doway-coms 2.2.26 → 2.2.30

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