doway-coms 2.11.11 → 2.11.13

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 (91) hide show
  1. package/.browserslistrc +2 -2
  2. package/README.md +28 -28
  3. package/dist/css/chunk-vendors.7f83d8f9.css +8 -0
  4. package/dist/css/index.7946d50b.css +1 -0
  5. package/dist/favicon.ico +0 -0
  6. package/dist/js/chunk-vendors.28fda91d.js +340 -0
  7. package/dist/js/index.49bc6add.js +2 -0
  8. package/lib/doway-coms.common.js +120397 -0
  9. package/lib/doway-coms.css +1 -0
  10. package/lib/doway-coms.umd.js +120407 -0
  11. package/lib/doway-coms.umd.min.js +328 -0
  12. package/package.json +62 -62
  13. package/packages/AuditsList/index.js +7 -7
  14. package/packages/AuditsList/src/index.vue +314 -314
  15. package/packages/BaseButton/index.js +7 -7
  16. package/packages/BaseButton/src/index.vue +242 -242
  17. package/packages/BaseCheckbox/index.js +7 -7
  18. package/packages/BaseCheckbox/src/index.vue +134 -134
  19. package/packages/BaseDate/index.js +7 -7
  20. package/packages/BaseDate/src/index.vue +197 -197
  21. package/packages/BaseDateWeek/index.js +7 -7
  22. package/packages/BaseDateWeek/src/index.vue +163 -163
  23. package/packages/BaseDatetime/index.js +7 -7
  24. package/packages/BaseDatetime/src/index.vue +196 -196
  25. package/packages/BaseFileGroup/index.js +7 -7
  26. package/packages/BaseFileGroup/src/index.vue +724 -724
  27. package/packages/BaseForm/index.js +7 -7
  28. package/packages/BaseForm/src/index.vue +895 -895
  29. package/packages/BaseGantt/index.js +9 -9
  30. package/packages/BaseGantt/src/index.vue +617 -617
  31. package/packages/BaseGrid/index.js +9 -9
  32. package/packages/BaseGrid/src/exportCmp.vue +105 -105
  33. package/packages/BaseGrid/src/gridApi.js +32 -32
  34. package/packages/BaseGrid/src/index.vue +4242 -4230
  35. package/packages/BaseGridAdjust/index.js +9 -9
  36. package/packages/BaseGridAdjust/src/index.vue +482 -482
  37. package/packages/BaseInput/index.js +7 -7
  38. package/packages/BaseInput/src/index.vue +195 -195
  39. package/packages/BaseIntervalInput/index.js +7 -7
  40. package/packages/BaseIntervalInput/src/index.vue +310 -310
  41. package/packages/BaseKanbanEmpty/index.js +7 -7
  42. package/packages/BaseKanbanEmpty/src/index.vue +176 -176
  43. package/packages/BaseNumberInput/index.js +7 -7
  44. package/packages/BaseNumberInput/src/index.vue +291 -291
  45. package/packages/BasePagination/index.js +7 -7
  46. package/packages/BasePagination/src/index.vue +91 -91
  47. package/packages/BasePictureCard/index.js +7 -7
  48. package/packages/BasePictureCard/src/index.vue +671 -671
  49. package/packages/BasePrintPreview/index.js +7 -7
  50. package/packages/BasePrintPreview/src/index.vue +150 -150
  51. package/packages/BasePulldown/index.js +7 -7
  52. package/packages/BasePulldown/src/index.vue +1395 -1395
  53. package/packages/BaseSearch/index.js +7 -7
  54. package/packages/BaseSearch/src/index.vue +935 -935
  55. package/packages/BaseSelect/index.js +7 -7
  56. package/packages/BaseSelect/src/index.vue +155 -155
  57. package/packages/BaseSelectMulti/index.js +7 -7
  58. package/packages/BaseSelectMulti/src/index.vue +148 -148
  59. package/packages/BaseTextArea/index.js +7 -7
  60. package/packages/BaseTextArea/src/index.vue +187 -187
  61. package/packages/BaseTime/index.js +7 -7
  62. package/packages/BaseTime/src/index.vue +166 -166
  63. package/packages/BaseTool/index.js +7 -7
  64. package/packages/BaseTool/src/index.vue +353 -353
  65. package/packages/BaseToolStatus/index.js +7 -7
  66. package/packages/BaseToolStatus/src/ApprovalPersonsGroup.vue +41 -41
  67. package/packages/BaseToolStatus/src/index.vue +439 -439
  68. package/packages/BaseTreeSelect/index.js +8 -8
  69. package/packages/BaseTreeSelect/src/index.vue +437 -437
  70. package/packages/HistoryModal/index.js +8 -8
  71. package/packages/HistoryModal/src/index.vue +144 -144
  72. package/packages/LeaveAMessage/index.js +7 -7
  73. package/packages/LeaveAMessage/src/index.vue +601 -601
  74. package/packages/directive/clickoutside.js +44 -44
  75. package/packages/index.js +197 -197
  76. package/packages/styles/default.css +78 -78
  77. package/packages/styles/default.less +91 -91
  78. package/packages/utils/api.js +122 -122
  79. package/packages/utils/auth.js +38 -38
  80. package/packages/utils/common.js +703 -703
  81. package/packages/utils/dom.js +181 -181
  82. package/packages/utils/enum.js +86 -86
  83. package/packages/utils/filters.js +495 -485
  84. package/packages/utils/gridFormat.js +66 -66
  85. package/packages/utils/msg.js +103 -103
  86. package/packages/utils/patchFiles.js +44 -44
  87. package/packages/utils/request.js +181 -181
  88. package/packages/utils/store.js +372 -372
  89. package/packages/utils/tscPrinter.js +101 -101
  90. package/sync.bash +6 -6
  91. package/vue.config.js +59 -59
