This commit is contained in:
yyhouc 2023-04-11 10:05:38 +08:00
parent 91cc91ab33
commit 073a83dbc0
5 changed files with 182 additions and 169 deletions

87
src/api/system/dictbiz.js Normal file
View File

@ -0,0 +1,87 @@
import request from '/@/utils/request';
var model = 'kn-setting';
export const getList = (params) => {
return request({
url: '/api/'+model+'/dict-biz/list',
method: 'get',
params: {
...params,
}
})
}
export const getParentList = (current, size, params) => {
return request({
url: '/api/'+model+'/dict-biz/parent-list',
method: 'get',
params: {
...params,
current,
size,
}
})
}
export const getChildList = (current, size, parentId, params) => {
return request({
url: '/api/'+model+'/dict-biz/child-list',
method: 'get',
params: {
...params,
current,
size,
parentId: parentId,
}
})
}
export const remove = (ids) => {
return request({
url: '/api/'+model+'/dict-biz/remove',
method: 'post',
params: {
ids,
}
})
}
export const add = (row) => {
return request({
url: '/api/'+model+'/dict-biz/submit',
method: 'post',
data: row
})
}
export const update = (row) => {
return request({
url: '/api/'+model+'/dict-biz/submit',
method: 'post',
data: row
})
}
export const getDict = (id) => {
return request({
url: '/api/'+model+'/dict-biz/detail',
method: 'get',
params: {
id,
}
})
}
export const getDictTree = () => {
return request({
url: '/api/'+model+'/dict-biz/tree?code=DICT',
method: 'get'
})
}
export const getDictionary = (params) => {
return request({
url: '/api/'+model+'/dict-biz/dictionary',
method: 'get',
params,
})
}

View File

