cloud-web-corejs 1.0.93 → 1.0.95
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.
- package/package.json +39 -30
- package/src/components/wf/content.vue +2 -0
- package/src/components/wf/setCandidateDialog.vue +1 -0
- package/src/components/wf/wf.js +3 -1
- package/src/components/xform/form-designer/designer.js +1 -1
- package/src/components/xform/form-designer/form-widget/container-widget/data-table-mixin.js +2 -1
- package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +3 -0
- package/src/components/xform/form-designer/form-widget/field-widget/checkbox-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/dropdown-item-widget.vue +77 -0
- package/src/components/xform/form-designer/form-widget/field-widget/dropdown-menu-widget.vue +106 -0
- package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +7 -2
- package/src/components/xform/form-designer/form-widget/field-widget/mixins/vabsearch-mixin.js +176 -0
- package/src/components/xform/form-designer/form-widget/field-widget/multiSearch-widget.vue +53 -0
- package/src/components/xform/form-designer/form-widget/field-widget/number-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/project-tag-widget.vue +5 -2
- package/src/components/xform/form-designer/form-widget/field-widget/radio-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/search_button-widget.vue +1 -1
- package/src/components/xform/form-designer/form-widget/field-widget/select-widget.vue +2 -1
- package/src/components/xform/form-designer/form-widget/field-widget/singerSearch-widget.vue +53 -0
- package/src/components/xform/form-designer/form-widget/field-widget/status-widget.vue +3 -2
- package/src/components/xform/form-designer/form-widget/field-widget/vabSearch-widget.vue +2 -170
- package/src/components/xform/form-designer/indexMixin.js +1 -1
- package/src/components/xform/form-designer/setting-panel/form-setting.vue +263 -38
- package/src/components/xform/form-designer/setting-panel/index.vue +4 -0
- package/src/components/xform/form-designer/setting-panel/indexMixin.js +1 -1
- package/src/components/xform/form-designer/setting-panel/option-items-setting.vue +8 -3
- package/src/components/xform/form-designer/setting-panel/property-editor/a-link-editor.vue +1 -1
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/columnRenderDialog.vue +3 -2
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +0 -8
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +111 -12
- package/src/components/xform/form-designer/setting-panel/property-editor/container-list-h5/list-h5-editor.vue +0 -8
- package/src/components/xform/form-designer/setting-panel/property-editor/field-button/search-dialog-event-editor.vue +26 -8
- package/src/components/xform/form-designer/setting-panel/property-editor/field-dropdown-menu/dropdown-item-editor.vue +21 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-dropdown-menu/dropdown-menu-editor.vue +59 -0
- package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import-button-editor.vue +7 -2
- package/src/components/xform/form-designer/setting-panel/property-editor/field-import-button/import2-button-editor.vue +8 -2
- package/src/components/xform/form-designer/setting-panel/property-editor/field-status/field-status-editor.vue +47 -28
- package/src/components/xform/form-designer/setting-panel/property-editor/field-vabSearch/vabSearchName-editor.vue +13 -1
- package/src/components/xform/form-designer/setting-panel/property-editor/formula-editor.vue +722 -467
- package/src/components/xform/form-designer/setting-panel/property-editor/formulaEnabled-editor.vue +1 -1
- package/src/components/xform/form-designer/setting-panel/property-editor/multiple-editor.vue +19 -14
- package/src/components/xform/form-designer/setting-panel/property-editor/project-tag-editor.vue +159 -18
- package/src/components/xform/form-designer/setting-panel/property-editor/textFlag-editor.vue +51 -2
- package/src/components/xform/form-designer/setting-panel/property-editor/wfFlag-editor.vue +2 -30
- package/src/components/xform/form-designer/setting-panel/property-editor/widgetShowRuleFlag-editor.vue +220 -0
- package/src/components/xform/form-designer/setting-panel/propertyRegister.js +5 -0
- package/src/components/xform/form-designer/toolbar-panel/index.vue +8 -4
- package/src/components/xform/form-designer/widget-panel/index.vue +21 -1
- package/src/components/xform/form-designer/widget-panel/indexMixin.js +3 -2
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +489 -132
- package/src/components/xform/form-render/container-item/data-table-item.vue +7 -4
- package/src/components/xform/form-render/container-item/data-table-mixin.js +4 -1
- package/src/components/xform/form-render/container-item/data-table-mixin2.js +2169 -0
- package/src/components/xform/form-render/container-item/list-h5-item.vue +1 -9
- package/src/components/xform/form-render/container-item/list-h5-item2.vue +1 -8
- package/src/components/xform/form-render/indexMixin.js +7 -3
- package/src/components/xform/lang/zh-CN.js +13 -3
- package/src/components/xform/mixins/defaultHandle.js +1 -1
- package/src/components/xform/mixins/scriptHttp.js +1 -1
- package/src/components/xform/utils/format.js +21 -30
- package/src/components/xform/utils/formula-util.js +669 -0
- package/src/components/xform/utils/util.js +1 -1
- package/src/mixins/selectDialog/index.js +1 -1
- package/src/store/modules/permission.js +1 -1
- package/src/store/modules/settings.js +1 -1
@@ -0,0 +1,2169 @@
|
|
1
|
+
import emitter from "../../../../components/xform/utils/emitter";
|
2
|
+
import i18n from "../../../../components/xform/utils/i18n";
|
3
|
+
import refMixin from "../../../../components/xform/form-render/refMixin";
|
4
|
+
import containerItemMixin from "./containerItemMixin";
|
5
|
+
|
6
|
+
import * as formatUtil from "../../../../components/xform/utils/format.js";
|
7
|
+
import tableConfig from "../../../../components/table/config.js";
|
8
|
+
import {extendDeeply} from "../../../../utils/index.js";
|
9
|
+
import {
|
10
|
+
assembleAxiosConfig,
|
11
|
+
getReportGlobalMap,
|
12
|
+
generateId,
|
13
|
+
} from "../../../../components/xform/utils/util";
|
14
|
+
import {tableTreeMixins} from "../../../../mixins/tableTree/index.js";
|
15
|
+
|
16
|
+
let modules = {};
|
17
|
+
const baseRefUtil = {
|
18
|
+
emitter,
|
19
|
+
i18n,
|
20
|
+
refMixin,
|
21
|
+
containerItemMixin,
|
22
|
+
formatUtil,
|
23
|
+
assembleAxiosConfig,
|
24
|
+
tableConfig,
|
25
|
+
getReportGlobalMap,
|
26
|
+
};
|
27
|
+
|
28
|
+
modules = {
|
29
|
+
mixins: [
|
30
|
+
baseRefUtil.emitter,
|
31
|
+
baseRefUtil.i18n,
|
32
|
+
baseRefUtil.refMixin,
|
33
|
+
baseRefUtil.containerItemMixin,
|
34
|
+
tableTreeMixins,
|
35
|
+
],
|
36
|
+
componentName: "ContainerItem",
|
37
|
+
props: {
|
38
|
+
widget: Object,
|
39
|
+
parentWidget: Object,
|
40
|
+
parentList: Array,
|
41
|
+
indexOfParentList: Number,
|
42
|
+
subFormRowIndex: {
|
43
|
+
type: Number,
|
44
|
+
default: -1,
|
45
|
+
},
|
46
|
+
subFormColIndex: {
|
47
|
+
type: Number,
|
48
|
+
default: -1,
|
49
|
+
},
|
50
|
+
subFormRowId: {
|
51
|
+
type: String,
|
52
|
+
default: "",
|
53
|
+
},
|
54
|
+
},
|
55
|
+
inject: [
|
56
|
+
"refList",
|
57
|
+
"sfRefList",
|
58
|
+
"globalModel",
|
59
|
+
"getFormConfig",
|
60
|
+
"getGlobalDsv",
|
61
|
+
"previewState",
|
62
|
+
],
|
63
|
+
data: function () {
|
64
|
+
let that = this;
|
65
|
+
return {
|
66
|
+
fieldModel: [],
|
67
|
+
selectedIndices: [],
|
68
|
+
pageSize: this.widget.options.pagination.pageSize,
|
69
|
+
pageSizes: this.widget.options.pagination.pageSizes,
|
70
|
+
currentPage: this.widget.options.pagination.currentPage,
|
71
|
+
total: this.widget.options.pagination.total,
|
72
|
+
formData: {
|
73
|
+
saleOrgName: "",
|
74
|
+
loginAccount: "",
|
75
|
+
mobile: "",
|
76
|
+
enabled: 1,
|
77
|
+
},
|
78
|
+
vxeOption: {},
|
79
|
+
requestAccess: null,
|
80
|
+
columnFormatMap: {
|
81
|
+
editInput: "input",
|
82
|
+
editNumber: "number",
|
83
|
+
editDate: "date",
|
84
|
+
editSelect: "select",
|
85
|
+
editSearch: "vabsearch",
|
86
|
+
editAttachment: "baseAttachment",
|
87
|
+
editStatus: "status",
|
88
|
+
aText: "a-text",
|
89
|
+
aLink: "a-link",
|
90
|
+
editDelete: "a-link",
|
91
|
+
editButton: "a-link",
|
92
|
+
button: "button",
|
93
|
+
addSiblingEditRow: "a-link",
|
94
|
+
addChildTreeRow: "a-link",
|
95
|
+
moveUpRow: "a-link",
|
96
|
+
moveDownRow: "a-link",
|
97
|
+
removeTreeRow: "a-link",
|
98
|
+
text: "text",
|
99
|
+
checkbox: "checkbox",
|
100
|
+
radio: "radio",
|
101
|
+
},
|
102
|
+
dataTableConfig: {},
|
103
|
+
widgets: [],
|
104
|
+
editWidgets: [],
|
105
|
+
|
106
|
+
sortParentRow: null,
|
107
|
+
sortRows: [],
|
108
|
+
showTreeMoveDialog: false,
|
109
|
+
tableConfig: {},
|
110
|
+
showTableFormDialogContent: true,
|
111
|
+
widgetMap: {},
|
112
|
+
rowWidgetList: []
|
113
|
+
};
|
114
|
+
},
|
115
|
+
watch: {
|
116
|
+
fieldModel(val) {
|
117
|
+
this.formModel[this.fieldKeyName] = val || [];
|
118
|
+
},
|
119
|
+
},
|
120
|
+
computed: {
|
121
|
+
hasWf() {
|
122
|
+
return this.getFormRef().hasWf || false;
|
123
|
+
},
|
124
|
+
tableDatas: {
|
125
|
+
cache: !1,
|
126
|
+
get: function () {
|
127
|
+
return this.globalModel.formModel[this.fieldKeyName] || [];
|
128
|
+
},
|
129
|
+
},
|
130
|
+
formConfig: function () {
|
131
|
+
return this.getFormConfig();
|
132
|
+
},
|
133
|
+
paginationLayout: function () {
|
134
|
+
return this.widget.options.smallPagination
|
135
|
+
? "prev, pager, next"
|
136
|
+
: "total, sizes, prev, pager, next, jumper";
|
137
|
+
},
|
138
|
+
customClass: function () {
|
139
|
+
return this.widget.options.customClass || "";
|
140
|
+
},
|
141
|
+
singleRowSelectFlag: function () {
|
142
|
+
return !this.widget.options.showCheckBox;
|
143
|
+
},
|
144
|
+
buttonsColumnFixed: function () {
|
145
|
+
return void 0 === this.widget.options.buttonsColumnFixed
|
146
|
+
? "right"
|
147
|
+
: !!this.widget.options.buttonsColumnFixed &&
|
148
|
+
this.widget.options.buttonsColumnFixed;
|
149
|
+
},
|
150
|
+
formModel: {
|
151
|
+
cache: !1,
|
152
|
+
get: function () {
|
153
|
+
return this.globalModel.formModel;
|
154
|
+
},
|
155
|
+
},
|
156
|
+
formDataId() {
|
157
|
+
let formRef = this.getFormRef();
|
158
|
+
return formRef.dataId;
|
159
|
+
},
|
160
|
+
},
|
161
|
+
created: function () {
|
162
|
+
if (!this.formModel[this.fieldKeyName])
|
163
|
+
this.formModel[this.fieldKeyName] = [];
|
164
|
+
this.initRefList();
|
165
|
+
this.handleOnCreated();
|
166
|
+
},
|
167
|
+
mounted: async function () {
|
168
|
+
this.handleOnMounted();
|
169
|
+
this.initTableList();
|
170
|
+
},
|
171
|
+
beforeDestroy: function () {
|
172
|
+
this.unregisterFromRefList();
|
173
|
+
},
|
174
|
+
methods: {
|
175
|
+
getRowRefKey(row, name) {
|
176
|
+
let keyVal = row._X_ROW_KEY;
|
177
|
+
let key = name + "_" + keyVal;
|
178
|
+
return key;
|
179
|
+
},
|
180
|
+
getWidgetByTableRow(index, name) {
|
181
|
+
let target = this.getWidgetRefByTableRow(index, name)
|
182
|
+
let widget = target.field || target.widget;
|
183
|
+
return widget
|
184
|
+
},
|
185
|
+
getWidgetRefByTableRow(index, name) {
|
186
|
+
let row = this.getGridTable().getTableData().fullData[index];
|
187
|
+
let key = this.getRowRefKey(row, name);
|
188
|
+
return this.getWidgetRef(key);
|
189
|
+
},
|
190
|
+
getWidgetRefByTableParam(tableParam) {
|
191
|
+
let index = tableParam.rowIndex;
|
192
|
+
let params = tableParam.column.params;
|
193
|
+
let name = params.widget.options.name;
|
194
|
+
return this.getWidgetRefByTableRow(index, name);
|
195
|
+
},
|
196
|
+
getRowWidget(rowParam, fieldWidget) {
|
197
|
+
let row = rowParam.row;
|
198
|
+
let params = rowParam.column.params;
|
199
|
+
let name = fieldWidget ? fieldWidget.options.name : params.widget.options.name;
|
200
|
+
let key = this.getRowRefKey(row, name);
|
201
|
+
let widget = this.widgetMap[key];
|
202
|
+
if (!widget) {
|
203
|
+
this.$set(
|
204
|
+
this.widgetMap,
|
205
|
+
key,
|
206
|
+
this.$baseLodash.cloneDeep(fieldWidget ? fieldWidget : params.widget)
|
207
|
+
);
|
208
|
+
}
|
209
|
+
|
210
|
+
return this.widgetMap[key];
|
211
|
+
},
|
212
|
+
loopHandleWidgetByName(name, callback) {
|
213
|
+
let rows = this.getValue();
|
214
|
+
rows.forEach((row, index) => {
|
215
|
+
let target = this.getWidgetRefByTableRow(index, name)
|
216
|
+
if (target) {
|
217
|
+
let widget = target.field || target.widget;
|
218
|
+
callback(row, widget, target)
|
219
|
+
}
|
220
|
+
})
|
221
|
+
},
|
222
|
+
getRowWidgetOption(rowParam, fieldWidget) {
|
223
|
+
let widget = this.getRowWidget(rowParam, fieldWidget);
|
224
|
+
let field = widget.category == 'container' ? 'widget' : 'field'
|
225
|
+
let option = {
|
226
|
+
[field]: widget
|
227
|
+
}
|
228
|
+
return option
|
229
|
+
},
|
230
|
+
getRowWidgetKey(rowParam, fieldWidget) {
|
231
|
+
let row = rowParam.row;
|
232
|
+
let params = rowParam.column.params;
|
233
|
+
let name = fieldWidget ? fieldWidget.options.name : params.widget.options.name;
|
234
|
+
let key = this.getRowRefKey(row, name);
|
235
|
+
return key;
|
236
|
+
},
|
237
|
+
getGridTableName() {
|
238
|
+
let formCode = this.getFormRef().reportTemplate.formCode;
|
239
|
+
let tableName = formCode + "_" + this.widget.options.name;
|
240
|
+
return tableName;
|
241
|
+
},
|
242
|
+
updateFormField: function () {
|
243
|
+
let rows = this.fieldModel || [];
|
244
|
+
let formRows = this.formModel[this.fieldKeyName];
|
245
|
+
if (formRows) {
|
246
|
+
this.formModel[this.fieldKeyName].splice(0, formRows.length);
|
247
|
+
this.formModel[this.fieldKeyName].push(...rows);
|
248
|
+
} else {
|
249
|
+
this.formModel[this.fieldKeyName] = rows;
|
250
|
+
}
|
251
|
+
},
|
252
|
+
setValue(val) {
|
253
|
+
// console.log("rows:",val);
|
254
|
+
this.clearRowWidgets()
|
255
|
+
let rows = val || [];
|
256
|
+
this.formModel[this.fieldKeyName] = rows;
|
257
|
+
let $grid = this.getGridTable();
|
258
|
+
this.fieldModel = rows;
|
259
|
+
// $grid.loadData(rows);
|
260
|
+
},
|
261
|
+
getValue() {
|
262
|
+
return this.formModel[this.fieldKeyName];
|
263
|
+
},
|
264
|
+
getFieldKeyName(widget) {
|
265
|
+
let o = widget.options.name;
|
266
|
+
return (widget.options.keyNameEnabled && widget.options.keyName) || o;
|
267
|
+
},
|
268
|
+
selectWidget: function (e) {
|
269
|
+
this.designer.setSelected(e);
|
270
|
+
},
|
271
|
+
formatterValue: function ({cellValue, row, column}) {
|
272
|
+
if (cellValue === null || cellValue === undefined) return cellValue;
|
273
|
+
|
274
|
+
if (column.params && column.params.formatS)
|
275
|
+
switch (column.params.formatS) {
|
276
|
+
case "d1":
|
277
|
+
return baseRefUtil.formatUtil.formatDate1(cellValue);
|
278
|
+
case "d2":
|
279
|
+
return baseRefUtil.formatUtil.formatDate2(cellValue);
|
280
|
+
case "d3":
|
281
|
+
return baseRefUtil.formatUtil.formatDate3(cellValue);
|
282
|
+
case "d4":
|
283
|
+
return baseRefUtil.formatUtil.formatDate4(cellValue);
|
284
|
+
case "d5":
|
285
|
+
return baseRefUtil.formatUtil.formatDate4(cellValue);
|
286
|
+
case "n1":
|
287
|
+
return baseRefUtil.formatUtil.formatNumber1(cellValue);
|
288
|
+
case "n2":
|
289
|
+
return baseRefUtil.formatUtil.formatNumber2(cellValue);
|
290
|
+
case "n3":
|
291
|
+
return baseRefUtil.formatUtil.formatNumber3(cellValue);
|
292
|
+
case "n4":
|
293
|
+
return baseRefUtil.formatUtil.formatNumber4(cellValue);
|
294
|
+
case "n5":
|
295
|
+
return baseRefUtil.formatUtil.formatNumber5(cellValue);
|
296
|
+
case "n6":
|
297
|
+
return baseRefUtil.formatUtil.formatNumber6(cellValue);
|
298
|
+
case "n7":
|
299
|
+
return baseRefUtil.formatUtil.formatNumber7(cellValue);
|
300
|
+
}
|
301
|
+
return cellValue;
|
302
|
+
},
|
303
|
+
getRowIndex: function (e) {
|
304
|
+
return this.widget.options.tableData.lastIndexOf(e);
|
305
|
+
},
|
306
|
+
setTableColumns: function (e) {
|
307
|
+
var t = this;
|
308
|
+
(this.widget.options.tableColumns = e),
|
309
|
+
this.$nextTick(function () {
|
310
|
+
t.$refs.dataTable.doLayout();
|
311
|
+
});
|
312
|
+
},
|
313
|
+
setTableColumn: function (e) {
|
314
|
+
this.setTableColumns(e);
|
315
|
+
},
|
316
|
+
getTableData: function () {
|
317
|
+
return this.widget.options.tableData;
|
318
|
+
},
|
319
|
+
resetForm(options) {
|
320
|
+
let formData = this.formModel;
|
321
|
+
let ignoreFields = options?.ignoreFields || [];
|
322
|
+
this.widget.widgetList.forEach((subWidget) => {
|
323
|
+
if (
|
324
|
+
!ignoreFields.length ||
|
325
|
+
!ignoreFields.includes(subWidget.options.name)
|
326
|
+
) {
|
327
|
+
let widgetRef = this.getWidgetRef(subWidget.options.name);
|
328
|
+
if (widgetRef && widgetRef.setValue) widgetRef.setValue(null);
|
329
|
+
}
|
330
|
+
});
|
331
|
+
},
|
332
|
+
searchEvent() {
|
333
|
+
this.getGridTable().commitProxy("reload");
|
334
|
+
},
|
335
|
+
async resetEvent(options) {
|
336
|
+
this.resetForm(options);
|
337
|
+
this.getGridTable().commitProxy("reload");
|
338
|
+
},
|
339
|
+
handleSearchClick() {
|
340
|
+
if (this.widget.options.onSearchTable) {
|
341
|
+
this.handleCustomEvent(this.widget.options.onSearchTable);
|
342
|
+
return;
|
343
|
+
}
|
344
|
+
this.searchEvent();
|
345
|
+
},
|
346
|
+
handleResetClick() {
|
347
|
+
if (this.widget.options.onResetTable) {
|
348
|
+
this.handleCustomEvent(this.widget.options.onResetTable);
|
349
|
+
return;
|
350
|
+
}
|
351
|
+
this.resetEvent();
|
352
|
+
},
|
353
|
+
openEditDialog(row, param) {
|
354
|
+
let formRef = this.getFormRef();
|
355
|
+
let parentTarget = formRef.$attrs["parent-target"];
|
356
|
+
parentTarget &&
|
357
|
+
parentTarget.$attrs.openEditDialog &&
|
358
|
+
parentTarget.$attrs.openEditDialog(row, param);
|
359
|
+
},
|
360
|
+
importExcel() {
|
361
|
+
},
|
362
|
+
getGrid(that, tableRef) {
|
363
|
+
var $grid;
|
364
|
+
if (Array.isArray(that.$refs[tableRef])) {
|
365
|
+
$grid = that.$refs[tableRef][0];
|
366
|
+
} else {
|
367
|
+
$grid = that.$refs[tableRef];
|
368
|
+
}
|
369
|
+
return $grid;
|
370
|
+
},
|
371
|
+
getTableCondition: function () {
|
372
|
+
if (this.widget.options.tableCondition) {
|
373
|
+
var e = new Function(this.widget.options.tableCondition);
|
374
|
+
return e.call(this);
|
375
|
+
}
|
376
|
+
},
|
377
|
+
getSearchCondition: function () {
|
378
|
+
let extraAccessData = this.extraAccessData || {};
|
379
|
+
let searchFormData = this.getSearchFormData();
|
380
|
+
let defaultData = {};
|
381
|
+
|
382
|
+
// let globalReqData = baseRefUtil.getReportGlobalMap();//全局请求参数
|
383
|
+
let tableCondition = this.getTableCondition();
|
384
|
+
let conditions = {
|
385
|
+
...defaultData,
|
386
|
+
...tableCondition,
|
387
|
+
...searchFormData,
|
388
|
+
...extraAccessData,
|
389
|
+
// ...globalReqData
|
390
|
+
};
|
391
|
+
return conditions;
|
392
|
+
},
|
393
|
+
createColumns() {
|
394
|
+
let rowWidgetList = [];
|
395
|
+
let tableColumns = this.widget.options.tableColumns;
|
396
|
+
let newColumns = [];
|
397
|
+
if (!this.widget.options.hideGridCheckBox) {
|
398
|
+
newColumns.push({
|
399
|
+
type: "checkbox",
|
400
|
+
width: 48,
|
401
|
+
resizable: false,
|
402
|
+
fixed: "left",
|
403
|
+
});
|
404
|
+
}
|
405
|
+
|
406
|
+
let tableWidgetName = this.widget.options.name;
|
407
|
+
const createColumn = (t, isChild) => {
|
408
|
+
|
409
|
+
let col = {
|
410
|
+
fixed: !!t.fixed && t.fixed,
|
411
|
+
field: t.prop,
|
412
|
+
title: this.getI18nLabel(t.label),
|
413
|
+
sortable: t.sortable,
|
414
|
+
align: t.align ? t.align : "center",
|
415
|
+
formatter: this.formatterValue,
|
416
|
+
params: {
|
417
|
+
formatS: t.formatS,
|
418
|
+
columnId: t.columnId,
|
419
|
+
exportType: t.exportType,
|
420
|
+
isItemLine: t.isItemLine,
|
421
|
+
footerDataType: t.footerDataType,
|
422
|
+
footerMethodConfg: t.footerMethodConfg,
|
423
|
+
widgetList: t.widgetList,
|
424
|
+
tableWidgetName
|
425
|
+
},
|
426
|
+
visible: t.show,
|
427
|
+
slots: {},
|
428
|
+
};
|
429
|
+
if (t.treeNode) {
|
430
|
+
col.treeNode = true;
|
431
|
+
}
|
432
|
+
if (t.children && t.children.length) {
|
433
|
+
col.align = "center";
|
434
|
+
delete col.field;
|
435
|
+
let childColumns = t.children.map((child) => {
|
436
|
+
return createColumn(child, true);
|
437
|
+
});
|
438
|
+
col.children = childColumns;
|
439
|
+
|
440
|
+
col.sortable = false;
|
441
|
+
col.filterType = false;
|
442
|
+
} else {
|
443
|
+
col.width = t.width;
|
444
|
+
if (isChild) {
|
445
|
+
if (col.title && col.field) {
|
446
|
+
col.filters = [
|
447
|
+
{
|
448
|
+
data: {},
|
449
|
+
},
|
450
|
+
];
|
451
|
+
col.filterRender = {
|
452
|
+
name: "FilterContent",
|
453
|
+
};
|
454
|
+
}
|
455
|
+
}
|
456
|
+
}
|
457
|
+
col = addColumProperty(col, t);
|
458
|
+
|
459
|
+
if (col.params.widget) {
|
460
|
+
rowWidgetList.push(col.params.widget)
|
461
|
+
}
|
462
|
+
if (col.params.editWidget) {
|
463
|
+
rowWidgetList.push(col.params.editWidget)
|
464
|
+
}
|
465
|
+
if (col.params.widgetList && col.params.widgetList.length) {
|
466
|
+
col.params.widgetList.forEach((item) => {
|
467
|
+
rowWidgetList.push(item)
|
468
|
+
})
|
469
|
+
|
470
|
+
}
|
471
|
+
return col;
|
472
|
+
};
|
473
|
+
|
474
|
+
const addColumProperty = (col, t) => {
|
475
|
+
let columnOption;
|
476
|
+
let widget;
|
477
|
+
let columnWidgetConfig = this.getColumnWidgetConfig(t);
|
478
|
+
let {columnSelectedWidget, columnEditFields} = columnWidgetConfig;
|
479
|
+
if (columnSelectedWidget) {
|
480
|
+
widget = columnSelectedWidget;
|
481
|
+
columnOption = widget.options;
|
482
|
+
} else {
|
483
|
+
columnOption = {};
|
484
|
+
}
|
485
|
+
|
486
|
+
let {columnSelectedWidget: editWidget} = this.getColumnWidgetConfig(
|
487
|
+
t,
|
488
|
+
true
|
489
|
+
);
|
490
|
+
|
491
|
+
let params = {
|
492
|
+
...columnOption,
|
493
|
+
widget: widget,
|
494
|
+
formatS: t.formatS,
|
495
|
+
required: t.required || false,
|
496
|
+
columnConfig: t,
|
497
|
+
editWidget,
|
498
|
+
};
|
499
|
+
Object.assign(col.params, params);
|
500
|
+
if (!col.children || !col.children.length) {
|
501
|
+
if (t.formatS == "render") {
|
502
|
+
let r = t.render ? new Function("params", "h", t.render) : null;
|
503
|
+
col.slots.default = (params, h) => {
|
504
|
+
return r ? r.call(this, params, h) : "";
|
505
|
+
};
|
506
|
+
} else if (columnSelectedWidget) {
|
507
|
+
// col.slots.default = columnSelectedWidget.id;
|
508
|
+
col.slots.default = "widget";
|
509
|
+
} else if (t.formatS == "editTreeButtonGroup") {
|
510
|
+
col.slots.default = "editTreeButtonGroup";
|
511
|
+
} else if (t.formatS == "widgetRender") {
|
512
|
+
col.slots.default = "widgetList";
|
513
|
+
}
|
514
|
+
|
515
|
+
if (editWidget) {
|
516
|
+
col.editRender = {name: "input"};
|
517
|
+
// col.slots.edit = editWidget.id;
|
518
|
+
col.slots.edit = "editWidget";
|
519
|
+
}
|
520
|
+
}
|
521
|
+
if (t.tableColumnConfig) {
|
522
|
+
let tableColumnConfig =
|
523
|
+
this.handleCustomEvent(t.tableColumnConfig) || {};
|
524
|
+
col = extendDeeply(col, tableColumnConfig);
|
525
|
+
}
|
526
|
+
return col;
|
527
|
+
};
|
528
|
+
|
529
|
+
let formRef = this.getFormRef();
|
530
|
+
tableColumns.forEach((t) => {
|
531
|
+
let col = createColumn(t);
|
532
|
+
newColumns.push(col);
|
533
|
+
});
|
534
|
+
|
535
|
+
if (
|
536
|
+
baseRefUtil.tableConfig &&
|
537
|
+
baseRefUtil.tableConfig.className == "list-table"
|
538
|
+
) {
|
539
|
+
if (tableColumns.length) {
|
540
|
+
let tableColumn = [tableColumns.length - 1];
|
541
|
+
if (tableColumn.fixed != "right") {
|
542
|
+
newColumns.push({
|
543
|
+
width: 47,
|
544
|
+
title: "",
|
545
|
+
fixed: "right",
|
546
|
+
sortable: false,
|
547
|
+
});
|
548
|
+
}
|
549
|
+
}
|
550
|
+
}
|
551
|
+
this.rowWidgetList = rowWidgetList;
|
552
|
+
return this.$baseLodash.cloneDeep(newColumns);
|
553
|
+
},
|
554
|
+
initTableList() {
|
555
|
+
let that = this;
|
556
|
+
let path = null;
|
557
|
+
let paramFun = null;
|
558
|
+
// let mainDataSetDTO = null;
|
559
|
+
let requestAccess = this.requestAccess;
|
560
|
+
let tableRef = this.getTableRef();
|
561
|
+
let formDataModel = this.getFormRef().formDataModel;
|
562
|
+
let isQueryTable = this.widget.options.isQueryTable || false;
|
563
|
+
let isDataPage = this.widget.options.accessReturnType == "2";
|
564
|
+
let reportTemplate = this.getFormRef().reportTemplate;
|
565
|
+
let formCode = reportTemplate.formCode;
|
566
|
+
let dataId = this.formDataId;
|
567
|
+
let accessScript = this.widget.options.accessScript;
|
568
|
+
let searchColumns = null;
|
569
|
+
|
570
|
+
if (isQueryTable) {
|
571
|
+
path = "#";
|
572
|
+
paramFun = () => {
|
573
|
+
let conditions = this.getSearchCondition();
|
574
|
+
let $grid = this.getGridTable();
|
575
|
+
if (this.widget.options.showPagination) {
|
576
|
+
let proxyInfo = $grid.getProxyInfo();
|
577
|
+
let searchCount = true;
|
578
|
+
let isQueryAllPage = $grid.isQueryAllPage;
|
579
|
+
if (isQueryAllPage == false) {
|
580
|
+
searchCount = false;
|
581
|
+
}
|
582
|
+
let pager = proxyInfo ? proxyInfo.pager : null;
|
583
|
+
if (pager) {
|
584
|
+
conditions.current = pager.currentPage;
|
585
|
+
conditions.size = pager.pageSize;
|
586
|
+
conditions.searchCount = searchCount;
|
587
|
+
}
|
588
|
+
}
|
589
|
+
|
590
|
+
/*let formData = {
|
591
|
+
accessCode: requestAccess.accessCode,
|
592
|
+
conditions: conditions
|
593
|
+
};*/
|
594
|
+
let formData = conditions;
|
595
|
+
return formData;
|
596
|
+
};
|
597
|
+
|
598
|
+
searchColumns = [];
|
599
|
+
let widgetList = this.widget.widgetList;
|
600
|
+
|
601
|
+
let getDateItem = (widget) => {
|
602
|
+
let options = widget.options;
|
603
|
+
|
604
|
+
let dateConfig = {
|
605
|
+
format: options.format,
|
606
|
+
valueFormat: options.valueFormat ?? null,
|
607
|
+
};
|
608
|
+
let typeMap = {
|
609
|
+
input: {type: "input"},
|
610
|
+
number: {type: "number"},
|
611
|
+
inputBatch: {type: "inputBatch"},
|
612
|
+
date: {
|
613
|
+
type: "date",
|
614
|
+
widgetType: options.type,
|
615
|
+
widgetConfig: dateConfig,
|
616
|
+
},
|
617
|
+
time: {
|
618
|
+
type: "time",
|
619
|
+
widgetConfig: {
|
620
|
+
...dateConfig,
|
621
|
+
valueFormat: "HH:mm:ss",
|
622
|
+
},
|
623
|
+
},
|
624
|
+
"date-range": {
|
625
|
+
type: "date",
|
626
|
+
widgetType: "daterange",
|
627
|
+
widgetConfig: {...dateConfig, isRange: true},
|
628
|
+
},
|
629
|
+
"time-range": {
|
630
|
+
type: "time",
|
631
|
+
widgetConfig: {
|
632
|
+
...dateConfig,
|
633
|
+
isRange: true,
|
634
|
+
valueFormat: "HH:mm:ss",
|
635
|
+
},
|
636
|
+
},
|
637
|
+
};
|
638
|
+
let item = typeMap[widget.type] || {};
|
639
|
+
return item;
|
640
|
+
};
|
641
|
+
|
642
|
+
widgetList.forEach((widget) => {
|
643
|
+
if ("container" !== widget.category) {
|
644
|
+
let options = widget.options;
|
645
|
+
let item = getDateItem(widget);
|
646
|
+
let type = item.type ?? null;
|
647
|
+
// let widgetType = item.widgetType ?? widgetType;
|
648
|
+
// let isRange = item.isRange || false;
|
649
|
+
searchColumns.push({
|
650
|
+
title: this.getI18nLabel(options.label),
|
651
|
+
field: this.getFieldKeyName(widget),
|
652
|
+
// type,
|
653
|
+
// widgetType,
|
654
|
+
// isRange,
|
655
|
+
common: true,
|
656
|
+
disabled: options.disabled,
|
657
|
+
defaultValueEnabled: !!type,
|
658
|
+
slot: options.name,
|
659
|
+
widget: widget,
|
660
|
+
formItem: false,
|
661
|
+
...item,
|
662
|
+
});
|
663
|
+
}
|
664
|
+
});
|
665
|
+
}
|
666
|
+
|
667
|
+
let formRef = this.getFormRef();
|
668
|
+
let dataTableConfig = formRef.$attrs.dataTableOption || {};
|
669
|
+
this.dataTableConfig = dataTableConfig;
|
670
|
+
|
671
|
+
let columns = this.createColumns();
|
672
|
+
this.widgets = columns
|
673
|
+
.filter((column) => !!column?.params?.widget)
|
674
|
+
.map((column) => column.params.widget);
|
675
|
+
this.editWidgets = columns
|
676
|
+
.filter((column) => !!column?.params?.editWidget)
|
677
|
+
.map((column) => column.params.editWidget);
|
678
|
+
|
679
|
+
let height =
|
680
|
+
this.widget.options.tableHeight || (isQueryTable ? "auto" : null);
|
681
|
+
if (
|
682
|
+
!this.widget.options.tableHeight &&
|
683
|
+
isQueryTable &&
|
684
|
+
this.previewState
|
685
|
+
) {
|
686
|
+
height = "550px";
|
687
|
+
}
|
688
|
+
|
689
|
+
let formConfig = this.formConfig;
|
690
|
+
let scriptCode = this.getScriptCode();
|
691
|
+
|
692
|
+
let otherParam = {};
|
693
|
+
let attachmentType = this.getAttachmentType();
|
694
|
+
if (attachmentType.length) {
|
695
|
+
otherParam.attachmentType = attachmentType;
|
696
|
+
}
|
697
|
+
let thirdtabm = this.getThirdtabm();
|
698
|
+
if (thirdtabm.length) {
|
699
|
+
otherParam.thirdtabm = thirdtabm;
|
700
|
+
}
|
701
|
+
|
702
|
+
let pagerConfig = {};
|
703
|
+
let editDefaultRow, treeNodeParam, treeConfig;
|
704
|
+
let isTreeTable = this.widget.options.isTreeTable;
|
705
|
+
if (isTreeTable) {
|
706
|
+
pagerConfig.pagerClass = "is--hidden";
|
707
|
+
if (this.widget.options.editDefaultRow) {
|
708
|
+
editDefaultRow = this.handleCustomEvent(
|
709
|
+
this.widget.options.editDefaultRow
|
710
|
+
);
|
711
|
+
}
|
712
|
+
treeNodeParam = (row) => {
|
713
|
+
return {
|
714
|
+
[this.widget.options.parentField]: row.id,
|
715
|
+
};
|
716
|
+
};
|
717
|
+
treeConfig = {
|
718
|
+
lazy: false,
|
719
|
+
children: "f_children",
|
720
|
+
hasChild: "f_has_child", // 设置是否有子节点标识
|
721
|
+
parentField: "f_parent",
|
722
|
+
transform: true,
|
723
|
+
expandAll: true,
|
724
|
+
loadMethod({$table, row}) {
|
725
|
+
// 模拟后台接口
|
726
|
+
let $grid = that.getGridTable();
|
727
|
+
let parentField = $grid.treeConfig.parentField;
|
728
|
+
return new Promise((resolve, reject) => {
|
729
|
+
let treeParam = that.widget.options.tableConfig?.treeNodeParam;
|
730
|
+
let reqPram = {};
|
731
|
+
if (treeParam) {
|
732
|
+
reqPram = treeParam(row) || {};
|
733
|
+
}
|
734
|
+
Object.assign(reqPram, {
|
735
|
+
[parentField]: row.id,
|
736
|
+
});
|
737
|
+
let accessParam = this.getAccessParam() || {};
|
738
|
+
let defaultOption = that.getHttpConfigForUser();
|
739
|
+
that.formHttp({
|
740
|
+
scriptCode: scriptCode,
|
741
|
+
data: {
|
742
|
+
formCode: formCode,
|
743
|
+
formVersion: reportTemplate.formVersion,
|
744
|
+
taBm: that.fieldKeyName,
|
745
|
+
data: {
|
746
|
+
...reqPram,
|
747
|
+
...otherParam,
|
748
|
+
...accessParam,
|
749
|
+
},
|
750
|
+
},
|
751
|
+
callback: (res) => {
|
752
|
+
if (res.type == "success") {
|
753
|
+
let rows = res.objx
|
754
|
+
? res.objx.records || res.objx || []
|
755
|
+
: [];
|
756
|
+
|
757
|
+
let hasChildField = $grid.treeConfig.hasChild;
|
758
|
+
if (row[hasChildField] && !rows.length) {
|
759
|
+
row[hasChildField] = false;
|
760
|
+
}
|
761
|
+
|
762
|
+
resolve(rows);
|
763
|
+
let treeCallback =
|
764
|
+
that.widget.options.tableConfig?.treeCallback;
|
765
|
+
if (treeCallback) {
|
766
|
+
that.$nextTick(() => {
|
767
|
+
setTimeout(function () {
|
768
|
+
treeCallback(rows);
|
769
|
+
}, 0);
|
770
|
+
});
|
771
|
+
}
|
772
|
+
} else {
|
773
|
+
reject(res);
|
774
|
+
}
|
775
|
+
},
|
776
|
+
});
|
777
|
+
});
|
778
|
+
},
|
779
|
+
};
|
780
|
+
}
|
781
|
+
let editOpts = {};
|
782
|
+
if (this.widget.options.isEditTable) {
|
783
|
+
editOpts = {
|
784
|
+
keepSource: true,
|
785
|
+
editConfig: {
|
786
|
+
trigger: "manual",
|
787
|
+
mode: "row",
|
788
|
+
showStatus: true,
|
789
|
+
autoClear: false,
|
790
|
+
},
|
791
|
+
};
|
792
|
+
}
|
793
|
+
let showFooter = this.widget.options.showGridFooter || false;
|
794
|
+
let otherConfig = {};
|
795
|
+
if (this.widget.options.hideGridCheckBox) {
|
796
|
+
otherConfig.checkBoxRequired = false;
|
797
|
+
}
|
798
|
+
let tableOption = {
|
799
|
+
// vue: this,
|
800
|
+
tableRef: tableRef,
|
801
|
+
tableName: this.getGridTableName(),
|
802
|
+
param: paramFun,
|
803
|
+
columns: columns,
|
804
|
+
searchColumns: searchColumns,
|
805
|
+
vform: true,
|
806
|
+
config: {
|
807
|
+
height: height,
|
808
|
+
showFooter,
|
809
|
+
pagerConfig,
|
810
|
+
treeConfig,
|
811
|
+
...editOpts,
|
812
|
+
...dataTableConfig.config,
|
813
|
+
|
814
|
+
},
|
815
|
+
exportAjax: (param) => {
|
816
|
+
let $grid = this.getGridTable();
|
817
|
+
let pageSize = param.size;
|
818
|
+
let currentPage = param.current;
|
819
|
+
let page = {pageSize, currentPage};
|
820
|
+
let customParam = {
|
821
|
+
config: {
|
822
|
+
modal: false,
|
823
|
+
},
|
824
|
+
};
|
825
|
+
return $grid.$options.propsData.proxyConfig.ajax.query.call(this, {
|
826
|
+
page,
|
827
|
+
param,
|
828
|
+
customParam,
|
829
|
+
});
|
830
|
+
},
|
831
|
+
// treeNodeUrl,
|
832
|
+
editDefaultRow,
|
833
|
+
treeNodeParam,
|
834
|
+
...otherConfig
|
835
|
+
};
|
836
|
+
|
837
|
+
if (isQueryTable) {
|
838
|
+
/*if(this.widget.options.isTreeTable){
|
839
|
+
tableOption.config.pagerConfig.autoHidden = false;
|
840
|
+
}*/
|
841
|
+
tableOption.path = path;
|
842
|
+
tableOption.config.proxyConfig = {
|
843
|
+
props: {
|
844
|
+
result: isDataPage ? "objx.records" : "objx", // 配置响应结果列表字段
|
845
|
+
total: isDataPage ? "objx.total" : "objx.length", // 配置响应结果总页数字段
|
846
|
+
},
|
847
|
+
ajax: {
|
848
|
+
// 接收 Promise 对象
|
849
|
+
query: ({page, sorts, filters, form, param, customParam}) => {
|
850
|
+
let formData = tableOption.param ? tableOption.param() || {} : {};
|
851
|
+
const queryParams = Object.assign({}, formData);
|
852
|
+
|
853
|
+
// 处理排序条件
|
854
|
+
/*if (sorts) {
|
855
|
+
const firstSort = sorts[0];
|
856
|
+
if (firstSort) {
|
857
|
+
queryParams.sort = firstSort.property;
|
858
|
+
queryParams.order = firstSort.order;
|
859
|
+
}
|
860
|
+
}*/
|
861
|
+
|
862
|
+
// 处理筛选条件
|
863
|
+
if (filters) {
|
864
|
+
filters.forEach(({property, values}) => {
|
865
|
+
queryParams[property] = values.join(",");
|
866
|
+
});
|
867
|
+
}
|
868
|
+
|
869
|
+
if (page.pageSize !== undefined) {
|
870
|
+
queryParams["size"] = page.pageSize;
|
871
|
+
queryParams["current"] = page.currentPage;
|
872
|
+
}
|
873
|
+
|
874
|
+
let $grid = this.getGridTable();
|
875
|
+
let isQueryAllPage = $grid.isQueryAllPage;
|
876
|
+
let pathStr1 = "";
|
877
|
+
if (isQueryAllPage === false) {
|
878
|
+
queryParams.searchCount = false;
|
879
|
+
}
|
880
|
+
Object.assign(queryParams, param);
|
881
|
+
|
882
|
+
// let formRef = that.getFormRef();
|
883
|
+
// let dataTableConfig = formRef.$attrs.dataTableOption || {};
|
884
|
+
if (that.dataTableConfig.queryParam) {
|
885
|
+
Object.assign(queryParams, that.dataTableConfig.queryParam);
|
886
|
+
}
|
887
|
+
|
888
|
+
var reqPath = typeof path == "function" ? path() : path;
|
889
|
+
let accessReturnType = this.widget.options.accessReturnType || 2;
|
890
|
+
let scriptCode = this.getScriptCode();
|
891
|
+
return new Promise((resolve, reject) => {
|
892
|
+
let reqData = {
|
893
|
+
...queryParams,
|
894
|
+
};
|
895
|
+
if (scriptCode) {
|
896
|
+
let index = 0;
|
897
|
+
let toDo = () => {
|
898
|
+
// let f = new Function("dataId", "formCode", "param", "done", accessScript);
|
899
|
+
let done = (res) => {
|
900
|
+
this.clearRowWidgets();
|
901
|
+
resolve(res);
|
902
|
+
if (res.type == "success") {
|
903
|
+
let rows = res.objx
|
904
|
+
? res.objx.records || res.objx || []
|
905
|
+
: [];
|
906
|
+
if (that.widget.options.isTreeTable) {
|
907
|
+
if (rows.length > 0) {
|
908
|
+
let fullAllDataRowMap =
|
909
|
+
$grid.$refs.xTable.fullAllDataRowMap;
|
910
|
+
let parentField = $grid.treeConfig.parentField;
|
911
|
+
let expandAll = $grid.treeConfig.expandAll || false;
|
912
|
+
let isLazy = $grid.treeConfig.lazy;
|
913
|
+
let expandIds = rows
|
914
|
+
.filter((item) => item[parentField])
|
915
|
+
.map((item) => item[parentField]);
|
916
|
+
let expandRows = expandIds.length
|
917
|
+
? rows.filter((item) =>
|
918
|
+
expandIds.includes(item.id)
|
919
|
+
)
|
920
|
+
: [];
|
921
|
+
if (expandAll && expandRows.length) {
|
922
|
+
that.$nextTick(() => {
|
923
|
+
setTimeout(function () {
|
924
|
+
$grid.treeConfig.lazy = false;
|
925
|
+
$grid.setTreeExpand(expandRows, true);
|
926
|
+
expandRows.forEach((lineData) => {
|
927
|
+
if (
|
928
|
+
$grid.$refs.xTable.isTreeExpandByRow(
|
929
|
+
lineData
|
930
|
+
)
|
931
|
+
) {
|
932
|
+
let rest =
|
933
|
+
fullAllDataRowMap.get(lineData);
|
934
|
+
rest.treeLoaded = true;
|
935
|
+
}
|
936
|
+
});
|
937
|
+
|
938
|
+
$grid.treeConfig.lazy = isLazy;
|
939
|
+
}, 0);
|
940
|
+
});
|
941
|
+
}
|
942
|
+
|
943
|
+
let row = rows.find((item) => !item[parentField]);
|
944
|
+
if (
|
945
|
+
row &&
|
946
|
+
(!expandAll || !expandIds.includes(row.id))
|
947
|
+
) {
|
948
|
+
let hasChild = $grid.treeConfig.hasChild;
|
949
|
+
if (row[hasChild]) {
|
950
|
+
that.$nextTick(() => {
|
951
|
+
setTimeout(function () {
|
952
|
+
$grid.setTreeExpand(row, true);
|
953
|
+
}, 0);
|
954
|
+
});
|
955
|
+
}
|
956
|
+
}
|
957
|
+
}
|
958
|
+
}
|
959
|
+
that.$nextTick(() => {
|
960
|
+
setTimeout(function () {
|
961
|
+
tableOption.callback && tableOption.callback(rows);
|
962
|
+
that.handleCustomEvent(
|
963
|
+
that.widget.options.formScriptCallback,
|
964
|
+
["rows"],
|
965
|
+
[rows]
|
966
|
+
);
|
967
|
+
}, 0);
|
968
|
+
});
|
969
|
+
}
|
970
|
+
};
|
971
|
+
this.loadDefaultQueryList(reqData, done, customParam);
|
972
|
+
};
|
973
|
+
let loopHandle = () => {
|
974
|
+
if (index < 500 && $grid.tableFormStop === true) {
|
975
|
+
//阻塞列表查询,或者次数达到500时,自动释放
|
976
|
+
index++;
|
977
|
+
setTimeout(() => {
|
978
|
+
loopHandle();
|
979
|
+
}, 10);
|
980
|
+
} else {
|
981
|
+
if ($grid.tableFormStop) $grid.tableFormStop = false;
|
982
|
+
toDo();
|
983
|
+
}
|
984
|
+
};
|
985
|
+
loopHandle();
|
986
|
+
} else {
|
987
|
+
resolve();
|
988
|
+
}
|
989
|
+
});
|
990
|
+
},
|
991
|
+
},
|
992
|
+
};
|
993
|
+
tableOption.callback = (rows) => {
|
994
|
+
// this.fieldModel = rows;
|
995
|
+
this.formModel[this.fieldKeyName] = rows;
|
996
|
+
};
|
997
|
+
}
|
998
|
+
|
999
|
+
if (isTreeTable) {
|
1000
|
+
tableOption.filterType = false;
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
if (this.widget.options.tableConfig) {
|
1004
|
+
let tableConfig =
|
1005
|
+
this.handleCustomEvent(this.widget.options.tableConfig) || {};
|
1006
|
+
tableOption = extendDeeply(tableOption, tableConfig);
|
1007
|
+
this.tableConfig = tableConfig;
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
if (tableOption.config.showFooter && !tableOption.config.footerMethod) {
|
1011
|
+
let footerColumnIds = columns
|
1012
|
+
.filter((item) => !!item.params?.footerDataType)
|
1013
|
+
.map((item) => item.params.columnId);
|
1014
|
+
if (footerColumnIds.length) {
|
1015
|
+
tableOption.config.footerMethod = (param) => {
|
1016
|
+
let {columns: column1s, data} = param;
|
1017
|
+
return [
|
1018
|
+
column1s.map((column, columnIndex) => {
|
1019
|
+
let columnId = column.params?.columnId;
|
1020
|
+
if (columnId && footerColumnIds.includes(columnId)) {
|
1021
|
+
let footerDataType = column.params.footerDataType;
|
1022
|
+
if (footerDataType == "1") {
|
1023
|
+
//求和
|
1024
|
+
return this.sumNum(data, column.field);
|
1025
|
+
} else if (footerDataType == "2") {
|
1026
|
+
//求平均值
|
1027
|
+
return this.meanNum(data, column.field);
|
1028
|
+
} else if (footerDataType == "3") {
|
1029
|
+
if (column.params.footerMethodConfg) {
|
1030
|
+
let n = new Function(
|
1031
|
+
"dataId",
|
1032
|
+
"formCode",
|
1033
|
+
"param",
|
1034
|
+
column.params.footerMethodConfg
|
1035
|
+
);
|
1036
|
+
return n.call(this, dataId, formCode, param) ?? null;
|
1037
|
+
}
|
1038
|
+
}
|
1039
|
+
}
|
1040
|
+
return null;
|
1041
|
+
}),
|
1042
|
+
];
|
1043
|
+
};
|
1044
|
+
}
|
1045
|
+
}
|
1046
|
+
tableOption.vue = this;
|
1047
|
+
|
1048
|
+
//合并单元格
|
1049
|
+
let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
|
1050
|
+
let unikey = this.widget.options.mergeRowKey;
|
1051
|
+
if (mergeRowEnabled && unikey) {
|
1052
|
+
tableOption.config.spanMethod = this.mergeRowMethod;
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
this.$vxeTableUtil.initVxeTable(tableOption).then((opts) => {
|
1056
|
+
this.vxeOption = opts;
|
1057
|
+
if (!isQueryTable) {
|
1058
|
+
setTimeout(() => {
|
1059
|
+
this.loadAccessData(1);
|
1060
|
+
}, 20);
|
1061
|
+
}
|
1062
|
+
});
|
1063
|
+
},
|
1064
|
+
meanNum(list, field) {
|
1065
|
+
let count = this.sumNum(list, field);
|
1066
|
+
return this.$baseDiv(count, list.length);
|
1067
|
+
},
|
1068
|
+
sumNum(list, field) {
|
1069
|
+
let count = 0;
|
1070
|
+
list.forEach((item) => {
|
1071
|
+
count = this.$baseAdd(count, item[field]);
|
1072
|
+
});
|
1073
|
+
return count;
|
1074
|
+
},
|
1075
|
+
getSearchFormData() {
|
1076
|
+
let map = {condition: []};
|
1077
|
+
let formData = this.globalModel.formModel;
|
1078
|
+
let widgetList = this.widget.widgetList;
|
1079
|
+
if (!!widgetList && widgetList.length > 0) {
|
1080
|
+
let loop = (wItem) => {
|
1081
|
+
if (wItem.category === "container") {
|
1082
|
+
loop(wItem);
|
1083
|
+
} else {
|
1084
|
+
let formField = this.getFieldKeyName(wItem);
|
1085
|
+
let vaule = formData[formField];
|
1086
|
+
if (vaule !== null && vaule !== undefined && vaule !== "") {
|
1087
|
+
if (!Array.isArray(vaule) || vaule.length > 0) {
|
1088
|
+
let item = {
|
1089
|
+
value: vaule,
|
1090
|
+
field: formField,
|
1091
|
+
filter: null,
|
1092
|
+
};
|
1093
|
+
let wType = wItem.type;
|
1094
|
+
if (["date-range", "time-range"].includes(wType)) {
|
1095
|
+
item.filter = "between";
|
1096
|
+
} else if (
|
1097
|
+
["input-batch", "checkbox"].includes(wType) ||
|
1098
|
+
(wType == "select" && wItem.options.multiple)
|
1099
|
+
) {
|
1100
|
+
item.filter = "in";
|
1101
|
+
} else if (
|
1102
|
+
["radio", "time", "date"].includes(wType) ||
|
1103
|
+
(wType == "select" && !wItem.options.multiple)
|
1104
|
+
) {
|
1105
|
+
item.filter = "eq";
|
1106
|
+
} else {
|
1107
|
+
item.filter = "like";
|
1108
|
+
}
|
1109
|
+
map.condition.push(item);
|
1110
|
+
}
|
1111
|
+
}
|
1112
|
+
}
|
1113
|
+
};
|
1114
|
+
widgetList.forEach((wItem) => {
|
1115
|
+
loop(wItem);
|
1116
|
+
});
|
1117
|
+
}
|
1118
|
+
return map;
|
1119
|
+
},
|
1120
|
+
getUrl() {
|
1121
|
+
let accessUrl = this.widget.options.accessUrl;
|
1122
|
+
return accessUrl || USER_PREFIX + `/form_ins/getFormInsData`;
|
1123
|
+
},
|
1124
|
+
getAttachmentType() {
|
1125
|
+
let vailColumns = this.widget.options.tableColumns.filter(
|
1126
|
+
(item) => item.prop && item.label
|
1127
|
+
);
|
1128
|
+
let result = vailColumns
|
1129
|
+
.filter((item) => {
|
1130
|
+
return item.formatS == "editAttachment";
|
1131
|
+
})
|
1132
|
+
.map((item) => item.prop);
|
1133
|
+
return result;
|
1134
|
+
},
|
1135
|
+
getThirdtabm() {
|
1136
|
+
let vailColumns = this.widget.options.tableColumns.filter(
|
1137
|
+
(item) => item.prop && item.label
|
1138
|
+
);
|
1139
|
+
let result = vailColumns
|
1140
|
+
.filter((item) => {
|
1141
|
+
return (
|
1142
|
+
item.formatS == "editSearch" && item.columnOption.multipleChoices
|
1143
|
+
);
|
1144
|
+
})
|
1145
|
+
.map((item) => item.prop);
|
1146
|
+
return result;
|
1147
|
+
},
|
1148
|
+
|
1149
|
+
loadDefaultViewList() {
|
1150
|
+
let dataId = this.formDataId;
|
1151
|
+
let reportTemplate = this.getFormRef().reportTemplate;
|
1152
|
+
let formCode = reportTemplate.formCode;
|
1153
|
+
let accessParam = this.getAccessParam() || {};
|
1154
|
+
let otherParam = {};
|
1155
|
+
let attachmentType = this.getAttachmentType();
|
1156
|
+
if (attachmentType.length) {
|
1157
|
+
otherParam.attachmentType = attachmentType;
|
1158
|
+
}
|
1159
|
+
let thirdtabm = this.getThirdtabm();
|
1160
|
+
if (thirdtabm.length) {
|
1161
|
+
otherParam.thirdtabm = thirdtabm;
|
1162
|
+
}
|
1163
|
+
let scriptCode = this.getScriptCode();
|
1164
|
+
return this.formHttp({
|
1165
|
+
/*url: "/" + reportTemplate.serviceName + "/form_ins/getList",*/
|
1166
|
+
scriptCode: scriptCode,
|
1167
|
+
data: {
|
1168
|
+
formCode: formCode,
|
1169
|
+
formVersion: reportTemplate.formVersion,
|
1170
|
+
taBm: this.fieldKeyName,
|
1171
|
+
data: {
|
1172
|
+
id: dataId,
|
1173
|
+
...otherParam,
|
1174
|
+
...accessParam,
|
1175
|
+
},
|
1176
|
+
},
|
1177
|
+
callback: (res) => {
|
1178
|
+
let $grid = this.getGridTable();
|
1179
|
+
let rows = res.objx ? res.objx.records || res.objx || [] : [];
|
1180
|
+
let defaultRow = this.createNewTableData();
|
1181
|
+
rows = rows.map((row) => {
|
1182
|
+
return {
|
1183
|
+
...defaultRow,
|
1184
|
+
...row,
|
1185
|
+
};
|
1186
|
+
});
|
1187
|
+
this.setValue(rows);
|
1188
|
+
this.$nextTick(() => {
|
1189
|
+
/*if (this.widget.options.isTreeTable) {
|
1190
|
+
let $grid = this.getGridTable();
|
1191
|
+
$grid.treeConfig.lazy = false;
|
1192
|
+
$grid.setAllTreeExpand(true);
|
1193
|
+
}*/
|
1194
|
+
this.tableConfig.callback && this.tableConfig.callback(rows);
|
1195
|
+
this.handleCustomEvent(
|
1196
|
+
this.widget.options.formScriptCallback,
|
1197
|
+
["rows"],
|
1198
|
+
[rows]
|
1199
|
+
);
|
1200
|
+
this.$forceUpdate();
|
1201
|
+
});
|
1202
|
+
},
|
1203
|
+
});
|
1204
|
+
},
|
1205
|
+
getAccessParam() {
|
1206
|
+
if (!this.widget.options.formScriptParam) return;
|
1207
|
+
return this.handleCustomEvent(this.widget.options.formScriptParam);
|
1208
|
+
},
|
1209
|
+
getScriptCode() {
|
1210
|
+
let accessReturnType = this.widget.options.accessReturnType;
|
1211
|
+
let defaultScriptCode = "getList";
|
1212
|
+
if (accessReturnType == 1) {
|
1213
|
+
defaultScriptCode = "getList";
|
1214
|
+
} else if (accessReturnType == 2) {
|
1215
|
+
defaultScriptCode = "getPage";
|
1216
|
+
}
|
1217
|
+
let scriptCode = this.widget.options.formScriptCode || defaultScriptCode;
|
1218
|
+
return scriptCode;
|
1219
|
+
},
|
1220
|
+
loadDefaultQueryList(reqData, done, customParam) {
|
1221
|
+
let reportTemplate = this.getFormRef().reportTemplate;
|
1222
|
+
let prefix = "/" + reportTemplate.serviceName;
|
1223
|
+
let formCode = reportTemplate.formCode;
|
1224
|
+
let formConfig = this.formConfig;
|
1225
|
+
let accessReturnType = this.widget.options.accessReturnType;
|
1226
|
+
let scriptCode = this.getScriptCode();
|
1227
|
+
let accessParam = this.getAccessParam() || {};
|
1228
|
+
|
1229
|
+
let otherParam = {};
|
1230
|
+
let attachmentType = this.getAttachmentType();
|
1231
|
+
if (attachmentType.length) {
|
1232
|
+
otherParam.attachmentType = attachmentType;
|
1233
|
+
}
|
1234
|
+
|
1235
|
+
let defaultOption = this.getHttpConfigForUser();
|
1236
|
+
|
1237
|
+
let ajaxConfig = customParam?.config || {};
|
1238
|
+
|
1239
|
+
let requestData = {
|
1240
|
+
...reqData,
|
1241
|
+
...otherParam
|
1242
|
+
};
|
1243
|
+
requestData = extendDeeply(requestData, accessParam);
|
1244
|
+
|
1245
|
+
return this.formHttp({
|
1246
|
+
// url: prefix + "/form_ins/getPage",
|
1247
|
+
scriptCode: scriptCode,
|
1248
|
+
data: {
|
1249
|
+
formCode: formCode,
|
1250
|
+
formVersion: reportTemplate.formVersion,
|
1251
|
+
taBm: this.fieldKeyName,
|
1252
|
+
data: requestData,
|
1253
|
+
},
|
1254
|
+
isLoading: false,
|
1255
|
+
...defaultOption,
|
1256
|
+
...ajaxConfig,
|
1257
|
+
callback: (res) => {
|
1258
|
+
done(res);
|
1259
|
+
},
|
1260
|
+
});
|
1261
|
+
},
|
1262
|
+
loadAccessData(flag) {
|
1263
|
+
if (flag === 1) {
|
1264
|
+
let tableConfig = this.tableConfig;
|
1265
|
+
let accessEnabled = tableConfig.accessEnabled ?? true;
|
1266
|
+
if (accessEnabled === false) {
|
1267
|
+
return;
|
1268
|
+
}
|
1269
|
+
if (this.formConfig.isLoadEntity && !this.formDataId) {
|
1270
|
+
return;
|
1271
|
+
}
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
let scriptCode = this.getScriptCode();
|
1275
|
+
if (scriptCode) {
|
1276
|
+
this.loadDefaultViewList();
|
1277
|
+
}
|
1278
|
+
},
|
1279
|
+
getReqParam(item, dataId, billData) {
|
1280
|
+
let param = {};
|
1281
|
+
if (item.accessParam) {
|
1282
|
+
if (typeof item.accessParam === "string") {
|
1283
|
+
let n = new Function("billData", item.accessParam);
|
1284
|
+
param = n.call(this, billData);
|
1285
|
+
} else {
|
1286
|
+
param = item.accessParam;
|
1287
|
+
}
|
1288
|
+
} else {
|
1289
|
+
param = {id: dataId};
|
1290
|
+
}
|
1291
|
+
return param;
|
1292
|
+
},
|
1293
|
+
getTableRef() {
|
1294
|
+
let tableRef = this.widget.id;
|
1295
|
+
return tableRef;
|
1296
|
+
},
|
1297
|
+
exportData(option) {
|
1298
|
+
let tableRef = this.getTableRef();
|
1299
|
+
let serviceName = this.getFormRef().reportTemplate.serviceName;
|
1300
|
+
option.prefix = option.prefix || "/" + serviceName;
|
1301
|
+
this.$excelExport({targetRef: tableRef, ...option});
|
1302
|
+
},
|
1303
|
+
async deleteRow(row, rowIndex) {
|
1304
|
+
let isTreeTable = this.widget.options.isTreeTable;
|
1305
|
+
if (isTreeTable) {
|
1306
|
+
this.removeTreeRow({row});
|
1307
|
+
return;
|
1308
|
+
}
|
1309
|
+
let $grid = this.getGridTable();
|
1310
|
+
$grid.remove(row);
|
1311
|
+
let tableData = $grid.getTableData();
|
1312
|
+
let isEditTable = this.widget.options.isEditTable;
|
1313
|
+
let fullData = !isEditTable ? tableData.fullData : tableData.tableData;
|
1314
|
+
await this.$nextTick(() => {
|
1315
|
+
this.formModel[this.fieldKeyName] = fullData;
|
1316
|
+
this.fieldModel = fullData;
|
1317
|
+
});
|
1318
|
+
this.$nextTick(() => {
|
1319
|
+
this.handleWbs();
|
1320
|
+
});
|
1321
|
+
this.deleteRowWidgets(row)
|
1322
|
+
},
|
1323
|
+
createNewTableData(isEdit) {
|
1324
|
+
let vailColumns = this.widget.options.tableColumns.filter(
|
1325
|
+
(item) => item.prop && item.label
|
1326
|
+
);
|
1327
|
+
let newData = {};
|
1328
|
+
vailColumns.forEach((item) => {
|
1329
|
+
let formatS = !isEdit ? item.formatS : item.editFormatS;
|
1330
|
+
let columnOption = !isEdit ? item.columnOption : item.editColumnOption;
|
1331
|
+
if (formatS == "editSearch") {
|
1332
|
+
newData[item.prop] = null;
|
1333
|
+
let vabSearchName = item?.columnOption?.vabSearchName;
|
1334
|
+
if (vabSearchName) newData[vabSearchName] = null;
|
1335
|
+
}
|
1336
|
+
if (formatS == "editAttachment") {
|
1337
|
+
newData[item.prop] = [];
|
1338
|
+
} else {
|
1339
|
+
newData[item.prop] = null;
|
1340
|
+
if (
|
1341
|
+
columnOption &&
|
1342
|
+
columnOption.defaultValue !== undefined &&
|
1343
|
+
columnOption.defaultValue !== null &&
|
1344
|
+
columnOption.defaultValue !== ""
|
1345
|
+
) {
|
1346
|
+
newData[item.prop] = columnOption.defaultValue;
|
1347
|
+
}
|
1348
|
+
}
|
1349
|
+
});
|
1350
|
+
return newData;
|
1351
|
+
},
|
1352
|
+
addTableData(rows, field) {
|
1353
|
+
let $grid = this.getGridTable();
|
1354
|
+
let formDataModel = this.formModel;
|
1355
|
+
let tableRows = formDataModel[this.fieldKeyName] || [];
|
1356
|
+
let fullData = $grid.getTableData().fullData;
|
1357
|
+
let items;
|
1358
|
+
if (field) {
|
1359
|
+
let keys = fullData.map((item) => {
|
1360
|
+
return item[field] + "";
|
1361
|
+
});
|
1362
|
+
items = rows.filter((item) => {
|
1363
|
+
let value = item[field] + "";
|
1364
|
+
return !keys.includes(value);
|
1365
|
+
});
|
1366
|
+
} else {
|
1367
|
+
items = rows;
|
1368
|
+
}
|
1369
|
+
if (items) {
|
1370
|
+
if (items.length) {
|
1371
|
+
items.forEach((row) => {
|
1372
|
+
let newData = this.createNewTableData();
|
1373
|
+
Object.assign(newData, row);
|
1374
|
+
|
1375
|
+
tableRows.push(newData);
|
1376
|
+
});
|
1377
|
+
}
|
1378
|
+
} else {
|
1379
|
+
let newData = this.createNewTableData();
|
1380
|
+
tableRows.push(newData);
|
1381
|
+
}
|
1382
|
+
// this.formModel[this.fieldKeyName] = this.$baseLodash(this.fieldModel)
|
1383
|
+
// this.fieldModel = tableRows
|
1384
|
+
this.setValue(tableRows);
|
1385
|
+
this.$nextTick(() => {
|
1386
|
+
this.handleWbs();
|
1387
|
+
});
|
1388
|
+
// $grid.loadData(tableRows);
|
1389
|
+
},
|
1390
|
+
getColumnWidgetConfig(row, isEdit) {
|
1391
|
+
let formatS = isEdit ? row.editFormatS : row.formatS;
|
1392
|
+
let formRef = this.getFormRef();
|
1393
|
+
let columnSelectedWidget = null;
|
1394
|
+
let columnEditFields = null;
|
1395
|
+
|
1396
|
+
let type = this.columnFormatMap[formatS];
|
1397
|
+
|
1398
|
+
if (type) {
|
1399
|
+
columnSelectedWidget = this.$baseLodash.cloneDeep(
|
1400
|
+
formRef.getFieldWidgetByType(type)
|
1401
|
+
);
|
1402
|
+
let tmpId = generateId();
|
1403
|
+
let idVal = row.prop ? row.prop : type + tmpId;
|
1404
|
+
columnSelectedWidget.id = idVal;
|
1405
|
+
columnSelectedWidget.options.name = idVal;
|
1406
|
+
|
1407
|
+
let columnOption;
|
1408
|
+
if (!isEdit) {
|
1409
|
+
columnOption = row.columnOption;
|
1410
|
+
} else {
|
1411
|
+
columnOption = row.editColumnOption;
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
if (columnOption && Object.keys(columnOption).length) {
|
1415
|
+
columnOption.required = row.required || false;
|
1416
|
+
columnSelectedWidget.options = columnOption;
|
1417
|
+
if ("editDelete" == formatS) {
|
1418
|
+
columnSelectedWidget.options.hiddenByWf =
|
1419
|
+
columnSelectedWidget.options.hiddenByWf ?? true;
|
1420
|
+
columnSelectedWidget.options.prefixIcon =
|
1421
|
+
columnSelectedWidget.options.prefixIcon || "el-icon-delete";
|
1422
|
+
} else if ("editButton" == formatS) {
|
1423
|
+
columnSelectedWidget.options.prefixIcon =
|
1424
|
+
columnSelectedWidget.options.prefixIcon || "el-icon-edit";
|
1425
|
+
}
|
1426
|
+
} else {
|
1427
|
+
columnSelectedWidget.options.required = row.required || false;
|
1428
|
+
if ("editDelete" == formatS) {
|
1429
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-delete";
|
1430
|
+
columnSelectedWidget.options.label = "删除";
|
1431
|
+
columnSelectedWidget.options.labelHidden = true;
|
1432
|
+
columnSelectedWidget.options.hiddenByWf = true;
|
1433
|
+
columnSelectedWidget.options.onClick =
|
1434
|
+
"let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
|
1435
|
+
} else if ("editButton" == formatS) {
|
1436
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-edit";
|
1437
|
+
columnSelectedWidget.options.label = "查看";
|
1438
|
+
columnSelectedWidget.options.labelHidden = true;
|
1439
|
+
columnSelectedWidget.options.onClick =
|
1440
|
+
"let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
|
1441
|
+
} else if ("addSiblingEditRow" == formatS) {
|
1442
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-plus";
|
1443
|
+
columnSelectedWidget.options.label = "新增兄弟节点";
|
1444
|
+
columnSelectedWidget.options.labelHidden = false;
|
1445
|
+
columnSelectedWidget.options.onClick =
|
1446
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
|
1447
|
+
} else if ("addChildTreeRow" == formatS) {
|
1448
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-plus";
|
1449
|
+
columnSelectedWidget.options.label = "新增子节点";
|
1450
|
+
columnSelectedWidget.options.labelHidden = false;
|
1451
|
+
columnSelectedWidget.options.onClick =
|
1452
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
|
1453
|
+
} else if ("moveUpRow" == formatS) {
|
1454
|
+
// columnSelectedWidget.options.prefixIcon = "el-icon-plus";
|
1455
|
+
columnSelectedWidget.options.label = "↑上移";
|
1456
|
+
columnSelectedWidget.options.labelHidden = false;
|
1457
|
+
columnSelectedWidget.options.onClick =
|
1458
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
|
1459
|
+
} else if ("moveDownRow" == formatS) {
|
1460
|
+
// columnSelectedWidget.options.prefixIcon = "el-icon-plus";
|
1461
|
+
columnSelectedWidget.options.label = "↓下移";
|
1462
|
+
columnSelectedWidget.options.labelHidden = false;
|
1463
|
+
columnSelectedWidget.options.onClick =
|
1464
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
|
1465
|
+
} else if ("removeTreeRow" == formatS) {
|
1466
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-delete";
|
1467
|
+
columnSelectedWidget.options.label = "删除";
|
1468
|
+
columnSelectedWidget.options.labelHidden = true;
|
1469
|
+
columnSelectedWidget.options.onClick =
|
1470
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
|
1471
|
+
}
|
1472
|
+
columnOption = columnSelectedWidget.options;
|
1473
|
+
}
|
1474
|
+
if (columnSelectedWidget.options.hasOwnProperty("keyName")) {
|
1475
|
+
columnSelectedWidget.options.keyName = row.prop;
|
1476
|
+
columnSelectedWidget.options.keyNameEnabled = true;
|
1477
|
+
} else {
|
1478
|
+
columnSelectedWidget.options.name = row.prop;
|
1479
|
+
}
|
1480
|
+
if (type != "button" && type != "a-link") {
|
1481
|
+
columnSelectedWidget.options.label = row.label;
|
1482
|
+
columnSelectedWidget.options.labelHidden = true;
|
1483
|
+
}
|
1484
|
+
}
|
1485
|
+
return {columnSelectedWidget, columnEditFields};
|
1486
|
+
},
|
1487
|
+
getColumnProp(widget, obj, isEdit) {
|
1488
|
+
if (!widget) {
|
1489
|
+
return "false";
|
1490
|
+
}
|
1491
|
+
/*if(isEdit){
|
1492
|
+
return "false"
|
1493
|
+
}*/
|
1494
|
+
|
1495
|
+
let fieldKeyName = this.getFieldKeyName(widget);
|
1496
|
+
let rowIndex = Math.max(obj.rowIndex, 0);
|
1497
|
+
let isQueryTable = this.widget.options.isQueryTable || false;
|
1498
|
+
if (isEdit || !isQueryTable) {
|
1499
|
+
let propName =
|
1500
|
+
fieldKeyName + "." + rowIndex + "." + obj.column.property;
|
1501
|
+
let lineWidget = !isEdit
|
1502
|
+
? obj.column.params.widget
|
1503
|
+
: obj.column.params.editWidget;
|
1504
|
+
if (!lineWidget) {
|
1505
|
+
return "false";
|
1506
|
+
}
|
1507
|
+
if (this.isVabsearchFlagWidget(lineWidget)) {
|
1508
|
+
let fieldName =
|
1509
|
+
lineWidget.options.vabSearchName ||
|
1510
|
+
this.getFieldKeyName(lineWidget);
|
1511
|
+
propName = fieldKeyName + "." + rowIndex + "." + fieldName;
|
1512
|
+
}
|
1513
|
+
|
1514
|
+
return propName;
|
1515
|
+
} else {
|
1516
|
+
return "false";
|
1517
|
+
}
|
1518
|
+
},
|
1519
|
+
isVabsearchFlagWidget(widget) {
|
1520
|
+
let type = widget?.type;
|
1521
|
+
return type == "vabsearch" || type == "singerSearch" || type == "multiSearch";
|
1522
|
+
},
|
1523
|
+
getColumnWidgetName(e) {
|
1524
|
+
if (e && e.type) {
|
1525
|
+
if (e.category == "container") {
|
1526
|
+
return this.getContainerWidgetName(e);
|
1527
|
+
} else {
|
1528
|
+
return e.type + "-widget";
|
1529
|
+
}
|
1530
|
+
}
|
1531
|
+
},
|
1532
|
+
getGridTable() {
|
1533
|
+
let $grid = this.$refs[this.getTableRef()];
|
1534
|
+
return $grid;
|
1535
|
+
},
|
1536
|
+
getContainerWidgetName: function (e) {
|
1537
|
+
return "grid" === e.type ? "grid-item" : e.type + "-item";
|
1538
|
+
},
|
1539
|
+
getWidgetName: function (e) {
|
1540
|
+
return (e.targetType || e.type) + "-widget";
|
1541
|
+
},
|
1542
|
+
handleCheckboxChange(param) {
|
1543
|
+
let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
|
1544
|
+
let mergeRowKey = this.widget.options.mergeRowKey;
|
1545
|
+
if (mergeRowEnabled && mergeRowKey) {
|
1546
|
+
let grid = this.getGridTable();
|
1547
|
+
let fullData = grid.getTableData().fullData;
|
1548
|
+
let row = param.row;
|
1549
|
+
let val = row[mergeRowKey];
|
1550
|
+
let items = fullData.filter((item) => item[mergeRowKey] === val);
|
1551
|
+
if (items.length) {
|
1552
|
+
grid.setCheckboxRow(items, param.checked);
|
1553
|
+
}
|
1554
|
+
}
|
1555
|
+
if (this.widget.options.onCheckboxChange) {
|
1556
|
+
let t = new Function("param", this.widget.options.onCheckboxChange);
|
1557
|
+
t.call(this, param);
|
1558
|
+
}
|
1559
|
+
let formRef = this.getFormRef();
|
1560
|
+
let dataTableConfig = formRef.$attrs.dataTableOption || {};
|
1561
|
+
dataTableConfig.onCheckboxChange &&
|
1562
|
+
dataTableConfig.onCheckboxChange(param);
|
1563
|
+
},
|
1564
|
+
handleCheckboxAll(param) {
|
1565
|
+
if (this.widget.options.onCheckboxAll) {
|
1566
|
+
let t = new Function("param", this.widget.options.onCheckboxAll);
|
1567
|
+
t.call(this, param);
|
1568
|
+
}
|
1569
|
+
let formRef = this.getFormRef();
|
1570
|
+
let dataTableConfig = formRef.$attrs.dataTableOption || {};
|
1571
|
+
dataTableConfig.onCheckboxAll && dataTableConfig.onCheckboxAll(param);
|
1572
|
+
},
|
1573
|
+
handleCellDblclick(param) {
|
1574
|
+
if (this.widget.options.onCellDblclick) {
|
1575
|
+
let t = new Function("param", this.widget.options.onCellDblclick);
|
1576
|
+
t.call(this, param);
|
1577
|
+
}
|
1578
|
+
let formRef = this.getFormRef();
|
1579
|
+
let dataTableConfig = formRef.$attrs.dataTableOption || {};
|
1580
|
+
dataTableConfig.onCellDblclick && dataTableConfig.onCellDblclick(param);
|
1581
|
+
},
|
1582
|
+
advancedClear() {
|
1583
|
+
let formModel = this.formModel;
|
1584
|
+
let searchColumns = this.getGridTable().searchColumns;
|
1585
|
+
searchColumns.forEach((form1Field) => {
|
1586
|
+
if (!form1Field.common) {
|
1587
|
+
let field = form1Field.field;
|
1588
|
+
let options = form1Field.widget.options;
|
1589
|
+
let value = formModel[field] ?? null;
|
1590
|
+
let widgetRef = this.getWidgetRef(options.name);
|
1591
|
+
widgetRef && widgetRef.setValue(value);
|
1592
|
+
}
|
1593
|
+
});
|
1594
|
+
// this.getGridTable().$forceUpdate();
|
1595
|
+
},
|
1596
|
+
tableFormSettingConfirm() {
|
1597
|
+
let formModel = this.formModel;
|
1598
|
+
this.getFormRef().setFormData(formModel);
|
1599
|
+
},
|
1600
|
+
|
1601
|
+
//editTable begin
|
1602
|
+
saveEditRow(obj) {
|
1603
|
+
let formRef = this.getFormRef();
|
1604
|
+
let formConfig = this.formConfig;
|
1605
|
+
let entity = formConfig.entity;
|
1606
|
+
if (!entity) return;
|
1607
|
+
let dataId = formRef?.dataId;
|
1608
|
+
let reportTemplate = formRef?.reportTemplate;
|
1609
|
+
let formCode = reportTemplate?.formCode;
|
1610
|
+
let scriptCode = formConfig.saveScriptCode || "saveUpdate";
|
1611
|
+
|
1612
|
+
let that = this;
|
1613
|
+
let $grid = obj.$table.$xegrid;
|
1614
|
+
let originOption = $grid.originOption;
|
1615
|
+
|
1616
|
+
let formModel = this.formModel;
|
1617
|
+
let dataMap = this.getGridTable().getTableData();
|
1618
|
+
|
1619
|
+
formRef.validate((valid) => {
|
1620
|
+
if (valid) {
|
1621
|
+
$grid.clearActived().then(() => {
|
1622
|
+
$grid.setActiveRow(obj.row);
|
1623
|
+
let mainData = commonDataUtil.handleForm(obj.row);
|
1624
|
+
|
1625
|
+
delete mainData._createNickName;
|
1626
|
+
delete mainData._createMobile;
|
1627
|
+
delete mainData._modifyNickName;
|
1628
|
+
delete mainData._modifyMobile;
|
1629
|
+
delete mainData._createBy;
|
1630
|
+
delete mainData._modifyBy;
|
1631
|
+
|
1632
|
+
let formData = {
|
1633
|
+
[entity]: mainData,
|
1634
|
+
};
|
1635
|
+
|
1636
|
+
let reqData = {
|
1637
|
+
formCode: formCode,
|
1638
|
+
formVersion: reportTemplate.formVersion,
|
1639
|
+
taBm: entity,
|
1640
|
+
data: formData,
|
1641
|
+
};
|
1642
|
+
|
1643
|
+
this.formHttp({
|
1644
|
+
scriptCode: scriptCode,
|
1645
|
+
data: reqData,
|
1646
|
+
successMsg: true,
|
1647
|
+
isConfirm: true,
|
1648
|
+
confirmText: "您确定要保存吗?",
|
1649
|
+
success: (res0) => {
|
1650
|
+
this.getRowData(res0.objx, (res) => {
|
1651
|
+
if (obj.row.id == res.objx.id) {
|
1652
|
+
$grid.clearActived().then(() => {
|
1653
|
+
Object.assign(obj.row, res.objx);
|
1654
|
+
});
|
1655
|
+
} else {
|
1656
|
+
$grid.remove(obj.row);
|
1657
|
+
$grid.insertAt(res.objx);
|
1658
|
+
}
|
1659
|
+
delete obj.$table.editCloneRow;
|
1660
|
+
});
|
1661
|
+
},
|
1662
|
+
});
|
1663
|
+
});
|
1664
|
+
}
|
1665
|
+
});
|
1666
|
+
},
|
1667
|
+
getRowData(dataId, callback) {
|
1668
|
+
let reportTemplate = this.getFormRef()?.reportTemplate;
|
1669
|
+
let formCode = reportTemplate.formCode;
|
1670
|
+
let formConfig = this.formConfig;
|
1671
|
+
// let isLoadEntity = formConfig.isLoadEntity;
|
1672
|
+
let entity = formConfig.entity;
|
1673
|
+
let scriptCode = formConfig.formScriptCode || "getOne";
|
1674
|
+
let defaultOption = this.getHttpConfigForUser();
|
1675
|
+
this.formHttp({
|
1676
|
+
scriptCode: scriptCode,
|
1677
|
+
data: {
|
1678
|
+
formCode: formCode,
|
1679
|
+
formVersion: reportTemplate.formVersion,
|
1680
|
+
taBm: entity,
|
1681
|
+
data: {
|
1682
|
+
id: dataId,
|
1683
|
+
},
|
1684
|
+
},
|
1685
|
+
...defaultOption,
|
1686
|
+
success: (res) => {
|
1687
|
+
callback && callback(res);
|
1688
|
+
},
|
1689
|
+
});
|
1690
|
+
},
|
1691
|
+
addChildTreeRow(rowData, obj, toTop) {
|
1692
|
+
let toEnd = !toTop;
|
1693
|
+
this.addTreeRow(rowData, obj, toEnd, null);
|
1694
|
+
},
|
1695
|
+
addTopTreeRow(rowData, toTop) {
|
1696
|
+
let toEnd = !toTop;
|
1697
|
+
this.addTreeRow(rowData, null, toEnd, null);
|
1698
|
+
},
|
1699
|
+
addSiblingTreeRow(rowData, obj) {
|
1700
|
+
this.addTreeRow(rowData, obj, null, true);
|
1701
|
+
},
|
1702
|
+
addTreeRow(rowData, obj, toEnd, toSibling) {
|
1703
|
+
let isEditTable = this.widget.options.isEditTable || false;
|
1704
|
+
let parent = obj?.row;
|
1705
|
+
let $grid = this.getGridTable();
|
1706
|
+
if (isEditTable && this.hasEditingRow($grid, 1)) {
|
1707
|
+
return false;
|
1708
|
+
}
|
1709
|
+
let parentField = $grid.treeConfig.parentField;
|
1710
|
+
let newRow = {};
|
1711
|
+
let originOption = $grid.originOption;
|
1712
|
+
let editDefaultRow;
|
1713
|
+
if (originOption.editDefaultRow) {
|
1714
|
+
if (typeof originOption.editDefaultRow == "function") {
|
1715
|
+
editDefaultRow = originOption.editDefaultRow() || {};
|
1716
|
+
} else {
|
1717
|
+
editDefaultRow = originOption.editDefaultRow || {};
|
1718
|
+
}
|
1719
|
+
}
|
1720
|
+
// Object.assign(newRow, editDefaultRow, rowData);
|
1721
|
+
newRow.id =
|
1722
|
+
"row_" + new Date().valueOf() + Math.floor(Math.random() * 1000000);
|
1723
|
+
if (!toSibling) {
|
1724
|
+
newRow[parentField] = parent?.id || 0;
|
1725
|
+
} else {
|
1726
|
+
newRow[parentField] = obj?.row[parentField] || 0;
|
1727
|
+
}
|
1728
|
+
|
1729
|
+
let newData = this.createNewTableData(isEditTable);
|
1730
|
+
newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
|
1731
|
+
|
1732
|
+
let tableRows = this.formModel[this.fieldKeyName] || [];
|
1733
|
+
if (!parent) {
|
1734
|
+
if (toEnd === true) {
|
1735
|
+
tableRows.push(newRow);
|
1736
|
+
} else if (toSibling === true) {
|
1737
|
+
let addIndex =
|
1738
|
+
tableRows.findIndex(
|
1739
|
+
(item) => item._X_ROW_KEY == obj.row._X_ROW_KEY
|
1740
|
+
) + 1;
|
1741
|
+
tableRows.splice(addIndex, 0, newRow);
|
1742
|
+
} else {
|
1743
|
+
tableRows.splice(0, 0, newRow);
|
1744
|
+
}
|
1745
|
+
this.setValue(tableRows);
|
1746
|
+
this.$nextTick(() => {
|
1747
|
+
this.handleWbs();
|
1748
|
+
if (isEditTable) {
|
1749
|
+
$grid.setActiveRow(newRow);
|
1750
|
+
}
|
1751
|
+
});
|
1752
|
+
|
1753
|
+
// $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
|
1754
|
+
} else {
|
1755
|
+
$grid.setTreeExpand(obj.row, true).then(() => {
|
1756
|
+
if (toEnd === true) {
|
1757
|
+
tableRows.push(newRow);
|
1758
|
+
} else if (toSibling === true) {
|
1759
|
+
let addIndex =
|
1760
|
+
tableRows.findIndex(
|
1761
|
+
(item) => item._X_ROW_KEY == obj.row._X_ROW_KEY
|
1762
|
+
) + 1;
|
1763
|
+
tableRows.splice(addIndex, 0, newRow);
|
1764
|
+
} else {
|
1765
|
+
tableRows.splice(0, 0, newRow);
|
1766
|
+
}
|
1767
|
+
this.setValue(tableRows);
|
1768
|
+
this.$nextTick(() => {
|
1769
|
+
this.handleWbs();
|
1770
|
+
$grid.setTreeExpand(obj.row, true).then(() => {
|
1771
|
+
if (isEditTable) {
|
1772
|
+
$grid.setActiveRow(newRow);
|
1773
|
+
}
|
1774
|
+
});
|
1775
|
+
});
|
1776
|
+
});
|
1777
|
+
}
|
1778
|
+
},
|
1779
|
+
removeTreeRow(obj) {
|
1780
|
+
let row = obj.row;
|
1781
|
+
let $grid = this.getGridTable();
|
1782
|
+
let childrenField = $grid.treeConfig.children;
|
1783
|
+
let tableRows = this.formModel[this.fieldKeyName];
|
1784
|
+
// let index = tableRows.findIndex(item => item.id === row.id)
|
1785
|
+
let delIds = [];
|
1786
|
+
if (row[childrenField]) {
|
1787
|
+
let loopDo = (item) => {
|
1788
|
+
if (item.id) delIds.push(item.id);
|
1789
|
+
item[childrenField] &&
|
1790
|
+
item[childrenField].forEach((subItem) => {
|
1791
|
+
loopDo(subItem);
|
1792
|
+
});
|
1793
|
+
};
|
1794
|
+
loopDo(row);
|
1795
|
+
}
|
1796
|
+
delIds.forEach((id) => {
|
1797
|
+
let index = tableRows.findIndex((item) => item.id === id);
|
1798
|
+
let delRow = tableRows[index];
|
1799
|
+
tableRows.splice(index, 1);
|
1800
|
+
this.deleteRowWidgets(delRow)
|
1801
|
+
|
1802
|
+
});
|
1803
|
+
this.$nextTick(() => {
|
1804
|
+
this.handleWbs();
|
1805
|
+
});
|
1806
|
+
},
|
1807
|
+
addSiblingEditRow(rowData, obj) {
|
1808
|
+
this.addEditRow(rowData, obj, null, true);
|
1809
|
+
},
|
1810
|
+
addEditRow(rowData, obj, toEnd, toSibling) {
|
1811
|
+
let isEditTable = this.widget.options.isEditTable || false;
|
1812
|
+
let parent = obj?.row;
|
1813
|
+
let $grid = this.getGridTable();
|
1814
|
+
if (isEditTable && this.hasEditingRow($grid, 1)) {
|
1815
|
+
return false;
|
1816
|
+
}
|
1817
|
+
let parentField = $grid.treeConfig.parentField;
|
1818
|
+
let newRow = {};
|
1819
|
+
let originOption = $grid.originOption;
|
1820
|
+
let editDefaultRow;
|
1821
|
+
if (originOption.editDefaultRow) {
|
1822
|
+
if (typeof originOption.editDefaultRow == "function") {
|
1823
|
+
editDefaultRow = originOption.editDefaultRow() || {};
|
1824
|
+
} else {
|
1825
|
+
editDefaultRow = originOption.editDefaultRow || {};
|
1826
|
+
}
|
1827
|
+
}
|
1828
|
+
// Object.assign(newRow, editDefaultRow, rowData);
|
1829
|
+
newRow.id =
|
1830
|
+
"row_" + new Date().valueOf() + Math.floor(Math.random() * 1000000);
|
1831
|
+
if (!toSibling) {
|
1832
|
+
newRow[parentField] = parent?.id || 0;
|
1833
|
+
} else {
|
1834
|
+
newRow[parentField] = obj?.row[parentField] || 0;
|
1835
|
+
}
|
1836
|
+
|
1837
|
+
let newData = this.createNewTableData(isEditTable);
|
1838
|
+
newRow = Object.assign({}, newData, newRow, editDefaultRow, rowData);
|
1839
|
+
|
1840
|
+
let tableRows = this.formModel[this.fieldKeyName] || [];
|
1841
|
+
if (!parent) {
|
1842
|
+
if (toEnd === true) {
|
1843
|
+
tableRows.push(newRow);
|
1844
|
+
} else if (toSibling === true) {
|
1845
|
+
let addIndex =
|
1846
|
+
tableRows.findIndex(
|
1847
|
+
(item) => item._X_ROW_KEY == obj.row._X_ROW_KEY
|
1848
|
+
) + 1;
|
1849
|
+
tableRows.splice(addIndex, 0, newRow);
|
1850
|
+
} else {
|
1851
|
+
tableRows.splice(0, 0, newRow);
|
1852
|
+
}
|
1853
|
+
this.setValue(tableRows);
|
1854
|
+
this.$nextTick(() => {
|
1855
|
+
this.handleWbs();
|
1856
|
+
if (isEditTable) {
|
1857
|
+
$grid.setActiveRow(newRow);
|
1858
|
+
}
|
1859
|
+
});
|
1860
|
+
|
1861
|
+
// $grid.insert(newRow).then(({row}) => $grid.setActiveRow(row));
|
1862
|
+
} else {
|
1863
|
+
$grid.setTreeExpand(obj.row, true).then(() => {
|
1864
|
+
if (toEnd === true) {
|
1865
|
+
tableRows.push(newRow);
|
1866
|
+
} else if (toSibling === true) {
|
1867
|
+
let addIndex =
|
1868
|
+
tableRows.findIndex(
|
1869
|
+
(item) => item._X_ROW_KEY == obj.row._X_ROW_KEY
|
1870
|
+
) + 1;
|
1871
|
+
tableRows.splice(addIndex, 0, newRow);
|
1872
|
+
} else {
|
1873
|
+
tableRows.splice(0, 0, newRow);
|
1874
|
+
}
|
1875
|
+
this.setValue(tableRows);
|
1876
|
+
this.$nextTick(() => {
|
1877
|
+
this.handleWbs();
|
1878
|
+
$grid.setTreeExpand(obj.row, true).then(() => {
|
1879
|
+
if (isEditTable) {
|
1880
|
+
$grid.setActiveRow(newRow);
|
1881
|
+
}
|
1882
|
+
});
|
1883
|
+
});
|
1884
|
+
});
|
1885
|
+
}
|
1886
|
+
},
|
1887
|
+
async removeEditRow(obj) {
|
1888
|
+
this.removeTreeRow(obj);
|
1889
|
+
},
|
1890
|
+
//editTable end
|
1891
|
+
getHttpConfigForUser() {
|
1892
|
+
let defaultOption = {
|
1893
|
+
addCreateInfo: true,
|
1894
|
+
queryCreateInfo: window.$vueRoot.$store.getters.queryCreateInfo || "0",
|
1895
|
+
};
|
1896
|
+
return defaultOption;
|
1897
|
+
},
|
1898
|
+
handleWbs() {
|
1899
|
+
if (this.widget.options.wbsEnabled) {
|
1900
|
+
this.updateWbs();
|
1901
|
+
}
|
1902
|
+
},
|
1903
|
+
updateWbs() {
|
1904
|
+
let that = this;
|
1905
|
+
let $grid = that.getGridTable();
|
1906
|
+
let childrenField = $grid.treeConfig.children;
|
1907
|
+
let fullData = $grid.getTableData().fullData;
|
1908
|
+
let tableRows = this.formModel[that.fieldKeyName] || [];
|
1909
|
+
let map = {};
|
1910
|
+
let loopDo = (item, wbs) => {
|
1911
|
+
item.f_wbs = wbs;
|
1912
|
+
map[item._X_ROW_KEY] = wbs;
|
1913
|
+
item[childrenField] &&
|
1914
|
+
item[childrenField].forEach((subitem, subindex) => {
|
1915
|
+
let sub_wbs = wbs + "." + (subindex + 1) + "";
|
1916
|
+
loopDo(subitem, sub_wbs);
|
1917
|
+
});
|
1918
|
+
};
|
1919
|
+
fullData.forEach((item, index) => {
|
1920
|
+
let wbs = index + 1 + "";
|
1921
|
+
loopDo(item, wbs);
|
1922
|
+
});
|
1923
|
+
$grid.updateData();
|
1924
|
+
},
|
1925
|
+
moveUpRow(obj) {
|
1926
|
+
let row = obj.row;
|
1927
|
+
let $grid = this.getGridTable();
|
1928
|
+
let tableRows = this.formModel[this.fieldKeyName] || [];
|
1929
|
+
let isTreeTable = this.widget.options.isTreeTable;
|
1930
|
+
if (isTreeTable) {
|
1931
|
+
let parentField = $grid.treeConfig.parentField;
|
1932
|
+
let rowField = $grid.treeConfig.rowField || "id";
|
1933
|
+
let paretValue = row[parentField];
|
1934
|
+
let siblingRows = tableRows.filter(
|
1935
|
+
(item) => item[parentField] === paretValue
|
1936
|
+
);
|
1937
|
+
if (siblingRows.length > 1) {
|
1938
|
+
let currentIndex = tableRows.findIndex(
|
1939
|
+
(item) => item[rowField] == row[rowField]
|
1940
|
+
);
|
1941
|
+
let index1 = siblingRows.findIndex(
|
1942
|
+
(item) => item[rowField] == row[rowField]
|
1943
|
+
);
|
1944
|
+
if (index1 > 0) {
|
1945
|
+
let prevRow = siblingRows[index1 - 1];
|
1946
|
+
let prevIndex = tableRows.findIndex(
|
1947
|
+
(item) => item[rowField] == prevRow[rowField]
|
1948
|
+
);
|
1949
|
+
tableRows.splice(currentIndex, 1);
|
1950
|
+
tableRows.splice(prevIndex, 0, row);
|
1951
|
+
this.setValue(tableRows);
|
1952
|
+
this.$nextTick(() => {
|
1953
|
+
this.handleWbs();
|
1954
|
+
});
|
1955
|
+
}
|
1956
|
+
}
|
1957
|
+
} else {
|
1958
|
+
let rowIndex = $grid.getRowIndex(row);
|
1959
|
+
if (rowIndex >= 0) {
|
1960
|
+
tableRows.splice(rowIndex, 1);
|
1961
|
+
tableRows.splice(rowIndex - 1, 0, row);
|
1962
|
+
this.setValue(tableRows);
|
1963
|
+
this.$nextTick(() => {
|
1964
|
+
this.handleWbs();
|
1965
|
+
});
|
1966
|
+
}
|
1967
|
+
}
|
1968
|
+
},
|
1969
|
+
moveDownRow(obj) {
|
1970
|
+
let row = obj.row;
|
1971
|
+
let $grid = this.getGridTable();
|
1972
|
+
let tableRows = this.formModel[this.fieldKeyName] || [];
|
1973
|
+
let isTreeTable = this.widget.options.isTreeTable;
|
1974
|
+
if (isTreeTable) {
|
1975
|
+
let parentField = $grid.treeConfig.parentField;
|
1976
|
+
let rowField = $grid.treeConfig.rowField || "id";
|
1977
|
+
let paretValue = row[parentField];
|
1978
|
+
let siblingRows = tableRows.filter(
|
1979
|
+
(item) => item[parentField] === paretValue
|
1980
|
+
);
|
1981
|
+
if (siblingRows.length > 1) {
|
1982
|
+
let currentIndex = tableRows.findIndex(
|
1983
|
+
(item) => item[rowField] == row[rowField]
|
1984
|
+
);
|
1985
|
+
let index1 = siblingRows.findIndex(
|
1986
|
+
(item) => item[rowField] == row[rowField]
|
1987
|
+
);
|
1988
|
+
if (index1 < siblingRows.length - 1) {
|
1989
|
+
let nextRow = siblingRows[index1 + 1];
|
1990
|
+
let nextIndex = tableRows.findIndex(
|
1991
|
+
(item) => item[rowField] == nextRow[rowField]
|
1992
|
+
);
|
1993
|
+
tableRows.splice(currentIndex, 1);
|
1994
|
+
tableRows.splice(nextIndex, 0, row);
|
1995
|
+
this.setValue(tableRows);
|
1996
|
+
this.$nextTick(() => {
|
1997
|
+
this.handleWbs();
|
1998
|
+
});
|
1999
|
+
}
|
2000
|
+
}
|
2001
|
+
} else {
|
2002
|
+
let rowIndex = $grid.getRowIndex(row);
|
2003
|
+
if (rowIndex < tableRows.length - 1) {
|
2004
|
+
tableRows.splice(rowIndex, 1);
|
2005
|
+
tableRows.splice(rowIndex + 1, 0, row);
|
2006
|
+
this.setValue(tableRows);
|
2007
|
+
this.$nextTick(() => {
|
2008
|
+
this.handleWbs();
|
2009
|
+
});
|
2010
|
+
}
|
2011
|
+
}
|
2012
|
+
},
|
2013
|
+
|
2014
|
+
openSortRowDialog(obj) {
|
2015
|
+
let $grid = this.getGridTable();
|
2016
|
+
let parentField = $grid.treeConfig.parentField;
|
2017
|
+
let rowField = $grid.treeConfig.rowField || "id";
|
2018
|
+
let row = obj.row;
|
2019
|
+
let tableRows = this.formModel[this.fieldKeyName] || [];
|
2020
|
+
|
2021
|
+
let sortParentRow = tableRows.find(
|
2022
|
+
(item) => item[rowField] === row[parentField]
|
2023
|
+
);
|
2024
|
+
let sortRows = tableRows.filter(
|
2025
|
+
(item) => item[parentField] === row[parentField]
|
2026
|
+
);
|
2027
|
+
this.sortRows = sortRows;
|
2028
|
+
this.sortParentRow = sortParentRow;
|
2029
|
+
this.showTreeMoveDialog = true;
|
2030
|
+
},
|
2031
|
+
confirmTreeMoveDialog(rows) {
|
2032
|
+
if (this.widget.options.isEditTable) {
|
2033
|
+
let reportTemplate = this.getFormRef().reportTemplate;
|
2034
|
+
let formConfig = this.formConfig;
|
2035
|
+
let entity = formConfig.entity;
|
2036
|
+
let reqData = {
|
2037
|
+
formCode: reportTemplate.formCode,
|
2038
|
+
formVersion: reportTemplate.formVersion,
|
2039
|
+
taBm: entity,
|
2040
|
+
data: rows,
|
2041
|
+
};
|
2042
|
+
let scriptCode = this.widget.options.sortScriptCode;
|
2043
|
+
this.formHttp({
|
2044
|
+
scriptCode: scriptCode,
|
2045
|
+
data: reqData,
|
2046
|
+
successMsg: true,
|
2047
|
+
isConfirm: true,
|
2048
|
+
confirmText: "您确定要保存排序吗?",
|
2049
|
+
success: (res) => {
|
2050
|
+
this.getGridTable().reloadTreeExpand(this.sortParentRow);
|
2051
|
+
},
|
2052
|
+
});
|
2053
|
+
} else {
|
2054
|
+
let $grid = this.getGridTable();
|
2055
|
+
let rowField = $grid.treeConfig.rowField || "id";
|
2056
|
+
let tableRows = this.formModel[this.fieldKeyName] || [];
|
2057
|
+
|
2058
|
+
let ids = rows.map((item) => item[rowField]);
|
2059
|
+
let index = tableRows.findIndex((item) => ids.includes(item[rowField]));
|
2060
|
+
let items = tableRows.filter((item) => !ids.includes(item[rowField]));
|
2061
|
+
rows.forEach((row, index1) => {
|
2062
|
+
items.splice(index + index1, 0, row);
|
2063
|
+
});
|
2064
|
+
this.setValue(items);
|
2065
|
+
this.$nextTick(() => {
|
2066
|
+
this.handleWbs();
|
2067
|
+
});
|
2068
|
+
}
|
2069
|
+
},
|
2070
|
+
// 通用行合并函数(将相同多列数据合并为一行)
|
2071
|
+
mergeRowMethod(tableParam) {
|
2072
|
+
let {row, _rowIndex, column, visibleData} = tableParam;
|
2073
|
+
let mergeRowEnabled = this.widget.options.mergeRowEnabled || false;
|
2074
|
+
let unikey = this.widget.options.mergeRowKey;
|
2075
|
+
const cellValue = row[unikey];
|
2076
|
+
let isItemLine = column.params?.isItemLine || false;
|
2077
|
+
if (mergeRowEnabled && unikey && !isItemLine) {
|
2078
|
+
const prevRow = visibleData[_rowIndex - 1];
|
2079
|
+
let nextRow = visibleData[_rowIndex + 1];
|
2080
|
+
if (prevRow && prevRow[unikey] === cellValue) {
|
2081
|
+
return {rowspan: 0, colspan: 0};
|
2082
|
+
} else {
|
2083
|
+
let countRowspan = 1;
|
2084
|
+
while (nextRow && nextRow[unikey] === cellValue) {
|
2085
|
+
nextRow = visibleData[++countRowspan + _rowIndex];
|
2086
|
+
}
|
2087
|
+
if (countRowspan > 1) {
|
2088
|
+
return {rowspan: countRowspan, colspan: 1};
|
2089
|
+
}
|
2090
|
+
}
|
2091
|
+
} else {
|
2092
|
+
// return { rowspan: 1, colspan: 1 }
|
2093
|
+
}
|
2094
|
+
},
|
2095
|
+
mergeRowMethod2({row, _rowIndex, column, visibleData}) {
|
2096
|
+
const fields = ["key"];
|
2097
|
+
const cellValue = row[column.field];
|
2098
|
+
if (cellValue && fields.includes(column.field)) {
|
2099
|
+
const prevRow = visibleData[_rowIndex - 1];
|
2100
|
+
let nextRow = visibleData[_rowIndex + 1];
|
2101
|
+
if (prevRow && prevRow[column.field] === cellValue) {
|
2102
|
+
return {rowspan: 0, colspan: 0};
|
2103
|
+
} else {
|
2104
|
+
let countRowspan = 1;
|
2105
|
+
while (nextRow && nextRow[column.field] === cellValue) {
|
2106
|
+
nextRow = visibleData[++countRowspan + _rowIndex];
|
2107
|
+
}
|
2108
|
+
if (countRowspan > 1) {
|
2109
|
+
return {rowspan: countRowspan, colspan: 1};
|
2110
|
+
}
|
2111
|
+
}
|
2112
|
+
}
|
2113
|
+
},
|
2114
|
+
|
2115
|
+
/**begin*/
|
2116
|
+
/*initFieldSchemaData() { //初始化fieldSchemaData!!!
|
2117
|
+
|
2118
|
+
let rowWidgetList = this.rowWidgetList
|
2119
|
+
let rows = this.getValue();
|
2120
|
+
let rowLength = rows.length
|
2121
|
+
this.widgetMap = {} //清除数组必须用splice,length=0不会响应式更新!!
|
2122
|
+
if (rowLength > 0) {
|
2123
|
+
for (let i = 0; i < rowLength; i++) {
|
2124
|
+
let row = rows[i];
|
2125
|
+
let fieldSchemas = []
|
2126
|
+
rowWidgetList.forEach(swItem => {
|
2127
|
+
fieldSchemas.push( this.cloneFieldSchema(swItem) )
|
2128
|
+
})
|
2129
|
+
let keyVal = row._X_ROW_KEY;
|
2130
|
+
this.widgetMap[keyVal] = fieldSchemas;
|
2131
|
+
}
|
2132
|
+
}
|
2133
|
+
},
|
2134
|
+
|
2135
|
+
addToFieldSchemaData(row) {
|
2136
|
+
let fieldSchemas = []
|
2137
|
+
this.rowWidgetList.forEach(swItem => {
|
2138
|
+
fieldSchemas.push( this.cloneFieldSchema(swItem) )
|
2139
|
+
})
|
2140
|
+
|
2141
|
+
let keyVal = row._X_ROW_KEY;
|
2142
|
+
this.widgetMap[keyVal] = fieldSchemas;
|
2143
|
+
},
|
2144
|
+
|
2145
|
+
deleteFromFieldSchemaData(row) {
|
2146
|
+
let keyVal = row._X_ROW_KEY;
|
2147
|
+
delete this.widgetMap[keyVal] ;
|
2148
|
+
},
|
2149
|
+
|
2150
|
+
cloneFieldSchema(fieldWidget) {
|
2151
|
+
let newFieldSchema = this.$baseLodash.cloneDeep(fieldWidget)
|
2152
|
+
newFieldSchema.id = fieldWidget.type + generateId()
|
2153
|
+
return newFieldSchema
|
2154
|
+
},*/
|
2155
|
+
clearRowWidgets() {
|
2156
|
+
// this.widgetMap = {};
|
2157
|
+
},
|
2158
|
+
deleteRowWidgets(row) {
|
2159
|
+
this.rowWidgetList.forEach(widget => {
|
2160
|
+
let key = this.getRowRefKey(row, widget.options.name);
|
2161
|
+
delete this.widgetMap[key];
|
2162
|
+
})
|
2163
|
+
}
|
2164
|
+
/**end*/
|
2165
|
+
|
2166
|
+
},
|
2167
|
+
};
|
2168
|
+
|
2169
|
+
export default modules;
|