mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
1. 完成字典数据的迁移
This commit is contained in:
parent
f6bb33863f
commit
ec00936532
@ -3,7 +3,7 @@ import request from '@/utils/request'
|
||||
// 查询字典数据列表
|
||||
export function listData(query) {
|
||||
return request({
|
||||
url: '/system/dict/data/list',
|
||||
url: '/system/dict-data/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
@ -12,7 +12,7 @@ export function listData(query) {
|
||||
// 查询字典数据详细
|
||||
export function getData(dictCode) {
|
||||
return request({
|
||||
url: '/system/dict/data/' + dictCode,
|
||||
url: '/system/dict-data/get?id=' + dictCode,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@ -20,7 +20,7 @@ export function getData(dictCode) {
|
||||
// 根据字典类型查询字典数据信息
|
||||
export function getDicts(dictType) {
|
||||
return request({
|
||||
url: '/system/dict/data/type/' + dictType,
|
||||
url: '/system/dict-data/type/' + dictType,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@ -28,7 +28,7 @@ export function getDicts(dictType) {
|
||||
// 新增字典数据
|
||||
export function addData(data) {
|
||||
return request({
|
||||
url: '/system/dict/data',
|
||||
url: '/system/dict-data/create',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
@ -37,8 +37,8 @@ export function addData(data) {
|
||||
// 修改字典数据
|
||||
export function updateData(data) {
|
||||
return request({
|
||||
url: '/system/dict/data',
|
||||
method: 'put',
|
||||
url: '/system/dict-data/update',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
@ -46,8 +46,8 @@ export function updateData(data) {
|
||||
// 删除字典数据
|
||||
export function delData(dictCode) {
|
||||
return request({
|
||||
url: '/system/dict/data/' + dictCode,
|
||||
method: 'delete'
|
||||
url: '/system/dict-data/delete?id=' + dictCode,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,9 @@ export function exportType(query) {
|
||||
}
|
||||
|
||||
// 获取字典选择框列表
|
||||
export function optionselect() {
|
||||
export function listAllSimple() {
|
||||
return request({
|
||||
url: '/system/dict-type/optionselect',
|
||||
url: '/system/dict-type/list-all-simple',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
@ -5,15 +5,15 @@
|
||||
<el-select v-model="queryParams.dictType" size="small">
|
||||
<el-option
|
||||
v-for="item in typeOptions"
|
||||
:key="item.dictId"
|
||||
:label="item.dictName"
|
||||
:value="item.dictType"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.type"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="字典标签" prop="dictLabel">
|
||||
<el-form-item label="字典标签" prop="label">
|
||||
<el-input
|
||||
v-model="queryParams.dictLabel"
|
||||
v-model="queryParams.label"
|
||||
placeholder="请输入字典标签"
|
||||
clearable
|
||||
size="small"
|
||||
@ -24,9 +24,9 @@
|
||||
<el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@ -46,26 +46,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"
|
||||
@ -78,12 +58,11 @@
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="dataList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="字典编码" align="center" prop="dictCode" />
|
||||
<el-table-column label="字典标签" align="center" prop="dictLabel" />
|
||||
<el-table-column label="字典键值" align="center" prop="dictValue" />
|
||||
<el-table-column label="字典排序" align="center" prop="dictSort" />
|
||||
<el-table v-loading="loading" :data="dataList" >
|
||||
<el-table-column label="字典编码" align="center" prop="id" />
|
||||
<el-table-column label="字典标签" align="center" prop="label" />
|
||||
<el-table-column label="字典键值" align="center" prop="value" />
|
||||
<el-table-column label="字典排序" align="center" prop="sort" />
|
||||
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
|
||||
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
@ -114,7 +93,7 @@
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
@ -125,22 +104,22 @@
|
||||
<el-form-item label="字典类型">
|
||||
<el-input v-model="form.dictType" :disabled="true" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数据标签" prop="dictLabel">
|
||||
<el-input v-model="form.dictLabel" placeholder="请输入数据标签" />
|
||||
<el-form-item label="数据标签" prop="label">
|
||||
<el-input v-model="form.label" placeholder="请输入数据标签" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数据键值" prop="dictValue">
|
||||
<el-input v-model="form.dictValue" placeholder="请输入数据键值" />
|
||||
<el-form-item label="数据键值" prop="value">
|
||||
<el-input v-model="form.value" placeholder="请输入数据键值" />
|
||||
</el-form-item>
|
||||
<el-form-item label="显示排序" prop="dictSort">
|
||||
<el-input-number v-model="form.dictSort" controls-position="right" :min="0" />
|
||||
<el-form-item label="显示排序" prop="sort">
|
||||
<el-input-number v-model="form.sort" controls-position="right" :min="0" />
|
||||
</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">
|
||||
@ -157,7 +136,10 @@
|
||||
|
||||
<script>
|
||||
import { listData, getData, delData, addData, updateData, exportData } from "@/api/system/dict/data";
|
||||
import { listType, getType } from "@/api/system/dict/type";
|
||||
import { listAllSimple, getType } from "@/api/system/dict/type";
|
||||
|
||||
import { SysCommonStatusEnum } from '@/utils/constants'
|
||||
import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
|
||||
|
||||
export default {
|
||||
name: "Data",
|
||||
@ -165,12 +147,6 @@ export default {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
@ -189,7 +165,7 @@ export default {
|
||||
typeOptions: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
dictName: undefined,
|
||||
dictType: undefined,
|
||||
@ -199,53 +175,55 @@ export default {
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
dictLabel: [
|
||||
label: [
|
||||
{ required: true, message: "数据标签不能为空", trigger: "blur" }
|
||||
],
|
||||
dictValue: [
|
||||
value: [
|
||||
{ required: true, message: "数据键值不能为空", trigger: "blur" }
|
||||
],
|
||||
dictSort: [
|
||||
sort: [
|
||||
{ required: true, message: "数据顺序不能为空", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// 枚举
|
||||
CommonStatusEnum: SysCommonStatusEnum,
|
||||
// 数据字典
|
||||
statusDictDatas: getDictDatas(DICT_TYPE.SYS_COMMON_STATUS)
|
||||
};
|
||||
},
|
||||
created() {
|
||||
const dictId = this.$route.params && this.$route.params.dictId;
|
||||
this.getType(dictId);
|
||||
this.getTypeList();
|
||||
this.getDicts("sys_normal_disable").then(response => {
|
||||
this.statusOptions = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询字典类型详细 */
|
||||
getType(dictId) {
|
||||
getType(dictId).then(response => {
|
||||
this.queryParams.dictType = response.data.dictType;
|
||||
this.defaultDictType = response.data.dictType;
|
||||
this.queryParams.dictType = response.data.type;
|
||||
this.defaultDictType = response.data.type;
|
||||
this.getList();
|
||||
});
|
||||
},
|
||||
/** 查询字典类型列表 */
|
||||
getTypeList() {
|
||||
listType().then(response => {
|
||||
this.typeOptions = response.rows;
|
||||
listAllSimple().then(response => {
|
||||
this.typeOptions = response.data;
|
||||
});
|
||||
},
|
||||
/** 查询字典数据列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listData(this.queryParams).then(response => {
|
||||
this.dataList = response.rows;
|
||||
this.total = response.total;
|
||||
this.dataList = 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() {
|
||||
@ -255,18 +233,18 @@ export default {
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
dictCode: undefined,
|
||||
dictLabel: undefined,
|
||||
dictValue: undefined,
|
||||
dictSort: 0,
|
||||
status: "0",
|
||||
id: undefined,
|
||||
label: undefined,
|
||||
value: undefined,
|
||||
sort: 0,
|
||||
status: SysCommonStatusEnum.ENABLE,
|
||||
remark: undefined
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
@ -282,17 +260,11 @@ export default {
|
||||
this.title = "添加字典数据";
|
||||
this.form.dictType = this.queryParams.dictType;
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.dictCode)
|
||||
this.single = selection.length!=1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const dictCode = row.dictCode || this.ids
|
||||
getData(dictCode).then(response => {
|
||||
const id = row.id || this.ids
|
||||
getData(id).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改字典数据";
|
||||
@ -302,7 +274,7 @@ export default {
|
||||
submitForm: function() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.form.dictCode != undefined) {
|
||||
if (this.form.id !== undefined) {
|
||||
updateData(this.form).then(response => {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
@ -320,13 +292,13 @@ export default {
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const dictCodes = row.dictCode || this.ids;
|
||||
this.$confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?', "警告", {
|
||||
const ids = row.id;
|
||||
this.$confirm('是否确认删除字典编码为"' + ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return delData(dictCodes);
|
||||
return delData(ids);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
@ -347,4 +319,4 @@ export default {
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
@ -314,12 +314,6 @@ export default {
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
})
|
||||
},
|
||||
/** 清理缓存按钮操作 */
|
||||
handleClearCache() {
|
||||
clearCache().then(response => {
|
||||
this.msgSuccess("清理成功");
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -2,11 +2,9 @@ package cn.iocoder.dashboard.modules.system.controller.dict;
|
||||
|
||||
import cn.iocoder.dashboard.common.pojo.CommonResult;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeCreateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypePageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.*;
|
||||
import cn.iocoder.dashboard.modules.system.convert.dict.SysDictTypeConvert;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict.SysDictTypeDO;
|
||||
import cn.iocoder.dashboard.modules.system.service.dict.SysDictTypeService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -15,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.dashboard.common.pojo.CommonResult.success;
|
||||
|
||||
@ -69,14 +68,13 @@ public class SysDictTypeController {
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 获取字典选择框列表
|
||||
// */
|
||||
// @GetMapping("/optionselect")
|
||||
// public AjaxResult optionselect() {
|
||||
// List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
// return AjaxResult.success(dictTypes);
|
||||
// }
|
||||
@GetMapping("/list-all-simple")
|
||||
@ApiOperation(value = "获得全部字典类型列表", notes = "包括开启 + 禁用的字典类型,主要用于前端的下拉选项")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
public CommonResult<List<SysDictTypeSimpleRespVO>> listSimpleDictTypes() {
|
||||
List<SysDictTypeDO> list = dictTypeService.listDictTypes();
|
||||
return success(SysDictTypeConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
//
|
||||
// @Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||
|
@ -13,9 +13,12 @@ import lombok.NoArgsConstructor;
|
||||
public class SysDictTypeSimpleRespVO {
|
||||
|
||||
@ApiModelProperty(value = "字典类型编号", required = true, example = "1024")
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "字典类型名称", required = true, example = "芋道")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "字典类型", required = true, example = "sys_common_sex")
|
||||
private String type;
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.dashboard.modules.system.convert.dict;
|
||||
import cn.iocoder.dashboard.common.pojo.PageResult;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeCreateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeSimpleRespVO;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict.SysDictTypeDO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -10,6 +11,8 @@ import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysDictTypeConvert {
|
||||
|
||||
@ -26,4 +29,6 @@ public interface SysDictTypeConvert {
|
||||
|
||||
SysDictTypeDO convert(SysDictTypeUpdateReqVO bean);
|
||||
|
||||
List<SysDictTypeSimpleRespVO> convertList(List<SysDictTypeDO> list);
|
||||
|
||||
}
|
||||
|
@ -4,10 +4,13 @@ import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.dashboard.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypePageReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict.SysDictTypeDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SysDictTypeMapper extends BaseMapper<SysDictTypeDO> {
|
||||
|
||||
@ -27,4 +30,8 @@ public interface SysDictTypeMapper extends BaseMapper<SysDictTypeDO> {
|
||||
return selectOne(new QueryWrapperX<SysDictTypeDO>().eq("name", name));
|
||||
}
|
||||
|
||||
default List<SysDictTypeDO> selectList() {
|
||||
return selectList(new QueryWrapper<>());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypePa
|
||||
import cn.iocoder.dashboard.modules.system.controller.dict.vo.type.SysDictTypeUpdateReqVO;
|
||||
import cn.iocoder.dashboard.modules.system.dal.mysql.dataobject.dict.SysDictTypeDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典类型 Service 接口
|
||||
*
|
||||
@ -59,4 +61,11 @@ public interface SysDictTypeService {
|
||||
*/
|
||||
void deleteDictType(Long id);
|
||||
|
||||
/**
|
||||
* 获得全部字典类型列表
|
||||
*
|
||||
* @return 字典类型列表
|
||||
*/
|
||||
List<SysDictTypeDO> listDictTypes();
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@ -74,6 +76,11 @@ public class SysDictTypeServiceImpl implements SysDictTypeService {
|
||||
// TODO 发送 MQ 消息
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictTypeDO> listDictTypes() {
|
||||
return dictTypeMapper.selectList();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteDictType0(Long id) {
|
||||
// 校验是否存在
|
||||
|
Loading…
Reference in New Issue
Block a user