bri-components 1.4.93 → 1.4.94

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 (156) hide show
  1. package/README.md +83 -83
  2. package/lib/0.bri-components.min.js +1 -0
  3. package/lib/1.bri-components.min.js +1 -0
  4. package/lib/10.bri-components.min.js +1 -0
  5. package/lib/11.bri-components.min.js +1 -0
  6. package/lib/2.bri-components.min.js +1 -0
  7. package/lib/3.bri-components.min.js +1 -0
  8. package/lib/4.bri-components.min.js +1 -0
  9. package/lib/5.bri-components.min.js +1 -0
  10. package/lib/6.bri-components.min.js +1 -0
  11. package/lib/7.bri-components.min.js +1 -0
  12. package/lib/8.bri-components.min.js +1 -0
  13. package/lib/9.bri-components.min.js +1 -0
  14. package/lib/bri-components.min.js +18 -0
  15. package/lib/styles/bundle.css +12 -12
  16. package/lib/styles/font/fontello.svg +31 -31
  17. package/package.json +125 -125
  18. package/src/.DS_Store +0 -0
  19. package/src/components/.DS_Store +0 -0
  20. package/src/components/Error/Error403.vue +42 -42
  21. package/src/components/Error/Error404.vue +40 -40
  22. package/src/components/Error/Error500.vue +51 -51
  23. package/src/components/Error/error.less +162 -162
  24. package/src/components/Error/errorBack.vue +40 -40
  25. package/src/components/controls/.DS_Store +0 -0
  26. package/src/components/controls/DshControlInput.vue +195 -195
  27. package/src/components/controls/base/BriUpload/BriUpload.vue +434 -434
  28. package/src/components/controls/base/BriUpload/BriUploadImage.vue +373 -373
  29. package/src/components/controls/base/BriUpload/uploadList.vue +724 -724
  30. package/src/components/controls/base/BriUpload/uploadMixin.js +446 -446
  31. package/src/components/controls/base/DshCascader/DshCascader.vue +210 -210
  32. package/src/components/controls/base/DshCascader/components/cascaderModal.vue +366 -366
  33. package/src/components/controls/base/DshCascader/components/cascaderPicker.vue +416 -416
  34. package/src/components/controls/base/DshCascader/components/cascaderSimple.vue +143 -143
  35. package/src/components/controls/base/DshCoordinates.vue +577 -577
  36. package/src/components/controls/base/DshDate/DshDate.vue +191 -191
  37. package/src/components/controls/base/DshDate/DshDaterange.vue +186 -186
  38. package/src/components/controls/base/DshDivider.vue +201 -201
  39. package/src/components/controls/base/DshEditor.vue +274 -274
  40. package/src/components/controls/base/DshInput/BriInputs.vue +166 -166
  41. package/src/components/controls/base/DshInput/DshInput.vue +255 -255
  42. package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +435 -435
  43. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -34
  44. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -14
  45. package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -322
  46. package/src/components/controls/base/DshNumber/DshNumber.vue +143 -143
  47. package/src/components/controls/base/DshNumber/DshNumberange.vue +109 -109
  48. package/src/components/controls/base/DshSelect/DshCheckbox.vue +168 -168
  49. package/src/components/controls/base/DshSelect/DshSelect.vue +180 -180
  50. package/src/components/controls/base/DshSwitch/DshSwitch.vue +115 -115
  51. package/src/components/controls/control.less +324 -324
  52. package/src/components/controls/controlMap.js +114 -114
  53. package/src/components/controls/extra/DshColor.vue +81 -81
  54. package/src/components/controls/extra/themeColor.vue +104 -104
  55. package/src/components/controls/extra/themeIcon.vue +114 -114
  56. package/src/components/controls/mixins/cascaderMixin.js +295 -295
  57. package/src/components/controls/mixins/cascaderPickerMixin.js +216 -216
  58. package/src/components/controls/mixins/cascaderTableMixin.js +130 -130
  59. package/src/components/controls/mixins/controlMixin.js +368 -368
  60. package/src/components/controls/mixins/dateMixin.js +149 -149
  61. package/src/components/controls/mixins/flatTableMixin.js +111 -111
  62. package/src/components/controls/mixins/numberMixin.js +112 -112
  63. package/src/components/controls/mixins/selectMixin.js +233 -233
  64. package/src/components/controls/mixins/switchMixin.js +87 -87
  65. package/src/components/controls/mixins/userAndDepartMixin.js +218 -218
  66. package/src/components/controls/senior/.DS_Store +0 -0
  67. package/src/components/controls/senior/DshLabels.vue +331 -331
  68. package/src/components/controls/senior/DshPackage.vue +57 -57
  69. package/src/components/controls/senior/cascaderTable.vue +210 -210
  70. package/src/components/controls/senior/flatTable.vue +135 -135
  71. package/src/components/controls/senior/selectDepartments.vue +438 -438
  72. package/src/components/controls/senior/selectUsers/departMenu.vue +293 -293
  73. package/src/components/controls/senior/selectUsers/selectUsers.vue +752 -752
  74. package/src/components/controls/special/DshBack.vue +42 -42
  75. package/src/components/controls/special/DshUndeveloped.vue +41 -41
  76. package/src/components/form/DshAdvSearch.vue +510 -510
  77. package/src/components/form/DshDefaultSearch.vue +258 -258
  78. package/src/components/form/DshForm.vue +494 -494
  79. package/src/components/form/searchMixin.js +375 -375
  80. package/src/components/list/BriCard.vue +95 -95
  81. package/src/components/list/BriTable.vue +205 -205
  82. package/src/components/list/BriTree.vue +529 -529
  83. package/src/components/list/BriTreeItem.vue +163 -163
  84. package/src/components/list/DshBox/DshBox.vue +219 -219
  85. package/src/components/list/DshBox/DshCard.vue +446 -446
  86. package/src/components/list/DshBox/DshCrossTable.vue +827 -827
  87. package/src/components/list/DshBox/DshList.vue +404 -404
  88. package/src/components/list/DshBox/DshPanel.vue +669 -669
  89. package/src/components/list/DshBox/DshSingleData.vue +119 -119
  90. package/src/components/list/DshBox/DshTable.vue +239 -239
  91. package/src/components/list/DshCascaderTable.vue +115 -115
  92. package/src/components/list/DshFlatTable.vue +339 -339
  93. package/src/components/list/DshPage.vue +194 -194
  94. package/src/components/list/DshTreeTable.vue +113 -113
  95. package/src/components/list/common/importModal.vue +243 -243
  96. package/src/components/list/common/quoteListModal.vue +206 -206
  97. package/src/components/list/mixins/DshCascaderTableMixin.js +278 -278
  98. package/src/components/list/mixins/DshFlatTableMixin.js +493 -493
  99. package/src/components/list/mixins/DshTreeTableMixin.js +286 -286
  100. package/src/components/list/mixins/tableBaseMixin.js +1661 -1661
  101. package/src/components/list/mixins/treeTableBaseMixin.js +149 -149
  102. package/src/components/other/BriAvatar.vue +166 -166
  103. package/src/components/other/BriCode.vue +125 -125
  104. package/src/components/other/BriCollapseTree.vue +207 -207
  105. package/src/components/other/BriGantt.vue +1084 -1084
  106. package/src/components/other/BriIframe.vue +116 -116
  107. package/src/components/other/BriLoading.vue +171 -171
  108. package/src/components/other/BriSvg.vue +28 -28
  109. package/src/components/other/DshColorPanel.vue +128 -128
  110. package/src/components/other/DshMenuNav.vue +188 -188
  111. package/src/components/small/BriButton.vue +71 -71
  112. package/src/components/small/BriDrawer.vue +169 -169
  113. package/src/components/small/BriTooltip.vue +87 -87
  114. package/src/components/small/DshBtnModal.vue +68 -68
  115. package/src/components/small/DshButtons.vue +324 -324
  116. package/src/components/small/DshDropdown.vue +225 -225
  117. package/src/components/small/DshIcons.vue +59 -59
  118. package/src/components/small/DshListRender.js +21 -21
  119. package/src/components/small/DshModal.vue +160 -160
  120. package/src/components/small/DshSteps.vue +141 -141
  121. package/src/components/small/DshTabs.vue +598 -598
  122. package/src/components/small/DshTabsSet.vue +309 -309
  123. package/src/components/small/DshTags.vue +251 -251
  124. package/src/components/small/DshTitle.vue +50 -50
  125. package/src/components/small/render.js +20 -20
  126. package/src/components/unit/DshFormUnit.vue +398 -398
  127. package/src/components/unit/DshListUnit.vue +115 -115
  128. package/src/components/unit/unitMixin.js +86 -86
  129. package/src/data/index.js +9 -9
  130. package/src/index.js +271 -271
  131. package/src/styles/.DS_Store +0 -0
  132. package/src/styles/bundle.css +12 -12
  133. package/src/styles/components/.DS_Store +0 -0
  134. package/src/styles/components/BriButton.less +292 -292
  135. package/src/styles/components/BriTable.less +344 -344
  136. package/src/styles/components/DshModal.less +257 -250
  137. package/src/styles/components/index.less +3 -3
  138. package/src/styles/global/animate.less +11 -11
  139. package/src/styles/global/base.less +45 -45
  140. package/src/styles/global/box.less +186 -186
  141. package/src/styles/global/control.less +122 -122
  142. package/src/styles/global/flex.less +282 -282
  143. package/src/styles/global/global.less +8 -8
  144. package/src/styles/global/text.less +59 -59
  145. package/src/styles/global/variables.less +85 -85
  146. package/src/styles/iconfont/iconfont.css +254 -254
  147. package/src/styles/iconfont/iconfont.json +422 -422
  148. package/src/styles/iconfont/iconfont.svg +137 -137
  149. package/src/styles/index.less +11 -11
  150. package/src/styles/reset-easytable.less +21 -21
  151. package/src/styles/reset-iview-controls.less +145 -145
  152. package/src/styles/reset-iview-other.less +49 -49
  153. package/src/styles/reset-iview-variables.less +34 -34
  154. package/src/styles/reset.less +45 -45
  155. package/src/utils/index.js +5 -5
  156. package/src/utils/table.js +175 -175
