提交字典
This commit is contained in:
parent
479388ff69
commit
9a70fb21dd
|
@ -1,5 +1,5 @@
|
|||
import request from '/@/utils/request';
|
||||
var model = 'kn-setting';
|
||||
var model = 'system-manager';
|
||||
export const getList = (params) => {
|
||||
return request({
|
||||
url: '/api/'+model+'/dict-biz/list',
|
||||
|
@ -55,7 +55,7 @@ export const add = (row) => {
|
|||
|
||||
export const update = (row) => {
|
||||
return request({
|
||||
url: '/api/'+model+'/dict-biz/submit',
|
||||
url: '/api/'+model+'/dict-biz/submit2',
|
||||
method: 'post',
|
||||
data: row
|
||||
})
|
||||
|
|
|
@ -241,7 +241,7 @@ onMounted(() => {
|
|||
Session.set('refresh-token', res.refresh_token);
|
||||
})
|
||||
}
|
||||
}, 10000);
|
||||
}, 5*60*1000);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ export const dynamicRoutes = [
|
|||
isKeepAlive: true,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin'],
|
||||
roles: ['admin', 'chief'],
|
||||
// icon: 'iconfont icon-xitongshezhi',
|
||||
zh: '系统管理',
|
||||
},
|
||||
|
@ -206,25 +206,24 @@ export const dynamicRoutes = [
|
|||
isKeepAlive: true,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin'],
|
||||
roles: ['admin', 'chief'],
|
||||
// icon: 'iconfont icon-caidan',
|
||||
zh: '普通管理员管理',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/systemManagement/dictionary',
|
||||
name: 'dictionaryManagement',
|
||||
component: () => import('/@/views/systemManagement/dictionary/index.vue'),
|
||||
path: '/system/dic',
|
||||
name: 'systemDic',
|
||||
component: () => import('/@/views/system/dic/index.vue'),
|
||||
meta: {
|
||||
title: 'Dictionary management',
|
||||
title: '字典管理',
|
||||
isLink: '',
|
||||
isHide: false,
|
||||
isKeepAlive: true,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin'],
|
||||
// icon: 'ele-ColdDrink',
|
||||
zh: '字典管理',
|
||||
roles: ['admin', 'chief'],
|
||||
// icon: 'ele-SetUp',
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -369,100 +368,6 @@ export const dynamicRoutes = [
|
|||
// },
|
||||
// ],
|
||||
// },
|
||||
{
|
||||
path: '/system',
|
||||
name: 'system',
|
||||
component: () => import('/@/layout/routerView/parent.vue'),
|
||||
redirect: '/system/menu',
|
||||
meta: {
|
||||
title: '系统设置',
|
||||
isLink: '',
|
||||
isHide: false,
|
||||
isKeepAlive: true,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin'],
|
||||
// icon: 'iconfont icon-xitongshezhi',
|
||||
zh:"系统设置"
|
||||
},
|
||||
children: [
|
||||
// {
|
||||
// path: '/system/menu',
|
||||
// name: 'systemMenu',
|
||||
// component: () => import('/@/views/system/menu/index.vue'),
|
||||
// meta: {
|
||||
// title: '菜单管理',
|
||||
// isLink: '',
|
||||
// isHide: false,
|
||||
// isKeepAlive: true,
|
||||
// isAffix: false,
|
||||
// isIframe: false,
|
||||
// roles: ['admin'],
|
||||
// icon: 'iconfont icon-caidan',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// path: '/system/role',
|
||||
// name: 'systemRole',
|
||||
// component: () => import('/@/views/system/role/index.vue'),
|
||||
// meta: {
|
||||
// title: '角色管理',
|
||||
// isLink: '',
|
||||
// isHide: false,
|
||||
// isKeepAlive: true,
|
||||
// isAffix: false,
|
||||
// isIframe: false,
|
||||
// roles: ['admin'],
|
||||
// icon: 'ele-ColdDrink',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// path: '/system/user',
|
||||
// name: 'systemUser',
|
||||
// component: () => import('/@/views/system/user/index.vue'),
|
||||
// meta: {
|
||||
// title: '用户管理',
|
||||
// isLink: '',
|
||||
// isHide: false,
|
||||
// isKeepAlive: true,
|
||||
// isAffix: false,
|
||||
// isIframe: false,
|
||||
// roles: ['admin'],
|
||||
// icon: 'iconfont icon-icon-',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// path: '/system/dept',
|
||||
// name: 'systemDept',
|
||||
// component: () => import('/@/views/system/dept/index.vue'),
|
||||
// meta: {
|
||||
// title: '部门管理',
|
||||
// isLink: '',
|
||||
// isHide: false,
|
||||
// isKeepAlive: true,
|
||||
// isAffix: false,
|
||||
// isIframe: false,
|
||||
// roles: ['admin'],
|
||||
// icon: 'ele-OfficeBuilding',
|
||||
// },
|
||||
// },
|
||||
{
|
||||
path: '/system/dic',
|
||||
name: 'systemDic',
|
||||
component: () => import('/@/views/system/dic/index.vue'),
|
||||
meta: {
|
||||
title: '字典管理',
|
||||
isLink: '',
|
||||
isHide: false,
|
||||
isKeepAlive: true,
|
||||
isAffix: false,
|
||||
isIframe: false,
|
||||
roles: ['admin'],
|
||||
// icon: 'ele-SetUp',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
@ -60,6 +60,8 @@ service.interceptors.response.use(
|
|||
ElMessage.error('网络超时');
|
||||
} else if (error.message == 'Network Error') {
|
||||
ElMessage.error('网络连接错误');
|
||||
} else if (error.response&&error.response.data.code == '500') {
|
||||
ElMessage.error(error.response.data.msg);
|
||||
} else{
|
||||
if (error.response.data.error_description) ElMessage.error(error.response.data.error_description);
|
||||
else {
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="字段Key">
|
||||
<el-input v-model="state.ruleForm.dictKey" placeholder="请输入字段名,拼接 ruleForm.list" clearable></el-input>
|
||||
<el-form-item label="字典值">
|
||||
<el-input v-model="state.ruleForm.dictKey" placeholder="请输入字段名,拼接 ruleForm.children" clearable></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||
|
@ -23,7 +23,7 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
||||
<el-row :gutter="35" v-for="(v, k) in state.ruleForm.list" :key="k">
|
||||
<el-row :gutter="35" v-for="(v, k) in state.ruleForm.children" :key="k">
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item :prop="`list[${k}].label`">
|
||||
<template #label>
|
||||
|
@ -43,8 +43,8 @@
|
|||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
||||
<el-form-item label="字典Key" :prop="`list[${k}].value`">
|
||||
<el-input v-model="v.dictKey" style="width: 100%" placeholder="请输入字典Key"> </el-input>
|
||||
<el-form-item label="字典值" :prop="`list[${k}].value`">
|
||||
<el-input v-model="v.dictKey" style="width: 100%" placeholder="请输入字典值"> </el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
@ -69,6 +69,7 @@
|
|||
<script setup name="systemDicDialog">
|
||||
import { RowAlign } from 'element-plus';
|
||||
import { reactive, ref } from 'vue';
|
||||
import { update } from '/@/api/system/dictbiz';
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
@ -79,9 +80,9 @@ const state = reactive({
|
|||
ruleForm: {
|
||||
dictValue: '', // 字典名称
|
||||
dictKey: '', // 字段名
|
||||
isSealed: 0, // 字典状态
|
||||
list: [], // 子集字段 + 属性值
|
||||
children: [], // 子集字段 + 属性值
|
||||
remark: '', // 字典描述
|
||||
status: false, // 字典状态
|
||||
},
|
||||
dialog: {
|
||||
isShowDialog: false,
|
||||
|
@ -91,37 +92,25 @@ const state = reactive({
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (type, row) => {
|
||||
|
||||
if (type === 'edit') {
|
||||
console.log(row);
|
||||
state.ruleForm = row;
|
||||
state.ruleForm.list = row.children;
|
||||
state.status = row.isSealed === 0;
|
||||
// if (row.fieldName === 'SYS_UERINFO') {
|
||||
// row.list = [
|
||||
// { id: Math.random(), label: 'sex', value: '1' },
|
||||
// { id: Math.random(), label: 'sex', value: '0' },
|
||||
// ];
|
||||
// } else {
|
||||
// row.list = [
|
||||
// { id: Math.random(), label: 'role', value: 'admin' },
|
||||
// { id: Math.random(), label: 'role', value: 'chief' },
|
||||
// { id: Math.random(), label: 'roleName', value: '超级管理员' },
|
||||
// { id: Math.random(), label: 'roleName', value: '主要管理员' },
|
||||
// ];
|
||||
// }
|
||||
// state.ruleForm = row;
|
||||
//如果children不存在或者为空,添加一个空对象
|
||||
if (!state.ruleForm.children || state.ruleForm.children.length === 0) {
|
||||
state.ruleForm.children=[{ dictValue: '', dictKey: '' }];
|
||||
}
|
||||
state.ruleForm.status = row.isSealed === 0;
|
||||
state.dialog.title = '修改字典';
|
||||
state.dialog.submitTxt = '修 改';
|
||||
} else {
|
||||
state.dialog.title = '新增字典';
|
||||
state.dialog.submitTxt = '新 增';
|
||||
// 清空表单,此项需加表单验证才能使用
|
||||
// nextTick(() => {
|
||||
// dicDialogFormRef.value.resetFields();
|
||||
// });
|
||||
if (!state.ruleForm.children || state.ruleForm.children.length === 0) {
|
||||
state.ruleForm.children=[{ dictValue: '', dictKey: '' }];
|
||||
}
|
||||
}
|
||||
state.dialog.isShowDialog = true;
|
||||
};
|
||||
|
@ -135,13 +124,26 @@ const onCancel = () => {
|
|||
};
|
||||
// 提交
|
||||
const onSubmit = () => {
|
||||
dicDialogFormRef.value.validate((valid) => {
|
||||
if (valid) {
|
||||
//判断是否有空对象,有则删除
|
||||
state.ruleForm.children.forEach((item, index) => {
|
||||
if (!item.dictValue && !item.dictKey) {
|
||||
state.ruleForm.children.splice(index, 1);
|
||||
}
|
||||
});
|
||||
//判断status是否为true,是则赋值为0,否则赋值为1
|
||||
state.ruleForm.isSealed = state.ruleForm.status ? 0 : 1;
|
||||
update(state.ruleForm).then((res) => {
|
||||
closeDialog();
|
||||
emit('refresh');
|
||||
// if (state.dialog.type === 'add') { }
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
// 新增行
|
||||
const onAddRow = () => {
|
||||
state.ruleForm.list.push({
|
||||
state.ruleForm.children.push({
|
||||
id: Math.random(),
|
||||
label: '',
|
||||
value: '',
|
||||
|
@ -149,7 +151,7 @@ const onAddRow = () => {
|
|||
};
|
||||
// 删除行
|
||||
const onDelRow = (k) => {
|
||||
state.ruleForm.list.splice(k, 1);
|
||||
state.ruleForm.children.splice(k, 1);
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<script setup name="systemDic">
|
||||
import { defineAsyncComponent, reactive, onMounted, ref } from 'vue';
|
||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||
import { getList } from '/@/api/system/dictbiz';
|
||||
import { getList,remove } from '/@/api/system/dictbiz';
|
||||
// 引入组件
|
||||
const DicDialog = defineAsyncComponent(() => import('/@/views/system/dic/dialog.vue'));
|
||||
|
||||
|
@ -95,12 +95,12 @@ const onRowDel = (row) => {
|
|||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
}).then(() => {
|
||||
remove(row.id).then(() => {
|
||||
getTableData();
|
||||
ElMessage.success('删除成功');
|
||||
})
|
||||
.catch(() => {});
|
||||
});
|
||||
}).catch(() => {});
|
||||
};
|
||||
// 分页改变
|
||||
const onHandleSizeChange = (val) => {
|
||||
|
|
Loading…
Reference in New Issue