Skip to content

Commit

Permalink
✨ add dict status
Browse files Browse the repository at this point in the history
  • Loading branch information
tookbra committed Jun 2, 2019
1 parent a8c7252 commit ba98a2c
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 14 deletions.
33 changes: 22 additions & 11 deletions src/mock/services/system/dict.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,40 @@ const pageDict = () => {
name: "权限",
code: "permission",
dictKey: "query",
dictValue: "查询"
dictValue: "查询",
status: 1
},
{
id: 2,
name: "权限",
code: "permission",
dictKey: "get",
dictValue: "详情"
dictValue: "详情",
status: 1
},
{
id: 3,
name: "权限",
code: "permission",
dictKey: "add",
dictValue: "新增"
dictValue: "新增",
status: 1
},
{
id: 4,
name: "权限",
code: "permission",
dictKey: "update",
dictValue: "修改"
dictValue: "修改",
status: 1
},
{
id: 5,
name: "权限",
code: "permission",
dictKey: "delete",
dictValue: "删除"
dictValue: "删除",
status: 1
}
]
});
Expand Down Expand Up @@ -69,7 +74,8 @@ export const getDict = req => {
name: "权限",
code: "permission",
dictKey: "query",
dictValue: "查询"
dictValue: "查询",
status: 1
});
};
// eslint-disable-next-line no-unused-vars
Expand All @@ -80,35 +86,40 @@ export const getDictByCode = req => {
name: "权限",
code: "permission",
dictKey: "query",
dictValue: "查询"
dictValue: "查询",
status: 1
},
{
id: 2,
name: "权限",
code: "permission",
dictKey: "get",
dictValue: "详情"
dictValue: "详情",
status: 1
},
{
id: 3,
name: "权限",
code: "permission",
dictKey: "add",
dictValue: "新增"
dictValue: "新增",
status: 1
},
{
id: 4,
name: "权限",
code: "permission",
dictKey: "update",
dictValue: "修改"
dictValue: "修改",
status: 1
},
{
id: 5,
name: "权限",
code: "permission",
dictKey: "delete",
dictValue: "删除"
dictValue: "删除",
status: 1
}
]);
};
Expand Down
45 changes: 42 additions & 3 deletions src/views/system/dict.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
<a-input v-model="queryParam.key" placeholder="字典键名" />
</a-form-item>
</a-col>
<a-col :md="5" :sm="24">
<a-form-item label="状态">
<a-select placeholder="请选择" default-value="">
<a-select-option value="">全部</a-select-option>
<a-select-option value="1">禁用</a-select-option>
<a-select-option value="2">启用</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :md="5" :sm="24">
<span class="table-page-search-submitButtons">
<a-button
Expand Down Expand Up @@ -52,6 +61,9 @@
}"
:showSizeChanger="true"
>
<span slot="status" slot-scope="text">
{{ text | statusFilter }}
</span>
<span slot="action" class="table-nav" slot-scope="text, record">
<template>
<a @click="() => showDetail(record)">
Expand Down Expand Up @@ -153,6 +165,24 @@
]"
/>
</a-form-item>
<a-form-item
label="状态"
:label-col="{ span: 5 }"
:wrapper-col="{ span: 14 }"
>
<a-select
placeholder="请选择状态"
v-decorator="[
'status',
{
rules: [{ required: true, message: '请选择状态' }]
}
]"
>
<a-select-option :value="1">正常</a-select-option>
<a-select-option :value="2">禁用</a-select-option>
</a-select>
</a-form-item>
</a-form>
</a-modal>
</basicContainer>
Expand Down Expand Up @@ -187,6 +217,7 @@ export default {
title: "",
edit: false,
dictForm: this.$form.createForm(this),
dict: {},
// 表头
columns: [
{
Expand All @@ -206,6 +237,11 @@ export default {
title: "字典键值",
dataIndex: "dictValue"
},
{
title: "状态",
dataIndex: "status",
scopedSlots: { customRender: "status" }
},
{
title: "操作",
dataIndex: "action",
Expand Down Expand Up @@ -335,8 +371,10 @@ export default {
this.dictForm.validateFields(err => {
if (!err) {
this.$loading.show();
let dict = this.dictForm.getFieldsValue();
dict.id = this.dict.id;
if (this.edit) {
modifyDict(this.dictForm.getFieldsValue())
modifyDict(dict)
.then(res => {
if (res.success) {
this.visible = false;
Expand All @@ -347,7 +385,7 @@ export default {
vm.$loading.hide();
});
} else {
addDict(this.dictForm.getFieldsValue())
addDict(dict)
.then(res => {
if (res.success) {
this.visible = false;
Expand Down Expand Up @@ -385,7 +423,7 @@ export default {
});
},
setFormValues({ ...dict }) {
let fields = ["id", "code", "name", "dictKey", "dictValue"];
let fields = ["id", "code", "name", "dictKey", "dictValue", "status"];
Object.keys(dict).forEach(key => {
if (fields.indexOf(key) !== -1) {
this.dictForm.getFieldDecorator(key);
Expand All @@ -394,6 +432,7 @@ export default {
this.dictForm.setFieldsValue(obj);
}
});
this.dict = dict;
}
}
};
Expand Down

0 comments on commit ba98a2c

Please sign in to comment.