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