@ -226,22 +226,23 @@ 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'],
{
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',
// },
// children: [
zh:"系统设置"
},
children: [
// {
// path: '/system/menu',
// name: 'systemMenu',
@ -302,23 +303,23 @@ export const dynamicRoutes = [
// 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'],
{
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

@ -1,133 +1,65 @@
<template>
<div class="system-dic-dialog-container">
<el-dialog :title="state.dialog.title"
v-model="state.dialog.isShowDialog"
width="769px">
<el-alert title="半成品,交互过于复杂,请自行扩展!"
<el-dialog :title="state.dialog.title" v-model="state.dialog.isShowDialog" width="769px">
<!-- <el-alert title="半成品,交互过于复杂,请自行扩展!"
type="warning"
:closable="false"
class="mb20"> </el-alert>
<el-form ref="dicDialogFormRef"
:model="state.ruleForm"
size="default"
label-width="90px">
class="mb20"> </el-alert> -->
<el-form ref="dicDialogFormRef" :model="state.ruleForm" size="default" label-width="90px">
<el-row :gutter="35">
<el-col :xs="24"
:sm="12"
:md="12"
:lg="12"
:xl="12"
class="mb20">
<el-form-item label="字典名称">
<el-input v-model="state.ruleForm.dicName"
placeholder="请输入字典名称"
clearable></el-input>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="字典名">
<el-input v-model="state.ruleForm.dictValue" placeholder="请输入字典名称" clearable></el-input>
</el-form-item>
</el-col>
<el-col :xs="24"
:sm="12"
:md="12"
:lg="12"
:xl="12"
class="mb20">
<el-form-item label="字段名">
<el-input v-model="state.ruleForm.fieldName"
placeholder="请输入字段名,拼接 ruleForm.list"
clearable></el-input>
<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>
</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-form-item label="字典状态">
<el-switch v-model="state.ruleForm.status"
inline-prompt
active-text="启"
inactive-text="禁"></el-switch>
<el-switch v-model="state.ruleForm.status" inline-prompt active-text="启" inactive-text="禁"></el-switch>
</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-col :xs="24"
:sm="12"
:md="12"
:lg="12"
:xl="12"
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-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item :prop="`list[${k}].label`">
<template #label>
<el-button type="primary"
circle
size="small"
@click="onAddRow"
v-if="k === 0">
<el-button type="primary" circle size="small" @click="onAddRow" v-if="k === 0">
<el-icon>
<ele-Plus />
</el-icon>
</el-button>
<el-button type="danger"
circle
size="small"
@click="onDelRow(k)"
v-else>
<el-button type="danger" circle size="small" @click="onDelRow(k)" v-else>
<el-icon>
<ele-Delete />
</el-icon>
</el-button>
<span class="ml10"></span>
<span class="ml10">典名</span>
</template>
<el-input v-model="v.label"
style="width: 100%"
placeholder="请输入字段名"> </el-input>
<el-input v-model="v.dictValue" style="width: 100%" placeholder="请输入字段名"> </el-input>
</el-form-item>
</el-col>
<el-col :xs="24"
:sm="12"
:md="12"
:lg="12"
:xl="12"
class="mb20">
<el-form-item label="属性"
:prop="`list[${k}].value`">
<el-input v-model="v.value"
style="width: 100%"
placeholder="请输入属性值"> </el-input>
<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>
</el-col>
</el-row>
</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-form-item label="字典描述">
<el-input v-model="state.ruleForm.describe"
type="textarea"
placeholder="请输入字典描述"
maxlength="150"></el-input>
<el-input v-model="state.ruleForm.remark" type="textarea" placeholder="请输入字典描述" maxlength="150"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="onCancel"
size="default"> </el-button>
<el-button type="primary"
@click="onSubmit"
size="default">{{ state.dialog.submitTxt }}</el-button>
<el-button @click="onCancel" size="default"> </el-button>
<el-button type="primary" @click="onSubmit" size="default">{{ state.dialog.submitTxt }}</el-button>
</span>
</template>
</el-dialog>
@ -135,6 +67,7 @@
</template>
<script setup name="systemDicDialog">
import { RowAlign } from 'element-plus';
import { reactive, ref } from 'vue';
// /
@ -144,11 +77,11 @@ const emit = defineEmits(['refresh']);
const dicDialogFormRef = ref();
const state = reactive({
ruleForm: {
dicName: '', //
fieldName: '', //
status: true, //
dictValue: '', //
dictKey: '', //
isSealed: 0, //
list: [], // +
describe: '', //
remark: '', //
},
dialog: {
isShowDialog: false,
@ -160,21 +93,26 @@ const state = reactive({
//
const openDialog = (type, row) => {
if (type === 'edit') {
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: '主要管理员' },
];
}
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;
state.dialog.title = '修改字典';
state.dialog.submitTxt = '修 改';
} else {

View File

@ -18,16 +18,15 @@
</div>
<el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
<el-table-column type="index" label="序号" width="50" />
<el-table-column prop="dicName" label="字典名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="fieldName" label="字段名" show-overflow-tooltip></el-table-column>
<el-table-column prop="status" label="字典状态" show-overflow-tooltip>
<el-table-column prop="dictValue" label="字典名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="dictKey" label="字典值" show-overflow-tooltip></el-table-column>
<el-table-column prop="isSealed" label="字典状态" show-overflow-tooltip>
<template #default="scope">
<el-tag type="success" v-if="scope.row.status">启用</el-tag>
<el-tag type="success" v-if="scope.row.isSealed===0">启用</el-tag>
<el-tag type="info" v-else>禁用</el-tag>
</template>
</el-table-column>
<el-table-column prop="describe" label="字典描述" show-overflow-tooltip></el-table-column>
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column>
<el-table-column prop="remark" label="字典描述" show-overflow-tooltip></el-table-column>
<el-table-column label="操作" width="100">
<template #default="scope">
<el-button size="small" text type="primary" @click="onOpenEditDic('edit', scope.row)">修改</el-button>
@ -35,7 +34,7 @@
</template>
</el-table-column>
</el-table>
<el-pagination
<!-- <el-pagination
@size-change="onHandleSizeChange"
@current-change="onHandleCurrentChange"
class="mt15"
@ -47,7 +46,7 @@
layout="total, sizes, prev, pager, next, jumper"
:total="state.tableData.total"
>
</el-pagination>
</el-pagination> -->
</el-card>
<DicDialog ref="dicDialogRef" @refresh="getTableData()" />
</div>
@ -56,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';
//
const DicDialog = defineAsyncComponent(() => import('/@/views/system/dic/dialog.vue'));
@ -77,22 +76,10 @@ const state = reactive({
//
const getTableData = () => {
state.tableData.loading = true;
const data = [];
for (let i = 0; i < 2; i++) {
data.push({
dicName: i === 0 ? '角色标识' : '用户性别',
fieldName: i === 0 ? 'SYS_ROLE' : 'SYS_UERINFO',
describe: i === 0 ? '这是角色字典' : '这是用户性别字典',
status: true,
createTime: new Date().toLocaleString(),
list: [],
});
}
state.tableData.data = data;
state.tableData.total = state.tableData.data.length;
setTimeout(() => {
getList().then((res) => {
state.tableData.data = res;
state.tableData.loading = false;
}, 500);
});
};
//
const onOpenAddDic = (type) => {

View File

@ -30,7 +30,7 @@ const viteConfig = defineConfig((mode) => {
hmr: true,
proxy: {
'/api': {
target: 'http://192.168.31.14:9090',
target: 'http://192.168.31.250:9090',
ws: true,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),