@@ -1,1395 +1,1395 @@
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
- },
667
- inputBlurEvent(event) {},
668
- /**
669
- * 输入框获取焦点事件
670
- */
671
- inputFocusEvent(event) {
672
- event.currentTarget.select()
673
- // this.$refs.pulldownRef.showPanel()
674
- // this.searchData()
675
- },
676
- /**
677
- * Tab键隐藏面板
678
- */
679
- inputKeydownEvent(event) {
680
- if (event.keyCode === 9) {
681
- //tab事件
682
- if(this.allowAutoClear!==false){
683
- this.$refs.pulldownRef.hidePanel()
684
- this.clearInputValue()
685
- }
686
- }
687
- },
688
- inputClickEvent(event) {
689
- if (this.$refs.pulldownRef.isPanelVisible() === false) {
690
- this.$refs.pulldownRef.showPanel()
691
- this.clearColumnFilter()
692
- this.searchData()
693
- } else {
694
- this.$refs.pulldownRef.hidePanel()
695
- // 点击输入框隐藏panel时清空输入框
696
- // if(this.allowAutoClear){
697
- // this.currentValue = ''
698
- // }
699
- }
700
- },
701
- /**
702
- * 输入库输入事件
703
- */
704
- inputKeyupEvent(event) {
705
- //好像ok
706
- if (!this.immediate && event.keyCode !== 13) {
707
- console.debug('davistest')
708
- } else {
709
- if (this.inputTimeout) {
710
- clearTimeout(this.inputTimeout)
711
- }
712
- let vm = this
713
- this.inputTimeout = setTimeout(() => {
714
- if(vm.$refs.pulldownRef){
715
- if(vm.$refs.pulldownRef.isPanelVisible() === false){
716
- vm.$refs.pulldownRef.showPanel()
717
- }
718
- vm.searchData()
719
- }else{
720
- //如果输入复制数据,或者快速输入数据然后切换到其他行的时候会
721
- //造成当前行编辑装填变成关闭,并且取步到弹出组件,导致输入的值没有被清空
722
- //所以这里需要判断是否有弹出组件,如果没有,则清空输入框
723
- //davis20241129
724
- if(vm.allowAutoClear!==false){
725
- vm.clearInputValue()
726
- }
727
- }
728
- //判断面板是否打开
729
- // if (vm.$refs.pulldownRef&&vm.$refs.pulldownRef.isPanelVisible() === false) {
730
- // vm.$refs.pulldownRef.showPanel()
731
- // }
732
- // vm.searchData()
733
- }, 500)
734
- }
735
- },
736
- /**
737
- * 网格列选中事件
738
- */
739
- gridCellClick({ row, column }) {
740
- if (row.sysRepeat === true) {
741
- return
742
- }
743
- if (column.type === 'seq' || column.type === 'checkbox') {
744
- return
745
- }
746
- this.isInputChanged = false
747
- this.setLinkValue(row, this.row)
748
- this.$emit('selectChanged', row)
749
- this.$refs.pulldownRef.hidePanel()
750
- },
751
- setLinkValue(pulldownRow, oriRow) {
752
- for (let i = 0; i < this.internalColumns.length; i++) {
753
- if (this.internalColumns[i].linkField) {
754
- let tempLinkFields = this.internalColumns[i].linkField.split('.')
755
- let tempRow = oriRow
756
- // for(let j=0;j<tempLinkFields.length;j++){
757
- // let tempField = tempLinkFields[j]
758
- // //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
759
- // if (!(tempField in tempRow)) {
760
- // this.$antwarning(
761
- // '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
762
- // )
763
- // break
764
- // }
765
- // if(j===tempLinkFields.length-1){
766
- // if (pulldownRow === null) {
767
- // if (this.internalColumns[i].nullClear === false) {
768
- // //是否空值清除数据,用于可选可输入的控件
769
- // continue
770
- // }
771
- // this.$set(tempRow, tempField, null)
772
- // } else {
773
- // this.$set(
774
- // tempRow,
775
- // tempField,
776
- // this.getLinkValue(tempField, pulldownRow)
777
- // )
778
- // }
779
- // }else{
780
- // tempRow = tempRow[tempField]
781
- // }
782
- // }
783
-
784
- //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
785
- if (!(this.internalColumns[i].linkField in oriRow)) {
786
- this.$antwarning(
787
- '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
788
- )
789
- continue
790
- }
791
- if (pulldownRow === null) {
792
- if (this.internalColumns[i].nullClear === false) {
793
- //是否空值清楚数据,用于可选可输入的控件
794
- continue
795
- }
796
- this.$set(oriRow, this.internalColumns[i].linkField, null)
797
- } else {
798
- this.$set(
799
- oriRow,
800
- this.internalColumns[i].linkField,
801
- this.getLinkValue(this.internalColumns[i].field, pulldownRow)
802
- )
803
- }
804
- }
805
- }
806
- },
807
- getLinkValue(field, row) {
808
- let linkField = field.split('.')
809
- if (linkField.length > 1) {
810
- let fieldValue = row
811
- for (let i = 0; i < linkField.length; i++) {
812
- if (
813
- fieldValue[linkField[i]] === undefined ||
814
- fieldValue[linkField[i]] === null
815
- ) {
816
- return null
817
- }
818
- fieldValue = fieldValue[linkField[i]]
819
- }
820
- return fieldValue
821
- }
822
- return row[field]
823
- },
824
- /**
825
- * 左下角按钮点击事件
826
- */
827
- pagerBtnClick(btn) {
828
- this.$refs.pupupAddView.show()
829
- // this.$emit('pulldownBtnClick', btn)
830
- this.$refs.pulldownRef.hidePanel()
831
- },
832
- // 多选内容时,若数据不满足条件,不可选中
833
- checkMethod({ row }) {
834
- if (row.sysRepeat) {
835
- return false
836
- }
837
- return true
838
- },
839
- /**
840
- * 确认多选
841
- */
842
- multiSelectConfirm() {
843
- this.isInputChanged = false
844
- this.$emit(
845
- 'confirmMultiSelect',
846
- this,
847
- this.$refs.pupupGridView.getCheckboxRecords(true)
848
- )
849
- this.$refs.pulldownRef.hidePanel()
850
- },
851
- popupSaveAfter(pupupAddRowInfo) {
852
- let postData = {
853
- fields: null,
854
- begin: 1,
855
- size: 1,
856
- expression: {},
857
- sorts: '',
858
- }
859
- let tempKeyExp = XEUtils.find(
860
- this.internalColumns,
861
- (item) => item.isKey === true
862
- )
863
- postData.expression = {
864
- operator: 'and',
865
- expressions: [
866
- {
867
- operator: 'and',
868
- expressions: [
869
- {
870
- field: tempKeyExp.field,
871
- operator: 'EQ',
872
- value: pupupAddRowInfo['id'],
873
- },
874
- ],
875
- },
876
- ],
877
- }
878
- let vm = this
879
- let tempApi = this.getPostApi(postData)
880
- request({
881
- url: tempApi,
882
- method: 'post',
883
- data: postData,
884
- })
885
- .then((responseData) => {
886
- if (responseData.content.length > 0) {
887
- vm.setLinkValue(responseData.content[0], vm.row)
888
- vm.$emit('selectChanged', responseData.content[0])
889
- }
890
- })
891
- .catch((error) => {
892
- console.error(error)
893
- })
894
- .finally(() => {})
895
- },
896
- /**
897
- * 分页改变事件
898
- */
899
- pageChangeEvent({ currentPage, pageSize }) {
900
- this.gridPagerConfig.currentPage = currentPage
901
- this.gridPagerConfig.pageSize = pageSize
902
- this.searchData()
903
- },
904
- /**
905
- * 面板隐藏事件
906
- */
907
- pullDownHideEvent({ $event }) {
908
- if(this.allowAutoClear!==false){
909
- this.clearInputValue()
910
- }
911
- },
912
- /**
913
- * 查询数据
914
- */
915
- searchData() {
916
- if (this.isLocalData === true) {
917
- let tempSearch = {
918
- value: this.currentValue,
919
- dataSource: [],
920
- field: this.field,
921
- }
922
- this.$emit('preSearch', tempSearch)
923
- this.searchRows = []
924
- //判断删选条件过滤
925
- XEUtils.arrayEach(tempSearch.dataSource,loopItem=>{
926
- let tempFlag = this.filterCols.length===0
927
- for(let i=0;i< this.filterCols.length;i++){
928
- let tempValue = loopItem[this.filterCols[i].field]
929
- if(XEUtils.isString(tempValue) && tempValue.includes(this.currentValue)===true){
930
- tempFlag = true
931
- break
932
- }
933
- }
934
- if(tempFlag===true || !this.currentValue){
935
- this.searchRows.push(loopItem)
936
- }
937
-
938
- })
939
- this.gridPagerConfig.total = this.searchRows.length
940
- return
941
- }
942
-
943
- let tempExp = {
944
- operator: 'or',
945
- expressions: [],
946
- }
947
- if (this.isOld === true) {
948
- tempExp = ''
949
- }
950
- if (this.filterExpression.expressions.length > 0) {
951
- tempExp.expressions.push(this.filterExpression)
952
- } else if (this.currentValue) {
953
- for (let i = 0; i < this.filterCols.length; i++) {
954
- if (this.isOld === true) {
955
- tempExp =
956
- tempExp +
957
- this.filterCols[i].field +
958
- '.contains("' +
959
- this.currentValue +
960
- '")'
961
- if (i < this.filterCols.length - 1) {
962
- tempExp = tempExp + ' or '
963
- }
964
- } else {
965
- if (this.filterCols[i].controlType == 'number') {
966
- tempExp.expressions.push({
967
- field: this.filterCols[i].field,
968
- operator: 'EQ',
969
- value: Number(this.currentValue),
970
- })
971
- } else {
972
- tempExp.expressions.push({
973
- field: this.filterCols[i].field,
974
- operator: 'CO',
975
- value: this.currentValue,
976
- })
977
- }
978
- }
979
- }
980
- }
981
- if (this.isOld === true && tempExp.length > 0) {
982
- tempExp = '(' + tempExp + ')'
983
- }
984
-
985
- if (this.defaultExpression) {
986
- let tempDefault = replaceParamString(
987
- this.defaultExpression,
988
- this.formRow,
989
- this.$store.getters.moduleSelectItems[this.$route.meta.moduleId]
990
- )
991
-
992
- if (tempExp) {
993
- tempExp = tempExp + ' and (' + tempDefault + ')'
994
- } else {
995
- tempExp = tempDefault
996
- }
997
- }
998
-
999
- let postExpression = {
1000
- field: this.field,
1001
- expression: tempExp,
1002
- extendParams: {},
1003
- replaceParams:[]
1004
- }
1005
- let repeatRowInfo = {
1006
- field: '',
1007
- values: [],
1008
- }
1009
- //查询之前从外部组件构造其他的条件
1010
- this.$emit('preSearch', postExpression, repeatRowInfo, this.row,this.newApiObj)
1011
- let postData = {
1012
- fields: this.fetchFields,
1013
- begin:
1014
- (this.gridPagerConfig.currentPage - 1) *
1015
- this.gridPagerConfig.pageSize +
1016
- 1,
1017
- size: this.gridPagerConfig.pageSize,
1018
- expression: postExpression.expression,
1019
- sorts: this.sorts,
1020
- extendParams: postExpression.extendParams,
1021
- replaceParams:postExpression.replaceParams
1022
- }
1023
- if (this.linkData) {
1024
- postData = {
1025
- moduleCode: this.$route.meta.moduleCode,
1026
- dataCodes: [
1027
- {
1028
- dataCode: this.linkData,
1029
- searchParam: postData,
1030
- },
1031
- ],
1032
- };
1033
- }
1034
-
1035
- // console.log(postData.sorts);
1036
- let tempApi = this.getPostApi(postData)
1037
-
1038
- // let tempApi = this.api
1039
- // if (this.api.indexOf('?') > 0) {
1040
- // tempApi = this.api.substring(0, this.api.indexOf('?'))
1041
- // let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1042
- // tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1043
- // let tempSplitParams = tempExtenParams.split('&')
1044
- // for (let i = 0; i < tempSplitParams.length; i++) {
1045
- // let tempSplitValue = tempSplitParams[i].split('=')
1046
- // this.$set(
1047
- // postData.extendParams,
1048
- // tempSplitValue[0],
1049
- // tempSplitValue[1]
1050
- // )
1051
- // }
1052
- // }
1053
- let vm = this
1054
- vm.gridLoading = true
1055
- request({
1056
- url: tempApi,
1057
- method: 'post',
1058
- data: postData,
1059
- })
1060
- .then((responseData) => {
1061
- if(vm.linkData){
1062
- vm.searchRows = responseData.content[this.linkData].rows
1063
- vm.gridPagerConfig.total = XEUtils.toNumber(responseData.content[this.linkData].totalRows);
1064
- }else{
1065
- if (vm.isOld === true) {
1066
- vm.searchRows = responseData.data
1067
- vm.gridPagerConfig.total = responseData.extData.totalRows
1068
- } else {
1069
- vm.searchRows = responseData.content
1070
- vm.$refs.pupupGridView.loadData(vm.searchRows)
1071
- vm.gridPagerConfig.total = responseData.otherContent.totalRows
1072
- }
1073
- }
1074
- //本身结果集会返回sysRepeat为true的数据,所以处理数据的时候不能默认设置成false,会把后台返回的数据重置掉
1075
- //查询下拉显示列配置成sysRepeat的列字段名称
1076
- let repeatCols = vm.columns
1077
- .filter((x) => x.sysRepeat)
1078
- .map((y) => {
1079
- return {
1080
- field: y.field,
1081
- linkField: y.linkField,
1082
- }
1083
- });
1084
- //添加当前行关联值
1085
- XEUtils.arrayEach(vm.contrasts, (loopItem)=>{
1086
- repeatCols.push({
1087
- isCurrentRow:true,
1088
- linkField:loopItem
1089
- })
1090
- })
1091
- if(repeatCols.length>0 && vm.propTableData.length>1){
1092
- //设置是否重复
1093
- XEUtils.arrayEach(vm.searchRows,(loopItem)=>{
1094
- if(loopItem.sysRepeat===true) return
1095
- //循环弹出查询返回的数据是否已经存在于表格中
1096
- loopItem.sysRepeat = XEUtils.some(vm.propTableData,(loopTableItem)=>{
1097
- //判断表格行数据是当前输入行就返回false,无需重复验证
1098
- if(loopTableItem['id']===vm.row['id']){
1099
- return false
1100
- }
1101
-
1102
- for(let i=0;i<repeatCols.length;i++){
1103
- let tempRepeatColInfo = repeatCols[i]
1104
- //弹出数据列值
1105
- let tempPopupRowColValue =tempRepeatColInfo.isCurrentRow===true?vm.row[tempRepeatColInfo.linkField]:
1106
- loopItem[tempRepeatColInfo.field]
1107
- //表格数据列值
1108
- let tempTableRowColValue = loopTableItem[tempRepeatColInfo.linkField]
1109
- if(tempPopupRowColValue!==tempTableRowColValue){
1110
- //只有有一个不一致,就返回false
1111
- return false
1112
- }
1113
- }
1114
- return true
1115
- })
1116
- })
1117
- }
1118
- // if (repeatRowInfo.field) {
1119
- // //设置重复值
1120
- // XEUtils.arrayEach(vm.searchRows, (item) => {
1121
- // if (
1122
- // XEUtils.arrayIndexOf(
1123
- // repeatRowInfo.values,
1124
- // item[repeatRowInfo.field]
1125
- // ) > -1
1126
- // ) {
1127
- // item['sysRepeat'] = true
1128
- // }
1129
- // })
1130
- // }
1131
- // 若当前表格内只有一行,则不进行判断
1132
- // if (vm.propTableData.length == 1) {
1133
- // return
1134
- // }
1135
- // 设置字段sysRepeat后,所定字段的值全部相同则不可选择
1136
- // let fieldNames = vm.columns
1137
- // .filter((x) => x.sysRepeat)
1138
- // .map((y) => {
1139
- // return {
1140
- // field: y.field,
1141
- // linkField: y.linkField,
1142
- // }
1143
- // })
1144
- // if (fieldNames.length) {
1145
- // vm.searchRows.forEach((info) => {
1146
- // // 当一次创建多行时,过滤需特定字段不可为空的
1147
- // // 获取数组对象,根据选定字段,过滤选定字段都为空的
1148
- // let tempArr = vm.propTableData.filter((currentInfo) => {
1149
- // let tempD = []
1150
- // fieldNames.forEach((z) => {
1151
- // // 字段的值若为null、undefined,记录过滤掉
1152
- // if (!currentInfo[z.linkField]) {
1153
- // tempD.push(true)
1154
- // }
1155
- // })
1156
- // return tempD.length !== fieldNames.length
1157
- // })
1158
- // let arr = []
1159
- // // 分为有参查询和无参查询
1160
- // if (tempExp.expressions.length && fieldNames.length == 1) {
1161
- // for (let j = 0; j < fieldNames.length; j++) {
1162
- // let mapArr = tempArr.map(
1163
- // (item) => item[fieldNames[j].linkField]
1164
- // )
1165
- // let setArr = new Set(mapArr)
1166
- // if (setArr.size < mapArr.length) {
1167
- // arr.push(true)
1168
- // }
1169
- // }
1170
- // if (fieldNames.length === arr.length) {
1171
- // info.sysRepeat = true
1172
- // }
1173
- // } else {
1174
- // tempArr.forEach((item) => {
1175
- // // 接口字段可能和表字段field不一致,linkField一致
1176
- // for (let j = 0; j < fieldNames.length; j++) {
1177
- // if (
1178
- // info[fieldNames[j].field] == item[fieldNames[j].linkField]
1179
- // ) {
1180
- // arr.push(true)
1181
- // }
1182
- // }
1183
- // if (fieldNames.length === arr.length) {
1184
- // info.sysRepeat = true
1185
- // }
1186
- // })
1187
- // }
1188
- // if (info.sysRepeat && this.contrasts.length) {
1189
- // let flag = 0
1190
- // XEUtils.arrayEach(this.propTableData, (item) => {
1191
- // if (item[this.field] === info[this.field]) {
1192
- // XEUtils.arrayEach(this.contrasts, (loop) => {
1193
- // if (
1194
- // item[loop] === this.row[loop] &&
1195
- // item.id !== this.row.id
1196
- // ) {
1197
- // flag++
1198
- // }
1199
- // })
1200
- // }
1201
- // })
1202
- // if (flag === this.contrasts.length) {
1203
- // info.sysRepeat = true
1204
- // }
1205
- // }
1206
- // })
1207
- // }
1208
- })
1209
- .catch((error) => {
1210
- console.error(error)
1211
- })
1212
- .finally(() => {
1213
- vm.gridLoading = false
1214
- })
1215
- },
1216
- getPostApi(postData) {
1217
- let tempApi = this.api
1218
- if(this.newApiObj.newApi){
1219
- tempApi=this.newApiObj.newApi
1220
- }
1221
- if (this.api.indexOf('?') > 0) {
1222
- tempApi = this.api.substring(0, this.api.indexOf('?'))
1223
- let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1224
- tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1225
- let tempSplitParams = tempExtenParams.split('&')
1226
- for (let i = 0; i < tempSplitParams.length; i++) {
1227
- let tempSplitValue = tempSplitParams[i].split('=')
1228
- this.$set(postData.extendParams, tempSplitValue[0], tempSplitValue[1])
1229
- }
1230
- }
1231
- return tempApi
1232
- },
1233
- sortChange({ column, property, order, sortBy, sortList, $event }) {
1234
- let currentSort = sortList.map((x) => {
1235
- return [x.field, x.order]
1236
- })
1237
- this.sorts = currentSort
1238
- this.searchData()
1239
- },
1240
-
1241
- // 下拉容器筛选条件被触发
1242
- filterVisible({ column }) {
1243
- XEUtils.remove(column.filters, (item) => {
1244
- return item.data === ''
1245
- })
1246
- if (column.filters.length === 0) {
1247
- column.filters.push({
1248
- data: '',
1249
- })
1250
- }
1251
- },
1252
- filterConfirm(column) {
1253
- let vm = this
1254
- this.filterExpression = {
1255
- operator: 'and',
1256
- expressions: [],
1257
- }
1258
- let col = this.columns.find((x) => x.field === column.field)
1259
- switch (col.controlType) {
1260
- case 'select':
1261
- column.filters[0].checked = column.filters[0].data.length > 0
1262
- break
1263
- default:
1264
- column.filters[0].checked = column.filters[0].data !== ''
1265
- break
1266
- }
1267
- //通知外部筛选改变事件
1268
- let columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1269
- XEUtils.each(columns, (item) => {
1270
- let filterExpression = {
1271
- operator: 'or',
1272
- expressions: [],
1273
- }
1274
- if (!col.controlType) {
1275
- col.controlType = 'text'
1276
- }
1277
- switch (col.controlType) {
1278
- case 'select':
1279
- if (item.filters && item.filters[0].checked) {
1280
- XEUtils.each(item.filters[0].data, (loopItem) => {
1281
- filterExpression.expressions.push({
1282
- field: item.field,
1283
- operator: 'EQ',
1284
- value: loopItem,
1285
- })
1286
- })
1287
- if (filterExpression.expressions.length > 0) {
1288
- vm.filterExpression.expressions.push(filterExpression)
1289
- }
1290
- }
1291
- break
1292
- default:
1293
- if (item.filters && item.filters[0].checked) {
1294
- XEUtils.each(item.filters, (loopItem) => {
1295
- if (loopItem.data) {
1296
- filterExpression.expressions.push({
1297
- field: item.field,
1298
- operator: 'CO',
1299
- value: loopItem.data,
1300
- })
1301
- }
1302
- })
1303
- if (filterExpression.expressions.length > 0) {
1304
- vm.filterExpression.expressions.push(filterExpression)
1305
- }
1306
- }
1307
- break
1308
- }
1309
- })
1310
- this.gridPagerConfig.currentPage = 1
1311
- this.searchData()
1312
- this.$refs.pupupGridView.closeFilter()
1313
- },
1314
- // 添加筛选条件
1315
- filterAddExp(column) {
1316
- column['filters'].push({
1317
- data: '',
1318
- })
1319
- },
1320
-
1321
- // 清除筛选条件
1322
- clearColumnFilter() {
1323
- if(!this.$refs.pupupGridView){
1324
- return
1325
- }
1326
- let columns = []
1327
- let vm = this
1328
- try {
1329
- columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1330
- } catch (err) {
1331
- console.debug(err)
1332
- }
1333
- XEUtils.each(columns, (item) => {
1334
- let col = vm.columns.find((x) => x.field === item.field)
1335
- if (!col) {
1336
- return
1337
- }
1338
- if (!col.controlType) {
1339
- col.controlType = 'text'
1340
- }
1341
- switch (col.controlType) {
1342
- case 'select':
1343
- if (item.filters && item.filters[0].checked) {
1344
- item.filters = [
1345
- {
1346
- data: [],
1347
- },
1348
- ]
1349
- }
1350
- break
1351
- default:
1352
- if (item.filters && item.filters[0].checked) {
1353
- item.filters = [
1354
- {
1355
- data: '',
1356
- },
1357
- ]
1358
- }
1359
- break
1360
- }
1361
- })
1362
- this.filterExpression = {
1363
- operator: 'and',
1364
- expressions: [],
1365
- }
1366
- },
1367
- },
1368
- }
1369
- </script>
1370
-
1371
- <style lang="scss" scoped>
1372
- .pulldown-grid {
1373
- min-width: 600px;
1374
- width: auto;
1375
- height: 350px;
1376
- background-color: #fff;
1377
- box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
1378
- }
1379
-
1380
- .d-grid-control {
1381
- width: 100% !important;
1382
- min-width: unset !important;
1383
- // height: 30px;
1384
- }
1385
- .interceptor-class {
1386
- padding: 10px;
1387
- ::v-deep .ant-btn {
1388
- margin: 10px 10px 0;
1389
- }
1390
- }
1391
- </style>
1392
-
1393
- <style lang="less">
1394
- @import '../../styles/default.less';
1395
- </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
+ },
667
+ inputBlurEvent(event) {},
668
+ /**
669
+ * 输入框获取焦点事件
670
+ */
671
+ inputFocusEvent(event) {
672
+ event.currentTarget.select()
673
+ // this.$refs.pulldownRef.showPanel()
674
+ // this.searchData()
675
+ },
676
+ /**
677
+ * Tab键隐藏面板
678
+ */
679
+ inputKeydownEvent(event) {
680
+ if (event.keyCode === 9) {
681
+ //tab事件
682
+ if(this.allowAutoClear!==false){
683
+ this.$refs.pulldownRef.hidePanel()
684
+ this.clearInputValue()
685
+ }
686
+ }
687
+ },
688
+ inputClickEvent(event) {
689
+ if (this.$refs.pulldownRef.isPanelVisible() === false) {
690
+ this.$refs.pulldownRef.showPanel()
691
+ this.clearColumnFilter()
692
+ this.searchData()
693
+ } else {
694
+ this.$refs.pulldownRef.hidePanel()
695
+ // 点击输入框隐藏panel时清空输入框
696
+ // if(this.allowAutoClear){
697
+ // this.currentValue = ''
698
+ // }
699
+ }
700
+ },
701
+ /**
702
+ * 输入库输入事件
703
+ */
704
+ inputKeyupEvent(event) {
705
+ //好像ok
706
+ if (!this.immediate && event.keyCode !== 13) {
707
+ console.debug('davistest')
708
+ } else {
709
+ if (this.inputTimeout) {
710
+ clearTimeout(this.inputTimeout)
711
+ }
712
+ let vm = this
713
+ this.inputTimeout = setTimeout(() => {
714
+ if(vm.$refs.pulldownRef){
715
+ if(vm.$refs.pulldownRef.isPanelVisible() === false){
716
+ vm.$refs.pulldownRef.showPanel()
717
+ }
718
+ vm.searchData()
719
+ }else{
720
+ //如果输入复制数据,或者快速输入数据然后切换到其他行的时候会
721
+ //造成当前行编辑装填变成关闭,并且取步到弹出组件,导致输入的值没有被清空
722
+ //所以这里需要判断是否有弹出组件,如果没有,则清空输入框
723
+ //davis20241129
724
+ if(vm.allowAutoClear!==false){
725
+ vm.clearInputValue()
726
+ }
727
+ }
728
+ //判断面板是否打开
729
+ // if (vm.$refs.pulldownRef&&vm.$refs.pulldownRef.isPanelVisible() === false) {
730
+ // vm.$refs.pulldownRef.showPanel()
731
+ // }
732
+ // vm.searchData()
733
+ }, 500)
734
+ }
735
+ },
736
+ /**
737
+ * 网格列选中事件
738
+ */
739
+ gridCellClick({ row, column }) {
740
+ if (row.sysRepeat === true) {
741
+ return
742
+ }
743
+ if (column.type === 'seq' || column.type === 'checkbox') {
744
+ return
745
+ }
746
+ this.isInputChanged = false
747
+ this.setLinkValue(row, this.row)
748
+ this.$emit('selectChanged', row)
749
+ this.$refs.pulldownRef.hidePanel()
750
+ },
751
+ setLinkValue(pulldownRow, oriRow) {
752
+ for (let i = 0; i < this.internalColumns.length; i++) {
753
+ if (this.internalColumns[i].linkField) {
754
+ let tempLinkFields = this.internalColumns[i].linkField.split('.')
755
+ let tempRow = oriRow
756
+ // for(let j=0;j<tempLinkFields.length;j++){
757
+ // let tempField = tempLinkFields[j]
758
+ // //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
759
+ // if (!(tempField in tempRow)) {
760
+ // this.$antwarning(
761
+ // '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
762
+ // )
763
+ // break
764
+ // }
765
+ // if(j===tempLinkFields.length-1){
766
+ // if (pulldownRow === null) {
767
+ // if (this.internalColumns[i].nullClear === false) {
768
+ // //是否空值清除数据,用于可选可输入的控件
769
+ // continue
770
+ // }
771
+ // this.$set(tempRow, tempField, null)
772
+ // } else {
773
+ // this.$set(
774
+ // tempRow,
775
+ // tempField,
776
+ // this.getLinkValue(tempField, pulldownRow)
777
+ // )
778
+ // }
779
+ // }else{
780
+ // tempRow = tempRow[tempField]
781
+ // }
782
+ // }
783
+
784
+ //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
785
+ if (!(this.internalColumns[i].linkField in oriRow)) {
786
+ this.$antwarning(
787
+ '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
788
+ )
789
+ continue
790
+ }
791
+ if (pulldownRow === null) {
792
+ if (this.internalColumns[i].nullClear === false) {
793
+ //是否空值清楚数据,用于可选可输入的控件
794
+ continue
795
+ }
796
+ this.$set(oriRow, this.internalColumns[i].linkField, null)
797
+ } else {
798
+ this.$set(
799
+ oriRow,
800
+ this.internalColumns[i].linkField,
801
+ this.getLinkValue(this.internalColumns[i].field, pulldownRow)
802
+ )
803
+ }
804
+ }
805
+ }
806
+ },
807
+ getLinkValue(field, row) {
808
+ let linkField = field.split('.')
809
+ if (linkField.length > 1) {
810
+ let fieldValue = row
811
+ for (let i = 0; i < linkField.length; i++) {
812
+ if (
813
+ fieldValue[linkField[i]] === undefined ||
814
+ fieldValue[linkField[i]] === null
815
+ ) {
816
+ return null
817
+ }
818
+ fieldValue = fieldValue[linkField[i]]
819
+ }
820
+ return fieldValue
821
+ }
822
+ return row[field]
823
+ },
824
+ /**
825
+ * 左下角按钮点击事件
826
+ */
827
+ pagerBtnClick(btn) {
828
+ this.$refs.pupupAddView.show()
829
+ // this.$emit('pulldownBtnClick', btn)
830
+ this.$refs.pulldownRef.hidePanel()
831
+ },
832
+ // 多选内容时,若数据不满足条件,不可选中
833
+ checkMethod({ row }) {
834
+ if (row.sysRepeat) {
835
+ return false
836
+ }
837
+ return true
838
+ },
839
+ /**
840
+ * 确认多选
841
+ */
842
+ multiSelectConfirm() {
843
+ this.isInputChanged = false
844
+ this.$emit(
845
+ 'confirmMultiSelect',
846
+ this,
847
+ this.$refs.pupupGridView.getCheckboxRecords(true)
848
+ )
849
+ this.$refs.pulldownRef.hidePanel()
850
+ },
851
+ popupSaveAfter(pupupAddRowInfo) {
852
+ let postData = {
853
+ fields: null,
854
+ begin: 1,
855
+ size: 1,
856
+ expression: {},
857
+ sorts: '',
858
+ }
859
+ let tempKeyExp = XEUtils.find(
860
+ this.internalColumns,
861
+ (item) => item.isKey === true
862
+ )
863
+ postData.expression = {
864
+ operator: 'and',
865
+ expressions: [
866
+ {
867
+ operator: 'and',
868
+ expressions: [
869
+ {
870
+ field: tempKeyExp.field,
871
+ operator: 'EQ',
872
+ value: pupupAddRowInfo['id'],
873
+ },
874
+ ],
875
+ },
876
+ ],
877
+ }
878
+ let vm = this
879
+ let tempApi = this.getPostApi(postData)
880
+ request({
881
+ url: tempApi,
882
+ method: 'post',
883
+ data: postData,
884
+ })
885
+ .then((responseData) => {
886
+ if (responseData.content.length > 0) {
887
+ vm.setLinkValue(responseData.content[0], vm.row)
888
+ vm.$emit('selectChanged', responseData.content[0])
889
+ }
890
+ })
891
+ .catch((error) => {
892
+ console.error(error)
893
+ })
894
+ .finally(() => {})
895
+ },
896
+ /**
897
+ * 分页改变事件
898
+ */
899
+ pageChangeEvent({ currentPage, pageSize }) {
900
+ this.gridPagerConfig.currentPage = currentPage
901
+ this.gridPagerConfig.pageSize = pageSize
902
+ this.searchData()
903
+ },
904
+ /**
905
+ * 面板隐藏事件
906
+ */
907
+ pullDownHideEvent({ $event }) {
908
+ if(this.allowAutoClear!==false){
909
+ this.clearInputValue()
910
+ }
911
+ },
912
+ /**
913
+ * 查询数据
914
+ */
915
+ searchData() {
916
+ if (this.isLocalData === true) {
917
+ let tempSearch = {
918
+ value: this.currentValue,
919
+ dataSource: [],
920
+ field: this.field,
921
+ }
922
+ this.$emit('preSearch', tempSearch)
923
+ this.searchRows = []
924
+ //判断删选条件过滤
925
+ XEUtils.arrayEach(tempSearch.dataSource,loopItem=>{
926
+ let tempFlag = this.filterCols.length===0
927
+ for(let i=0;i< this.filterCols.length;i++){
928
+ let tempValue = loopItem[this.filterCols[i].field]
929
+ if(XEUtils.isString(tempValue) && tempValue.includes(this.currentValue)===true){
930
+ tempFlag = true
931
+ break
932
+ }
933
+ }
934
+ if(tempFlag===true || !this.currentValue){
935
+ this.searchRows.push(loopItem)
936
+ }
937
+
938
+ })
939
+ this.gridPagerConfig.total = this.searchRows.length
940
+ return
941
+ }
942
+
943
+ let tempExp = {
944
+ operator: 'or',
945
+ expressions: [],
946
+ }
947
+ if (this.isOld === true) {
948
+ tempExp = ''
949
+ }
950
+ if (this.filterExpression.expressions.length > 0) {
951
+ tempExp.expressions.push(this.filterExpression)
952
+ } else if (this.currentValue) {
953
+ for (let i = 0; i < this.filterCols.length; i++) {
954
+ if (this.isOld === true) {
955
+ tempExp =
956
+ tempExp +
957
+ this.filterCols[i].field +
958
+ '.contains("' +
959
+ this.currentValue +
960
+ '")'
961
+ if (i < this.filterCols.length - 1) {
962
+ tempExp = tempExp + ' or '
963
+ }
964
+ } else {
965
+ if (this.filterCols[i].controlType == 'number') {
966
+ tempExp.expressions.push({
967
+ field: this.filterCols[i].field,
968
+ operator: 'EQ',
969
+ value: Number(this.currentValue),
970
+ })
971
+ } else {
972
+ tempExp.expressions.push({
973
+ field: this.filterCols[i].field,
974
+ operator: 'CO',
975
+ value: this.currentValue,
976
+ })
977
+ }
978
+ }
979
+ }
980
+ }
981
+ if (this.isOld === true && tempExp.length > 0) {
982
+ tempExp = '(' + tempExp + ')'
983
+ }
984
+
985
+ if (this.defaultExpression) {
986
+ let tempDefault = replaceParamString(
987
+ this.defaultExpression,
988
+ this.formRow,
989
+ this.$store.getters.moduleSelectItems[this.$route.meta.moduleId]
990
+ )
991
+
992
+ if (tempExp) {
993
+ tempExp = tempExp + ' and (' + tempDefault + ')'
994
+ } else {
995
+ tempExp = tempDefault
996
+ }
997
+ }
998
+
999
+ let postExpression = {
1000
+ field: this.field,
1001
+ expression: tempExp,
1002
+ extendParams: {},
1003
+ replaceParams:[]
1004
+ }
1005
+ let repeatRowInfo = {
1006
+ field: '',
1007
+ values: [],
1008
+ }
1009
+ //查询之前从外部组件构造其他的条件
1010
+ this.$emit('preSearch', postExpression, repeatRowInfo, this.row,this.newApiObj)
1011
+ let postData = {
1012
+ fields: this.fetchFields,
1013
+ begin:
1014
+ (this.gridPagerConfig.currentPage - 1) *
1015
+ this.gridPagerConfig.pageSize +
1016
+ 1,
1017
+ size: this.gridPagerConfig.pageSize,
1018
+ expression: postExpression.expression,
1019
+ sorts: this.sorts,
1020
+ extendParams: postExpression.extendParams,
1021
+ replaceParams:postExpression.replaceParams
1022
+ }
1023
+ if (this.linkData) {
1024
+ postData = {
1025
+ moduleCode: this.$route.meta.moduleCode,
1026
+ dataCodes: [
1027
+ {
1028
+ dataCode: this.linkData,
1029
+ searchParam: postData,
1030
+ },
1031
+ ],
1032
+ };
1033
+ }
1034
+
1035
+ // console.log(postData.sorts);
1036
+ let tempApi = this.getPostApi(postData)
1037
+
1038
+ // let tempApi = this.api
1039
+ // if (this.api.indexOf('?') > 0) {
1040
+ // tempApi = this.api.substring(0, this.api.indexOf('?'))
1041
+ // let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1042
+ // tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1043
+ // let tempSplitParams = tempExtenParams.split('&')
1044
+ // for (let i = 0; i < tempSplitParams.length; i++) {
1045
+ // let tempSplitValue = tempSplitParams[i].split('=')
1046
+ // this.$set(
1047
+ // postData.extendParams,
1048
+ // tempSplitValue[0],
1049
+ // tempSplitValue[1]
1050
+ // )
1051
+ // }
1052
+ // }
1053
+ let vm = this
1054
+ vm.gridLoading = true
1055
+ request({
1056
+ url: tempApi,
1057
+ method: 'post',
1058
+ data: postData,
1059
+ })
1060
+ .then((responseData) => {
1061
+ if(vm.linkData){
1062
+ vm.searchRows = responseData.content[this.linkData].rows
1063
+ vm.gridPagerConfig.total = XEUtils.toNumber(responseData.content[this.linkData].totalRows);
1064
+ }else{
1065
+ if (vm.isOld === true) {
1066
+ vm.searchRows = responseData.data
1067
+ vm.gridPagerConfig.total = responseData.extData.totalRows
1068
+ } else {
1069
+ vm.searchRows = responseData.content
1070
+ vm.$refs.pupupGridView.loadData(vm.searchRows)
1071
+ vm.gridPagerConfig.total = responseData.otherContent.totalRows
1072
+ }
1073
+ }
1074
+ //本身结果集会返回sysRepeat为true的数据,所以处理数据的时候不能默认设置成false,会把后台返回的数据重置掉
1075
+ //查询下拉显示列配置成sysRepeat的列字段名称
1076
+ let repeatCols = vm.columns
1077
+ .filter((x) => x.sysRepeat)
1078
+ .map((y) => {
1079
+ return {
1080
+ field: y.field,
1081
+ linkField: y.linkField,
1082
+ }
1083
+ });
1084
+ //添加当前行关联值
1085
+ XEUtils.arrayEach(vm.contrasts, (loopItem)=>{
1086
+ repeatCols.push({
1087
+ isCurrentRow:true,
1088
+ linkField:loopItem
1089
+ })
1090
+ })
1091
+ if(repeatCols.length>0 && vm.propTableData.length>1){
1092
+ //设置是否重复
1093
+ XEUtils.arrayEach(vm.searchRows,(loopItem)=>{
1094
+ if(loopItem.sysRepeat===true) return
1095
+ //循环弹出查询返回的数据是否已经存在于表格中
1096
+ loopItem.sysRepeat = XEUtils.some(vm.propTableData,(loopTableItem)=>{
1097
+ //判断表格行数据是当前输入行就返回false,无需重复验证
1098
+ if(loopTableItem['id']===vm.row['id']){
1099
+ return false
1100
+ }
1101
+
1102
+ for(let i=0;i<repeatCols.length;i++){
1103
+ let tempRepeatColInfo = repeatCols[i]
1104
+ //弹出数据列值
1105
+ let tempPopupRowColValue =tempRepeatColInfo.isCurrentRow===true?vm.row[tempRepeatColInfo.linkField]:
1106
+ loopItem[tempRepeatColInfo.field]
1107
+ //表格数据列值
1108
+ let tempTableRowColValue = loopTableItem[tempRepeatColInfo.linkField]
1109
+ if(tempPopupRowColValue!==tempTableRowColValue){
1110
+ //只有有一个不一致,就返回false
1111
+ return false
1112
+ }
1113
+ }
1114
+ return true
1115
+ })
1116
+ })
1117
+ }
1118
+ // if (repeatRowInfo.field) {
1119
+ // //设置重复值
1120
+ // XEUtils.arrayEach(vm.searchRows, (item) => {
1121
+ // if (
1122
+ // XEUtils.arrayIndexOf(
1123
+ // repeatRowInfo.values,
1124
+ // item[repeatRowInfo.field]
1125
+ // ) > -1
1126
+ // ) {
1127
+ // item['sysRepeat'] = true
1128
+ // }
1129
+ // })
1130
+ // }
1131
+ // 若当前表格内只有一行,则不进行判断
1132
+ // if (vm.propTableData.length == 1) {
1133
+ // return
1134
+ // }
1135
+ // 设置字段sysRepeat后,所定字段的值全部相同则不可选择
1136
+ // let fieldNames = vm.columns
1137
+ // .filter((x) => x.sysRepeat)
1138
+ // .map((y) => {
1139
+ // return {
1140
+ // field: y.field,
1141
+ // linkField: y.linkField,
1142
+ // }
1143
+ // })
1144
+ // if (fieldNames.length) {
1145
+ // vm.searchRows.forEach((info) => {
1146
+ // // 当一次创建多行时,过滤需特定字段不可为空的
1147
+ // // 获取数组对象,根据选定字段,过滤选定字段都为空的
1148
+ // let tempArr = vm.propTableData.filter((currentInfo) => {
1149
+ // let tempD = []
1150
+ // fieldNames.forEach((z) => {
1151
+ // // 字段的值若为null、undefined,记录过滤掉
1152
+ // if (!currentInfo[z.linkField]) {
1153
+ // tempD.push(true)
1154
+ // }
1155
+ // })
1156
+ // return tempD.length !== fieldNames.length
1157
+ // })
1158
+ // let arr = []
1159
+ // // 分为有参查询和无参查询
1160
+ // if (tempExp.expressions.length && fieldNames.length == 1) {
1161
+ // for (let j = 0; j < fieldNames.length; j++) {
1162
+ // let mapArr = tempArr.map(
1163
+ // (item) => item[fieldNames[j].linkField]
1164
+ // )
1165
+ // let setArr = new Set(mapArr)
1166
+ // if (setArr.size < mapArr.length) {
1167
+ // arr.push(true)
1168
+ // }
1169
+ // }
1170
+ // if (fieldNames.length === arr.length) {
1171
+ // info.sysRepeat = true
1172
+ // }
1173
+ // } else {
1174
+ // tempArr.forEach((item) => {
1175
+ // // 接口字段可能和表字段field不一致,linkField一致
1176
+ // for (let j = 0; j < fieldNames.length; j++) {
1177
+ // if (
1178
+ // info[fieldNames[j].field] == item[fieldNames[j].linkField]
1179
+ // ) {
1180
+ // arr.push(true)
1181
+ // }
1182
+ // }
1183
+ // if (fieldNames.length === arr.length) {
1184
+ // info.sysRepeat = true
1185
+ // }
1186
+ // })
1187
+ // }
1188
+ // if (info.sysRepeat && this.contrasts.length) {
1189
+ // let flag = 0
1190
+ // XEUtils.arrayEach(this.propTableData, (item) => {
1191
+ // if (item[this.field] === info[this.field]) {
1192
+ // XEUtils.arrayEach(this.contrasts, (loop) => {
1193
+ // if (
1194
+ // item[loop] === this.row[loop] &&
1195
+ // item.id !== this.row.id
1196
+ // ) {
1197
+ // flag++
1198
+ // }
1199
+ // })
1200
+ // }
1201
+ // })
1202
+ // if (flag === this.contrasts.length) {
1203
+ // info.sysRepeat = true
1204
+ // }
1205
+ // }
1206
+ // })
1207
+ // }
1208
+ })
1209
+ .catch((error) => {
1210
+ console.error(error)
1211
+ })
1212
+ .finally(() => {
1213
+ vm.gridLoading = false
1214
+ })
1215
+ },
1216
+ getPostApi(postData) {
1217
+ let tempApi = this.api
1218
+ if(this.newApiObj.newApi){
1219
+ tempApi=this.newApiObj.newApi
1220
+ }
1221
+ if (this.api.indexOf('?') > 0) {
1222
+ tempApi = this.api.substring(0, this.api.indexOf('?'))
1223
+ let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
1224
+ tempExtenParams = replaceParam(tempExtenParams, this.formRow)
1225
+ let tempSplitParams = tempExtenParams.split('&')
1226
+ for (let i = 0; i < tempSplitParams.length; i++) {
1227
+ let tempSplitValue = tempSplitParams[i].split('=')
1228
+ this.$set(postData.extendParams, tempSplitValue[0], tempSplitValue[1])
1229
+ }
1230
+ }
1231
+ return tempApi
1232
+ },
1233
+ sortChange({ column, property, order, sortBy, sortList, $event }) {
1234
+ let currentSort = sortList.map((x) => {
1235
+ return [x.field, x.order]
1236
+ })
1237
+ this.sorts = currentSort
1238
+ this.searchData()
1239
+ },
1240
+
1241
+ // 下拉容器筛选条件被触发
1242
+ filterVisible({ column }) {
1243
+ XEUtils.remove(column.filters, (item) => {
1244
+ return item.data === ''
1245
+ })
1246
+ if (column.filters.length === 0) {
1247
+ column.filters.push({
1248
+ data: '',
1249
+ })
1250
+ }
1251
+ },
1252
+ filterConfirm(column) {
1253
+ let vm = this
1254
+ this.filterExpression = {
1255
+ operator: 'and',
1256
+ expressions: [],
1257
+ }
1258
+ let col = this.columns.find((x) => x.field === column.field)
1259
+ switch (col.controlType) {
1260
+ case 'select':
1261
+ column.filters[0].checked = column.filters[0].data.length > 0
1262
+ break
1263
+ default:
1264
+ column.filters[0].checked = column.filters[0].data !== ''
1265
+ break
1266
+ }
1267
+ //通知外部筛选改变事件
1268
+ let columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1269
+ XEUtils.each(columns, (item) => {
1270
+ let filterExpression = {
1271
+ operator: 'or',
1272
+ expressions: [],
1273
+ }
1274
+ if (!col.controlType) {
1275
+ col.controlType = 'text'
1276
+ }
1277
+ switch (col.controlType) {
1278
+ case 'select':
1279
+ if (item.filters && item.filters[0].checked) {
1280
+ XEUtils.each(item.filters[0].data, (loopItem) => {
1281
+ filterExpression.expressions.push({
1282
+ field: item.field,
1283
+ operator: 'EQ',
1284
+ value: loopItem,
1285
+ })
1286
+ })
1287
+ if (filterExpression.expressions.length > 0) {
1288
+ vm.filterExpression.expressions.push(filterExpression)
1289
+ }
1290
+ }
1291
+ break
1292
+ default:
1293
+ if (item.filters && item.filters[0].checked) {
1294
+ XEUtils.each(item.filters, (loopItem) => {
1295
+ if (loopItem.data) {
1296
+ filterExpression.expressions.push({
1297
+ field: item.field,
1298
+ operator: 'CO',
1299
+ value: loopItem.data,
1300
+ })
1301
+ }
1302
+ })
1303
+ if (filterExpression.expressions.length > 0) {
1304
+ vm.filterExpression.expressions.push(filterExpression)
1305
+ }
1306
+ }
1307
+ break
1308
+ }
1309
+ })
1310
+ this.gridPagerConfig.currentPage = 1
1311
+ this.searchData()
1312
+ this.$refs.pupupGridView.closeFilter()
1313
+ },
1314
+ // 添加筛选条件
1315
+ filterAddExp(column) {
1316
+ column['filters'].push({
1317
+ data: '',
1318
+ })
1319
+ },
1320
+
1321
+ // 清除筛选条件
1322
+ clearColumnFilter() {
1323
+ if(!this.$refs.pupupGridView){
1324
+ return
1325
+ }
1326
+ let columns = []
1327
+ let vm = this
1328
+ try {
1329
+ columns = this.$refs.pupupGridView.getTableColumn().collectColumn
1330
+ } catch (err) {
1331
+ console.debug(err)
1332
+ }
1333
+ XEUtils.each(columns, (item) => {
1334
+ let col = vm.columns.find((x) => x.field === item.field)
1335
+ if (!col) {
1336
+ return
1337
+ }
1338
+ if (!col.controlType) {
1339
+ col.controlType = 'text'
1340
+ }
1341
+ switch (col.controlType) {
1342
+ case 'select':
1343
+ if (item.filters && item.filters[0].checked) {
1344
+ item.filters = [
1345
+ {
1346
+ data: [],
1347
+ },
1348
+ ]
1349
+ }
1350
+ break
1351
+ default:
1352
+ if (item.filters && item.filters[0].checked) {
1353
+ item.filters = [
1354
+ {
1355
+ data: '',
1356
+ },
1357
+ ]
1358
+ }
1359
+ break
1360
+ }
1361
+ })
1362
+ this.filterExpression = {
1363
+ operator: 'and',
1364
+ expressions: [],
1365
+ }
1366
+ },
1367
+ },
1368
+ }
1369
+ </script>
1370
+
1371
+ <style lang="scss" scoped>
1372
+ .pulldown-grid {
1373
+ min-width: 600px;
1374
+ width: auto;
1375
+ height: 350px;
1376
+ background-color: #fff;
1377
+ box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
1378
+ }
1379
+
1380
+ .d-grid-control {
1381
+ width: 100% !important;
1382
+ min-width: unset !important;
1383
+ // height: 30px;
1384
+ }
1385
+ .interceptor-class {
1386
+ padding: 10px;
1387
+ ::v-deep .ant-btn {
1388
+ margin: 10px 10px 0;
1389
+ }
1390
+ }
1391
+ </style>
1392
+
1393
+ <style lang="less">
1394
+ @import '../../styles/default.less';
1395
+ </style>