提交字典

This commit is contained in:
yyhouc 2023-04-11 15:52:50 +08:00
parent 479388ff69
commit 9a70fb21dd
6 changed files with 54 additions and 145 deletions

View File

@ -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
}) })

View File

@ -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>

View File

@ -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',
},
},
],
},
], ],
}, },
]; ];

View File

@ -60,6 +60,8 @@ 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 if (error.response&&error.response.data.code == '500') {
ElMessage.error(error.response.data.msg);
} else{ } 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 {

View File

@ -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);
}
});
//statustrue01
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);
}; };
// //

View File

@ -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) => {