agilebuilder-ui 1.0.85 → 1.0.87-temp1

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