doway-coms 2.11.56 → 2.11.57

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 (92) hide show
  1. package/.browserslistrc +2 -2
  2. package/README.md +28 -28
  3. package/package.json +62 -62
  4. package/packages/AuditsList/index.js +7 -7
  5. package/packages/AuditsList/src/index.vue +314 -314
  6. package/packages/BaseButton/index.js +7 -7
  7. package/packages/BaseButton/src/index.vue +242 -242
  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 +233 -233
  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/BaseFileGroup/index.js +7 -7
  17. package/packages/BaseFileGroup/src/index.vue +724 -724
  18. package/packages/BaseForm/index.js +7 -7
  19. package/packages/BaseForm/src/index.vue +901 -901
  20. package/packages/BaseGantt/index.js +9 -9
  21. package/packages/BaseGantt/src/index.vue +617 -617
  22. package/packages/BaseGrid/index.js +9 -9
  23. package/packages/BaseGrid/src/exportCmp.vue +105 -105
  24. package/packages/BaseGrid/src/gridApi.js +32 -32
  25. package/packages/BaseGrid/src/index.vue +4349 -4368
  26. package/packages/BaseGridAdjust/index.js +9 -9
  27. package/packages/BaseGridAdjust/src/index.vue +482 -482
  28. package/packages/BaseInput/index.js +7 -7
  29. package/packages/BaseInput/src/index.vue +207 -207
  30. package/packages/BaseIntervalInput/index.js +7 -7
  31. package/packages/BaseIntervalInput/src/index.vue +310 -310
  32. package/packages/BaseKanbanEmpty/index.js +7 -7
  33. package/packages/BaseKanbanEmpty/src/index.vue +176 -176
  34. package/packages/BaseNumberInput/index.js +7 -7
  35. package/packages/BaseNumberInput/src/index.vue +291 -291
  36. package/packages/BasePagination/index.js +7 -7
  37. package/packages/BasePagination/src/index.vue +90 -90
  38. package/packages/BasePictureCard/index.js +7 -7
  39. package/packages/BasePictureCard/src/index.vue +671 -671
  40. package/packages/BasePrintPreview/index.js +7 -7
  41. package/packages/BasePrintPreview/src/index.vue +150 -150
  42. package/packages/BasePulldown/index.js +7 -7
  43. package/packages/BasePulldown/src/index.vue +1396 -1396
  44. package/packages/BaseSearch/index.js +7 -7
  45. package/packages/BaseSearch/src/index.vue +935 -935
  46. package/packages/BaseSelect/index.js +7 -7
  47. package/packages/BaseSelect/src/index.vue +162 -162
  48. package/packages/BaseSelectMulti/index.js +7 -7
  49. package/packages/BaseSelectMulti/src/index.vue +148 -148
  50. package/packages/BaseTextArea/index.js +7 -7
  51. package/packages/BaseTextArea/src/index.vue +197 -197
  52. package/packages/BaseTime/index.js +7 -7
  53. package/packages/BaseTime/src/index.vue +166 -166
  54. package/packages/BaseTool/index.js +7 -7
  55. package/packages/BaseTool/src/index.vue +353 -353
  56. package/packages/BaseToolStatus/index.js +7 -7
  57. package/packages/BaseToolStatus/src/ApprovalPersonsGroup.vue +41 -41
  58. package/packages/BaseToolStatus/src/index.vue +439 -439
  59. package/packages/BaseTreeSelect/index.js +8 -8
  60. package/packages/BaseTreeSelect/src/index.vue +437 -437
  61. package/packages/HistoryModal/index.js +8 -8
  62. package/packages/HistoryModal/src/index.vue +156 -156
  63. package/packages/LeaveAMessage/index.js +7 -7
  64. package/packages/LeaveAMessage/src/index.vue +601 -601
  65. package/packages/directive/clickoutside.js +44 -44
  66. package/packages/index.js +197 -197
  67. package/packages/styles/default.css +78 -78
  68. package/packages/styles/default.less +91 -91
  69. package/packages/styles/hps/default.less +73 -73
  70. package/packages/utils/api.js +122 -122
  71. package/packages/utils/auth.js +38 -38
  72. package/packages/utils/common.js +728 -728
  73. package/packages/utils/dom.js +181 -181
  74. package/packages/utils/enum.js +86 -86
  75. package/packages/utils/filters.js +495 -495
  76. package/packages/utils/gridFormat.js +66 -66
  77. package/packages/utils/msg.js +104 -104
  78. package/packages/utils/patchFiles.js +44 -44
  79. package/packages/utils/request.js +181 -181
  80. package/packages/utils/store.js +373 -373
  81. package/packages/utils/tscPrinter.js +101 -101
  82. package/sync.bash +6 -6
  83. package/vue.config.js +59 -59
  84. package/dist/css/chunk-vendors.7f83d8f9.css +0 -8
  85. package/dist/css/index.7946d50b.css +0 -1
  86. package/dist/favicon.ico +0 -0
  87. package/dist/js/chunk-vendors.28fda91d.js +0 -340
  88. package/dist/js/index.49bc6add.js +0 -2
  89. package/lib/doway-coms.common.js +0 -120397
  90. package/lib/doway-coms.css +0 -1
  91. package/lib/doway-coms.umd.js +0 -120407
  92. package/lib/doway-coms.umd.min.js +0 -328