@@ -1,1661 +1,1661 @@
1
- import DshListUnit from "../../unit/DshListUnit.vue";
2
- import importModal from "../common/importModal.vue";
3
- import quoteListModal from "../common/quoteListModal.vue";
4
-
5
- export default {
6
- mixins: [],
7
- components: {
8
- DshListUnit,
9
- importModal,
10
- quoteListModal
11
- },
12
- props: {
13
- canEdit: {
14
- type: Boolean,
15
- default: true
16
- },
17
- tableDataObj: {
18
- type: Object,
19
- default () {
20
- return {};
21
- }
22
- },
23
- data: {
24
- type: Array,
25
- default () {
26
- return [];
27
- }
28
- },
29
- rowDefault: {
30
- type: Object,
31
- default () {
32
- return {};
33
- }
34
- },
35
- columns: {
36
- type: Array,
37
- default () {
38
- return [];
39
- }
40
- },
41
- propsObj: {
42
- type: Object,
43
- default () {
44
- return {};
45
- }
46
- },
47
-
48
- parentObj: {
49
- type: Object,
50
- default () {
51
- return {};
52
- }
53
- },
54
- parentFormList: {
55
- type: Array,
56
- default () {
57
- return [];
58
- }
59
- }
60
-
61
- // compareData: {
62
- // type: Array,
63
- // default () {
64
- // return [];
65
- // }
66
- // }
67
- },
68
- data () {
69
- return {
70
- widthMap: this.$getModFieldPropertyMap("width"),
71
- dftInitValMap: this.$getModFieldPropertyMap("initDefaultVal"),
72
- // saveProperties: ["__readonly__", "__isDefault__", "__old__", "__isQuote__"],
73
- // resetProperties: ["__treeIndex__", "__isExpand__", "__isShow__", "__isTmpShow__"],
74
- resetProperties: ["__treeIndex__", "__isExpand__", "__isShow__", "__isTmpShow__", "__isSearchShow__", "__isRendered__"],
75
-
76
- initFlag: true,
77
- isExpandAction: false,
78
- // showRuleMessage: false, // 进行全体校验
79
-
80
- idRecordMap: {}, // 默认id转换映射
81
- // hoverRecordMap: {},
82
- ruleRecordMap: {}, // 单元格是否发生校验的记录映射
83
-
84
- showTopSearch: true,
85
- selfLogicPropsObj: {
86
- _name: "逻辑",
87
- _key: "logic",
88
- _optionKind: "flat",
89
- _clearable: false,
90
- _data: [
91
- { _key: "and", name: "且" },
92
- { _key: "or", name: "或" }
93
- ]
94
- },
95
- dftAdvSearch: {
96
- logic: "and",
97
- conditions: []
98
- },
99
-
100
- isLoading: false,
101
- selectIds: [],
102
-
103
- dshRenderName: undefined,
104
- hideStatus: true,
105
- showQuoteModal: false,
106
- showImportModal: false,
107
- exportTimer: null,
108
- isEnlarge: false,
109
- isEnlargeFlag: false, // 为重渲染膜态框内容而用
110
-
111
- baseOperationMap: {
112
- canCreate: {
113
- name: "添加一行",
114
- tip: "添加一行",
115
- type: "canCreate",
116
- btnType: "default",
117
- icon: "md-add",
118
- size: "default",
119
- long: true,
120
- disabled: false,
121
- event: "clickCreate"
122
- },
123
- canInsert: {
124
- name: "插入一行",
125
- tip: "插入一行",
126
- type: "canInsert",
127
- btnType: "primaryText",
128
- icon: "md-add",
129
- size: "small",
130
- disabled: false,
131
- event: "clickCreate"
132
- },
133
- canDelete: {
134
- name: "删除",
135
- tip: "删除该行",
136
- type: "canDelete",
137
- btnType: "errorText",
138
- icon: "md-trash",
139
- size: "small",
140
- color: "#E83636",
141
- disabled: false,
142
- event: "clickDelete"
143
- }
144
- },
145
- otherOperationMap: {
146
- canQuickChangeVal: {
147
- name: "立即改变值事件",
148
- type: "canQuickChangeVal",
149
- event: "quickChangeVal"
150
- },
151
- canChangeVal: {
152
- name: "改变值事件",
153
- type: "canChangeVal",
154
- event: "changeVal"
155
- }
156
- },
157
- topOperationMap: {
158
- canHideOrShow: {
159
- name: "显示/隐藏字段",
160
- type: "canHideOrShow",
161
- // icon: "md-share-alt",
162
- size: "small",
163
- btnType: "text",
164
- event: "toggleHideOrShow"
165
- },
166
- canQuote: {
167
- name: "引用",
168
- type: "canQuote",
169
- icon: "ios-copy",
170
- size: "small",
171
- btnType: "text",
172
- event: "clickQuote"
173
- },
174
- canImport: {
175
- name: "导入",
176
- type: "canImport",
177
- icon: "ios-create-outline",
178
- size: "small",
179
- btnType: "text",
180
- event: "clickImport"
181
- },
182
- canExport: {
183
- name: "导出",
184
- type: "canExport",
185
- icon: "md-share-alt",
186
- size: "small",
187
- btnType: "text",
188
- event: "clickExport"
189
- },
190
- canEnlarge: {
191
- name: "全屏",
192
- type: "canEnlarge",
193
- icon: "md-expand",
194
- size: "small",
195
- btnType: "text",
196
- event: "clickEnlarge"
197
- }
198
- }
199
- };
200
- },
201
- computed: {
202
- appObj () {
203
- return this.$store.getters.appObj || {};
204
- },
205
- appColor () {
206
- return ((this.$appData.themeColors || {})[this.appObj.colorType] || {}).color || "#3DB8C5";
207
- },
208
-
209
- dshRender () {
210
- return this[this.dshRenderName];
211
- },
212
- controlKey () {
213
- return this.propsObj._key;
214
- },
215
- // 是否在字段默认值设置里使用
216
- isDftSet () {
217
- return this.controlKey === "_default";
218
- },
219
- controlType () {
220
- return this.propsObj._type;
221
- },
222
- controlName () {
223
- return this.propsObj._name;
224
- },
225
- modKey () {
226
- return this.propsObj.modKey;
227
- },
228
- screenKey () {
229
- return this.propsObj.screenKey;
230
- },
231
- allScreenKey () {
232
- return this.propsObj.allScreenKey;
233
- },
234
- flowInstId () {
235
- return this.propsObj.flowInstId;
236
- },
237
-
238
- commonPropsObj () {
239
- return {
240
- // isShare: false, // 是否是分享页在用
241
- _subType: "default", // "default", "cross", "old"
242
- _showMode: "default", // "default", "form"
243
-
244
- _showRequired: true, // 表头显示校验符号*
245
- _showDescription: true, // 表头显示提示
246
- _contentHeight: 500, // 表格最大高度
247
- _headHeightAuto: false, // 表头高度自适应
248
- _heightAuto: false, // 单元格高度自适应
249
- _useIndex: true, // 使用序号列
250
- _useSummary: false, // 使用汇总行
251
- _noborderColKeys: [], // 无边线的列
252
- _bgColKeys: [], // 带背景色的列
253
-
254
- _disabledBtns: false, // 禁用增删按钮
255
- _showCreateBtnColKeys: [], // 显示增删图标的列
256
- _useInsertInOperationCol: false, // 操作列出现插入行按钮
257
- _disabledFootCreateBtn: false, // 禁用底部新增按钮
258
- _disabledDeleteDftRow: false, // 默认的数据行禁止删除
259
- _disabledDeleteOldRow: false, // 保存的数据行禁止删除
260
- _dftReadonly: false, // 默认的数据只读
261
- _dftReadonlyColKeys: [], // 默认的数据只读的列
262
- _oldReadonly: false, // 保存的数据只读
263
- _oldReadonlyColKeys: [], // 保存的数据只读的列
264
-
265
- _searchList: [], // 作为搜索的字段
266
- _searchLabelWidth: 100, // 搜索的label宽度
267
- _tableAdvSearch: {
268
- logic: "and",
269
- conditions: []
270
- }, // 筛选默认值(cascaderTable和flatTable组件里默认值情使用时,以及modSetForm里,会重置_tableAdvSearch)
271
-
272
- _showOrHideColKeys: [], // 联动隐藏字段的keys
273
- _showByNumFieldKey: "", // 控制联动隐藏字段的外层字段
274
- _hideColKeys: [], // 隐藏/查看列字段的keys
275
- _isQuote: false, // 引用
276
- _quoteDisabledColKeys: [], // 引用数据行不可编辑列
277
- _quoteListFields: [], // 引用列表的显示字段
278
- _quoteAdvSearch: {
279
- logic: "and",
280
- conditions: []
281
- }, // 引用列表筛选条件
282
- _isImport: false, // 导入
283
- _importAsDft: false, // 导入的数据作为默认数据
284
- _isExport: false, // 导出
285
- _useEnlarge: true, // 全屏
286
-
287
- _default: {
288
- rowDefault: {},
289
- list: [],
290
- tree: []
291
- },
292
- ...(this.selfBasePropsObj || {}),
293
-
294
- ...this.propsObj
295
- };
296
- },
297
- selfPropsObj () {
298
- return {
299
- ...this.commonPropsObj
300
- };
301
- },
302
- // isShare () {
303
- // return this.selfPropsObj.isShare;
304
- // },
305
- subType () {
306
- return this.selfPropsObj._subType;
307
- },
308
- showMode () {
309
- return this.selfPropsObj._showMode;
310
- },
311
- inTableType () {
312
- return ["cascaderTable"].includes(this.controlType) && !["old"].includes(this.subType)
313
- ? "treeTable"
314
- : this.controlType;
315
- },
316
-
317
- contentHeight () {
318
- return this.selfPropsObj._contentHeight === undefined
319
- ? undefined
320
- : this.selfPropsObj._contentHeight || 500;
321
- },
322
- showRequired () {
323
- return this.selfPropsObj._showRequired;
324
- },
325
- showDescription () {
326
- return this.selfPropsObj._showDescription;
327
- },
328
- headHeightAuto () {
329
- return this.selfPropsObj._headHeightAuto;
330
- },
331
- heightAuto () {
332
- return this.selfPropsObj._heightAuto;
333
- },
334
- useIndex () {
335
- return this.selfPropsObj._useIndex;
336
- },
337
- useSummary () {
338
- return this.selfPropsObj._useSummary;
339
- },
340
- noborderColKeys () {
341
- return this.selfPropsObj._noborderColKeys;
342
- },
343
- bgColKeys () {
344
- return this.selfPropsObj._bgColKeys;
345
- },
346
-
347
- disabledBtns () {
348
- return this.isDftSet ? false : this.selfPropsObj._disabledBtns;
349
- },
350
- showCreateBtnColKeys () {
351
- return this.selfPropsObj._showCreateBtnColKeys || []; // 配置端有问题,高级依赖时值成undefined了
352
- },
353
- useInsertInOperationCol () {
354
- return this.selfPropsObj._useInsertInOperationCol;
355
- },
356
- disabledFootCreateBtn () {
357
- return this.isDftSet ? false : this.selfPropsObj._disabledFootCreateBtn;
358
- },
359
- disabledDeleteDftRow () {
360
- return this.isDftSet ? false : this.selfPropsObj._disabledDeleteDftRow;
361
- },
362
- disabledDeleteOldRow () {
363
- return this.isDftSet ? false : this.selfPropsObj._disabledDeleteOldRow;
364
- },
365
- dftReadonly () {
366
- return this.isDftSet ? false : this.selfPropsObj._dftReadonly;
367
- },
368
- dftReadonlyColKeys () {
369
- return this.isDftSet ? [] : this.selfPropsObj._dftReadonlyColKeys || []; // 配置端有问题,高级依赖时值成undefined了
370
- },
371
- oldReadonly () {
372
- return this.isDftSet ? false : this.selfPropsObj._oldReadonly;
373
- },
374
- oldReadonlyColKeys () {
375
- return this.isDftSet ? [] : this.selfPropsObj._oldReadonlyColKeys || []; // 配置端有问题,高级依赖时值成undefined了
376
- },
377
-
378
- /* --- 筛选 --- */
379
- searchLabelWidth () {
380
- return this.selfPropsObj._searchLabelWidth;
381
- },
382
- searchList () {
383
- return this.selfPropsObj._searchList;
384
- },
385
- searchListMap () {
386
- return this.$arrToMap(this.searchList, "_key");
387
- },
388
- searchListFields () {
389
- return this.searchList.map(searchItem => searchItem._key);
390
- },
391
- searchFormList () {
392
- return this.$filterList(this.searchListFields, this.selfColumns).map(formItem => ({
393
- ...formItem,
394
- ...this.searchListMap[formItem._key],
395
- _name: formItem._name
396
- }));
397
- },
398
- tableAdvSearch () {
399
- return this.$transformAdvSearch(this.selfPropsObj._tableAdvSearch, this.parentFormList, this.parentObj);
400
- },
401
- // 默认筛选配置里-隐藏的筛选条件
402
- hideAdvSearch () {
403
- return {
404
- logic: ["and", "or"].includes(this.tableAdvSearch.logic) ? this.tableAdvSearch.logic : "and",
405
- conditions: this.tableAdvSearch.conditions.filter(conditionItem =>
406
- !this.searchListFields.includes(conditionItem.fieldKey)
407
- )
408
- };
409
- },
410
- // 过滤行数据的 最终的筛选条件
411
- finalTableAdvSearch () {
412
- return {
413
- logic: "and",
414
- conditions: [
415
- this.hideAdvSearch,
416
- this.dftAdvSearch
417
- ]
418
- };
419
- },
420
-
421
- // 是否筛选状态
422
- isSearching () {
423
- return this.parentObj.__isCreate__ === true
424
- ? false
425
- : this.$isAdvSearching(this.finalTableAdvSearch);
426
- },
427
- searchTitle () {
428
- return `${this.isSearching ? "筛选" : "全部"}数据;`;
429
- },
430
-
431
- /* --- 列字段 --- */
432
- // columns => selfColumns => usedColumns => contentColumns => showContentColumns => showColumns
433
- selfColumns () {
434
- // console.log("selfColumns");
435
- return this.columns;
436
- },
437
- usedColumns () {
438
- // console.log("usedColumns");
439
- const list = this.selfColumns.filter(colItem =>
440
- this.showOrHideColKeys.includes(colItem._key)
441
- ? this.showColKeys.includes(colItem._key)
442
- : true
443
- );
444
-
445
- return list.filter(colItem => this.$isAdvRelyShow(colItem, this.allListData, this.parentObj, true));
446
- },
447
- contentColumns () {
448
- return this.usedColumns.map(colItem => ({
449
- renderHeaderCell: ({ column }, h) => {
450
- return this.contentThCellRender(h, { column });
451
- },
452
- renderBodyCell: ({ row, rowIndex, column }, h) => {
453
- return this.contentTdCellRender(h, { row, rowIndex, column });
454
- },
455
- ...colItem
456
- }));
457
- },
458
- showContentColumns () {
459
- return this.contentColumns.filter(colItem =>
460
- this.hideStatus === true
461
- ? !this.hideColKeys.includes(colItem._key)
462
- : true
463
- );
464
- },
465
- selectionColumn () {
466
- return {
467
- _key: "__selection__",
468
- key: "__selection__",
469
- field: "__selection__",
470
- type: "checkbox",
471
- width: 50,
472
- align: "center",
473
- fixed: "left"
474
- };
475
- },
476
- operationColumn () {
477
- return {
478
- title: "操作",
479
- _key: "__operation__",
480
- key: "__operation__",
481
- field: "__operation__",
482
- _align: "center",
483
- align: "center",
484
- _fixed: "right",
485
- fixed: "right",
486
- _width: 100 + (this.rowOperationList.length - 1) * 110,
487
- width: 100 + (this.rowOperationList.length - 1) * 110,
488
- renderBodyCell: ({ row, rowIndex, column }, h) => {
489
- return this.operationTdCellRender(h, { row, rowIndex, column });
490
- }
491
- };
492
- },
493
-
494
- /* --- 表格参数 --- */
495
- tablePropsObj () {
496
- return {
497
- // rowStyleOption: {
498
- // hoverHighlight: true,
499
- // clickHighlight: true,
500
- // stripe: true // 斑马纹
501
- // },
502
- maxHeight: this.contentHeight,
503
- // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
504
- columnHiddenOption: {
505
- // defaultHiddenColumnKeys: [...this.hideColKeys] // 必须这么写,不解构,切换一次隐藏/显示后,hideColKeys会变成空数组
506
- },
507
- cellStyleOption: {
508
- bodyCellClass: this.bodyCellClass
509
- },
510
- cellSpanOption: {
511
- bodyCellSpan: this.bodyCellSpan
512
- },
513
- eventCustomOption: {
514
- bodyCellEvents: this.eventCustomOption
515
- }
516
- };
517
- },
518
- tableInModalPropsObj () {
519
- return {
520
- ...this.tablePropsObj,
521
- maxHeight: undefined
522
- };
523
- },
524
- checkboxOption () {
525
- return {
526
- selectedRowKeys: this.selectIds
527
- };
528
- },
529
-
530
- /* --- 联动隐藏 --- */
531
- showColKeys () {
532
- return this.showByNumFieldVal != null && this.showByNumFieldVal >= 0
533
- ? this.showOrHideColKeys.slice(0, this.showByNumFieldVal)
534
- : this.showOrHideColKeys;
535
- },
536
- showOrHideColKeys () {
537
- return this.selfPropsObj._showOrHideColKeys || [];
538
- },
539
- // 控制联动隐藏的数字类型字段
540
- showByNumFieldKey () {
541
- return this.selfPropsObj._showByNumFieldKey;
542
- },
543
- // 控制联动隐藏的数字类型字段的值
544
- showByNumFieldVal () {
545
- return this.showByNumFieldKey
546
- ? this.parentObj[this.showByNumFieldKey]
547
- : undefined;
548
- },
549
-
550
- /* --- 显示/隐藏 --- */
551
- hideColKeys () {
552
- return this.selfPropsObj._hideColKeys;
553
- },
554
-
555
- /* --- 引用 --- */
556
- isQuote () {
557
- return this.selfPropsObj._isQuote;
558
- },
559
- quoteReadonlyColKeys () {
560
- return this.selfPropsObj._quoteDisabledColKeys;
561
- },
562
- quoteListFields () {
563
- return this.selfPropsObj._quoteListFields;
564
- },
565
- quoteAdvSearch () {
566
- return this.$transformAdvSearch(this.selfPropsObj._quoteAdvSearch, this.parentFormList, this.parentObj);
567
- },
568
- quoteParams () {
569
- return {
570
- screenKey: this.allScreenKey,
571
- fields: [
572
- ...this.quoteListFields,
573
- this.controlKey,
574
- "createdAt"
575
- ],
576
- advSearch: {
577
- logic: "and",
578
- conditions: [
579
- {
580
- fieldKey: "_id",
581
- fieldOperator: "ne",
582
- fieldValue: [this.parentDataId]
583
- },
584
- this.quoteAdvSearch
585
- ]
586
- }
587
- };
588
- },
589
-
590
- /* --- 导入 --- */
591
- isImport () {
592
- return this.selfPropsObj._isImport;
593
- },
594
- importAsDft () {
595
- return this.selfPropsObj._importAsDft;
596
- },
597
- importParams () {
598
- return {
599
- _id: this.parentDataId,
600
- _key: this.controlKey,
601
- importType: this.inTableType
602
- };
603
- },
604
-
605
- /* --- 导出 --- */
606
- isExport () {
607
- return this.selfPropsObj._isExport;
608
- },
609
- exportParams () {
610
- return {
611
- screenKey: this.screenKey,
612
- _id: this.parentDataId,
613
- _key: this.controlKey,
614
- flowinst: this.flowInstId,
615
- advSearch: this.finalTableAdvSearch
616
- };
617
- },
618
-
619
- /* --- 全屏 --- */
620
- useEnlarge () {
621
- return this.selfPropsObj._useEnlarge;
622
- },
623
- modalPropsObj () {
624
- return {
625
- mode: "fullscreen",
626
- title: this.controlName
627
- };
628
- },
629
-
630
- /* --- 数据 --- */
631
- // 默认值数据
632
- defaultListData () {
633
- const loop = (tree = [], list = []) => {
634
- return tree.reduce((newList, rowItem) => {
635
- newList = [...newList, rowItem];
636
-
637
- return rowItem.children && rowItem.children.length
638
- ? loop(rowItem.children, newList)
639
- : newList;
640
- }, list);
641
- };
642
-
643
- return ["cascaderTable"].includes(this.controlType)
644
- ? loop(this.selfPropsObj._default.tree)
645
- : this.selfPropsObj._default.list;
646
- },
647
- defaultListDataIds () {
648
- return this.defaultListData
649
- .map(rowItem => rowItem._id)
650
- .filter(id => !!id);
651
- },
652
- // 全部数据(或筛选出的数据)-总数
653
- selfTotal () {
654
- return this.showListData.length;
655
- },
656
-
657
- // 新增行的默认值
658
- selfRowDft () {
659
- return this.selfColumns.reduce((obj, column) => {
660
- const dftInRowVal = this.rowDefault[column._key];
661
- const dftVal = column._default;
662
- const dftInitVal = this.dftInitValMap[column._type];
663
-
664
- return Object.assign(obj, {
665
- [column._key]: dftInRowVal === undefined // 不用isEmptyData判断原因:为空值时可能是故意置空的
666
- ? this.$isEmptyData(dftVal)
667
- ? dftInitVal
668
- : dftVal
669
- : dftInRowVal
670
- });
671
- }, {});
672
- },
673
- parentDataId () {
674
- return this.parentObj._id;
675
- },
676
- // compareListData () {
677
- // this.compareData.forEach(item => {
678
- // !item._id && this.$set(item, "_id", this.$ObjectID().str);
679
- // });
680
- // return this.compareData;
681
- // },
682
- // useCampare () {
683
- // return !!this.compareListData.length;
684
- // },
685
- changedCols () {
686
- return [];
687
- },
688
-
689
- /* --- 功能按钮 --- */
690
- baseOperationBtns () {
691
- return Object.keys(this.baseOperationMap);
692
- },
693
- otherOperationBtns () {
694
- return Object.keys(this.otherOperationMap);
695
- },
696
- topOperationBtns () {
697
- return Object.keys(this.topOperationMap);
698
- },
699
- allOperationMap () {
700
- return {
701
- ...(this.baseOperationMap || {}),
702
- ...(this.otherOperationMap || {}),
703
- ...(this.topOperationMap || {}),
704
-
705
- canCreate: {
706
- ...this.baseOperationMap.canCreate,
707
- name: this.showMode === "form"
708
- ? this.baseOperationMap.canCreate.name.replace("行", "条")
709
- : this.baseOperationMap.canCreate.name,
710
- tip: this.showMode === "form"
711
- ? this.baseOperationMap.canCreate.tip.replace("行", "条")
712
- : this.baseOperationMap.canCreate.tip
713
- },
714
- canInsert: {
715
- ...this.baseOperationMap.canInsert,
716
- name: this.showMode === "form"
717
- ? this.baseOperationMap.canInsert.name.replace("行", "条")
718
- : this.baseOperationMap.canInsert.name,
719
- tip: this.showMode === "form"
720
- ? this.baseOperationMap.canInsert.tip.replace("行", "条")
721
- : this.baseOperationMap.canInsert.tip,
722
- color: this.appColor
723
- },
724
- canHideOrShow: {
725
- ...this.topOperationMap.canHideOrShow,
726
- name: this.hideStatus ? "显示字段" : "隐藏字段"
727
- },
728
-
729
- ...(this.selfAllOperationMap || {})
730
- };
731
- },
732
- operationMap () {
733
- return this.$categoryMapToMap(
734
- this.allOperationMap,
735
- undefined,
736
- undefined,
737
- [
738
- ...(
739
- this.canEdit
740
- ? [
741
- ...(this.disabledBtns ? [] : this.baseOperationBtns),
742
- ...this.otherOperationBtns,
743
- ...(this.isQuote ? ["canQuote"] : []),
744
- ...(this.isImport ? ["canImport"] : [])
745
- ]
746
- : []
747
- ),
748
- ...(this.isExport ? ["canExport"] : []),
749
- ...(this.useEnlarge ? ["canEnlarge"] : []),
750
- ...(this.hideColKeys.length ? ["canHideOrShow"] : [])
751
- ]
752
- );
753
- },
754
- rowOperationList () {
755
- const btns = [
756
- ...(this.useInsertInOperationCol ? ["canInsert"] : []),
757
- "canDelete"
758
- ];
759
- return this.$getOperationList(btns);
760
- }
761
- },
762
- watch: {
763
- isEnlarge (bool) {
764
- setTimeout(() => {
765
- this.isEnlargeFlag = bool;
766
- // this.dealingOpenModal && this.dealingOpenModal();
767
- }, 0);
768
- }
769
- },
770
- created () {
771
- this.baseInit();
772
- },
773
- methods: {
774
- baseInit () {
775
- this.dftAdvSearch = {
776
- logic: ["and", "or"].includes(this.tableAdvSearch.logic) ? this.tableAdvSearch.logic : "and",
777
- conditions: this.tableAdvSearch.conditions.filter(conditionItem =>
778
- this.searchListFields.includes(conditionItem.fieldKey)
779
- )
780
- };
781
-
782
- this.loadingFunc();
783
- },
784
-
785
- // 共外部使用
786
- validate () {
787
- // this.showRuleMessage = true;
788
- // return this.allListData.every((row, rowIndex) => this.getRowRuleResult(row, rowIndex));
789
-
790
- let bool = true;
791
- this.allListData.forEach((row, rowIndex) => {
792
- const resultBool = this.getRowRuleResult(row, rowIndex);
793
-
794
- if (resultBool === false) {
795
- bool = false;
796
- }
797
- });
798
-
799
- return bool;
800
- },
801
- // 重置
802
- reset () {
803
- this.initFlag = true;
804
- this.isExpandAction = false;
805
- // this.showRuleMessage = false;
806
-
807
- this.idRecordMap = {};
808
- // this.hoverRecordMap = {};
809
- this.ruleRecordMap = {};
810
-
811
- this.dftAdvSearch = {
812
- logic: "and",
813
- conditions: []
814
- };
815
- this.hideStatus = true;
816
-
817
- this.changePage && this.changePage(1);
818
- this.selfReset && this.selfReset();
819
- },
820
- loadingFunc () {
821
- this.isLoading = true;
822
- this.changeSelect();
823
-
824
- setTimeout(() => {
825
- this.isLoading = false;
826
- });
827
- },
828
-
829
- // 筛选回调
830
- searchCb (conditions) {
831
- if (this.parentObj.__isCreate__ !== true) {
832
- this.isExpandAction = false;
833
- this.dftAdvSearch.conditions = conditions;
834
-
835
- this.changePage && this.changePage(1);
836
- }
837
- },
838
- // 列表选择项改变 (!!!外部在使用)
839
- changeSelect (selections = [], ...params) {
840
- this.selectIds = selections.map(item => item._id);
841
- this.$emit("changeSelect", this.selectIds, selections, ...params);
842
- },
843
-
844
- // 输入框失去焦点
845
- controlBlur (operationItem, row, rowIndex, column, params) {
846
- this.dealRuleRecord(row, column);
847
- },
848
- // 输入框值改变立即
849
- quickChangeVal (operationItem, row, rowIndex, column, params) {
850
- if (["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
851
- this.dealRuleRecord(row, column);
852
- this.change("quickChangeVal", row, rowIndex, column, ...params);
853
- }
854
- },
855
- // 输入框值改变
856
- changeVal (operationItem, row, rowIndex, column, params) {
857
- if (!["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
858
- this.dealRuleRecord(row, column);
859
- this.change("changeVal", row, rowIndex, column, ...params);
860
- }
861
- },
862
- change (eventType, row, rowIndex, column, ...params) {
863
- this.$emit("change", this.tableDataObj, eventType, column, row, rowIndex, ...params);
864
- },
865
-
866
- /* ----------- 隐藏/显示字段 ---------- */
867
- toggleHideOrShow () {
868
- // if (this.$refs.briTable) {
869
- // if (this.hideStatus === true) {
870
- // this.$refs.briTable.showColumnsByKeys(this.hideColKeys);
871
- // } else {
872
- // this.$refs.briTable.hideColumnsByKeys(this.hideColKeys);
873
- // }
874
- // }
875
-
876
- this.hideStatus = !this.hideStatus;
877
- },
878
-
879
- /* ----------- 引用 ---------- */
880
- // 点击引用
881
- clickQuote () {
882
- this.dshRenderName = "quoteModalRender";
883
- this.showQuoteModal = true;
884
- },
885
- // 引用模态框渲染函数
886
- quoteModalRender (h, params) {
887
- return this.showQuoteModal
888
- ? h("quote-list-modal", {
889
- props: {
890
- value: this.showQuoteModal,
891
- propsObj: this.propsObj,
892
- listParams: this.quoteParams
893
- },
894
- on: {
895
- input: bool => {
896
- this.showQuoteModal = bool;
897
- },
898
- confirm: this.quoteCb
899
- }
900
- })
901
- : undefined;
902
- },
903
- // 引用回调
904
- quoteCb (dataObj) {
905
- if (dataObj) {
906
- const fieldVal = dataObj[this.controlKey];
907
- const isEmpty = this.$isEmptyData(fieldVal) || (
908
- ["cascaderTable"].includes(this.controlType)
909
- ? !fieldVal.tree || !fieldVal.tree.length
910
- : ["flatTable"].includes(this.controlType)
911
- ? !fieldVal.list || !fieldVal.list.length
912
- : false
913
- );
914
-
915
- if (isEmpty) {
916
- this.$Modal.confirm({
917
- title: "提示",
918
- content: "该数据下此内容为空,无法引用!",
919
- onOk: () => { }
920
- });
921
- }
922
- else {
923
- if (["cascaderTable"].includes(this.controlType)) {
924
- const transformData = (list = []) => {
925
- const loop = (list = []) =>
926
- list.map(item => ({
927
- ...item,
928
- children: item.children ? loop(item.children) : item.children,
929
- __isQuote__: true,
930
- __old__: false
931
- }));
932
-
933
- return loop(list);
934
- };
935
-
936
- this.parentObj[this.controlKey] = {
937
- ...fieldVal,
938
- tree: transformData(fieldVal.tree)
939
- };
940
- }
941
- else if (["flatTable"].includes(this.controlType)) {
942
- this.parentObj[this.controlKey] = {
943
- ...fieldVal,
944
- list: fieldVal.list.map(item => ({
945
- ...item,
946
- __isQuote__: true,
947
- __old__: false
948
- }))
949
- };
950
- }
951
-
952
- this.$Message.success("引用成功!");
953
- this.reset();
954
- this.showTopSearch = false;
955
- this.$nextTick(() => {
956
- this.showTopSearch = true;
957
- });
958
-
959
- this.change("quote");
960
- }
961
- } else {
962
- this.$Message.error("未选择引用数据!");
963
- }
964
- },
965
-
966
- /* ----------- 导入 ---------- */
967
- // 点击导入
968
- clickImport () {
969
- this.dshRenderName = "importModalRender";
970
- this.showImportModal = true;
971
- },
972
- // 导入模态框渲染函数
973
- importModalRender (h, params) {
974
- return this.showImportModal
975
- ? h("import-modal", {
976
- props: {
977
- value: this.showImportModal,
978
- propsObj: this.propsObj,
979
- importParams: this.importParams
980
- },
981
- on: {
982
- input: bool => {
983
- this.showImportModal = bool;
984
- },
985
- importCb: this.importCb
986
- }
987
- })
988
- : undefined;
989
- },
990
- // 导入回调
991
- importCb (dataObj) {
992
- const fieldVal = dataObj;
993
- if (this.importAsDft) {
994
- if (["cascaderTable"].includes(this.controlType)) {
995
- const transformData = (list = []) => {
996
- const loop = (list = []) =>
997
- list.map(item => ({
998
- ...item,
999
- children: item.children ? loop(item.children) : item.children,
1000
- __isDefault__: true,
1001
- __old__: false
1002
- }));
1003
-
1004
- return loop(list);
1005
- };
1006
-
1007
- this.parentObj[this.controlKey] = {
1008
- ...fieldVal,
1009
- tree: transformData(fieldVal.tree)
1010
- };
1011
- }
1012
- else if (["flatTable"].includes(this.controlType)) {
1013
- this.parentObj[this.controlKey] = {
1014
- ...fieldVal,
1015
- list: fieldVal.list.map(item => ({
1016
- ...item,
1017
- __isDefault__: true,
1018
- __old__: false
1019
- }))
1020
- };
1021
- }
1022
- } else {
1023
- this.parentObj[this.controlKey] = dataObj;
1024
- }
1025
-
1026
- // 因为data和rowspanMap不马上更新
1027
- this.$nextTick(() => {
1028
- this.reset();
1029
- this.change("import");
1030
- });
1031
- },
1032
-
1033
- /* ----------- 导出 ---------- */
1034
- // 点击导出
1035
- clickExport (operationItem) {
1036
- this.handleExport(operationItem);
1037
- },
1038
- // 接口 -导出
1039
- handleExport (operationItem) {
1040
- operationItem.disabled = true;
1041
-
1042
- this.$https({
1043
- url: {
1044
- module: "sheet",
1045
- name: ["cascaderTable"].includes(this.controlType) ? "exportCascaderTableExcel" : "exportFlatTableExcel"
1046
- },
1047
- params: this.exportParams,
1048
- callback: data => {
1049
- this.getJobStatus(operationItem, data.jobId, data.excel_url);
1050
- this.exportTimer = setInterval(() => {
1051
- this.getJobStatus(operationItem, data.jobId, data.excel_url);
1052
- }, 1000);
1053
- }
1054
- });
1055
- },
1056
- // 接口 -获取导出地址
1057
- getJobStatus (operationItem, id, url) {
1058
- this.$https({
1059
- url: {
1060
- module: "sheet",
1061
- name: "getJobStatus"
1062
- },
1063
- params: {
1064
- jobId: id
1065
- },
1066
- callback: data => {
1067
- if (data.status === "completed") {
1068
- operationItem.disabled = false;
1069
- clearInterval(this.exportTimer);
1070
- window.location.href = data.url;
1071
- } else if (data.status === "failed") {
1072
- this.$Message.info({
1073
- content: "操作失败,请稍后再试!"
1074
- });
1075
- }
1076
- },
1077
- error: res => {
1078
- operationItem.disabled = false;
1079
- this.exportTimer = null;
1080
- }
1081
- });
1082
- },
1083
-
1084
- /* ----------- 全屏 ---------- */
1085
- // 打开全屏模态框
1086
- clickEnlarge (operationItem) {
1087
- this.isEnlarge = true;
1088
- },
1089
-
1090
- /* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
1091
- getTableTopRender (inEnlarge = false) {
1092
- return (h, params) => {
1093
- return h("div", {
1094
- style: {
1095
- "margin-bottom": "3px",
1096
- "display": "flex",
1097
- "flex-direction": "row",
1098
- "justify-content": "space-between",
1099
- "align-items": "center"
1100
- }
1101
- }, [
1102
- // 左 -统计,逻辑
1103
- this.topSummaryRender(h),
1104
-
1105
- // 右 -功能按钮
1106
- this.topOperationRender(h, inEnlarge)
1107
- ]);
1108
- };
1109
- },
1110
- topSummaryRender (h) {
1111
- return this.searchFormList.length
1112
- ? h("div", {
1113
- style: {
1114
- "display": "flex",
1115
- "flex-direction": "row",
1116
- "align-items": "center"
1117
- }
1118
- }, [
1119
- h("span", {
1120
- style: {
1121
- "font-weight": "500"
1122
- }
1123
- }, this.searchTitle),
1124
-
1125
- h("div", {
1126
- style: {
1127
- "display": "flex",
1128
- "flex-direction": "row",
1129
- "align-items": "center",
1130
- "margin-left": "12px"
1131
- }
1132
- }, [
1133
- h("div", {
1134
- style: {
1135
- "font-weight": "500"
1136
- }
1137
- }, this.selfLogicPropsObj._name + ":"),
1138
-
1139
- h("dsh-select", {
1140
- style: {
1141
- "margin-left": "8px",
1142
- "margin-top": "-4px"
1143
- },
1144
- props: {
1145
- value: this.dftAdvSearch,
1146
- propsObj: this.selfLogicPropsObj
1147
- }
1148
- })
1149
- ])
1150
- ])
1151
- : h("div", "");
1152
- },
1153
- // 全屏里不显示功能按钮
1154
- topOperationRender (h, inEnlarge) {
1155
- return inEnlarge
1156
- ? undefined
1157
- : h("dsh-buttons", {
1158
- style: {
1159
- "text-align": "right"
1160
- },
1161
- props: {
1162
- itemClass: undefined,
1163
- list: this.$getOperationList(this.topOperationBtns)
1164
- },
1165
- on: {
1166
- click: (event) => {
1167
- this.$dispatchEvent(event);
1168
- }
1169
- },
1170
- nativeOn: {
1171
- click: (e) => {
1172
- e.stopPropagation();
1173
- }
1174
- }
1175
- });
1176
- },
1177
- topSearchRender (h) {
1178
- return this.searchFormList.length
1179
- ? h("dsh-default-search", {
1180
- props: {
1181
- formList: this.searchFormList,
1182
- initValue: this.dftAdvSearch.conditions,
1183
- labelWidth: this.searchLabelWidth
1184
- },
1185
- on: {
1186
- change: this.searchCb
1187
- }
1188
- })
1189
- : undefined;
1190
- },
1191
- createBtnRender (h) {
1192
- return !this.isSearching && this.disabledFootCreateBtn !== true
1193
- ? h("dsh-buttons", {
1194
- style: {
1195
- "margin-top": "3px"
1196
- },
1197
- props: {
1198
- itemClass: undefined,
1199
- list: this.$getOperationList(["canCreate"])
1200
- },
1201
- on: {
1202
- click: (event) => {
1203
- this.$dispatchEvent(event);
1204
- }
1205
- }
1206
- })
1207
- : undefined;
1208
- },
1209
- contentThCellRender (h, { column }) {
1210
- column = this.$transformDynamicProperty(column, undefined, this.parentObj);
1211
- // console.log(column._name);
1212
-
1213
- return this.$getHeadRender(h, column, {
1214
- showRequired: this.showRequired,
1215
- showDescription: this.showDescription,
1216
- headHeightAuto: this.headHeightAuto
1217
- });
1218
- },
1219
- contentTdCellRender (h, { row, rowIndex, column }) {
1220
- // console.log(rowIndex);
1221
- column = this.$transformDynamicProperty(column, row, this.parentObj);
1222
- column = this.getResetCol({ row, rowIndex, column });
1223
- const unitCanEdit = this.getUnitCanEdit({ row, rowIndex, column });
1224
- const ruleResultObj = this.getColRuleResult({ row, rowIndex, column });
1225
-
1226
- return [
1227
- // this.isShowCompare({ row, rowIndex, column })
1228
- // ? h("Tooltip", {
1229
- // style: {
1230
- // width: "100%"
1231
- // },
1232
- // props: {
1233
- // content: this.$isEmptyData(this.compareListData[rowIndex][column._key]) ? "" : this.compareListData[rowIndex][column._key],
1234
- // transfer: true,
1235
- // maxWidth: 200,
1236
- // placement: "top"
1237
- // },
1238
- // scopedSlots: {
1239
- // default: props => h("dsh-list-unit", {
1240
- // props: {
1241
- // canEdit: unitCanEdit,
1242
- // formData: row,
1243
- // formItem: {
1244
- // ...column,
1245
- // _key: column.colType === "tree" ? "name" : column._key
1246
- // },
1247
- // allFormList: this.selfColumns,
1248
- // inTableType: this.inTableType,
1249
- // allListRows: this.allListData,
1250
- // rowIndex: rowIndex,
1251
- // parentFormList: this.parentFormList,
1252
- // parentObj: this.parentObj
1253
- // },
1254
- // on: {
1255
- // blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1256
- // quickChange: () => this.$dispatchEvent(this.operationMap.canQuickChangeVal, row, rowIndex, column, arguments),
1257
- // change: () => this.$dispatchEvent(this.operationMap.canChangeVal, row, rowIndex, column, arguments)
1258
- // }
1259
- // })
1260
- // }
1261
- // })
1262
- h("dsh-list-unit", {
1263
- key: `${row._id}--${column._key}`,
1264
- props: {
1265
- canEdit: unitCanEdit,
1266
- formData: row,
1267
- formItem: {
1268
- ...column,
1269
- _key: column.colType === "tree" ? "name" : column._key
1270
- },
1271
- allFormList: this.selfColumns,
1272
- changedCols: this.changedCols,
1273
- changedFields: (row.__changed__ || []).map(item => item.fieldKey),
1274
- inTableType: this.inTableType,
1275
- allListRows: this.allListData,
1276
- rowIndex: rowIndex,
1277
- parentFormList: this.parentFormList,
1278
- parentObj: this.parentObj
1279
- },
1280
- on: {
1281
- blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1282
- quickChange: () => this.$dispatchEvent(this.operationMap.canQuickChangeVal, row, rowIndex, column, arguments),
1283
- change: () => this.$dispatchEvent(this.operationMap.canChangeVal, row, rowIndex, column, arguments)
1284
- }
1285
- }),
1286
-
1287
- // 校验文字
1288
- !ruleResultObj.bool
1289
- ? h("span", {
1290
- class: "bri-table-td-tip"
1291
- }, ruleResultObj.message)
1292
- : undefined,
1293
-
1294
- // 添加符
1295
- ...this.operationIconRender(h, { row, rowIndex, column }, 12)
1296
- ];
1297
- },
1298
- operationTdCellRender (h, { row, rowIndex, column }) {
1299
- const operationList = this.rowOperationList.map(btnItem => ({
1300
- ...btnItem,
1301
- disabled: btnItem.type === "canDelete"
1302
- ? !this.getRowDelBtnCanEdit(row, rowIndex)
1303
- : btnItem.disabled
1304
- }));
1305
-
1306
- return [
1307
- h("dsh-buttons", {
1308
- props: {
1309
- list: operationList
1310
- },
1311
- on: {
1312
- click: (operationItem) => {
1313
- this.$dispatchEvent(operationItem, row, rowIndex, column);
1314
- }
1315
- }
1316
- })
1317
- ];
1318
- },
1319
- operationIconRender (h, { row, rowIndex, column }, iconSize = 14) {
1320
- const baseBool = !this.isSearching &&
1321
- (this.showCreateBtnColKeys.length ? this.showCreateBtnColKeys.includes(column._key) : ["__index__", "__treeIndex__"].includes(column._key));
1322
- // this.hoverRecordMap[`${row._id}`];
1323
-
1324
- return [
1325
- // 插入一行图标
1326
- baseBool
1327
- ? this.getOperationIconRender(h, { row, rowIndex, column }, "canInsert", iconSize)
1328
- : h("span", ""),
1329
-
1330
- // 添加一行下级图标
1331
- baseBool &&
1332
- row.level < this.maxLevel &&
1333
- !["cascaderTable"].includes(this.inTableType) // 老版级联表格类型不要“添加下级”图标
1334
- ? this.getOperationIconRender(h, { row, rowIndex, column }, "canCreateChild", iconSize, true)
1335
- : h("span", ""),
1336
-
1337
- // 删除该行图标
1338
- baseBool &&
1339
- this.getRowDelBtnCanEdit(row, rowIndex) &&
1340
- ["cascaderTable"].includes(this.inTableType)
1341
- ? this.getOperationIconRender(h, { row, rowIndex, column }, "canDelete", iconSize, true)
1342
- : h("span", "")
1343
- ];
1344
- },
1345
- getOperationIconRender (h, { row, rowIndex, column }, operationType, iconSize = 14, isLeft = false) {
1346
- const operationItem = this.operationMap[operationType];
1347
-
1348
- return operationItem && operationItem.disabled !== true
1349
- ? h("div", {
1350
- style: {
1351
- position: "absolute",
1352
- bottom: "0px",
1353
- right: isLeft ? `${iconSize + 3}px` : "0px",
1354
- width: `${iconSize + 2}px`,
1355
- height: `${iconSize + 2}px`,
1356
- border: `1px solid ${operationItem.color}`,
1357
- borderRadius: "2px",
1358
- backgroundColor: "#ffffff",
1359
- lineHeight: `${iconSize - 2}px`,
1360
- cursor: "pointer",
1361
- verticalAlign: "middle",
1362
- transition: "color .2s ease-in-out,border-color .2s ease-in-out"
1363
- }
1364
- }, [
1365
- h("Tooltip", {
1366
- props: {
1367
- content: operationItem.tip,
1368
- maxWidth: "250",
1369
- transfer: true
1370
- }
1371
- }, [
1372
- h("Icon", {
1373
- style: {
1374
- fontWeight: "500",
1375
- color: operationItem.color
1376
- },
1377
- props: {
1378
- type: operationItem.icon,
1379
- size: iconSize
1380
- },
1381
- on: {
1382
- click: () => {
1383
- this.$dispatchEvent(operationItem, row, rowIndex, column);
1384
- }
1385
- }
1386
- })
1387
- ])
1388
- ])
1389
- : h("span", "");
1390
- },
1391
- bodyCellClass ({ row, rowIndex, column }) {
1392
- return "bri-table-td" +
1393
- `${["__treeIndex__"].includes(column._key)
1394
- ? " bri-table-td-treeIndex"
1395
- : this.getRowCanEdit(row, rowIndex)
1396
- ? " bri-table-td-edit"
1397
- : ""
1398
- }` +
1399
- `${this.isExpandAction
1400
- ? " bri-table-td-visible"
1401
- : ""
1402
- }` +
1403
- `${this.noborderColKeys.includes(column._key)
1404
- ? " bri-table-td-noborder"
1405
- : ""
1406
- }` +
1407
- `${this.bgColKeys.includes(column._key)
1408
- ? " bri-table-td-bg"
1409
- : ""
1410
- }`;
1411
- },
1412
- eventCustomOption ({ row, rowIndex, column }) {
1413
- return {
1414
- click: (event) => {
1415
-
1416
- },
1417
- dblclick: (event) => {
1418
-
1419
- },
1420
- contextmenu: (event) => {
1421
-
1422
- },
1423
- mouseenter: (event) => {
1424
- // this.$set(this.hoverRecordMap, `${row._id}`, true);
1425
- },
1426
- mouseleave: (event) => {
1427
- // this.$set(this.hoverRecordMap, `${row._id}`, false);
1428
- }
1429
- };
1430
- },
1431
-
1432
- /* ----------- 方法 ---------- */
1433
- // 整行校验结果
1434
- getRowRuleResult (row, rowIndex) {
1435
- // return this.usedColumns.every(column => this.getColRuleResult({ row, rowIndex, column }).bool);
1436
-
1437
- let bool = true;
1438
- this.usedColumns.forEach(column => {
1439
- column = this.$transformDynamicProperty(column, row, this.parentObj);
1440
-
1441
- const resultObj = this.getColRuleResultObj({ row, rowIndex, column });
1442
- if (!resultObj.bool) {
1443
- bool = false;
1444
- this.dealRuleRecord(row, column);
1445
- }
1446
- });
1447
-
1448
- return bool;
1449
- },
1450
- getRowFormList (row, rowIndex) {
1451
- return this.selfColumns.map(column => {
1452
- column = this.$transformDynamicProperty(column, row, this.parentObj);
1453
- const unitCanEdit = this.getColCanEdit({ row, rowIndex, column });
1454
-
1455
- return {
1456
- ...column,
1457
- canEdit: unitCanEdit
1458
- };
1459
- });
1460
- },
1461
- // 是否默认行
1462
- getIsDftRow (row, rowIndex) {
1463
- return this.isDftSet ? false : row.__isDefault__;
1464
- },
1465
- // 行按钮是否可操作(删除按钮可编辑 不代表行内容是可编辑的)
1466
- getRowDelBtnCanEdit (row, rowIndex) {
1467
- return row.__readonly__ !== true && // 不能为只读数据
1468
- (this.disabledDeleteDftRow ? row.__isDefault__ !== true : true) && // 默认数据可删除
1469
- (this.disabledDeleteOldRow ? row.__old__ !== true : true); // 老数据可删除
1470
- },
1471
- // 行内容是否可编辑
1472
- getRowCanEdit (row, rowIndex) {
1473
- return this.canEdit && // 是编辑状态
1474
- (this.getIsDftRow(row) ? !this.dftReadonly : true) && // 默认数据可编辑
1475
- (row.__old__ === true ? !this.oldReadonly : true) && // 老数据可编辑
1476
- row.__readonly__ !== true; // 不能为只读数据
1477
- },
1478
-
1479
- // 单元格校验结果
1480
- getColRuleResult ({ row, rowIndex, column }) {
1481
- column = this.$transformDynamicProperty(column, row, this.parentObj);
1482
-
1483
- // 未触发校验时 不显示错误
1484
- // return this.ruleRecordMap[this.getMixKey(row, column)] || this.showRuleMessage
1485
- return this.ruleRecordMap[this.getMixKey(row, column)]
1486
- ? this.getColRuleResultObj({ row, rowIndex, column })
1487
- : {
1488
- bool: true,
1489
- message: "未触发校验,通过!"
1490
- };
1491
- },
1492
- // 获取单元格校验对象
1493
- getColRuleResultObj ({ row, rowIndex, column }) {
1494
- // 校验必填不通过 => 校验对比
1495
- const resultObj = {};
1496
- this.$getFieldRuleResult(column, row, resultObj) &&
1497
- this.$normalComparedFunc(column, row, this.selfColumns, this.parentObj, this.parentFormList, this.inTableType, resultObj) &&
1498
- this.$levelComparedFunc(column, row, this.allListData, this.inTableType, resultObj);
1499
-
1500
- return resultObj;
1501
- },
1502
- // 加工单元格对应的配置
1503
- getResetCol ({ row, rowIndex, column }) {
1504
- return {
1505
- // isShare: this.isShare,
1506
- ...column,
1507
- _heightAuto: this.heightAuto,
1508
- ...(
1509
- this.noborderColKeys.includes(column._key)
1510
- ? { _placeholder: " " }
1511
- : {}
1512
- ),
1513
- ...(
1514
- this.getSelfResetCol
1515
- ? this.getSelfResetCol({ row, rowIndex, column })
1516
- : {}
1517
- )
1518
- };
1519
- },
1520
- // 单元格最终是否可编辑性
1521
- getUnitCanEdit ({ row, rowIndex, column }) {
1522
- return this.getRowCanEdit(row, rowIndex) &&
1523
- this.getColCanEdit({ row, rowIndex, column }) &&
1524
- this.$isAdvRelyShow(column, row, this.parentObj, true);
1525
- },
1526
- // 单元格本身是否可编辑性
1527
- getColCanEdit ({ row, rowIndex, column }) {
1528
- return (this.getIsDftRow(row) ? !this.dftReadonlyColKeys.includes(column._key) : true) && // 默认行的某列是否可编辑
1529
- (row.__old__ === true ? !this.oldReadonlyColKeys.includes(column._key) : true) && // 老数据行里某些列不可编辑
1530
- (row.__isQuote__ ? !this.quoteReadonlyColKeys.includes(column._key) : true) && // 引用的数据是否可编辑
1531
- (this.getSelfColCanEdit ? this.getSelfColCanEdit({ row, rowIndex, column }) : true) &&
1532
- (
1533
- ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(column._type)
1534
- ? column._summaryType
1535
- ? row.isLeaf === true
1536
- : ["downToUp", "upToDown"].includes(column._writeSort)
1537
- ? column._noLimitWrite === true
1538
- ? true
1539
- : ["downToUp"].includes(column._writeSort)
1540
- ? !(row.children && row.children.length) || row.children.every(sonRow => !this.$isEmptyData(sonRow[column._key]))
1541
- : row.level === 1 || !this.$isEmptyData(this.getParentRow(row, this.data)[column._key])
1542
- : true
1543
- : true
1544
- ) &&
1545
- !(["cascaderTable"].includes(this.controlType) && ["level", "children"].includes(column._key)) && // 层级表格的固定字段不可编辑
1546
- column._enterType !== "calculate" && // 计算的不可编辑
1547
- column._readonly !== true && // 只读
1548
- column._disabled !== true && // 只读
1549
- column.canEdit !== false; // 字段本身编辑权限 考虑为undefined时候
1550
- },
1551
-
1552
- /* ----------- 工具方法 ---------- */
1553
- // 初始化时 修复数据
1554
- fixRowData (row, levelNum) {
1555
- if (this.initFlag) {
1556
- // 配置端设置的地方,不会运行下面的,因为_default被过滤掉没值,defaultListDataIds就是空的
1557
- if (row._id) {
1558
- if (this.defaultListDataIds.includes(row._id)) {
1559
- row.__isDefault__ = true;
1560
-
1561
- // 默认数据的id置换一遍,不然每条数据里该列表的id都是重复的
1562
- const oldId = row._id;
1563
- const newId = this.$ObjectID().str;
1564
- row._id = newId;
1565
- this.idRecordMap[newId] = oldId;
1566
- }
1567
- } else {
1568
- row._id = this.$ObjectID().str;
1569
- }
1570
-
1571
- row.__old__ = this.isDftSet ? false : this.parentObj.__isCreate__ !== true; // 标记老数据
1572
- row.__isDefault__ = this.isDftSet ? true : !!row.__isDefault__; // 标记默认数据(配置端默认值)
1573
-
1574
- // 初次进来 把关于展示的状态值全部清除(只有层级表在用,按理说应放在DshTreeTableMixin.js,但为了清除三大表格的老数据,才放在这)
1575
- this.resetProperties.forEach(property => {
1576
- delete row[property];
1577
- });
1578
- }
1579
-
1580
- this.fixSelfRowData && this.fixSelfRowData(row, levelNum);
1581
- },
1582
- // 生成新的一行数据
1583
- getNewRowData (level, list) {
1584
- if (["cascaderTable"].includes(this.controlType)) {
1585
- return {
1586
- ...this.$deepCopy(this.selfRowDft),
1587
- ...(this.getSelfNewRowData ? this.$deepCopy(this.getSelfNewRowData(level, list)) : {}),
1588
- _id: this.$ObjectID().str,
1589
- level: level,
1590
- isLeaf: true,
1591
- children: [],
1592
- // __old__: false,
1593
- __isDefault__: this.isDftSet
1594
- };
1595
- } else {
1596
- return {
1597
- ...this.$deepCopy(this.selfRowDft),
1598
- _id: this.$ObjectID().str,
1599
- // __old__: false,
1600
- __isDefault__: this.isDftSet
1601
- };
1602
- }
1603
- },
1604
- // 获取父级行
1605
- getParentRow (row, tree = []) {
1606
- if (row.level === 1) {
1607
- return {
1608
- children: tree
1609
- };
1610
- } else {
1611
- let parentRow;
1612
-
1613
- const loop = (list = []) => {
1614
- return list.some(rowItem => {
1615
- if (rowItem.level === row.level - 1) {
1616
- const isExist = rowItem.children.some(childRowItem => childRowItem._id === row._id);
1617
- parentRow = rowItem;
1618
- return isExist;
1619
- } else {
1620
- return loop(rowItem.children);
1621
- }
1622
- });
1623
- };
1624
- loop(tree);
1625
-
1626
- return parentRow;
1627
- }
1628
- },
1629
- // // 单元格是否显示对比
1630
- // isShowCompare ({ row, rowIndex, column }) {
1631
- // const oldRow = this.compareListData[rowIndex] || {};
1632
- // const curVal = row[column._key];
1633
- // const oldVal = oldRow[column._key];
1634
-
1635
- // return this.useCampare &&
1636
- // ["number"].includes(column._type) &&
1637
- // !(this.$isEmptyData(curVal) && this.$isEmptyData(oldVal)) &&
1638
- // curVal !== oldVal;
1639
- // },
1640
- // 比较两行某列的值是否相等
1641
- isCompareSame (column, row, compareRow) {
1642
- const curColKey = column ? column._key : undefined;
1643
- const curColType = column ? column._type : undefined;
1644
-
1645
- return this.$isEmptyData(compareRow[curColKey]) && this.$isEmptyData(row[curColKey])
1646
- ? true
1647
- : ["users", "departments"].includes(curColType)
1648
- ? compareRow[curColKey].length === row[curColKey].length && compareRow[curColKey].every((item, index) => item._key === row[curColKey][index]._key)
1649
- : compareRow[curColKey] === row[curColKey];
1650
- },
1651
- // 行id + 分隔符 + 列key 组成键
1652
- getMixKey (row, column, splitStr = "--") {
1653
- return `${row._id}${splitStr}${column._key}`;
1654
- },
1655
- // 更新校验显示的标记
1656
- dealRuleRecord (row, column) {
1657
- // this.$set(this.ruleRecordMap, this.getMixKey(row, column), true);
1658
- this.ruleRecordMap[this.getMixKey(row, column)] = true;
1659
- }
1660
- }
1661
- };
1
+ import DshListUnit from "../../unit/DshListUnit.vue";
2
+ import importModal from "../common/importModal.vue";
3
+ import quoteListModal from "../common/quoteListModal.vue";
4
+
5
+ export default {
6
+ mixins: [],
7
+ components: {
8
+ DshListUnit,
9
+ importModal,
10
+ quoteListModal
11
+ },
12
+ props: {
13
+ canEdit: {
14
+ type: Boolean,
15
+ default: true
16
+ },
17
+ tableDataObj: {
18
+ type: Object,
19
+ default () {
20
+ return {};
21
+ }
22
+ },
23
+ data: {
24
+ type: Array,
25
+ default () {
26
+ return [];
27
+ }
28
+ },
29
+ rowDefault: {
30
+ type: Object,
31
+ default () {
32
+ return {};
33
+ }
34
+ },
35
+ columns: {
36
+ type: Array,
37
+ default () {
38
+ return [];
39
+ }
40
+ },
41
+ propsObj: {
42
+ type: Object,
43
+ default () {
44
+ return {};
45
+ }
46
+ },
47
+
48
+ parentObj: {
49
+ type: Object,
50
+ default () {
51
+ return {};
52
+ }
53
+ },
54
+ parentFormList: {
55
+ type: Array,
56
+ default () {
57
+ return [];
58
+ }
59
+ }
60
+
61
+ // compareData: {
62
+ // type: Array,
63
+ // default () {
64
+ // return [];
65
+ // }
66
+ // }
67
+ },
68
+ data () {
69
+ return {
70
+ widthMap: this.$getModFieldPropertyMap("width"),
71
+ dftInitValMap: this.$getModFieldPropertyMap("initDefaultVal"),
72
+ // saveProperties: ["__readonly__", "__isDefault__", "__old__", "__isQuote__"],
73
+ // resetProperties: ["__treeIndex__", "__isExpand__", "__isShow__", "__isTmpShow__"],
74
+ resetProperties: ["__treeIndex__", "__isExpand__", "__isShow__", "__isTmpShow__", "__isSearchShow__", "__isRendered__"],
75
+
76
+ initFlag: true,
77
+ isExpandAction: false,
78
+ // showRuleMessage: false, // 进行全体校验
79
+
80
+ idRecordMap: {}, // 默认id转换映射
81
+ // hoverRecordMap: {},
82
+ ruleRecordMap: {}, // 单元格是否发生校验的记录映射
83
+
84
+ showTopSearch: true,
85
+ selfLogicPropsObj: {
86
+ _name: "逻辑",
87
+ _key: "logic",
88
+ _optionKind: "flat",
89
+ _clearable: false,
90
+ _data: [
91
+ { _key: "and", name: "且" },
92
+ { _key: "or", name: "或" }
93
+ ]
94
+ },
95
+ dftAdvSearch: {
96
+ logic: "and",
97
+ conditions: []
98
+ },
99
+
100
+ isLoading: false,
101
+ selectIds: [],
102
+
103
+ dshRenderName: undefined,
104
+ hideStatus: true,
105
+ showQuoteModal: false,
106
+ showImportModal: false,
107
+ exportTimer: null,
108
+ isEnlarge: false,
109
+ isEnlargeFlag: false, // 为重渲染膜态框内容而用
110
+
111
+ baseOperationMap: {
112
+ canCreate: {
113
+ name: "添加一行",
114
+ tip: "添加一行",
115
+ type: "canCreate",
116
+ btnType: "default",
117
+ icon: "md-add",
118
+ size: "default",
119
+ long: true,
120
+ disabled: false,
121
+ event: "clickCreate"
122
+ },
123
+ canInsert: {
124
+ name: "插入一行",
125
+ tip: "插入一行",
126
+ type: "canInsert",
127
+ btnType: "primaryText",
128
+ icon: "md-add",
129
+ size: "small",
130
+ disabled: false,
131
+ event: "clickCreate"
132
+ },
133
+ canDelete: {
134
+ name: "删除",
135
+ tip: "删除该行",
136
+ type: "canDelete",
137
+ btnType: "errorText",
138
+ icon: "md-trash",
139
+ size: "small",
140
+ color: "#E83636",
141
+ disabled: false,
142
+ event: "clickDelete"
143
+ }
144
+ },
145
+ otherOperationMap: {
146
+ canQuickChangeVal: {
147
+ name: "立即改变值事件",
148
+ type: "canQuickChangeVal",
149
+ event: "quickChangeVal"
150
+ },
151
+ canChangeVal: {
152
+ name: "改变值事件",
153
+ type: "canChangeVal",
154
+ event: "changeVal"
155
+ }
156
+ },
157
+ topOperationMap: {
158
+ canHideOrShow: {
159
+ name: "显示/隐藏字段",
160
+ type: "canHideOrShow",
161
+ // icon: "md-share-alt",
162
+ size: "small",
163
+ btnType: "text",
164
+ event: "toggleHideOrShow"
165
+ },
166
+ canQuote: {
167
+ name: "引用",
168
+ type: "canQuote",
169
+ icon: "ios-copy",
170
+ size: "small",
171
+ btnType: "text",
172
+ event: "clickQuote"
173
+ },
174
+ canImport: {
175
+ name: "导入",
176
+ type: "canImport",
177
+ icon: "ios-create-outline",
178
+ size: "small",
179
+ btnType: "text",
180
+ event: "clickImport"
181
+ },
182
+ canExport: {
183
+ name: "导出",
184
+ type: "canExport",
185
+ icon: "md-share-alt",
186
+ size: "small",
187
+ btnType: "text",
188
+ event: "clickExport"
189
+ },
190
+ canEnlarge: {
191
+ name: "全屏",
192
+ type: "canEnlarge",
193
+ icon: "md-expand",
194
+ size: "small",
195
+ btnType: "text",
196
+ event: "clickEnlarge"
197
+ }
198
+ }
199
+ };
200
+ },
201
+ computed: {
202
+ appObj () {
203
+ return this.$store.getters.appObj || {};
204
+ },
205
+ appColor () {
206
+ return ((this.$appData.themeColors || {})[this.appObj.colorType] || {}).color || "#3DB8C5";
207
+ },
208
+
209
+ dshRender () {
210
+ return this[this.dshRenderName];
211
+ },
212
+ controlKey () {
213
+ return this.propsObj._key;
214
+ },
215
+ // 是否在字段默认值设置里使用
216
+ isDftSet () {
217
+ return this.controlKey === "_default";
218
+ },
219
+ controlType () {
220
+ return this.propsObj._type;
221
+ },
222
+ controlName () {
223
+ return this.propsObj._name;
224
+ },
225
+ modKey () {
226
+ return this.propsObj.modKey;
227
+ },
228
+ screenKey () {
229
+ return this.propsObj.screenKey;
230
+ },
231
+ allScreenKey () {
232
+ return this.propsObj.allScreenKey;
233
+ },
234
+ flowInstId () {
235
+ return this.propsObj.flowInstId;
236
+ },
237
+
238
+ commonPropsObj () {
239
+ return {
240
+ // isShare: false, // 是否是分享页在用
241
+ _subType: "default", // "default", "cross", "old"
242
+ _showMode: "default", // "default", "form"
243
+
244
+ _showRequired: true, // 表头显示校验符号*
245
+ _showDescription: true, // 表头显示提示
246
+ _contentHeight: 500, // 表格最大高度
247
+ _headHeightAuto: false, // 表头高度自适应
248
+ _heightAuto: false, // 单元格高度自适应
249
+ _useIndex: true, // 使用序号列
250
+ _useSummary: false, // 使用汇总行
251
+ _noborderColKeys: [], // 无边线的列
252
+ _bgColKeys: [], // 带背景色的列
253
+
254
+ _disabledBtns: false, // 禁用增删按钮
255
+ _showCreateBtnColKeys: [], // 显示增删图标的列
256
+ _useInsertInOperationCol: false, // 操作列出现插入行按钮
257
+ _disabledFootCreateBtn: false, // 禁用底部新增按钮
258
+ _disabledDeleteDftRow: false, // 默认的数据行禁止删除
259
+ _disabledDeleteOldRow: false, // 保存的数据行禁止删除
260
+ _dftReadonly: false, // 默认的数据只读
261
+ _dftReadonlyColKeys: [], // 默认的数据只读的列
262
+ _oldReadonly: false, // 保存的数据只读
263
+ _oldReadonlyColKeys: [], // 保存的数据只读的列
264
+
265
+ _searchList: [], // 作为搜索的字段
266
+ _searchLabelWidth: 100, // 搜索的label宽度
267
+ _tableAdvSearch: {
268
+ logic: "and",
269
+ conditions: []
270
+ }, // 筛选默认值(cascaderTable和flatTable组件里默认值情使用时,以及modSetForm里,会重置_tableAdvSearch)
271
+
272
+ _showOrHideColKeys: [], // 联动隐藏字段的keys
273
+ _showByNumFieldKey: "", // 控制联动隐藏字段的外层字段
274
+ _hideColKeys: [], // 隐藏/查看列字段的keys
275
+ _isQuote: false, // 引用
276
+ _quoteDisabledColKeys: [], // 引用数据行不可编辑列
277
+ _quoteListFields: [], // 引用列表的显示字段
278
+ _quoteAdvSearch: {
279
+ logic: "and",
280
+ conditions: []
281
+ }, // 引用列表筛选条件
282
+ _isImport: false, // 导入
283
+ _importAsDft: false, // 导入的数据作为默认数据
284
+ _isExport: false, // 导出
285
+ _useEnlarge: true, // 全屏
286
+
287
+ _default: {
288
+ rowDefault: {},
289
+ list: [],
290
+ tree: []
291
+ },
292
+ ...(this.selfBasePropsObj || {}),
293
+
294
+ ...this.propsObj
295
+ };
296
+ },
297
+ selfPropsObj () {
298
+ return {
299
+ ...this.commonPropsObj
300
+ };
301
+ },
302
+ // isShare () {
303
+ // return this.selfPropsObj.isShare;
304
+ // },
305
+ subType () {
306
+ return this.selfPropsObj._subType;
307
+ },
308
+ showMode () {
309
+ return this.selfPropsObj._showMode;
310
+ },
311
+ inTableType () {
312
+ return ["cascaderTable"].includes(this.controlType) && !["old"].includes(this.subType)
313
+ ? "treeTable"
314
+ : this.controlType;
315
+ },
316
+
317
+ contentHeight () {
318
+ return this.selfPropsObj._contentHeight === undefined
319
+ ? undefined
320
+ : this.selfPropsObj._contentHeight || 500;
321
+ },
322
+ showRequired () {
323
+ return this.selfPropsObj._showRequired;
324
+ },
325
+ showDescription () {
326
+ return this.selfPropsObj._showDescription;
327
+ },
328
+ headHeightAuto () {
329
+ return this.selfPropsObj._headHeightAuto;
330
+ },
331
+ heightAuto () {
332
+ return this.selfPropsObj._heightAuto;
333
+ },
334
+ useIndex () {
335
+ return this.selfPropsObj._useIndex;
336
+ },
337
+ useSummary () {
338
+ return this.selfPropsObj._useSummary;
339
+ },
340
+ noborderColKeys () {
341
+ return this.selfPropsObj._noborderColKeys;
342
+ },
343
+ bgColKeys () {
344
+ return this.selfPropsObj._bgColKeys;
345
+ },
346
+
347
+ disabledBtns () {
348
+ return this.isDftSet ? false : this.selfPropsObj._disabledBtns;
349
+ },
350
+ showCreateBtnColKeys () {
351
+ return this.selfPropsObj._showCreateBtnColKeys || []; // 配置端有问题,高级依赖时值成undefined了
352
+ },
353
+ useInsertInOperationCol () {
354
+ return this.selfPropsObj._useInsertInOperationCol;
355
+ },
356
+ disabledFootCreateBtn () {
357
+ return this.isDftSet ? false : this.selfPropsObj._disabledFootCreateBtn;
358
+ },
359
+ disabledDeleteDftRow () {
360
+ return this.isDftSet ? false : this.selfPropsObj._disabledDeleteDftRow;
361
+ },
362
+ disabledDeleteOldRow () {
363
+ return this.isDftSet ? false : this.selfPropsObj._disabledDeleteOldRow;
364
+ },
365
+ dftReadonly () {
366
+ return this.isDftSet ? false : this.selfPropsObj._dftReadonly;
367
+ },
368
+ dftReadonlyColKeys () {
369
+ return this.isDftSet ? [] : this.selfPropsObj._dftReadonlyColKeys || []; // 配置端有问题,高级依赖时值成undefined了
370
+ },
371
+ oldReadonly () {
372
+ return this.isDftSet ? false : this.selfPropsObj._oldReadonly;
373
+ },
374
+ oldReadonlyColKeys () {
375
+ return this.isDftSet ? [] : this.selfPropsObj._oldReadonlyColKeys || []; // 配置端有问题,高级依赖时值成undefined了
376
+ },
377
+
378
+ /* --- 筛选 --- */
379
+ searchLabelWidth () {
380
+ return this.selfPropsObj._searchLabelWidth;
381
+ },
382
+ searchList () {
383
+ return this.selfPropsObj._searchList;
384
+ },
385
+ searchListMap () {
386
+ return this.$arrToMap(this.searchList, "_key");
387
+ },
388
+ searchListFields () {
389
+ return this.searchList.map(searchItem => searchItem._key);
390
+ },
391
+ searchFormList () {
392
+ return this.$filterList(this.searchListFields, this.selfColumns).map(formItem => ({
393
+ ...formItem,
394
+ ...this.searchListMap[formItem._key],
395
+ _name: formItem._name
396
+ }));
397
+ },
398
+ tableAdvSearch () {
399
+ return this.$transformAdvSearch(this.selfPropsObj._tableAdvSearch, this.parentFormList, this.parentObj);
400
+ },
401
+ // 默认筛选配置里-隐藏的筛选条件
402
+ hideAdvSearch () {
403
+ return {
404
+ logic: ["and", "or"].includes(this.tableAdvSearch.logic) ? this.tableAdvSearch.logic : "and",
405
+ conditions: this.tableAdvSearch.conditions.filter(conditionItem =>
406
+ !this.searchListFields.includes(conditionItem.fieldKey)
407
+ )
408
+ };
409
+ },
410
+ // 过滤行数据的 最终的筛选条件
411
+ finalTableAdvSearch () {
412
+ return {
413
+ logic: "and",
414
+ conditions: [
415
+ this.hideAdvSearch,
416
+ this.dftAdvSearch
417
+ ]
418
+ };
419
+ },
420
+
421
+ // 是否筛选状态
422
+ isSearching () {
423
+ return this.parentObj.__isCreate__ === true
424
+ ? false
425
+ : this.$isAdvSearching(this.finalTableAdvSearch);
426
+ },
427
+ searchTitle () {
428
+ return `${this.isSearching ? "筛选" : "全部"}数据;`;
429
+ },
430
+
431
+ /* --- 列字段 --- */
432
+ // columns => selfColumns => usedColumns => contentColumns => showContentColumns => showColumns
433
+ selfColumns () {
434
+ // console.log("selfColumns");
435
+ return this.columns;
436
+ },
437
+ usedColumns () {
438
+ // console.log("usedColumns");
439
+ const list = this.selfColumns.filter(colItem =>
440
+ this.showOrHideColKeys.includes(colItem._key)
441
+ ? this.showColKeys.includes(colItem._key)
442
+ : true
443
+ );
444
+
445
+ return list.filter(colItem => this.$isAdvRelyShow(colItem, this.allListData, this.parentObj, true));
446
+ },
447
+ contentColumns () {
448
+ return this.usedColumns.map(colItem => ({
449
+ renderHeaderCell: ({ column }, h) => {
450
+ return this.contentThCellRender(h, { column });
451
+ },
452
+ renderBodyCell: ({ row, rowIndex, column }, h) => {
453
+ return this.contentTdCellRender(h, { row, rowIndex, column });
454
+ },
455
+ ...colItem
456
+ }));
457
+ },
458
+ showContentColumns () {
459
+ return this.contentColumns.filter(colItem =>
460
+ this.hideStatus === true
461
+ ? !this.hideColKeys.includes(colItem._key)
462
+ : true
463
+ );
464
+ },
465
+ selectionColumn () {
466
+ return {
467
+ _key: "__selection__",
468
+ key: "__selection__",
469
+ field: "__selection__",
470
+ type: "checkbox",
471
+ width: 50,
472
+ align: "center",
473
+ fixed: "left"
474
+ };
475
+ },
476
+ operationColumn () {
477
+ return {
478
+ title: "操作",
479
+ _key: "__operation__",
480
+ key: "__operation__",
481
+ field: "__operation__",
482
+ _align: "center",
483
+ align: "center",
484
+ _fixed: "right",
485
+ fixed: "right",
486
+ _width: 100 + (this.rowOperationList.length - 1) * 110,
487
+ width: 100 + (this.rowOperationList.length - 1) * 110,
488
+ renderBodyCell: ({ row, rowIndex, column }, h) => {
489
+ return this.operationTdCellRender(h, { row, rowIndex, column });
490
+ }
491
+ };
492
+ },
493
+
494
+ /* --- 表格参数 --- */
495
+ tablePropsObj () {
496
+ return {
497
+ // rowStyleOption: {
498
+ // hoverHighlight: true,
499
+ // clickHighlight: true,
500
+ // stripe: true // 斑马纹
501
+ // },
502
+ maxHeight: this.contentHeight,
503
+ // 通过实例方法 hideColumnsByKeys(keys)将列隐藏,通过实例方法 showColumnsByKeys(keys)将隐藏的列显示
504
+ columnHiddenOption: {
505
+ // defaultHiddenColumnKeys: [...this.hideColKeys] // 必须这么写,不解构,切换一次隐藏/显示后,hideColKeys会变成空数组
506
+ },
507
+ cellStyleOption: {
508
+ bodyCellClass: this.bodyCellClass
509
+ },
510
+ cellSpanOption: {
511
+ bodyCellSpan: this.bodyCellSpan
512
+ },
513
+ eventCustomOption: {
514
+ bodyCellEvents: this.eventCustomOption
515
+ }
516
+ };
517
+ },
518
+ tableInModalPropsObj () {
519
+ return {
520
+ ...this.tablePropsObj,
521
+ maxHeight: undefined
522
+ };
523
+ },
524
+ checkboxOption () {
525
+ return {
526
+ selectedRowKeys: this.selectIds
527
+ };
528
+ },
529
+
530
+ /* --- 联动隐藏 --- */
531
+ showColKeys () {
532
+ return this.showByNumFieldVal != null && this.showByNumFieldVal >= 0
533
+ ? this.showOrHideColKeys.slice(0, this.showByNumFieldVal)
534
+ : this.showOrHideColKeys;
535
+ },
536
+ showOrHideColKeys () {
537
+ return this.selfPropsObj._showOrHideColKeys || [];
538
+ },
539
+ // 控制联动隐藏的数字类型字段
540
+ showByNumFieldKey () {
541
+ return this.selfPropsObj._showByNumFieldKey;
542
+ },
543
+ // 控制联动隐藏的数字类型字段的值
544
+ showByNumFieldVal () {
545
+ return this.showByNumFieldKey
546
+ ? this.parentObj[this.showByNumFieldKey]
547
+ : undefined;
548
+ },
549
+
550
+ /* --- 显示/隐藏 --- */
551
+ hideColKeys () {
552
+ return this.selfPropsObj._hideColKeys;
553
+ },
554
+
555
+ /* --- 引用 --- */
556
+ isQuote () {
557
+ return this.selfPropsObj._isQuote;
558
+ },
559
+ quoteReadonlyColKeys () {
560
+ return this.selfPropsObj._quoteDisabledColKeys;
561
+ },
562
+ quoteListFields () {
563
+ return this.selfPropsObj._quoteListFields;
564
+ },
565
+ quoteAdvSearch () {
566
+ return this.$transformAdvSearch(this.selfPropsObj._quoteAdvSearch, this.parentFormList, this.parentObj);
567
+ },
568
+ quoteParams () {
569
+ return {
570
+ screenKey: this.allScreenKey,
571
+ fields: [
572
+ ...this.quoteListFields,
573
+ this.controlKey,
574
+ "createdAt"
575
+ ],
576
+ advSearch: {
577
+ logic: "and",
578
+ conditions: [
579
+ {
580
+ fieldKey: "_id",
581
+ fieldOperator: "ne",
582
+ fieldValue: [this.parentDataId]
583
+ },
584
+ this.quoteAdvSearch
585
+ ]
586
+ }
587
+ };
588
+ },
589
+
590
+ /* --- 导入 --- */
591
+ isImport () {
592
+ return this.selfPropsObj._isImport;
593
+ },
594
+ importAsDft () {
595
+ return this.selfPropsObj._importAsDft;
596
+ },
597
+ importParams () {
598
+ return {
599
+ _id: this.parentDataId,
600
+ _key: this.controlKey,
601
+ importType: this.inTableType
602
+ };
603
+ },
604
+
605
+ /* --- 导出 --- */
606
+ isExport () {
607
+ return this.selfPropsObj._isExport;
608
+ },
609
+ exportParams () {
610
+ return {
611
+ screenKey: this.screenKey,
612
+ _id: this.parentDataId,
613
+ _key: this.controlKey,
614
+ flowinst: this.flowInstId,
615
+ advSearch: this.finalTableAdvSearch
616
+ };
617
+ },
618
+
619
+ /* --- 全屏 --- */
620
+ useEnlarge () {
621
+ return this.selfPropsObj._useEnlarge;
622
+ },
623
+ modalPropsObj () {
624
+ return {
625
+ mode: "fullscreen",
626
+ title: this.controlName
627
+ };
628
+ },
629
+
630
+ /* --- 数据 --- */
631
+ // 默认值数据
632
+ defaultListData () {
633
+ const loop = (tree = [], list = []) => {
634
+ return tree.reduce((newList, rowItem) => {
635
+ newList = [...newList, rowItem];
636
+
637
+ return rowItem.children && rowItem.children.length
638
+ ? loop(rowItem.children, newList)
639
+ : newList;
640
+ }, list);
641
+ };
642
+
643
+ return ["cascaderTable"].includes(this.controlType)
644
+ ? loop(this.selfPropsObj._default.tree)
645
+ : this.selfPropsObj._default.list;
646
+ },
647
+ defaultListDataIds () {
648
+ return this.defaultListData
649
+ .map(rowItem => rowItem._id)
650
+ .filter(id => !!id);
651
+ },
652
+ // 全部数据(或筛选出的数据)-总数
653
+ selfTotal () {
654
+ return this.showListData.length;
655
+ },
656
+
657
+ // 新增行的默认值
658
+ selfRowDft () {
659
+ return this.selfColumns.reduce((obj, column) => {
660
+ const dftInRowVal = this.rowDefault[column._key];
661
+ const dftVal = column._default;
662
+ const dftInitVal = this.dftInitValMap[column._type];
663
+
664
+ return Object.assign(obj, {
665
+ [column._key]: dftInRowVal === undefined // 不用isEmptyData判断原因:为空值时可能是故意置空的
666
+ ? this.$isEmptyData(dftVal)
667
+ ? dftInitVal
668
+ : dftVal
669
+ : dftInRowVal
670
+ });
671
+ }, {});
672
+ },
673
+ parentDataId () {
674
+ return this.parentObj._id;
675
+ },
676
+ // compareListData () {
677
+ // this.compareData.forEach(item => {
678
+ // !item._id && this.$set(item, "_id", this.$ObjectID().str);
679
+ // });
680
+ // return this.compareData;
681
+ // },
682
+ // useCampare () {
683
+ // return !!this.compareListData.length;
684
+ // },
685
+ changedCols () {
686
+ return [];
687
+ },
688
+
689
+ /* --- 功能按钮 --- */
690
+ baseOperationBtns () {
691
+ return Object.keys(this.baseOperationMap);
692
+ },
693
+ otherOperationBtns () {
694
+ return Object.keys(this.otherOperationMap);
695
+ },
696
+ topOperationBtns () {
697
+ return Object.keys(this.topOperationMap);
698
+ },
699
+ allOperationMap () {
700
+ return {
701
+ ...(this.baseOperationMap || {}),
702
+ ...(this.otherOperationMap || {}),
703
+ ...(this.topOperationMap || {}),
704
+
705
+ canCreate: {
706
+ ...this.baseOperationMap.canCreate,
707
+ name: this.showMode === "form"
708
+ ? this.baseOperationMap.canCreate.name.replace("行", "条")
709
+ : this.baseOperationMap.canCreate.name,
710
+ tip: this.showMode === "form"
711
+ ? this.baseOperationMap.canCreate.tip.replace("行", "条")
712
+ : this.baseOperationMap.canCreate.tip
713
+ },
714
+ canInsert: {
715
+ ...this.baseOperationMap.canInsert,
716
+ name: this.showMode === "form"
717
+ ? this.baseOperationMap.canInsert.name.replace("行", "条")
718
+ : this.baseOperationMap.canInsert.name,
719
+ tip: this.showMode === "form"
720
+ ? this.baseOperationMap.canInsert.tip.replace("行", "条")
721
+ : this.baseOperationMap.canInsert.tip,
722
+ color: this.appColor
723
+ },
724
+ canHideOrShow: {
725
+ ...this.topOperationMap.canHideOrShow,
726
+ name: this.hideStatus ? "显示字段" : "隐藏字段"
727
+ },
728
+
729
+ ...(this.selfAllOperationMap || {})
730
+ };
731
+ },
732
+ operationMap () {
733
+ return this.$categoryMapToMap(
734
+ this.allOperationMap,
735
+ undefined,
736
+ undefined,
737
+ [
738
+ ...(
739
+ this.canEdit
740
+ ? [
741
+ ...(this.disabledBtns ? [] : this.baseOperationBtns),
742
+ ...this.otherOperationBtns,
743
+ ...(this.isQuote ? ["canQuote"] : []),
744
+ ...(this.isImport ? ["canImport"] : [])
745
+ ]
746
+ : []
747
+ ),
748
+ ...(this.isExport ? ["canExport"] : []),
749
+ ...(this.useEnlarge ? ["canEnlarge"] : []),
750
+ ...(this.hideColKeys.length ? ["canHideOrShow"] : [])
751
+ ]
752
+ );
753
+ },
754
+ rowOperationList () {
755
+ const btns = [
756
+ ...(this.useInsertInOperationCol ? ["canInsert"] : []),
757
+ "canDelete"
758
+ ];
759
+ return this.$getOperationList(btns);
760
+ }
761
+ },
762
+ watch: {
763
+ isEnlarge (bool) {
764
+ setTimeout(() => {
765
+ this.isEnlargeFlag = bool;
766
+ // this.dealingOpenModal && this.dealingOpenModal();
767
+ }, 0);
768
+ }
769
+ },
770
+ created () {
771
+ this.baseInit();
772
+ },
773
+ methods: {
774
+ baseInit () {
775
+ this.dftAdvSearch = {
776
+ logic: ["and", "or"].includes(this.tableAdvSearch.logic) ? this.tableAdvSearch.logic : "and",
777
+ conditions: this.tableAdvSearch.conditions.filter(conditionItem =>
778
+ this.searchListFields.includes(conditionItem.fieldKey)
779
+ )
780
+ };
781
+
782
+ this.loadingFunc();
783
+ },
784
+
785
+ // 共外部使用
786
+ validate () {
787
+ // this.showRuleMessage = true;
788
+ // return this.allListData.every((row, rowIndex) => this.getRowRuleResult(row, rowIndex));
789
+
790
+ let bool = true;
791
+ this.allListData.forEach((row, rowIndex) => {
792
+ const resultBool = this.getRowRuleResult(row, rowIndex);
793
+
794
+ if (resultBool === false) {
795
+ bool = false;
796
+ }
797
+ });
798
+
799
+ return bool;
800
+ },
801
+ // 重置
802
+ reset () {
803
+ this.initFlag = true;
804
+ this.isExpandAction = false;
805
+ // this.showRuleMessage = false;
806
+
807
+ this.idRecordMap = {};
808
+ // this.hoverRecordMap = {};
809
+ this.ruleRecordMap = {};
810
+
811
+ this.dftAdvSearch = {
812
+ logic: "and",
813
+ conditions: []
814
+ };
815
+ this.hideStatus = true;
816
+
817
+ this.changePage && this.changePage(1);
818
+ this.selfReset && this.selfReset();
819
+ },
820
+ loadingFunc () {
821
+ this.isLoading = true;
822
+ this.changeSelect();
823
+
824
+ setTimeout(() => {
825
+ this.isLoading = false;
826
+ });
827
+ },
828
+
829
+ // 筛选回调
830
+ searchCb (conditions) {
831
+ if (this.parentObj.__isCreate__ !== true) {
832
+ this.isExpandAction = false;
833
+ this.dftAdvSearch.conditions = conditions;
834
+
835
+ this.changePage && this.changePage(1);
836
+ }
837
+ },
838
+ // 列表选择项改变 (!!!外部在使用)
839
+ changeSelect (selections = [], ...params) {
840
+ this.selectIds = selections.map(item => item._id);
841
+ this.$emit("changeSelect", this.selectIds, selections, ...params);
842
+ },
843
+
844
+ // 输入框失去焦点
845
+ controlBlur (operationItem, row, rowIndex, column, params) {
846
+ this.dealRuleRecord(row, column);
847
+ },
848
+ // 输入框值改变立即
849
+ quickChangeVal (operationItem, row, rowIndex, column, params) {
850
+ if (["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
851
+ this.dealRuleRecord(row, column);
852
+ this.change("quickChangeVal", row, rowIndex, column, ...params);
853
+ }
854
+ },
855
+ // 输入框值改变
856
+ changeVal (operationItem, row, rowIndex, column, params) {
857
+ if (!["text", "textarea", "idcard", "email", "phone", "url", "password"].includes(column._type)) {
858
+ this.dealRuleRecord(row, column);
859
+ this.change("changeVal", row, rowIndex, column, ...params);
860
+ }
861
+ },
862
+ change (eventType, row, rowIndex, column, ...params) {
863
+ this.$emit("change", this.tableDataObj, eventType, column, row, rowIndex, ...params);
864
+ },
865
+
866
+ /* ----------- 隐藏/显示字段 ---------- */
867
+ toggleHideOrShow () {
868
+ // if (this.$refs.briTable) {
869
+ // if (this.hideStatus === true) {
870
+ // this.$refs.briTable.showColumnsByKeys(this.hideColKeys);
871
+ // } else {
872
+ // this.$refs.briTable.hideColumnsByKeys(this.hideColKeys);
873
+ // }
874
+ // }
875
+
876
+ this.hideStatus = !this.hideStatus;
877
+ },
878
+
879
+ /* ----------- 引用 ---------- */
880
+ // 点击引用
881
+ clickQuote () {
882
+ this.dshRenderName = "quoteModalRender";
883
+ this.showQuoteModal = true;
884
+ },
885
+ // 引用模态框渲染函数
886
+ quoteModalRender (h, params) {
887
+ return this.showQuoteModal
888
+ ? h("quote-list-modal", {
889
+ props: {
890
+ value: this.showQuoteModal,
891
+ propsObj: this.propsObj,
892
+ listParams: this.quoteParams
893
+ },
894
+ on: {
895
+ input: bool => {
896
+ this.showQuoteModal = bool;
897
+ },
898
+ confirm: this.quoteCb
899
+ }
900
+ })
901
+ : undefined;
902
+ },
903
+ // 引用回调
904
+ quoteCb (dataObj) {
905
+ if (dataObj) {
906
+ const fieldVal = dataObj[this.controlKey];
907
+ const isEmpty = this.$isEmptyData(fieldVal) || (
908
+ ["cascaderTable"].includes(this.controlType)
909
+ ? !fieldVal.tree || !fieldVal.tree.length
910
+ : ["flatTable"].includes(this.controlType)
911
+ ? !fieldVal.list || !fieldVal.list.length
912
+ : false
913
+ );
914
+
915
+ if (isEmpty) {
916
+ this.$Modal.confirm({
917
+ title: "提示",
918
+ content: "该数据下此内容为空,无法引用!",
919
+ onOk: () => { }
920
+ });
921
+ }
922
+ else {
923
+ if (["cascaderTable"].includes(this.controlType)) {
924
+ const transformData = (list = []) => {
925
+ const loop = (list = []) =>
926
+ list.map(item => ({
927
+ ...item,
928
+ children: item.children ? loop(item.children) : item.children,
929
+ __isQuote__: true,
930
+ __old__: false
931
+ }));
932
+
933
+ return loop(list);
934
+ };
935
+
936
+ this.parentObj[this.controlKey] = {
937
+ ...fieldVal,
938
+ tree: transformData(fieldVal.tree)
939
+ };
940
+ }
941
+ else if (["flatTable"].includes(this.controlType)) {
942
+ this.parentObj[this.controlKey] = {
943
+ ...fieldVal,
944
+ list: fieldVal.list.map(item => ({
945
+ ...item,
946
+ __isQuote__: true,
947
+ __old__: false
948
+ }))
949
+ };
950
+ }
951
+
952
+ this.$Message.success("引用成功!");
953
+ this.reset();
954
+ this.showTopSearch = false;
955
+ this.$nextTick(() => {
956
+ this.showTopSearch = true;
957
+ });
958
+
959
+ this.change("quote");
960
+ }
961
+ } else {
962
+ this.$Message.error("未选择引用数据!");
963
+ }
964
+ },
965
+
966
+ /* ----------- 导入 ---------- */
967
+ // 点击导入
968
+ clickImport () {
969
+ this.dshRenderName = "importModalRender";
970
+ this.showImportModal = true;
971
+ },
972
+ // 导入模态框渲染函数
973
+ importModalRender (h, params) {
974
+ return this.showImportModal
975
+ ? h("import-modal", {
976
+ props: {
977
+ value: this.showImportModal,
978
+ propsObj: this.propsObj,
979
+ importParams: this.importParams
980
+ },
981
+ on: {
982
+ input: bool => {
983
+ this.showImportModal = bool;
984
+ },
985
+ importCb: this.importCb
986
+ }
987
+ })
988
+ : undefined;
989
+ },
990
+ // 导入回调
991
+ importCb (dataObj) {
992
+ const fieldVal = dataObj;
993
+ if (this.importAsDft) {
994
+ if (["cascaderTable"].includes(this.controlType)) {
995
+ const transformData = (list = []) => {
996
+ const loop = (list = []) =>
997
+ list.map(item => ({
998
+ ...item,
999
+ children: item.children ? loop(item.children) : item.children,
1000
+ __isDefault__: true,
1001
+ __old__: false
1002
+ }));
1003
+
1004
+ return loop(list);
1005
+ };
1006
+
1007
+ this.parentObj[this.controlKey] = {
1008
+ ...fieldVal,
1009
+ tree: transformData(fieldVal.tree)
1010
+ };
1011
+ }
1012
+ else if (["flatTable"].includes(this.controlType)) {
1013
+ this.parentObj[this.controlKey] = {
1014
+ ...fieldVal,
1015
+ list: fieldVal.list.map(item => ({
1016
+ ...item,
1017
+ __isDefault__: true,
1018
+ __old__: false
1019
+ }))
1020
+ };
1021
+ }
1022
+ } else {
1023
+ this.parentObj[this.controlKey] = dataObj;
1024
+ }
1025
+
1026
+ // 因为data和rowspanMap不马上更新
1027
+ this.$nextTick(() => {
1028
+ this.reset();
1029
+ this.change("import");
1030
+ });
1031
+ },
1032
+
1033
+ /* ----------- 导出 ---------- */
1034
+ // 点击导出
1035
+ clickExport (operationItem) {
1036
+ this.handleExport(operationItem);
1037
+ },
1038
+ // 接口 -导出
1039
+ handleExport (operationItem) {
1040
+ operationItem.disabled = true;
1041
+
1042
+ this.$https({
1043
+ url: {
1044
+ module: "sheet",
1045
+ name: ["cascaderTable"].includes(this.controlType) ? "exportCascaderTableExcel" : "exportFlatTableExcel"
1046
+ },
1047
+ params: this.exportParams,
1048
+ callback: data => {
1049
+ this.getJobStatus(operationItem, data.jobId, data.excel_url);
1050
+ this.exportTimer = setInterval(() => {
1051
+ this.getJobStatus(operationItem, data.jobId, data.excel_url);
1052
+ }, 1000);
1053
+ }
1054
+ });
1055
+ },
1056
+ // 接口 -获取导出地址
1057
+ getJobStatus (operationItem, id, url) {
1058
+ this.$https({
1059
+ url: {
1060
+ module: "sheet",
1061
+ name: "getJobStatus"
1062
+ },
1063
+ params: {
1064
+ jobId: id
1065
+ },
1066
+ callback: data => {
1067
+ if (data.status === "completed") {
1068
+ operationItem.disabled = false;
1069
+ clearInterval(this.exportTimer);
1070
+ window.location.href = data.url;
1071
+ } else if (data.status === "failed") {
1072
+ this.$Message.info({
1073
+ content: "操作失败,请稍后再试!"
1074
+ });
1075
+ }
1076
+ },
1077
+ error: res => {
1078
+ operationItem.disabled = false;
1079
+ this.exportTimer = null;
1080
+ }
1081
+ });
1082
+ },
1083
+
1084
+ /* ----------- 全屏 ---------- */
1085
+ // 打开全屏模态框
1086
+ clickEnlarge (operationItem) {
1087
+ this.isEnlarge = true;
1088
+ },
1089
+
1090
+ /* ----------- 渲染函数(声明:为了代码更加规范清晰,return的是h相关的函数,则函数名get开头;return的是h的直接调用,函数名不要get开头)---------- */
1091
+ getTableTopRender (inEnlarge = false) {
1092
+ return (h, params) => {
1093
+ return h("div", {
1094
+ style: {
1095
+ "margin-bottom": "3px",
1096
+ "display": "flex",
1097
+ "flex-direction": "row",
1098
+ "justify-content": "space-between",
1099
+ "align-items": "center"
1100
+ }
1101
+ }, [
1102
+ // 左 -统计,逻辑
1103
+ this.topSummaryRender(h),
1104
+
1105
+ // 右 -功能按钮
1106
+ this.topOperationRender(h, inEnlarge)
1107
+ ]);
1108
+ };
1109
+ },
1110
+ topSummaryRender (h) {
1111
+ return this.searchFormList.length
1112
+ ? h("div", {
1113
+ style: {
1114
+ "display": "flex",
1115
+ "flex-direction": "row",
1116
+ "align-items": "center"
1117
+ }
1118
+ }, [
1119
+ h("span", {
1120
+ style: {
1121
+ "font-weight": "500"
1122
+ }
1123
+ }, this.searchTitle),
1124
+
1125
+ h("div", {
1126
+ style: {
1127
+ "display": "flex",
1128
+ "flex-direction": "row",
1129
+ "align-items": "center",
1130
+ "margin-left": "12px"
1131
+ }
1132
+ }, [
1133
+ h("div", {
1134
+ style: {
1135
+ "font-weight": "500"
1136
+ }
1137
+ }, this.selfLogicPropsObj._name + ":"),
1138
+
1139
+ h("dsh-select", {
1140
+ style: {
1141
+ "margin-left": "8px",
1142
+ "margin-top": "-4px"
1143
+ },
1144
+ props: {
1145
+ value: this.dftAdvSearch,
1146
+ propsObj: this.selfLogicPropsObj
1147
+ }
1148
+ })
1149
+ ])
1150
+ ])
1151
+ : h("div", "");
1152
+ },
1153
+ // 全屏里不显示功能按钮
1154
+ topOperationRender (h, inEnlarge) {
1155
+ return inEnlarge
1156
+ ? undefined
1157
+ : h("dsh-buttons", {
1158
+ style: {
1159
+ "text-align": "right"
1160
+ },
1161
+ props: {
1162
+ itemClass: undefined,
1163
+ list: this.$getOperationList(this.topOperationBtns)
1164
+ },
1165
+ on: {
1166
+ click: (event) => {
1167
+ this.$dispatchEvent(event);
1168
+ }
1169
+ },
1170
+ nativeOn: {
1171
+ click: (e) => {
1172
+ e.stopPropagation();
1173
+ }
1174
+ }
1175
+ });
1176
+ },
1177
+ topSearchRender (h) {
1178
+ return this.searchFormList.length
1179
+ ? h("dsh-default-search", {
1180
+ props: {
1181
+ formList: this.searchFormList,
1182
+ initValue: this.dftAdvSearch.conditions,
1183
+ labelWidth: this.searchLabelWidth
1184
+ },
1185
+ on: {
1186
+ change: this.searchCb
1187
+ }
1188
+ })
1189
+ : undefined;
1190
+ },
1191
+ createBtnRender (h) {
1192
+ return !this.isSearching && this.disabledFootCreateBtn !== true
1193
+ ? h("dsh-buttons", {
1194
+ style: {
1195
+ "margin-top": "3px"
1196
+ },
1197
+ props: {
1198
+ itemClass: undefined,
1199
+ list: this.$getOperationList(["canCreate"])
1200
+ },
1201
+ on: {
1202
+ click: (event) => {
1203
+ this.$dispatchEvent(event);
1204
+ }
1205
+ }
1206
+ })
1207
+ : undefined;
1208
+ },
1209
+ contentThCellRender (h, { column }) {
1210
+ column = this.$transformDynamicProperty(column, undefined, this.parentObj);
1211
+ // console.log(column._name);
1212
+
1213
+ return this.$getHeadRender(h, column, {
1214
+ showRequired: this.showRequired,
1215
+ showDescription: this.showDescription,
1216
+ headHeightAuto: this.headHeightAuto
1217
+ });
1218
+ },
1219
+ contentTdCellRender (h, { row, rowIndex, column }) {
1220
+ // console.log(rowIndex);
1221
+ column = this.$transformDynamicProperty(column, row, this.parentObj);
1222
+ column = this.getResetCol({ row, rowIndex, column });
1223
+ const unitCanEdit = this.getUnitCanEdit({ row, rowIndex, column });
1224
+ const ruleResultObj = this.getColRuleResult({ row, rowIndex, column });
1225
+
1226
+ return [
1227
+ // this.isShowCompare({ row, rowIndex, column })
1228
+ // ? h("Tooltip", {
1229
+ // style: {
1230
+ // width: "100%"
1231
+ // },
1232
+ // props: {
1233
+ // content: this.$isEmptyData(this.compareListData[rowIndex][column._key]) ? "" : this.compareListData[rowIndex][column._key],
1234
+ // transfer: true,
1235
+ // maxWidth: 200,
1236
+ // placement: "top"
1237
+ // },
1238
+ // scopedSlots: {
1239
+ // default: props => h("dsh-list-unit", {
1240
+ // props: {
1241
+ // canEdit: unitCanEdit,
1242
+ // formData: row,
1243
+ // formItem: {
1244
+ // ...column,
1245
+ // _key: column.colType === "tree" ? "name" : column._key
1246
+ // },
1247
+ // allFormList: this.selfColumns,
1248
+ // inTableType: this.inTableType,
1249
+ // allListRows: this.allListData,
1250
+ // rowIndex: rowIndex,
1251
+ // parentFormList: this.parentFormList,
1252
+ // parentObj: this.parentObj
1253
+ // },
1254
+ // on: {
1255
+ // blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1256
+ // quickChange: () => this.$dispatchEvent(this.operationMap.canQuickChangeVal, row, rowIndex, column, arguments),
1257
+ // change: () => this.$dispatchEvent(this.operationMap.canChangeVal, row, rowIndex, column, arguments)
1258
+ // }
1259
+ // })
1260
+ // }
1261
+ // })
1262
+ h("dsh-list-unit", {
1263
+ key: `${row._id}--${column._key}`,
1264
+ props: {
1265
+ canEdit: unitCanEdit,
1266
+ formData: row,
1267
+ formItem: {
1268
+ ...column,
1269
+ _key: column.colType === "tree" ? "name" : column._key
1270
+ },
1271
+ allFormList: this.selfColumns,
1272
+ changedCols: this.changedCols,
1273
+ changedFields: (row.__changed__ || []).map(item => item.fieldKey),
1274
+ inTableType: this.inTableType,
1275
+ allListRows: this.allListData,
1276
+ rowIndex: rowIndex,
1277
+ parentFormList: this.parentFormList,
1278
+ parentObj: this.parentObj
1279
+ },
1280
+ on: {
1281
+ blur: () => this.controlBlur(null, row, rowIndex, column, arguments),
1282
+ quickChange: () => this.$dispatchEvent(this.operationMap.canQuickChangeVal, row, rowIndex, column, arguments),
1283
+ change: () => this.$dispatchEvent(this.operationMap.canChangeVal, row, rowIndex, column, arguments)
1284
+ }
1285
+ }),
1286
+
1287
+ // 校验文字
1288
+ !ruleResultObj.bool
1289
+ ? h("span", {
1290
+ class: "bri-table-td-tip"
1291
+ }, ruleResultObj.message)
1292
+ : undefined,
1293
+
1294
+ // 添加符
1295
+ ...this.operationIconRender(h, { row, rowIndex, column }, 12)
1296
+ ];
1297
+ },
1298
+ operationTdCellRender (h, { row, rowIndex, column }) {
1299
+ const operationList = this.rowOperationList.map(btnItem => ({
1300
+ ...btnItem,
1301
+ disabled: btnItem.type === "canDelete"
1302
+ ? !this.getRowDelBtnCanEdit(row, rowIndex)
1303
+ : btnItem.disabled
1304
+ }));
1305
+
1306
+ return [
1307
+ h("dsh-buttons", {
1308
+ props: {
1309
+ list: operationList
1310
+ },
1311
+ on: {
1312
+ click: (operationItem) => {
1313
+ this.$dispatchEvent(operationItem, row, rowIndex, column);
1314
+ }
1315
+ }
1316
+ })
1317
+ ];
1318
+ },
1319
+ operationIconRender (h, { row, rowIndex, column }, iconSize = 14) {
1320
+ const baseBool = !this.isSearching &&
1321
+ (this.showCreateBtnColKeys.length ? this.showCreateBtnColKeys.includes(column._key) : ["__index__", "__treeIndex__"].includes(column._key));
1322
+ // this.hoverRecordMap[`${row._id}`];
1323
+
1324
+ return [
1325
+ // 插入一行图标
1326
+ baseBool
1327
+ ? this.getOperationIconRender(h, { row, rowIndex, column }, "canInsert", iconSize)
1328
+ : h("span", ""),
1329
+
1330
+ // 添加一行下级图标
1331
+ baseBool &&
1332
+ row.level < this.maxLevel &&
1333
+ !["cascaderTable"].includes(this.inTableType) // 老版级联表格类型不要“添加下级”图标
1334
+ ? this.getOperationIconRender(h, { row, rowIndex, column }, "canCreateChild", iconSize, true)
1335
+ : h("span", ""),
1336
+
1337
+ // 删除该行图标
1338
+ baseBool &&
1339
+ this.getRowDelBtnCanEdit(row, rowIndex) &&
1340
+ ["cascaderTable"].includes(this.inTableType)
1341
+ ? this.getOperationIconRender(h, { row, rowIndex, column }, "canDelete", iconSize, true)
1342
+ : h("span", "")
1343
+ ];
1344
+ },
1345
+ getOperationIconRender (h, { row, rowIndex, column }, operationType, iconSize = 14, isLeft = false) {
1346
+ const operationItem = this.operationMap[operationType];
1347
+
1348
+ return operationItem && operationItem.disabled !== true
1349
+ ? h("div", {
1350
+ style: {
1351
+ position: "absolute",
1352
+ bottom: "0px",
1353
+ right: isLeft ? `${iconSize + 3}px` : "0px",
1354
+ width: `${iconSize + 2}px`,
1355
+ height: `${iconSize + 2}px`,
1356
+ border: `1px solid ${operationItem.color}`,
1357
+ borderRadius: "2px",
1358
+ backgroundColor: "#ffffff",
1359
+ lineHeight: `${iconSize - 2}px`,
1360
+ cursor: "pointer",
1361
+ verticalAlign: "middle",
1362
+ transition: "color .2s ease-in-out,border-color .2s ease-in-out"
1363
+ }
1364
+ }, [
1365
+ h("Tooltip", {
1366
+ props: {
1367
+ content: operationItem.tip,
1368
+ maxWidth: "250",
1369
+ transfer: true
1370
+ }
1371
+ }, [
1372
+ h("Icon", {
1373
+ style: {
1374
+ fontWeight: "500",
1375
+ color: operationItem.color
1376
+ },
1377
+ props: {
1378
+ type: operationItem.icon,
1379
+ size: iconSize
1380
+ },
1381
+ on: {
1382
+ click: () => {
1383
+ this.$dispatchEvent(operationItem, row, rowIndex, column);
1384
+ }
1385
+ }
1386
+ })
1387
+ ])
1388
+ ])
1389
+ : h("span", "");
1390
+ },
1391
+ bodyCellClass ({ row, rowIndex, column }) {
1392
+ return "bri-table-td" +
1393
+ `${["__treeIndex__"].includes(column._key)
1394
+ ? " bri-table-td-treeIndex"
1395
+ : this.getRowCanEdit(row, rowIndex)
1396
+ ? " bri-table-td-edit"
1397
+ : ""
1398
+ }` +
1399
+ `${this.isExpandAction
1400
+ ? " bri-table-td-visible"
1401
+ : ""
1402
+ }` +
1403
+ `${this.noborderColKeys.includes(column._key)
1404
+ ? " bri-table-td-noborder"
1405
+ : ""
1406
+ }` +
1407
+ `${this.bgColKeys.includes(column._key)
1408
+ ? " bri-table-td-bg"
1409
+ : ""
1410
+ }`;
1411
+ },
1412
+ eventCustomOption ({ row, rowIndex, column }) {
1413
+ return {
1414
+ click: (event) => {
1415
+
1416
+ },
1417
+ dblclick: (event) => {
1418
+
1419
+ },
1420
+ contextmenu: (event) => {
1421
+
1422
+ },
1423
+ mouseenter: (event) => {
1424
+ // this.$set(this.hoverRecordMap, `${row._id}`, true);
1425
+ },
1426
+ mouseleave: (event) => {
1427
+ // this.$set(this.hoverRecordMap, `${row._id}`, false);
1428
+ }
1429
+ };
1430
+ },
1431
+
1432
+ /* ----------- 方法 ---------- */
1433
+ // 整行校验结果
1434
+ getRowRuleResult (row, rowIndex) {
1435
+ // return this.usedColumns.every(column => this.getColRuleResult({ row, rowIndex, column }).bool);
1436
+
1437
+ let bool = true;
1438
+ this.usedColumns.forEach(column => {
1439
+ column = this.$transformDynamicProperty(column, row, this.parentObj);
1440
+
1441
+ const resultObj = this.getColRuleResultObj({ row, rowIndex, column });
1442
+ if (!resultObj.bool) {
1443
+ bool = false;
1444
+ this.dealRuleRecord(row, column);
1445
+ }
1446
+ });
1447
+
1448
+ return bool;
1449
+ },
1450
+ getRowFormList (row, rowIndex) {
1451
+ return this.selfColumns.map(column => {
1452
+ column = this.$transformDynamicProperty(column, row, this.parentObj);
1453
+ const unitCanEdit = this.getColCanEdit({ row, rowIndex, column });
1454
+
1455
+ return {
1456
+ ...column,
1457
+ canEdit: unitCanEdit
1458
+ };
1459
+ });
1460
+ },
1461
+ // 是否默认行
1462
+ getIsDftRow (row, rowIndex) {
1463
+ return this.isDftSet ? false : row.__isDefault__;
1464
+ },
1465
+ // 行按钮是否可操作(删除按钮可编辑 不代表行内容是可编辑的)
1466
+ getRowDelBtnCanEdit (row, rowIndex) {
1467
+ return row.__readonly__ !== true && // 不能为只读数据
1468
+ (this.disabledDeleteDftRow ? row.__isDefault__ !== true : true) && // 默认数据可删除
1469
+ (this.disabledDeleteOldRow ? row.__old__ !== true : true); // 老数据可删除
1470
+ },
1471
+ // 行内容是否可编辑
1472
+ getRowCanEdit (row, rowIndex) {
1473
+ return this.canEdit && // 是编辑状态
1474
+ (this.getIsDftRow(row) ? !this.dftReadonly : true) && // 默认数据可编辑
1475
+ (row.__old__ === true ? !this.oldReadonly : true) && // 老数据可编辑
1476
+ row.__readonly__ !== true; // 不能为只读数据
1477
+ },
1478
+
1479
+ // 单元格校验结果
1480
+ getColRuleResult ({ row, rowIndex, column }) {
1481
+ column = this.$transformDynamicProperty(column, row, this.parentObj);
1482
+
1483
+ // 未触发校验时 不显示错误
1484
+ // return this.ruleRecordMap[this.getMixKey(row, column)] || this.showRuleMessage
1485
+ return this.ruleRecordMap[this.getMixKey(row, column)]
1486
+ ? this.getColRuleResultObj({ row, rowIndex, column })
1487
+ : {
1488
+ bool: true,
1489
+ message: "未触发校验,通过!"
1490
+ };
1491
+ },
1492
+ // 获取单元格校验对象
1493
+ getColRuleResultObj ({ row, rowIndex, column }) {
1494
+ // 校验必填不通过 => 校验对比
1495
+ const resultObj = {};
1496
+ this.$getFieldRuleResult(column, row, resultObj) &&
1497
+ this.$normalComparedFunc(column, row, this.selfColumns, this.parentObj, this.parentFormList, this.inTableType, resultObj) &&
1498
+ this.$levelComparedFunc(column, row, this.allListData, this.inTableType, resultObj);
1499
+
1500
+ return resultObj;
1501
+ },
1502
+ // 加工单元格对应的配置
1503
+ getResetCol ({ row, rowIndex, column }) {
1504
+ return {
1505
+ // isShare: this.isShare,
1506
+ ...column,
1507
+ _heightAuto: this.heightAuto,
1508
+ ...(
1509
+ this.noborderColKeys.includes(column._key)
1510
+ ? { _placeholder: " " }
1511
+ : {}
1512
+ ),
1513
+ ...(
1514
+ this.getSelfResetCol
1515
+ ? this.getSelfResetCol({ row, rowIndex, column })
1516
+ : {}
1517
+ )
1518
+ };
1519
+ },
1520
+ // 单元格最终是否可编辑性
1521
+ getUnitCanEdit ({ row, rowIndex, column }) {
1522
+ return this.getRowCanEdit(row, rowIndex) &&
1523
+ this.getColCanEdit({ row, rowIndex, column }) &&
1524
+ this.$isAdvRelyShow(column, row, this.parentObj, true);
1525
+ },
1526
+ // 单元格本身是否可编辑性
1527
+ getColCanEdit ({ row, rowIndex, column }) {
1528
+ return (this.getIsDftRow(row) ? !this.dftReadonlyColKeys.includes(column._key) : true) && // 默认行的某列是否可编辑
1529
+ (row.__old__ === true ? !this.oldReadonlyColKeys.includes(column._key) : true) && // 老数据行里某些列不可编辑
1530
+ (row.__isQuote__ ? !this.quoteReadonlyColKeys.includes(column._key) : true) && // 引用的数据是否可编辑
1531
+ (this.getSelfColCanEdit ? this.getSelfColCanEdit({ row, rowIndex, column }) : true) &&
1532
+ (
1533
+ ["treeTable"].includes(this.inTableType) && ["number", "date"].includes(column._type)
1534
+ ? column._summaryType
1535
+ ? row.isLeaf === true
1536
+ : ["downToUp", "upToDown"].includes(column._writeSort)
1537
+ ? column._noLimitWrite === true
1538
+ ? true
1539
+ : ["downToUp"].includes(column._writeSort)
1540
+ ? !(row.children && row.children.length) || row.children.every(sonRow => !this.$isEmptyData(sonRow[column._key]))
1541
+ : row.level === 1 || !this.$isEmptyData(this.getParentRow(row, this.data)[column._key])
1542
+ : true
1543
+ : true
1544
+ ) &&
1545
+ !(["cascaderTable"].includes(this.controlType) && ["level", "children"].includes(column._key)) && // 层级表格的固定字段不可编辑
1546
+ column._enterType !== "calculate" && // 计算的不可编辑
1547
+ column._readonly !== true && // 只读
1548
+ column._disabled !== true && // 只读
1549
+ column.canEdit !== false; // 字段本身编辑权限 考虑为undefined时候
1550
+ },
1551
+
1552
+ /* ----------- 工具方法 ---------- */
1553
+ // 初始化时 修复数据
1554
+ fixRowData (row, levelNum) {
1555
+ if (this.initFlag) {
1556
+ // 配置端设置的地方,不会运行下面的,因为_default被过滤掉没值,defaultListDataIds就是空的
1557
+ if (row._id) {
1558
+ if (this.defaultListDataIds.includes(row._id)) {
1559
+ row.__isDefault__ = true;
1560
+
1561
+ // 默认数据的id置换一遍,不然每条数据里该列表的id都是重复的
1562
+ const oldId = row._id;
1563
+ const newId = this.$ObjectID().str;
1564
+ row._id = newId;
1565
+ this.idRecordMap[newId] = oldId;
1566
+ }
1567
+ } else {
1568
+ row._id = this.$ObjectID().str;
1569
+ }
1570
+
1571
+ row.__old__ = this.isDftSet ? false : this.parentObj.__isCreate__ !== true; // 标记老数据
1572
+ row.__isDefault__ = this.isDftSet ? true : !!row.__isDefault__; // 标记默认数据(配置端默认值)
1573
+
1574
+ // 初次进来 把关于展示的状态值全部清除(只有层级表在用,按理说应放在DshTreeTableMixin.js,但为了清除三大表格的老数据,才放在这)
1575
+ this.resetProperties.forEach(property => {
1576
+ delete row[property];
1577
+ });
1578
+ }
1579
+
1580
+ this.fixSelfRowData && this.fixSelfRowData(row, levelNum);
1581
+ },
1582
+ // 生成新的一行数据
1583
+ getNewRowData (level, list) {
1584
+ if (["cascaderTable"].includes(this.controlType)) {
1585
+ return {
1586
+ ...this.$deepCopy(this.selfRowDft),
1587
+ ...(this.getSelfNewRowData ? this.$deepCopy(this.getSelfNewRowData(level, list)) : {}),
1588
+ _id: this.$ObjectID().str,
1589
+ level: level,
1590
+ isLeaf: true,
1591
+ children: [],
1592
+ // __old__: false,
1593
+ __isDefault__: this.isDftSet
1594
+ };
1595
+ } else {
1596
+ return {
1597
+ ...this.$deepCopy(this.selfRowDft),
1598
+ _id: this.$ObjectID().str,
1599
+ // __old__: false,
1600
+ __isDefault__: this.isDftSet
1601
+ };
1602
+ }
1603
+ },
1604
+ // 获取父级行
1605
+ getParentRow (row, tree = []) {
1606
+ if (row.level === 1) {
1607
+ return {
1608
+ children: tree
1609
+ };
1610
+ } else {
1611
+ let parentRow;
1612
+
1613
+ const loop = (list = []) => {
1614
+ return list.some(rowItem => {
1615
+ if (rowItem.level === row.level - 1) {
1616
+ const isExist = rowItem.children.some(childRowItem => childRowItem._id === row._id);
1617
+ parentRow = rowItem;
1618
+ return isExist;
1619
+ } else {
1620
+ return loop(rowItem.children);
1621
+ }
1622
+ });
1623
+ };
1624
+ loop(tree);
1625
+
1626
+ return parentRow;
1627
+ }
1628
+ },
1629
+ // // 单元格是否显示对比
1630
+ // isShowCompare ({ row, rowIndex, column }) {
1631
+ // const oldRow = this.compareListData[rowIndex] || {};
1632
+ // const curVal = row[column._key];
1633
+ // const oldVal = oldRow[column._key];
1634
+
1635
+ // return this.useCampare &&
1636
+ // ["number"].includes(column._type) &&
1637
+ // !(this.$isEmptyData(curVal) && this.$isEmptyData(oldVal)) &&
1638
+ // curVal !== oldVal;
1639
+ // },
1640
+ // 比较两行某列的值是否相等
1641
+ isCompareSame (column, row, compareRow) {
1642
+ const curColKey = column ? column._key : undefined;
1643
+ const curColType = column ? column._type : undefined;
1644
+
1645
+ return this.$isEmptyData(compareRow[curColKey]) && this.$isEmptyData(row[curColKey])
1646
+ ? true
1647
+ : ["users", "departments"].includes(curColType)
1648
+ ? compareRow[curColKey].length === row[curColKey].length && compareRow[curColKey].every((item, index) => item._key === row[curColKey][index]._key)
1649
+ : compareRow[curColKey] === row[curColKey];
1650
+ },
1651
+ // 行id + 分隔符 + 列key 组成键
1652
+ getMixKey (row, column, splitStr = "--") {
1653
+ return `${row._id}${splitStr}${column._key}`;
1654
+ },
1655
+ // 更新校验显示的标记
1656
+ dealRuleRecord (row, column) {
1657
+ // this.$set(this.ruleRecordMap, this.getMixKey(row, column), true);
1658
+ this.ruleRecordMap[this.getMixKey(row, column)] = true;
1659
+ }
1660
+ }
1661
+ };