agilebuilder-ui 1.0.84 → 1.0.85-temp2

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