系统配置

This commit is contained in:
cwchen 2025-09-25 16:44:03 +08:00
parent f8bb8607c6
commit 920c4ec0b7
4 changed files with 256 additions and 24 deletions

37
src/api/system/setting.js Normal file
View File

@ -0,0 +1,37 @@
import request from '@/utils/request'
// 新增参数
export function addAPI(data) {
return request({
url: '/smartArchives/sys/config/add',
method: 'POST',
data: data,
})
}
// 修改参数
export function editAPI(data) {
return request({
url: '/smartArchives/sys/config/update',
method: 'POST',
data: data,
})
}
// 删除参数
export function deleteAPI(data) {
return request({
url: '/smartArchives/sys/config/del',
method: 'POST',
data: data,
})
}
// 参数列表
export function getListAPI(data) {
return request({
url: '/smartArchives/sys/config/list',
method: 'GET',
params: data,
})
}

View File

@ -0,0 +1,192 @@
<template>
<!-- 小型弹窗用于完成删除保存等操作 -->
<el-dialog class="l-dialog" :class="lDialog" :title="title" :visible.sync="dialogVisible" :showClose="true"
:closeOnClickModal="false" @close="handleClose" :append-to-body="true">
<div>
<el-form :model="form" :rules="rules" ref="ruleForm" label-width="110px">
<el-form-item label="参数名称" prop="configName">
<el-input class="form-item" v-model="form.configName" clearable show-word-limit
placeholder="请输入参数名称" maxlength="32" :disabled="isAdd === 'edit'"></el-input>
</el-form-item>
<el-form-item label="参数编码" prop="configCode">
<el-input class="form-item" v-model="form.configCode" clearable show-word-limit
placeholder="请输入参数编码" maxlength="32" :disabled="isAdd === 'edit'"></el-input>
</el-form-item>
<el-form-item label="状态" prop="useStatus">
<el-radio v-model="form.useStatus" label="0">启用</el-radio>
<el-radio v-model="form.useStatus" label="1">禁用</el-radio>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button class="clear-btn" @click="handleClose" :disabled="disabled">取消</el-button>
<el-button type="primary" class="search-btn" :disabled="disabled"
@click="submitForm('ruleForm')">确认</el-button>
</span>
</el-dialog>
</template>
<script>
import _ from 'lodash'
import {
addAPI,
editAPI,
} from '@/api/system/setting'
export default {
name: "SettingForm",
props: ["width", "dataForm", "title", "disabled", "isAdd", "rowData"],
dicts: ['dimension', 'file_related_type'],
data() {
return {
lDialog: this.width > 500 ? "w700" : "w500",
dialogVisible: true,
isDisabled: true,
form: {
configName: null,
configCode: null,
useStatus: '0',
},
loading: null,
rules: {
configName: [
{ required: true, message: '请输入参数名称', trigger: 'blur' }
],
configCode: [
{ required: true, message: '请输入参数编码', trigger: 'blur' }
],
},
};
},
created() {
this.initFormData();
},
methods: {
/** 初始化表单数据 */
initFormData() {
if (this.isAdd === 'edit' && this.rowData) {
console.log(this.rowData);
//
this.form = {
id: this.rowData.id,
configName: this.rowData.configName || null,
configCode: this.rowData.configCode || null,
useStatus: this.rowData.useStatus || '0',
};
} else {
//
this.form = {
configName: null,
configCode: null,
useStatus: '0',
};
}
},
/*关闭弹窗 */
handleClose() {
this.dialogVisible = false;
this.$emit("closeDialog");
setTimeout(() => {
this.dialogVisible = true;
});
},
/**确认弹窗 */
sureBtnClick() {
this.dialogVisible = false;
this.$emit("closeDialog");
setTimeout(() => {
this.dialogVisible = true;
});
},
/**重置表单*/
reset() {
this.form = {
configName: null,
configCode: null,
useStatus: '0',
};
this.resetForm("ruleForm");
},
handleReuslt(res) {
this.$modal.msgSuccess(res.msg);
this.reset();
this.$emit('handleQuery');
this.handleClose();
},
/**验证 */
submitForm(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
//
this.loading = this.$loading({
lock: true,
text: "数据提交中,请稍候...",
background: 'rgba(0,0,0,0.5)',
target: this.$el.querySelector('.el-dialog') || document.body
})
let params = _.cloneDeep(this.form);
if (this.isAdd === 'add') {
addAPI(params).then(res => {
this.loading.close();
if (res.code === 200) {
this.handleReuslt(res);
} else {
this.$modal.msgError(res.msg);
}
}).catch(error => {
this.loading.close();
// this.$modal.msgError('');
});
} else {
editAPI(params).then(res => {
this.loading.close();
if (res.code === 200) {
this.handleReuslt(res);
} else {
this.$modal.msgError(res.msg);
}
}).catch(error => {
this.loading.close();
// this.$modal.msgError('');
});
}
}
});
}
}
};
</script>
<style lang="scss" scoped>
.w700 ::v-deep .el-dialog {
width: 700px;
}
.w500 ::v-deep .el-dialog {
width: 500px;
}
.w500 ::v-deep .el-dialog__header,
.w700 ::v-deep .el-dialog__header {
// background: #eeeeee;
.el-dialog__title {
font-size: 16px;
}
}
.yxq .el-range-separator {
margin-right: 7px !important;
}
.el-date-editor--daterange.el-input__inner {
width: 260px;
}
.form-item {
width: 100%;
}
.select-style {
display: flex;
justify-content: space-between;
}
</style>

