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