doway-coms 2.2.34 → 2.3.2

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.
Files changed (82) hide show
  1. package/.browserslistrc +2 -2
  2. package/README.md +28 -28
  3. package/package.json +53 -53
  4. package/packages/AuditsList/index.js +7 -7
  5. package/packages/AuditsList/src/index.vue +266 -266
  6. package/packages/BaseButton/index.js +7 -7
  7. package/packages/BaseButton/src/index.vue +241 -241
  8. package/packages/BaseCheckbox/index.js +7 -7
  9. package/packages/BaseCheckbox/src/index.vue +134 -134
  10. package/packages/BaseDate/index.js +7 -7
  11. package/packages/BaseDate/src/index.vue +197 -197
  12. package/packages/BaseDateWeek/index.js +7 -7
  13. package/packages/BaseDateWeek/src/index.vue +163 -163
  14. package/packages/BaseDatetime/index.js +7 -7
  15. package/packages/BaseDatetime/src/index.vue +196 -196
  16. package/packages/BaseForm/index.js +7 -7
  17. package/packages/BaseForm/src/index.vue +730 -730
  18. package/packages/BaseGantt/index.js +9 -9
  19. package/packages/BaseGantt/src/index.vue +617 -617
  20. package/packages/BaseGrid/index.js +9 -9
  21. package/packages/BaseGrid/src/SeqSetting.vue +278 -278
  22. package/packages/BaseGrid/src/index.vue +3616 -3618
  23. package/packages/BaseGridAdjust/index.js +9 -9
  24. package/packages/BaseGridAdjust/src/index.vue +482 -482
  25. package/packages/BaseInput/index.js +7 -7
  26. package/packages/BaseInput/src/index.vue +164 -164
  27. package/packages/BaseIntervalInput/index.js +7 -7
  28. package/packages/BaseIntervalInput/src/index.vue +310 -310
  29. package/packages/BaseKanbanEmpty/index.js +7 -7
  30. package/packages/BaseKanbanEmpty/src/index.vue +176 -176
  31. package/packages/BaseNumberInput/index.js +7 -7
  32. package/packages/BaseNumberInput/src/index.vue +291 -291
  33. package/packages/BasePagination/index.js +7 -7
  34. package/packages/BasePagination/src/index.vue +91 -91
  35. package/packages/BasePictureCard/index.js +7 -7
  36. package/packages/BasePictureCard/src/index.vue +580 -580
  37. package/packages/BasePrintPreview/index.js +7 -7
  38. package/packages/BasePrintPreview/src/index.vue +129 -129
  39. package/packages/BasePulldown/index.js +7 -7
  40. package/packages/BasePulldown/src/index.vue +1282 -1285
  41. package/packages/BaseSearch/index.js +7 -7
  42. package/packages/BaseSearch/src/index.vue +935 -935
  43. package/packages/BaseSelect/index.js +7 -7
  44. package/packages/BaseSelect/src/index.vue +155 -155
  45. package/packages/BaseSelectMulti/index.js +7 -7
  46. package/packages/BaseSelectMulti/src/index.vue +148 -148
  47. package/packages/BaseTextArea/index.js +7 -7
  48. package/packages/BaseTextArea/src/index.vue +178 -178
  49. package/packages/BaseTime/index.js +7 -7
  50. package/packages/BaseTime/src/index.vue +166 -166
  51. package/packages/BaseTool/index.js +7 -7
  52. package/packages/BaseTool/src/index.vue +349 -349
  53. package/packages/BaseToolStatus/index.js +7 -7
  54. package/packages/BaseToolStatus/src/index.vue +388 -388
  55. package/packages/BaseTreeSelect/index.js +8 -8
  56. package/packages/BaseTreeSelect/src/index.vue +437 -437
  57. package/packages/LeaveAMessage/index.js +7 -7
  58. package/packages/LeaveAMessage/src/index.vue +601 -601
  59. package/packages/index.js +191 -191
  60. package/packages/styles/default.css +78 -78
  61. package/packages/styles/default.less +84 -84
  62. package/packages/utils/api.js +107 -107
  63. package/packages/utils/auth.js +38 -38
  64. package/packages/utils/common.js +610 -610
  65. package/packages/utils/dom.js +181 -181
  66. package/packages/utils/enum.js +86 -86
  67. package/packages/utils/filters.js +472 -472
  68. package/packages/utils/gridFormat.js +66 -66
  69. package/packages/utils/msg.js +84 -84
  70. package/packages/utils/patchFiles.js +44 -44
  71. package/packages/utils/request.js +178 -178
  72. package/packages/utils/store.js +309 -305
  73. package/vue.config.js +59 -59
  74. package/dist/css/chunk-vendors.7f83d8f9.css +0 -8
  75. package/dist/css/index.7946d50b.css +0 -1
  76. package/dist/favicon.ico +0 -0
  77. package/dist/js/chunk-vendors.28fda91d.js +0 -340
  78. package/dist/js/index.49bc6add.js +0 -2
  79. package/lib/doway-coms.common.js +0 -120397
  80. package/lib/doway-coms.css +0 -1
  81. package/lib/doway-coms.umd.js +0 -120407
  82. package/lib/doway-coms.umd.min.js +0 -328
