使用vue-data-dict,简化数据字典使用

This commit is contained in:
RuoYi
2021-09-17 15:36:54 +08:00
parent 23270c60bc
commit 12ab8b03d9
28 changed files with 503 additions and 325 deletions

View File

@ -69,7 +69,7 @@
<el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="statusOptions" :value="scope.row.status"/>
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
@ -107,6 +107,7 @@ import selectUser from "./selectUser";
export default {
name: "AuthUser",
dicts: ['sys_normal_disable'],
components: { selectUser },
data() {
return {
@ -122,8 +123,6 @@ export default {
total: 0,
// 用户表格数据
userList: [],
// 状态数据字典
statusOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
@ -139,9 +138,6 @@ export default {
if (roleId) {
this.queryParams.roleId = roleId;
this.getList();
this.getDicts("sys_normal_disable").then(response => {
this.statusOptions = response.data;
});
}
},
methods: {

View File

@ -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 dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
@ -183,10 +183,10 @@
<el-form-item label="状态">
<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 dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.value"
>{{dict.label}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="菜单权限">
@ -265,6 +265,7 @@ import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/d
export default {
name: "Role",
dicts: ['sys_normal_disable'],
data() {
return {
// 遮罩层
@ -295,8 +296,6 @@ export default {
deptNodeAll: false,
// 日期范围
dateRange: [],
// 状态数据字典
statusOptions: [],
// 数据范围选项
dataScopeOptions: [
{
@ -354,9 +353,6 @@ export default {
},
created() {
this.getList();
this.getDicts("sys_normal_disable").then(response => {
this.statusOptions = response.data;
});
},
methods: {
/** 查询角色列表 */

View File

@ -34,7 +34,7 @@
<el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
<el-table-column label="状态" align="center" prop="status">
<template slot-scope="scope">
<dict-tag :options="statusOptions" :value="scope.row.status"/>
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
@ -61,6 +61,7 @@
<script>
import { unallocatedUserList, authUserSelectAll } from "@/api/system/role";
export default {
dicts: ['sys_normal_disable'],
props: {
// 角色编号
roleId: {
@ -77,8 +78,6 @@ export default {
total: 0,
// 未授权用户数据
userList: [],
// 状态数据字典
statusOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
@ -89,11 +88,6 @@ export default {
}
};
},
created() {
this.getDicts("sys_normal_disable").then(response => {
this.statusOptions = response.data;
});
},
methods: {
// 显示弹框
show() {