数据字典

master
dongzeliang 2024-04-12 19:09:17 +08:00
parent 03bf2153a1
commit f4ece97056
2 changed files with 370 additions and 72 deletions

View File

@ -292,26 +292,208 @@ export default {
methods: { methods: {
/** 查询字典类型详细 */ /** 查询字典类型详细 */
getType(dictId) { getType(dictId) {
getType(dictId).then(response => { let response = {
"code": 200,
"msg": "操作成功",
"data": {
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 1,
"dictName": "用户性别",
"dictType": "sys_user_sex",
"status": "0",
"remark": "用户性别列表"
}
}
this.queryParams.dictType = response.data.dictType; this.queryParams.dictType = response.data.dictType;
this.defaultDictType = response.data.dictType; this.defaultDictType = response.data.dictType;
this.getList(); this.getList();
});
}, },
/** 查询字典类型列表 */ /** 查询字典类型列表 */
getTypeList() { getTypeList() {
getDictOptionselect().then(response => { let response = {
"code": 200,
"msg": "操作成功",
"data": [
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 1,
"dictName": "用户性别",
"dictType": "sys_user_sex",
"status": "0",
"remark": "用户性别列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 2,
"dictName": "菜单状态",
"dictType": "sys_show_hide",
"status": "0",
"remark": "菜单状态列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 3,
"dictName": "系统开关",
"dictType": "sys_normal_disable",
"status": "0",
"remark": "系统开关列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 4,
"dictName": "任务状态",
"dictType": "sys_job_status",
"status": "0",
"remark": "任务状态列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 5,
"dictName": "任务分组",
"dictType": "sys_job_group",
"status": "0",
"remark": "任务分组列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 6,
"dictName": "系统是否",
"dictType": "sys_yes_no",
"status": "0",
"remark": "系统是否列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 7,
"dictName": "通知类型",
"dictType": "sys_notice_type",
"status": "0",
"remark": "通知类型列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 8,
"dictName": "通知状态",
"dictType": "sys_notice_status",
"status": "0",
"remark": "通知状态列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 9,
"dictName": "操作类型",
"dictType": "sys_oper_type",
"status": "0",
"remark": "操作类型列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 10,
"dictName": "系统状态",
"dictType": "sys_common_status",
"status": "0",
"remark": "登录状态列表"
}
]
}
this.typeOptions = response.data; this.typeOptions = response.data;
});
}, },
/** 查询字典数据列表 */ /** 查询字典数据列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listData(this.queryParams).then(response => { let response = {
"code": 200,
"msg": "查询成功",
"data": {
"total": 3,
"rows": [
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictCode": 1,
"dictSort": 1,
"dictLabel": "男",
"dictValue": "0",
"dictType": "sys_user_sex",
"cssClass": "",
"listClass": "",
"isDefault": "Y",
"status": "0",
"remark": "性别男"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictCode": 2,
"dictSort": 2,
"dictLabel": "女",
"dictValue": "1",
"dictType": "sys_user_sex",
"cssClass": "",
"listClass": "",
"isDefault": "N",
"status": "0",
"remark": "性别女"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictCode": 3,
"dictSort": 3,
"dictLabel": "未知",
"dictValue": "2",
"dictType": "sys_user_sex",
"cssClass": "",
"listClass": "",
"isDefault": "N",
"status": "0",
"remark": "性别未知"
}
]
}
}
this.dataList = response.data.rows; this.dataList = response.data.rows;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
});
}, },
// //
cancel() { cancel() {
@ -364,31 +546,40 @@ export default {
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
const dictCode = row.dictCode || this.ids let response = {
getData(dictCode).then(response => { "code": 200,
"msg": "操作成功",
"data": {
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictCode": 1,
"dictSort": 1,
"dictLabel": "男",
"dictValue": "0",
"dictType": "sys_user_sex",
"cssClass": "",
"listClass": "",
"isDefault": "Y",
"status": "0",
"remark": "性别男"
}
}
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改字典数据"; this.title = "修改字典数据";
});
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function () { submitForm: function () {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.dictCode != undefined) { if (this.form.dictCode != undefined) {
updateData(this.form).then(response => {
this.$store.dispatch('dict/removeDict', this.queryParams.dictType);
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList();
});
} else { } else {
addData(this.form).then(response => {
this.$store.dispatch('dict/removeDict', this.queryParams.dictType);
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList();
});
} }
} }
}); });
@ -396,20 +587,13 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const dictCodes = row.dictCode || this.ids; const dictCodes = row.dictCode || this.ids;
this.$modal.confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?').then(function () { this.$modal.confirm('是否确认删除字典编码为"' + dictCodes + '"的数据项?').then(() => {
return delData(dictCodes);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
this.$store.dispatch('dict/removeDict', this.queryParams.dictType);
}).catch(() => {
}); });
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
this.download('system/dict/data/export', { this.$modal.msgSuccess("导出成功");
...this.queryParams
}, `data_${new Date().getTime()}.xlsx`)
} }
} }
}; };

View File

@ -251,12 +251,128 @@ export default {
/** 查询字典类型列表 */ /** 查询字典类型列表 */
getList() { getList() {
this.loading = true; this.loading = true;
listType(this.addDateRange(this.queryParams, this.dateRange)).then(response => { let response = {
"code": 200,
"msg": "查询成功",
"data": {
"total": 10,
"rows": [
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 1,
"dictName": "用户性别",
"dictType": "sys_user_sex",
"status": "0",
"remark": "用户性别列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 2,
"dictName": "菜单状态",
"dictType": "sys_show_hide",
"status": "0",
"remark": "菜单状态列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 3,
"dictName": "系统开关",
"dictType": "sys_normal_disable",
"status": "0",
"remark": "系统开关列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 4,
"dictName": "任务状态",
"dictType": "sys_job_status",
"status": "0",
"remark": "任务状态列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 5,
"dictName": "任务分组",
"dictType": "sys_job_group",
"status": "0",
"remark": "任务分组列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 6,
"dictName": "系统是否",
"dictType": "sys_yes_no",
"status": "0",
"remark": "系统是否列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 7,
"dictName": "通知类型",
"dictType": "sys_notice_type",
"status": "0",
"remark": "通知类型列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 8,
"dictName": "通知状态",
"dictType": "sys_notice_status",
"status": "0",
"remark": "通知状态列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 9,
"dictName": "操作类型",
"dictType": "sys_oper_type",
"status": "0",
"remark": "操作类型列表"
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 10,
"dictName": "系统状态",
"dictType": "sys_common_status",
"status": "0",
"remark": "登录状态列表"
}
]
}
}
this.typeList = response.data.rows; this.typeList = response.data.rows;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
}
);
}, },
// //
cancel() { cancel() {
@ -301,28 +417,35 @@ export default {
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
const dictId = row.dictId || this.ids const dictId = row.dictId || this.ids
getType(dictId).then(response => { let response = {
"code": 200,
"msg": "操作成功",
"data": {
"createBy": 1,
"createTime": "2023-09-29 11:47:28",
"updateBy": null,
"updateTime": null,
"dictId": 1,
"dictName": "用户性别",
"dictType": "sys_user_sex",
"status": "0",
"remark": "用户性别列表"
}
}
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改字典类型"; this.title = "修改字典类型";
});
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function () { submitForm: function () {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.dictId != undefined) { if (this.form.dictId != undefined) {
updateType(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.open = false; this.open = false;
this.getList();
});
} else { } else {
addType(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList();
});
} }
} }
}); });
@ -330,26 +453,17 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const dictIds = row.dictId || this.ids; const dictIds = row.dictId || this.ids;
this.$modal.confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?').then(function () { this.$modal.confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?').then(() => {
return delType(dictIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功");
}).catch(() => {
}); });
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
this.download('system/dict/type/export', { this.$modal.msgSuccess("导出成功");
...this.queryParams
}, `type_${new Date().getTime()}.xlsx`)
}, },
/** 刷新缓存按钮操作 */ /** 刷新缓存按钮操作 */
handleRefreshCache() { handleRefreshCache() {
refreshCache().then(() => {
this.$modal.msgSuccess("刷新成功"); this.$modal.msgSuccess("刷新成功");
this.$store.dispatch('dict/cleanDict');
});
} }
} }
}; };