commit | author | age
|
9bcb19
|
1 |
<template> |
I |
2 |
<a-modal |
|
3 |
title="字典值管理" |
|
4 |
:width="900" |
|
5 |
:visible="visible" |
|
6 |
:footer="null" |
|
7 |
@cancel="handleCancel" |
|
8 |
> |
|
9 |
<x-card v-if="hasPerm('sysDictData:page')"> |
|
10 |
<div slot="content" class="table-page-search-wrapper" > |
|
11 |
<a-form layout="inline"> |
|
12 |
<a-row :gutter="48"> |
|
13 |
<a-col :md="8" :sm="24"> |
|
14 |
<a-form-item label="字典值" > |
|
15 |
<a-input v-model="queryParam.value" allow-clear placeholder="请输入字典值"/> |
|
16 |
</a-form-item> |
|
17 |
</a-col> |
|
18 |
<a-col :md="8" :sm="24"> |
|
19 |
<a-form-item label="唯一编码" > |
|
20 |
<a-input v-model="queryParam.code" allow-clear placeholder="请输入唯一编码"/> |
|
21 |
</a-form-item> |
|
22 |
</a-col> |
|
23 |
<a-col :md="8" :sm="24"> |
|
24 |
<span class="table-page-search-submitButtons"> |
|
25 |
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button> |
|
26 |
<a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button> |
|
27 |
</span> |
|
28 |
</a-col> |
|
29 |
</a-row> |
|
30 |
</a-form> |
|
31 |
</div> |
|
32 |
</x-card> |
|
33 |
<a-card :bordered="false"> |
|
34 |
<s-table |
|
35 |
ref="table" |
|
36 |
:columns="columns" |
|
37 |
:data="loadData" |
|
38 |
:alert="false" |
|
39 |
:rowKey="(record) => record.code" |
|
40 |
> |
|
41 |
<template slot="operator" v-if="hasPerm('sysDictData:add')" > |
|
42 |
<a-button @click="$refs.addForm.add(typeId)" icon="plus" type="primary" v-if="hasPerm('sysDictData:add')">新增数据</a-button> |
|
43 |
</template> |
|
44 |
<span slot="status" slot-scope="text"> |
|
45 |
{{ statusFilter(text) }} |
|
46 |
</span> |
|
47 |
<span slot="action" slot-scope="text, record"> |
|
48 |
<a v-if="hasPerm('sysDictData:edit')" @click="$refs.editForm.edit(record)">编辑</a> |
|
49 |
<a-divider type="vertical" v-if="hasPerm('sysDictData:edit') & hasPerm('sysDictData:delete')"/> |
|
50 |
<a-popconfirm v-if="hasPerm('sysDictData:delete')" placement="topRight" title="确认删除?" @confirm="() => sysDictDataDelete(record)"> |
|
51 |
<a>删除</a> |
|
52 |
</a-popconfirm> |
|
53 |
</span> |
|
54 |
</s-table> |
|
55 |
<add-form ref="addForm" @ok="handleOk" /> |
|
56 |
<edit-form ref="editForm" @ok="handleOk" /> |
|
57 |
</a-card> |
|
58 |
</a-modal> |
|
59 |
</template> |
|
60 |
<script> |
|
61 |
import { STable, XCard } from '@/components' |
|
62 |
import { sysDictDataPage, sysDictDataDelete } from '@/api/modular/system/dictDataManage' |
|
63 |
import { sysDictTypeDropDown } from '@/api/modular/system/dictManage' |
|
64 |
import addForm from './addForm' |
|
65 |
import editForm from './editForm' |
|
66 |
export default { |
|
67 |
components: { |
|
68 |
XCard, |
|
69 |
STable, |
|
70 |
addForm, |
|
71 |
editForm |
|
72 |
}, |
|
73 |
data () { |
|
74 |
return { |
|
75 |
// 查询参数 |
|
76 |
queryParam: {}, |
|
77 |
// 表头 |
|
78 |
columns: [ |
|
79 |
{ |
|
80 |
title: '字典值', |
|
81 |
dataIndex: 'value' |
|
82 |
}, |
|
83 |
{ |
|
84 |
title: '唯一编码', |
|
85 |
dataIndex: 'code' |
|
86 |
}, |
|
87 |
{ |
|
88 |
title: '排序', |
|
89 |
dataIndex: 'sort' |
|
90 |
}, |
|
91 |
{ |
|
92 |
title: '备注', |
|
93 |
dataIndex: 'remark', |
|
94 |
width: 200 |
|
95 |
}, |
|
96 |
{ |
|
97 |
title: '状态', |
|
98 |
dataIndex: 'status', |
|
99 |
scopedSlots: { customRender: 'status' } |
|
100 |
} |
|
101 |
], |
|
102 |
visible: false, |
|
103 |
typeId: [], |
|
104 |
// 加载数据方法 必须为 Promise 对象 |
|
105 |
loadData: parameter => { |
|
106 |
this.queryParam.typeId = this.typeId |
|
107 |
return sysDictDataPage(Object.assign(parameter, this.queryParam)).then((res) => { |
|
108 |
return res.data |
|
109 |
}) |
|
110 |
}, |
|
111 |
statusDict: [] |
|
112 |
} |
|
113 |
}, |
|
114 |
created () { |
|
115 |
this.sysDictTypeDropDown() |
|
116 |
if (this.hasPerm('sysDictData:edit') || this.hasPerm('sysDictData:delete')) { |
|
117 |
this.columns.push({ |
|
118 |
title: '操作', |
|
119 |
width: '150px', |
|
120 |
dataIndex: 'action', |
|
121 |
scopedSlots: { customRender: 'action' } |
|
122 |
}) |
|
123 |
} |
|
124 |
}, |
|
125 |
methods: { |
|
126 |
// 打开此页面首先加载此方法 |
|
127 |
index (record) { |
|
128 |
this.visible = true |
|
129 |
this.typeId = record.id |
|
130 |
this.queryParam.typeId = record.id |
|
131 |
try { |
|
132 |
this.$refs.table.refresh() |
|
133 |
} catch (e) { |
|
134 |
// 首次进入界面,因表格加载顺序,会抛异常,我们不予理会 |
|
135 |
} |
|
136 |
}, |
|
137 |
statusFilter (status) { |
|
138 |
// eslint-disable-next-line eqeqeq |
|
139 |
const values = this.statusDict.filter(item => item.code == status) |
|
140 |
if (values.length > 0) { |
|
141 |
return values[0].value |
|
142 |
} |
|
143 |
}, |
|
144 |
/** |
|
145 |
* 获取字典数据 |
|
146 |
*/ |
|
147 |
sysDictTypeDropDown () { |
|
148 |
sysDictTypeDropDown({ code: 'common_status' }).then((res) => { |
|
149 |
this.statusDict = res.data |
|
150 |
}) |
|
151 |
}, |
|
152 |
handleCancel () { |
|
153 |
this.queryParam = {} |
|
154 |
this.visible = false |
|
155 |
}, |
|
156 |
sysDictDataDelete (record) { |
|
157 |
sysDictDataDelete(record).then((res) => { |
|
158 |
if (res.success) { |
|
159 |
this.$message.success('删除成功') |
|
160 |
this.$refs.table.refresh() |
|
161 |
} else { |
|
162 |
this.$message.error('删除失败:' + res.message) |
|
163 |
} |
|
164 |
}).catch((err) => { |
|
165 |
this.$message.error('删除错误:' + err.message) |
|
166 |
}) |
|
167 |
}, |
|
168 |
handleOk () { |
|
169 |
this.$refs.table.refresh() |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
</script> |
|
174 |
<style lang="less"> |
|
175 |
.table-operator { |
|
176 |
margin-bottom: 18px; |
|
177 |
} |
|
178 |
button { |
|
179 |
margin-right: 8px; |
|
180 |
} |
|
181 |
</style> |