doway-coms 1.6.19 → 1.6.20

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