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