|
1
2
3
4
|
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
|
|
5
6
|
<!--
-->
|
|
7
8
9
10
11
12
|
<!-- 操作按钮区域 -->
<div class="table-operator">
<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<a-menu slot="overlay">
|
|
13
14
15
16
|
<a-menu-item key="1" @click="batchDel">
<a-icon type="delete"/>
删除
</a-menu-item>
|
|
17
|
</a-menu>
|
|
18
19
20
|
<a-button style="margin-left: 8px"> 批量操作
<a-icon type="down"/>
</a-button>
|
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
</a-dropdown>
</div>
<!-- table区域-begin -->
<div>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
|
|
45
|
<a-divider type="vertical"/>
|
|
46
|
<a-dropdown>
|
|
47
|
<a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
|
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<a-menu slot="overlay">
<a-menu-item>
<a href="javascript:;" @click="handleDetail(record)">详情</a>
</a-menu-item>
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
</div>
<!-- table区域-end -->
<!-- 表单区域 -->
<sysDepart-modal ref="sysDepartModal" @ok="modalFormOk"></sysDepart-modal>
</a-card>
</template>
<script>
import SysDepartModal from './modules/DepartModal'
|
|
72
73
74
75
|
/* import { filterObj } from '@/utils/util'
, queryByFactories*/
import {queryDepartTreeList} from '@/api/api'
import {deleteAction} from '@/api/manage'
|
|
76
|
|
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// 表头
const columns = [
{
title: '机构名称',
dataIndex: 'departName',
},
{
title: '机构类型',
align: "center",
dataIndex: 'orgType'
},
{
title: '机构编码',
dataIndex: 'orgCode'
},
{
title: '手机号',
dataIndex: 'mobile'
},
{
title: '传真',
dataIndex: 'fax'
},
{
title: '地址',
dataIndex: 'address'
},
{
title: '排序',
align: 'center',
dataIndex: 'departOrder'
},
{
title: '操作',
align: "center",
dataIndex: 'action',
scopedSlots: {customRender: 'action'},
}
];
|
|
116
117
118
119
120
121
|
export default {
name: "DepartList2",
components: {
SysDepartModal
},
|
|
122
123
124
125
126
|
data() {
return {
description: 'jeecg 生成SysDepart代码管理页面',
// 查询条件
queryParam: {},
|
|
127
|
//数据集
|
|
128
129
130
|
factories: '',
dataSource: [],
columns: columns,
|
|
131
|
// 分页参数
|
|
132
133
134
135
136
137
138
139
140
141
142
143
|
/* ipagination:{
current: 1,
pageSize: 5,
pageSizeOptions: ['5', '10', '20'],
showTotal: (total, range) => {
return range[0] + "-" + range[1] + " 共" + total + "条"
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},*/
isorter: {
|
|
144
145
146
|
column: 'createTime',
order: 'desc',
},
|
|
147
|
loading: false,
|
|
148
149
|
selectedRowKeys: [],
selectedRows: [],
|
|
150
|
url: {
|
|
151
152
153
|
list: "/sys/sysDepart/list",
delete: "/sys/sysDepart/delete",
deleteBatch: "/sys/sysDepart/deleteBatch",
|
|
154
155
156
157
158
159
160
161
|
},
}
},
created() {
this.loadData();
},
methods: {
|
|
162
|
loadData() {
|
|
163
|
this.dataSource = [];
|
|
164
165
166
167
168
|
queryDepartTreeList().then((res) => {
if (res.success) {
this.dataSource = res.result;
}
})
|
|
169
170
171
|
},
|
|
172
|
getQueryField() {
|
|
173
174
|
//TODO 字段权限控制
var str = "id,";
|
|
175
176
|
for (var a = 0; a < this.columns.length; a++) {
str += "," + this.columns[a].dataIndex;
|
|
177
178
179
|
}
return str;
},
|
|
180
|
onSelectChange(selectedRowKeys, selectionRows) {
|
|
181
182
183
|
this.selectedRowKeys = selectedRowKeys;
this.selectionRows = selectionRows;
},
|
|
184
|
onClearSelected() {
|
|
185
186
187
188
|
this.selectedRowKeys = [];
this.selectionRows = [];
},
//TODO getQueryParams
|
|
189
|
handleDelete: function (id) {
|
|
190
|
var that = this;
|
|
191
192
|
deleteAction(that.url.delete, {id: id}).then((res) => {
if (res.success) {
|
|
193
194
|
that.$message.success(res.message);
that.loadData();
|
|
195
|
} else {
|
|
196
197
198
199
|
that.$message.warning(res.message);
}
});
},
|
|
200
|
handleDetail(record) {
|
|
201
|
this.$refs.sysDepartModal.edit(record);
|
|
202
|
this.$refs.sysDepartModal.title = "详情";
|
|
203
204
|
this.$refs.sysDepartModal.disableSubmit = true;
},
|
|
205
206
|
batchDel: function () {
if (this.selectedRowKeys.length <= 0) {
|
|
207
|
this.$message.warning('请选择一条记录!');
|
|
208
209
|
return;
} else {
|
|
210
|
var ids = "";
|
|
211
212
|
for (var a = 0; a < this.selectedRowKeys.length; a++) {
ids += this.selectedRowKeys[a] + ",";
|
|
213
214
215
|
}
var that = this;
this.$confirm({
|
|
216
217
218
219
220
|
title: "确认删除",
content: "是否删除选中数据?",
onOk: function () {
deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
if (res.success) {
|
|
221
222
223
|
that.$message.success(res.message);
that.loadData();
that.onClearSelected();
|
|
224
|
} else {
|
|
225
226
227
228
229
230
231
|
that.$message.warning(res.message);
}
});
}
});
}
},
|
|
232
|
handleEdit: function (record) {
|
|
233
|
this.$refs.sysDepartModal.edit(record);
|
|
234
|
this.$refs.sysDepartModal.title = "编辑";
|
|
235
|
},
|
|
236
|
handleAdd() {
|
|
237
|
this.$refs.sysDepartModal.add();
|
|
238
|
this.$refs.sysDepartModal.title = "新增";
|
|
239
|
},
|
|
240
|
handleTableChange(pagination, filters, sorter) {
|
|
241
242
243
|
//分页、排序、筛选变化时触发
console.log(sorter);
//TODO 筛选
|
|
244
|
if (Object.keys(sorter).length > 0) {
|
|
245
|
this.isorter.column = sorter.field;
|
|
246
|
this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
|
|
247
248
249
250
|
}
/*this.ipagination = pagination;*/
this.loadData();
},
|
|
251
|
modalFormOk() {
|
|
252
253
254
255
256
257
258
|
// 新增/修改 成功时,重载列表
this.loadData();
}
}
}
</script>
<style scoped>
|
|
259
|
@import '~@assets/less/common.less'
|
|
260
|
</style>
|