doway-coms 2.11.76 → 2.11.78

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