doway-coms 2.2.18 → 2.2.21

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