imatrix-ui 0.2.3-up → 0.2.4-up

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.
@@ -1,1221 +1,1224 @@
1
- <template>
2
- <el-table-column
3
- :fixed="fixed"
4
- :sortable="sortable"
5
- :filters="filters"
6
- :filter-method="filterMethod"
7
- :prop="column.prop"
8
- :width="getColumnWidth()"
9
- :align="align"
10
- :header-align="headerAlign"
11
- :class-name="column.prop"
12
- >
13
- <template v-slot:header>
14
- <span :class="{ is_req: isFieldRequired() }"
15
- ><span
16
- class="cell--span required__label"
17
- :title="$escapeHtml(label)"
18
- v-html="$escapeHtml(label)"
19
- /></span>
20
- <el-icon v-if="isShowAdd" @click="createFormSubTableRow" style="font-size: 20px; color: #409eff"><CirclePlus /></el-icon>
21
- </template>
22
- <template v-slot="scope">
23
- <!--添加:key="column.prop+'_'+scope.$index"是为了解决多行是行编辑状态时新建的记录的文本框内有值的问题-->
24
- <dynamic-input
25
- v-if="lineEdit.editable && isEditable && scope.row.$editing"
26
- v-model:value="scope.row[column.prop]"
27
- :type="column.componentType"
28
- :position="{
29
- row: scope.$index,
30
- prop: column.prop,
31
- }"
32
- :list-toolbar-form-data="listToolbarFormData"
33
- :line-edit="lineEdit"
34
- :options="column.valueSet"
35
- :row="scope.row"
36
- :column="column"
37
- :list-code="listCode"
38
- :is-sql="isSql"
39
- :row-index="scope.$index"
40
- :class="isRequired(scope.row.$editing) ? 'm-requried' : ''"
41
- @findIndex="findIndex(scope.$index)"
42
- @focus="onFocus(scope.$index)"
43
- @refresData="refresData"
44
- @refresPortData="refresPortData"
45
- @refresPortsData="refresPortsData"
46
- @refresMainTableFields="refresMainTableFields"
47
- @prohibitToEdit="prohibitToEdit"
48
- />
49
- <span v-else>
50
- <span v-if="column.operations" class="grid-operation-buttons">
51
- <span
52
- v-for="(operation, operationIndex) in column.operations"
53
- :key="operationIndex"
54
- class="cell--span"
55
- >
56
- <el-dropdown
57
- v-if="operation.isGroup"
58
- :size="
59
- operation.buttons && operation.buttons.length > 0
60
- ? operation.buttons[0].props.size
61
- : 'small'
62
- "
63
- style="padding-left: 10px"
64
- split-button
65
- @command="handleCommand"
66
- >
67
- {{ $escapeHtml(operation.label) }}
68
- <template v-slot:dropdown>
69
- <el-dropdown-menu>
70
- <span
71
- v-for="(buttonChild, buttonChildIndex) in operation.buttons"
72
- :key="buttonChild.props.code + buttonChildIndex"
73
- >
74
- <el-dropdown-item
75
- v-permission="buttonChild.props.permission"
76
- :command="
77
- beforeHandleCommand(
78
- buttonChild.props.code,
79
- scope.row,
80
- scope.$index
81
- )
82
- "
83
- :disabled="preventReclick"
84
- >
85
- {{
86
- $escapeHtml(
87
- buttonChild.props.label
88
- ? buttonChild.props.label
89
- : buttonChild.props.code === 'search'
90
- ? $t('superPageMessage.searchButtonLabel')
91
- : ''
92
- )
93
- }}
94
- </el-dropdown-item>
95
- </span>
96
- </el-dropdown-menu>
97
- </template>
98
- </el-dropdown>
99
- <row-operation
100
- v-else
101
- :operation-setting="operation.props"
102
- :label="
103
- operation.props.label
104
- ? operation.props.label
105
- : scope.row[column.prop]
106
- "
107
- :operation-index="operationIndex"
108
- :entity="scope.row"
109
- :editing="scope.row.$editing"
110
- :column="column"
111
- :row-index="scope.$index"
112
- :is-show="operation.isShow"
113
- :on-click="operation.onClick"
114
- />
115
- </span>
116
- </span>
117
- <span
118
- v-else-if="
119
- customFormatValue(
120
- scope.row,
121
- column.prop,
122
- customFormat,
123
- scope.$index
124
- )
125
- "
126
- class="cell--span"
127
- >
128
- <component
129
- :is="column.prop + scope.$index"
130
- :row="scope.row"
131
- :entity="scope.row"
132
- :prop="column.prop"
133
- :parent="parentFormData"
134
- :row-index="scope.$index"
135
- :show-value="$escapeHtml(getLabel(scope.row, scope.$index))"
136
- :value="getCellValue(scope.row)"
137
- :select-options="column.valueSet"
138
- />
139
- </span>
140
- <!-- 自定义格式的时候 -->
141
- <span
142
- v-else-if="
143
- columnFormatter !== undefined &&
144
- columnFormatter.type !== undefined &&
145
- columnFormatter.type === 'customControl' &&
146
- columnFormatter.options &&
147
- columnFormatter.options.format &&
148
- columnFormatter.options.format !== ''
149
- "
150
- class="cell--span"
151
- >
152
- <!--:key="column.prop+'_'+scope.$index+'_'+currentPage" 为了解决子表分页时,新增自动跳转到下一页,第一条记录的自定义控件被复用,导致业务逻辑没执行 -->
153
- <component
154
- :is="columnFormatter.options.format"
155
- :key="column.prop + '_' + scope.$index + '_' + currentPage"
156
- :disabled="true"
157
- :row="pageGridData[scope.$index]"
158
- :entity="pageGridData[scope.$index]"
159
- :prop="column.prop"
160
- :parent="parentFormData"
161
- :row-index="scope.$index"
162
- :get-form-data="getFormData"
163
- :get-grid-data="getTableGridData"
164
- :show-value="
165
- $escapeHtml(getLabel(pageGridData[scope.$index], scope.$index))
166
- "
167
- :value="getCellValue(pageGridData[scope.$index])"
168
- :select-options="column.valueSet"
169
- :grid-data="gridData"
170
- :page-grid-data="pageGridData"
171
- :current-page="currentPage"
172
- /></span>
173
- <span
174
- v-else-if="
175
- columnFormatter !== undefined &&
176
- columnFormatter.type !== undefined &&
177
- columnFormatter.type === 'secretInfo'
178
- "
179
- :id="column.prop + 'DomData' + scope.$index"
180
- class="cell--span"
181
- >
182
- <secret-info
183
- :entity="scope.row"
184
- :prop="column.prop"
185
- :value="getCellValue(scope.row)"
186
- :table-name="tableName"
187
- :list-code="listCode"
188
- :page-code="pageCode"
189
- :list-name="listName"
190
- :field-label="$escapeHtml(label)"
191
- />
192
- </span>
193
- <span v-else-if="isObjectProp(column.prop)">
194
- <span v-if="column.componentType === 'annex'" type="primary">
195
- <span
196
- v-if="isShowOverflowTooltip"
197
- :id="column.prop + 'DomData' + scope.$index"
198
- :title="$escapeHtml(getLabel(scope.row))"
199
- :style="{ width: cellWidth + 'px' }"
200
- class="ellipsis cell--span"
201
- >
202
- <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
203
- <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
204
- </span>
205
- {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
206
- </span>
207
- <span
208
- v-else
209
- :id="column.prop + 'DomData' + scope.$index"
210
- class="cell--span"
211
- >
212
- <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
213
- <el-icon class="annex-cell" @click="previewImg(scope.row)"><el-icon-zoom-in /></el-icon>
214
- </span>
215
- {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
216
- </span>
217
- </span>
218
- <span
219
- v-else-if="column.formatter && column.formatter.type === 'files'"
220
- type="primary"
221
- >
222
- <span
223
- v-if="isShowOverflowTooltip"
224
- :id="column.prop + 'DomData' + scope.$index"
225
- :title="$escapeHtml(getLabel(scope.row))"
226
- :style="{ width: cellWidth + 'px' }"
227
- class="ellipsis cell--span"
228
- >
229
- <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
230
- <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
231
- </span>
232
- {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
233
- </span>
234
- <span
235
- v-else
236
- :id="column.prop + 'DomData' + scope.$index"
237
- class="cell--span"
238
- >
239
- <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
240
- <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
241
- </span>
242
- {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
243
- </span>
244
- </span>
245
- <el-link
246
- v-else-if="
247
- columnFormatter !== undefined &&
248
- columnFormatter.type !== undefined &&
249
- columnFormatter.type === 'hyperlinks' &&
250
- getMyHyperLinkSetting(scope.row).visible === true
251
- "
252
- type="primary"
253
- @click="clickHyperLink(column, scope.row, listCode, scope.$index)"
254
- >
255
- <span
256
- v-if="isShowOverflowTooltip"
257
- :id="column.prop + 'DomData' + scope.$index"
258
- :title="getMyHyperLinkSetting(scope.row).title"
259
- :style="{ width: cellWidth + 'px' }"
260
- class="ellipsis cell--span"
261
- >{{ getMyHyperLinkSetting(scope.row).label
262
- }}<i
263
- v-if="getMyHyperLinkSetting(scope.row).icon"
264
- :class="getMyHyperLinkSetting(scope.row).icon"
265
- /></span>
266
- <span
267
- v-else
268
- :id="column.prop + 'DomData' + scope.$index"
269
- class="cell--span"
270
- >{{ getMyHyperLinkSetting(scope.row).label
271
- }}<i
272
- v-if="getMyHyperLinkSetting(scope.row).icon"
273
- :class="getMyHyperLinkSetting(scope.row).icon"
274
- /></span>
275
- </el-link>
276
- <span
277
- v-else-if="isShowOverflowTooltip"
278
- :id="column.prop + 'DomData' + scope.$index"
279
- :title="$escapeHtml(getLabel(scope.row))"
280
- :style="{ width: cellWidth + 'px' }"
281
- class="ellipsis cell--span"
282
- >{{ $escapeHtml(getLabel(scope.row, scope.$index)) }}</span
283
- >
284
- <span
285
- v-else
286
- :id="column.prop + 'DomData' + scope.$index"
287
- class="cell--span"
288
- >{{ $escapeHtml(getLabel(scope.row, scope.$index)) }}</span
289
- >
290
- </span>
291
- <span v-else>
292
- <span
293
- v-if="
294
- column.componentType === 'annex' ||
295
- column.componentType === 'multipartUpload'
296
- "
297
- type="primary"
298
- >
299
- <span
300
- v-if="isShowOverflowTooltip"
301
- :id="column.prop + 'DomData' + scope.$index"
302
- :title="$escapeHtml(getLabel(scope.row))"
303
- :style="{ width: cellWidth + 'px' }"
304
- class="ellipsis cell--span"
305
- >
306
- <FsPreview
307
- :label="$escapeHtml(getLabel(scope.row, scope.$index))"
308
- :entity="scope.row"
309
- :file-set-obj="JSON.parse(column.fileSet)"
310
- :is-sql="isSql"
311
- />
312
- </span>
313
- <span
314
- v-else
315
- :id="column.prop + 'DomData' + scope.$index"
316
- class="cell--span"
317
- >
318
- <FsPreview
319
- :label="$escapeHtml(getLabel(scope.row, scope.$index))"
320
- :entity="scope.row"
321
- :file-set-obj="JSON.parse(column.fileSet)"
322
- :is-sql="isSql"
323
- />
324
- </span>
325
- </span>
326
- <span
327
- v-else-if="column.formatter && column.formatter.type === 'files'"
328
- >
329
- <span
330
- v-if="isShowOverflowTooltip"
331
- :id="column.prop + 'DomData' + scope.$index"
332
- :title="$escapeHtml(getLabel(scope.row))"
333
- :style="{ width: cellWidth + 'px' }"
334
- class="ellipsis cell--span"
335
- >
336
- <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
337
- <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
338
- </span>
339
- {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
340
- </span>
341
- <span
342
- v-else
343
- :id="column.prop + 'DomData' + scope.$index"
344
- class="cell--span"
345
- >
346
- <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
347
- <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
348
- </span>
349
- {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
350
- </span>
351
- </span>
352
- <!-- 超链接 -->
353
- <el-link
354
- v-else-if="
355
- columnFormatter !== undefined &&
356
- columnFormatter.type !== undefined &&
357
- columnFormatter.type === 'hyperlinks' &&
358
- getMyHyperLinkSetting(scope.row).visible === true
359
- "
360
- type="primary"
361
- @click="clickHyperLink(column, scope.row, listCode, scope.$index)"
362
- >
363
- <span
364
- v-if="isShowOverflowTooltip"
365
- :id="column.prop + 'DomData' + scope.$index"
366
- :title="$escapeHtml(getMyHyperLinkSetting(scope.row).title)"
367
- :style="{ width: cellWidth + 'px' }"
368
- class="ellipsis cell--span"
369
- >{{ $escapeHtml(getMyHyperLinkSetting(scope.row).label)
370
- }}<i
371
- v-if="getMyHyperLinkSetting(scope.row).icon"
372
- :class="getMyHyperLinkSetting(scope.row).icon"
373
- /></span>
374
- <span
375
- v-else
376
- :id="column.prop + 'DomData' + scope.$index"
377
- class="cell--span"
378
- >{{ $escapeHtml(getMyHyperLinkSetting(scope.row).label)
379
- }}<i
380
- v-if="getMyHyperLinkSetting(scope.row).icon"
381
- :class="getMyHyperLinkSetting(scope.row).icon"
382
- /></span>
383
- </el-link>
384
- <!-- 富文本 -->
385
- <span
386
- v-else-if="
387
- column.formatter && column.formatter.type === 'richEditor'
388
- "
389
- >
390
- <el-tooltip
391
- :content="$t('superGrid.show')"
392
- class="item"
393
- effect="dark"
394
- placement="top"
395
- >
396
- <em
397
- class="fa fa-info-circle annex-cell"
398
- @click="showRichEditorContent(scope.row, column, getHeader())"
399
- />
400
- </el-tooltip>
401
- </span>
402
- <span
403
- v-else-if="column.formatter && column.formatter.type === 'icon'"
404
- >
405
- <i
406
- v-if="getFormatIconSetting(formatConfig).position === 'pre'"
407
- :class="getFormatIconSetting(formatConfig).icon"
408
- />
409
- <span
410
- v-if="formatConfig.displayTextJudge"
411
- :id="column.prop + 'DomData' + scope.$index"
412
- class="cell--span"
413
- >{{ $escapeHtml(getFormatIconSetting(scope.row).label) }}
414
- </span>
415
- <i
416
- v-if="getFormatIconSetting(formatConfig).position === 'suf'"
417
- :class="getFormatIconSetting(formatConfig).icon"
418
- />
419
- </span>
420
- <span
421
- v-else-if="isShowOverflowTooltip"
422
- :id="column.prop + 'DomData' + scope.$index"
423
- :title="getLabel(scope.row)"
424
- :style="{ width: cellWidth + 'px' }"
425
- style="white-space: pre"
426
- class="ellipsis cell--span"
427
- v-html="$escapeHtml(getLabel(scope.row, scope.$index))"
428
- />
429
- <span
430
- v-else
431
- :id="column.prop + 'DomData' + scope.$index"
432
- class="cell--span"
433
- >{{ $escapeHtml(getLabel(scope.row, scope.$index)) }}</span
434
- >
435
- </span>
436
- </span>
437
- </template>
438
- </el-table-column>
439
- <view-image-dialog
440
- v-if="showSingleImgFlag"
441
- :file-list="fileList"
442
- @close="showSingleImgFlag = false"
443
- />
444
- <rich-editor-viewer
445
- v-if="showRichEditorViewer"
446
- ref="richEditorViewerRef"
447
- @closeRichEditorContent="closeRichEditorContent"
448
- />
449
- </template>
450
-
451
- <script>
452
- import {
453
- CirclePlus as ElIconCirclePlusOutline,
454
- ZoomIn as ElIconZoomIn,
455
- } from '@element-plus/icons-vue'
456
- import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
457
- import { getColumnValues, isRequiredEdit } from './utils'
458
- import DynamicInput from './dynamic-input.vue'
459
- import store from './store'
460
- import { ArrowKeyAction, isHasEditOption, getFileList } from './utils'
461
- import { doFormatWithValueSet } from './formatter'
462
- import customFormatter from './custom-formatter'
463
- import RowOperation from './row-operation.vue'
464
- import apis from './apis'
465
- import { mapGetters } from 'vuex'
466
- import {
467
- getEntityFieldValue,
468
- getParentObjectUtil,
469
- } from '../../../src/utils/util'
470
- import ViewImageDialog from './view-image-dialog.vue'
471
- import eventBus from './eventBus'
472
- import { isDynamicDataSourceSource } from './utils'
473
- import FsPreview from '../../fs-preview'
474
- import RichEditorViewer from '../../rich-editor/viewer.vue'
475
- export default {
476
- components: {
477
- DynamicInput,
478
- RowOperation,
479
- ViewImageDialog,
480
- FsPreview,
481
- RichEditorViewer,
482
- ElIconCirclePlusOutline,
483
- ElIconZoomIn,
484
- },
485
- name: 'NormalColumn',
486
- props: {
487
- column: {
488
- type: Object,
489
- default: null,
490
- },
491
- customFormat: {
492
- type: Function,
493
- default: null,
494
- },
495
- listCode: {
496
- type: String,
497
- default: null,
498
- },
499
- isSql: {
500
- type: Boolean,
501
- default: false,
502
- },
503
- newWidth: {
504
- type: Number,
505
- default: null,
506
- },
507
- dragColumnProp: {
508
- type: String,
509
- default: null,
510
- },
511
- tableName: {
512
- type: String,
513
- default: null,
514
- },
515
- pageCode: {
516
- type: String,
517
- default: null,
518
- },
519
- listName: {
520
- type: String,
521
- default: null,
522
- },
523
- currentPage: {
524
- type: Number,
525
- default: 1,
526
- },
527
- gridData: {
528
- type: Array,
529
- default: null,
530
- },
531
- pageGridData: {
532
- type: Array,
533
- default: null,
534
- },
535
- listToolbarFormData: {
536
- type: Object,
537
- default: null,
538
- },
539
- },
540
- data() {
541
- let parentFormData
542
- const gridParams = store.get(this.listCode)
543
- if (
544
- gridParams.options.extraParam &&
545
- gridParams.options.extraParam.entityMap
546
- ) {
547
- parentFormData = gridParams.options.extraParam.entityMap
548
- }
549
- return {
550
- selectRow: null,
551
- that: this,
552
- align: 'left', // 文本内容对齐
553
- headerAlign: 'left', // 表头对齐方式
554
- columnFormatter: this.column.formatter,
555
- hyperLinks: {},
556
- fileDownType: '',
557
- isFormSubTable: false, // 是否是表单子表
558
- subTableCanAdd: true, // 表单子表时是否有新增权限
559
- isShowAdd: false, // 是否显示表头的新增按钮
560
- cellWidth: null,
561
- parentFormData,
562
- fileMultiple: false, // 附件上传是否多选
563
- showSingleImgFlag: false,
564
- singleImgSrc: '',
565
- fileList: [],
566
- index: null,
567
- isEditable: this.column.editable,
568
- showRichEditorViewer: false,
569
- formatConfig: {},
570
- getFormData: gridParams.options.getFormData,
571
- getTableGridData: gridParams.options.getGridData,
572
- }
573
- },
574
- computed: {
575
- filters() {
576
- if (this.column.filterable) {
577
- const gridParams = store.get(this.listCode)
578
- const values = getColumnValues(gridParams.gridData, this.column.prop)
579
- const filters = []
580
- for (const value of values) {
581
- filters.push({
582
- text: value,
583
- value,
584
- })
585
- }
586
- return filters
587
- } else {
588
- return null
589
- }
590
- },
591
- filterMethod() {
592
- if (this.column.filterable) {
593
- return this.filterHandler
594
- } else {
595
- return null
596
- }
597
- },
598
- fixed() {
599
- if (
600
- (this.column.fixed && this.column.fixed === 'false') ||
601
- this.column.fixed === undefined ||
602
- this.column.fixed === ''
603
- ) {
604
- return false
605
- }
606
- if (
607
- this.column.prop === 'operation' &&
608
- this.column.fixed &&
609
- this.column.fixed === 'left'
610
- ) {
611
- // 操作列居右固定
612
- return 'right'
613
- }
614
- return this.column.fixed
615
- },
616
- sortable() {
617
- const gridParams = store.get(this.listCode)
618
- if (
619
- gridParams &&
620
- gridParams.options &&
621
- gridParams.options.isFormSubTable &&
622
- gridParams.options.showOperationButton
623
- ) {
624
- return false
625
- }
626
- if (
627
- this.column.sortable === 'false' ||
628
- this.column.sortable === false ||
629
- this.column.sortable === ''
630
- ) {
631
- return false
632
- } else if (
633
- this.column.sortable === 'true' ||
634
- this.column.sortable === true
635
- ) {
636
- return 'custom'
637
- }
638
- if (this.column.sortable) {
639
- return 'custom'
640
- } else {
641
- return false
642
- }
643
- },
644
- lineEdit() {
645
- let isLineEdit = false
646
- if (this.listCode) {
647
- const gridParams = store.get(this.listCode)
648
- if (gridParams.lineEdit !== null && gridParams.lineEdit !== undefined) {
649
- isLineEdit = gridParams.lineEdit
650
- } else {
651
- isLineEdit = false
652
- }
653
- }
654
- return isLineEdit
655
- },
656
-
657
- ...mapGetters(['preventReclick']),
658
- },
659
- watch: {
660
- isSql: {
661
- deep: true,
662
-
663
- handler(newValue, oldValue) {
664
- this.isSql = newValue
665
- },
666
- },
667
- newWidth: {
668
- deep: true,
669
-
670
- handler(newValue, oldValue) {
671
- if (
672
- newValue !== undefined &&
673
- newValue !== null &&
674
- this.dragColumnProp &&
675
- this.dragColumnProp === this.column.prop
676
- ) {
677
- this.cellWidth = newValue
678
- }
679
- },
680
- },
681
- },
682
- created() {
683
- if (this.column.width) {
684
- this.cellWidth = this.column.width - 10
685
- }
686
- const gridParams = store.get(this.listCode)
687
- if (gridParams && gridParams.options && gridParams.options.isFormSubTable) {
688
- this.isFormSubTable = gridParams.options.isFormSubTable
689
- }
690
- if (
691
- gridParams &&
692
- gridParams.options &&
693
- gridParams.options.subTableCanAdd !== undefined &&
694
- gridParams.options.subTableCanAdd !== null
695
- ) {
696
- this.subTableCanAdd = gridParams.options.subTableCanAdd
697
- }
698
- if (this.column.prop && this.column.prop === 'operation') {
699
- // 如果是操作列按钮则不显示省略号
700
- this.isShowOverflowTooltip = false
701
- } else {
702
- if (
703
- typeof gridParams.options.showOverflowTooltip !== 'undefined' &&
704
- gridParams.options.showOverflowTooltip === false
705
- ) {
706
- this.isShowOverflowTooltip = false
707
- } else {
708
- this.isShowOverflowTooltip = true
709
- }
710
- }
711
- if (typeof gridParams.options.align !== 'undefined') {
712
- this.align = gridParams.options.align
713
- } else if (this.column.contAlign && this.column.contAlign !== '') {
714
- this.align = this.column.contAlign
715
- }
716
- if (typeof gridParams.options.headerAlign !== 'undefined') {
717
- this.headerAlign = gridParams.options.headerAlign
718
- } else if (this.column.titleAlign && this.column.titleAlign !== '') {
719
- this.headerAlign = this.column.titleAlign
720
- } else {
721
- // 如果没有配置表头对齐方式,默认使用内容对齐方式
722
- this.headerAlign = 'left'
723
- }
724
- if (
725
- gridParams.isHasDynamic === undefined &&
726
- this.column.dynamic !== undefined &&
727
- this.column.dynamic === true
728
- ) {
729
- // 当前列表中有动态列
730
- gridParams.isHasDynamic = true
731
- }
732
- this.label = this.getHeader()
733
- if (this.column.operations) {
734
- // console.log('this.column.operations', this.column.operations)
735
- }
736
- // console.log('gridParams.options.subTableCanAdd=', gridParams.options.subTableCanAdd, 'this.subTableCanAdd=', this.subTableCanAdd)
737
- this.isShowAdd =
738
- this.isFormSubTable &&
739
- this.column.prop === 'operation' &&
740
- this.subTableCanAdd &&
741
- gridParams.options &&
742
- gridParams.options.showOperationButton
743
- if (
744
- this.column.fileSet &&
745
- this.column.fileSet !== '' &&
746
- this.column.componentType === 'annex'
747
- ) {
748
- const fileSetObj = JSON.parse(this.column.fileSet)
749
- if (fileSetObj && fileSetObj.multiple) {
750
- this.fileMultiple = true
751
- }
752
- }
753
- if (
754
- this.column.formatter &&
755
- this.column.formatter.options &&
756
- this.column.formatter.options.format
757
- ) {
758
- this.formatConfig = JSON.parse(this.column.formatter.options.format)
759
- }
760
- },
761
- mounted() {
762
- // 监听保存时点击按钮事件线触发
763
- $on(eventBus, 'un-edit', (param) => {
764
- // 处理多选选项组问题保存问题
765
- if (
766
- this.column.componentType &&
767
- (this.column.componentType === 'multiselect' ||
768
- this.column.componentType === 'select')
769
- ) {
770
- const isDynamic = isDynamicDataSourceSource(this.column)
771
- if (!isDynamic) {
772
- // 选项组保存时将数组处理为字符串
773
- const beforeColumnValue = param.row[this.column.prop]
774
- if (
775
- beforeColumnValue &&
776
- Object.prototype.toString.apply(beforeColumnValue) ===
777
- '[object Array]'
778
- ) {
779
- // 如果是数组才需要转换
780
- param.row[this.column.prop] = beforeColumnValue.join(',')
781
- }
782
- } else {
783
- // 动态数据源多选保存时,获取已选择的字段,由于多选选项组的值是数组,保存时要拼接成“ ,” 分隔的字符串
784
- if ('_dynamic-source-data-' + this.column.prop in this.column) {
785
- const temp = this.column['_dynamic-source-data-' + this.column.prop]
786
- const valueSetOptions = temp.valueSetOptions
787
- // 获取当前字段对应在映射关系中对应的是动态数据源中的哪一个字段key
788
- let selectDataKey
789
- for (let i = 0; i < valueSetOptions.length; i++) {
790
- const valueSetOption = valueSetOptions[i]
791
- if (
792
- this.column.prop === valueSetOption.valueColumn.dbColumnName
793
- ) {
794
- selectDataKey = valueSetOption.columnName
795
- break
796
- }
797
- }
798
- if (selectDataKey) {
799
- // beforeColumnValue是数组值,如果是单选则是字符串
800
- let beforeColumnValue = param.row[this.column.prop]
801
- if (this.column.componentType === 'select') {
802
- if (selectDataKey !== temp.valueAttribute) {
803
- // 解决当前字段不是动态数据源选项值所映射的字段的问题 例如当前字段是工厂名称, 动态数据源选项值是工厂编码
804
- beforeColumnValue = temp.optionItems.find(
805
- (item) =>
806
- // 当前字段映射的是工厂名称,
807
- // 筛选动态数据源选项值字段对应的当前字段所映射的字段, 例如 根据工厂编码找工厂编码对应的工厂名称
808
- // 找出名称后赋值给当前字段
809
- item[temp.valueAttribute] === beforeColumnValue
810
- )[selectDataKey]
811
- }
812
- // 如果是单选
813
- // 现在选择时已经赋值,不再需要这里进行赋值
814
- // temp.optionItems.forEach(optionItem => {
815
- // if (optionItem[temp.valueAttribute] === beforeColumnValue) {
816
- // this.$set(param.row, this.column.prop, optionItem[selectDataKey])
817
- // }
818
- // })
819
- param.row[this.column.prop] = beforeColumnValue
820
- } else {
821
- // 如果是多选,join “ ,” , 并给row赋值
822
- // 现在选择时已经赋值,不再需要这里进行赋值
823
- // const afterColumnValue = []
824
- // temp.optionItems.forEach(optionItem => {
825
- // beforeColumnValue.forEach(value => {
826
- // if (optionItem[temp.valueAttribute] === value) {
827
- // afterColumnValue.push(optionItem[selectDataKey])
828
- // }
829
- // })
830
- // })
831
- if (
832
- beforeColumnValue &&
833
- selectDataKey !== temp.valueAttribute
834
- ) {
835
- // 解决当前字段不是动态数据源选项值所映射的字段的问题 例如当前字段是工厂名称, 动态数据源选项值是工厂编码
836
- const t = []
837
- beforeColumnValue.forEach((selectItem) => {
838
- if (selectDataKey !== temp.valueAttribute) {
839
- t.push(
840
- temp.optionItems.find(
841
- (option) => option[temp.valueAttribute] === selectItem
842
- )[selectDataKey]
843
- )
844
- }
845
- })
846
- beforeColumnValue = t
847
- }
848
- param.row[this.column.prop] = beforeColumnValue.join(',')
849
- }
850
- }
851
- } else {
852
- const beforeColumnValue = param.row[this.column.prop]
853
- if (
854
- beforeColumnValue &&
855
- Object.prototype.toString.apply(beforeColumnValue) ===
856
- '[object Array]'
857
- ) {
858
- // 如果是数组才需要转换
859
- param.row[this.column.prop] = beforeColumnValue.join(',')
860
- }
861
- }
862
- }
863
- }
864
- })
865
- },
866
- unmounted() {
867
- $off(eventBus, 'un-edit')
868
- },
869
- methods: {
870
- ...customFormatter,
871
- ...apis,
872
- getHeader() {
873
- if (!this.column.titleValueSet) {
874
- return this.column.label.replace(/\\n/g, '</br>')
875
- } else {
876
- return this.formatHeader()
877
- }
878
- },
879
- formatHeader() {
880
- return doFormatWithValueSet(
881
- this.column.titleValueSetValue,
882
- this.column.label
883
- )
884
- },
885
- filterHandler(value, row, column) {
886
- const property = column['property']
887
- return row[property] === value
888
- },
889
- onFocus(index) {
890
- const gridParams = store.get(this.listCode)
891
- if (gridParams.lineEdit.editingCell) {
892
- gridParams.lineEdit.editingCell.row = index
893
- gridParams.lineEdit.editingCell.prop = this.column.prop
894
- }
895
- },
896
- findIndex(index) {
897
- this.index = index
898
- const gridParams = store.get(this.listCode)
899
- if (gridParams.lineEdit.editingCell) {
900
- gridParams.lineEdit.editingCell.row = index
901
- gridParams.lineEdit.editingCell.prop = this.column.prop
902
- }
903
- },
904
- refresData(data) {
905
- $emit(this, 'refresData', data)
906
- },
907
- refresPortData(port, value) {
908
- const gridParams = store.get(this.listCode)
909
- console.log('gridParams', gridParams)
910
- console.log('this.index', this.index)
911
- if (
912
- gridParams &&
913
- gridParams.lineEdit &&
914
- gridParams.lineEdit.editingCell
915
- ) {
916
- $emit(
917
- this,
918
- 'refresPortData',
919
- port,
920
- value,
921
- gridParams.lineEdit.editingCell.row
922
- )
923
- } else {
924
- $emit(this, 'refresPortData', port, value, this.index)
925
- }
926
- },
927
- refresPortsData(map) {
928
- const gridParams = store.get(this.listCode)
929
- console.log('gridParams', gridParams)
930
- console.log('this.index', this.index)
931
- if (
932
- gridParams &&
933
- gridParams.lineEdit &&
934
- gridParams.lineEdit.editingCell
935
- ) {
936
- $emit(this, 'refresPortsData', map, gridParams.lineEdit.editingCell.row)
937
- } else {
938
- $emit(this, 'refresPortsData', map, this.index)
939
- }
940
- },
941
- refresMainTableFields(map) {
942
- $emit(this, 'refresMainTableFields', map)
943
- },
944
- // @keyup.native.left="move('left')"
945
- // @keyup.native.right="move('right')"
946
- // @keyup.native.up="move('up')"
947
- // @keyup.native.down="move('down')"
948
- move(direction) {
949
- if (direction === 'left') {
950
- const prop = ArrowKeyAction.getLeftColumn(this.column.prop)
951
- const gridParams = store.get(this.listCode)
952
- gridParams.lineEdit.editingCell.prop = prop
953
- }
954
- },
955
- // filterHandler(value, row, column) {
956
- // const property = column['property']
957
- // return row[property] === value
958
- // },
959
- isSaveByEnter() {
960
- const gridParams = store.get(this.listCode)
961
- return (
962
- typeof gridParams.options.lineEditOptions.isSaveByEnter ===
963
- 'undefined' ||
964
- (isHasEditOption('isSaveByEnter', this.listCode) &&
965
- gridParams.options.lineEditOptions.isSaveByEnter === true)
966
- )
967
- },
968
- isRestoreByEsc() {
969
- const gridParams = store.get(this.listCode)
970
- return (
971
- typeof gridParams.options.lineEditOptions.isRestoreByEsc ===
972
- 'undefined' ||
973
- (isHasEditOption('isRestoreByEsc', this.listCode) &&
974
- gridParams.options.lineEditOptions.isRestoreByEsc === true)
975
- )
976
- },
977
- canFocus(index) {
978
- const gridParams = store.get(this.listCode)
979
- if (
980
- index === gridParams.lineEdit.editingCell.row &&
981
- this.column.prop === gridParams.lineEdit.editingCell.prop
982
- ) {
983
- return true
984
- } else {
985
- return false
986
- }
987
- },
988
- getLabel(row, index) {
989
- this.transferColumnDataToUpperCase(row)
990
- const obj = this.objectPropValueTwo(row, this.column)
991
- // // 存储执行时间
992
- // const get2 = new Date().getTime()
993
- // const get3 = Number(get2) - Number(get1)
994
- // if (!window.sessionStorage.getItem('getLabel')) {
995
- // window.sessionStorage.setItem('getLabel', get3)
996
- // } else {
997
- // const get4 = window.sessionStorage.getItem('getLabel')
998
- // const get5 = Number(get4) + Number(get3)
999
- // window.sessionStorage.setItem('getLabel', get5)
1000
- // }
1001
- return obj
1002
- // const returnValue = this.objectPropValueTwo(row, this.column)
1003
- // if (returnValue) {
1004
- // // 解决当文本中有多个空格时候, vue自动将多个空格合并为一个空格,
1005
- // // 或者修改vue的配置 https://cn.vuejs.org/api/application.html#app-config-compileroptions app.config.compilerOptions.whitespace
1006
- // return returnValue.replaceAll(' ', '\u00A0')
1007
- // }
1008
- // return returnValue
1009
- },
1010
- getCellValue(row) {
1011
- let cellValue = getEntityFieldValue(row, this.column.prop, false)
1012
- if (cellValue === undefined || cellValue === null) {
1013
- this.transferColumnDataToUpperCase(row)
1014
- cellValue = getEntityFieldValue(row, this.column.prop, false)
1015
- }
1016
- return cellValue
1017
- },
1018
- // 兼容oracle和mysql数据库,oracle是字段名是大写的,mysql是小写的,将小写转为大写
1019
- transferColumnDataToUpperCase(row) {
1020
- const reg1 = /[A-Z]+/ // 大写字母
1021
- if (this.isSql && reg1.test(this.column.prop)) {
1022
- this.transferColumnDataToUpperCaseWithProp(
1023
- row,
1024
- this.column.prop.toLowerCase(),
1025
- this.column.prop
1026
- )
1027
- }
1028
- },
1029
- transferColumnDataToUpperCaseWithProp(row, propLowerCase, columnProp) {
1030
- let dataModel
1031
- if (propLowerCase && propLowerCase.indexOf('.') > 0) {
1032
- const parentObj = getParentObjectUtil(propLowerCase, row)
1033
- const prop = propLowerCase.substring(propLowerCase.lastIndexOf('.') + 1)
1034
- dataModel = parentObj[prop]
1035
- if (dataModel !== undefined) {
1036
- // sql字段名小写转大写,兼容mysql、oracle数据库
1037
- parentObj[columnProp] = dataModel
1038
- delete parentObj[prop]
1039
- }
1040
- } else {
1041
- dataModel = row[propLowerCase]
1042
- if (dataModel !== undefined) {
1043
- // sql字段名小写转大写,兼容mysql、oracle数据库
1044
- row[columnProp] = dataModel
1045
- delete row[propLowerCase]
1046
- }
1047
- }
1048
- return dataModel
1049
- },
1050
- getMyHyperLinkSetting(row) {
1051
- this.transferColumnDataToUpperCase(row)
1052
- const gridParams = store.get(this.listCode)
1053
- let tableName
1054
- if (
1055
- gridParams &&
1056
- gridParams.basicInfo &&
1057
- gridParams.basicInfo.tableName
1058
- ) {
1059
- tableName = gridParams.basicInfo.tableName
1060
- }
1061
- const hyperLinkResult = this.getHyperLinkSetting(
1062
- this.column,
1063
- row,
1064
- this.isSql,
1065
- gridParams.additionalParamMap,
1066
- gridParams.contextParameter,
1067
- tableName,
1068
- this.listCode
1069
- )
1070
- hyperLinkResult.icon = this.getHyperIconClass(hyperLinkResult)
1071
- return hyperLinkResult
1072
- },
1073
- getHyperIconClass(hyperLinkResult) {
1074
- let iconName
1075
- if (
1076
- hyperLinkResult &&
1077
- hyperLinkResult !== null &&
1078
- hyperLinkResult.icon &&
1079
- hyperLinkResult.icon !== ''
1080
- ) {
1081
- iconName = hyperLinkResult.icon
1082
- }
1083
- if (iconName && iconName.indexOf('fa-') === 0) {
1084
- // 表示以“fa-”开头,使用font-awesome中的图标
1085
- iconName = 'fa ' + iconName
1086
- }
1087
- return iconName
1088
- },
1089
- createFormSubTableRow() {
1090
- console.log('触发了行新建')
1091
- this.createRow(this.listCode)
1092
- },
1093
- handleCommand(comman) {
1094
- let prop = null
1095
- this.column.operations.forEach((item) => {
1096
- if (item.isGroup) {
1097
- item.buttons.forEach((button) => {
1098
- if (button.props.code === comman.comman) {
1099
- prop = button
1100
- }
1101
- })
1102
- }
1103
- })
1104
- if (prop) {
1105
- customFormatter.onClickFun(
1106
- comman.row,
1107
- this.column,
1108
- prop.onClick,
1109
- comman.rowIndex
1110
- )
1111
- }
1112
- },
1113
- beforeHandleCommand(comman, row, rowIndex) {
1114
- return {
1115
- comman: comman,
1116
- row: row,
1117
- rowIndex: rowIndex,
1118
- }
1119
- },
1120
- previewImg(row) {
1121
- this.fileList = getFileList(row, this.column, this.isSql)
1122
- this.showSingleImgFlag = true
1123
- },
1124
- getFileList(row) {
1125
- return getFileList(row, this.column, this.isSql)
1126
- },
1127
- getColumnWidth() {
1128
- if (
1129
- this.column &&
1130
- this.column.prop === 'operation' &&
1131
- !this.column.width
1132
- ) {
1133
- // 表示操作列,宽度固定
1134
- return '210'
1135
- }
1136
- return this.column.width ? this.column.width + '' : '130'
1137
- },
1138
- // 设置字段禁止编辑
1139
- fnProhibitToEdit(isEditable) {
1140
- this.isEditable = isEditable
1141
- },
1142
- // 设置字段禁止编辑
1143
- prohibitToEdit(entity) {
1144
- $emit(this, 'prohibitToEdit', entity)
1145
- },
1146
- isFieldRequired() {
1147
- return isRequiredEdit(this.column, this.listCode)
1148
- // return true
1149
- },
1150
- // 展示富文本内容
1151
- showRichEditorContent(row, column, header) {
1152
- this.showRichEditorViewer = true
1153
- this.$nextTick(() => {
1154
- this.$refs.richEditorViewerRef.showContent(row[column.prop], header)
1155
- })
1156
- },
1157
- closeRichEditorContent() {
1158
- this.showRichEditorViewer = false
1159
- },
1160
- isRequired(editing) {
1161
- if (
1162
- !this.isFormSubTable &&
1163
- this.lineEdit.editable &&
1164
- this.isEditable &&
1165
- editing &&
1166
- this.column.validations
1167
- ) {
1168
- if (this.column.validations.indexOf('"required":true') > 0) {
1169
- return true
1170
- }
1171
- }
1172
- return false
1173
- },
1174
- getFormatIconSetting(row) {
1175
- this.transferColumnDataToUpperCase(row)
1176
- const gridParams = store.get(this.listCode)
1177
- const result = this.getIconSetting(
1178
- this.column,
1179
- row,
1180
- this.isSql,
1181
- gridParams,
1182
- this.listCode
1183
- )
1184
- result.icon = this.getHyperIconClass(result)
1185
- if (
1186
- this.column.formatter.options &&
1187
- this.column.formatter.options.format
1188
- ) {
1189
- result.position = JSON.parse(
1190
- this.column.formatter.options.format
1191
- ).position
1192
- }
1193
- return result
1194
- },
1195
- },
1196
- emits: [
1197
- 'refresData',
1198
- 'refresPortData',
1199
- 'refresPortsData',
1200
- 'refresMainTableFields',
1201
- 'prohibitToEdit',
1202
- ,
1203
- ],
1204
- }
1205
- </script>
1206
-
1207
- <style lang="scss" scoped>
1208
- .annex-cell {
1209
- padding-right: 5px;
1210
- cursor: pointer;
1211
- color: #409eff;
1212
- }
1213
- .m-requried {
1214
- float: left;
1215
- white-space: nowrap;
1216
- }
1217
- .m-requried::after {
1218
- content: '*';
1219
- color: #f56c6c;
1220
- }
1221
- </style>
1
+ <template>
2
+ <el-table-column
3
+ :fixed="fixed"
4
+ :sortable="sortable"
5
+ :filters="filters"
6
+ :filter-method="filterMethod"
7
+ :prop="column.prop"
8
+ :width="getColumnWidth()"
9
+ :align="align"
10
+ :header-align="headerAlign"
11
+ :class-name="column.prop"
12
+ >
13
+ <template v-slot:header>
14
+ <span :class="{ is_req: isFieldRequired() }"
15
+ ><span
16
+ class="cell--span required__label"
17
+ :title="$escapeHtml(label)"
18
+ v-html="$escapeHtml(label)"
19
+ /></span>
20
+ <el-icon v-if="isShowAdd" @click="createFormSubTableRow" style="font-size: 20px; color: #409eff"><CirclePlus /></el-icon>
21
+ </template>
22
+ <template v-slot="scope">
23
+ <!--添加:key="column.prop+'_'+scope.$index"是为了解决多行是行编辑状态时新建的记录的文本框内有值的问题-->
24
+ <dynamic-input
25
+ v-if="lineEdit.editable && isEditable && scope.row.$editing"
26
+ v-model:value="scope.row[column.prop]"
27
+ :type="column.componentType"
28
+ :position="{
29
+ row: scope.$index,
30
+ prop: column.prop,
31
+ }"
32
+ :list-toolbar-form-data="listToolbarFormData"
33
+ :line-edit="lineEdit"
34
+ :options="column.valueSet"
35
+ :row="scope.row"
36
+ :column="column"
37
+ :list-code="listCode"
38
+ :is-sql="isSql"
39
+ :row-index="scope.$index"
40
+ :class="isRequired(scope.row.$editing) ? 'm-requried' : ''"
41
+ @findIndex="findIndex(scope.$index)"
42
+ @focus="onFocus(scope.$index)"
43
+ @refresData="refresData"
44
+ @refresPortData="refresPortData"
45
+ @refresPortsData="refresPortsData"
46
+ @refresMainTableFields="refresMainTableFields"
47
+ @prohibitToEdit="prohibitToEdit"
48
+ />
49
+ <span v-else>
50
+ <span v-if="column.operations" class="grid-operation-buttons">
51
+ <span
52
+ v-for="(operation, operationIndex) in column.operations"
53
+ :key="operationIndex"
54
+ class="cell--span"
55
+ >
56
+ <el-dropdown
57
+ v-if="operation.isGroup"
58
+ :size="
59
+ operation.buttons && operation.buttons.length > 0
60
+ ? operation.buttons[0].props.size
61
+ : 'small'
62
+ "
63
+ style="padding-left: 10px"
64
+ split-button
65
+ @command="handleCommand"
66
+ >
67
+ {{ $escapeHtml(operation.label) }}
68
+ <template v-slot:dropdown>
69
+ <el-dropdown-menu>
70
+ <span
71
+ v-for="(buttonChild, buttonChildIndex) in operation.buttons"
72
+ :key="buttonChild.props.code + buttonChildIndex"
73
+ >
74
+ <el-dropdown-item
75
+ v-permission="buttonChild.props.permission"
76
+ :command="
77
+ beforeHandleCommand(
78
+ buttonChild.props.code,
79
+ scope.row,
80
+ scope.$index
81
+ )
82
+ "
83
+ :disabled="preventReclick"
84
+ >
85
+ {{
86
+ $escapeHtml(
87
+ buttonChild.props.label
88
+ ? buttonChild.props.label
89
+ : buttonChild.props.code === 'search'
90
+ ? $t('superPageMessage.searchButtonLabel')
91
+ : ''
92
+ )
93
+ }}
94
+ </el-dropdown-item>
95
+ </span>
96
+ </el-dropdown-menu>
97
+ </template>
98
+ </el-dropdown>
99
+ <row-operation
100
+ v-else
101
+ :operation-setting="operation.props"
102
+ :label="
103
+ operation.props.label
104
+ ? operation.props.label
105
+ : scope.row[column.prop]
106
+ "
107
+ :operation-index="operationIndex"
108
+ :entity="scope.row"
109
+ :editing="scope.row.$editing"
110
+ :column="column"
111
+ :row-index="scope.$index"
112
+ :is-show="operation.isShow"
113
+ :on-click="operation.onClick"
114
+ />
115
+ </span>
116
+ </span>
117
+ <span
118
+ v-else-if="
119
+ customFormatValue(
120
+ scope.row,
121
+ column.prop,
122
+ customFormat,
123
+ scope.$index
124
+ )
125
+ "
126
+ class="cell--span"
127
+ >
128
+ <component
129
+ :is="column.prop + scope.$index"
130
+ :row="scope.row"
131
+ :entity="scope.row"
132
+ :prop="column.prop"
133
+ :parent="parentFormData"
134
+ :row-index="scope.$index"
135
+ :show-value="$escapeHtml(getLabel(scope.row, scope.$index))"
136
+ :value="getCellValue(scope.row)"
137
+ :select-options="column.valueSet"
138
+ />
139
+ </span>
140
+ <!-- 自定义格式的时候 -->
141
+ <span
142
+ v-else-if="
143
+ columnFormatter !== undefined &&
144
+ columnFormatter.type !== undefined &&
145
+ columnFormatter.type === 'customControl' &&
146
+ columnFormatter.options &&
147
+ columnFormatter.options.format &&
148
+ columnFormatter.options.format !== ''
149
+ "
150
+ class="cell--span"
151
+ >
152
+ <!--:key="column.prop+'_'+scope.$index+'_'+currentPage" 为了解决子表分页时,新增自动跳转到下一页,第一条记录的自定义控件被复用,导致业务逻辑没执行 -->
153
+ <component
154
+ :is="columnFormatter.options.format"
155
+ :key="column.prop + '_' + scope.$index + '_' + currentPage"
156
+ :disabled="true"
157
+ :row="pageGridData[scope.$index]"
158
+ :entity="pageGridData[scope.$index]"
159
+ :prop="column.prop"
160
+ :parent="parentFormData"
161
+ :row-index="scope.$index"
162
+ :get-form-data="getFormData"
163
+ :get-grid-data="getTableGridData"
164
+ :show-value="
165
+ $escapeHtml(getLabel(pageGridData[scope.$index], scope.$index))
166
+ "
167
+ :value="getCellValue(pageGridData[scope.$index])"
168
+ :select-options="column.valueSet"
169
+ :grid-data="gridData"
170
+ :page-grid-data="pageGridData"
171
+ :current-page="currentPage"
172
+ /></span>
173
+ <span
174
+ v-else-if="
175
+ columnFormatter !== undefined &&
176
+ columnFormatter.type !== undefined &&
177
+ columnFormatter.type === 'secretInfo'
178
+ "
179
+ :id="column.prop + 'DomData' + scope.$index"
180
+ class="cell--span"
181
+ >
182
+ <secret-info
183
+ :entity="scope.row"
184
+ :prop="column.prop"
185
+ :value="getCellValue(scope.row)"
186
+ :table-name="tableName"
187
+ :list-code="listCode"
188
+ :page-code="pageCode"
189
+ :list-name="listName"
190
+ :field-label="$escapeHtml(label)"
191
+ />
192
+ </span>
193
+ <span v-else-if="isObjectProp(column.prop)">
194
+ <span v-if="column.componentType === 'annex'" type="primary">
195
+ <span
196
+ v-if="isShowOverflowTooltip"
197
+ :id="column.prop + 'DomData' + scope.$index"
198
+ :title="$escapeHtml(getLabel(scope.row))"
199
+ :style="{ width: cellWidth + 'px' }"
200
+ class="ellipsis cell--span"
201
+ >
202
+ <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
203
+ <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
204
+ </span>
205
+ {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
206
+ </span>
207
+ <span
208
+ v-else
209
+ :id="column.prop + 'DomData' + scope.$index"
210
+ class="cell--span"
211
+ >
212
+ <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
213
+ <el-icon class="annex-cell" @click="previewImg(scope.row)"><el-icon-zoom-in /></el-icon>
214
+ </span>
215
+ {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
216
+ </span>
217
+ </span>
218
+ <span
219
+ v-else-if="column.formatter && column.formatter.type === 'files'"
220
+ type="primary"
221
+ >
222
+ <span
223
+ v-if="isShowOverflowTooltip"
224
+ :id="column.prop + 'DomData' + scope.$index"
225
+ :title="$escapeHtml(getLabel(scope.row))"
226
+ :style="{ width: cellWidth + 'px' }"
227
+ class="ellipsis cell--span"
228
+ >
229
+ <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
230
+ <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
231
+ </span>
232
+ {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
233
+ </span>
234
+ <span
235
+ v-else
236
+ :id="column.prop + 'DomData' + scope.$index"
237
+ class="cell--span"
238
+ >
239
+ <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
240
+ <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
241
+ </span>
242
+ {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
243
+ </span>
244
+ </span>
245
+ <el-link
246
+ v-else-if="
247
+ columnFormatter !== undefined &&
248
+ columnFormatter.type !== undefined &&
249
+ columnFormatter.type === 'hyperlinks' &&
250
+ getMyHyperLinkSetting(scope.row).visible === true
251
+ "
252
+ type="primary"
253
+ @click="clickHyperLink(column, scope.row, listCode, scope.$index)"
254
+ >
255
+ <span
256
+ v-if="isShowOverflowTooltip"
257
+ :id="column.prop + 'DomData' + scope.$index"
258
+ :title="getMyHyperLinkSetting(scope.row).title"
259
+ :style="{ width: cellWidth + 'px' }"
260
+ class="ellipsis cell--span"
261
+ >{{ getMyHyperLinkSetting(scope.row).label
262
+ }}<i
263
+ v-if="getMyHyperLinkSetting(scope.row).icon"
264
+ :class="getMyHyperLinkSetting(scope.row).icon"
265
+ /></span>
266
+ <span
267
+ v-else
268
+ :id="column.prop + 'DomData' + scope.$index"
269
+ class="cell--span"
270
+ >{{ getMyHyperLinkSetting(scope.row).label
271
+ }}<i
272
+ v-if="getMyHyperLinkSetting(scope.row).icon"
273
+ :class="getMyHyperLinkSetting(scope.row).icon"
274
+ /></span>
275
+ </el-link>
276
+ <span
277
+ v-else-if="isShowOverflowTooltip"
278
+ :id="column.prop + 'DomData' + scope.$index"
279
+ :title="$escapeHtml(getLabel(scope.row))"
280
+ :style="{ width: cellWidth + 'px' }"
281
+ class="ellipsis cell--span"
282
+ >{{ $escapeHtml(getLabel(scope.row, scope.$index)) }}</span
283
+ >
284
+ <span
285
+ v-else
286
+ :id="column.prop + 'DomData' + scope.$index"
287
+ class="cell--span"
288
+ >{{ $escapeHtml(getLabel(scope.row, scope.$index)) }}</span
289
+ >
290
+ </span>
291
+ <span v-else>
292
+ <span
293
+ v-if="
294
+ column.componentType === 'annex' ||
295
+ column.componentType === 'multipartUpload'
296
+ "
297
+ type="primary"
298
+ >
299
+ <span
300
+ v-if="isShowOverflowTooltip"
301
+ :id="column.prop + 'DomData' + scope.$index"
302
+ :title="$escapeHtml(getLabel(scope.row))"
303
+ :style="{ width: cellWidth + 'px' }"
304
+ class="ellipsis cell--span"
305
+ >
306
+ <FsPreview
307
+ :label="$escapeHtml(getLabel(scope.row, scope.$index))"
308
+ :entity="scope.row"
309
+ :file-set-obj="JSON.parse(column.fileSet)"
310
+ :is-sql="isSql"
311
+ />
312
+ </span>
313
+ <span
314
+ v-else
315
+ :id="column.prop + 'DomData' + scope.$index"
316
+ class="cell--span"
317
+ >
318
+ <FsPreview
319
+ :label="$escapeHtml(getLabel(scope.row, scope.$index))"
320
+ :entity="scope.row"
321
+ :file-set-obj="JSON.parse(column.fileSet)"
322
+ :is-sql="isSql"
323
+ />
324
+ </span>
325
+ </span>
326
+ <span
327
+ v-else-if="column.formatter && column.formatter.type === 'files'"
328
+ >
329
+ <span
330
+ v-if="isShowOverflowTooltip"
331
+ :id="column.prop + 'DomData' + scope.$index"
332
+ :title="$escapeHtml(getLabel(scope.row))"
333
+ :style="{ width: cellWidth + 'px' }"
334
+ class="ellipsis cell--span"
335
+ >
336
+ <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
337
+ <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
338
+ </span>
339
+ {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
340
+ </span>
341
+ <span
342
+ v-else
343
+ :id="column.prop + 'DomData' + scope.$index"
344
+ class="cell--span"
345
+ >
346
+ <span v-if="$escapeHtml(getLabel(scope.row, scope.$index))">
347
+ <el-icon @click="previewImg(scope.row)" class="annex-cell"><el-icon-zoom-in /></el-icon>
348
+ </span>
349
+ {{ $escapeHtml(getLabel(scope.row, scope.$index)) }}
350
+ </span>
351
+ </span>
352
+ <!-- 超链接 -->
353
+ <el-link
354
+ v-else-if="
355
+ columnFormatter !== undefined &&
356
+ columnFormatter.type !== undefined &&
357
+ columnFormatter.type === 'hyperlinks' &&
358
+ getMyHyperLinkSetting(scope.row).visible === true
359
+ "
360
+ type="primary"
361
+ @click="clickHyperLink(column, scope.row, listCode, scope.$index)"
362
+ >
363
+ <span
364
+ v-if="isShowOverflowTooltip"
365
+ :id="column.prop + 'DomData' + scope.$index"
366
+ :title="$escapeHtml(getMyHyperLinkSetting(scope.row).title)"
367
+ :style="{ width: cellWidth + 'px' }"
368
+ class="ellipsis cell--span"
369
+ >{{ $escapeHtml(getMyHyperLinkSetting(scope.row).label)
370
+ }}<i
371
+ v-if="getMyHyperLinkSetting(scope.row).icon"
372
+ :class="getMyHyperLinkSetting(scope.row).icon"
373
+ /></span>
374
+ <span
375
+ v-else
376
+ :id="column.prop + 'DomData' + scope.$index"
377
+ class="cell--span"
378
+ >{{ $escapeHtml(getMyHyperLinkSetting(scope.row).label)
379
+ }}<i
380
+ v-if="getMyHyperLinkSetting(scope.row).icon"
381
+ :class="getMyHyperLinkSetting(scope.row).icon"
382
+ /></span>
383
+ </el-link>
384
+ <!-- 富文本 -->
385
+ <span
386
+ v-else-if="
387
+ column.formatter && column.formatter.type === 'richEditor'
388
+ "
389
+ >
390
+ <el-tooltip
391
+ :content="$t('superGrid.show')"
392
+ class="item"
393
+ effect="dark"
394
+ placement="top"
395
+ >
396
+ <em
397
+ class="fa fa-info-circle annex-cell"
398
+ @click="showRichEditorContent(scope.row, column, getHeader())"
399
+ />
400
+ </el-tooltip>
401
+ </span>
402
+ <span
403
+ v-else-if="column.formatter && column.formatter.type === 'icon'"
404
+ >
405
+ <i
406
+ v-if="getFormatIconSetting(formatConfig).position === 'pre'"
407
+ :class="getFormatIconSetting(formatConfig).icon"
408
+ />
409
+ <span
410
+ v-if="formatConfig.displayTextJudge"
411
+ :id="column.prop + 'DomData' + scope.$index"
412
+ class="cell--span"
413
+ >{{ $escapeHtml(getFormatIconSetting(scope.row).label) }}
414
+ </span>
415
+ <i
416
+ v-if="getFormatIconSetting(formatConfig).position === 'suf'"
417
+ :class="getFormatIconSetting(formatConfig).icon"
418
+ />
419
+ </span>
420
+ <span
421
+ v-else-if="isShowOverflowTooltip"
422
+ :id="column.prop + 'DomData' + scope.$index"
423
+ :title="getLabel(scope.row)"
424
+ :style="{ width: cellWidth + 'px' }"
425
+ style="white-space: pre"
426
+ class="ellipsis cell--span"
427
+ v-html="$escapeHtml(getLabel(scope.row, scope.$index))"
428
+ />
429
+ <span
430
+ v-else
431
+ :id="column.prop + 'DomData' + scope.$index"
432
+ class="cell--span"
433
+ >{{ $escapeHtml(getLabel(scope.row, scope.$index)) }}</span
434
+ >
435
+ </span>
436
+ </span>
437
+ </template>
438
+ </el-table-column>
439
+ <view-image-dialog
440
+ v-if="showSingleImgFlag"
441
+ :file-list="fileList"
442
+ @close="showSingleImgFlag = false"
443
+ />
444
+ <rich-editor-viewer
445
+ v-if="showRichEditorViewer"
446
+ ref="richEditorViewerRef"
447
+ @closeRichEditorContent="closeRichEditorContent"
448
+ />
449
+ </template>
450
+
451
+ <script>
452
+ import {
453
+ CirclePlus as ElIconCirclePlusOutline,
454
+ ZoomIn as ElIconZoomIn,
455
+ } from '@element-plus/icons-vue'
456
+ import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
457
+ import { getColumnValues, isRequiredEdit } from './utils'
458
+ import DynamicInput from './dynamic-input.vue'
459
+ import store from './store'
460
+ import { ArrowKeyAction, isHasEditOption, getFileList } from './utils'
461
+ import { doFormatWithValueSet } from './formatter'
462
+ import customFormatter from './custom-formatter'
463
+ import RowOperation from './row-operation.vue'
464
+ import apis from './apis'
465
+ import { mapGetters } from 'vuex'
466
+ import {
467
+ getEntityFieldValue,
468
+ getParentObjectUtil,
469
+ } from '../../../src/utils/util'
470
+ import ViewImageDialog from './view-image-dialog.vue'
471
+ import eventBus from './eventBus'
472
+ import { isDynamicDataSourceSource } from './utils'
473
+ import FsPreview from '../../fs-preview'
474
+ import RichEditorViewer from '../../rich-editor/viewer.vue'
475
+ export default {
476
+ components: {
477
+ DynamicInput,
478
+ RowOperation,
479
+ ViewImageDialog,
480
+ FsPreview,
481
+ RichEditorViewer,
482
+ ElIconCirclePlusOutline,
483
+ ElIconZoomIn,
484
+ },
485
+ name: 'NormalColumn',
486
+ props: {
487
+ column: {
488
+ type: Object,
489
+ default: null,
490
+ },
491
+ customFormat: {
492
+ type: Function,
493
+ default: null,
494
+ },
495
+ listCode: {
496
+ type: String,
497
+ default: null,
498
+ },
499
+ isSql: {
500
+ type: Boolean,
501
+ default: false,
502
+ },
503
+ newWidth: {
504
+ type: Number,
505
+ default: null,
506
+ },
507
+ dragColumnProp: {
508
+ type: String,
509
+ default: null,
510
+ },
511
+ tableName: {
512
+ type: String,
513
+ default: null,
514
+ },
515
+ pageCode: {
516
+ type: String,
517
+ default: null,
518
+ },
519
+ listName: {
520
+ type: String,
521
+ default: null,
522
+ },
523
+ currentPage: {
524
+ type: Number,
525
+ default: 1,
526
+ },
527
+ gridData: {
528
+ type: Array,
529
+ default: null,
530
+ },
531
+ pageGridData: {
532
+ type: Array,
533
+ default: null,
534
+ },
535
+ listToolbarFormData: {
536
+ type: Object,
537
+ default: null,
538
+ },
539
+ },
540
+ data() {
541
+ let parentFormData
542
+ const gridParams = store.get(this.listCode)
543
+ if (
544
+ gridParams.options.extraParam &&
545
+ gridParams.options.extraParam.entityMap
546
+ ) {
547
+ parentFormData = gridParams.options.extraParam.entityMap
548
+ }
549
+ return {
550
+ selectRow: null,
551
+ that: this,
552
+ align: 'left', // 文本内容对齐
553
+ headerAlign: 'left', // 表头对齐方式
554
+ columnFormatter: this.column.formatter,
555
+ hyperLinks: {},
556
+ fileDownType: '',
557
+ isFormSubTable: false, // 是否是表单子表
558
+ subTableCanAdd: true, // 表单子表时是否有新增权限
559
+ isShowAdd: false, // 是否显示表头的新增按钮
560
+ cellWidth: null,
561
+ parentFormData,
562
+ fileMultiple: false, // 附件上传是否多选
563
+ showSingleImgFlag: false,
564
+ singleImgSrc: '',
565
+ fileList: [],
566
+ index: null,
567
+ isEditable: this.column.editable,
568
+ showRichEditorViewer: false,
569
+ formatConfig: {},
570
+ getFormData: gridParams.options.getFormData,
571
+ getTableGridData: gridParams.options.getGridData,
572
+ }
573
+ },
574
+ computed: {
575
+ filters() {
576
+ if (this.column.filterable) {
577
+ const gridParams = store.get(this.listCode)
578
+ const values = getColumnValues(gridParams.gridData, this.column.prop)
579
+ const filters = []
580
+ for (const value of values) {
581
+ filters.push({
582
+ text: value,
583
+ value,
584
+ })
585
+ }
586
+ return filters
587
+ } else {
588
+ return null
589
+ }
590
+ },
591
+ filterMethod() {
592
+ if (this.column.filterable) {
593
+ return this.filterHandler
594
+ } else {
595
+ return null
596
+ }
597
+ },
598
+ fixed() {
599
+ if (
600
+ (this.column.fixed && this.column.fixed === 'false') ||
601
+ this.column.fixed === undefined ||
602
+ this.column.fixed === ''
603
+ ) {
604
+ return false
605
+ }
606
+ if (
607
+ this.column.prop === 'operation' &&
608
+ this.column.fixed &&
609
+ this.column.fixed === 'left'
610
+ ) {
611
+ // 操作列居右固定
612
+ return 'right'
613
+ }
614
+ return this.column.fixed
615
+ },
616
+ sortable() {
617
+ const gridParams = store.get(this.listCode)
618
+ if (
619
+ gridParams &&
620
+ gridParams.options &&
621
+ gridParams.options.isFormSubTable &&
622
+ gridParams.options.showOperationButton
623
+ ) {
624
+ return false
625
+ }
626
+ if (
627
+ this.column.sortable === 'false' ||
628
+ this.column.sortable === false ||
629
+ this.column.sortable === ''
630
+ ) {
631
+ return false
632
+ } else if (
633
+ this.column.sortable === 'true' ||
634
+ this.column.sortable === true
635
+ ) {
636
+ return 'custom'
637
+ }
638
+ if (this.column.sortable) {
639
+ return 'custom'
640
+ } else {
641
+ return false
642
+ }
643
+ },
644
+ lineEdit() {
645
+ let isLineEdit = false
646
+ if (this.listCode) {
647
+ const gridParams = store.get(this.listCode)
648
+ if (gridParams.lineEdit !== null && gridParams.lineEdit !== undefined) {
649
+ isLineEdit = gridParams.lineEdit
650
+ } else {
651
+ isLineEdit = false
652
+ }
653
+ }
654
+ return isLineEdit
655
+ },
656
+
657
+ ...mapGetters(['preventReclick']),
658
+ },
659
+ watch: {
660
+ isSql: {
661
+ deep: true,
662
+
663
+ handler(newValue, oldValue) {
664
+ this.isSql = newValue
665
+ },
666
+ },
667
+ newWidth: {
668
+ deep: true,
669
+
670
+ handler(newValue, oldValue) {
671
+ if (
672
+ newValue !== undefined &&
673
+ newValue !== null &&
674
+ this.dragColumnProp &&
675
+ this.dragColumnProp === this.column.prop
676
+ ) {
677
+ this.cellWidth = newValue
678
+ }
679
+ },
680
+ },
681
+ },
682
+ created() {
683
+ if (this.column.width) {
684
+ this.cellWidth = this.column.width - 10
685
+ }
686
+ const gridParams = store.get(this.listCode)
687
+ if (gridParams && gridParams.options && gridParams.options.isFormSubTable) {
688
+ this.isFormSubTable = gridParams.options.isFormSubTable
689
+ }
690
+ if (
691
+ gridParams &&
692
+ gridParams.options &&
693
+ gridParams.options.subTableCanAdd !== undefined &&
694
+ gridParams.options.subTableCanAdd !== null
695
+ ) {
696
+ this.subTableCanAdd = gridParams.options.subTableCanAdd
697
+ }
698
+ if (this.column.prop && this.column.prop === 'operation') {
699
+ // 如果是操作列按钮则不显示省略号
700
+ this.isShowOverflowTooltip = false
701
+ } else {
702
+ if (
703
+ typeof gridParams.options.showOverflowTooltip !== 'undefined' &&
704
+ gridParams.options.showOverflowTooltip === false
705
+ ) {
706
+ this.isShowOverflowTooltip = false
707
+ } else {
708
+ this.isShowOverflowTooltip = true
709
+ }
710
+ }
711
+ if (typeof gridParams.options.align !== 'undefined') {
712
+ this.align = gridParams.options.align
713
+ } else if (this.column.contAlign && this.column.contAlign !== '') {
714
+ this.align = this.column.contAlign
715
+ }
716
+ if (typeof gridParams.options.headerAlign !== 'undefined') {
717
+ this.headerAlign = gridParams.options.headerAlign
718
+ } else if (this.column.titleAlign && this.column.titleAlign !== '') {
719
+ this.headerAlign = this.column.titleAlign
720
+ } else {
721
+ // 如果没有配置表头对齐方式,默认使用内容对齐方式
722
+ this.headerAlign = 'left'
723
+ }
724
+ if (
725
+ gridParams.isHasDynamic === undefined &&
726
+ this.column.dynamic !== undefined &&
727
+ this.column.dynamic === true
728
+ ) {
729
+ // 当前列表中有动态列
730
+ gridParams.isHasDynamic = true
731
+ }
732
+ this.label = this.getHeader()
733
+ if (this.column.operations) {
734
+ // console.log('this.column.operations', this.column.operations)
735
+ }
736
+ // console.log('gridParams.options.subTableCanAdd=', gridParams.options.subTableCanAdd, 'this.subTableCanAdd=', this.subTableCanAdd)
737
+ this.isShowAdd =
738
+ this.isFormSubTable &&
739
+ this.column.prop === 'operation' &&
740
+ this.subTableCanAdd &&
741
+ gridParams.options &&
742
+ gridParams.options.showOperationButton
743
+ if (
744
+ this.column.fileSet &&
745
+ this.column.fileSet !== '' &&
746
+ this.column.componentType === 'annex'
747
+ ) {
748
+ const fileSetObj = JSON.parse(this.column.fileSet)
749
+ if (fileSetObj && fileSetObj.multiple) {
750
+ this.fileMultiple = true
751
+ }
752
+ }
753
+ if (
754
+ this.column.formatter &&
755
+ this.column.formatter.options &&
756
+ this.column.formatter.options.format &&
757
+ this.column.formatter.type === 'icon'
758
+
759
+ ) {
760
+
761
+ this.formatConfig = JSON.parse(this.column.formatter.options.format)
762
+ }
763
+ },
764
+ mounted() {
765
+ // 监听保存时点击按钮事件线触发
766
+ $on(eventBus, 'un-edit', (param) => {
767
+ // 处理多选选项组问题保存问题
768
+ if (
769
+ this.column.componentType &&
770
+ (this.column.componentType === 'multiselect' ||
771
+ this.column.componentType === 'select')
772
+ ) {
773
+ const isDynamic = isDynamicDataSourceSource(this.column)
774
+ if (!isDynamic) {
775
+ // 选项组保存时将数组处理为字符串
776
+ const beforeColumnValue = param.row[this.column.prop]
777
+ if (
778
+ beforeColumnValue &&
779
+ Object.prototype.toString.apply(beforeColumnValue) ===
780
+ '[object Array]'
781
+ ) {
782
+ // 如果是数组才需要转换
783
+ param.row[this.column.prop] = beforeColumnValue.join(',')
784
+ }
785
+ } else {
786
+ // 动态数据源多选保存时,获取已选择的字段,由于多选选项组的值是数组,保存时要拼接成“ ,” 分隔的字符串
787
+ if ('_dynamic-source-data-' + this.column.prop in this.column) {
788
+ const temp = this.column['_dynamic-source-data-' + this.column.prop]
789
+ const valueSetOptions = temp.valueSetOptions
790
+ // 获取当前字段对应在映射关系中对应的是动态数据源中的哪一个字段key
791
+ let selectDataKey
792
+ for (let i = 0; i < valueSetOptions.length; i++) {
793
+ const valueSetOption = valueSetOptions[i]
794
+ if (
795
+ this.column.prop === valueSetOption.valueColumn.dbColumnName
796
+ ) {
797
+ selectDataKey = valueSetOption.columnName
798
+ break
799
+ }
800
+ }
801
+ if (selectDataKey) {
802
+ // beforeColumnValue是数组值,如果是单选则是字符串
803
+ let beforeColumnValue = param.row[this.column.prop]
804
+ if (this.column.componentType === 'select') {
805
+ if (selectDataKey !== temp.valueAttribute) {
806
+ // 解决当前字段不是动态数据源选项值所映射的字段的问题 例如当前字段是工厂名称, 动态数据源选项值是工厂编码
807
+ beforeColumnValue = temp.optionItems.find(
808
+ (item) =>
809
+ // 当前字段映射的是工厂名称,
810
+ // 筛选动态数据源选项值字段对应的当前字段所映射的字段, 例如 根据工厂编码找工厂编码对应的工厂名称
811
+ // 找出名称后赋值给当前字段
812
+ item[temp.valueAttribute] === beforeColumnValue
813
+ )[selectDataKey]
814
+ }
815
+ // 如果是单选
816
+ // 现在选择时已经赋值,不再需要这里进行赋值
817
+ // temp.optionItems.forEach(optionItem => {
818
+ // if (optionItem[temp.valueAttribute] === beforeColumnValue) {
819
+ // this.$set(param.row, this.column.prop, optionItem[selectDataKey])
820
+ // }
821
+ // })
822
+ param.row[this.column.prop] = beforeColumnValue
823
+ } else {
824
+ // 如果是多选,join “ ,” , 并给row赋值
825
+ // 现在选择时已经赋值,不再需要这里进行赋值
826
+ // const afterColumnValue = []
827
+ // temp.optionItems.forEach(optionItem => {
828
+ // beforeColumnValue.forEach(value => {
829
+ // if (optionItem[temp.valueAttribute] === value) {
830
+ // afterColumnValue.push(optionItem[selectDataKey])
831
+ // }
832
+ // })
833
+ // })
834
+ if (
835
+ beforeColumnValue &&
836
+ selectDataKey !== temp.valueAttribute
837
+ ) {
838
+ // 解决当前字段不是动态数据源选项值所映射的字段的问题 例如当前字段是工厂名称, 动态数据源选项值是工厂编码
839
+ const t = []
840
+ beforeColumnValue.forEach((selectItem) => {
841
+ if (selectDataKey !== temp.valueAttribute) {
842
+ t.push(
843
+ temp.optionItems.find(
844
+ (option) => option[temp.valueAttribute] === selectItem
845
+ )[selectDataKey]
846
+ )
847
+ }
848
+ })
849
+ beforeColumnValue = t
850
+ }
851
+ param.row[this.column.prop] = beforeColumnValue.join(',')
852
+ }
853
+ }
854
+ } else {
855
+ const beforeColumnValue = param.row[this.column.prop]
856
+ if (
857
+ beforeColumnValue &&
858
+ Object.prototype.toString.apply(beforeColumnValue) ===
859
+ '[object Array]'
860
+ ) {
861
+ // 如果是数组才需要转换
862
+ param.row[this.column.prop] = beforeColumnValue.join(',')
863
+ }
864
+ }
865
+ }
866
+ }
867
+ })
868
+ },
869
+ unmounted() {
870
+ $off(eventBus, 'un-edit')
871
+ },
872
+ methods: {
873
+ ...customFormatter,
874
+ ...apis,
875
+ getHeader() {
876
+ if (!this.column.titleValueSet) {
877
+ return this.column.label.replace(/\\n/g, '</br>')
878
+ } else {
879
+ return this.formatHeader()
880
+ }
881
+ },
882
+ formatHeader() {
883
+ return doFormatWithValueSet(
884
+ this.column.titleValueSetValue,
885
+ this.column.label
886
+ )
887
+ },
888
+ filterHandler(value, row, column) {
889
+ const property = column['property']
890
+ return row[property] === value
891
+ },
892
+ onFocus(index) {
893
+ const gridParams = store.get(this.listCode)
894
+ if (gridParams.lineEdit.editingCell) {
895
+ gridParams.lineEdit.editingCell.row = index
896
+ gridParams.lineEdit.editingCell.prop = this.column.prop
897
+ }
898
+ },
899
+ findIndex(index) {
900
+ this.index = index
901
+ const gridParams = store.get(this.listCode)
902
+ if (gridParams.lineEdit.editingCell) {
903
+ gridParams.lineEdit.editingCell.row = index
904
+ gridParams.lineEdit.editingCell.prop = this.column.prop
905
+ }
906
+ },
907
+ refresData(data) {
908
+ $emit(this, 'refresData', data)
909
+ },
910
+ refresPortData(port, value) {
911
+ const gridParams = store.get(this.listCode)
912
+ console.log('gridParams', gridParams)
913
+ console.log('this.index', this.index)
914
+ if (
915
+ gridParams &&
916
+ gridParams.lineEdit &&
917
+ gridParams.lineEdit.editingCell
918
+ ) {
919
+ $emit(
920
+ this,
921
+ 'refresPortData',
922
+ port,
923
+ value,
924
+ gridParams.lineEdit.editingCell.row
925
+ )
926
+ } else {
927
+ $emit(this, 'refresPortData', port, value, this.index)
928
+ }
929
+ },
930
+ refresPortsData(map) {
931
+ const gridParams = store.get(this.listCode)
932
+ console.log('gridParams', gridParams)
933
+ console.log('this.index', this.index)
934
+ if (
935
+ gridParams &&
936
+ gridParams.lineEdit &&
937
+ gridParams.lineEdit.editingCell
938
+ ) {
939
+ $emit(this, 'refresPortsData', map, gridParams.lineEdit.editingCell.row)
940
+ } else {
941
+ $emit(this, 'refresPortsData', map, this.index)
942
+ }
943
+ },
944
+ refresMainTableFields(map) {
945
+ $emit(this, 'refresMainTableFields', map)
946
+ },
947
+ // @keyup.native.left="move('left')"
948
+ // @keyup.native.right="move('right')"
949
+ // @keyup.native.up="move('up')"
950
+ // @keyup.native.down="move('down')"
951
+ move(direction) {
952
+ if (direction === 'left') {
953
+ const prop = ArrowKeyAction.getLeftColumn(this.column.prop)
954
+ const gridParams = store.get(this.listCode)
955
+ gridParams.lineEdit.editingCell.prop = prop
956
+ }
957
+ },
958
+ // filterHandler(value, row, column) {
959
+ // const property = column['property']
960
+ // return row[property] === value
961
+ // },
962
+ isSaveByEnter() {
963
+ const gridParams = store.get(this.listCode)
964
+ return (
965
+ typeof gridParams.options.lineEditOptions.isSaveByEnter ===
966
+ 'undefined' ||
967
+ (isHasEditOption('isSaveByEnter', this.listCode) &&
968
+ gridParams.options.lineEditOptions.isSaveByEnter === true)
969
+ )
970
+ },
971
+ isRestoreByEsc() {
972
+ const gridParams = store.get(this.listCode)
973
+ return (
974
+ typeof gridParams.options.lineEditOptions.isRestoreByEsc ===
975
+ 'undefined' ||
976
+ (isHasEditOption('isRestoreByEsc', this.listCode) &&
977
+ gridParams.options.lineEditOptions.isRestoreByEsc === true)
978
+ )
979
+ },
980
+ canFocus(index) {
981
+ const gridParams = store.get(this.listCode)
982
+ if (
983
+ index === gridParams.lineEdit.editingCell.row &&
984
+ this.column.prop === gridParams.lineEdit.editingCell.prop
985
+ ) {
986
+ return true
987
+ } else {
988
+ return false
989
+ }
990
+ },
991
+ getLabel(row, index) {
992
+ this.transferColumnDataToUpperCase(row)
993
+ const obj = this.objectPropValueTwo(row, this.column)
994
+ // // 存储执行时间
995
+ // const get2 = new Date().getTime()
996
+ // const get3 = Number(get2) - Number(get1)
997
+ // if (!window.sessionStorage.getItem('getLabel')) {
998
+ // window.sessionStorage.setItem('getLabel', get3)
999
+ // } else {
1000
+ // const get4 = window.sessionStorage.getItem('getLabel')
1001
+ // const get5 = Number(get4) + Number(get3)
1002
+ // window.sessionStorage.setItem('getLabel', get5)
1003
+ // }
1004
+ return obj
1005
+ // const returnValue = this.objectPropValueTwo(row, this.column)
1006
+ // if (returnValue) {
1007
+ // // 解决当文本中有多个空格时候, vue自动将多个空格合并为一个空格,
1008
+ // // 或者修改vue的配置 https://cn.vuejs.org/api/application.html#app-config-compileroptions app.config.compilerOptions.whitespace
1009
+ // return returnValue.replaceAll(' ', '\u00A0')
1010
+ // }
1011
+ // return returnValue
1012
+ },
1013
+ getCellValue(row) {
1014
+ let cellValue = getEntityFieldValue(row, this.column.prop, false)
1015
+ if (cellValue === undefined || cellValue === null) {
1016
+ this.transferColumnDataToUpperCase(row)
1017
+ cellValue = getEntityFieldValue(row, this.column.prop, false)
1018
+ }
1019
+ return cellValue
1020
+ },
1021
+ // 兼容oracle和mysql数据库,oracle是字段名是大写的,mysql是小写的,将小写转为大写
1022
+ transferColumnDataToUpperCase(row) {
1023
+ const reg1 = /[A-Z]+/ // 大写字母
1024
+ if (this.isSql && reg1.test(this.column.prop)) {
1025
+ this.transferColumnDataToUpperCaseWithProp(
1026
+ row,
1027
+ this.column.prop.toLowerCase(),
1028
+ this.column.prop
1029
+ )
1030
+ }
1031
+ },
1032
+ transferColumnDataToUpperCaseWithProp(row, propLowerCase, columnProp) {
1033
+ let dataModel
1034
+ if (propLowerCase && propLowerCase.indexOf('.') > 0) {
1035
+ const parentObj = getParentObjectUtil(propLowerCase, row)
1036
+ const prop = propLowerCase.substring(propLowerCase.lastIndexOf('.') + 1)
1037
+ dataModel = parentObj[prop]
1038
+ if (dataModel !== undefined) {
1039
+ // sql字段名小写转大写,兼容mysql、oracle数据库
1040
+ parentObj[columnProp] = dataModel
1041
+ delete parentObj[prop]
1042
+ }
1043
+ } else {
1044
+ dataModel = row[propLowerCase]
1045
+ if (dataModel !== undefined) {
1046
+ // sql字段名小写转大写,兼容mysql、oracle数据库
1047
+ row[columnProp] = dataModel
1048
+ delete row[propLowerCase]
1049
+ }
1050
+ }
1051
+ return dataModel
1052
+ },
1053
+ getMyHyperLinkSetting(row) {
1054
+ this.transferColumnDataToUpperCase(row)
1055
+ const gridParams = store.get(this.listCode)
1056
+ let tableName
1057
+ if (
1058
+ gridParams &&
1059
+ gridParams.basicInfo &&
1060
+ gridParams.basicInfo.tableName
1061
+ ) {
1062
+ tableName = gridParams.basicInfo.tableName
1063
+ }
1064
+ const hyperLinkResult = this.getHyperLinkSetting(
1065
+ this.column,
1066
+ row,
1067
+ this.isSql,
1068
+ gridParams.additionalParamMap,
1069
+ gridParams.contextParameter,
1070
+ tableName,
1071
+ this.listCode
1072
+ )
1073
+ hyperLinkResult.icon = this.getHyperIconClass(hyperLinkResult)
1074
+ return hyperLinkResult
1075
+ },
1076
+ getHyperIconClass(hyperLinkResult) {
1077
+ let iconName
1078
+ if (
1079
+ hyperLinkResult &&
1080
+ hyperLinkResult !== null &&
1081
+ hyperLinkResult.icon &&
1082
+ hyperLinkResult.icon !== ''
1083
+ ) {
1084
+ iconName = hyperLinkResult.icon
1085
+ }
1086
+ if (iconName && iconName.indexOf('fa-') === 0) {
1087
+ // 表示以“fa-”开头,使用font-awesome中的图标
1088
+ iconName = 'fa ' + iconName
1089
+ }
1090
+ return iconName
1091
+ },
1092
+ createFormSubTableRow() {
1093
+ console.log('触发了行新建')
1094
+ this.createRow(this.listCode)
1095
+ },
1096
+ handleCommand(comman) {
1097
+ let prop = null
1098
+ this.column.operations.forEach((item) => {
1099
+ if (item.isGroup) {
1100
+ item.buttons.forEach((button) => {
1101
+ if (button.props.code === comman.comman) {
1102
+ prop = button
1103
+ }
1104
+ })
1105
+ }
1106
+ })
1107
+ if (prop) {
1108
+ customFormatter.onClickFun(
1109
+ comman.row,
1110
+ this.column,
1111
+ prop.onClick,
1112
+ comman.rowIndex
1113
+ )
1114
+ }
1115
+ },
1116
+ beforeHandleCommand(comman, row, rowIndex) {
1117
+ return {
1118
+ comman: comman,
1119
+ row: row,
1120
+ rowIndex: rowIndex,
1121
+ }
1122
+ },
1123
+ previewImg(row) {
1124
+ this.fileList = getFileList(row, this.column, this.isSql)
1125
+ this.showSingleImgFlag = true
1126
+ },
1127
+ getFileList(row) {
1128
+ return getFileList(row, this.column, this.isSql)
1129
+ },
1130
+ getColumnWidth() {
1131
+ if (
1132
+ this.column &&
1133
+ this.column.prop === 'operation' &&
1134
+ !this.column.width
1135
+ ) {
1136
+ // 表示操作列,宽度固定
1137
+ return '210'
1138
+ }
1139
+ return this.column.width ? this.column.width + '' : '130'
1140
+ },
1141
+ // 设置字段禁止编辑
1142
+ fnProhibitToEdit(isEditable) {
1143
+ this.isEditable = isEditable
1144
+ },
1145
+ // 设置字段禁止编辑
1146
+ prohibitToEdit(entity) {
1147
+ $emit(this, 'prohibitToEdit', entity)
1148
+ },
1149
+ isFieldRequired() {
1150
+ return isRequiredEdit(this.column, this.listCode)
1151
+ // return true
1152
+ },
1153
+ // 展示富文本内容
1154
+ showRichEditorContent(row, column, header) {
1155
+ this.showRichEditorViewer = true
1156
+ this.$nextTick(() => {
1157
+ this.$refs.richEditorViewerRef.showContent(row[column.prop], header)
1158
+ })
1159
+ },
1160
+ closeRichEditorContent() {
1161
+ this.showRichEditorViewer = false
1162
+ },
1163
+ isRequired(editing) {
1164
+ if (
1165
+ !this.isFormSubTable &&
1166
+ this.lineEdit.editable &&
1167
+ this.isEditable &&
1168
+ editing &&
1169
+ this.column.validations
1170
+ ) {
1171
+ if (this.column.validations.indexOf('"required":true') > 0) {
1172
+ return true
1173
+ }
1174
+ }
1175
+ return false
1176
+ },
1177
+ getFormatIconSetting(row) {
1178
+ this.transferColumnDataToUpperCase(row)
1179
+ const gridParams = store.get(this.listCode)
1180
+ const result = this.getIconSetting(
1181
+ this.column,
1182
+ row,
1183
+ this.isSql,
1184
+ gridParams,
1185
+ this.listCode
1186
+ )
1187
+ result.icon = this.getHyperIconClass(result)
1188
+ if (
1189
+ this.column.formatter.options &&
1190
+ this.column.formatter.options.format
1191
+ ) {
1192
+ result.position = JSON.parse(
1193
+ this.column.formatter.options.format
1194
+ ).position
1195
+ }
1196
+ return result
1197
+ },
1198
+ },
1199
+ emits: [
1200
+ 'refresData',
1201
+ 'refresPortData',
1202
+ 'refresPortsData',
1203
+ 'refresMainTableFields',
1204
+ 'prohibitToEdit',
1205
+ ,
1206
+ ],
1207
+ }
1208
+ </script>
1209
+
1210
+ <style lang="scss" scoped>
1211
+ .annex-cell {
1212
+ padding-right: 5px;
1213
+ cursor: pointer;
1214
+ color: #409eff;
1215
+ }
1216
+ .m-requried {
1217
+ float: left;
1218
+ white-space: nowrap;
1219
+ }
1220
+ .m-requried::after {
1221
+ content: '*';
1222
+ color: #f56c6c;
1223
+ }
1224
+ </style>