doway-coms 2.6.3 → 2.6.4

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