vue2-client 1.8.21 → 1.8.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,525 +1,531 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-show="tableColumns.length > 0">
|
|
3
|
-
<a-row :gutter="48">
|
|
4
|
-
<a-col>
|
|
5
|
-
<span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
|
|
6
|
-
<a-space>
|
|
7
|
-
<slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
8
|
-
<a-button v-if="!buttonState || buttonState.add" type="primary" @click="add">
|
|
9
|
-
<a-icon :style="iconStyle" type="plus"/>新增
|
|
10
|
-
</a-button>
|
|
11
|
-
<a-button
|
|
12
|
-
v-if="!buttonState || buttonState.edit"
|
|
13
|
-
:disabled="!isModify"
|
|
14
|
-
:loading="editLoading"
|
|
15
|
-
class="btn-success"
|
|
16
|
-
type="dashed"
|
|
17
|
-
@click="edit()">
|
|
18
|
-
<a-icon :style="iconStyle" type="edit"/>修改
|
|
19
|
-
</a-button>
|
|
20
|
-
<a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
|
|
21
|
-
<a-icon :style="iconStyle" type="delete"/>删除
|
|
22
|
-
</a-button>
|
|
23
|
-
<a-button v-if="!buttonState || buttonState.import" type="dashed" @click="importData">
|
|
24
|
-
<a-icon :style="iconStyle" type="import" />导入
|
|
25
|
-
</a-button>
|
|
26
|
-
<a-dropdown v-if="!buttonState || buttonState.export">
|
|
27
|
-
<a-menu slot="overlay">
|
|
28
|
-
<a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon :style="iconStyle" type="ordered-list" />导出选中数据</a-menu-item>
|
|
29
|
-
<a-menu-item key="2" @click="handleExport(false)"><a-icon :style="iconStyle" type="snippets" />导出本页数据</a-menu-item>
|
|
30
|
-
<a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download" />导出所有符合条件的数据</a-menu-item>
|
|
31
|
-
</a-menu>
|
|
32
|
-
<a-button>导出 <a-icon type="down" /> </a-button>
|
|
33
|
-
</a-dropdown>
|
|
34
|
-
<slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
35
|
-
</a-space>
|
|
36
|
-
</span>
|
|
37
|
-
</a-col>
|
|
38
|
-
<a-col>
|
|
39
|
-
<span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
|
|
40
|
-
<a-button-group>
|
|
41
|
-
<slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
42
|
-
<a-button @click="refresh(true)">
|
|
43
|
-
<a-icon :style="iconStyle" type="reload" />
|
|
44
|
-
</a-button>
|
|
45
|
-
<table-setting v-if="columnSelectLoaded" v-model="tableColumns" />
|
|
46
|
-
</a-button-group>
|
|
47
|
-
</span>
|
|
48
|
-
</a-col>
|
|
49
|
-
</a-row>
|
|
50
|
-
<s-table
|
|
51
|
-
ref="table"
|
|
52
|
-
:alert="true"
|
|
53
|
-
:columns="tableColumns"
|
|
54
|
-
:data="loadData"
|
|
55
|
-
:rowKey="rowKey"
|
|
56
|
-
:rowSelection="rowSelection"
|
|
57
|
-
:scroll="{ x: scrollXWidth, y: scrollYHeight }"
|
|
58
|
-
:showPagination="showPagination"
|
|
59
|
-
size="default"
|
|
60
|
-
>
|
|
61
|
-
<template
|
|
62
|
-
v-for="(item, index) in tableColumns"
|
|
63
|
-
:slot="item.dataIndex"
|
|
64
|
-
slot-scope="text, record">
|
|
65
|
-
<!-- 文本溢出省略(ellipsis) -->
|
|
66
|
-
<span v-if="item.slotType === 'ellipsis'" :key="index">
|
|
67
|
-
<ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
|
|
68
|
-
</span>
|
|
69
|
-
<!-- 徽标(badge) -->
|
|
70
|
-
<span v-else-if="item.slotType === 'badge'" :key="index">
|
|
71
|
-
<x-badge v-if="text !== null && text !== undefined" :badge-key="item.slotKeyMap" :value="text" />
|
|
72
|
-
</span>
|
|
73
|
-
<!-- 日期(date) -->
|
|
74
|
-
<span v-else-if="item.slotType === 'date'" :key="index">
|
|
75
|
-
{{ format(text,'yyyy-MM-dd') }}
|
|
76
|
-
</span>
|
|
77
|
-
<!-- 日期时间(datetime) -->
|
|
78
|
-
<span v-else-if="item.slotType === 'dateTime'" :key="index">
|
|
79
|
-
{{ format(text,'yyyy-MM-dd hh:mm:ss') }}
|
|
80
|
-
</span>
|
|
81
|
-
<!-- 操作列(action) -->
|
|
82
|
-
<span v-else-if="item.slotType === 'action'" :key="index">
|
|
83
|
-
<a @click="action(record, item.dataIndex)">{{ item.slotValue }}</a>
|
|
84
|
-
</span>
|
|
85
|
-
</template>
|
|
86
|
-
<template slot="footer">
|
|
87
|
-
<slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
88
|
-
</template>
|
|
89
|
-
</s-table>
|
|
90
|
-
<!-- 上传文件 -->
|
|
91
|
-
<x-import-excel
|
|
92
|
-
ref="importExcel"
|
|
93
|
-
@ok="refresh(true)"
|
|
94
|
-
:title="title"
|
|
95
|
-
:service-name="serviceName"
|
|
96
|
-
:query-params-name="queryParamsName"
|
|
97
|
-
/>
|
|
98
|
-
</div>
|
|
99
|
-
</template>
|
|
100
|
-
<script>
|
|
101
|
-
import { Ellipsis, STable } from '@vue2-client/components'
|
|
102
|
-
import { formatDate } from '@vue2-client/utils/util'
|
|
103
|
-
import XBadge from '@vue2-client/base-client/components/common/XBadge'
|
|
104
|
-
import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
|
|
105
|
-
import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
|
|
106
|
-
import { exportData, query, queryWithResource, remove } from '@vue2-client/services/api/common'
|
|
107
|
-
import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
|
|
108
|
-
import { Modal } from 'ant-design-vue'
|
|
109
|
-
import { post } from '@vue2-client/services/api'
|
|
110
|
-
import { CommonTempTable } from '@vue2-client/services/api/commonTempTable'
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
Object.assign(conditionParams, this.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
requestParameters.
|
|
142
|
-
requestParameters.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this.
|
|
241
|
-
this.
|
|
242
|
-
this.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
totalWidth = totalWidth +
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
//
|
|
262
|
-
// this.scrollYHeight = 'calc(100vh -
|
|
263
|
-
// }
|
|
264
|
-
//
|
|
265
|
-
|
|
266
|
-
//
|
|
267
|
-
this.
|
|
268
|
-
//
|
|
269
|
-
this.
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
*
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
*
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
this.
|
|
308
|
-
this.
|
|
309
|
-
this
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
*
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
exportData = this
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
this
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
})
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
this
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
return
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
this.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
this.$message.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
return
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
color: #
|
|
513
|
-
}
|
|
514
|
-
.btn-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div v-show="tableColumns.length > 0">
|
|
3
|
+
<a-row :gutter="48">
|
|
4
|
+
<a-col>
|
|
5
|
+
<span :style="{ float: 'left', overflow: 'hidden', marginBottom: '8px' }">
|
|
6
|
+
<a-space>
|
|
7
|
+
<slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
8
|
+
<a-button v-if="!buttonState || buttonState.add" type="primary" @click="add">
|
|
9
|
+
<a-icon :style="iconStyle" type="plus"/>新增
|
|
10
|
+
</a-button>
|
|
11
|
+
<a-button
|
|
12
|
+
v-if="!buttonState || buttonState.edit"
|
|
13
|
+
:disabled="!isModify"
|
|
14
|
+
:loading="editLoading"
|
|
15
|
+
class="btn-success"
|
|
16
|
+
type="dashed"
|
|
17
|
+
@click="edit()">
|
|
18
|
+
<a-icon :style="iconStyle" type="edit"/>修改
|
|
19
|
+
</a-button>
|
|
20
|
+
<a-button v-if="!buttonState || buttonState.delete" :disabled="!isDelete" type="danger" @click="deleteItem">
|
|
21
|
+
<a-icon :style="iconStyle" type="delete"/>删除
|
|
22
|
+
</a-button>
|
|
23
|
+
<a-button v-if="!buttonState || buttonState.import" type="dashed" @click="importData">
|
|
24
|
+
<a-icon :style="iconStyle" type="import" />导入
|
|
25
|
+
</a-button>
|
|
26
|
+
<a-dropdown v-if="!buttonState || buttonState.export">
|
|
27
|
+
<a-menu slot="overlay">
|
|
28
|
+
<a-menu-item :disabled="selectedRowKeys.length === 0" key="1" @click="handleExport(true)"><a-icon :style="iconStyle" type="ordered-list" />导出选中数据</a-menu-item>
|
|
29
|
+
<a-menu-item key="2" @click="handleExport(false)"><a-icon :style="iconStyle" type="snippets" />导出本页数据</a-menu-item>
|
|
30
|
+
<a-menu-item key="3" @click="handleExportByQuery"><a-icon :style="iconStyle" type="download" />导出所有符合条件的数据</a-menu-item>
|
|
31
|
+
</a-menu>
|
|
32
|
+
<a-button>导出 <a-icon type="down" /> </a-button>
|
|
33
|
+
</a-dropdown>
|
|
34
|
+
<slot name="button" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
35
|
+
</a-space>
|
|
36
|
+
</span>
|
|
37
|
+
</a-col>
|
|
38
|
+
<a-col>
|
|
39
|
+
<span :style="{ float: 'right', overflow: 'hidden', marginBottom: '8px' }">
|
|
40
|
+
<a-button-group>
|
|
41
|
+
<slot name="rightBtnExpand" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
42
|
+
<a-button @click="refresh(true)">
|
|
43
|
+
<a-icon :style="iconStyle" type="reload" />
|
|
44
|
+
</a-button>
|
|
45
|
+
<table-setting v-if="columnSelectLoaded" v-model="tableColumns" />
|
|
46
|
+
</a-button-group>
|
|
47
|
+
</span>
|
|
48
|
+
</a-col>
|
|
49
|
+
</a-row>
|
|
50
|
+
<s-table
|
|
51
|
+
ref="table"
|
|
52
|
+
:alert="true"
|
|
53
|
+
:columns="tableColumns"
|
|
54
|
+
:data="loadData"
|
|
55
|
+
:rowKey="rowKey"
|
|
56
|
+
:rowSelection="rowSelection"
|
|
57
|
+
:scroll="{ x: scrollXWidth, y: scrollYHeight }"
|
|
58
|
+
:showPagination="showPagination"
|
|
59
|
+
size="default"
|
|
60
|
+
>
|
|
61
|
+
<template
|
|
62
|
+
v-for="(item, index) in tableColumns"
|
|
63
|
+
:slot="item.dataIndex"
|
|
64
|
+
slot-scope="text, record">
|
|
65
|
+
<!-- 文本溢出省略(ellipsis) -->
|
|
66
|
+
<span v-if="item.slotType === 'ellipsis'" :key="index">
|
|
67
|
+
<ellipsis :length="item.slotValue" tooltip>{{ text === '' ? '--' : text }}</ellipsis>
|
|
68
|
+
</span>
|
|
69
|
+
<!-- 徽标(badge) -->
|
|
70
|
+
<span v-else-if="item.slotType === 'badge'" :key="index">
|
|
71
|
+
<x-badge v-if="text !== null && text !== undefined" :badge-key="item.slotKeyMap" :value="text" />
|
|
72
|
+
</span>
|
|
73
|
+
<!-- 日期(date) -->
|
|
74
|
+
<span v-else-if="item.slotType === 'date'" :key="index">
|
|
75
|
+
{{ format(text,'yyyy-MM-dd') }}
|
|
76
|
+
</span>
|
|
77
|
+
<!-- 日期时间(datetime) -->
|
|
78
|
+
<span v-else-if="item.slotType === 'dateTime'" :key="index">
|
|
79
|
+
{{ format(text,'yyyy-MM-dd hh:mm:ss') }}
|
|
80
|
+
</span>
|
|
81
|
+
<!-- 操作列(action) -->
|
|
82
|
+
<span v-else-if="item.slotType === 'action'" :key="index">
|
|
83
|
+
<a @click="action(record, item.dataIndex)">{{ item.slotValue }}</a>
|
|
84
|
+
</span>
|
|
85
|
+
</template>
|
|
86
|
+
<template slot="footer">
|
|
87
|
+
<slot name="footer" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
|
|
88
|
+
</template>
|
|
89
|
+
</s-table>
|
|
90
|
+
<!-- 上传文件 -->
|
|
91
|
+
<x-import-excel
|
|
92
|
+
ref="importExcel"
|
|
93
|
+
@ok="refresh(true)"
|
|
94
|
+
:title="title"
|
|
95
|
+
:service-name="serviceName"
|
|
96
|
+
:query-params-name="queryParamsName"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
</template>
|
|
100
|
+
<script>
|
|
101
|
+
import { Ellipsis, STable } from '@vue2-client/components'
|
|
102
|
+
import { formatDate } from '@vue2-client/utils/util'
|
|
103
|
+
import XBadge from '@vue2-client/base-client/components/common/XBadge'
|
|
104
|
+
import TableSetting from '@vue2-client/components/TableSetting/TableSetting'
|
|
105
|
+
import { exportJson } from '@vue2-client/utils/excel/Export2Excel'
|
|
106
|
+
import { exportData, query, queryWithResource, remove } from '@vue2-client/services/api/common'
|
|
107
|
+
import XImportExcel from '@vue2-client/base-client/components/common/XImportExcel'
|
|
108
|
+
import { Modal } from 'ant-design-vue'
|
|
109
|
+
import { post } from '@vue2-client/services/api'
|
|
110
|
+
import { CommonTempTable } from '@vue2-client/services/api/commonTempTable'
|
|
111
|
+
import { mapState } from 'vuex'
|
|
112
|
+
|
|
113
|
+
export default {
|
|
114
|
+
name: 'XTable',
|
|
115
|
+
components: {
|
|
116
|
+
TableSetting,
|
|
117
|
+
STable,
|
|
118
|
+
Ellipsis,
|
|
119
|
+
XBadge,
|
|
120
|
+
XImportExcel
|
|
121
|
+
},
|
|
122
|
+
data () {
|
|
123
|
+
return {
|
|
124
|
+
// 筛选列加载状态
|
|
125
|
+
columnSelectLoaded: false,
|
|
126
|
+
// 预览模式
|
|
127
|
+
viewMode: false,
|
|
128
|
+
// 加载数据方法 必须为 Promise 对象
|
|
129
|
+
loadData: parameter => {
|
|
130
|
+
// 取到表格携带的表单参数
|
|
131
|
+
const requestParameters = Object.assign({}, parameter)
|
|
132
|
+
// 取到父组件传入的表单参数
|
|
133
|
+
const conditionParams = {}
|
|
134
|
+
Object.assign(conditionParams, this.fixedQueryForm)
|
|
135
|
+
Object.assign(conditionParams, this.form)
|
|
136
|
+
// 如果传了燃气公司字段,则进行数据处理
|
|
137
|
+
if (conditionParams.orgName) {
|
|
138
|
+
requestParameters.orgName = conditionParams.orgName
|
|
139
|
+
delete conditionParams.orgName
|
|
140
|
+
}
|
|
141
|
+
requestParameters.conditionParams = conditionParams
|
|
142
|
+
requestParameters.queryParamsName = this.queryParamsName
|
|
143
|
+
requestParameters.queryParams = this.queryParams
|
|
144
|
+
// 加载数据
|
|
145
|
+
return this.loadTableData(requestParameters)
|
|
146
|
+
},
|
|
147
|
+
rowKey: undefined,
|
|
148
|
+
// x滚动条宽度
|
|
149
|
+
scrollXWidth: 1600,
|
|
150
|
+
// y滚动条高度
|
|
151
|
+
scrollYHeight: 437,
|
|
152
|
+
// 表格选择列Key集合
|
|
153
|
+
selectedRowKeys: [],
|
|
154
|
+
// 表格选择Row集合
|
|
155
|
+
selectedRows: [],
|
|
156
|
+
// 业务标题
|
|
157
|
+
title: '',
|
|
158
|
+
// 数据列
|
|
159
|
+
tableColumns: [],
|
|
160
|
+
// 查询用表单
|
|
161
|
+
form: {},
|
|
162
|
+
// 是否允许修改
|
|
163
|
+
isModify: false,
|
|
164
|
+
// 是否允许删除
|
|
165
|
+
isDelete: false,
|
|
166
|
+
// 服务名称
|
|
167
|
+
serviceName: undefined,
|
|
168
|
+
// 选中用于修改的id
|
|
169
|
+
selectId: undefined,
|
|
170
|
+
// 是否为临时表
|
|
171
|
+
isTableTemp: false,
|
|
172
|
+
// 是否显示展示列抽屉
|
|
173
|
+
visible: false,
|
|
174
|
+
// 编辑按钮加载状态
|
|
175
|
+
editLoading: false,
|
|
176
|
+
// 按钮状态
|
|
177
|
+
buttonState: {},
|
|
178
|
+
// 图标样式
|
|
179
|
+
iconStyle: {
|
|
180
|
+
position: 'relative',
|
|
181
|
+
top: '1px'
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
props: {
|
|
186
|
+
// 查询配置文件名
|
|
187
|
+
queryParamsName: {
|
|
188
|
+
type: String,
|
|
189
|
+
default: () => {
|
|
190
|
+
return ''
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
// 查询配置文件Json
|
|
194
|
+
queryParamsJson: {
|
|
195
|
+
type: Object,
|
|
196
|
+
default: null
|
|
197
|
+
},
|
|
198
|
+
// 固定查询表单
|
|
199
|
+
fixedQueryForm: {
|
|
200
|
+
type: Object,
|
|
201
|
+
default: () => {
|
|
202
|
+
return {}
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
// 数据只有一页时是否展示分页,true:展示,auto:隐藏
|
|
206
|
+
showPagination: {
|
|
207
|
+
type: Boolean,
|
|
208
|
+
default: true
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
computed: {
|
|
212
|
+
rowSelection () {
|
|
213
|
+
return {
|
|
214
|
+
selectedRowKeys: this.selectedRowKeys,
|
|
215
|
+
onChange: this.onSelectChange
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
...mapState('setting', ['compatible'])
|
|
219
|
+
},
|
|
220
|
+
mounted () {},
|
|
221
|
+
methods: {
|
|
222
|
+
/**
|
|
223
|
+
* 初始化表格参数
|
|
224
|
+
*/
|
|
225
|
+
init (params) {
|
|
226
|
+
const {
|
|
227
|
+
// 查询参数对象, 用于没有对应查询配置文件名时
|
|
228
|
+
queryParams,
|
|
229
|
+
tableColumns,
|
|
230
|
+
buttonState,
|
|
231
|
+
title,
|
|
232
|
+
serviceName,
|
|
233
|
+
viewMode
|
|
234
|
+
} = params
|
|
235
|
+
this.queryParams = queryParams
|
|
236
|
+
this.tableColumns = JSON.parse(JSON.stringify(tableColumns))
|
|
237
|
+
if (this.tableColumns.length === 0) {
|
|
238
|
+
return
|
|
239
|
+
}
|
|
240
|
+
this.buttonState = buttonState
|
|
241
|
+
this.title = title
|
|
242
|
+
this.serviceName = serviceName
|
|
243
|
+
this.viewMode = viewMode
|
|
244
|
+
this.rowKey = this.tableColumns[0].dataIndex
|
|
245
|
+
let totalWidth = 0
|
|
246
|
+
// 设置表格宽度
|
|
247
|
+
for (let i = 0; i < this.tableColumns.length; i++) {
|
|
248
|
+
const item = this.tableColumns[i]
|
|
249
|
+
if (item.slotType === 'action') {
|
|
250
|
+
item.fixed = 'right'
|
|
251
|
+
item.width = 70
|
|
252
|
+
}
|
|
253
|
+
if (item.width) {
|
|
254
|
+
totalWidth = totalWidth + item.width
|
|
255
|
+
} else {
|
|
256
|
+
totalWidth = totalWidth + 180
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// 设置表格高度
|
|
260
|
+
// const height = document.documentElement.clientHeight
|
|
261
|
+
// if (height >= 1070) {
|
|
262
|
+
// this.scrollYHeight = 'calc(100vh - 526px)'
|
|
263
|
+
// } else {
|
|
264
|
+
// this.scrollYHeight = 'calc(100vh - 398px)'
|
|
265
|
+
// }
|
|
266
|
+
// 设置表格高度为固定值
|
|
267
|
+
this.scrollYHeight = 'calc(100vh - 33rem)'
|
|
268
|
+
// 横向滚动长度大于所有宽度,才能实现固定表头
|
|
269
|
+
this.scrollXWidth = totalWidth
|
|
270
|
+
// 加载筛选列完成
|
|
271
|
+
this.columnSelectLoaded = true
|
|
272
|
+
this.setQueryForm({})
|
|
273
|
+
},
|
|
274
|
+
/**
|
|
275
|
+
* 加载表格数据
|
|
276
|
+
* @param requestParameters 请求参数
|
|
277
|
+
*/
|
|
278
|
+
loadTableData (requestParameters) {
|
|
279
|
+
let result = {}
|
|
280
|
+
if (this.queryParamsJson) {
|
|
281
|
+
if (this.queryParamsJson.tableName.startsWith('##')) {
|
|
282
|
+
this.isTableTemp = true
|
|
283
|
+
result = this.initTempTable(requestParameters)
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (!this.isTableTemp) {
|
|
287
|
+
result = query(requestParameters, this.serviceName)
|
|
288
|
+
}
|
|
289
|
+
this.clearRowKeys()
|
|
290
|
+
this.$emit('afterQuery', result, requestParameters.conditionParams)
|
|
291
|
+
return result
|
|
292
|
+
},
|
|
293
|
+
/**
|
|
294
|
+
* 操作列事件
|
|
295
|
+
* @param record 本条数据
|
|
296
|
+
* @param actionType 操作类型
|
|
297
|
+
*/
|
|
298
|
+
action (record, actionType) {
|
|
299
|
+
this.$emit('action', record, record[this.getPrimaryKeyName()], actionType)
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* 选择列事件
|
|
303
|
+
* @param selectedRowKeys 被选择的列Key集合
|
|
304
|
+
* @param selectedRows 被选择的列集合
|
|
305
|
+
*/
|
|
306
|
+
onSelectChange (selectedRowKeys, selectedRows) {
|
|
307
|
+
this.selectedRowKeys = selectedRowKeys
|
|
308
|
+
this.selectedRows = selectedRows
|
|
309
|
+
this.isModify = this.selectedRowKeys.length === 1
|
|
310
|
+
this.isDelete = this.selectedRowKeys.length > 0
|
|
311
|
+
this.$emit('selectRow', selectedRowKeys, selectedRows)
|
|
312
|
+
},
|
|
313
|
+
/**
|
|
314
|
+
* 清除表格选中项
|
|
315
|
+
*/
|
|
316
|
+
clearRowKeys () {
|
|
317
|
+
this.$refs.table.clearSelected()
|
|
318
|
+
},
|
|
319
|
+
/**
|
|
320
|
+
* 为表格附加查询条件
|
|
321
|
+
*/
|
|
322
|
+
setQueryForm (form = {}) {
|
|
323
|
+
this.form = form
|
|
324
|
+
this.refresh(true)
|
|
325
|
+
},
|
|
326
|
+
/**
|
|
327
|
+
* 表格重新加载方法
|
|
328
|
+
* 如果参数为 true, 则强制刷新到第一页
|
|
329
|
+
*/
|
|
330
|
+
refresh (bool) {
|
|
331
|
+
this.$nextTick(() => {
|
|
332
|
+
this.$refs.table.refresh(bool)
|
|
333
|
+
})
|
|
334
|
+
},
|
|
335
|
+
/**
|
|
336
|
+
* 格式化日期
|
|
337
|
+
* @param date 日期字符串
|
|
338
|
+
* @param format 格式化方式
|
|
339
|
+
*/
|
|
340
|
+
format (date, format) {
|
|
341
|
+
return formatDate(date, format)
|
|
342
|
+
},
|
|
343
|
+
/**
|
|
344
|
+
* 获取主键列名称
|
|
345
|
+
*/
|
|
346
|
+
getPrimaryKeyName () {
|
|
347
|
+
return this.tableColumns[0].dataIndex
|
|
348
|
+
},
|
|
349
|
+
// 导出选中或本页数据
|
|
350
|
+
handleExport (isSelected) {
|
|
351
|
+
const tHeader = this.tableColumns.filter(res => res.slotType !== 'action').map(res => res.title)
|
|
352
|
+
const filterVal = this.tableColumns.map(res => res.dataIndex)
|
|
353
|
+
let exportData
|
|
354
|
+
if (isSelected) {
|
|
355
|
+
exportData = this.selectedRows
|
|
356
|
+
} else {
|
|
357
|
+
exportData = this.$refs.table.localDataSource
|
|
358
|
+
}
|
|
359
|
+
exportJson(tHeader, exportData.map(v => filterVal.map(j => v[j])), this.title + `数据_${new Date().toLocaleString()}`)
|
|
360
|
+
},
|
|
361
|
+
// 导出符合条件的数据
|
|
362
|
+
handleExportByQuery () {
|
|
363
|
+
const that = this
|
|
364
|
+
const conditionParams = Object.assign(that.form, that.fixedQueryForm)
|
|
365
|
+
this.$confirm({
|
|
366
|
+
title: '是否确认导出?',
|
|
367
|
+
content: '此操作将导出当前条件下所有数据而非选中数据',
|
|
368
|
+
onOk () {
|
|
369
|
+
exportData({
|
|
370
|
+
queryParamsName: that.queryParamsName,
|
|
371
|
+
queryParams: that.queryParams,
|
|
372
|
+
form: conditionParams
|
|
373
|
+
}, that.serviceName).then(res => {
|
|
374
|
+
let value = res
|
|
375
|
+
if (that.compatible === 'V4') {
|
|
376
|
+
value = res.value
|
|
377
|
+
}
|
|
378
|
+
window.open('/res/excel/export/' + value)
|
|
379
|
+
})
|
|
380
|
+
},
|
|
381
|
+
onCancel () {}
|
|
382
|
+
})
|
|
383
|
+
},
|
|
384
|
+
// 新增业务
|
|
385
|
+
add () {
|
|
386
|
+
this.$emit('add')
|
|
387
|
+
},
|
|
388
|
+
// 编辑业务
|
|
389
|
+
edit (id) {
|
|
390
|
+
this.editLoading = true
|
|
391
|
+
this.getEditData(id).then(modifyModelData => {
|
|
392
|
+
this.$emit('edit', modifyModelData)
|
|
393
|
+
this.editLoading = false
|
|
394
|
+
})
|
|
395
|
+
},
|
|
396
|
+
// 获取被编辑的数据
|
|
397
|
+
getEditData (id) {
|
|
398
|
+
const requestParameters = {
|
|
399
|
+
queryParamsName: this.queryParamsName,
|
|
400
|
+
queryParams: this.queryParams,
|
|
401
|
+
conditionParams: {},
|
|
402
|
+
pageNo: 1,
|
|
403
|
+
pageSize: 1
|
|
404
|
+
}
|
|
405
|
+
if (!id) {
|
|
406
|
+
this.selectId = this.selectedRowKeys[0]
|
|
407
|
+
} else {
|
|
408
|
+
this.selectId = id
|
|
409
|
+
}
|
|
410
|
+
const primaryKeyName = this.getPrimaryKeyName()
|
|
411
|
+
requestParameters.conditionParams[primaryKeyName] = this.selectId
|
|
412
|
+
requestParameters.f_businessid = this.selectId
|
|
413
|
+
if (this.isTableTemp) {
|
|
414
|
+
this.$emit('tempTableEdit', requestParameters)
|
|
415
|
+
return
|
|
416
|
+
}
|
|
417
|
+
return queryWithResource(requestParameters, this.serviceName).then(res => {
|
|
418
|
+
// 将更新需要的主键值加入到primaryKeyData中
|
|
419
|
+
const primaryKeyData = {}
|
|
420
|
+
primaryKeyData[primaryKeyName] = this.selectId
|
|
421
|
+
return { data: res.data[0], primaryKeyData: primaryKeyData, images: res.images, files: res.files }
|
|
422
|
+
})
|
|
423
|
+
},
|
|
424
|
+
// 删除业务
|
|
425
|
+
deleteItem () {
|
|
426
|
+
if (this.viewMode) {
|
|
427
|
+
this.$message.info('预览模式禁止删除')
|
|
428
|
+
return
|
|
429
|
+
}
|
|
430
|
+
Modal.confirm({
|
|
431
|
+
title: '提示',
|
|
432
|
+
content: '您本次要删除共' + this.selectedRowKeys.length + '条数据,确定操作吗?',
|
|
433
|
+
zIndex: 1001,
|
|
434
|
+
onOk: () => {
|
|
435
|
+
return new Promise((resolve, reject) => {
|
|
436
|
+
const requestParameters = {
|
|
437
|
+
queryParamsName: this.queryParamsName,
|
|
438
|
+
idList: this.selectedRowKeys
|
|
439
|
+
}
|
|
440
|
+
remove(requestParameters, this.serviceName).then(res => {
|
|
441
|
+
resolve(res)
|
|
442
|
+
this.$message.success('删除成功!')
|
|
443
|
+
this.refresh(true)
|
|
444
|
+
// afterDelete
|
|
445
|
+
this.$emit('afterDelete', requestParameters)
|
|
446
|
+
}).catch(e => {
|
|
447
|
+
reject(e)
|
|
448
|
+
this.$message.error('删除失败!')
|
|
449
|
+
})
|
|
450
|
+
})
|
|
451
|
+
},
|
|
452
|
+
onCancel () {}
|
|
453
|
+
})
|
|
454
|
+
},
|
|
455
|
+
// 导入业务
|
|
456
|
+
importData () {
|
|
457
|
+
this.$refs.importExcel.importExcelHandleOpen()
|
|
458
|
+
},
|
|
459
|
+
// 初始化临时表
|
|
460
|
+
async initTempTable (json) {
|
|
461
|
+
await this.createTempTable(this.queryParamsJson)
|
|
462
|
+
await this.insertTempTableData(this.queryParamsJson)
|
|
463
|
+
let result = {}
|
|
464
|
+
await post(CommonTempTable.initApplySubTable, {
|
|
465
|
+
define: json
|
|
466
|
+
}).then(res => {
|
|
467
|
+
console.log('子表临时表已创建')
|
|
468
|
+
result = res
|
|
469
|
+
})
|
|
470
|
+
return result
|
|
471
|
+
},
|
|
472
|
+
// 创建临时表sql生成
|
|
473
|
+
createTempTable (defineJson) {
|
|
474
|
+
const tableName = defineJson.tableName
|
|
475
|
+
const define = defineJson.column
|
|
476
|
+
return post(CommonTempTable.createTempTable, {
|
|
477
|
+
define: define,
|
|
478
|
+
tableName: tableName
|
|
479
|
+
}).then(res => {
|
|
480
|
+
return res
|
|
481
|
+
}, err => {
|
|
482
|
+
console.log(err)
|
|
483
|
+
})
|
|
484
|
+
},
|
|
485
|
+
// 插入临时表数据sql生成
|
|
486
|
+
insertTempTableData (defineJson) {
|
|
487
|
+
const tableName = defineJson.tableName
|
|
488
|
+
const params = {}
|
|
489
|
+
params.define = defineJson.column
|
|
490
|
+
params.applyId = defineJson.applyId
|
|
491
|
+
params.stepName = defineJson.stepName
|
|
492
|
+
params.tableName = tableName
|
|
493
|
+
return post(CommonTempTable.insertDataToTempTable, {
|
|
494
|
+
tempTableData: params
|
|
495
|
+
}).then(res => {
|
|
496
|
+
return res
|
|
497
|
+
})
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
</script>
|
|
502
|
+
<style lang="less" scoped>
|
|
503
|
+
.btn-success {
|
|
504
|
+
color: #ffffff;
|
|
505
|
+
}
|
|
506
|
+
.btn-success:enabled:hover {
|
|
507
|
+
background-color: #85CE61 !important;
|
|
508
|
+
border-color: #85CE61 !important;
|
|
509
|
+
}
|
|
510
|
+
.btn-success:enabled {
|
|
511
|
+
background-color: #67c23a;
|
|
512
|
+
border-color: #67c23a;
|
|
513
|
+
}
|
|
514
|
+
.btn-success:disabled {
|
|
515
|
+
color: rgba(0, 0, 0, 0.25);
|
|
516
|
+
}
|
|
517
|
+
.btn-warn {
|
|
518
|
+
color: #ffffff;
|
|
519
|
+
}
|
|
520
|
+
.btn-warn:enabled:hover {
|
|
521
|
+
background-color: #ffc833 !important;
|
|
522
|
+
border-color: #ffc833 !important;
|
|
523
|
+
}
|
|
524
|
+
.btn-warn:enabled {
|
|
525
|
+
background-color: #ffba00;
|
|
526
|
+
border-color: #ffba00;
|
|
527
|
+
}
|
|
528
|
+
.btn-warn:disabled {
|
|
529
|
+
color: rgba(0, 0, 0, 0.25);
|
|
530
|
+
}
|
|
531
|
+
</style>
|