1. 完成字典类型的迁移

2. 开始字典数据的迁移
This commit is contained in:
YunaiV
2021-01-12 19:55:07 +08:00
parent f7f27c9693
commit f6bb33863f
27 changed files with 754 additions and 223 deletions

View File

@ -3,7 +3,7 @@ import request from '@/utils/request'
// 查询字典类型列表
export function listType(query) {
return request({
url: '/system/dict/type/list',
url: '/system/dict-type/page',
method: 'get',
params: query
})
@ -12,7 +12,7 @@ export function listType(query) {
// 查询字典类型详细
export function getType(dictId) {
return request({
url: '/system/dict/type/' + dictId,
url: '/system/dict-type/get?id=' + dictId,
method: 'get'
})
}
@ -20,7 +20,7 @@ export function getType(dictId) {
// 新增字典类型
export function addType(data) {
return request({
url: '/system/dict/type',
url: '/system/dict-type/create',
method: 'post',
data: data
})
@ -29,8 +29,8 @@ export function addType(data) {
// 修改字典类型
export function updateType(data) {
return request({
url: '/system/dict/type',
method: 'put',
url: '/system/dict-type/update',
method: 'post',
data: data
})
}
@ -38,23 +38,15 @@ export function updateType(data) {
// 删除字典类型
export function delType(dictId) {
return request({
url: '/system/dict/type/' + dictId,
method: 'delete'
})
}
// 清理参数缓存
export function clearCache() {
return request({
url: '/system/dict/type/clearCache',
method: 'delete'
url: '/system/dict-type/delete?id=' + dictId,
method: 'post'
})
}
// 导出字典类型
export function exportType(query) {
return request({
url: '/system/dict/type/export',
url: '/system/dict-type/export',
method: 'get',
params: query
})
@ -63,7 +55,7 @@ export function exportType(query) {
// 获取字典选择框列表
export function optionselect() {
return request({
url: '/system/dict/type/optionselect',
url: '/system/dict-type/optionselect',
method: 'get'
})
}
}

View File

@ -1,9 +1,9 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="字典名称" prop="dictName">
<el-form-item label="字典名称" prop="name">
<el-input
v-model="queryParams.dictName"
v-model="queryParams.name"
placeholder="请输入字典名称"
clearable
size="small"
@ -11,9 +11,9 @@
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="字典类型" prop="dictType">
<el-form-item label="字典类型" prop="type">
<el-input
v-model="queryParams.dictType"
v-model="queryParams.type"
placeholder="请输入字典类型"
clearable
size="small"
@ -30,10 +30,10 @@
style="width: 240px"
>
<el-option
v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
v-for="dict in statusDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
@ -65,26 +65,6 @@
v-hasPermi="['system:dict:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:dict:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:dict:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
@ -94,26 +74,16 @@
v-hasPermi="['system:dict:export']"
>导出</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-refresh"
size="mini"
@click="handleClearCache"
v-hasPermi="['system:dict:remove']"
>清理缓存</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="字典编号" align="center" prop="dictId" />
<el-table-column label="字典名称" align="center" prop="dictName" :show-overflow-tooltip="true" />
<el-table v-loading="loading" :data="typeList">
<el-table-column label="字典编号" align="center" prop="id" />
<el-table-column label="字典名称" align="center" prop="name" :show-overflow-tooltip="true" />
<el-table-column label="字典类型" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<router-link :to="'/dict/type/data/' + scope.row.dictId" class="link-type">
<span>{{ scope.row.dictType }}</span>
<router-link :to="'/dict/type/data/' + scope.row.id" class="link-type">
<span>{{ scope.row.type }}</span>
</router-link>
</template>
</el-table-column>
@ -147,7 +117,7 @@
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
@ -155,19 +125,19 @@
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="字典名称" prop="dictName">
<el-input v-model="form.dictName" placeholder="请输入字典名称" />
<el-form-item label="字典名称" prop="name">
<el-input v-model="form.name" placeholder="请输入字典名称" />
</el-form-item>
<el-form-item label="字典类型" prop="dictType">
<el-input v-model="form.dictType" placeholder="请输入字典类型" />
<el-form-item label="字典类型" prop="type">
<el-input v-model="form.type" placeholder="请输入字典类型" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictValue"
>{{dict.dictLabel}}</el-radio>
v-for="dict in statusDictDatas"
:key="parseInt(dict.value)"
:label="parseInt(dict.value)"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="备注" prop="remark">
@ -183,7 +153,10 @@
</template>
<script>
import { listType, getType, delType, addType, updateType, exportType, clearCache } from "@/api/system/dict/type";
import { listType, getType, delType, addType, updateType, exportType } from "@/api/system/dict/type";
import { SysCommonStatusEnum } from '@/utils/constants'
import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
export default {
name: "Dict",
@ -191,12 +164,6 @@ export default {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
@ -213,45 +180,50 @@ export default {
dateRange: [],
// 查询参数
queryParams: {
pageNum: 1,
pageNo: 1,
pageSize: 10,
dictName: undefined,
dictType: undefined,
name: undefined,
type: undefined,
status: undefined
},
// 表单参数
form: {},
// 表单校验
rules: {
dictName: [
name: [
{ required: true, message: "字典名称不能为空", trigger: "blur" }
],
dictType: [
type: [
{ required: true, message: "字典类型不能为空", trigger: "blur" }
]
}
},
// 枚举
CommonStatusEnum: SysCommonStatusEnum,
// 数据字典
statusDictDatas: getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)
};
},
created() {
this.getList();
this.getDicts("sys_normal_disable").then(response => {
this.statusOptions = response.data;
});
},
methods: {
/** 查询字典类型列表 */
getList() {
this.loading = true;
listType(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.typeList = response.rows;
this.total = response.total;
listType(this.addDateRange(this.queryParams, [
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
])).then(response => {
this.typeList = response.data.list;
this.total = response.data.total;
this.loading = false;
}
);
},
// 字典状态字典翻译
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status);
return getDictDataLabel(DICT_TYPE.SYS_COMMON_STATUS, row.status)
},
// 取消按钮
cancel() {
@ -261,17 +233,17 @@ export default {
// 表单重置
reset() {
this.form = {
dictId: undefined,
dictName: undefined,
dictType: undefined,
status: "0",
id: undefined,
name: undefined,
type: undefined,
status: SysCommonStatusEnum.ENABLE,
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
@ -286,17 +258,11 @@ export default {
this.open = true;
this.title = "添加字典类型";
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.dictId)
this.single = selection.length!=1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const dictId = row.dictId || this.ids
getType(dictId).then(response => {
const id = row.id;
getType(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改字典类型";
@ -306,7 +272,7 @@ export default {
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.dictId != undefined) {
if (this.form.id !== undefined) {
updateType(this.form).then(response => {
this.msgSuccess("修改成功");
this.open = false;
@ -324,13 +290,13 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
const dictIds = row.dictId || this.ids;
this.$confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?', "警告", {
const ids = row.id || this.ids;
this.$confirm('是否确认删除字典编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delType(dictIds);
return delType(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
@ -357,4 +323,4 @@ export default {
}
}
};
</script>
</script>

View File

@ -141,12 +141,6 @@ export default {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数