doway-coms 2.11.96 → 2.11.97

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