doway-coms 2.10.79 → 2.10.81

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