doway-coms 2.4.2 → 2.4.3

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