提交字典

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';
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
})

View File

@ -241,7 +241,7 @@ onMounted(() => {
Session.set('refresh-token', res.refresh_token);
})
}
}, 10000);
}, 5*60*1000);
});
</script>

View File

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

View File

@ -60,7 +60,9 @@ service.interceptors.response.use(
ElMessage.error('网络超时');
} else if (error.message == 'Network 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);
else {
//if (error.response.data) ElMessage.error(error.response.statusText);

View File

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

View File

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