View File

@ -2,16 +2,14 @@ export const formLabel = [
{ {
isShow: false, // 是否展示label isShow: false, // 是否展示label
f_type: 'ipt', f_type: 'ipt',
f_label: '据类型名称', f_label: '数名称',
f_model: 'dataTypeName', f_model: 'configName',
f_max: 32, f_max: 32,
}, },
] ]
export const columnsList = [ export const columnsList = [
{ t_props: 'pName', t_label: '数据分类类型' }, { t_props: 'configName', t_label: '参数名称' },
{ t_props: 'dataTypeName', t_label: '数据类型名称' }, { t_props: 'configCode', t_label: '参数编码' },
{ t_props: 'updateUserName', t_label: '更新人' }, { t_slot: 'useStatus', t_label: '状态' },
{ t_props: 'updateTime', t_label: '更新时间' },
{ t_props: 'remark', t_label: '备注' }
] ]

View File

@ -1,29 +1,34 @@
<template> <template>
<!-- 数据分类管理 --> <!-- 数据分类管理 -->
<div class="app-container"> <div class="app-container">
<TableModel :formLabel="formLabel" :showOperation="true" :showRightTools="true" ref="dataClassTableRef" <TableModel :formLabel="formLabel" :showOperation="true" :showRightTools="true" ref="settingTableRef"
:columnsList="columnsList" :request-api="getListDataClassAPI"> :columnsList="columnsList" :request-api="getListAPI">
<template slot="btn"> <template slot="btn">
<el-button plain size="mini" type="primary" icon="el-icon-plus" v-hasPermi="['data:classify:add']" <el-button plain size="mini" type="primary" icon="el-icon-plus" v-hasPermi="['sys:config:add']"
@click="handleAdd"> @click="handleAdd">
新增 新增
</el-button> </el-button>
</template> </template>
<template slot="useStatus" slot-scope="{ data }">
<el-tag :type="data.useStatus === '0' ? 'success' : 'danger'">
{{ data.useStatus === '0' ? '启用' : '禁用' }}
</el-tag>
</template>
<template slot="handle" slot-scope="{ data }"> <template slot="handle" slot-scope="{ data }">
<el-button plain size="mini" type="primary" icon="el-icon-edit" v-hasPermi="['data:classify:update']" <el-button plain size="mini" type="primary" icon="el-icon-edit" v-hasPermi="['sys:config:update']"
@click="handleUpdate(data)"> @click="handleUpdate(data)">
修改 修改
</el-button> </el-button>
<el-button plain size="mini" type="danger" icon="el-icon-delete" v-hasPermi="['data:classify:del']" <el-button plain size="mini" type="danger" icon="el-icon-delete" v-hasPermi="['sys:config:del']"
@click="handleDelete(data)"> @click="handleDelete(data)" v-if="data.id > 4">
删除 删除
</el-button> </el-button>
</template> </template>
</TableModel> </TableModel>
<!-- 新增/编辑 --> <!-- 新增/编辑 -->
<!-- <DataClassForm v-if="isflag" :isAdd="isAdd" :rowData="row" @handleQuery="handleQuery" :title="title" <SettingForm v-if="isflag" :isAdd="isAdd" :rowData="row" @handleQuery="handleQuery" :title="title"
@closeDialog="closeDialog" @showColose="showColose" :dataForm="row" :disabled="loading" :width="600" /> --> @closeDialog="closeDialog" @showColose="showColose" :dataForm="row" :disabled="loading" :width="600" />
</div> </div>
</template> </template>
@ -31,23 +36,23 @@
import TableModel from '@/components/TableModel' import TableModel from '@/components/TableModel'
import { columnsList, formLabel } from './config' import { columnsList, formLabel } from './config'
import { import {
deleteDataClassAPI, deleteAPI,
getListDataClassAPI, getListAPI,
} from '@/api/data-collect/data-class-manage' } from '@/api/system/setting'
// import DataClassForm from './prop/dataClassForm' import SettingForm from './components/settingForm'
export default { export default {
name: 'DataClassManage', name: 'DataClassManage',
components: { components: {
TableModel, TableModel,
// DataClassForm SettingForm
}, },
data() { data() {
return { return {
formLabel, formLabel,
columnsList, columnsList,
getListDataClassAPI, getListAPI,
title: "", title: "",
isflag: false, isflag: false,
isAdd: '', isAdd: '',
@ -82,14 +87,14 @@ export default {
}, },
/* 搜索操作 */ /* 搜索操作 */
handleQuery() { handleQuery() {
this.$refs.dataClassTableRef.getTableList() this.$refs.settingTableRef.getTableList()
}, },
/** 删除操作 */ /** 删除操作 */
handleDelete(row) { handleDelete(row) {
this.$modal.confirm(`是否确认删除据类型名称为"${row.dataTypeName}"的数据项?`).then(() => { this.$modal.confirm(`是否确认删除数名称为"${row.configName}"的数据项?`).then(() => {
// //
this.$modal.loading("正在删除,请稍候..."); this.$modal.loading("正在删除,请稍候...");
deleteDataClassAPI({ id: row.id }).then(res => { deleteAPI({ id: row.id }).then(res => {
this.$modal.closeLoading(); this.$modal.closeLoading();
if (res.code === 200) { if (res.code === 200) {
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");