@@ -1,1285 +1,1282 @@
1
- <template>
2
- <div class="d-control-container">
3
- <div
4
- class="d-control-label"
5
- v-if="showLabel === true"
6
- :style="{ width: labelWidth > 0 ? labelWidth + 'px' : 'none' }"
7
- >
8
- {{ label }}
9
- <span v-if="rules && rules['required']" class="d-control-label-required"
10
- >*</span
11
- >
12
- <Tooltip :title="tooltip" v-if="tooltip" style="margin: 0 2px">
13
- <img src="../../styles/icon/help.png" alt="" style="width: 14px" />
14
- </Tooltip>
15
- </div>
16
- <div
17
- :class="{
18
- 'd-control': showLabel === true,
19
- 'd-grid-control': showLabel === false,
20
- }"
21
- >
22
- <VxePulldown
23
- style="width: 100%"
24
- @hide-panel="pullDownHideEvent"
25
- ref="pulldownRef"
26
- v-if="edit === true"
27
- transfer
28
- >
29
- <template #default>
30
- <ValidationProvider :name="label" v-slot="v" :rules="rules">
31
- <a-input
32
- :size="'small'"
33
- allow-clear
34
- @change="inputChangeEvent"
35
- class="inner-cell-control"
36
- v-model="currentValue"
37
- @click="inputClickEvent"
38
- @focus="inputFocusEvent"
39
- @blur="inputBlurEvent"
40
- @keydown="inputKeydownEvent"
41
- @keyup="inputKeyupEvent"
42
- :class="{ 'd-error-input': v.errors.length > 0 }"
43
- :disabled="disabled"
44
- ></a-input>
45
- <div class="d-error-msg">
46
- {{ v.errors[0] }}
47
- </div>
48
- </ValidationProvider>
49
- </template>
50
- <template #dropdown>
51
- <div class="pulldown-grid interceptor-class">
52
- <vxe-grid
53
- size="mini"
54
- border
55
- :row-class-name="gridRowStyle"
56
- highlight-current-row
57
- :keyboard-config="{ isArrow: true }"
58
- highlight-hover-row
59
- auto-resize
60
- resizable
61
- :loading="gridLoading"
62
- height="auto"
63
- ref="pupupGridView"
64
- :data="searchRows"
65
- @cell-click="gridCellClick"
66
- @filter-visible="filterVisible"
67
- :columns="internalColumns"
68
- :checkbox-config="{ checkMethod: checkMethod }"
69
- @sort-change="sortChange"
70
- :filter-config="{
71
- remote: true,
72
- }"
73
- :sort-config="{
74
- multiple: true,
75
- remote: true,
76
- chronological: true,
77
- defaultSort: defaultSort,
78
- }"
79
- >
80
- <!-- :pager-config="gridPagerConfig" -->
81
- <!-- @page-change="pageChangeEvent" -->
82
- <template #matCode_header="{ column }">
83
- <div class="first-col">
84
- <div class="first-col-top">
85
- {{ column.title }}
86
- </div>
87
- <div class="first-col-bottom">
88
- <input style="width: 100%" />
89
- </div>
90
- </div>
91
- </template>
92
- <!-- 普通输入框的过滤筛选-->
93
- <template #text_filter="{ column }">
94
- <div class="interceptor-class">
95
- <div v-for="(item, $index) in column.filters" :key="$index">
96
- <a-input
97
- allowClear
98
- v-model="item.data"
99
- @keyup.enter.native="filterConfirm(column)"
100
- style="margin-bottom: 5px"
101
- />
102
- </div>
103
- <a-button @click="filterAddExp(column)">添加条件</a-button>
104
- <a-button @click="filterConfirm(column)">确认</a-button>
105
- </div>
106
- </template>
107
- <!-- 选择筛选框-->
108
- <template #select_filter="{ column }">
109
- <div class="interceptor-class">
110
- <a-checkbox-group
111
- v-model="column.filters[0].data"
112
- @keyup.enter.native="filterConfirm(column)"
113
- >
114
- <div style="max-height: 200px; overflow-y: scroll">
115
- <div
116
- style="text-align: left"
117
- v-for="loopSource in column.params.dataSource"
118
- :key="loopSource.value"
119
- >
120
- <a-checkbox
121
- :value="loopSource.value"
122
- style="margin: 5px 0"
123
- >{{ loopSource.caption }}
124
- </a-checkbox>
125
- </div>
126
- </div>
127
- </a-checkbox-group>
128
- <br />
129
- <a-button @click="filterConfirm(column)">确认</a-button>
130
- </div>
131
- </template>
132
- <template #pager>
133
- <a-row>
134
- <a-col :span="8">
135
- <a-button
136
- v-if="isMultiSelect === true"
137
- type="primary"
138
- size="small"
139
- style="margin: 5px"
140
- @click="multiSelectConfirm"
141
- >
142
- 确认选择
143
- </a-button>
144
- <a-button
145
- v-if="popupAddName"
146
- type="primary"
147
- size="small"
148
- style="margin: 5px"
149
- @click="pagerBtnClick(btn)"
150
- >
151
- 新增
152
- </a-button>
153
-
154
- <template v-if="optBtns.length > 0">
155
- <a-button
156
- v-for="btn in optBtns"
157
- :key="btn.field"
158
- type="primary"
159
- size="small"
160
- style="margin: 5px"
161
- @click="pagerBtnClick(btn)"
162
- >
163
- {{ btn.name }}
164
- </a-button>
165
- </template>
166
- </a-col>
167
- <a-col :span="16">
168
- <vxe-pager
169
- align="right"
170
- size="mini"
171
- :current-page.sync="gridPagerConfig.currentPage"
172
- :page-size.sync="gridPagerConfig.pageSize"
173
- :total="gridPagerConfig.total"
174
- @page-change="pageChangeEvent"
175
- >
176
- </vxe-pager>
177
- </a-col>
178
- </a-row>
179
- </template>
180
- </vxe-grid>
181
- </div>
182
- </template>
183
- </VxePulldown>
184
- <span v-if="edit === false">
185
- <a v-if="route" @click="routeLinkClick">{{ currentValue }}</a>
186
- <span v-else> {{ currentValue }}</span>
187
- </span>
188
- </div>
189
- <keep-alive>
190
- <div
191
- :is="popupAddName"
192
- ref="pupupAddView"
193
- @popupSaveAfter="popupSaveAfter"
194
- ></div>
195
- </keep-alive>
196
- </div>
197
- </template>
198
-
199
- <script>
200
- import XEUtils from 'xe-utils'
201
- import { sysRowState, sysFormState, controlType } from '../../utils/enum'
202
- import { replaceParamString, replaceParam } from '../../utils/common'
203
- import request from '../../utils/request'
204
- import { Input, Button, Row, Col, Checkbox } from 'ant-design-vue'
205
- import { ValidationProvider } from 'vee-validate'
206
- import { Pulldown } from 'vxe-table'
207
- import { Tooltip } from 'ant-design-vue'
208
- export default {
209
- name: 'BasePulldown',
210
- components: {
211
- 'a-input': Input,
212
- 'a-button': Button,
213
- 'a-row': Row,
214
- 'a-col': Col,
215
- 'a-checkbox': Checkbox,
216
- 'a-checkbox-group': Checkbox.Group,
217
- VxePulldown: Pulldown,
218
- ValidationProvider,
219
- Tooltip,
220
- },
221
- data() {
222
- return {
223
- fetchFields: '',
224
- internalColumns: [],
225
- isInputChanged: false,
226
- inputTimeout: null,
227
- searchRows: [],
228
- filterCols: [],
229
- gridLoading: false,
230
- gridPagerConfig: {
231
- total: 0,
232
- currentPage: 1,
233
- pageSize: 10,
234
- },
235
- sorts: [],
236
- defaultSort: [],
237
- filterExpression: {
238
- operator: 'and',
239
- expressions: [],
240
- },
241
- newApiObj:{
242
- newApi:''
243
- }
244
- }
245
- },
246
- props: {
247
- dataSource: {
248
- type: Array,
249
- default: function() {
250
- return []
251
- }
252
- },
253
- labelWidth: {
254
- type: Number,
255
- default: function () {
256
- return 0
257
- },
258
- },
259
- isMultiSelect: {
260
- type: Boolean,
261
- default: function () {
262
- return false
263
- },
264
- },
265
- popupAddName: {
266
- type: String,
267
- default: function () {
268
- return null
269
- },
270
- },
271
- popupAddPath: {
272
- type: String,
273
- default: function () {
274
- return null
275
- },
276
- },
277
- rules: {
278
- type: Object,
279
- default: function () {
280
- return null
281
- },
282
- },
283
- showLabel: {
284
- type: Boolean,
285
- default: function () {
286
- return true
287
- },
288
- },
289
- label: {
290
- type: String,
291
- default: function () {
292
- return ''
293
- },
294
- },
295
- defaultExpression: {
296
- type: String,
297
- default: function () {
298
- return ''
299
- },
300
- },
301
- formRow: {
302
- type: Object,
303
- default: function () {
304
- return {}
305
- },
306
- },
307
- row: {
308
- type: Object,
309
- default: function () {
310
- return {}
311
- },
312
- },
313
- edit: {
314
- type: Boolean,
315
- default: function () {
316
- return false
317
- },
318
- },
319
- route: Object,
320
- placeholder: {
321
- // 提示信息
322
- type: String,
323
- },
324
- api: {
325
- // api接口
326
- type: String,
327
- },
328
- field: {
329
- type: String,
330
- },
331
- pageSize: {
332
- // 分页数量,默认不分页
333
- type: Number,
334
- default: () => {
335
- return 0
336
- },
337
- },
338
- columns: {
339
- // 列集合
340
- type: Array,
341
- default: () => {
342
- return []
343
- },
344
- },
345
- isOld: {
346
- // 列集合
347
- type: Boolean,
348
- default: () => {
349
- return false
350
- },
351
- },
352
- exps: {
353
- // 条件
354
- type: Array,
355
- default: () => {
356
- return []
357
- },
358
- },
359
- value: {
360
- type: String,
361
- default: function () {
362
- return ''
363
- },
364
- },
365
- optBtns: {
366
- // 操作按钮
367
- type: Array,
368
- default: () => {
369
- return []
370
- },
371
- },
372
- gridTable: {
373
- // 操作按钮
374
- type: Object,
375
- default: () => {
376
- return null
377
- },
378
- },
379
- immediate: {
380
- type: Boolean,
381
- default: true,
382
- },
383
- isLocalData: {
384
- type: Boolean,
385
- default: false,
386
- },
387
- tooltip: {
388
- type: String,
389
- default: function () {
390
- return ''
391
- },
392
- },
393
- propTableData: {
394
- type: Array,
395
- default: function () {
396
- return []
397
- },
398
- },
399
- contrasts: {
400
- type: Array,
401
- default: function () {
402
- return []
403
- },
404
- },
405
- allowAutoClear:{
406
- type:Boolean,
407
- default:function(){
408
- return true
409
- }
410
- },
411
- disabled:{
412
- type:Boolean,
413
- default:function(){
414
- return false
415
- }
416
- },
417
- },
418
- watch: {
419
- // 触发下拉表格字段更改,直接重新渲染
420
- columns: {
421
- handler(newVal) {
422
- this.reloadColumn()
423
- },
424
- deep: true
425
- }
426
- },
427
- computed: {
428
- currentValue: {
429
- // 动态计算currentValue的值
430
- get: function () {
431
- // return this.value // 将props中的value赋值给currentValue
432
- for (let i = 0; i < this.dataSource.length; i++) {
433
- const element = this.dataSource[i];
434
- if (this.value === element.value) {
435
- return element.caption
436
- }
437
- }
438
- return this.value
439
- },
440
- set: function (val) {
441
- this.$emit('input', val) // 通过$emit触发父组件
442
- },
443
- },
444
- },
445
- created() {
446
- // if (this.popupAddName && !this.$options.components[this.popupAddName]) {
447
- // // const tempRequire = require('@/views' + this.popupAddPath + '.vue').default
448
- // // this.$options.components[this.popupAddName] = tempRequire
449
- // this.$options.components[this.popupAddName] = () =>
450
- // import('@/views' + this.popupAddPath + '.vue')
451
- // }
452
- this.gridPagerConfig.pageSize = this.pageSize
453
-
454
- this.internalColumns.push({
455
- type: 'seq',
456
- fixed: 'left',
457
- width: 50,
458
- })
459
-
460
- if (this.isMultiSelect === true) {
461
- this.internalColumns.push({
462
- type: 'checkbox',
463
- fixed: 'left',
464
- width: 40,
465
- })
466
- }
467
-
468
- for (let i = 0; i < this.columns.length; i++) {
469
- this.fetchFields = this.fetchFields + this.columns[i].field + ','
470
- this.columns[i]['params'] = {
471
- dataSource: [],
472
- }
473
- if (this.columns[i].dataSource) {
474
- this.columns[i]['params'].dataSource = this.columns[i].dataSource
475
- }
476
- if (!this.columns[i].width) {
477
- this.columns[i]['width'] = 100
478
- }
479
- if (this.columns[i].isCheckbox === true) {
480
- this.columns[i]['type'] = 'checkbox'
481
- }
482
- if (!this.columns[i].controlType) {
483
- this.columns[i].controlType = 'text'
484
- }
485
- // 设置字段的过滤插槽
486
- if (this.columns[i].filter) {
487
- this.columns[i]['filterMultiple'] = false
488
-
489
- switch (this.columns[i].controlType) {
490
- case 'checkbox':
491
- this.columns[i]['slots'] = {
492
- filter: `checkbox_filter`,
493
- }
494
- break
495
- case 'select':
496
- this.columns[i]['slots'] = {
497
- filter: `select_filter`,
498
- }
499
- this.columns[i]['filters'] = [
500
- {
501
- data: [],
502
- },
503
- ]
504
- break
505
- default:
506
- this.columns[i]['slots'] = {
507
- filter: `text_filter`,
508
- }
509
- this.columns[i]['filters'] = [
510
- {
511
- data: '',
512
- },
513
- ]
514
- break
515
- }
516
- }
517
- // 默认排序
518
- if (this.columns[i].defaultSort) {
519
- this.defaultSort.push({
520
- field: this.columns[i].field,
521
- order: this.columns[i].defaultSort,
522
- })
523
- this.sorts.push([this.columns[i].field, this.columns[i].defaultSort])
524
- }
525
- this.internalColumns.push(this.columns[i])
526
- if (this.columns[i].filter === true) {
527
- this.filterCols.push(this.columns[i])
528
- }
529
- }
530
- },
531
- methods: {
532
- // 刷新重置字段列
533
- reloadColumn() {
534
- this.internalColumns = []
535
- this.fetchFields = []
536
- this.internalColumns.push({
537
- type: 'seq',
538
- fixed: 'left',
539
- width: 50,
540
- })
541
- if (this.isMultiSelect === true) {
542
- this.internalColumns.push({
543
- type: 'checkbox',
544
- fixed: 'left',
545
- width: 40,
546
- })
547
- }
548
- for (let i = 0; i < this.columns.length; i++) {
549
- this.fetchFields = this.fetchFields + this.columns[i].field + ','
550
- this.columns[i]['params'] = {
551
- dataSource: [],
552
- }
553
- if (this.columns[i].dataSource) {
554
- this.columns[i]['params'].dataSource = this.columns[i].dataSource
555
- }
556
- if (!this.columns[i].width) {
557
- this.columns[i]['width'] = 100
558
- }
559
- if (this.columns[i].isCheckbox === true) {
560
- this.columns[i]['type'] = 'checkbox'
561
- }
562
- if (!this.columns[i].controlType) {
563
- this.columns[i].controlType = 'text'
564
- }
565
- // 设置字段的过滤插槽
566
- if (this.columns[i].filter) {
567
- this.columns[i]['filterMultiple'] = false
568
-
569
- switch (this.columns[i].controlType) {
570
- case 'checkbox':
571
- this.columns[i]['slots'] = {
572
- filter: `checkbox_filter`,
573
- }
574
- break
575
- case 'select':
576
- this.columns[i]['slots'] = {
577
- filter: `select_filter`,
578
- }
579
- this.columns[i]['filters'] = [
580
- {
581
- data: [],
582
- },
583
- ]
584
- break
585
- default:
586
- this.columns[i]['slots'] = {
587
- filter: `text_filter`,
588
- }
589
- this.columns[i]['filters'] = [
590
- {
591
- data: '',
592
- },
593
- ]
594
- break
595
- }
596
- }
597
- // 默认排序
598
- if (this.columns[i].defaultSort) {
599
- this.defaultSort.push({
600
- field: this.columns[i].field,
601
- order: this.columns[i].defaultSort,
602
- })
603
- this.sorts.push([this.columns[i].field, this.columns[i].defaultSort])
604
- }
605
- this.internalColumns.push(this.columns[i])
606
- if (this.columns[i].filter === true) {
607
- this.filterCols.push(this.columns[i])
608
- }
609
- }
610
- this.$refs.pupupGridView.refreshColumn()
611
- },
612
- gridRowStyle(scope) {
613
- if (scope.row.sysRepeat === true) {
614
- return 'row--pending'
615
- }
616
- // if(scope.row.)
617
- },
618
- clearInputValue() {
619
- if (this.isInputChanged === true&&this.allowAutoClear) {
620
- this.setLinkValue(null, this.row)
621
- this.$emit('selectChanged', null)
622
- }
623
- },
624
- routeLinkClick() {
625
- let tempRouteName = this.route.name
626
- let tempRouteQuery = this.row[this.route.field]
627
- if (XEUtils.isArray(tempRouteName)) {
628
- //需要不同条件跳转不同页面
629
- for (let i = 0; i < tempRouteName.length; i++) {
630
- if (tempRouteName[i].value === this.row[tempRouteName[i].field]) {
631
- tempRouteQuery =
632
- this.row[tempRouteName[i].query] || this.row[this.route.field]
633
- tempRouteName = tempRouteName[i].name
634
- break
635
- }
636
- }
637
- }
638
- this.$router.pushRoute({
639
- name: tempRouteName,
640
- query: { id: tempRouteQuery },
641
- })
642
- },
643
- /**
644
- * 输入框改变事件
645
- */
646
- inputChangeEvent(event) {
647
- this.isInputChanged = true
648
- if (event.type === 'click' && event.pointerType === 'mouse') {
649
- //点击了清空按钮
650
- this.$nextTick(() => {
651
- this.clearInputValue()
652
- this.inputClickEvent(null)
653
- })
654
- }
655
- },
656
- inputBlurEvent(event) {},
657
- /**
658
- * 输入框获取焦点事件
659
- */
660
- inputFocusEvent(event) {
661
- event.currentTarget.select()
662
- // this.$refs.pulldownRef.showPanel()
663
- // this.searchData()
664
- },
665
- /**
666
- * Tab键隐藏面板
667
- */
668
- inputKeydownEvent(event) {
669
- if (event.keyCode === 9) {
670
- //tab事件
671
- this.$refs.pulldownRef.hidePanel()
672
- this.clearInputValue()
673
- }
674
- },
675
- inputClickEvent(event) {
676
- if (this.$refs.pulldownRef.isPanelVisible() === false) {
677
- this.$refs.pulldownRef.showPanel()
678
- this.clearColumnFilter()
679
- this.searchData()
680
- } else {
681
- this.$refs.pulldownRef.hidePanel()
682
- // 点击输入框隐藏panel时清空输入框
683
- if(this.allowAutoClear){
684
- this.currentValue = ''
685
- }
686
- }
687
- },
688
- /**
689
- * 输入库输入事件
690
- */
691
- inputKeyupEvent(event) {
692
- //好像ok
693
- if (!this.immediate && event.keyCode !== 13) {
694
- console.debug('davistest')
695
- } else {
696
- if (this.inputTimeout) {
697
- clearTimeout(this.inputTimeout)
698
- }
699
- let vm = this
700
- this.inputTimeout = setTimeout(() => {
701
- //判断面板是否打开
702
- if (vm.$refs.pulldownRef.isPanelVisible() === false) {
703
- vm.$refs.pulldownRef.showPanel()
704
- }
705
- vm.searchData()
706
- }, 500)
707
- }
708
- },
709
- /**
710
- * 网格列选中事件
711
- */
712
- gridCellClick({ row, column }) {
713
- if (row.sysRepeat === true) {
714
- return
715
- }
716
- if (column.type === 'seq' || column.type === 'checkbox') {
717
- return
718
- }
719
- this.isInputChanged = false
720
- this.setLinkValue(row, this.row)
721
- this.$emit('selectChanged', row)
722
- this.$refs.pulldownRef.hidePanel()
723
- },
724
- setLinkValue(pulldownRow, oriRow) {
725
- for (let i = 0; i < this.internalColumns.length; i++) {
726
- if (this.internalColumns[i].linkField) {
727
- let tempLinkFields = this.internalColumns[i].linkField.split('.')
728
- let tempRow = oriRow
729
- // for(let j=0;j<tempLinkFields.length;j++){
730
- // let tempField = tempLinkFields[j]
731
- // //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
732
- // if (!(tempField in tempRow)) {
733
- // this.$antwarning(
734
- // '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
735
- // )
736
- // break
737
- // }
738
- // if(j===tempLinkFields.length-1){
739
- // if (pulldownRow === null) {
740
- // if (this.internalColumns[i].nullClear === false) {
741
- // //是否空值清除数据,用于可选可输入的控件
742
- // continue
743
- // }
744
- // this.$set(tempRow, tempField, null)
745
- // } else {
746
- // this.$set(
747
- // tempRow,
748
- // tempField,
749
- // this.getLinkValue(tempField, pulldownRow)
750
- // )
751
- // }
752
- // }else{
753
- // tempRow = tempRow[tempField]
754
- // }
755
- // }
756
-
757
- //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
758
- if (!(this.internalColumns[i].linkField in oriRow)) {
759
- this.$antwarning(
760
- '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
761
- )
762
- continue
763
- }
764
- if (pulldownRow === null) {
765
- if (this.internalColumns[i].nullClear === false) {
766
- //是否空值清楚数据,用于可选可输入的控件
767
- continue
768
- }
769
- this.$set(oriRow, this.internalColumns[i].linkField, null)
770
- } else {
771
- this.$set(
772
- oriRow,
773
- this.internalColumns[i].linkField,
774
- this.getLinkValue(this.internalColumns[i].field, pulldownRow)
775
- )
776
- }
777
- }
778
- }
779
- },
780
- getLinkValue(field, row) {
781
- let linkField = field.split('.')
782
- if (linkField.length > 1) {
783
- let fieldValue = row
784
- for (let i = 0; i < linkField.length; i++) {
785
- if (
786
- fieldValue[linkField[i]] === undefined ||
787
- fieldValue[linkField[i]] === null
788
- ) {
789
- return null
790
- }
791
- fieldValue = fieldValue[linkField[i]]
792
- }
793
- return fieldValue
794
- }
795
- return row[field]
796
- },
797
- /**
798
- * 左下角按钮点击事件
799
- */
800
- pagerBtnClick(btn) {
801
- this.$refs.pupupAddView.show()
802
- // this.$emit('pulldownBtnClick', btn)
803
- this.$refs.pulldownRef.hidePanel()
804
- },
805
- // 多选内容时,若数据不满足条件,不可选中
806
- checkMethod({ row }) {
807
- if (row.sysRepeat) {
808
- return false
809
- }
810
- return true
811
- },
812
- /**
813
- * 确认多选
814
- */
815
- multiSelectConfirm() {
816
- this.isInputChanged = false
817
- this.$emit(
818
- 'confirmMultiSelect',
819
- this,
820
- this.$refs.pupupGridView.getCheckboxRecords(true)
821
- )
822
- this.$refs.pulldownRef.hidePanel()
823
- },
824
- popupSaveAfter(pupupAddRowInfo) {
825
- let postData = {
826
- fields: null,
827
- begin: 1,
828
- size: 1,
829
- expression: {},
830
- sorts: '',
831
- }
832
- let tempKeyExp = XEUtils.find(
833
- this.internalColumns,
834
- (item) => item.isKey === true
835
- )
836
- postData.expression = {
837
- operator: 'and',
838
- expressions: [
839
- {
840
- operator: 'and',
841
- expressions: [
842
- {
843
- field: tempKeyExp.field,
844
- operator: 'EQ',
845
- value: pupupAddRowInfo['id'],
846
- },
847
- ],
848
- },
849
- ],
850
- }
851
- let vm = this
852
- let tempApi = this.getPostApi(postData)
853
- request({
854
- url: tempApi,
855
- method: 'post',
856
- data: postData,
857
- })
858
- .then((responseData) => {
859
- if (responseData.content.length > 0) {
860
- vm.setLinkValue(responseData.content[0], vm.row)
861
- vm.$emit('selectChanged', responseData.content[0])
862
- }
863
- })
864
- .catch((error) => {
865
- console.error(error)
866
- })
867
- .finally(() => {})
868
- },
869
- /**
870
- * 分页改变事件
871
- */
872
- pageChangeEvent({ currentPage, pageSize }) {
873
- this.gridPagerConfig.currentPage = currentPage
874
- this.gridPagerConfig.pageSize = pageSize
875
- this.searchData()
876
- },
877
- /**
878
- * 面板隐藏事件
879
- */
880
- pullDownHideEvent({ $event }) {
881
- this.clearInputValue()
882
- },
883
- /**
884
- * 查询数据
885
- */
886
- searchData() {
887
- if (this.isLocalData === true) {
888
- let tempSearch = {
889
- value: this.currentValue,
890
- dataSource: [],
891
- }
892
- this.$emit('preSearch', tempSearch)
893
- this.searchRows = tempSearch.dataSource
894
- this.gridPagerConfig.total = tempSearch.dataSource.length
895
- return
896
- }
897
-
898
- let tempExp = {
899
- operator: 'or',
900
- expressions: [],
901
- }
902
- if (this.isOld === true) {
903
- tempExp = ''
904
- }
905
- if (this.filterExpression.expressions.length > 0) {
906
- tempExp.expressions.push(this.filterExpression)
907
- } else if (this.currentValue) {
908
- for (let i = 0; i < this.filterCols.length; i++) {
909
- if (this.isOld === true) {
910
- tempExp =
911
- tempExp +
912
- this.filterCols[i].field +
913
- '.contains("' +
914
- this.currentValue +
915
- '")'
916
- if (i < this.filterCols.length - 1) {
917
- tempExp = tempExp + ' or '
918
- }
919
- } else {
920
- if (this.filterCols[i].controlType == 'number') {
921
- tempExp.expressions.push({
922
- field: this.filterCols[i].field,
923
- operator: 'EQ',
924
- value: Number(this.currentValue),
925
- })
926
- } else {
927
- tempExp.expressions.push({
928
- field: this.filterCols[i].field,
929
- operator: 'CO',
930
- value: this.currentValue,
931
- })
932
- }
933
- }
934
- }
935
- }
936
- if (this.isOld === true && tempExp.length > 0) {
937
- tempExp = '(' + tempExp + ')'
938
- }
939
-
940
- if (this.defaultExpression) {
941
- let tempDefault = replaceParamString(
942
- this.defaultExpression,
943
- this.formRow,
944
- this.$store.getters.moduleSelectItems[this.$route.meta.moduleId]
945
- )
946
-
947
- if (tempExp) {
948
- tempExp = tempExp + ' and (' + tempDefault + ')'
949
- } else {
950
- tempExp = tempDefault
951
- }
952
- }
953
-
954
- let postExpression = {
955
- field: this.field,
956
- expression: tempExp,
957
- extendParams: {},
958
- }
959
- let repeatRowInfo = {
960
- field: '',
961
- values: [],
962
- }
963
- //查询之前从外部组件构造其他的条件
964
- this.$emit('preSearch', postExpression, repeatRowInfo, this.row,this.newApiObj)
965
- let postData = {
966
- fields: this.fetchFields,
967
- begin:
968
- (this.gridPagerConfig.currentPage - 1) *
969
- this.gridPagerConfig.pageSize +
970
- 1,
971
- size: this.gridPagerConfig.pageSize,
972
- expression: postExpression.expression,
973
- sorts: this.sorts,
974
- extendParams: postExpression.extendParams,
975
- }
976
- // console.log(postData.sorts);
977
- let tempApi = this.getPostApi(postData)
978
-
979
- // let tempApi = this.api
980
- // if (this.api.indexOf('?') > 0) {
981
- // tempApi = this.api.substring(0, this.api.indexOf('?'))
982
- // let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
983
- // tempExtenParams = replaceParam(tempExtenParams, this.formRow)
984
- // let tempSplitParams = tempExtenParams.split('&')
985
- // for (let i = 0; i < tempSplitParams.length; i++) {
986
- // let tempSplitValue = tempSplitParams[i].split('=')
987
- // this.$set(
988
- // postData.extendParams,
989
- // tempSplitValue[0],
990
- // tempSplitValue[1]
991
- // )
992
- // }
993
- // }
994
- let vm = this
995
- vm.gridLoading = true
996
- request({
997
- url: tempApi,
998
- method: 'post',
999
- data: postData,
1000
- })
1001
- .then((responseData) => {
1002
- if (vm.isOld === true) {
1003
- vm.searchRows = responseData.data
1004
- vm.gridPagerConfig.total = responseData.extData.totalRows
1005
- } else {
1006
- vm.searchRows = responseData.content
1007
- vm.$refs.pupupGridView.loadData(vm.searchRows)
1008
- vm.gridPagerConfig.total = responseData.otherContent.totalRows
1009
- }
1010
- if (repeatRowInfo.field) {
1011
- //设置重复值
1012
- XEUtils.arrayEach(vm.searchRows, (item) => {
1013
- if (
1014
- XEUtils.arrayIndexOf(
1015
- repeatRowInfo.values,
1016
- item[repeatRowInfo.field]
1017
- ) > -1
1018
- ) {
1019
- item['sysRepeat'] = true
1020
- } else {
1021
- item['sysRepeat'] = false
1022
- }
1023
- })
1024
- }
1025
- // 若当前表格内只有一行,则不进行判断
1026
- if (vm.propTableData.length == 1) {
1027
- return
1028
- }
1029
- // 设置字段sysRepeat后,所定字段的值全部相同则不可选择
1030
- let fieldNames = vm.columns
1031
- .filter((x) => x.sysRepeat)
1032
- .map((y) => {
1033
- return {
1034
- field: y.field,
1035
- linkField: y.linkField,
1036
- }
1037
- })
1038
- if (fieldNames.length) {
1039
- vm.searchRows.forEach((info) => {
1040
- // 当一次创建多行时,过滤需特定字段不可为空的
1041
- // 获取数组对象,根据选定字段,过滤选定字段都为空的
1042
- let tempArr = vm.propTableData.filter((currentInfo) => {
1043
- let tempD = []
1044
- fieldNames.forEach((z) => {
1045
- // 字段的值若为null、undefined,记录过滤掉
1046
- if (!currentInfo[z.linkField]) {
1047
- tempD.push(true)
1048
- }
1049
- })
1050
- return tempD.length !== fieldNames.length
1051
- })
1052
- let arr = []
1053
- // 分为有参查询和无参查询
1054
- if (tempExp.expressions.length && fieldNames.length == 1) {
1055
- for (let j = 0; j < fieldNames.length; j++) {
1056
- let mapArr = tempArr.map(
1057
- (item) => item[fieldNames[j].linkField]
1058
- )
1059
- let setArr = new Set(mapArr)
1060
- if (setArr.size < mapArr.length) {
1061
- arr.push(true)
1062
- }
1063
- }
1064
- if (fieldNames.length === arr.length) {
1065
- info.sysRepeat = true
1066
- }
1067
- } else {
1068
- tempArr.forEach((item) => {
1069
- // 接口字段可能和表字段field不一致,linkField一致
1070
- for (let j = 0; j < fieldNames.length; j++) {
1071
- if (
1072
- info[fieldNames[j].field] == item[fieldNames[j].linkField]
1073
- ) {
1074
- arr.push(true)
1075
- }
1076
- }
1077
- if (fieldNames.length === arr.length) {
1078
- info.sysRepeat = true
1079
- }
1080
- })
1081
- }
1082
- if (info.sysRepeat && this.contrasts.length) {
1083
- let flag = 0
1084
- info.sysRepeat = false
1085
- XEUtils.arrayEach(this.propTableData, (item) => {
1086
- if (item[this.field] === info[this.field]) {
1087
- XEUtils.arrayEach(this.contrasts, (loop) => {
1088
- if (
1089
- item[loop] === this.row[loop] &&
1090
- item.id !== this.row.id
1091
- ) {
1092
- flag++
1093
- }
1094
- })
1095
- }
1096
- })
1097
- if (flag === this.contrasts.length) {
1098
- info.sysRepeat = true
1099
- }
1100
- }
1101
- })
1102
- }
1103
- })
1104
- .catch((error) => {
1105
- console.error(error)
1106
- })
1107
- .finally(() => {
1108
- vm.gridLoading = false
1109
- })
1110
- },
1111
- getPostApi(postData) {
1112
- let tempApi = this.api
1113
- if(this.newApiObj.newApi){
1114
- tempApi=this.newApiObj.newApi
1115
- }
1116
- if (this.api.indexOf('?') > 0) {
1117
- tempApi = this.api.substring(0, this.api.indexOf('?'))
1118
- let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1119
- tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1120
- let tempSplitParams = tempExtenParams.split('&')
1121
- for (let i = 0; i < tempSplitParams.length; i++) {
1122
- let tempSplitValue = tempSplitParams[i].split('=')
1123
- this.$set(postData.extendParams, tempSplitValue[0], tempSplitValue[1])
1124
- }
1125
- }
1126
- return tempApi
1127
- },
1128
- sortChange({ column, property, order, sortBy, sortList, $event }) {
1129
- let currentSort = sortList.map((x) => {
1130
- return [x.field, x.order]
1131
- })
1132
- this.sorts = currentSort
1133
- this.searchData()
1134
- },
1135
-
1136
- // 下拉容器筛选条件被触发
1137
- filterVisible({ column }) {
1138
- XEUtils.remove(column.filters, (item) => {
1139
- return item.data === ''
1140
- })
1141
- if (column.filters.length === 0) {
1142
- column.filters.push({
1143
- data: '',
1144
- })
1145
- }
1146
- },
1147
- filterConfirm(column) {
1148
- let vm = this
1149
- this.filterExpression = {
1150
- operator: 'and',
1151
- expressions: [],
1152
- }
1153
- let col = this.columns.find((x) => x.field === column.field)
1154
- switch (col.controlType) {
1155
- case 'select':
1156
- column.filters[0].checked = column.filters[0].data.length > 0
1157
- break
1158
- default:
1159
- column.filters[0].checked = column.filters[0].data !== ''
1160
- break
1161
- }
1162
- //通知外部筛选改变事件
1163
- let columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1164
- XEUtils.each(columns, (item) => {
1165
- let filterExpression = {
1166
- operator: 'or',
1167
- expressions: [],
1168
- }
1169
- if (!col.controlType) {
1170
- col.controlType = 'text'
1171
- }
1172
- switch (col.controlType) {
1173
- case 'select':
1174
- if (item.filters && item.filters[0].checked) {
1175
- XEUtils.each(item.filters[0].data, (loopItem) => {
1176
- filterExpression.expressions.push({
1177
- field: item.field,
1178
- operator: 'EQ',
1179
- value: loopItem,
1180
- })
1181
- })
1182
- if (filterExpression.expressions.length > 0) {
1183
- vm.filterExpression.expressions.push(filterExpression)
1184
- }
1185
- }
1186
- break
1187
- default:
1188
- if (item.filters && item.filters[0].checked) {
1189
- XEUtils.each(item.filters, (loopItem) => {
1190
- if (loopItem.data) {
1191
- filterExpression.expressions.push({
1192
- field: item.field,
1193
- operator: 'CO',
1194
- value: loopItem.data,
1195
- })
1196
- }
1197
- })
1198
- if (filterExpression.expressions.length > 0) {
1199
- vm.filterExpression.expressions.push(filterExpression)
1200
- }
1201
- }
1202
- break
1203
- }
1204
- })
1205
- this.gridPagerConfig.currentPage = 1
1206
- this.searchData()
1207
- this.$refs.pupupGridView.closeFilter()
1208
- },
1209
- // 添加筛选条件
1210
- filterAddExp(column) {
1211
- column['filters'].push({
1212
- data: '',
1213
- })
1214
- },
1215
-
1216
- // 清除筛选条件
1217
- clearColumnFilter() {
1218
- let columns = []
1219
- let vm = this
1220
- try {
1221
- columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1222
- } catch (err) {
1223
- console.debug(err)
1224
- }
1225
- XEUtils.each(columns, (item) => {
1226
- let col = vm.columns.find((x) => x.field === item.field)
1227
- if (!col) {
1228
- return
1229
- }
1230
- if (!col.controlType) {
1231
- col.controlType = 'text'
1232
- }
1233
- switch (col.controlType) {
1234
- case 'select':
1235
- if (item.filters && item.filters[0].checked) {
1236
- item.filters = [
1237
- {
1238
- data: [],
1239
- },
1240
- ]
1241
- }
1242
- break
1243
- default:
1244
- if (item.filters && item.filters[0].checked) {
1245
- item.filters = [
1246
- {
1247
- data: '',
1248
- },
1249
- ]
1250
- }
1251
- break
1252
- }
1253
- })
1254
- this.filterExpression = {
1255
- operator: 'and',
1256
- expressions: [],
1257
- }
1258
- },
1259
- },
1260
- }
1261
- </script>
1262
-
1263
- <style lang="scss" scoped>
1264
- .pulldown-grid {
1265
- min-width: 600px;
1266
- width: auto;
1267
- height: 350px;
1268
- background-color: #fff;
1269
- box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
1270
- }
1271
-
1272
- .d-grid-control {
1273
- height: 30px;
1274
- }
1275
- .interceptor-class {
1276
- padding: 10px;
1277
- ::v-deep .ant-btn {
1278
- margin: 10px 10px 0;
1279
- }
1280
- }
1281
- </style>
1282
-
1283
- <style lang="less">
1284
- @import '../../styles/default.less';
1285
- </style>
1
+ <template>
2
+ <div class="d-control-container">
3
+ <div
4
+ class="d-control-label"
5
+ v-if="showLabel === true"
6
+ :style="{ width: labelWidth > 0 ? labelWidth + 'px' : 'none' }"
7
+ >
8
+ {{ label }}
9
+ <span v-if="rules && rules['required']" class="d-control-label-required"
10
+ >*</span
11
+ >
12
+ <Tooltip :title="tooltip" v-if="tooltip" style="margin: 0 2px">
13
+ <img src="../../styles/icon/help.png" alt="" style="width: 14px" />
14
+ </Tooltip>
15
+ </div>
16
+ <div
17
+ :class="{
18
+ 'd-control': showLabel === true,
19
+ 'd-grid-control': showLabel === false,
20
+ }"
21
+ >
22
+ <VxePulldown
23
+ style="width: 100%"
24
+ @hide-panel="pullDownHideEvent"
25
+ ref="pulldownRef"
26
+ v-if="edit === true"
27
+ transfer
28
+ >
29
+ <template #default>
30
+ <ValidationProvider :name="label" v-slot="v" :rules="rules">
31
+ <a-input
32
+ :size="'small'"
33
+ allow-clear
34
+ @change="inputChangeEvent"
35
+ class="inner-cell-control"
36
+ v-model="currentValue"
37
+ @click="inputClickEvent"
38
+ @focus="inputFocusEvent"
39
+ @blur="inputBlurEvent"
40
+ @keydown="inputKeydownEvent"
41
+ @keyup="inputKeyupEvent"
42
+ :class="{ 'd-error-input': v.errors.length > 0 }"
43
+ :disabled="disabled"
44
+ ></a-input>
45
+ <div class="d-error-msg">
46
+ {{ v.errors[0] }}
47
+ </div>
48
+ </ValidationProvider>
49
+ </template>
50
+ <template #dropdown>
51
+ <div class="pulldown-grid interceptor-class">
52
+ <vxe-grid
53
+ size="mini"
54
+ border
55
+ :row-class-name="gridRowStyle"
56
+ highlight-current-row
57
+ :keyboard-config="{ isArrow: true }"
58
+ highlight-hover-row
59
+ auto-resize
60
+ resizable
61
+ :loading="gridLoading"
62
+ height="auto"
63
+ ref="pupupGridView"
64
+ :data="searchRows"
65
+ @cell-click="gridCellClick"
66
+ @filter-visible="filterVisible"
67
+ :columns="internalColumns"
68
+ :checkbox-config="{ checkMethod: checkMethod }"
69
+ @sort-change="sortChange"
70
+ :filter-config="{
71
+ remote: true,
72
+ }"
73
+ :sort-config="{
74
+ multiple: true,
75
+ remote: true,
76
+ chronological: true,
77
+ defaultSort: defaultSort,
78
+ }"
79
+ >
80
+ <!-- :pager-config="gridPagerConfig" -->
81
+ <!-- @page-change="pageChangeEvent" -->
82
+ <template #matCode_header="{ column }">
83
+ <div class="first-col">
84
+ <div class="first-col-top">
85
+ {{ column.title }}
86
+ </div>
87
+ <div class="first-col-bottom">
88
+ <input style="width: 100%" />
89
+ </div>
90
+ </div>
91
+ </template>
92
+ <!-- 普通输入框的过滤筛选-->
93
+ <template #text_filter="{ column }">
94
+ <div class="interceptor-class">
95
+ <div v-for="(item, $index) in column.filters" :key="$index">
96
+ <a-input
97
+ allowClear
98
+ v-model="item.data"
99
+ @keyup.enter.native="filterConfirm(column)"
100
+ style="margin-bottom: 5px"
101
+ />
102
+ </div>
103
+ <a-button @click="filterAddExp(column)">添加条件</a-button>
104
+ <a-button @click="filterConfirm(column)">确认</a-button>
105
+ </div>
106
+ </template>
107
+ <!-- 选择筛选框-->
108
+ <template #select_filter="{ column }">
109
+ <div class="interceptor-class">
110
+ <a-checkbox-group
111
+ v-model="column.filters[0].data"
112
+ @keyup.enter.native="filterConfirm(column)"
113
+ >
114
+ <div style="max-height: 200px; overflow-y: scroll">
115
+ <div
116
+ style="text-align: left"
117
+ v-for="loopSource in column.params.dataSource"
118
+ :key="loopSource.value"
119
+ >
120
+ <a-checkbox
121
+ :value="loopSource.value"
122
+ style="margin: 5px 0"
123
+ >{{ loopSource.caption }}
124
+ </a-checkbox>
125
+ </div>
126
+ </div>
127
+ </a-checkbox-group>
128
+ <br />
129
+ <a-button @click="filterConfirm(column)">确认</a-button>
130
+ </div>
131
+ </template>
132
+ <template #pager>
133
+ <a-row>
134
+ <a-col :span="8">
135
+ <a-button
136
+ v-if="isMultiSelect === true"
137
+ type="primary"
138
+ size="small"
139
+ style="margin: 5px"
140
+ @click="multiSelectConfirm"
141
+ >
142
+ 确认选择
143
+ </a-button>
144
+ <a-button
145
+ v-if="popupAddName"
146
+ type="primary"
147
+ size="small"
148
+ style="margin: 5px"
149
+ @click="pagerBtnClick(btn)"
150
+ >
151
+ 新增
152
+ </a-button>
153
+
154
+ <template v-if="optBtns.length > 0">
155
+ <a-button
156
+ v-for="btn in optBtns"
157
+ :key="btn.field"
158
+ type="primary"
159
+ size="small"
160
+ style="margin: 5px"
161
+ @click="pagerBtnClick(btn)"
162
+ >
163
+ {{ btn.name }}
164
+ </a-button>
165
+ </template>
166
+ </a-col>
167
+ <a-col :span="16">
168
+ <vxe-pager
169
+ align="right"
170
+ size="mini"
171
+ :current-page.sync="gridPagerConfig.currentPage"
172
+ :page-size.sync="gridPagerConfig.pageSize"
173
+ :total="gridPagerConfig.total"
174
+ @page-change="pageChangeEvent"
175
+ >
176
+ </vxe-pager>
177
+ </a-col>
178
+ </a-row>
179
+ </template>
180
+ </vxe-grid>
181
+ </div>
182
+ </template>
183
+ </VxePulldown>
184
+ <span v-if="edit === false">
185
+ <a v-if="route" @click="routeLinkClick">{{ currentValue }}</a>
186
+ <span v-else> {{ currentValue }}</span>
187
+ </span>
188
+ </div>
189
+ <keep-alive>
190
+ <div
191
+ :is="popupAddName"
192
+ ref="pupupAddView"
193
+ @popupSaveAfter="popupSaveAfter"
194
+ ></div>
195
+ </keep-alive>
196
+ </div>
197
+ </template>
198
+
199
+ <script>
200
+ import XEUtils from 'xe-utils'
201
+ import { sysRowState, sysFormState, controlType } from '../../utils/enum'
202
+ import { replaceParamString, replaceParam } from '../../utils/common'
203
+ import request from '../../utils/request'
204
+ import { Input, Button, Row, Col, Checkbox } from 'ant-design-vue'
205
+ import { ValidationProvider } from 'vee-validate'
206
+ import { Pulldown } from 'vxe-table'
207
+ import { Tooltip } from 'ant-design-vue'
208
+ export default {
209
+ name: 'BasePulldown',
210
+ components: {
211
+ 'a-input': Input,
212
+ 'a-button': Button,
213
+ 'a-row': Row,
214
+ 'a-col': Col,
215
+ 'a-checkbox': Checkbox,
216
+ 'a-checkbox-group': Checkbox.Group,
217
+ VxePulldown: Pulldown,
218
+ ValidationProvider,
219
+ Tooltip,
220
+ },
221
+ data() {
222
+ return {
223
+ fetchFields: '',
224
+ internalColumns: [],
225
+ isInputChanged: false,
226
+ inputTimeout: null,
227
+ searchRows: [],
228
+ filterCols: [],
229
+ gridLoading: false,
230
+ gridPagerConfig: {
231
+ total: 0,
232
+ currentPage: 1,
233
+ pageSize: 10,
234
+ },
235
+ sorts: [],
236
+ defaultSort: [],
237
+ filterExpression: {
238
+ operator: 'and',
239
+ expressions: [],
240
+ },
241
+ newApiObj:{
242
+ newApi:''
243
+ }
244
+ }
245
+ },
246
+ props: {
247
+ dataSource: {
248
+ type: Array,
249
+ default: function() {
250
+ return []
251
+ }
252
+ },
253
+ labelWidth: {
254
+ type: Number,
255
+ default: function () {
256
+ return 0
257
+ },
258
+ },
259
+ isMultiSelect: {
260
+ type: Boolean,
261
+ default: function () {
262
+ return false
263
+ },
264
+ },
265
+ popupAddName: {
266
+ type: String,
267
+ default: function () {
268
+ return null
269
+ },
270
+ },
271
+ popupAddPath: {
272
+ type: String,
273
+ default: function () {
274
+ return null
275
+ },
276
+ },
277
+ rules: {
278
+ type: Object,
279
+ default: function () {
280
+ return null
281
+ },
282
+ },
283
+ showLabel: {
284
+ type: Boolean,
285
+ default: function () {
286
+ return true
287
+ },
288
+ },
289
+ label: {
290
+ type: String,
291
+ default: function () {
292
+ return ''
293
+ },
294
+ },
295
+ defaultExpression: {
296
+ type: String,
297
+ default: function () {
298
+ return ''
299
+ },
300
+ },
301
+ formRow: {
302
+ type: Object,
303
+ default: function () {
304
+ return {}
305
+ },
306
+ },
307
+ row: {
308
+ type: Object,
309
+ default: function () {
310
+ return {}
311
+ },
312
+ },
313
+ edit: {
314
+ type: Boolean,
315
+ default: function () {
316
+ return false
317
+ },
318
+ },
319
+ route: Object,
320
+ placeholder: {
321
+ // 提示信息
322
+ type: String,
323
+ },
324
+ api: {
325
+ // api接口
326
+ type: String,
327
+ },
328
+ field: {
329
+ type: String,
330
+ },
331
+ pageSize: {
332
+ // 分页数量,默认不分页
333
+ type: Number,
334
+ default: () => {
335
+ return 0
336
+ },
337
+ },
338
+ columns: {
339
+ // 列集合
340
+ type: Array,
341
+ default: () => {
342
+ return []
343
+ },
344
+ },
345
+ isOld: {
346
+ // 列集合
347
+ type: Boolean,
348
+ default: () => {
349
+ return false
350
+ },
351
+ },
352
+ exps: {
353
+ // 条件
354
+ type: Array,
355
+ default: () => {
356
+ return []
357
+ },
358
+ },
359
+ value: {
360
+ type: String,
361
+ default: function () {
362
+ return ''
363
+ },
364
+ },
365
+ optBtns: {
366
+ // 操作按钮
367
+ type: Array,
368
+ default: () => {
369
+ return []
370
+ },
371
+ },
372
+ gridTable: {
373
+ // 操作按钮
374
+ type: Object,
375
+ default: () => {
376
+ return null
377
+ },
378
+ },
379
+ immediate: {
380
+ type: Boolean,
381
+ default: true,
382
+ },
383
+ isLocalData: {
384
+ type: Boolean,
385
+ default: false,
386
+ },
387
+ tooltip: {
388
+ type: String,
389
+ default: function () {
390
+ return ''
391
+ },
392
+ },
393
+ propTableData: {
394
+ type: Array,
395
+ default: function () {
396
+ return []
397
+ },
398
+ },
399
+ contrasts: {
400
+ type: Array,
401
+ default: function () {
402
+ return []
403
+ },
404
+ },
405
+ allowAutoClear:{
406
+ type:Boolean,
407
+ default:function(){
408
+ return true
409
+ }
410
+ },
411
+ disabled:{
412
+ type:Boolean,
413
+ default:function(){
414
+ return false
415
+ }
416
+ },
417
+ },
418
+ watch: {
419
+ // 触发下拉表格字段更改,直接重新渲染
420
+ columns: {
421
+ handler(newVal) {
422
+ this.reloadColumn()
423
+ },
424
+ deep: true
425
+ }
426
+ },
427
+ computed: {
428
+ currentValue: {
429
+ // 动态计算currentValue的值
430
+ get: function () {
431
+ // return this.value // 将props中的value赋值给currentValue
432
+ for (let i = 0; i < this.dataSource.length; i++) {
433
+ const element = this.dataSource[i];
434
+ if (this.value === element.value) {
435
+ return element.caption
436
+ }
437
+ }
438
+ return this.value
439
+ },
440
+ set: function (val) {
441
+ this.$emit('input', val) // 通过$emit触发父组件
442
+ },
443
+ },
444
+ },
445
+ created() {
446
+ // if (this.popupAddName && !this.$options.components[this.popupAddName]) {
447
+ // // const tempRequire = require('@/views' + this.popupAddPath + '.vue').default
448
+ // // this.$options.components[this.popupAddName] = tempRequire
449
+ // this.$options.components[this.popupAddName] = () =>
450
+ // import('@/views' + this.popupAddPath + '.vue')
451
+ // }
452
+ this.gridPagerConfig.pageSize = this.pageSize
453
+
454
+ this.internalColumns.push({
455
+ type: 'seq',
456
+ fixed: 'left',
457
+ width: 50,
458
+ })
459
+
460
+ if (this.isMultiSelect === true) {
461
+ this.internalColumns.push({
462
+ type: 'checkbox',
463
+ fixed: 'left',
464
+ width: 40,
465
+ })
466
+ }
467
+
468
+ for (let i = 0; i < this.columns.length; i++) {
469
+ this.fetchFields = this.fetchFields + this.columns[i].field + ','
470
+ this.columns[i]['params'] = {
471
+ dataSource: [],
472
+ }
473
+ if (this.columns[i].dataSource) {
474
+ this.columns[i]['params'].dataSource = this.columns[i].dataSource
475
+ }
476
+ if (!this.columns[i].width) {
477
+ this.columns[i]['width'] = 100
478
+ }
479
+ if (this.columns[i].isCheckbox === true) {
480
+ this.columns[i]['type'] = 'checkbox'
481
+ }
482
+ if (!this.columns[i].controlType) {
483
+ this.columns[i].controlType = 'text'
484
+ }
485
+ // 设置字段的过滤插槽
486
+ if (this.columns[i].filter) {
487
+ this.columns[i]['filterMultiple'] = false
488
+
489
+ switch (this.columns[i].controlType) {
490
+ case 'checkbox':
491
+ this.columns[i]['slots'] = {
492
+ filter: `checkbox_filter`,
493
+ }
494
+ break
495
+ case 'select':
496
+ this.columns[i]['slots'] = {
497
+ filter: `select_filter`,
498
+ }
499
+ this.columns[i]['filters'] = [
500
+ {
501
+ data: [],
502
+ },
503
+ ]
504
+ break
505
+ default:
506
+ this.columns[i]['slots'] = {
507
+ filter: `text_filter`,
508
+ }
509
+ this.columns[i]['filters'] = [
510
+ {
511
+ data: '',
512
+ },
513
+ ]
514
+ break
515
+ }
516
+ }
517
+ // 默认排序
518
+ if (this.columns[i].defaultSort) {
519
+ this.defaultSort.push({
520
+ field: this.columns[i].field,
521
+ order: this.columns[i].defaultSort,
522
+ })
523
+ this.sorts.push([this.columns[i].field, this.columns[i].defaultSort])
524
+ }
525
+ this.internalColumns.push(this.columns[i])
526
+ if (this.columns[i].filter === true) {
527
+ this.filterCols.push(this.columns[i])
528
+ }
529
+ }
530
+ },
531
+ methods: {
532
+ // 刷新重置字段列
533
+ reloadColumn() {
534
+ this.internalColumns = []
535
+ this.fetchFields = []
536
+ this.internalColumns.push({
537
+ type: 'seq',
538
+ fixed: 'left',
539
+ width: 50,
540
+ })
541
+ if (this.isMultiSelect === true) {
542
+ this.internalColumns.push({
543
+ type: 'checkbox',
544
+ fixed: 'left',
545
+ width: 40,
546
+ })
547
+ }
548
+ for (let i = 0; i < this.columns.length; i++) {
549
+ this.fetchFields = this.fetchFields + this.columns[i].field + ','
550
+ this.columns[i]['params'] = {
551
+ dataSource: [],
552
+ }
553
+ if (this.columns[i].dataSource) {
554
+ this.columns[i]['params'].dataSource = this.columns[i].dataSource
555
+ }
556
+ if (!this.columns[i].width) {
557
+ this.columns[i]['width'] = 100
558
+ }
559
+ if (this.columns[i].isCheckbox === true) {
560
+ this.columns[i]['type'] = 'checkbox'
561
+ }
562
+ if (!this.columns[i].controlType) {
563
+ this.columns[i].controlType = 'text'
564
+ }
565
+ // 设置字段的过滤插槽
566
+ if (this.columns[i].filter) {
567
+ this.columns[i]['filterMultiple'] = false
568
+
569
+ switch (this.columns[i].controlType) {
570
+ case 'checkbox':
571
+ this.columns[i]['slots'] = {
572
+ filter: `checkbox_filter`,
573
+ }
574
+ break
575
+ case 'select':
576
+ this.columns[i]['slots'] = {
577
+ filter: `select_filter`,
578
+ }
579
+ this.columns[i]['filters'] = [
580
+ {
581
+ data: [],
582
+ },
583
+ ]
584
+ break
585
+ default:
586
+ this.columns[i]['slots'] = {
587
+ filter: `text_filter`,
588
+ }
589
+ this.columns[i]['filters'] = [
590
+ {
591
+ data: '',
592
+ },
593
+ ]
594
+ break
595
+ }
596
+ }
597
+ // 默认排序
598
+ if (this.columns[i].defaultSort) {
599
+ this.defaultSort.push({
600
+ field: this.columns[i].field,
601
+ order: this.columns[i].defaultSort,
602
+ })
603
+ this.sorts.push([this.columns[i].field, this.columns[i].defaultSort])
604
+ }
605
+ this.internalColumns.push(this.columns[i])
606
+ if (this.columns[i].filter === true) {
607
+ this.filterCols.push(this.columns[i])
608
+ }
609
+ }
610
+ this.$refs.pupupGridView.refreshColumn()
611
+ },
612
+ gridRowStyle(scope) {
613
+ if (scope.row.sysRepeat === true) {
614
+ return 'row--pending'
615
+ }
616
+ // if(scope.row.)
617
+ },
618
+ clearInputValue() {
619
+ if (this.isInputChanged === true&&this.allowAutoClear) {
620
+ this.setLinkValue(null, this.row)
621
+ this.$emit('selectChanged', null)
622
+ }
623
+ },
624
+ routeLinkClick() {
625
+ let tempRouteName = this.route.name
626
+ let tempRouteQuery = this.row[this.route.field]
627
+ if (XEUtils.isArray(tempRouteName)) {
628
+ //需要不同条件跳转不同页面
629
+ for (let i = 0; i < tempRouteName.length; i++) {
630
+ if (tempRouteName[i].value === this.row[tempRouteName[i].field]) {
631
+ tempRouteQuery =
632
+ this.row[tempRouteName[i].query] || this.row[this.route.field]
633
+ tempRouteName = tempRouteName[i].name
634
+ break
635
+ }
636
+ }
637
+ }
638
+ this.$router.pushRoute({
639
+ name: tempRouteName,
640
+ query: { id: tempRouteQuery },
641
+ })
642
+ },
643
+ /**
644
+ * 输入框改变事件
645
+ */
646
+ inputChangeEvent(event) {
647
+ this.isInputChanged = true
648
+ if (event.type === 'click' && event.pointerType === 'mouse') {
649
+ //点击了清空按钮
650
+ this.$nextTick(() => {
651
+ this.clearInputValue()
652
+ this.inputClickEvent(null)
653
+ })
654
+ }
655
+ },
656
+ inputBlurEvent(event) {},
657
+ /**
658
+ * 输入框获取焦点事件
659
+ */
660
+ inputFocusEvent(event) {
661
+ event.currentTarget.select()
662
+ // this.$refs.pulldownRef.showPanel()
663
+ // this.searchData()
664
+ },
665
+ /**
666
+ * Tab键隐藏面板
667
+ */
668
+ inputKeydownEvent(event) {
669
+ if (event.keyCode === 9) {
670
+ //tab事件
671
+ this.$refs.pulldownRef.hidePanel()
672
+ this.clearInputValue()
673
+ }
674
+ },
675
+ inputClickEvent(event) {
676
+ if (this.$refs.pulldownRef.isPanelVisible() === false) {
677
+ this.$refs.pulldownRef.showPanel()
678
+ this.clearColumnFilter()
679
+ this.searchData()
680
+ } else {
681
+ this.$refs.pulldownRef.hidePanel()
682
+ // 点击输入框隐藏panel时清空输入框
683
+ if(this.allowAutoClear){
684
+ this.currentValue = ''
685
+ }
686
+ }
687
+ },
688
+ /**
689
+ * 输入库输入事件
690
+ */
691
+ inputKeyupEvent(event) {
692
+ //好像ok
693
+ if (!this.immediate && event.keyCode !== 13) {
694
+ console.debug('davistest')
695
+ } else {
696
+ if (this.inputTimeout) {
697
+ clearTimeout(this.inputTimeout)
698
+ }
699
+ let vm = this
700
+ this.inputTimeout = setTimeout(() => {
701
+ //判断面板是否打开
702
+ if (vm.$refs.pulldownRef.isPanelVisible() === false) {
703
+ vm.$refs.pulldownRef.showPanel()
704
+ }
705
+ vm.searchData()
706
+ }, 500)
707
+ }
708
+ },
709
+ /**
710
+ * 网格列选中事件
711
+ */
712
+ gridCellClick({ row, column }) {
713
+ if (row.sysRepeat === true) {
714
+ return
715
+ }
716
+ if (column.type === 'seq' || column.type === 'checkbox') {
717
+ return
718
+ }
719
+ this.isInputChanged = false
720
+ this.setLinkValue(row, this.row)
721
+ this.$emit('selectChanged', row)
722
+ this.$refs.pulldownRef.hidePanel()
723
+ },
724
+ setLinkValue(pulldownRow, oriRow) {
725
+ for (let i = 0; i < this.internalColumns.length; i++) {
726
+ if (this.internalColumns[i].linkField) {
727
+ let tempLinkFields = this.internalColumns[i].linkField.split('.')
728
+ let tempRow = oriRow
729
+ // for(let j=0;j<tempLinkFields.length;j++){
730
+ // let tempField = tempLinkFields[j]
731
+ // //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
732
+ // if (!(tempField in tempRow)) {
733
+ // this.$antwarning(
734
+ // '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
735
+ // )
736
+ // break
737
+ // }
738
+ // if(j===tempLinkFields.length-1){
739
+ // if (pulldownRow === null) {
740
+ // if (this.internalColumns[i].nullClear === false) {
741
+ // //是否空值清除数据,用于可选可输入的控件
742
+ // continue
743
+ // }
744
+ // this.$set(tempRow, tempField, null)
745
+ // } else {
746
+ // this.$set(
747
+ // tempRow,
748
+ // tempField,
749
+ // this.getLinkValue(tempField, pulldownRow)
750
+ // )
751
+ // }
752
+ // }else{
753
+ // tempRow = tempRow[tempField]
754
+ // }
755
+ // }
756
+
757
+ //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
758
+ if (!(this.internalColumns[i].linkField in oriRow)) {
759
+ this.$antwarning(
760
+ '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
761
+ )
762
+ continue
763
+ }
764
+ if (pulldownRow === null) {
765
+ if (this.internalColumns[i].nullClear === false) {
766
+ //是否空值清楚数据,用于可选可输入的控件
767
+ continue
768
+ }
769
+ this.$set(oriRow, this.internalColumns[i].linkField, null)
770
+ } else {
771
+ this.$set(
772
+ oriRow,
773
+ this.internalColumns[i].linkField,
774
+ this.getLinkValue(this.internalColumns[i].field, pulldownRow)
775
+ )
776
+ }
777
+ }
778
+ }
779
+ },
780
+ getLinkValue(field, row) {
781
+ let linkField = field.split('.')
782
+ if (linkField.length > 1) {
783
+ let fieldValue = row
784
+ for (let i = 0; i < linkField.length; i++) {
785
+ if (
786
+ fieldValue[linkField[i]] === undefined ||
787
+ fieldValue[linkField[i]] === null
788
+ ) {
789
+ return null
790
+ }
791
+ fieldValue = fieldValue[linkField[i]]
792
+ }
793
+ return fieldValue
794
+ }
795
+ return row[field]
796
+ },
797
+ /**
798
+ * 左下角按钮点击事件
799
+ */
800
+ pagerBtnClick(btn) {
801
+ this.$refs.pupupAddView.show()
802
+ // this.$emit('pulldownBtnClick', btn)
803
+ this.$refs.pulldownRef.hidePanel()
804
+ },
805
+ // 多选内容时,若数据不满足条件,不可选中
806
+ checkMethod({ row }) {
807
+ if (row.sysRepeat) {
808
+ return false
809
+ }
810
+ return true
811
+ },
812
+ /**
813
+ * 确认多选
814
+ */
815
+ multiSelectConfirm() {
816
+ this.isInputChanged = false
817
+ this.$emit(
818
+ 'confirmMultiSelect',
819
+ this,
820
+ this.$refs.pupupGridView.getCheckboxRecords(true)
821
+ )
822
+ this.$refs.pulldownRef.hidePanel()
823
+ },
824
+ popupSaveAfter(pupupAddRowInfo) {
825
+ let postData = {
826
+ fields: null,
827
+ begin: 1,
828
+ size: 1,
829
+ expression: {},
830
+ sorts: '',
831
+ }
832
+ let tempKeyExp = XEUtils.find(
833
+ this.internalColumns,
834
+ (item) => item.isKey === true
835
+ )
836
+ postData.expression = {
837
+ operator: 'and',
838
+ expressions: [
839
+ {
840
+ operator: 'and',
841
+ expressions: [
842
+ {
843
+ field: tempKeyExp.field,
844
+ operator: 'EQ',
845
+ value: pupupAddRowInfo['id'],
846
+ },
847
+ ],
848
+ },
849
+ ],
850
+ }
851
+ let vm = this
852
+ let tempApi = this.getPostApi(postData)
853
+ request({
854
+ url: tempApi,
855
+ method: 'post',
856
+ data: postData,
857
+ })
858
+ .then((responseData) => {
859
+ if (responseData.content.length > 0) {
860
+ vm.setLinkValue(responseData.content[0], vm.row)
861
+ vm.$emit('selectChanged', responseData.content[0])
862
+ }
863
+ })
864
+ .catch((error) => {
865
+ console.error(error)
866
+ })
867
+ .finally(() => {})
868
+ },
869
+ /**
870
+ * 分页改变事件
871
+ */
872
+ pageChangeEvent({ currentPage, pageSize }) {
873
+ this.gridPagerConfig.currentPage = currentPage
874
+ this.gridPagerConfig.pageSize = pageSize
875
+ this.searchData()
876
+ },
877
+ /**
878
+ * 面板隐藏事件
879
+ */
880
+ pullDownHideEvent({ $event }) {
881
+ this.clearInputValue()
882
+ },
883
+ /**
884
+ * 查询数据
885
+ */
886
+ searchData() {
887
+ if (this.isLocalData === true) {
888
+ let tempSearch = {
889
+ value: this.currentValue,
890
+ dataSource: [],
891
+ }
892
+ this.$emit('preSearch', tempSearch)
893
+ this.searchRows = tempSearch.dataSource
894
+ this.gridPagerConfig.total = tempSearch.dataSource.length
895
+ return
896
+ }
897
+
898
+ let tempExp = {
899
+ operator: 'or',
900
+ expressions: [],
901
+ }
902
+ if (this.isOld === true) {
903
+ tempExp = ''
904
+ }
905
+ if (this.filterExpression.expressions.length > 0) {
906
+ tempExp.expressions.push(this.filterExpression)
907
+ } else if (this.currentValue) {
908
+ for (let i = 0; i < this.filterCols.length; i++) {
909
+ if (this.isOld === true) {
910
+ tempExp =
911
+ tempExp +
912
+ this.filterCols[i].field +
913
+ '.contains("' +
914
+ this.currentValue +
915
+ '")'
916
+ if (i < this.filterCols.length - 1) {
917
+ tempExp = tempExp + ' or '
918
+ }
919
+ } else {
920
+ if (this.filterCols[i].controlType == 'number') {
921
+ tempExp.expressions.push({
922
+ field: this.filterCols[i].field,
923
+ operator: 'EQ',
924
+ value: Number(this.currentValue),
925
+ })
926
+ } else {
927
+ tempExp.expressions.push({
928
+ field: this.filterCols[i].field,
929
+ operator: 'CO',
930
+ value: this.currentValue,
931
+ })
932
+ }
933
+ }
934
+ }
935
+ }
936
+ if (this.isOld === true && tempExp.length > 0) {
937
+ tempExp = '(' + tempExp + ')'
938
+ }
939
+
940
+ if (this.defaultExpression) {
941
+ let tempDefault = replaceParamString(
942
+ this.defaultExpression,
943
+ this.formRow,
944
+ this.$store.getters.moduleSelectItems[this.$route.meta.moduleId]
945
+ )
946
+
947
+ if (tempExp) {
948
+ tempExp = tempExp + ' and (' + tempDefault + ')'
949
+ } else {
950
+ tempExp = tempDefault
951
+ }
952
+ }
953
+
954
+ let postExpression = {
955
+ field: this.field,
956
+ expression: tempExp,
957
+ extendParams: {},
958
+ }
959
+ let repeatRowInfo = {
960
+ field: '',
961
+ values: [],
962
+ }
963
+ //查询之前从外部组件构造其他的条件
964
+ this.$emit('preSearch', postExpression, repeatRowInfo, this.row,this.newApiObj)
965
+ let postData = {
966
+ fields: this.fetchFields,
967
+ begin:
968
+ (this.gridPagerConfig.currentPage - 1) *
969
+ this.gridPagerConfig.pageSize +
970
+ 1,
971
+ size: this.gridPagerConfig.pageSize,
972
+ expression: postExpression.expression,
973
+ sorts: this.sorts,
974
+ extendParams: postExpression.extendParams,
975
+ }
976
+ // console.log(postData.sorts);
977
+ let tempApi = this.getPostApi(postData)
978
+
979
+ // let tempApi = this.api
980
+ // if (this.api.indexOf('?') > 0) {
981
+ // tempApi = this.api.substring(0, this.api.indexOf('?'))
982
+ // let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
983
+ // tempExtenParams = replaceParam(tempExtenParams, this.formRow)
984
+ // let tempSplitParams = tempExtenParams.split('&')
985
+ // for (let i = 0; i < tempSplitParams.length; i++) {
986
+ // let tempSplitValue = tempSplitParams[i].split('=')
987
+ // this.$set(
988
+ // postData.extendParams,
989
+ // tempSplitValue[0],
990
+ // tempSplitValue[1]
991
+ // )
992
+ // }
993
+ // }
994
+ let vm = this
995
+ vm.gridLoading = true
996
+ request({
997
+ url: tempApi,
998
+ method: 'post',
999
+ data: postData,
1000
+ })
1001
+ .then((responseData) => {
1002
+ if (vm.isOld === true) {
1003
+ vm.searchRows = responseData.data
1004
+ vm.gridPagerConfig.total = responseData.extData.totalRows
1005
+ } else {
1006
+ vm.searchRows = responseData.content
1007
+ vm.$refs.pupupGridView.loadData(vm.searchRows)
1008
+ vm.gridPagerConfig.total = responseData.otherContent.totalRows
1009
+ }
1010
+ if (repeatRowInfo.field) {
1011
+ //设置重复值
1012
+ XEUtils.arrayEach(vm.searchRows, (item) => {
1013
+ if (
1014
+ XEUtils.arrayIndexOf(
1015
+ repeatRowInfo.values,
1016
+ item[repeatRowInfo.field]
1017
+ ) > -1
1018
+ ) {
1019
+ item['sysRepeat'] = true
1020
+ }
1021
+ })
1022
+ }
1023
+ // 若当前表格内只有一行,则不进行判断
1024
+ if (vm.propTableData.length == 1) {
1025
+ return
1026
+ }
1027
+ // 设置字段sysRepeat后,所定字段的值全部相同则不可选择
1028
+ let fieldNames = vm.columns
1029
+ .filter((x) => x.sysRepeat)
1030
+ .map((y) => {
1031
+ return {
1032
+ field: y.field,
1033
+ linkField: y.linkField,
1034
+ }
1035
+ })
1036
+ if (fieldNames.length) {
1037
+ vm.searchRows.forEach((info) => {
1038
+ // 当一次创建多行时,过滤需特定字段不可为空的
1039
+ // 获取数组对象,根据选定字段,过滤选定字段都为空的
1040
+ let tempArr = vm.propTableData.filter((currentInfo) => {
1041
+ let tempD = []
1042
+ fieldNames.forEach((z) => {
1043
+ // 字段的值若为null、undefined,记录过滤掉
1044
+ if (!currentInfo[z.linkField]) {
1045
+ tempD.push(true)
1046
+ }
1047
+ })
1048
+ return tempD.length !== fieldNames.length
1049
+ })
1050
+ let arr = []
1051
+ // 分为有参查询和无参查询
1052
+ if (tempExp.expressions.length && fieldNames.length == 1) {
1053
+ for (let j = 0; j < fieldNames.length; j++) {
1054
+ let mapArr = tempArr.map(
1055
+ (item) => item[fieldNames[j].linkField]
1056
+ )
1057
+ let setArr = new Set(mapArr)
1058
+ if (setArr.size < mapArr.length) {
1059
+ arr.push(true)
1060
+ }
1061
+ }
1062
+ if (fieldNames.length === arr.length) {
1063
+ info.sysRepeat = true
1064
+ }
1065
+ } else {
1066
+ tempArr.forEach((item) => {
1067
+ // 接口字段可能和表字段field不一致,linkField一致
1068
+ for (let j = 0; j < fieldNames.length; j++) {
1069
+ if (
1070
+ info[fieldNames[j].field] == item[fieldNames[j].linkField]
1071
+ ) {
1072
+ arr.push(true)
1073
+ }
1074
+ }
1075
+ if (fieldNames.length === arr.length) {
1076
+ info.sysRepeat = true
1077
+ }
1078
+ })
1079
+ }
1080
+ if (info.sysRepeat && this.contrasts.length) {
1081
+ let flag = 0
1082
+ XEUtils.arrayEach(this.propTableData, (item) => {
1083
+ if (item[this.field] === info[this.field]) {
1084
+ XEUtils.arrayEach(this.contrasts, (loop) => {
1085
+ if (
1086
+ item[loop] === this.row[loop] &&
1087
+ item.id !== this.row.id
1088
+ ) {
1089
+ flag++
1090
+ }
1091
+ })
1092
+ }
1093
+ })
1094
+ if (flag === this.contrasts.length) {
1095
+ info.sysRepeat = true
1096
+ }
1097
+ }
1098
+ })
1099
+ }
1100
+ })
1101
+ .catch((error) => {
1102
+ console.error(error)
1103
+ })
1104
+ .finally(() => {
1105
+ vm.gridLoading = false
1106
+ })
1107
+ },
1108
+ getPostApi(postData) {
1109
+ let tempApi = this.api
1110
+ if(this.newApiObj.newApi){
1111
+ tempApi=this.newApiObj.newApi
1112
+ }
1113
+ if (this.api.indexOf('?') > 0) {
1114
+ tempApi = this.api.substring(0, this.api.indexOf('?'))
1115
+ let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1116
+ tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1117
+ let tempSplitParams = tempExtenParams.split('&')
1118
+ for (let i = 0; i < tempSplitParams.length; i++) {
1119
+ let tempSplitValue = tempSplitParams[i].split('=')
1120
+ this.$set(postData.extendParams, tempSplitValue[0], tempSplitValue[1])
1121
+ }
1122
+ }
1123
+ return tempApi
1124
+ },
1125
+ sortChange({ column, property, order, sortBy, sortList, $event }) {
1126
+ let currentSort = sortList.map((x) => {
1127
+ return [x.field, x.order]
1128
+ })
1129
+ this.sorts = currentSort
1130
+ this.searchData()
1131
+ },
1132
+
1133
+ // 下拉容器筛选条件被触发
1134
+ filterVisible({ column }) {
1135
+ XEUtils.remove(column.filters, (item) => {
1136
+ return item.data === ''
1137
+ })
1138
+ if (column.filters.length === 0) {
1139
+ column.filters.push({
1140
+ data: '',
1141
+ })
1142
+ }
1143
+ },
1144
+ filterConfirm(column) {
1145
+ let vm = this
1146
+ this.filterExpression = {
1147
+ operator: 'and',
1148
+ expressions: [],
1149
+ }
1150
+ let col = this.columns.find((x) => x.field === column.field)
1151
+ switch (col.controlType) {
1152
+ case 'select':
1153
+ column.filters[0].checked = column.filters[0].data.length > 0
1154
+ break
1155
+ default:
1156
+ column.filters[0].checked = column.filters[0].data !== ''
1157
+ break
1158
+ }
1159
+ //通知外部筛选改变事件
1160
+ let columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1161
+ XEUtils.each(columns, (item) => {
1162
+ let filterExpression = {
1163
+ operator: 'or',
1164
+ expressions: [],
1165
+ }
1166
+ if (!col.controlType) {
1167
+ col.controlType = 'text'
1168
+ }
1169
+ switch (col.controlType) {
1170
+ case 'select':
1171
+ if (item.filters && item.filters[0].checked) {
1172
+ XEUtils.each(item.filters[0].data, (loopItem) => {
1173
+ filterExpression.expressions.push({
1174
+ field: item.field,
1175
+ operator: 'EQ',
1176
+ value: loopItem,
1177
+ })
1178
+ })
1179
+ if (filterExpression.expressions.length > 0) {
1180
+ vm.filterExpression.expressions.push(filterExpression)
1181
+ }
1182
+ }
1183
+ break
1184
+ default:
1185
+ if (item.filters && item.filters[0].checked) {
1186
+ XEUtils.each(item.filters, (loopItem) => {
1187
+ if (loopItem.data) {
1188
+ filterExpression.expressions.push({
1189
+ field: item.field,
1190
+ operator: 'CO',
1191
+ value: loopItem.data,
1192
+ })
1193
+ }
1194
+ })
1195
+ if (filterExpression.expressions.length > 0) {
1196
+ vm.filterExpression.expressions.push(filterExpression)
1197
+ }
1198
+ }
1199
+ break
1200
+ }
1201
+ })
1202
+ this.gridPagerConfig.currentPage = 1
1203
+ this.searchData()
1204
+ this.$refs.pupupGridView.closeFilter()
1205
+ },
1206
+ // 添加筛选条件
1207
+ filterAddExp(column) {
1208
+ column['filters'].push({
1209
+ data: '',
1210
+ })
1211
+ },
1212
+
1213
+ // 清除筛选条件
1214
+ clearColumnFilter() {
1215
+ let columns = []
1216
+ let vm = this
1217
+ try {
1218
+ columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1219
+ } catch (err) {
1220
+ console.debug(err)
1221
+ }
1222
+ XEUtils.each(columns, (item) => {
1223
+ let col = vm.columns.find((x) => x.field === item.field)
1224
+ if (!col) {
1225
+ return
1226
+ }
1227
+ if (!col.controlType) {
1228
+ col.controlType = 'text'
1229
+ }
1230
+ switch (col.controlType) {
1231
+ case 'select':
1232
+ if (item.filters && item.filters[0].checked) {
1233
+ item.filters = [
1234
+ {
1235
+ data: [],
1236
+ },
1237
+ ]
1238
+ }
1239
+ break
1240
+ default:
1241
+ if (item.filters && item.filters[0].checked) {
1242
+ item.filters = [
1243
+ {
1244
+ data: '',
1245
+ },
1246
+ ]
1247
+ }
1248
+ break
1249
+ }
1250
+ })
1251
+ this.filterExpression = {
1252
+ operator: 'and',
1253
+ expressions: [],
1254
+ }
1255
+ },
1256
+ },
1257
+ }
1258
+ </script>
1259
+
1260
+ <style lang="scss" scoped>
1261
+ .pulldown-grid {
1262
+ min-width: 600px;
1263
+ width: auto;
1264
+ height: 350px;
1265
+ background-color: #fff;
1266
+ box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
1267
+ }
1268
+
1269
+ .d-grid-control {
1270
+ height: 30px;
1271
+ }
1272
+ .interceptor-class {
1273
+ padding: 10px;
1274
+ ::v-deep .ant-btn {
1275
+ margin: 10px 10px 0;
1276
+ }
1277
+ }
1278
+ </style>
1279
+
1280
+ <style lang="less">
1281
+ @import '../../styles/default.less';
1282
+ </style>