@@ -1,1396 +1,1396 @@
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
- <Tooltip :title="currentValue" v-else>{{currentValue}}</Tooltip>
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
- linkData: {
394
- type: String,
395
- default: function () {
396
- return ''
397
- },
398
- },
399
- propTableData: {
400
- type: Array,
401
- default: function () {
402
- return []
403
- },
404
- },
405
- contrasts: {
406
- type: Array,
407
- default: function () {
408
- return []
409
- },
410
- },
411
- allowAutoClear:{
412
- type:Boolean,
413
- default:function(){
414
- return true
415
- }
416
- },
417
- disabled:{
418
- type:Boolean,
419
- default:function(){
420
- return false
421
- }
422
- },
423
- },
424
- // watch: { //davis20250111注释掉,会照成死循环问题
425
- // // 触发下拉表格字段更改,直接重新渲染
426
- // columns: {
427
- // handler(newVal) {
428
- // this.reloadColumn()
429
- // },
430
- // deep: true
431
- // }
432
- // },
433
- computed: {
434
- currentValue: {
435
- // 动态计算currentValue的值
436
- get: function () {
437
- // return this.value // 将props中的value赋值给currentValue
438
- for (let i = 0; i < this.dataSource.length; i++) {
439
- const element = this.dataSource[i];
440
- if (this.value === element.value) {
441
- return element.caption
442
- }
443
- }
444
- return this.value
445
- },
446
- set: function (val) {
447
- this.$emit('input', val) // 通过$emit触发父组件
448
- },
449
- },
450
- },
451
- created() {
452
- // if (this.popupAddName && !this.$options.components[this.popupAddName]) {
453
- // // const tempRequire = require('@/views' + this.popupAddPath + '.vue').default
454
- // // this.$options.components[this.popupAddName] = tempRequire
455
- // this.$options.components[this.popupAddName] = () =>
456
- // import('@/views' + this.popupAddPath + '.vue')
457
- // }
458
- this.gridPagerConfig.pageSize = this.pageSize
459
-
460
- this.internalColumns.push({
461
- type: 'seq',
462
- fixed: 'left',
463
- width: 50,
464
- })
465
-
466
- if (this.isMultiSelect === true) {
467
- this.internalColumns.push({
468
- type: 'checkbox',
469
- fixed: 'left',
470
- width: 40,
471
- })
472
- }
473
-
474
- for (let i = 0; i < this.columns.length; i++) {
475
- this.fetchFields = this.fetchFields + this.columns[i].field + ','
476
- this.columns[i]['params'] = {
477
- dataSource: [],
478
- }
479
- if (this.columns[i].dataSource) {
480
- this.columns[i]['params'].dataSource = this.columns[i].dataSource
481
- if(this.columns[i].controlType===controlType.select){
482
- this.columns[i]['formatter'] = 'formatSelect'
483
- }
484
- }
485
- if (!this.columns[i].width) {
486
- this.columns[i]['width'] = 100
487
- }
488
- if (this.columns[i].isCheckbox === true) {
489
- this.columns[i]['type'] = 'checkbox'
490
- }
491
- if (!this.columns[i].controlType) {
492
- this.columns[i].controlType = 'text'
493
- }
494
- // 设置字段的过滤插槽
495
- if (this.columns[i].filter) {
496
- this.columns[i]['filterMultiple'] = false
497
-
498
- switch (this.columns[i].controlType) {
499
- case 'checkbox':
500
- this.columns[i]['slots'] = {
501
- filter: `checkbox_filter`,
502
- }
503
- break
504
- case 'select':
505
- this.columns[i]['slots'] = {
506
- filter: `select_filter`,
507
- }
508
- this.columns[i]['filters'] = [
509
- {
510
- data: [],
511
- },
512
- ]
513
- break
514
- default:
515
- this.columns[i]['slots'] = {
516
- filter: `text_filter`,
517
- }
518
- this.columns[i]['filters'] = [
519
- {
520
- data: '',
521
- },
522
- ]
523
- break
524
- }
525
- }
526
- // 默认排序
527
- if (this.columns[i].defaultSort) {
528
- this.defaultSort.push({
529
- field: this.columns[i].field,
530
- order: this.columns[i].defaultSort,
531
- })
532
- this.sorts.push([this.columns[i].field, this.columns[i].defaultSort])
533
- }
534
- this.internalColumns.push(this.columns[i])
535
- if (this.columns[i].filter === true) {
536
- this.filterCols.push(this.columns[i])
537
- }
538
- }
539
- },
540
- methods: {
541
- // 刷新重置字段列
542
- reloadColumn() {
543
- this.internalColumns = []
544
- this.filterCols = []
545
- this.fetchFields = []
546
- this.internalColumns.push({
547
- type: 'seq',
548
- fixed: 'left',
549
- width: 50,
550
- })
551
- if (this.isMultiSelect === true) {
552
- this.internalColumns.push({
553
- type: 'checkbox',
554
- fixed: 'left',
555
- width: 40,
556
- })
557
- }
558
- for (let i = 0; i < this.columns.length; i++) {
559
- this.fetchFields = this.fetchFields + this.columns[i].field + ','
560
- this.columns[i]['params'] = {
561
- dataSource: [],
562
- }
563
- if (this.columns[i].dataSource) {
564
- this.columns[i]['params'].dataSource = this.columns[i].dataSource
565
- }
566
- if (!this.columns[i].width) {
567
- this.columns[i]['width'] = 100
568
- }
569
- if (this.columns[i].isCheckbox === true) {
570
- this.columns[i]['type'] = 'checkbox'
571
- }
572
- if (!this.columns[i].controlType) {
573
- this.columns[i].controlType = 'text'
574
- }
575
- // 设置字段的过滤插槽
576
- if (this.columns[i].filter) {
577
- this.columns[i]['filterMultiple'] = false
578
-
579
- switch (this.columns[i].controlType) {
580
- case 'checkbox':
581
- this.columns[i]['slots'] = {
582
- filter: `checkbox_filter`,
583
- }
584
- break
585
- case 'select':
586
- this.columns[i]['slots'] = {
587
- filter: `select_filter`,
588
- }
589
- this.columns[i]['filters'] = [
590
- {
591
- data: [],
592
- },
593
- ]
594
- break
595
- default:
596
- this.columns[i]['slots'] = {
597
- filter: `text_filter`,
598
- }
599
- this.columns[i]['filters'] = [
600
- {
601
- data: '',
602
- },
603
- ]
604
- break
605
- }
606
- }
607
- // 默认排序
608
- if (this.columns[i].defaultSort) {
609
- this.defaultSort.push({
610
- field: this.columns[i].field,
611
- order: this.columns[i].defaultSort,
612
- })
613
- this.sorts.push([this.columns[i].field, this.columns[i].defaultSort])
614
- }
615
- this.internalColumns.push(this.columns[i])
616
- if (this.columns[i].filter === true) {
617
- this.filterCols.push(this.columns[i])
618
- }
619
- }
620
- this.$refs.pupupGridView.refreshColumn()
621
- },
622
- gridRowStyle(scope) {
623
- if (scope.row.sysRepeat === true) {
624
- return 'row--pending'
625
- }
626
- // if(scope.row.)
627
- },
628
- clearInputValue() {
629
- if (this.isInputChanged === true) {
630
- this.setLinkValue(null, this.row)
631
- this.$emit('selectChanged', null)
632
- }
633
- },
634
- routeLinkClick() {
635
- let tempRouteName = this.route.name
636
- let tempRouteQuery = this.row[this.route.field]
637
- if (XEUtils.isArray(tempRouteName)) {
638
- //需要不同条件跳转不同页面
639
- for (let i = 0; i < tempRouteName.length; i++) {
640
- if (tempRouteName[i].value === this.row[tempRouteName[i].field]) {
641
- tempRouteQuery =
642
- this.row[tempRouteName[i].query] || this.row[this.route.field]
643
- tempRouteName = tempRouteName[i].name
644
- break
645
- }
646
- }
647
- }
648
- if (!tempRouteQuery) return
649
- this.$router.pushRoute({
650
- name: tempRouteName,
651
- query: { id: tempRouteQuery },
652
- })
653
- },
654
- /**
655
- * 输入框改变事件
656
- */
657
- inputChangeEvent(event) {
658
- this.isInputChanged = true
659
- if (event.type === 'click' && event.pointerType === 'mouse') {
660
- //点击了清空按钮
661
- this.$nextTick(() => {
662
- this.clearInputValue()
663
- this.inputClickEvent(null)
664
- })
665
- }
666
- this.$emit('inputChangeEvent', null)
667
- },
668
- inputBlurEvent(event) {},
669
- /**
670
- * 输入框获取焦点事件
671
- */
672
- inputFocusEvent(event) {
673
- event.currentTarget.select()
674
- // this.$refs.pulldownRef.showPanel()
675
- // this.searchData()
676
- },
677
- /**
678
- * Tab键隐藏面板
679
- */
680
- inputKeydownEvent(event) {
681
- if (event.keyCode === 9) {
682
- //tab事件
683
- if(this.allowAutoClear!==false){
684
- this.$refs.pulldownRef.hidePanel()
685
- this.clearInputValue()
686
- }
687
- }
688
- },
689
- inputClickEvent(event) {
690
- if (this.$refs.pulldownRef.isPanelVisible() === false) {
691
- this.$refs.pulldownRef.showPanel()
692
- this.clearColumnFilter()
693
- this.searchData()
694
- } else {
695
- this.$refs.pulldownRef.hidePanel()
696
- // 点击输入框隐藏panel时清空输入框
697
- // if(this.allowAutoClear){
698
- // this.currentValue = ''
699
- // }
700
- }
701
- },
702
- /**
703
- * 输入库输入事件
704
- */
705
- inputKeyupEvent(event) {
706
- //好像ok
707
- if (!this.immediate && event.keyCode !== 13) {
708
- console.debug('davistest')
709
- } else {
710
- if (this.inputTimeout) {
711
- clearTimeout(this.inputTimeout)
712
- }
713
- let vm = this
714
- this.inputTimeout = setTimeout(() => {
715
- if(vm.$refs.pulldownRef){
716
- if(vm.$refs.pulldownRef.isPanelVisible() === false){
717
- vm.$refs.pulldownRef.showPanel()
718
- }
719
- vm.searchData()
720
- }else{
721
- //如果输入复制数据,或者快速输入数据然后切换到其他行的时候会
722
- //造成当前行编辑装填变成关闭,并且取步到弹出组件,导致输入的值没有被清空
723
- //所以这里需要判断是否有弹出组件,如果没有,则清空输入框
724
- //davis20241129
725
- if(vm.allowAutoClear!==false){
726
- vm.clearInputValue()
727
- }
728
- }
729
- //判断面板是否打开
730
- // if (vm.$refs.pulldownRef&&vm.$refs.pulldownRef.isPanelVisible() === false) {
731
- // vm.$refs.pulldownRef.showPanel()
732
- // }
733
- // vm.searchData()
734
- }, 500)
735
- }
736
- },
737
- /**
738
- * 网格列选中事件
739
- */
740
- gridCellClick({ row, column }) {
741
- if (row.sysRepeat === true) {
742
- return
743
- }
744
- if (column.type === 'seq' || column.type === 'checkbox') {
745
- return
746
- }
747
- this.isInputChanged = false
748
- this.setLinkValue(row, this.row)
749
- this.$emit('selectChanged', row)
750
- this.$refs.pulldownRef.hidePanel()
751
- },
752
- setLinkValue(pulldownRow, oriRow) {
753
- for (let i = 0; i < this.internalColumns.length; i++) {
754
- if (this.internalColumns[i].linkField) {
755
- let tempLinkFields = this.internalColumns[i].linkField.split('.')
756
- let tempRow = oriRow
757
- // for(let j=0;j<tempLinkFields.length;j++){
758
- // let tempField = tempLinkFields[j]
759
- // //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
760
- // if (!(tempField in tempRow)) {
761
- // this.$antwarning(
762
- // '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
763
- // )
764
- // break
765
- // }
766
- // if(j===tempLinkFields.length-1){
767
- // if (pulldownRow === null) {
768
- // if (this.internalColumns[i].nullClear === false) {
769
- // //是否空值清除数据,用于可选可输入的控件
770
- // continue
771
- // }
772
- // this.$set(tempRow, tempField, null)
773
- // } else {
774
- // this.$set(
775
- // tempRow,
776
- // tempField,
777
- // this.getLinkValue(tempField, pulldownRow)
778
- // )
779
- // }
780
- // }else{
781
- // tempRow = tempRow[tempField]
782
- // }
783
- // }
784
-
785
- //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
786
- if (!(this.internalColumns[i].linkField in oriRow)) {
787
- this.$antwarning(
788
- '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
789
- )
790
- continue
791
- }
792
- if (pulldownRow === null) {
793
- if (this.internalColumns[i].nullClear === false) {
794
- //是否空值清楚数据,用于可选可输入的控件
795
- continue
796
- }
797
- this.$set(oriRow, this.internalColumns[i].linkField, null)
798
- } else {
799
- this.$set(
800
- oriRow,
801
- this.internalColumns[i].linkField,
802
- this.getLinkValue(this.internalColumns[i].field, pulldownRow)
803
- )
804
- }
805
- }
806
- }
807
- },
808
- getLinkValue(field, row) {
809
- let linkField = field.split('.')
810
- if (linkField.length > 1) {
811
- let fieldValue = row
812
- for (let i = 0; i < linkField.length; i++) {
813
- if (
814
- fieldValue[linkField[i]] === undefined ||
815
- fieldValue[linkField[i]] === null
816
- ) {
817
- return null
818
- }
819
- fieldValue = fieldValue[linkField[i]]
820
- }
821
- return fieldValue
822
- }
823
- return row[field]
824
- },
825
- /**
826
- * 左下角按钮点击事件
827
- */
828
- pagerBtnClick(btn) {
829
- this.$refs.pupupAddView.show()
830
- // this.$emit('pulldownBtnClick', btn)
831
- this.$refs.pulldownRef.hidePanel()
832
- },
833
- // 多选内容时,若数据不满足条件,不可选中
834
- checkMethod({ row }) {
835
- if (row.sysRepeat) {
836
- return false
837
- }
838
- return true
839
- },
840
- /**
841
- * 确认多选
842
- */
843
- multiSelectConfirm() {
844
- this.isInputChanged = false
845
- this.$emit(
846
- 'confirmMultiSelect',
847
- this,
848
- this.$refs.pupupGridView.getCheckboxRecords(true)
849
- )
850
- this.$refs.pulldownRef.hidePanel()
851
- },
852
- popupSaveAfter(pupupAddRowInfo) {
853
- let postData = {
854
- fields: null,
855
- begin: 1,
856
- size: 1,
857
- expression: {},
858
- sorts: '',
859
- }
860
- let tempKeyExp = XEUtils.find(
861
- this.internalColumns,
862
- (item) => item.isKey === true
863
- )
864
- postData.expression = {
865
- operator: 'and',
866
- expressions: [
867
- {
868
- operator: 'and',
869
- expressions: [
870
- {
871
- field: tempKeyExp.field,
872
- operator: 'EQ',
873
- value: pupupAddRowInfo['id'],
874
- },
875
- ],
876
- },
877
- ],
878
- }
879
- let vm = this
880
- let tempApi = this.getPostApi(postData)
881
- request({
882
- url: tempApi,
883
- method: 'post',
884
- data: postData,
885
- })
886
- .then((responseData) => {
887
- if (responseData.content.length > 0) {
888
- vm.setLinkValue(responseData.content[0], vm.row)
889
- vm.$emit('selectChanged', responseData.content[0])
890
- }
891
- })
892
- .catch((error) => {
893
- console.error(error)
894
- })
895
- .finally(() => {})
896
- },
897
- /**
898
- * 分页改变事件
899
- */
900
- pageChangeEvent({ currentPage, pageSize }) {
901
- this.gridPagerConfig.currentPage = currentPage
902
- this.gridPagerConfig.pageSize = pageSize
903
- this.searchData()
904
- },
905
- /**
906
- * 面板隐藏事件
907
- */
908
- pullDownHideEvent({ $event }) {
909
- if(this.allowAutoClear!==false){
910
- this.clearInputValue()
911
- }
912
- },
913
- /**
914
- * 查询数据
915
- */
916
- searchData() {
917
- if (this.isLocalData === true) {
918
- let tempSearch = {
919
- value: this.currentValue,
920
- dataSource: [],
921
- field: this.field,
922
- }
923
- this.$emit('preSearch', tempSearch)
924
- this.searchRows = []
925
- //判断删选条件过滤
926
- XEUtils.arrayEach(tempSearch.dataSource,loopItem=>{
927
- let tempFlag = this.filterCols.length===0
928
- for(let i=0;i< this.filterCols.length;i++){
929
- let tempValue = loopItem[this.filterCols[i].field]
930
- if(XEUtils.isString(tempValue) && tempValue.includes(this.currentValue)===true){
931
- tempFlag = true
932
- break
933
- }
934
- }
935
- if(tempFlag===true || !this.currentValue){
936
- this.searchRows.push(loopItem)
937
- }
938
-
939
- })
940
- this.gridPagerConfig.total = this.searchRows.length
941
- return
942
- }
943
-
944
- let tempExp = {
945
- operator: 'or',
946
- expressions: [],
947
- }
948
- if (this.isOld === true) {
949
- tempExp = ''
950
- }
951
- if (this.filterExpression.expressions.length > 0) {
952
- tempExp.expressions.push(this.filterExpression)
953
- } else if (this.currentValue) {
954
- for (let i = 0; i < this.filterCols.length; i++) {
955
- if (this.isOld === true) {
956
- tempExp =
957
- tempExp +
958
- this.filterCols[i].field +
959
- '.contains("' +
960
- this.currentValue +
961
- '")'
962
- if (i < this.filterCols.length - 1) {
963
- tempExp = tempExp + ' or '
964
- }
965
- } else {
966
- if (this.filterCols[i].controlType == 'number') {
967
- tempExp.expressions.push({
968
- field: this.filterCols[i].field,
969
- operator: 'EQ',
970
- value: Number(this.currentValue),
971
- })
972
- } else {
973
- tempExp.expressions.push({
974
- field: this.filterCols[i].field,
975
- operator: 'CO',
976
- value: this.currentValue,
977
- })
978
- }
979
- }
980
- }
981
- }
982
- if (this.isOld === true && tempExp.length > 0) {
983
- tempExp = '(' + tempExp + ')'
984
- }
985
-
986
- if (this.defaultExpression) {
987
- let tempDefault = replaceParamString(
988
- this.defaultExpression,
989
- this.formRow,
990
- this.$store.getters.moduleSelectItems[this.$route.meta.moduleId]
991
- )
992
-
993
- if (tempExp) {
994
- tempExp = tempExp + ' and (' + tempDefault + ')'
995
- } else {
996
- tempExp = tempDefault
997
- }
998
- }
999
-
1000
- let postExpression = {
1001
- field: this.field,
1002
- expression: tempExp,
1003
- extendParams: {},
1004
- replaceParams:[]
1005
- }
1006
- let repeatRowInfo = {
1007
- field: '',
1008
- values: [],
1009
- }
1010
- //查询之前从外部组件构造其他的条件
1011
- this.$emit('preSearch', postExpression, repeatRowInfo, this.row,this.newApiObj)
1012
- let postData = {
1013
- fields: this.fetchFields,
1014
- begin:
1015
- (this.gridPagerConfig.currentPage - 1) *
1016
- this.gridPagerConfig.pageSize +
1017
- 1,
1018
- size: this.gridPagerConfig.pageSize,
1019
- expression: postExpression.expression,
1020
- sorts: this.sorts,
1021
- extendParams: postExpression.extendParams,
1022
- replaceParams:postExpression.replaceParams
1023
- }
1024
- if (this.linkData) {
1025
- postData = {
1026
- moduleCode: this.$route.meta.moduleCode,
1027
- dataCodes: [
1028
- {
1029
- dataCode: this.linkData,
1030
- searchParam: postData,
1031
- },
1032
- ],
1033
- };
1034
- }
1035
-
1036
- // console.log(postData.sorts);
1037
- let tempApi = this.getPostApi(postData)
1038
-
1039
- // let tempApi = this.api
1040
- // if (this.api.indexOf('?') > 0) {
1041
- // tempApi = this.api.substring(0, this.api.indexOf('?'))
1042
- // let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1043
- // tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1044
- // let tempSplitParams = tempExtenParams.split('&')
1045
- // for (let i = 0; i < tempSplitParams.length; i++) {
1046
- // let tempSplitValue = tempSplitParams[i].split('=')
1047
- // this.$set(
1048
- // postData.extendParams,
1049
- // tempSplitValue[0],
1050
- // tempSplitValue[1]
1051
- // )
1052
- // }
1053
- // }
1054
- let vm = this
1055
- vm.gridLoading = true
1056
- request({
1057
- url: tempApi,
1058
- method: 'post',
1059
- data: postData,
1060
- })
1061
- .then((responseData) => {
1062
- if(vm.linkData){
1063
- vm.searchRows = responseData.content[this.linkData].rows
1064
- vm.gridPagerConfig.total = XEUtils.toNumber(responseData.content[this.linkData].totalRows);
1065
- }else{
1066
- if (vm.isOld === true) {
1067
- vm.searchRows = responseData.data
1068
- vm.gridPagerConfig.total = responseData.extData.totalRows
1069
- } else {
1070
- vm.searchRows = responseData.content
1071
- vm.$refs.pupupGridView.loadData(vm.searchRows)
1072
- vm.gridPagerConfig.total = responseData.otherContent.totalRows
1073
- }
1074
- }
1075
- //本身结果集会返回sysRepeat为true的数据,所以处理数据的时候不能默认设置成false,会把后台返回的数据重置掉
1076
- //查询下拉显示列配置成sysRepeat的列字段名称
1077
- let repeatCols = vm.columns
1078
- .filter((x) => x.sysRepeat)
1079
- .map((y) => {
1080
- return {
1081
- field: y.field,
1082
- linkField: y.linkField,
1083
- }
1084
- });
1085
- //添加当前行关联值
1086
- XEUtils.arrayEach(vm.contrasts, (loopItem)=>{
1087
- repeatCols.push({
1088
- isCurrentRow:true,
1089
- linkField:loopItem
1090
- })
1091
- })
1092
- if(repeatCols.length>0 && vm.propTableData.length>1){
1093
- //设置是否重复
1094
- XEUtils.arrayEach(vm.searchRows,(loopItem)=>{
1095
- if(loopItem.sysRepeat===true) return
1096
- //循环弹出查询返回的数据是否已经存在于表格中
1097
- loopItem.sysRepeat = XEUtils.some(vm.propTableData,(loopTableItem)=>{
1098
- //判断表格行数据是当前输入行就返回false,无需重复验证
1099
- if(loopTableItem['id']===vm.row['id']){
1100
- return false
1101
- }
1102
-
1103
- for(let i=0;i<repeatCols.length;i++){
1104
- let tempRepeatColInfo = repeatCols[i]
1105
- //弹出数据列值
1106
- let tempPopupRowColValue =tempRepeatColInfo.isCurrentRow===true?vm.row[tempRepeatColInfo.linkField]:
1107
- loopItem[tempRepeatColInfo.field]
1108
- //表格数据列值
1109
- let tempTableRowColValue = loopTableItem[tempRepeatColInfo.linkField]
1110
- if(tempPopupRowColValue!==tempTableRowColValue){
1111
- //只有有一个不一致,就返回false
1112
- return false
1113
- }
1114
- }
1115
- return true
1116
- })
1117
- })
1118
- }
1119
- // if (repeatRowInfo.field) {
1120
- // //设置重复值
1121
- // XEUtils.arrayEach(vm.searchRows, (item) => {
1122
- // if (
1123
- // XEUtils.arrayIndexOf(
1124
- // repeatRowInfo.values,
1125
- // item[repeatRowInfo.field]
1126
- // ) > -1
1127
- // ) {
1128
- // item['sysRepeat'] = true
1129
- // }
1130
- // })
1131
- // }
1132
- // 若当前表格内只有一行,则不进行判断
1133
- // if (vm.propTableData.length == 1) {
1134
- // return
1135
- // }
1136
- // 设置字段sysRepeat后,所定字段的值全部相同则不可选择
1137
- // let fieldNames = vm.columns
1138
- // .filter((x) => x.sysRepeat)
1139
- // .map((y) => {
1140
- // return {
1141
- // field: y.field,
1142
- // linkField: y.linkField,
1143
- // }
1144
- // })
1145
- // if (fieldNames.length) {
1146
- // vm.searchRows.forEach((info) => {
1147
- // // 当一次创建多行时,过滤需特定字段不可为空的
1148
- // // 获取数组对象,根据选定字段,过滤选定字段都为空的
1149
- // let tempArr = vm.propTableData.filter((currentInfo) => {
1150
- // let tempD = []
1151
- // fieldNames.forEach((z) => {
1152
- // // 字段的值若为null、undefined,记录过滤掉
1153
- // if (!currentInfo[z.linkField]) {
1154
- // tempD.push(true)
1155
- // }
1156
- // })
1157
- // return tempD.length !== fieldNames.length
1158
- // })
1159
- // let arr = []
1160
- // // 分为有参查询和无参查询
1161
- // if (tempExp.expressions.length && fieldNames.length == 1) {
1162
- // for (let j = 0; j < fieldNames.length; j++) {
1163
- // let mapArr = tempArr.map(
1164
- // (item) => item[fieldNames[j].linkField]
1165
- // )
1166
- // let setArr = new Set(mapArr)
1167
- // if (setArr.size < mapArr.length) {
1168
- // arr.push(true)
1169
- // }
1170
- // }
1171
- // if (fieldNames.length === arr.length) {
1172
- // info.sysRepeat = true
1173
- // }
1174
- // } else {
1175
- // tempArr.forEach((item) => {
1176
- // // 接口字段可能和表字段field不一致,linkField一致
1177
- // for (let j = 0; j < fieldNames.length; j++) {
1178
- // if (
1179
- // info[fieldNames[j].field] == item[fieldNames[j].linkField]
1180
- // ) {
1181
- // arr.push(true)
1182
- // }
1183
- // }
1184
- // if (fieldNames.length === arr.length) {
1185
- // info.sysRepeat = true
1186
- // }
1187
- // })
1188
- // }
1189
- // if (info.sysRepeat && this.contrasts.length) {
1190
- // let flag = 0
1191
- // XEUtils.arrayEach(this.propTableData, (item) => {
1192
- // if (item[this.field] === info[this.field]) {
1193
- // XEUtils.arrayEach(this.contrasts, (loop) => {
1194
- // if (
1195
- // item[loop] === this.row[loop] &&
1196
- // item.id !== this.row.id
1197
- // ) {
1198
- // flag++
1199
- // }
1200
- // })
1201
- // }
1202
- // })
1203
- // if (flag === this.contrasts.length) {
1204
- // info.sysRepeat = true
1205
- // }
1206
- // }
1207
- // })
1208
- // }
1209
- })
1210
- .catch((error) => {
1211
- console.error(error)
1212
- })
1213
- .finally(() => {
1214
- vm.gridLoading = false
1215
- })
1216
- },
1217
- getPostApi(postData) {
1218
- let tempApi = this.api
1219
- if(this.newApiObj.newApi){
1220
- tempApi=this.newApiObj.newApi
1221
- }
1222
- if (this.api.indexOf('?') > 0) {
1223
- tempApi = this.api.substring(0, this.api.indexOf('?'))
1224
- let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1225
- tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1226
- let tempSplitParams = tempExtenParams.split('&')
1227
- for (let i = 0; i < tempSplitParams.length; i++) {
1228
- let tempSplitValue = tempSplitParams[i].split('=')
1229
- this.$set(postData.extendParams, tempSplitValue[0], tempSplitValue[1])
1230
- }
1231
- }
1232
- return tempApi
1233
- },
1234
- sortChange({ column, property, order, sortBy, sortList, $event }) {
1235
- let currentSort = sortList.map((x) => {
1236
- return [x.field, x.order]
1237
- })
1238
- this.sorts = currentSort
1239
- this.searchData()
1240
- },
1241
-
1242
- // 下拉容器筛选条件被触发
1243
- filterVisible({ column }) {
1244
- XEUtils.remove(column.filters, (item) => {
1245
- return item.data === ''
1246
- })
1247
- if (column.filters.length === 0) {
1248
- column.filters.push({
1249
- data: '',
1250
- })
1251
- }
1252
- },
1253
- filterConfirm(column) {
1254
- let vm = this
1255
- this.filterExpression = {
1256
- operator: 'and',
1257
- expressions: [],
1258
- }
1259
- let col = this.columns.find((x) => x.field === column.field)
1260
- switch (col.controlType) {
1261
- case 'select':
1262
- column.filters[0].checked = column.filters[0].data.length > 0
1263
- break
1264
- default:
1265
- column.filters[0].checked = column.filters[0].data !== ''
1266
- break
1267
- }
1268
- //通知外部筛选改变事件
1269
- let columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1270
- XEUtils.each(columns, (item) => {
1271
- let filterExpression = {
1272
- operator: 'or',
1273
- expressions: [],
1274
- }
1275
- if (!col.controlType) {
1276
- col.controlType = 'text'
1277
- }
1278
- switch (col.controlType) {
1279
- case 'select':
1280
- if (item.filters && item.filters[0].checked) {
1281
- XEUtils.each(item.filters[0].data, (loopItem) => {
1282
- filterExpression.expressions.push({
1283
- field: item.field,
1284
- operator: 'EQ',
1285
- value: loopItem,
1286
- })
1287
- })
1288
- if (filterExpression.expressions.length > 0) {
1289
- vm.filterExpression.expressions.push(filterExpression)
1290
- }
1291
- }
1292
- break
1293
- default:
1294
- if (item.filters && item.filters[0].checked) {
1295
- XEUtils.each(item.filters, (loopItem) => {
1296
- if (loopItem.data) {
1297
- filterExpression.expressions.push({
1298
- field: item.field,
1299
- operator: 'CO',
1300
- value: loopItem.data,
1301
- })
1302
- }
1303
- })
1304
- if (filterExpression.expressions.length > 0) {
1305
- vm.filterExpression.expressions.push(filterExpression)
1306
- }
1307
- }
1308
- break
1309
- }
1310
- })
1311
- this.gridPagerConfig.currentPage = 1
1312
- this.searchData()
1313
- this.$refs.pupupGridView.closeFilter()
1314
- },
1315
- // 添加筛选条件
1316
- filterAddExp(column) {
1317
- column['filters'].push({
1318
- data: '',
1319
- })
1320
- },
1321
-
1322
- // 清除筛选条件
1323
- clearColumnFilter() {
1324
- if(!this.$refs.pupupGridView){
1325
- return
1326
- }
1327
- let columns = []
1328
- let vm = this
1329
- try {
1330
- columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1331
- } catch (err) {
1332
- console.debug(err)
1333
- }
1334
- XEUtils.each(columns, (item) => {
1335
- let col = vm.columns.find((x) => x.field === item.field)
1336
- if (!col) {
1337
- return
1338
- }
1339
- if (!col.controlType) {
1340
- col.controlType = 'text'
1341
- }
1342
- switch (col.controlType) {
1343
- case 'select':
1344
- if (item.filters && item.filters[0].checked) {
1345
- item.filters = [
1346
- {
1347
- data: [],
1348
- },
1349
- ]
1350
- }
1351
- break
1352
- default:
1353
- if (item.filters && item.filters[0].checked) {
1354
- item.filters = [
1355
- {
1356
- data: '',
1357
- },
1358
- ]
1359
- }
1360
- break
1361
- }
1362
- })
1363
- this.filterExpression = {
1364
- operator: 'and',
1365
- expressions: [],
1366
- }
1367
- },
1368
- },
1369
- }
1370
- </script>
1371
-
1372
- <style lang="scss" scoped>
1373
- .pulldown-grid {
1374
- min-width: 600px;
1375
- width: auto;
1376
- height: 350px;
1377
- background-color: #fff;
1378
- box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
1379
- }
1380
-
1381
- .d-grid-control {
1382
- width: 100% !important;
1383
- min-width: unset !important;
1384
- // height: 30px;
1385
- }
1386
- .interceptor-class {
1387
- padding: 10px;
1388
- ::v-deep .ant-btn {
1389
- margin: 10px 10px 0;
1390
- }
1391
- }
1392
- </style>
1393
-
1394
- <style lang="less">
1395
- @import '../../styles/default.less';
1396
- </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
+ <Tooltip :title="currentValue" v-else>{{currentValue}}</Tooltip>
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
+ linkData: {
394
+ type: String,
395
+ default: function () {
396
+ return ''
397
+ },
398
+ },
399
+ propTableData: {
400
+ type: Array,
401
+ default: function () {
402
+ return []
403
+ },
404
+ },
405
+ contrasts: {
406
+ type: Array,
407
+ default: function () {
408
+ return []
409
+ },
410
+ },
411
+ allowAutoClear:{
412
+ type:Boolean,
413
+ default:function(){
414
+ return true
415
+ }
416
+ },
417
+ disabled:{
418
+ type:Boolean,
419
+ default:function(){
420
+ return false
421
+ }
422
+ },
423
+ },
424
+ // watch: { //davis20250111注释掉,会照成死循环问题
425
+ // // 触发下拉表格字段更改,直接重新渲染
426
+ // columns: {
427
+ // handler(newVal) {
428
+ // this.reloadColumn()
429
+ // },
430
+ // deep: true
431
+ // }
432
+ // },
433
+ computed: {
434
+ currentValue: {
435
+ // 动态计算currentValue的值
436
+ get: function () {
437
+ // return this.value // 将props中的value赋值给currentValue
438
+ for (let i = 0; i < this.dataSource.length; i++) {
439
+ const element = this.dataSource[i];
440
+ if (this.value === element.value) {
441
+ return element.caption
442
+ }
443
+ }
444
+ return this.value
445
+ },
446
+ set: function (val) {
447
+ this.$emit('input', val) // 通过$emit触发父组件
448
+ },
449
+ },
450
+ },
451
+ created() {
452
+ // if (this.popupAddName && !this.$options.components[this.popupAddName]) {
453
+ // // const tempRequire = require('@/views' + this.popupAddPath + '.vue').default
454
+ // // this.$options.components[this.popupAddName] = tempRequire
455
+ // this.$options.components[this.popupAddName] = () =>
456
+ // import('@/views' + this.popupAddPath + '.vue')
457
+ // }
458
+ this.gridPagerConfig.pageSize = this.pageSize
459
+
460
+ this.internalColumns.push({
461
+ type: 'seq',
462
+ fixed: 'left',
463
+ width: 50,
464
+ })
465
+
466
+ if (this.isMultiSelect === true) {
467
+ this.internalColumns.push({
468
+ type: 'checkbox',
469
+ fixed: 'left',
470
+ width: 40,
471
+ })
472
+ }
473
+
474
+ for (let i = 0; i < this.columns.length; i++) {
475
+ this.fetchFields = this.fetchFields + this.columns[i].field + ','
476
+ this.columns[i]['params'] = {
477
+ dataSource: [],
478
+ }
479
+ if (this.columns[i].dataSource) {
480
+ this.columns[i]['params'].dataSource = this.columns[i].dataSource
481
+ if(this.columns[i].controlType===controlType.select){
482
+ this.columns[i]['formatter'] = 'formatSelect'
483
+ }
484
+ }
485
+ if (!this.columns[i].width) {
486
+ this.columns[i]['width'] = 100
487
+ }
488
+ if (this.columns[i].isCheckbox === true) {
489
+ this.columns[i]['type'] = 'checkbox'
490
+ }
491
+ if (!this.columns[i].controlType) {
492
+ this.columns[i].controlType = 'text'
493
+ }
494
+ // 设置字段的过滤插槽
495
+ if (this.columns[i].filter) {
496
+ this.columns[i]['filterMultiple'] = false
497
+
498
+ switch (this.columns[i].controlType) {
499
+ case 'checkbox':
500
+ this.columns[i]['slots'] = {
501
+ filter: `checkbox_filter`,
502
+ }
503
+ break
504
+ case 'select':
505
+ this.columns[i]['slots'] = {
506
+ filter: `select_filter`,
507
+ }
508
+ this.columns[i]['filters'] = [
509
+ {
510
+ data: [],
511
+ },
512
+ ]
513
+ break
514
+ default:
515
+ this.columns[i]['slots'] = {
516
+ filter: `text_filter`,
517
+ }
518
+ this.columns[i]['filters'] = [
519
+ {
520
+ data: '',
521
+ },
522
+ ]
523
+ break
524
+ }
525
+ }
526
+ // 默认排序
527
+ if (this.columns[i].defaultSort) {
528
+ this.defaultSort.push({
529
+ field: this.columns[i].field,
530
+ order: this.columns[i].defaultSort,
531
+ })
532
+ this.sorts.push([this.columns[i].field, this.columns[i].defaultSort])
533
+ }
534
+ this.internalColumns.push(this.columns[i])
535
+ if (this.columns[i].filter === true) {
536
+ this.filterCols.push(this.columns[i])
537
+ }
538
+ }
539
+ },
540
+ methods: {
541
+ // 刷新重置字段列
542
+ reloadColumn() {
543
+ this.internalColumns = []
544
+ this.filterCols = []
545
+ this.fetchFields = []
546
+ this.internalColumns.push({
547
+ type: 'seq',
548
+ fixed: 'left',
549
+ width: 50,
550
+ })
551
+ if (this.isMultiSelect === true) {
552
+ this.internalColumns.push({
553
+ type: 'checkbox',
554
+ fixed: 'left',
555
+ width: 40,
556
+ })
557
+ }
558
+ for (let i = 0; i < this.columns.length; i++) {
559
+ this.fetchFields = this.fetchFields + this.columns[i].field + ','
560
+ this.columns[i]['params'] = {
561
+ dataSource: [],
562
+ }
563
+ if (this.columns[i].dataSource) {
564
+ this.columns[i]['params'].dataSource = this.columns[i].dataSource
565
+ }
566
+ if (!this.columns[i].width) {
567
+ this.columns[i]['width'] = 100
568
+ }
569
+ if (this.columns[i].isCheckbox === true) {
570
+ this.columns[i]['type'] = 'checkbox'
571
+ }
572
+ if (!this.columns[i].controlType) {
573
+ this.columns[i].controlType = 'text'
574
+ }
575
+ // 设置字段的过滤插槽
576
+ if (this.columns[i].filter) {
577
+ this.columns[i]['filterMultiple'] = false
578
+
579
+ switch (this.columns[i].controlType) {
580
+ case 'checkbox':
581
+ this.columns[i]['slots'] = {
582
+ filter: `checkbox_filter`,
583
+ }
584
+ break
585
+ case 'select':
586
+ this.columns[i]['slots'] = {
587
+ filter: `select_filter`,
588
+ }
589
+ this.columns[i]['filters'] = [
590
+ {
591
+ data: [],
592
+ },
593
+ ]
594
+ break
595
+ default:
596
+ this.columns[i]['slots'] = {
597
+ filter: `text_filter`,
598
+ }
599
+ this.columns[i]['filters'] = [
600
+ {
601
+ data: '',
602
+ },
603
+ ]
604
+ break
605
+ }
606
+ }
607
+ // 默认排序
608
+ if (this.columns[i].defaultSort) {
609
+ this.defaultSort.push({
610
+ field: this.columns[i].field,
611
+ order: this.columns[i].defaultSort,
612
+ })
613
+ this.sorts.push([this.columns[i].field, this.columns[i].defaultSort])
614
+ }
615
+ this.internalColumns.push(this.columns[i])
616
+ if (this.columns[i].filter === true) {
617
+ this.filterCols.push(this.columns[i])
618
+ }
619
+ }
620
+ this.$refs.pupupGridView.refreshColumn()
621
+ },
622
+ gridRowStyle(scope) {
623
+ if (scope.row.sysRepeat === true) {
624
+ return 'row--pending'
625
+ }
626
+ // if(scope.row.)
627
+ },
628
+ clearInputValue() {
629
+ if (this.isInputChanged === true) {
630
+ this.setLinkValue(null, this.row)
631
+ this.$emit('selectChanged', null)
632
+ }
633
+ },
634
+ routeLinkClick() {
635
+ let tempRouteName = this.route.name
636
+ let tempRouteQuery = this.row[this.route.field]
637
+ if (XEUtils.isArray(tempRouteName)) {
638
+ //需要不同条件跳转不同页面
639
+ for (let i = 0; i < tempRouteName.length; i++) {
640
+ if (tempRouteName[i].value === this.row[tempRouteName[i].field]) {
641
+ tempRouteQuery =
642
+ this.row[tempRouteName[i].query] || this.row[this.route.field]
643
+ tempRouteName = tempRouteName[i].name
644
+ break
645
+ }
646
+ }
647
+ }
648
+ if (!tempRouteQuery) return
649
+ this.$router.pushRoute({
650
+ name: tempRouteName,
651
+ query: { id: tempRouteQuery },
652
+ })
653
+ },
654
+ /**
655
+ * 输入框改变事件
656
+ */
657
+ inputChangeEvent(event) {
658
+ this.isInputChanged = true
659
+ if (event.type === 'click' && event.pointerType === 'mouse') {
660
+ //点击了清空按钮
661
+ this.$nextTick(() => {
662
+ this.clearInputValue()
663
+ this.inputClickEvent(null)
664
+ })
665
+ }
666
+ this.$emit('inputChangeEvent', null)
667
+ },
668
+ inputBlurEvent(event) {},
669
+ /**
670
+ * 输入框获取焦点事件
671
+ */
672
+ inputFocusEvent(event) {
673
+ event.currentTarget.select()
674
+ // this.$refs.pulldownRef.showPanel()
675
+ // this.searchData()
676
+ },
677
+ /**
678
+ * Tab键隐藏面板
679
+ */
680
+ inputKeydownEvent(event) {
681
+ if (event.keyCode === 9) {
682
+ //tab事件
683
+ if(this.allowAutoClear!==false){
684
+ this.$refs.pulldownRef.hidePanel()
685
+ this.clearInputValue()
686
+ }
687
+ }
688
+ },
689
+ inputClickEvent(event) {
690
+ if (this.$refs.pulldownRef.isPanelVisible() === false) {
691
+ this.$refs.pulldownRef.showPanel()
692
+ this.clearColumnFilter()
693
+ this.searchData()
694
+ } else {
695
+ this.$refs.pulldownRef.hidePanel()
696
+ // 点击输入框隐藏panel时清空输入框
697
+ // if(this.allowAutoClear){
698
+ // this.currentValue = ''
699
+ // }
700
+ }
701
+ },
702
+ /**
703
+ * 输入库输入事件
704
+ */
705
+ inputKeyupEvent(event) {
706
+ //好像ok
707
+ if (!this.immediate && event.keyCode !== 13) {
708
+ console.debug('davistest')
709
+ } else {
710
+ if (this.inputTimeout) {
711
+ clearTimeout(this.inputTimeout)
712
+ }
713
+ let vm = this
714
+ this.inputTimeout = setTimeout(() => {
715
+ if(vm.$refs.pulldownRef){
716
+ if(vm.$refs.pulldownRef.isPanelVisible() === false){
717
+ vm.$refs.pulldownRef.showPanel()
718
+ }
719
+ vm.searchData()
720
+ }else{
721
+ //如果输入复制数据,或者快速输入数据然后切换到其他行的时候会
722
+ //造成当前行编辑装填变成关闭,并且取步到弹出组件,导致输入的值没有被清空
723
+ //所以这里需要判断是否有弹出组件,如果没有,则清空输入框
724
+ //davis20241129
725
+ if(vm.allowAutoClear!==false){
726
+ vm.clearInputValue()
727
+ }
728
+ }
729
+ //判断面板是否打开
730
+ // if (vm.$refs.pulldownRef&&vm.$refs.pulldownRef.isPanelVisible() === false) {
731
+ // vm.$refs.pulldownRef.showPanel()
732
+ // }
733
+ // vm.searchData()
734
+ }, 500)
735
+ }
736
+ },
737
+ /**
738
+ * 网格列选中事件
739
+ */
740
+ gridCellClick({ row, column }) {
741
+ if (row.sysRepeat === true) {
742
+ return
743
+ }
744
+ if (column.type === 'seq' || column.type === 'checkbox') {
745
+ return
746
+ }
747
+ this.isInputChanged = false
748
+ this.setLinkValue(row, this.row)
749
+ this.$emit('selectChanged', row)
750
+ this.$refs.pulldownRef.hidePanel()
751
+ },
752
+ setLinkValue(pulldownRow, oriRow) {
753
+ for (let i = 0; i < this.internalColumns.length; i++) {
754
+ if (this.internalColumns[i].linkField) {
755
+ let tempLinkFields = this.internalColumns[i].linkField.split('.')
756
+ let tempRow = oriRow
757
+ // for(let j=0;j<tempLinkFields.length;j++){
758
+ // let tempField = tempLinkFields[j]
759
+ // //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
760
+ // if (!(tempField in tempRow)) {
761
+ // this.$antwarning(
762
+ // '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
763
+ // )
764
+ // break
765
+ // }
766
+ // if(j===tempLinkFields.length-1){
767
+ // if (pulldownRow === null) {
768
+ // if (this.internalColumns[i].nullClear === false) {
769
+ // //是否空值清除数据,用于可选可输入的控件
770
+ // continue
771
+ // }
772
+ // this.$set(tempRow, tempField, null)
773
+ // } else {
774
+ // this.$set(
775
+ // tempRow,
776
+ // tempField,
777
+ // this.getLinkValue(tempField, pulldownRow)
778
+ // )
779
+ // }
780
+ // }else{
781
+ // tempRow = tempRow[tempField]
782
+ // }
783
+ // }
784
+
785
+ //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
786
+ if (!(this.internalColumns[i].linkField in oriRow)) {
787
+ this.$antwarning(
788
+ '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
789
+ )
790
+ continue
791
+ }
792
+ if (pulldownRow === null) {
793
+ if (this.internalColumns[i].nullClear === false) {
794
+ //是否空值清楚数据,用于可选可输入的控件
795
+ continue
796
+ }
797
+ this.$set(oriRow, this.internalColumns[i].linkField, null)
798
+ } else {
799
+ this.$set(
800
+ oriRow,
801
+ this.internalColumns[i].linkField,
802
+ this.getLinkValue(this.internalColumns[i].field, pulldownRow)
803
+ )
804
+ }
805
+ }
806
+ }
807
+ },
808
+ getLinkValue(field, row) {
809
+ let linkField = field.split('.')
810
+ if (linkField.length > 1) {
811
+ let fieldValue = row
812
+ for (let i = 0; i < linkField.length; i++) {
813
+ if (
814
+ fieldValue[linkField[i]] === undefined ||
815
+ fieldValue[linkField[i]] === null
816
+ ) {
817
+ return null
818
+ }
819
+ fieldValue = fieldValue[linkField[i]]
820
+ }
821
+ return fieldValue
822
+ }
823
+ return row[field]
824
+ },
825
+ /**
826
+ * 左下角按钮点击事件
827
+ */
828
+ pagerBtnClick(btn) {
829
+ this.$refs.pupupAddView.show()
830
+ // this.$emit('pulldownBtnClick', btn)
831
+ this.$refs.pulldownRef.hidePanel()
832
+ },
833
+ // 多选内容时,若数据不满足条件,不可选中
834
+ checkMethod({ row }) {
835
+ if (row.sysRepeat) {
836
+ return false
837
+ }
838
+ return true
839
+ },
840
+ /**
841
+ * 确认多选
842
+ */
843
+ multiSelectConfirm() {
844
+ this.isInputChanged = false
845
+ this.$emit(
846
+ 'confirmMultiSelect',
847
+ this,
848
+ this.$refs.pupupGridView.getCheckboxRecords(true)
849
+ )
850
+ this.$refs.pulldownRef.hidePanel()
851
+ },
852
+ popupSaveAfter(pupupAddRowInfo) {
853
+ let postData = {
854
+ fields: null,
855
+ begin: 1,
856
+ size: 1,
857
+ expression: {},
858
+ sorts: '',
859
+ }
860
+ let tempKeyExp = XEUtils.find(
861
+ this.internalColumns,
862
+ (item) => item.isKey === true
863
+ )
864
+ postData.expression = {
865
+ operator: 'and',
866
+ expressions: [
867
+ {
868
+ operator: 'and',
869
+ expressions: [
870
+ {
871
+ field: tempKeyExp.field,
872
+ operator: 'EQ',
873
+ value: pupupAddRowInfo['id'],
874
+ },
875
+ ],
876
+ },
877
+ ],
878
+ }
879
+ let vm = this
880
+ let tempApi = this.getPostApi(postData)
881
+ request({
882
+ url: tempApi,
883
+ method: 'post',
884
+ data: postData,
885
+ })
886
+ .then((responseData) => {
887
+ if (responseData.content.length > 0) {
888
+ vm.setLinkValue(responseData.content[0], vm.row)
889
+ vm.$emit('selectChanged', responseData.content[0])
890
+ }
891
+ })
892
+ .catch((error) => {
893
+ console.error(error)
894
+ })
895
+ .finally(() => {})
896
+ },
897
+ /**
898
+ * 分页改变事件
899
+ */
900
+ pageChangeEvent({ currentPage, pageSize }) {
901
+ this.gridPagerConfig.currentPage = currentPage
902
+ this.gridPagerConfig.pageSize = pageSize
903
+ this.searchData()
904
+ },
905
+ /**
906
+ * 面板隐藏事件
907
+ */
908
+ pullDownHideEvent({ $event }) {
909
+ if(this.allowAutoClear!==false){
910
+ this.clearInputValue()
911
+ }
912
+ },
913
+ /**
914
+ * 查询数据
915
+ */
916
+ searchData() {
917
+ if (this.isLocalData === true) {
918
+ let tempSearch = {
919
+ value: this.currentValue,
920
+ dataSource: [],
921
+ field: this.field,
922
+ }
923
+ this.$emit('preSearch', tempSearch)
924
+ this.searchRows = []
925
+ //判断删选条件过滤
926
+ XEUtils.arrayEach(tempSearch.dataSource,loopItem=>{
927
+ let tempFlag = this.filterCols.length===0
928
+ for(let i=0;i< this.filterCols.length;i++){
929
+ let tempValue = loopItem[this.filterCols[i].field]
930
+ if(XEUtils.isString(tempValue) && tempValue.includes(this.currentValue)===true){
931
+ tempFlag = true
932
+ break
933
+ }
934
+ }
935
+ if(tempFlag===true || !this.currentValue){
936
+ this.searchRows.push(loopItem)
937
+ }
938
+
939
+ })
940
+ this.gridPagerConfig.total = this.searchRows.length
941
+ return
942
+ }
943
+
944
+ let tempExp = {
945
+ operator: 'or',
946
+ expressions: [],
947
+ }
948
+ if (this.isOld === true) {
949
+ tempExp = ''
950
+ }
951
+ if (this.filterExpression.expressions.length > 0) {
952
+ tempExp.expressions.push(this.filterExpression)
953
+ } else if (this.currentValue) {
954
+ for (let i = 0; i < this.filterCols.length; i++) {
955
+ if (this.isOld === true) {
956
+ tempExp =
957
+ tempExp +
958
+ this.filterCols[i].field +
959
+ '.contains("' +
960
+ this.currentValue +
961
+ '")'
962
+ if (i < this.filterCols.length - 1) {
963
+ tempExp = tempExp + ' or '
964
+ }
965
+ } else {
966
+ if (this.filterCols[i].controlType == 'number') {
967
+ tempExp.expressions.push({
968
+ field: this.filterCols[i].field,
969
+ operator: 'EQ',
970
+ value: Number(this.currentValue),
971
+ })
972
+ } else {
973
+ tempExp.expressions.push({
974
+ field: this.filterCols[i].field,
975
+ operator: 'CO',
976
+ value: this.currentValue,
977
+ })
978
+ }
979
+ }
980
+ }
981
+ }
982
+ if (this.isOld === true && tempExp.length > 0) {
983
+ tempExp = '(' + tempExp + ')'
984
+ }
985
+
986
+ if (this.defaultExpression) {
987
+ let tempDefault = replaceParamString(
988
+ this.defaultExpression,
989
+ this.formRow,
990
+ this.$store.getters.moduleSelectItems[this.$route.meta.moduleId]
991
+ )
992
+
993
+ if (tempExp) {
994
+ tempExp = tempExp + ' and (' + tempDefault + ')'
995
+ } else {
996
+ tempExp = tempDefault
997
+ }
998
+ }
999
+
1000
+ let postExpression = {
1001
+ field: this.field,
1002
+ expression: tempExp,
1003
+ extendParams: {},
1004
+ replaceParams:[]
1005
+ }
1006
+ let repeatRowInfo = {
1007
+ field: '',
1008
+ values: [],
1009
+ }
1010
+ //查询之前从外部组件构造其他的条件
1011
+ this.$emit('preSearch', postExpression, repeatRowInfo, this.row,this.newApiObj)
1012
+ let postData = {
1013
+ fields: this.fetchFields,
1014
+ begin:
1015
+ (this.gridPagerConfig.currentPage - 1) *
1016
+ this.gridPagerConfig.pageSize +
1017
+ 1,
1018
+ size: this.gridPagerConfig.pageSize,
1019
+ expression: postExpression.expression,
1020
+ sorts: this.sorts,
1021
+ extendParams: postExpression.extendParams,
1022
+ replaceParams:postExpression.replaceParams
1023
+ }
1024
+ if (this.linkData) {
1025
+ postData = {
1026
+ moduleCode: this.$route.meta.moduleCode,
1027
+ dataCodes: [
1028
+ {
1029
+ dataCode: this.linkData,
1030
+ searchParam: postData,
1031
+ },
1032
+ ],
1033
+ };
1034
+ }
1035
+
1036
+ // console.log(postData.sorts);
1037
+ let tempApi = this.getPostApi(postData)
1038
+
1039
+ // let tempApi = this.api
1040
+ // if (this.api.indexOf('?') > 0) {
1041
+ // tempApi = this.api.substring(0, this.api.indexOf('?'))
1042
+ // let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1043
+ // tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1044
+ // let tempSplitParams = tempExtenParams.split('&')
1045
+ // for (let i = 0; i < tempSplitParams.length; i++) {
1046
+ // let tempSplitValue = tempSplitParams[i].split('=')
1047
+ // this.$set(
1048
+ // postData.extendParams,
1049
+ // tempSplitValue[0],
1050
+ // tempSplitValue[1]
1051
+ // )
1052
+ // }
1053
+ // }
1054
+ let vm = this
1055
+ vm.gridLoading = true
1056
+ request({
1057
+ url: tempApi,
1058
+ method: 'post',
1059
+ data: postData,
1060
+ })
1061
+ .then((responseData) => {
1062
+ if(vm.linkData){
1063
+ vm.searchRows = responseData.content[this.linkData].rows
1064
+ vm.gridPagerConfig.total = XEUtils.toNumber(responseData.content[this.linkData].totalRows);
1065
+ }else{
1066
+ if (vm.isOld === true) {
1067
+ vm.searchRows = responseData.data
1068
+ vm.gridPagerConfig.total = responseData.extData.totalRows
1069
+ } else {
1070
+ vm.searchRows = responseData.content
1071
+ vm.$refs.pupupGridView.loadData(vm.searchRows)
1072
+ vm.gridPagerConfig.total = responseData.otherContent.totalRows
1073
+ }
1074
+ }
1075
+ //本身结果集会返回sysRepeat为true的数据,所以处理数据的时候不能默认设置成false,会把后台返回的数据重置掉
1076
+ //查询下拉显示列配置成sysRepeat的列字段名称
1077
+ let repeatCols = vm.columns
1078
+ .filter((x) => x.sysRepeat)
1079
+ .map((y) => {
1080
+ return {
1081
+ field: y.field,
1082
+ linkField: y.linkField,
1083
+ }
1084
+ });
1085
+ //添加当前行关联值
1086
+ XEUtils.arrayEach(vm.contrasts, (loopItem)=>{
1087
+ repeatCols.push({
1088
+ isCurrentRow:true,
1089
+ linkField:loopItem
1090
+ })
1091
+ })
1092
+ if(repeatCols.length>0 && vm.propTableData.length>1){
1093
+ //设置是否重复
1094
+ XEUtils.arrayEach(vm.searchRows,(loopItem)=>{
1095
+ if(loopItem.sysRepeat===true) return
1096
+ //循环弹出查询返回的数据是否已经存在于表格中
1097
+ loopItem.sysRepeat = XEUtils.some(vm.propTableData,(loopTableItem)=>{
1098
+ //判断表格行数据是当前输入行就返回false,无需重复验证
1099
+ if(loopTableItem['id']===vm.row['id']){
1100
+ return false
1101
+ }
1102
+
1103
+ for(let i=0;i<repeatCols.length;i++){
1104
+ let tempRepeatColInfo = repeatCols[i]
1105
+ //弹出数据列值
1106
+ let tempPopupRowColValue =tempRepeatColInfo.isCurrentRow===true?vm.row[tempRepeatColInfo.linkField]:
1107
+ loopItem[tempRepeatColInfo.field]
1108
+ //表格数据列值
1109
+ let tempTableRowColValue = loopTableItem[tempRepeatColInfo.linkField]
1110
+ if(tempPopupRowColValue!==tempTableRowColValue){
1111
+ //只有有一个不一致,就返回false
1112
+ return false
1113
+ }
1114
+ }
1115
+ return true
1116
+ })
1117
+ })
1118
+ }
1119
+ // if (repeatRowInfo.field) {
1120
+ // //设置重复值
1121
+ // XEUtils.arrayEach(vm.searchRows, (item) => {
1122
+ // if (
1123
+ // XEUtils.arrayIndexOf(
1124
+ // repeatRowInfo.values,
1125
+ // item[repeatRowInfo.field]
1126
+ // ) > -1
1127
+ // ) {
1128
+ // item['sysRepeat'] = true
1129
+ // }
1130
+ // })
1131
+ // }
1132
+ // 若当前表格内只有一行,则不进行判断
1133
+ // if (vm.propTableData.length == 1) {
1134
+ // return
1135
+ // }
1136
+ // 设置字段sysRepeat后,所定字段的值全部相同则不可选择
1137
+ // let fieldNames = vm.columns
1138
+ // .filter((x) => x.sysRepeat)
1139
+ // .map((y) => {
1140
+ // return {
1141
+ // field: y.field,
1142
+ // linkField: y.linkField,
1143
+ // }
1144
+ // })
1145
+ // if (fieldNames.length) {
1146
+ // vm.searchRows.forEach((info) => {
1147
+ // // 当一次创建多行时,过滤需特定字段不可为空的
1148
+ // // 获取数组对象,根据选定字段,过滤选定字段都为空的
1149
+ // let tempArr = vm.propTableData.filter((currentInfo) => {
1150
+ // let tempD = []
1151
+ // fieldNames.forEach((z) => {
1152
+ // // 字段的值若为null、undefined,记录过滤掉
1153
+ // if (!currentInfo[z.linkField]) {
1154
+ // tempD.push(true)
1155
+ // }
1156
+ // })
1157
+ // return tempD.length !== fieldNames.length
1158
+ // })
1159
+ // let arr = []
1160
+ // // 分为有参查询和无参查询
1161
+ // if (tempExp.expressions.length && fieldNames.length == 1) {
1162
+ // for (let j = 0; j < fieldNames.length; j++) {
1163
+ // let mapArr = tempArr.map(
1164
+ // (item) => item[fieldNames[j].linkField]
1165
+ // )
1166
+ // let setArr = new Set(mapArr)
1167
+ // if (setArr.size < mapArr.length) {
1168
+ // arr.push(true)
1169
+ // }
1170
+ // }
1171
+ // if (fieldNames.length === arr.length) {
1172
+ // info.sysRepeat = true
1173
+ // }
1174
+ // } else {
1175
+ // tempArr.forEach((item) => {
1176
+ // // 接口字段可能和表字段field不一致,linkField一致
1177
+ // for (let j = 0; j < fieldNames.length; j++) {
1178
+ // if (
1179
+ // info[fieldNames[j].field] == item[fieldNames[j].linkField]
1180
+ // ) {
1181
+ // arr.push(true)
1182
+ // }
1183
+ // }
1184
+ // if (fieldNames.length === arr.length) {
1185
+ // info.sysRepeat = true
1186
+ // }
1187
+ // })
1188
+ // }
1189
+ // if (info.sysRepeat && this.contrasts.length) {
1190
+ // let flag = 0
1191
+ // XEUtils.arrayEach(this.propTableData, (item) => {
1192
+ // if (item[this.field] === info[this.field]) {
1193
+ // XEUtils.arrayEach(this.contrasts, (loop) => {
1194
+ // if (
1195
+ // item[loop] === this.row[loop] &&
1196
+ // item.id !== this.row.id
1197
+ // ) {
1198
+ // flag++
1199
+ // }
1200
+ // })
1201
+ // }
1202
+ // })
1203
+ // if (flag === this.contrasts.length) {
1204
+ // info.sysRepeat = true
1205
+ // }
1206
+ // }
1207
+ // })
1208
+ // }
1209
+ })
1210
+ .catch((error) => {
1211
+ console.error(error)
1212
+ })
1213
+ .finally(() => {
1214
+ vm.gridLoading = false
1215
+ })
1216
+ },
1217
+ getPostApi(postData) {
1218
+ let tempApi = this.api
1219
+ if(this.newApiObj.newApi){
1220
+ tempApi=this.newApiObj.newApi
1221
+ }
1222
+ if (this.api.indexOf('?') > 0) {
1223
+ tempApi = this.api.substring(0, this.api.indexOf('?'))
1224
+ let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1225
+ tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1226
+ let tempSplitParams = tempExtenParams.split('&')
1227
+ for (let i = 0; i < tempSplitParams.length; i++) {
1228
+ let tempSplitValue = tempSplitParams[i].split('=')
1229
+ this.$set(postData.extendParams, tempSplitValue[0], tempSplitValue[1])
1230
+ }
1231
+ }
1232
+ return tempApi
1233
+ },
1234
+ sortChange({ column, property, order, sortBy, sortList, $event }) {
1235
+ let currentSort = sortList.map((x) => {
1236
+ return [x.field, x.order]
1237
+ })
1238
+ this.sorts = currentSort
1239
+ this.searchData()
1240
+ },
1241
+
1242
+ // 下拉容器筛选条件被触发
1243
+ filterVisible({ column }) {
1244
+ XEUtils.remove(column.filters, (item) => {
1245
+ return item.data === ''
1246
+ })
1247
+ if (column.filters.length === 0) {
1248
+ column.filters.push({
1249
+ data: '',
1250
+ })
1251
+ }
1252
+ },
1253
+ filterConfirm(column) {
1254
+ let vm = this
1255
+ this.filterExpression = {
1256
+ operator: 'and',
1257
+ expressions: [],
1258
+ }
1259
+ let col = this.columns.find((x) => x.field === column.field)
1260
+ switch (col.controlType) {
1261
+ case 'select':
1262
+ column.filters[0].checked = column.filters[0].data.length > 0
1263
+ break
1264
+ default:
1265
+ column.filters[0].checked = column.filters[0].data !== ''
1266
+ break
1267
+ }
1268
+ //通知外部筛选改变事件
1269
+ let columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1270
+ XEUtils.each(columns, (item) => {
1271
+ let filterExpression = {
1272
+ operator: 'or',
1273
+ expressions: [],
1274
+ }
1275
+ if (!col.controlType) {
1276
+ col.controlType = 'text'
1277
+ }
1278
+ switch (col.controlType) {
1279
+ case 'select':
1280
+ if (item.filters && item.filters[0].checked) {
1281
+ XEUtils.each(item.filters[0].data, (loopItem) => {
1282
+ filterExpression.expressions.push({
1283
+ field: item.field,
1284
+ operator: 'EQ',
1285
+ value: loopItem,
1286
+ })
1287
+ })
1288
+ if (filterExpression.expressions.length > 0) {
1289
+ vm.filterExpression.expressions.push(filterExpression)
1290
+ }
1291
+ }
1292
+ break
1293
+ default:
1294
+ if (item.filters && item.filters[0].checked) {
1295
+ XEUtils.each(item.filters, (loopItem) => {
1296
+ if (loopItem.data) {
1297
+ filterExpression.expressions.push({
1298
+ field: item.field,
1299
+ operator: 'CO',
1300
+ value: loopItem.data,
1301
+ })
1302
+ }
1303
+ })
1304
+ if (filterExpression.expressions.length > 0) {
1305
+ vm.filterExpression.expressions.push(filterExpression)
1306
+ }
1307
+ }
1308
+ break
1309
+ }
1310
+ })
1311
+ this.gridPagerConfig.currentPage = 1
1312
+ this.searchData()
1313
+ this.$refs.pupupGridView.closeFilter()
1314
+ },
1315
+ // 添加筛选条件
1316
+ filterAddExp(column) {
1317
+ column['filters'].push({
1318
+ data: '',
1319
+ })
1320
+ },
1321
+
1322
+ // 清除筛选条件
1323
+ clearColumnFilter() {
1324
+ if(!this.$refs.pupupGridView){
1325
+ return
1326
+ }
1327
+ let columns = []
1328
+ let vm = this
1329
+ try {
1330
+ columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1331
+ } catch (err) {
1332
+ console.debug(err)
1333
+ }
1334
+ XEUtils.each(columns, (item) => {
1335
+ let col = vm.columns.find((x) => x.field === item.field)
1336
+ if (!col) {
1337
+ return
1338
+ }
1339
+ if (!col.controlType) {
1340
+ col.controlType = 'text'
1341
+ }
1342
+ switch (col.controlType) {
1343
+ case 'select':
1344
+ if (item.filters && item.filters[0].checked) {
1345
+ item.filters = [
1346
+ {
1347
+ data: [],
1348
+ },
1349
+ ]
1350
+ }
1351
+ break
1352
+ default:
1353
+ if (item.filters && item.filters[0].checked) {
1354
+ item.filters = [
1355
+ {
1356
+ data: '',
1357
+ },
1358
+ ]
1359
+ }
1360
+ break
1361
+ }
1362
+ })
1363
+ this.filterExpression = {
1364
+ operator: 'and',
1365
+ expressions: [],
1366
+ }
1367
+ },
1368
+ },
1369
+ }
1370
+ </script>
1371
+
1372
+ <style lang="scss" scoped>
1373
+ .pulldown-grid {
1374
+ min-width: 600px;
1375
+ width: auto;
1376
+ height: 350px;
1377
+ background-color: #fff;
1378
+ box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
1379
+ }
1380
+
1381
+ .d-grid-control {
1382
+ width: 100% !important;
1383
+ min-width: unset !important;
1384
+ // height: 30px;
1385
+ }
1386
+ .interceptor-class {
1387
+ padding: 10px;
1388
+ ::v-deep .ant-btn {
1389
+ margin: 10px 10px 0;
1390
+ }
1391
+ }
1392
+ </style>
1393
+
1394
+ <style lang="less">
1395
+ @import '../../styles/default.less';
1396
+ </style>