doway-coms 1.4.98 → 1.4.99

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 (74) 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 +664 -664
  16. package/packages/BaseGantt/index.js +9 -9
  17. package/packages/BaseGantt/src/index.vue +604 -604
  18. package/packages/BaseGrid/index.js +9 -9
  19. package/packages/BaseGrid/src/index.vue +2684 -2684
  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 +561 -561
  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 +859 -859
  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 +153 -153
  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 +583 -583
  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 +250 -246
  65. package/vue.config.js +59 -59
  66. package/dist/css/chunk-vendors.7f83d8f9.css +0 -8
  67. package/dist/css/index.7946d50b.css +0 -1
  68. package/dist/favicon.ico +0 -0
  69. package/dist/js/chunk-vendors.28fda91d.js +0 -340
  70. package/dist/js/index.49bc6add.js +0 -2
  71. package/lib/doway-coms.common.js +0 -120397
  72. package/lib/doway-coms.css +0 -1
  73. package/lib/doway-coms.umd.js +0 -120407
  74. package/lib/doway-coms.umd.min.js +0 -328
@@ -1,860 +1,860 @@
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
- }}
10
- <span v-if="rules && rules['required']" class="d-control-label-required"
11
- >*</span
12
- >
13
- <Tooltip :title="tooltip" v-if="tooltip" style="margin: 0 2px">
14
- <img src="../../styles/icon/help.png" alt="" style="width: 14px">
15
- </Tooltip>
16
- </div>
17
- <div
18
- :class="{
19
- 'd-control': showLabel === true,
20
- 'd-grid-control': showLabel === false
21
- }"
22
- >
23
- <VxePulldown
24
- style="width:100%"
25
- @hide-panel="pullDownHideEvent"
26
- ref="pulldownRef"
27
- v-if="edit === true"
28
- transfer
29
- >
30
- <template #default>
31
- <ValidationProvider :name="label" v-slot="v" :rules="rules">
32
- <a-input
33
- :size="'small'"
34
- allow-clear
35
- @change="inputChangeEvent"
36
- class="inner-cell-control"
37
- v-model="currentValue"
38
- @click="inputClickEvent"
39
- @focus="inputFocusEvent"
40
- @blur="inputBlurEvent"
41
- @keydown="inputKeydownEvent"
42
- @keyup="inputKeyupEvent"
43
- :class="{ 'd-error-input': v.errors.length > 0 }"
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
- :columns="internalColumns"
67
- >
68
- <!-- :pager-config="gridPagerConfig" -->
69
- <!-- @page-change="pageChangeEvent" -->
70
- <template #matCode_header="{column}">
71
- <div class="first-col">
72
- <div class="first-col-top">
73
- {{ column.title }}
74
- </div>
75
- <div class="first-col-bottom">
76
- <input style="width:100%" />
77
- </div>
78
- </div>
79
- </template>
80
- <template #pager>
81
- <a-row>
82
- <a-col :span="8">
83
- <a-button
84
- v-if="isMultiSelect === true"
85
- type="primary"
86
- size="small"
87
- style="margin: 5px"
88
- @click="multiSelectConfirm"
89
- >
90
- 确认选择
91
- </a-button>
92
- <a-button
93
- v-if="popupAddName"
94
- type="primary"
95
- size="small"
96
- style="margin: 5px"
97
- @click="pagerBtnClick(btn)"
98
- >
99
- 新增
100
- </a-button>
101
-
102
- <template v-if="optBtns.length > 0">
103
- <a-button
104
- v-for="btn in optBtns"
105
- :key="btn.field"
106
- type="primary"
107
- size="small"
108
- style="margin: 5px"
109
- @click="pagerBtnClick(btn)"
110
- >
111
- {{ btn.name }}
112
- </a-button>
113
- </template>
114
- </a-col>
115
- <a-col :span="16">
116
- <vxe-pager
117
- align="right"
118
- size="mini"
119
- :current-page.sync="gridPagerConfig.currentPage"
120
- :page-size.sync="gridPagerConfig.pageSize"
121
- :total="gridPagerConfig.total"
122
- @page-change="pageChangeEvent"
123
- >
124
- </vxe-pager>
125
- </a-col>
126
- </a-row>
127
- </template>
128
- </vxe-grid>
129
- </div>
130
- </template>
131
- </VxePulldown>
132
- <span v-if="edit === false">
133
- <a v-if="route" @click="routeLinkClick">{{ currentValue }}</a>
134
- <span v-else> {{ currentValue }}</span>
135
- </span>
136
- </div>
137
-
138
- <keep-alive>
139
- <div
140
- :is="popupAddName"
141
- ref="pupupAddView"
142
- @popupSaveAfter="popupSaveAfter"
143
- ></div>
144
- </keep-alive>
145
- </div>
146
- </template>
147
-
148
- <script>
149
- import XEUtils from 'xe-utils'
150
- import { sysRowState, sysFormState, controlType } from '../../utils/enum'
151
- import { replaceParamString, replaceParam } from '../../utils/common'
152
- import request from '../../utils/request'
153
- import { Input,Button,Row,Col } from 'ant-design-vue'
154
- import { ValidationProvider } from 'vee-validate'
155
- import {Pulldown} from 'vxe-table'
156
- import { Tooltip } from 'ant-design-vue'
157
- export default {
158
- name: 'BasePulldown',
159
- components:{
160
- 'a-input':Input,
161
- 'a-button':Button,
162
- 'a-row':Row,
163
- 'a-col':Col,
164
- 'VxePulldown':Pulldown,
165
- ValidationProvider,
166
- Tooltip,
167
-
168
- },
169
- data() {
170
- return {
171
- fetchFields: '',
172
- internalColumns: [],
173
- isInputChanged: false,
174
- inputTimeout: null,
175
- searchRows: [],
176
- filterCols: [],
177
- gridLoading: false,
178
- gridPagerConfig: {
179
- total: 0,
180
- currentPage: 1,
181
- pageSize: 10
182
- }
183
- }
184
- },
185
- props: {
186
- labelWidth: {
187
- type: Number,
188
- default: function() {
189
- return 0
190
- }
191
- },
192
- isMultiSelect: {
193
- type: Boolean,
194
- default: function() {
195
- return false
196
- }
197
- },
198
- popupAddName: {
199
- type: String,
200
- default: function() {
201
- return null
202
- }
203
- },
204
- popupAddPath: {
205
- type: String,
206
- default: function() {
207
- return null
208
- }
209
- },
210
- rules: {
211
- type: Object,
212
- default: function() {
213
- return null
214
- }
215
- },
216
- showLabel: {
217
- type: Boolean,
218
- default: function() {
219
- return true
220
- }
221
- },
222
- label: {
223
- type: String,
224
- default: function() {
225
- return ''
226
- }
227
- },
228
- defaultExpression: {
229
- type: String,
230
- default: function() {
231
- return ''
232
- }
233
- },
234
- formRow: {
235
- type: Object,
236
- default: function() {
237
- return {}
238
- }
239
- },
240
- row: {
241
- type: Object,
242
- default: function() {
243
- return {}
244
- }
245
- },
246
- edit: {
247
- type: Boolean,
248
- default: function() {
249
- return false
250
- }
251
- },
252
- route: Object,
253
- placeholder: {
254
- // 提示信息
255
- type: String
256
- },
257
- api: {
258
- // api接口
259
- type: String
260
- },
261
- field: {
262
- type: String
263
- },
264
- pageSize: {
265
- // 分页数量,默认不分页
266
- type: Number,
267
- default: () => {
268
- return 0
269
- }
270
- },
271
- columns: {
272
- // 列集合
273
- type: Array,
274
- default: () => {
275
- return []
276
- }
277
- },
278
- isOld: {
279
- // 列集合
280
- type: Boolean,
281
- default: () => {
282
- return false
283
- }
284
- },
285
- exps: {
286
- // 条件
287
- type: Array,
288
- default: () => {
289
- return []
290
- }
291
- },
292
- value: {
293
- type: String,
294
- default: function() {
295
- return ''
296
- }
297
- },
298
- optBtns: {
299
- // 操作按钮
300
- type: Array,
301
- default: () => {
302
- return []
303
- }
304
- },
305
- gridTable: {
306
- // 操作按钮
307
- type: Object,
308
- default: () => {
309
- return null
310
- }
311
- },
312
- immediate: {
313
- type: Boolean,
314
- default: true
315
- },
316
- isLocalData: {
317
- type: Boolean,
318
- default: false
319
- },
320
- tooltip: {
321
- type: String,
322
- default: function() {
323
- return ''
324
- }
325
- },
326
- propTableData: {
327
- type: Array,
328
- default: function() {
329
- return []
330
- }
331
- },
332
- },
333
- watch: {},
334
- computed: {
335
- currentValue: {
336
- // 动态计算currentValue的值
337
- get: function() {
338
- return this.value // 将props中的value赋值给currentValue
339
- },
340
- set: function(val) {
341
- this.$emit('input', val) // 通过$emit触发父组件
342
- }
343
- }
344
- },
345
- created() {
346
- // if (this.popupAddName && !this.$options.components[this.popupAddName]) {
347
- // // const tempRequire = require('@/views' + this.popupAddPath + '.vue').default
348
- // // this.$options.components[this.popupAddName] = tempRequire
349
- // this.$options.components[this.popupAddName] = () =>
350
- // import('@/views' + this.popupAddPath + '.vue')
351
- // }
352
- this.gridPagerConfig.pageSize = this.pageSize
353
-
354
- this.internalColumns.push({
355
- type: 'seq',
356
- fixed: 'left',
357
- width: 50
358
- })
359
-
360
- if (this.isMultiSelect === true) {
361
- this.internalColumns.push({
362
- type: 'checkbox',
363
- fixed: 'left',
364
- width: 40
365
- })
366
- }
367
-
368
- for (let i = 0; i < this.columns.length; i++) {
369
- this.fetchFields = this.fetchFields + this.columns[i].field + ','
370
- this.columns[i]['params'] = {
371
- dataSource: []
372
- }
373
- if (this.columns[i].dataSource) {
374
- this.columns[i]['params'].dataSource = this.columns[i].dataSource
375
- }
376
- if (!this.columns[i].width) {
377
- this.columns[i]['width'] = 100
378
- }
379
- if (this.columns[i].isCheckbox === true) {
380
- this.columns[i]['type'] = 'checkbox'
381
- // colInfo['field'] = 'matCode'
382
- }
383
- // if(this.columns[i].formatter){
384
- // this.columns[i].formatter=
385
-
386
- // }
387
- this.internalColumns.push(this.columns[i])
388
- if (this.columns[i].filter === true) {
389
- this.filterCols.push(this.columns[i])
390
- }
391
- }
392
- },
393
- methods: {
394
- gridRowStyle(scope) {
395
- if (scope.row.sysRepeat === true) {
396
- return 'row--pending'
397
- }
398
- // if(scope.row.)
399
- },
400
- clearInputValue() {
401
- if (this.isInputChanged === true) {
402
- this.setLinkValue(null, this.row)
403
- this.$emit('selectChanged', null)
404
- }
405
- },
406
- routeLinkClick() {
407
- //首先需要判断是否有权限
408
- // let treeModule = XEUtils.findTree(
409
- // this.$store.getters.addRouters,
410
- // item => item.name === this.route.name
411
- // )
412
- // if (!treeModule) {
413
- // this.$antwarning('没有权限')
414
- // return
415
- // }
416
- this.$router.pushRoute({
417
- name: this.route.name,
418
- query: { id: this.row[this.route.field] }
419
- })
420
- },
421
- /**
422
- * 输入框改变事件
423
- */
424
- inputChangeEvent(event) {
425
- this.isInputChanged = true
426
- if (event.type === 'click' && event.pointerType === 'mouse') {
427
- //点击了清空按钮
428
- this.$nextTick(() => {
429
- this.clearInputValue()
430
- this.inputClickEvent(null)
431
- })
432
- }
433
- },
434
- inputBlurEvent(event) {},
435
- /**
436
- * 输入框获取焦点事件
437
- */
438
- inputFocusEvent(event) {
439
- event.currentTarget.select()
440
- // this.$refs.pulldownRef.showPanel()
441
- // this.searchData()
442
- },
443
- /**
444
- * Tab键隐藏面板
445
- */
446
- inputKeydownEvent(event) {
447
- if (event.keyCode === 9) {
448
- //tab事件
449
- this.$refs.pulldownRef.hidePanel()
450
- this.clearInputValue()
451
- }
452
- },
453
- inputClickEvent(event) {
454
- if (this.$refs.pulldownRef.isPanelVisible() === false) {
455
- this.$refs.pulldownRef.showPanel()
456
- this.searchData()
457
- } else {
458
- this.$refs.pulldownRef.hidePanel()
459
- }
460
- },
461
- /**
462
- * 输入库输入事件
463
- */
464
- inputKeyupEvent(event) {
465
- //好像ok
466
- if (!this.immediate && event.keyCode !== 13) {
467
- console.debug('davistest')
468
- } else {
469
- if (this.inputTimeout) {
470
- clearTimeout(this.inputTimeout)
471
- }
472
- let vm = this
473
- this.inputTimeout = setTimeout(() => {
474
- //判断面板是否打开
475
- if (vm.$refs.pulldownRef.isPanelVisible() === false) {
476
- vm.$refs.pulldownRef.showPanel()
477
- }
478
- vm.searchData()
479
- }, 500)
480
- }
481
- },
482
- /**
483
- * 网格列选中事件
484
- */
485
- gridCellClick({ row, column }) {
486
- if (row.sysRepeat === true) {
487
- return
488
- }
489
- if (column.type === 'seq' || column.type === 'checkbox') {
490
- return
491
- }
492
- this.isInputChanged = false
493
- this.setLinkValue(row, this.row)
494
- this.$emit('selectChanged', row)
495
- this.$refs.pulldownRef.hidePanel()
496
- },
497
- setLinkValue(pulldownRow, oriRow) {
498
- for (let i = 0; i < this.internalColumns.length; i++) {
499
- if (this.internalColumns[i].linkField) {
500
- let tempLinkFields = this.internalColumns[i].linkField.split('.')
501
- let tempRow = oriRow
502
- // for(let j=0;j<tempLinkFields.length;j++){
503
- // let tempField = tempLinkFields[j]
504
- // //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
505
- // if (!(tempField in tempRow)) {
506
- // this.$antwarning(
507
- // '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
508
- // )
509
- // break
510
- // }
511
- // if(j===tempLinkFields.length-1){
512
- // if (pulldownRow === null) {
513
- // if (this.internalColumns[i].nullClear === false) {
514
- // //是否空值清除数据,用于可选可输入的控件
515
- // continue
516
- // }
517
- // this.$set(tempRow, tempField, null)
518
- // } else {
519
- // this.$set(
520
- // tempRow,
521
- // tempField,
522
- // this.getLinkValue(tempField, pulldownRow)
523
- // )
524
- // }
525
- // }else{
526
- // tempRow = tempRow[tempField]
527
- // }
528
- // }
529
-
530
- //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
531
- if (!(this.internalColumns[i].linkField in oriRow)) {
532
- this.$antwarning(
533
- '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
534
- )
535
- continue
536
- }
537
- if (pulldownRow === null) {
538
- if (this.internalColumns[i].nullClear === false) {
539
- //是否空值清楚数据,用于可选可输入的控件
540
- continue
541
- }
542
- this.$set(oriRow, this.internalColumns[i].linkField, null)
543
- } else {
544
- this.$set(
545
- oriRow,
546
- this.internalColumns[i].linkField,
547
- this.getLinkValue(this.internalColumns[i].field, pulldownRow)
548
- )
549
- }
550
- }
551
- }
552
- },
553
- getLinkValue(field, row) {
554
- let linkField = field.split('.')
555
- if (linkField.length > 1) {
556
- let fieldValue = row
557
- for (let i = 0; i < linkField.length; i++) {
558
- if (
559
- fieldValue[linkField[i]] === undefined ||
560
- fieldValue[linkField[i]] === null
561
- ) {
562
- return null
563
- }
564
- fieldValue = fieldValue[linkField[i]]
565
- }
566
- return fieldValue
567
- }
568
- return row[field]
569
- },
570
- /**
571
- * 左下角按钮点击事件
572
- */
573
- pagerBtnClick(btn) {
574
- this.$refs.pupupAddView.show()
575
- // this.$emit('pulldownBtnClick', btn)
576
- this.$refs.pulldownRef.hidePanel()
577
- },
578
- /**
579
- * 确认多选
580
- */
581
- multiSelectConfirm() {
582
- this.isInputChanged = false
583
- this.$emit(
584
- 'confirmMultiSelect',
585
- this,
586
- this.$refs.pupupGridView.getCheckboxRecords(true)
587
- )
588
- this.$refs.pulldownRef.hidePanel()
589
- },
590
- popupSaveAfter(pupupAddRowInfo) {
591
- let postData = {
592
- fields: null,
593
- begin: 1,
594
- size: 1,
595
- expression: {},
596
- sort: ''
597
- }
598
- let tempKeyExp = XEUtils.find(
599
- this.internalColumns,
600
- item => item.isKey === true
601
- )
602
- postData.expression = {
603
- operator: 'and',
604
- expressions: [
605
- {
606
- operator: 'and',
607
- expressions: [
608
- {
609
- field: tempKeyExp.field,
610
- operator: 'EQ',
611
- value: pupupAddRowInfo['id']
612
- }
613
- ]
614
- }
615
- ]
616
- }
617
- let vm = this
618
- let tempApi = this.getPostApi(postData)
619
- request({
620
- url: tempApi,
621
- method: 'post',
622
- data: postData
623
- })
624
- .then(responseData => {
625
- if (responseData.content.length > 0) {
626
- vm.setLinkValue(responseData.content[0], vm.row)
627
- vm.$emit('selectChanged', responseData.content[0])
628
- }
629
- })
630
- .catch(error => {
631
- console.error(error)
632
- })
633
- .finally(() => {})
634
- },
635
- /**
636
- * 分页改变事件
637
- */
638
- pageChangeEvent({ currentPage, pageSize }) {
639
- this.gridPagerConfig.currentPage = currentPage
640
- this.gridPagerConfig.pageSize = pageSize
641
- this.searchData()
642
- },
643
- /**
644
- * 面板隐藏事件
645
- */
646
- pullDownHideEvent({ $event }) {
647
- this.clearInputValue()
648
- },
649
- /**
650
- * 查询数据
651
- */
652
- searchData() {
653
- if (this.isLocalData === true) {
654
- let tempSearch = {
655
- value: this.currentValue,
656
- dataSource: []
657
- }
658
- this.$emit('preSearch', tempSearch)
659
- this.searchRows = tempSearch.dataSource
660
- this.gridPagerConfig.total = tempSearch.dataSource.length
661
- return
662
- }
663
-
664
- let tempExp = {
665
- operator: 'or',
666
- expressions: []
667
- }
668
- if (this.isOld === true) {
669
- tempExp = ''
670
- }
671
- if (this.currentValue) {
672
- for (let i = 0; i < this.filterCols.length; i++) {
673
- if (this.isOld === true) {
674
- tempExp =
675
- tempExp +
676
- this.filterCols[i].field +
677
- '.contains("' +
678
- this.currentValue +
679
- '")'
680
- if (i < this.filterCols.length - 1) {
681
- tempExp = tempExp + ' or '
682
- }
683
- } else {
684
- if (this.filterCols[i].controlType == 'number') {
685
- tempExp.expressions.push({
686
- field: this.filterCols[i].field,
687
- operator: 'EQ',
688
- value: Number(this.currentValue)
689
- })
690
- } else {
691
- tempExp.expressions.push({
692
- field: this.filterCols[i].field,
693
- operator: 'CO',
694
- value: this.currentValue
695
- })
696
- }
697
- }
698
- }
699
- }
700
- if (this.isOld === true && tempExp.length > 0) {
701
- tempExp = '(' + tempExp + ')'
702
- }
703
-
704
- if (this.defaultExpression) {
705
- let tempDefault = replaceParamString(
706
- this.defaultExpression,
707
- this.formRow,
708
- this.$store.getters.moduleSelectItems[this.$route.meta.moduleId]
709
- )
710
-
711
- if (tempExp) {
712
- tempExp = tempExp + ' and (' + tempDefault + ')'
713
- } else {
714
- tempExp = tempDefault
715
- }
716
- }
717
-
718
- let postExpression = {
719
- field: this.field,
720
- expression: tempExp,
721
- extendParams: {}
722
- }
723
- let repeatRowInfo = {
724
- field: '',
725
- values: []
726
- }
727
- //查询之前从外部组件构造其他的条件
728
- this.$emit('preSearch', postExpression, repeatRowInfo)
729
- let postData = {
730
- fields: this.fetchFields,
731
- begin:
732
- (this.gridPagerConfig.currentPage - 1) *
733
- this.gridPagerConfig.pageSize +
734
- 1,
735
- size: this.gridPagerConfig.pageSize,
736
- expression: postExpression.expression,
737
- sort: '',
738
- extendParams: postExpression.extendParams
739
- }
740
-
741
- let tempApi = this.getPostApi(postData)
742
-
743
- // let tempApi = this.api
744
- // if (this.api.indexOf('?') > 0) {
745
- // tempApi = this.api.substring(0, this.api.indexOf('?'))
746
- // let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
747
- // tempExtenParams = replaceParam(tempExtenParams, this.formRow)
748
- // let tempSplitParams = tempExtenParams.split('&')
749
- // for (let i = 0; i < tempSplitParams.length; i++) {
750
- // let tempSplitValue = tempSplitParams[i].split('=')
751
- // this.$set(
752
- // postData.extendParams,
753
- // tempSplitValue[0],
754
- // tempSplitValue[1]
755
- // )
756
- // }
757
- // }
758
- let vm = this
759
- vm.gridLoading = true
760
- request({
761
- url: tempApi,
762
- method: 'post',
763
- data: postData
764
- })
765
- .then(responseData => {
766
- if (vm.isOld === true) {
767
- vm.searchRows = responseData.data
768
- vm.gridPagerConfig.total = responseData.extData.totalRows
769
- } else {
770
- vm.searchRows = responseData.content
771
- vm.gridPagerConfig.total = responseData.otherContent.totalRows
772
- }
773
- if (repeatRowInfo.field) {
774
- //设置重复值
775
- XEUtils.arrayEach(vm.searchRows, item => {
776
- if (
777
- XEUtils.arrayIndexOf(
778
- repeatRowInfo.values,
779
- item[repeatRowInfo.field]
780
- ) > -1
781
- ) {
782
- item['sysRepeat'] = true
783
- } else {
784
- item['sysRepeat'] = false
785
- }
786
- })
787
- }
788
- // 设置字段sysRepeat后,所定字段的值全部相同则不可选择
789
- let fieldNames = vm.columns.filter(x => x.sysRepeat)
790
- .map(y=> {
791
- return {
792
- field: y.field,
793
- linkField: y.linkField,
794
- }
795
- })
796
- if (fieldNames.length) {
797
- vm.searchRows.forEach(info => {
798
- vm.propTableData.forEach(item=>{
799
- // 接口字段可能和表字段field不一致,linkField一致
800
- let arr= []
801
- for(let j=0;j<fieldNames.length;j++){
802
- if(info[fieldNames[j].field] == item[fieldNames[j].linkField]){
803
- arr.push(true)
804
- }
805
- }
806
- if(fieldNames.length === arr.length){
807
- info.sysRepeat = true
808
- }
809
- })
810
- })
811
- }
812
- })
813
- .catch(error => {
814
- console.error(error)
815
- })
816
- .finally(() => {
817
- vm.gridLoading = false
818
- })
819
- },
820
- getPostApi(postData) {
821
- let tempApi = this.api
822
- if (this.api.indexOf('?') > 0) {
823
- tempApi = this.api.substring(0, this.api.indexOf('?'))
824
- let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
825
- tempExtenParams = replaceParam(tempExtenParams, this.formRow)
826
- let tempSplitParams = tempExtenParams.split('&')
827
- for (let i = 0; i < tempSplitParams.length; i++) {
828
- let tempSplitValue = tempSplitParams[i].split('=')
829
- this.$set(
830
- postData.extendParams,
831
- tempSplitValue[0],
832
- tempSplitValue[1]
833
- )
834
- }
835
- }
836
- return tempApi
837
- }
838
- }
839
- }
840
- </script>
841
-
842
- <style lang="scss" scoped>
843
- .pulldown-grid {
844
- min-width: 600px;
845
- width: auto;
846
- height: 350px;
847
- background-color: #fff;
848
- box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
849
- }
850
-
851
- .d-grid-control {
852
- width: 100%;
853
- height: 30px;
854
- }
855
- </style>
856
-
857
-
858
- <style lang="less">
859
- @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
+ }}
10
+ <span v-if="rules && rules['required']" class="d-control-label-required"
11
+ >*</span
12
+ >
13
+ <Tooltip :title="tooltip" v-if="tooltip" style="margin: 0 2px">
14
+ <img src="../../styles/icon/help.png" alt="" style="width: 14px">
15
+ </Tooltip>
16
+ </div>
17
+ <div
18
+ :class="{
19
+ 'd-control': showLabel === true,
20
+ 'd-grid-control': showLabel === false
21
+ }"
22
+ >
23
+ <VxePulldown
24
+ style="width:100%"
25
+ @hide-panel="pullDownHideEvent"
26
+ ref="pulldownRef"
27
+ v-if="edit === true"
28
+ transfer
29
+ >
30
+ <template #default>
31
+ <ValidationProvider :name="label" v-slot="v" :rules="rules">
32
+ <a-input
33
+ :size="'small'"
34
+ allow-clear
35
+ @change="inputChangeEvent"
36
+ class="inner-cell-control"
37
+ v-model="currentValue"
38
+ @click="inputClickEvent"
39
+ @focus="inputFocusEvent"
40
+ @blur="inputBlurEvent"
41
+ @keydown="inputKeydownEvent"
42
+ @keyup="inputKeyupEvent"
43
+ :class="{ 'd-error-input': v.errors.length > 0 }"
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
+ :columns="internalColumns"
67
+ >
68
+ <!-- :pager-config="gridPagerConfig" -->
69
+ <!-- @page-change="pageChangeEvent" -->
70
+ <template #matCode_header="{column}">
71
+ <div class="first-col">
72
+ <div class="first-col-top">
73
+ {{ column.title }}
74
+ </div>
75
+ <div class="first-col-bottom">
76
+ <input style="width:100%" />
77
+ </div>
78
+ </div>
79
+ </template>
80
+ <template #pager>
81
+ <a-row>
82
+ <a-col :span="8">
83
+ <a-button
84
+ v-if="isMultiSelect === true"
85
+ type="primary"
86
+ size="small"
87
+ style="margin: 5px"
88
+ @click="multiSelectConfirm"
89
+ >
90
+ 确认选择
91
+ </a-button>
92
+ <a-button
93
+ v-if="popupAddName"
94
+ type="primary"
95
+ size="small"
96
+ style="margin: 5px"
97
+ @click="pagerBtnClick(btn)"
98
+ >
99
+ 新增
100
+ </a-button>
101
+
102
+ <template v-if="optBtns.length > 0">
103
+ <a-button
104
+ v-for="btn in optBtns"
105
+ :key="btn.field"
106
+ type="primary"
107
+ size="small"
108
+ style="margin: 5px"
109
+ @click="pagerBtnClick(btn)"
110
+ >
111
+ {{ btn.name }}
112
+ </a-button>
113
+ </template>
114
+ </a-col>
115
+ <a-col :span="16">
116
+ <vxe-pager
117
+ align="right"
118
+ size="mini"
119
+ :current-page.sync="gridPagerConfig.currentPage"
120
+ :page-size.sync="gridPagerConfig.pageSize"
121
+ :total="gridPagerConfig.total"
122
+ @page-change="pageChangeEvent"
123
+ >
124
+ </vxe-pager>
125
+ </a-col>
126
+ </a-row>
127
+ </template>
128
+ </vxe-grid>
129
+ </div>
130
+ </template>
131
+ </VxePulldown>
132
+ <span v-if="edit === false">
133
+ <a v-if="route" @click="routeLinkClick">{{ currentValue }}</a>
134
+ <span v-else> {{ currentValue }}</span>
135
+ </span>
136
+ </div>
137
+
138
+ <keep-alive>
139
+ <div
140
+ :is="popupAddName"
141
+ ref="pupupAddView"
142
+ @popupSaveAfter="popupSaveAfter"
143
+ ></div>
144
+ </keep-alive>
145
+ </div>
146
+ </template>
147
+
148
+ <script>
149
+ import XEUtils from 'xe-utils'
150
+ import { sysRowState, sysFormState, controlType } from '../../utils/enum'
151
+ import { replaceParamString, replaceParam } from '../../utils/common'
152
+ import request from '../../utils/request'
153
+ import { Input,Button,Row,Col } from 'ant-design-vue'
154
+ import { ValidationProvider } from 'vee-validate'
155
+ import {Pulldown} from 'vxe-table'
156
+ import { Tooltip } from 'ant-design-vue'
157
+ export default {
158
+ name: 'BasePulldown',
159
+ components:{
160
+ 'a-input':Input,
161
+ 'a-button':Button,
162
+ 'a-row':Row,
163
+ 'a-col':Col,
164
+ 'VxePulldown':Pulldown,
165
+ ValidationProvider,
166
+ Tooltip,
167
+
168
+ },
169
+ data() {
170
+ return {
171
+ fetchFields: '',
172
+ internalColumns: [],
173
+ isInputChanged: false,
174
+ inputTimeout: null,
175
+ searchRows: [],
176
+ filterCols: [],
177
+ gridLoading: false,
178
+ gridPagerConfig: {
179
+ total: 0,
180
+ currentPage: 1,
181
+ pageSize: 10
182
+ }
183
+ }
184
+ },
185
+ props: {
186
+ labelWidth: {
187
+ type: Number,
188
+ default: function() {
189
+ return 0
190
+ }
191
+ },
192
+ isMultiSelect: {
193
+ type: Boolean,
194
+ default: function() {
195
+ return false
196
+ }
197
+ },
198
+ popupAddName: {
199
+ type: String,
200
+ default: function() {
201
+ return null
202
+ }
203
+ },
204
+ popupAddPath: {
205
+ type: String,
206
+ default: function() {
207
+ return null
208
+ }
209
+ },
210
+ rules: {
211
+ type: Object,
212
+ default: function() {
213
+ return null
214
+ }
215
+ },
216
+ showLabel: {
217
+ type: Boolean,
218
+ default: function() {
219
+ return true
220
+ }
221
+ },
222
+ label: {
223
+ type: String,
224
+ default: function() {
225
+ return ''
226
+ }
227
+ },
228
+ defaultExpression: {
229
+ type: String,
230
+ default: function() {
231
+ return ''
232
+ }
233
+ },
234
+ formRow: {
235
+ type: Object,
236
+ default: function() {
237
+ return {}
238
+ }
239
+ },
240
+ row: {
241
+ type: Object,
242
+ default: function() {
243
+ return {}
244
+ }
245
+ },
246
+ edit: {
247
+ type: Boolean,
248
+ default: function() {
249
+ return false
250
+ }
251
+ },
252
+ route: Object,
253
+ placeholder: {
254
+ // 提示信息
255
+ type: String
256
+ },
257
+ api: {
258
+ // api接口
259
+ type: String
260
+ },
261
+ field: {
262
+ type: String
263
+ },
264
+ pageSize: {
265
+ // 分页数量,默认不分页
266
+ type: Number,
267
+ default: () => {
268
+ return 0
269
+ }
270
+ },
271
+ columns: {
272
+ // 列集合
273
+ type: Array,
274
+ default: () => {
275
+ return []
276
+ }
277
+ },
278
+ isOld: {
279
+ // 列集合
280
+ type: Boolean,
281
+ default: () => {
282
+ return false
283
+ }
284
+ },
285
+ exps: {
286
+ // 条件
287
+ type: Array,
288
+ default: () => {
289
+ return []
290
+ }
291
+ },
292
+ value: {
293
+ type: String,
294
+ default: function() {
295
+ return ''
296
+ }
297
+ },
298
+ optBtns: {
299
+ // 操作按钮
300
+ type: Array,
301
+ default: () => {
302
+ return []
303
+ }
304
+ },
305
+ gridTable: {
306
+ // 操作按钮
307
+ type: Object,
308
+ default: () => {
309
+ return null
310
+ }
311
+ },
312
+ immediate: {
313
+ type: Boolean,
314
+ default: true
315
+ },
316
+ isLocalData: {
317
+ type: Boolean,
318
+ default: false
319
+ },
320
+ tooltip: {
321
+ type: String,
322
+ default: function() {
323
+ return ''
324
+ }
325
+ },
326
+ propTableData: {
327
+ type: Array,
328
+ default: function() {
329
+ return []
330
+ }
331
+ },
332
+ },
333
+ watch: {},
334
+ computed: {
335
+ currentValue: {
336
+ // 动态计算currentValue的值
337
+ get: function() {
338
+ return this.value // 将props中的value赋值给currentValue
339
+ },
340
+ set: function(val) {
341
+ this.$emit('input', val) // 通过$emit触发父组件
342
+ }
343
+ }
344
+ },
345
+ created() {
346
+ // if (this.popupAddName && !this.$options.components[this.popupAddName]) {
347
+ // // const tempRequire = require('@/views' + this.popupAddPath + '.vue').default
348
+ // // this.$options.components[this.popupAddName] = tempRequire
349
+ // this.$options.components[this.popupAddName] = () =>
350
+ // import('@/views' + this.popupAddPath + '.vue')
351
+ // }
352
+ this.gridPagerConfig.pageSize = this.pageSize
353
+
354
+ this.internalColumns.push({
355
+ type: 'seq',
356
+ fixed: 'left',
357
+ width: 50
358
+ })
359
+
360
+ if (this.isMultiSelect === true) {
361
+ this.internalColumns.push({
362
+ type: 'checkbox',
363
+ fixed: 'left',
364
+ width: 40
365
+ })
366
+ }
367
+
368
+ for (let i = 0; i < this.columns.length; i++) {
369
+ this.fetchFields = this.fetchFields + this.columns[i].field + ','
370
+ this.columns[i]['params'] = {
371
+ dataSource: []
372
+ }
373
+ if (this.columns[i].dataSource) {
374
+ this.columns[i]['params'].dataSource = this.columns[i].dataSource
375
+ }
376
+ if (!this.columns[i].width) {
377
+ this.columns[i]['width'] = 100
378
+ }
379
+ if (this.columns[i].isCheckbox === true) {
380
+ this.columns[i]['type'] = 'checkbox'
381
+ // colInfo['field'] = 'matCode'
382
+ }
383
+ // if(this.columns[i].formatter){
384
+ // this.columns[i].formatter=
385
+
386
+ // }
387
+ this.internalColumns.push(this.columns[i])
388
+ if (this.columns[i].filter === true) {
389
+ this.filterCols.push(this.columns[i])
390
+ }
391
+ }
392
+ },
393
+ methods: {
394
+ gridRowStyle(scope) {
395
+ if (scope.row.sysRepeat === true) {
396
+ return 'row--pending'
397
+ }
398
+ // if(scope.row.)
399
+ },
400
+ clearInputValue() {
401
+ if (this.isInputChanged === true) {
402
+ this.setLinkValue(null, this.row)
403
+ this.$emit('selectChanged', null)
404
+ }
405
+ },
406
+ routeLinkClick() {
407
+ //首先需要判断是否有权限
408
+ // let treeModule = XEUtils.findTree(
409
+ // this.$store.getters.addRouters,
410
+ // item => item.name === this.route.name
411
+ // )
412
+ // if (!treeModule) {
413
+ // this.$antwarning('没有权限')
414
+ // return
415
+ // }
416
+ this.$router.pushRoute({
417
+ name: this.route.name,
418
+ query: { id: this.row[this.route.field] }
419
+ })
420
+ },
421
+ /**
422
+ * 输入框改变事件
423
+ */
424
+ inputChangeEvent(event) {
425
+ this.isInputChanged = true
426
+ if (event.type === 'click' && event.pointerType === 'mouse') {
427
+ //点击了清空按钮
428
+ this.$nextTick(() => {
429
+ this.clearInputValue()
430
+ this.inputClickEvent(null)
431
+ })
432
+ }
433
+ },
434
+ inputBlurEvent(event) {},
435
+ /**
436
+ * 输入框获取焦点事件
437
+ */
438
+ inputFocusEvent(event) {
439
+ event.currentTarget.select()
440
+ // this.$refs.pulldownRef.showPanel()
441
+ // this.searchData()
442
+ },
443
+ /**
444
+ * Tab键隐藏面板
445
+ */
446
+ inputKeydownEvent(event) {
447
+ if (event.keyCode === 9) {
448
+ //tab事件
449
+ this.$refs.pulldownRef.hidePanel()
450
+ this.clearInputValue()
451
+ }
452
+ },
453
+ inputClickEvent(event) {
454
+ if (this.$refs.pulldownRef.isPanelVisible() === false) {
455
+ this.$refs.pulldownRef.showPanel()
456
+ this.searchData()
457
+ } else {
458
+ this.$refs.pulldownRef.hidePanel()
459
+ }
460
+ },
461
+ /**
462
+ * 输入库输入事件
463
+ */
464
+ inputKeyupEvent(event) {
465
+ //好像ok
466
+ if (!this.immediate && event.keyCode !== 13) {
467
+ console.debug('davistest')
468
+ } else {
469
+ if (this.inputTimeout) {
470
+ clearTimeout(this.inputTimeout)
471
+ }
472
+ let vm = this
473
+ this.inputTimeout = setTimeout(() => {
474
+ //判断面板是否打开
475
+ if (vm.$refs.pulldownRef.isPanelVisible() === false) {
476
+ vm.$refs.pulldownRef.showPanel()
477
+ }
478
+ vm.searchData()
479
+ }, 500)
480
+ }
481
+ },
482
+ /**
483
+ * 网格列选中事件
484
+ */
485
+ gridCellClick({ row, column }) {
486
+ if (row.sysRepeat === true) {
487
+ return
488
+ }
489
+ if (column.type === 'seq' || column.type === 'checkbox') {
490
+ return
491
+ }
492
+ this.isInputChanged = false
493
+ this.setLinkValue(row, this.row)
494
+ this.$emit('selectChanged', row)
495
+ this.$refs.pulldownRef.hidePanel()
496
+ },
497
+ setLinkValue(pulldownRow, oriRow) {
498
+ for (let i = 0; i < this.internalColumns.length; i++) {
499
+ if (this.internalColumns[i].linkField) {
500
+ let tempLinkFields = this.internalColumns[i].linkField.split('.')
501
+ let tempRow = oriRow
502
+ // for(let j=0;j<tempLinkFields.length;j++){
503
+ // let tempField = tempLinkFields[j]
504
+ // //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
505
+ // if (!(tempField in tempRow)) {
506
+ // this.$antwarning(
507
+ // '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
508
+ // )
509
+ // break
510
+ // }
511
+ // if(j===tempLinkFields.length-1){
512
+ // if (pulldownRow === null) {
513
+ // if (this.internalColumns[i].nullClear === false) {
514
+ // //是否空值清除数据,用于可选可输入的控件
515
+ // continue
516
+ // }
517
+ // this.$set(tempRow, tempField, null)
518
+ // } else {
519
+ // this.$set(
520
+ // tempRow,
521
+ // tempField,
522
+ // this.getLinkValue(tempField, pulldownRow)
523
+ // )
524
+ // }
525
+ // }else{
526
+ // tempRow = tempRow[tempField]
527
+ // }
528
+ // }
529
+
530
+ //如果赋值的属性不存在数据集中,就忽略更新,防止修改后网格单元格值不更细
531
+ if (!(this.internalColumns[i].linkField in oriRow)) {
532
+ this.$antwarning(
533
+ '赋值字段[' + this.internalColumns[i].linkField + ']不存在'
534
+ )
535
+ continue
536
+ }
537
+ if (pulldownRow === null) {
538
+ if (this.internalColumns[i].nullClear === false) {
539
+ //是否空值清楚数据,用于可选可输入的控件
540
+ continue
541
+ }
542
+ this.$set(oriRow, this.internalColumns[i].linkField, null)
543
+ } else {
544
+ this.$set(
545
+ oriRow,
546
+ this.internalColumns[i].linkField,
547
+ this.getLinkValue(this.internalColumns[i].field, pulldownRow)
548
+ )
549
+ }
550
+ }
551
+ }
552
+ },
553
+ getLinkValue(field, row) {
554
+ let linkField = field.split('.')
555
+ if (linkField.length > 1) {
556
+ let fieldValue = row
557
+ for (let i = 0; i < linkField.length; i++) {
558
+ if (
559
+ fieldValue[linkField[i]] === undefined ||
560
+ fieldValue[linkField[i]] === null
561
+ ) {
562
+ return null
563
+ }
564
+ fieldValue = fieldValue[linkField[i]]
565
+ }
566
+ return fieldValue
567
+ }
568
+ return row[field]
569
+ },
570
+ /**
571
+ * 左下角按钮点击事件
572
+ */
573
+ pagerBtnClick(btn) {
574
+ this.$refs.pupupAddView.show()
575
+ // this.$emit('pulldownBtnClick', btn)
576
+ this.$refs.pulldownRef.hidePanel()
577
+ },
578
+ /**
579
+ * 确认多选
580
+ */
581
+ multiSelectConfirm() {
582
+ this.isInputChanged = false
583
+ this.$emit(
584
+ 'confirmMultiSelect',
585
+ this,
586
+ this.$refs.pupupGridView.getCheckboxRecords(true)
587
+ )
588
+ this.$refs.pulldownRef.hidePanel()
589
+ },
590
+ popupSaveAfter(pupupAddRowInfo) {
591
+ let postData = {
592
+ fields: null,
593
+ begin: 1,
594
+ size: 1,
595
+ expression: {},
596
+ sort: ''
597
+ }
598
+ let tempKeyExp = XEUtils.find(
599
+ this.internalColumns,
600
+ item => item.isKey === true
601
+ )
602
+ postData.expression = {
603
+ operator: 'and',
604
+ expressions: [
605
+ {
606
+ operator: 'and',
607
+ expressions: [
608
+ {
609
+ field: tempKeyExp.field,
610
+ operator: 'EQ',
611
+ value: pupupAddRowInfo['id']
612
+ }
613
+ ]
614
+ }
615
+ ]
616
+ }
617
+ let vm = this
618
+ let tempApi = this.getPostApi(postData)
619
+ request({
620
+ url: tempApi,
621
+ method: 'post',
622
+ data: postData
623
+ })
624
+ .then(responseData => {
625
+ if (responseData.content.length > 0) {
626
+ vm.setLinkValue(responseData.content[0], vm.row)
627
+ vm.$emit('selectChanged', responseData.content[0])
628
+ }
629
+ })
630
+ .catch(error => {
631
+ console.error(error)
632
+ })
633
+ .finally(() => {})
634
+ },
635
+ /**
636
+ * 分页改变事件
637
+ */
638
+ pageChangeEvent({ currentPage, pageSize }) {
639
+ this.gridPagerConfig.currentPage = currentPage
640
+ this.gridPagerConfig.pageSize = pageSize
641
+ this.searchData()
642
+ },
643
+ /**
644
+ * 面板隐藏事件
645
+ */
646
+ pullDownHideEvent({ $event }) {
647
+ this.clearInputValue()
648
+ },
649
+ /**
650
+ * 查询数据
651
+ */
652
+ searchData() {
653
+ if (this.isLocalData === true) {
654
+ let tempSearch = {
655
+ value: this.currentValue,
656
+ dataSource: []
657
+ }
658
+ this.$emit('preSearch', tempSearch)
659
+ this.searchRows = tempSearch.dataSource
660
+ this.gridPagerConfig.total = tempSearch.dataSource.length
661
+ return
662
+ }
663
+
664
+ let tempExp = {
665
+ operator: 'or',
666
+ expressions: []
667
+ }
668
+ if (this.isOld === true) {
669
+ tempExp = ''
670
+ }
671
+ if (this.currentValue) {
672
+ for (let i = 0; i < this.filterCols.length; i++) {
673
+ if (this.isOld === true) {
674
+ tempExp =
675
+ tempExp +
676
+ this.filterCols[i].field +
677
+ '.contains("' +
678
+ this.currentValue +
679
+ '")'
680
+ if (i < this.filterCols.length - 1) {
681
+ tempExp = tempExp + ' or '
682
+ }
683
+ } else {
684
+ if (this.filterCols[i].controlType == 'number') {
685
+ tempExp.expressions.push({
686
+ field: this.filterCols[i].field,
687
+ operator: 'EQ',
688
+ value: Number(this.currentValue)
689
+ })
690
+ } else {
691
+ tempExp.expressions.push({
692
+ field: this.filterCols[i].field,
693
+ operator: 'CO',
694
+ value: this.currentValue
695
+ })
696
+ }
697
+ }
698
+ }
699
+ }
700
+ if (this.isOld === true && tempExp.length > 0) {
701
+ tempExp = '(' + tempExp + ')'
702
+ }
703
+
704
+ if (this.defaultExpression) {
705
+ let tempDefault = replaceParamString(
706
+ this.defaultExpression,
707
+ this.formRow,
708
+ this.$store.getters.moduleSelectItems[this.$route.meta.moduleId]
709
+ )
710
+
711
+ if (tempExp) {
712
+ tempExp = tempExp + ' and (' + tempDefault + ')'
713
+ } else {
714
+ tempExp = tempDefault
715
+ }
716
+ }
717
+
718
+ let postExpression = {
719
+ field: this.field,
720
+ expression: tempExp,
721
+ extendParams: {}
722
+ }
723
+ let repeatRowInfo = {
724
+ field: '',
725
+ values: []
726
+ }
727
+ //查询之前从外部组件构造其他的条件
728
+ this.$emit('preSearch', postExpression, repeatRowInfo)
729
+ let postData = {
730
+ fields: this.fetchFields,
731
+ begin:
732
+ (this.gridPagerConfig.currentPage - 1) *
733
+ this.gridPagerConfig.pageSize +
734
+ 1,
735
+ size: this.gridPagerConfig.pageSize,
736
+ expression: postExpression.expression,
737
+ sort: '',
738
+ extendParams: postExpression.extendParams
739
+ }
740
+
741
+ let tempApi = this.getPostApi(postData)
742
+
743
+ // let tempApi = this.api
744
+ // if (this.api.indexOf('?') > 0) {
745
+ // tempApi = this.api.substring(0, this.api.indexOf('?'))
746
+ // let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
747
+ // tempExtenParams = replaceParam(tempExtenParams, this.formRow)
748
+ // let tempSplitParams = tempExtenParams.split('&')
749
+ // for (let i = 0; i < tempSplitParams.length; i++) {
750
+ // let tempSplitValue = tempSplitParams[i].split('=')
751
+ // this.$set(
752
+ // postData.extendParams,
753
+ // tempSplitValue[0],
754
+ // tempSplitValue[1]
755
+ // )
756
+ // }
757
+ // }
758
+ let vm = this
759
+ vm.gridLoading = true
760
+ request({
761
+ url: tempApi,
762
+ method: 'post',
763
+ data: postData
764
+ })
765
+ .then(responseData => {
766
+ if (vm.isOld === true) {
767
+ vm.searchRows = responseData.data
768
+ vm.gridPagerConfig.total = responseData.extData.totalRows
769
+ } else {
770
+ vm.searchRows = responseData.content
771
+ vm.gridPagerConfig.total = responseData.otherContent.totalRows
772
+ }
773
+ if (repeatRowInfo.field) {
774
+ //设置重复值
775
+ XEUtils.arrayEach(vm.searchRows, item => {
776
+ if (
777
+ XEUtils.arrayIndexOf(
778
+ repeatRowInfo.values,
779
+ item[repeatRowInfo.field]
780
+ ) > -1
781
+ ) {
782
+ item['sysRepeat'] = true
783
+ } else {
784
+ item['sysRepeat'] = false
785
+ }
786
+ })
787
+ }
788
+ // 设置字段sysRepeat后,所定字段的值全部相同则不可选择
789
+ let fieldNames = vm.columns.filter(x => x.sysRepeat)
790
+ .map(y=> {
791
+ return {
792
+ field: y.field,
793
+ linkField: y.linkField,
794
+ }
795
+ })
796
+ if (fieldNames.length) {
797
+ vm.searchRows.forEach(info => {
798
+ vm.propTableData.forEach(item=>{
799
+ // 接口字段可能和表字段field不一致,linkField一致
800
+ let arr= []
801
+ for(let j=0;j<fieldNames.length;j++){
802
+ if(info[fieldNames[j].field] == item[fieldNames[j].linkField]){
803
+ arr.push(true)
804
+ }
805
+ }
806
+ if(fieldNames.length === arr.length){
807
+ info.sysRepeat = true
808
+ }
809
+ })
810
+ })
811
+ }
812
+ })
813
+ .catch(error => {
814
+ console.error(error)
815
+ })
816
+ .finally(() => {
817
+ vm.gridLoading = false
818
+ })
819
+ },
820
+ getPostApi(postData) {
821
+ let tempApi = this.api
822
+ if (this.api.indexOf('?') > 0) {
823
+ tempApi = this.api.substring(0, this.api.indexOf('?'))
824
+ let tempExtenParams = this.api.substring(this.api.indexOf('?') + 1)
825
+ tempExtenParams = replaceParam(tempExtenParams, this.formRow)
826
+ let tempSplitParams = tempExtenParams.split('&')
827
+ for (let i = 0; i < tempSplitParams.length; i++) {
828
+ let tempSplitValue = tempSplitParams[i].split('=')
829
+ this.$set(
830
+ postData.extendParams,
831
+ tempSplitValue[0],
832
+ tempSplitValue[1]
833
+ )
834
+ }
835
+ }
836
+ return tempApi
837
+ }
838
+ }
839
+ }
840
+ </script>
841
+
842
+ <style lang="scss" scoped>
843
+ .pulldown-grid {
844
+ min-width: 600px;
845
+ width: auto;
846
+ height: 350px;
847
+ background-color: #fff;
848
+ box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
849
+ }
850
+
851
+ .d-grid-control {
852
+ width: 100%;
853
+ height: 30px;
854
+ }
855
+ </style>
856
+
857
+
858
+ <style lang="less">
859
+ @import '../../styles/default.less';
860
860
  </style>