doway-coms 1.5.7 → 1.5.9

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