cloud-web-corejs 1.0.54-dev.674 → 1.0.54-dev.676
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 +1 -1
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/data-table-editor.vue +164 -4
- package/src/components/xform/form-designer/setting-panel/property-editor/container-data-table/table-column-dialog.vue +15 -0
- package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +7 -0
- package/src/components/xform/form-render/container-item/data-table-item.vue +0 -9
- package/src/components/xform/form-render/container-item/data-table-mixin.js +503 -26
- package/src/components/xform/form-render/indexMixin.js +15 -9
- package/src/components/xform/mixins/scriptHttp.js +176 -5
- package/src/components/xform/utils/util.js +11 -0
- package/src/utils/vab.js +87 -107
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
deepClone,
|
|
14
14
|
loopHandleWidget,
|
|
15
15
|
columnFormatMap,
|
|
16
|
+
getColumnWidgetOptions,
|
|
16
17
|
traverseAllWidgetsNew,
|
|
17
18
|
} from "../../../../components/xform/utils/util";
|
|
18
19
|
import { applyColumnLabelIcon } from "../../../../components/xform/utils/tableColumnHelper";
|
|
@@ -120,6 +121,8 @@ modules = {
|
|
|
120
121
|
fieldSchemaMap: {},
|
|
121
122
|
fieldSchemaData: [],
|
|
122
123
|
eventConfig: {},
|
|
124
|
+
dynamicTableColumns: [],
|
|
125
|
+
dynamicColumnsPreloaded: false,
|
|
123
126
|
};
|
|
124
127
|
},
|
|
125
128
|
watch: {
|
|
@@ -171,6 +174,12 @@ modules = {
|
|
|
171
174
|
created: function () {
|
|
172
175
|
if (!this.formModel[this.fieldKeyName])
|
|
173
176
|
this.formModel[this.fieldKeyName] = [];
|
|
177
|
+
if (!this.widget.options.dynamicColumnMode) {
|
|
178
|
+
this.$set(this.widget.options, "dynamicColumnMode", "append");
|
|
179
|
+
}
|
|
180
|
+
if (this.widget.options.dynamicColumnScriptEnabled === undefined) {
|
|
181
|
+
this.$set(this.widget.options, "dynamicColumnScriptEnabled", false);
|
|
182
|
+
}
|
|
174
183
|
this.initRefList();
|
|
175
184
|
// this.initConfig();
|
|
176
185
|
this.initTableCustomEvent();
|
|
@@ -180,8 +189,10 @@ modules = {
|
|
|
180
189
|
},
|
|
181
190
|
mounted: async function () {
|
|
182
191
|
this.handleOnMounted();
|
|
183
|
-
this.
|
|
184
|
-
this.
|
|
192
|
+
this.bootstrapDynamicColumnsBeforeInit().then(() => {
|
|
193
|
+
this.initColumnWidgetConfig(() => {
|
|
194
|
+
this.initTableList();
|
|
195
|
+
});
|
|
185
196
|
});
|
|
186
197
|
},
|
|
187
198
|
beforeDestroy: function () {
|
|
@@ -218,27 +229,97 @@ modules = {
|
|
|
218
229
|
let widget = this.getTableColumnWidget(obj);
|
|
219
230
|
return widget ? this.getFieldKeyName(widget) : null;
|
|
220
231
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
collectColumnWidgetConfigRequests(tableColumns, options = {}) {
|
|
233
|
+
const { forceRefresh = false } = options;
|
|
234
|
+
const requests = [];
|
|
224
235
|
this.loodHandleColumns(tableColumns, (row) => {
|
|
236
|
+
if (forceRefresh) {
|
|
237
|
+
this.resetColumnWidgetSyncFlag(row.widget);
|
|
238
|
+
this.resetColumnWidgetSyncFlag(row.editWidget);
|
|
239
|
+
}
|
|
225
240
|
requests.push(this.handleColumnWidgetConfig(row.widget));
|
|
226
241
|
requests.push(this.handleColumnWidgetConfig(row.editWidget));
|
|
227
242
|
let widgetList = row.widgetList;
|
|
228
243
|
if (widgetList && widgetList.length) {
|
|
229
244
|
traverseAllWidgetsNew(widgetList, (widget) => {
|
|
245
|
+
if (forceRefresh) {
|
|
246
|
+
this.resetColumnWidgetSyncFlag(widget);
|
|
247
|
+
}
|
|
230
248
|
requests.push(this.handleColumnWidgetConfig(widget));
|
|
231
249
|
});
|
|
232
250
|
}
|
|
233
251
|
});
|
|
252
|
+
return requests.filter(Boolean);
|
|
253
|
+
},
|
|
254
|
+
resetColumnWidgetSyncFlag(widget) {
|
|
255
|
+
if (widget) {
|
|
256
|
+
widget._syncInited = false;
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
syncColumnWidgetFieldKey(columnRow, widget) {
|
|
260
|
+
if (!widget || !columnRow?.prop) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const prop = columnRow.prop;
|
|
264
|
+
if (Object.prototype.hasOwnProperty.call(widget.options, "keyName")) {
|
|
265
|
+
widget.options.keyName = prop;
|
|
266
|
+
widget.options.keyNameEnabled = true;
|
|
267
|
+
} else {
|
|
268
|
+
widget.options.name = prop;
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
syncEffectiveColumnWidgetFieldKeys(tableColumns) {
|
|
272
|
+
this.loodHandleColumns(tableColumns, (row) => {
|
|
273
|
+
this.syncColumnWidgetFieldKey(row, row.widget);
|
|
274
|
+
this.syncColumnWidgetFieldKey(row, row.editWidget);
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
initColumnWidgetConfig(callback, options = {}) {
|
|
278
|
+
const tableColumns =
|
|
279
|
+
options.columns ?? this.getEffectiveTableColumns();
|
|
280
|
+
const requests = this.collectColumnWidgetConfigRequests(
|
|
281
|
+
tableColumns,
|
|
282
|
+
options
|
|
283
|
+
);
|
|
234
284
|
if (requests.length) {
|
|
235
285
|
Promise.all(requests).then(() => {
|
|
236
|
-
callback();
|
|
286
|
+
callback && callback();
|
|
237
287
|
});
|
|
238
288
|
} else {
|
|
239
|
-
callback();
|
|
289
|
+
callback && callback();
|
|
240
290
|
}
|
|
241
291
|
},
|
|
292
|
+
refreshColumnWidgetConfig(options = {}) {
|
|
293
|
+
const tableColumns =
|
|
294
|
+
options.columns ?? this.getEffectiveTableColumns();
|
|
295
|
+
const forceRefresh = options.forceRefresh !== false;
|
|
296
|
+
return new Promise((resolve, reject) => {
|
|
297
|
+
const requests = this.collectColumnWidgetConfigRequests(tableColumns, {
|
|
298
|
+
forceRefresh,
|
|
299
|
+
});
|
|
300
|
+
const finish = () => {
|
|
301
|
+
this.initFieldSchemaData(true);
|
|
302
|
+
const $grid = this.getGridTable();
|
|
303
|
+
if ($grid?.refreshColumn) {
|
|
304
|
+
$grid.refreshColumn();
|
|
305
|
+
}
|
|
306
|
+
options.success && options.success();
|
|
307
|
+
resolve();
|
|
308
|
+
};
|
|
309
|
+
if (requests.length) {
|
|
310
|
+
Promise.all(requests).then(finish).catch((err) => {
|
|
311
|
+
options.fail && options.fail(err);
|
|
312
|
+
options.error && options.error(err);
|
|
313
|
+
reject(err);
|
|
314
|
+
});
|
|
315
|
+
} else {
|
|
316
|
+
finish();
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
reloadColumnWidgetOptions(options) {
|
|
321
|
+
return this.refreshColumnWidgetConfig(options);
|
|
322
|
+
},
|
|
242
323
|
fillColumnWidgetOptionItems(widget, rows) {
|
|
243
324
|
let widgetType = widget.type;
|
|
244
325
|
let formScriptEnabledTypes = ["select", "checkbox", "radio"];
|
|
@@ -309,19 +390,21 @@ modules = {
|
|
|
309
390
|
let formRef = this.getFormRef();
|
|
310
391
|
this.widget.options.tableColumns.forEach((row) => {
|
|
311
392
|
let type = columnFormatMap[row.formatS];
|
|
312
|
-
|
|
393
|
+
let widgetOptions = getColumnWidgetOptions(row);
|
|
394
|
+
if (type && widgetOptions && !row.widget) {
|
|
313
395
|
let fieldWidget = formRef.copyNewFieldWidget(
|
|
314
396
|
formRef.getFieldWidgetByType(type)
|
|
315
397
|
);
|
|
316
|
-
fieldWidget.options =
|
|
398
|
+
fieldWidget.options = widgetOptions;
|
|
317
399
|
row.widget = fieldWidget;
|
|
318
400
|
}
|
|
319
401
|
let type2 = columnFormatMap[row.editFormatS];
|
|
320
|
-
|
|
402
|
+
let editWidgetOptions = getColumnWidgetOptions(row, true);
|
|
403
|
+
if (type2 && editWidgetOptions && !row.editWidget) {
|
|
321
404
|
let fieldWidget = formRef.copyNewFieldWidget(
|
|
322
405
|
formRef.getFieldWidgetByType(type2)
|
|
323
406
|
);
|
|
324
|
-
fieldWidget.options =
|
|
407
|
+
fieldWidget.options = editWidgetOptions;
|
|
325
408
|
row.editWidget = fieldWidget;
|
|
326
409
|
}
|
|
327
410
|
});
|
|
@@ -609,15 +692,403 @@ modules = {
|
|
|
609
692
|
getRowIndex: function (e) {
|
|
610
693
|
return this.widget.options.tableData.lastIndexOf(e);
|
|
611
694
|
},
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
695
|
+
getTableColumns() {
|
|
696
|
+
return this.widget.options.tableColumns || [];
|
|
697
|
+
},
|
|
698
|
+
getDynamicTableColumnsFromScript() {
|
|
699
|
+
const script = this.widget.options.dynamicColumnsScript;
|
|
700
|
+
if (!script) {
|
|
701
|
+
return undefined;
|
|
702
|
+
}
|
|
703
|
+
const result = this.handleCustomEvent(script);
|
|
704
|
+
if (result === null || result === undefined) {
|
|
705
|
+
return undefined;
|
|
706
|
+
}
|
|
707
|
+
return this.normalizeDynamicColumnResult(result);
|
|
708
|
+
},
|
|
709
|
+
normalizeDynamicColumnResult(result) {
|
|
710
|
+
if (result === null || result === undefined) {
|
|
711
|
+
return result;
|
|
712
|
+
}
|
|
713
|
+
if (Array.isArray(result)) {
|
|
714
|
+
return this.normalizeDynamicColumns(result);
|
|
715
|
+
}
|
|
716
|
+
if (typeof result !== "object") {
|
|
717
|
+
return result;
|
|
718
|
+
}
|
|
719
|
+
const normalized = { ...result };
|
|
720
|
+
if (Array.isArray(result.columns)) {
|
|
721
|
+
normalized.columns = this.normalizeDynamicColumns(result.columns);
|
|
722
|
+
}
|
|
723
|
+
if (Array.isArray(result.tableColumns)) {
|
|
724
|
+
normalized.tableColumns = this.normalizeDynamicColumns(
|
|
725
|
+
result.tableColumns
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
return normalized;
|
|
729
|
+
},
|
|
730
|
+
mergeDynamicTableColumns(staticColumns, dynamicResult) {
|
|
731
|
+
const staticCols = staticColumns || [];
|
|
732
|
+
if (dynamicResult === undefined || dynamicResult === null) {
|
|
733
|
+
return staticCols;
|
|
734
|
+
}
|
|
735
|
+
if (Array.isArray(dynamicResult)) {
|
|
736
|
+
if (this.widget.options.dynamicColumnMode === "replace") {
|
|
737
|
+
return dynamicResult;
|
|
738
|
+
}
|
|
739
|
+
return staticCols.concat(dynamicResult);
|
|
740
|
+
}
|
|
741
|
+
if (dynamicResult.replace) {
|
|
742
|
+
return dynamicResult.columns || [];
|
|
743
|
+
}
|
|
744
|
+
if (dynamicResult.columns) {
|
|
745
|
+
return staticCols.concat(dynamicResult.columns);
|
|
746
|
+
}
|
|
747
|
+
return staticCols;
|
|
748
|
+
},
|
|
749
|
+
getEffectiveTableColumns() {
|
|
750
|
+
const staticColumns = this.widget.options.tableColumns || [];
|
|
751
|
+
const runtimeDynamic = this.dynamicTableColumns || [];
|
|
752
|
+
const scriptDynamic = this.getDynamicTableColumnsFromScript();
|
|
753
|
+
if (scriptDynamic !== undefined) {
|
|
754
|
+
return this.mergeDynamicTableColumns(staticColumns, scriptDynamic);
|
|
755
|
+
}
|
|
756
|
+
if (runtimeDynamic.length) {
|
|
757
|
+
if (this.widget.options.dynamicColumnMode === "replace") {
|
|
758
|
+
return runtimeDynamic;
|
|
759
|
+
}
|
|
760
|
+
return staticColumns.concat(runtimeDynamic);
|
|
761
|
+
}
|
|
762
|
+
return staticColumns;
|
|
763
|
+
},
|
|
764
|
+
attachTableColumnWidgets(tableColumns) {
|
|
765
|
+
if (!Array.isArray(tableColumns) || !tableColumns.length) {
|
|
766
|
+
return tableColumns;
|
|
767
|
+
}
|
|
768
|
+
this.loodHandleColumns(tableColumns, (row) => {
|
|
769
|
+
if (row.formatS && columnFormatMap[row.formatS] && !row.editFormatS) {
|
|
770
|
+
row.editFormatS = row.formatS;
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
const formRef = this.getFormRef();
|
|
774
|
+
if (!formRef?.handleTableColumnWidget) {
|
|
775
|
+
return tableColumns;
|
|
776
|
+
}
|
|
777
|
+
const savedColumns = this.widget.options.tableColumns;
|
|
778
|
+
this.widget.options.tableColumns = tableColumns;
|
|
779
|
+
formRef.handleTableColumnWidget(this.widget);
|
|
780
|
+
this.widget.options.tableColumns = savedColumns;
|
|
781
|
+
return tableColumns;
|
|
782
|
+
},
|
|
783
|
+
ensureEffectiveColumnWidgets() {
|
|
784
|
+
const effectiveColumns = this.getEffectiveTableColumns();
|
|
785
|
+
this.attachTableColumnWidgets(effectiveColumns);
|
|
786
|
+
this.syncEffectiveColumnWidgetFieldKeys(effectiveColumns);
|
|
787
|
+
},
|
|
788
|
+
getColumnVisible(columnConfig) {
|
|
789
|
+
if (columnConfig.show === false) {
|
|
790
|
+
return false;
|
|
791
|
+
}
|
|
792
|
+
if (columnConfig.columnShow) {
|
|
793
|
+
const result = this.handleCustomEvent(
|
|
794
|
+
columnConfig.columnShow,
|
|
795
|
+
["columnConfig"],
|
|
796
|
+
[columnConfig]
|
|
797
|
+
);
|
|
798
|
+
return result !== false && result !== null;
|
|
799
|
+
}
|
|
800
|
+
return true;
|
|
801
|
+
},
|
|
802
|
+
applyTableColumnsReload() {
|
|
803
|
+
this.ensureEffectiveColumnWidgets();
|
|
804
|
+
const effectiveColumns = this.getEffectiveTableColumns();
|
|
805
|
+
return new Promise((resolve) => {
|
|
806
|
+
this.initColumnWidgetConfig(() => {
|
|
807
|
+
const columns = this.createColumns();
|
|
808
|
+
this.widgets = columns
|
|
809
|
+
.filter((column) => !!column?.params?.widget)
|
|
810
|
+
.map((column) => column.params.widget);
|
|
811
|
+
this.editWidgets = columns
|
|
812
|
+
.filter((column) => !!column?.params?.editWidget)
|
|
813
|
+
.map((column) => column.params.editWidget);
|
|
814
|
+
if (this.vxeOption) {
|
|
815
|
+
this.$set(this.vxeOption, "columns", columns);
|
|
816
|
+
}
|
|
817
|
+
const $grid = this.getGridTable();
|
|
818
|
+
if ($grid?.reloadColumn) {
|
|
819
|
+
const reloadResult = $grid.reloadColumn(columns);
|
|
820
|
+
const finish = () => {
|
|
821
|
+
this.initFieldSchemaData(true);
|
|
822
|
+
resolve(columns);
|
|
823
|
+
};
|
|
824
|
+
if (reloadResult?.then) {
|
|
825
|
+
reloadResult.then(finish).catch(finish);
|
|
826
|
+
} else {
|
|
827
|
+
finish();
|
|
828
|
+
}
|
|
829
|
+
} else {
|
|
830
|
+
resolve(columns);
|
|
831
|
+
}
|
|
832
|
+
}, { columns: effectiveColumns, forceRefresh: true });
|
|
833
|
+
});
|
|
834
|
+
},
|
|
835
|
+
reloadTableColumns(tableColumns) {
|
|
836
|
+
if (Array.isArray(tableColumns)) {
|
|
837
|
+
this.dynamicTableColumns = [];
|
|
838
|
+
this.widget.options.tableColumns = tableColumns;
|
|
839
|
+
}
|
|
840
|
+
return this.applyTableColumnsReload();
|
|
841
|
+
},
|
|
842
|
+
setTableColumns(tableColumns) {
|
|
843
|
+
return this.reloadTableColumns(tableColumns);
|
|
844
|
+
},
|
|
845
|
+
setTableColumn(tableColumns) {
|
|
846
|
+
return this.setTableColumns(tableColumns);
|
|
847
|
+
},
|
|
848
|
+
setDynamicTableColumns(tableColumns, options = {}) {
|
|
849
|
+
const { mode, deferReload } = options;
|
|
850
|
+
return this.assignDynamicTableColumns(tableColumns, { mode }).then(
|
|
851
|
+
(columns) => {
|
|
852
|
+
const shouldDeferReload =
|
|
853
|
+
deferReload === true ||
|
|
854
|
+
(deferReload !== false && !this.isTableColumnGridInitialized());
|
|
855
|
+
if (shouldDeferReload) {
|
|
856
|
+
return columns;
|
|
857
|
+
}
|
|
858
|
+
return this.applyTableColumnsReload().then(() => columns);
|
|
859
|
+
}
|
|
860
|
+
);
|
|
861
|
+
},
|
|
862
|
+
refreshTableColumns() {
|
|
863
|
+
return this.applyTableColumnsReload();
|
|
864
|
+
},
|
|
865
|
+
refreshColumnVisible() {
|
|
866
|
+
return this.refreshTableColumns();
|
|
867
|
+
},
|
|
868
|
+
normalizeDynamicColumnItem(item, index) {
|
|
869
|
+
if (!item || typeof item !== "object") {
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
const prop =
|
|
873
|
+
item.prop ?? item.field ?? item.name ?? item.key ?? undefined;
|
|
874
|
+
const label = item.label ?? item.title ?? undefined;
|
|
875
|
+
let formatS = item.formatS || item.format || null;
|
|
876
|
+
let editFormatS = item.editFormatS || null;
|
|
877
|
+
const widgetOptions = item.widgetOptions;
|
|
878
|
+
const editWidgetOptions = item.editWidgetOptions;
|
|
879
|
+
|
|
880
|
+
const normalized = {
|
|
881
|
+
...item,
|
|
882
|
+
columnId: item.columnId || `${Date.now()}_${index}`,
|
|
883
|
+
prop,
|
|
884
|
+
label,
|
|
885
|
+
width: item.width ?? 150,
|
|
886
|
+
show: item.show !== false,
|
|
887
|
+
sortable: item.sortable !== false,
|
|
888
|
+
filterable: item.filterable !== false,
|
|
889
|
+
align: item.align || "left",
|
|
890
|
+
formatS,
|
|
891
|
+
editFormatS: editFormatS || undefined,
|
|
892
|
+
widgetOptions,
|
|
893
|
+
editWidgetOptions: editWidgetOptions || undefined,
|
|
894
|
+
};
|
|
895
|
+
delete normalized.columnOption;
|
|
896
|
+
delete normalized.editColumnOption;
|
|
897
|
+
return normalized;
|
|
898
|
+
},
|
|
899
|
+
normalizeDynamicColumns(columns) {
|
|
900
|
+
if (!Array.isArray(columns)) {
|
|
901
|
+
return [];
|
|
902
|
+
}
|
|
903
|
+
return columns
|
|
904
|
+
.map((item, index) => this.normalizeDynamicColumnItem(item, index))
|
|
905
|
+
.filter(Boolean);
|
|
906
|
+
},
|
|
907
|
+
buildDynamicColumnRequestData(options = {}) {
|
|
908
|
+
if (options.data !== undefined) {
|
|
909
|
+
return options.data;
|
|
910
|
+
}
|
|
911
|
+
const paramScript = this.widget.options.dynamicColumnScriptParam;
|
|
912
|
+
let customParam = {};
|
|
913
|
+
if (paramScript) {
|
|
914
|
+
customParam =
|
|
915
|
+
(this.handleCustomParam &&
|
|
916
|
+
this.handleCustomParam(paramScript)) ||
|
|
917
|
+
this.handleCustomEvent(paramScript) ||
|
|
918
|
+
{};
|
|
919
|
+
}
|
|
920
|
+
const formRef = this.getFormRef();
|
|
921
|
+
const reportTemplate = formRef.reportTemplate || {};
|
|
922
|
+
return {
|
|
923
|
+
formCode: reportTemplate.formCode,
|
|
924
|
+
formVersion: reportTemplate.formVersion,
|
|
925
|
+
taBm: this.fieldKeyName,
|
|
926
|
+
data: {
|
|
927
|
+
dataId: this.formDataId,
|
|
928
|
+
formData: this.globalModel?.formModel || {},
|
|
929
|
+
...customParam,
|
|
930
|
+
},
|
|
931
|
+
};
|
|
932
|
+
},
|
|
933
|
+
convertDynamicColumnResponse(res, options = {}) {
|
|
934
|
+
const convertScript =
|
|
935
|
+
options.convertScript ?? this.widget.options.onDynamicColumnsConvert;
|
|
936
|
+
if (convertScript) {
|
|
937
|
+
const result = this.handleCustomEvent(convertScript, ["res"], [res]);
|
|
938
|
+
if (Array.isArray(result)) {
|
|
939
|
+
return this.normalizeDynamicColumns(result);
|
|
940
|
+
}
|
|
941
|
+
if (result?.columns) {
|
|
942
|
+
return this.normalizeDynamicColumns(result.columns);
|
|
943
|
+
}
|
|
944
|
+
return [];
|
|
945
|
+
}
|
|
946
|
+
const objx = res?.objx;
|
|
947
|
+
if (Array.isArray(objx)) {
|
|
948
|
+
return this.normalizeDynamicColumns(objx);
|
|
949
|
+
}
|
|
950
|
+
if (objx?.columns && Array.isArray(objx.columns)) {
|
|
951
|
+
return this.normalizeDynamicColumns(objx.columns);
|
|
952
|
+
}
|
|
953
|
+
if (objx?.tableColumns && Array.isArray(objx.tableColumns)) {
|
|
954
|
+
return this.normalizeDynamicColumns(objx.tableColumns);
|
|
955
|
+
}
|
|
956
|
+
return [];
|
|
957
|
+
},
|
|
958
|
+
loadDynamicColumnsFromApi(options = {}) {
|
|
959
|
+
const isLoading = options.isLoading ?? true;
|
|
960
|
+
const mode = options.mode ?? this.widget.options.dynamicColumnMode;
|
|
961
|
+
return this.requestDynamicColumnsFromApi({
|
|
962
|
+
...options,
|
|
963
|
+
isLoading,
|
|
964
|
+
}).then(({ res, columns }) => {
|
|
965
|
+
return this.setDynamicTableColumns(columns, {
|
|
966
|
+
mode,
|
|
967
|
+
deferReload: options.deferReload,
|
|
968
|
+
}).then((resultColumns) => {
|
|
969
|
+
options.success && options.success(res, resultColumns);
|
|
970
|
+
return resultColumns;
|
|
617
971
|
});
|
|
972
|
+
});
|
|
973
|
+
},
|
|
974
|
+
loadDynamicColumns(options) {
|
|
975
|
+
return this.loadDynamicColumnsFromApi(options);
|
|
976
|
+
},
|
|
977
|
+
fetchDynamicColumns(options) {
|
|
978
|
+
return this.loadDynamicColumnsFromApi(options);
|
|
979
|
+
},
|
|
980
|
+
resolveShouldAutoLoadDynamicColumns() {
|
|
981
|
+
const options = this.widget.options;
|
|
982
|
+
if (!options.dynamicColumnScriptEnabled || !options.dynamicColumnScriptCode) {
|
|
983
|
+
return Promise.resolve(false);
|
|
984
|
+
}
|
|
985
|
+
const script = options.dynamicColumnAutoLoadScript;
|
|
986
|
+
if (!script) {
|
|
987
|
+
return Promise.resolve(true);
|
|
988
|
+
}
|
|
989
|
+
const formRef = this.getFormRef();
|
|
990
|
+
if (!formRef || formRef.designState) {
|
|
991
|
+
return Promise.resolve(false);
|
|
992
|
+
}
|
|
993
|
+
return new Promise((resolve) => {
|
|
994
|
+
let settled = false;
|
|
995
|
+
const finishLoad = () => {
|
|
996
|
+
if (settled) {
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
settled = true;
|
|
1000
|
+
resolve(true);
|
|
1001
|
+
};
|
|
1002
|
+
const finishSkip = () => {
|
|
1003
|
+
if (settled) {
|
|
1004
|
+
return;
|
|
1005
|
+
}
|
|
1006
|
+
settled = true;
|
|
1007
|
+
resolve(false);
|
|
1008
|
+
};
|
|
1009
|
+
const done = finishLoad;
|
|
1010
|
+
try {
|
|
1011
|
+
const result = formRef.handleCustomEvent(script, ["done"], [done]);
|
|
1012
|
+
if (settled) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
if (result === null || result === false) {
|
|
1016
|
+
if (result === null) {
|
|
1017
|
+
finishSkip();
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
// return false:异步 defer 等待 done();未调用则视为跳过
|
|
1021
|
+
setTimeout(() => {
|
|
1022
|
+
if (!settled) {
|
|
1023
|
+
finishSkip();
|
|
1024
|
+
}
|
|
1025
|
+
}, 0);
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
finishLoad();
|
|
1029
|
+
} catch (e) {
|
|
1030
|
+
finishSkip();
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
},
|
|
1034
|
+
isTableColumnGridInitialized() {
|
|
1035
|
+
return !!this.vxeOption;
|
|
1036
|
+
},
|
|
1037
|
+
assignDynamicTableColumns(tableColumns, options = {}) {
|
|
1038
|
+
const { mode } = options;
|
|
1039
|
+
if (mode) {
|
|
1040
|
+
this.widget.options.dynamicColumnMode = mode;
|
|
1041
|
+
}
|
|
1042
|
+
this.dynamicTableColumns = Array.isArray(tableColumns)
|
|
1043
|
+
? tableColumns
|
|
1044
|
+
: [];
|
|
1045
|
+
this.ensureEffectiveColumnWidgets();
|
|
1046
|
+
return Promise.resolve(this.dynamicTableColumns);
|
|
1047
|
+
},
|
|
1048
|
+
requestDynamicColumnsFromApi(options = {}) {
|
|
1049
|
+
const scriptCode =
|
|
1050
|
+
options.scriptCode ?? this.widget.options.dynamicColumnScriptCode;
|
|
1051
|
+
if (!scriptCode) {
|
|
1052
|
+
return Promise.reject(new Error("dynamicColumnScriptCode is required"));
|
|
1053
|
+
}
|
|
1054
|
+
const data = this.buildDynamicColumnRequestData(options);
|
|
1055
|
+
const isLoading = options.isLoading ?? true;
|
|
1056
|
+
return this.formHttp({
|
|
1057
|
+
scriptCode,
|
|
1058
|
+
data,
|
|
1059
|
+
isLoading,
|
|
1060
|
+
fail: options.fail,
|
|
1061
|
+
error: options.error,
|
|
1062
|
+
}).then((res) => {
|
|
1063
|
+
const columns = this.convertDynamicColumnResponse(res, options);
|
|
1064
|
+
options.onFetchSuccess && options.onFetchSuccess(res, columns);
|
|
1065
|
+
return { res, columns };
|
|
1066
|
+
});
|
|
1067
|
+
},
|
|
1068
|
+
bootstrapDynamicColumnsBeforeInit() {
|
|
1069
|
+
return this.resolveShouldAutoLoadDynamicColumns().then((shouldLoad) => {
|
|
1070
|
+
if (!shouldLoad) {
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1073
|
+
this.dynamicColumnsPreloaded = true;
|
|
1074
|
+
const mode = this.widget.options.dynamicColumnMode;
|
|
1075
|
+
return this.requestDynamicColumnsFromApi({ isLoading: true })
|
|
1076
|
+
.then(({ columns }) => this.assignDynamicTableColumns(columns, { mode }))
|
|
1077
|
+
.catch(() => {
|
|
1078
|
+
this.dynamicColumnsPreloaded = false;
|
|
1079
|
+
});
|
|
1080
|
+
});
|
|
618
1081
|
},
|
|
619
|
-
|
|
620
|
-
this.
|
|
1082
|
+
tryAutoLoadDynamicColumns() {
|
|
1083
|
+
if (this.dynamicColumnsPreloaded) {
|
|
1084
|
+
return Promise.resolve();
|
|
1085
|
+
}
|
|
1086
|
+
return this.resolveShouldAutoLoadDynamicColumns().then((shouldLoad) => {
|
|
1087
|
+
if (!shouldLoad) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
return this.loadDynamicColumnsFromApi({ isLoading: true }).catch(() => {});
|
|
1091
|
+
});
|
|
621
1092
|
},
|
|
622
1093
|
getTableData: function () {
|
|
623
1094
|
return this.widget.options.tableData;
|
|
@@ -709,7 +1180,9 @@ modules = {
|
|
|
709
1180
|
},
|
|
710
1181
|
createColumns() {
|
|
711
1182
|
let rowWidgetList = [];
|
|
712
|
-
let tableColumns = this.
|
|
1183
|
+
let tableColumns = this.attachTableColumnWidgets(
|
|
1184
|
+
this.getEffectiveTableColumns()
|
|
1185
|
+
);
|
|
713
1186
|
let newColumns = [];
|
|
714
1187
|
if (!this.widget.options.hideGridCheckBox) {
|
|
715
1188
|
newColumns.push({
|
|
@@ -748,7 +1221,7 @@ modules = {
|
|
|
748
1221
|
: false,
|
|
749
1222
|
columnConfig: t,
|
|
750
1223
|
},
|
|
751
|
-
visible: t
|
|
1224
|
+
visible: this.getColumnVisible(t),
|
|
752
1225
|
slots: {},
|
|
753
1226
|
};
|
|
754
1227
|
applyColumnLabelIcon(col, t);
|
|
@@ -1114,6 +1587,7 @@ modules = {
|
|
|
1114
1587
|
let dataTableConfig = formRef.$attrs.dataTableOption || {};
|
|
1115
1588
|
this.dataTableConfig = dataTableConfig;
|
|
1116
1589
|
|
|
1590
|
+
this.ensureEffectiveColumnWidgets();
|
|
1117
1591
|
let columns = this.createColumns();
|
|
1118
1592
|
this.widgets = columns
|
|
1119
1593
|
.filter((column) => !!column?.params?.widget)
|
|
@@ -1717,11 +2191,13 @@ modules = {
|
|
|
1717
2191
|
}
|
|
1718
2192
|
this.$vxeTableUtil.initVxeTable(tableOption).then((opts) => {
|
|
1719
2193
|
this.vxeOption = opts;
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
2194
|
+
this.tryAutoLoadDynamicColumns().finally(() => {
|
|
2195
|
+
if (!isQueryTable) {
|
|
2196
|
+
setTimeout(() => {
|
|
2197
|
+
this.loadAccessData(1);
|
|
2198
|
+
}, 20);
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
1725
2201
|
});
|
|
1726
2202
|
},
|
|
1727
2203
|
loodHandleColumns(columns, callback) {
|
|
@@ -1826,7 +2302,8 @@ modules = {
|
|
|
1826
2302
|
let result = vailColumns
|
|
1827
2303
|
.filter((item) => {
|
|
1828
2304
|
return (
|
|
1829
|
-
item.formatS === "editSearch" &&
|
|
2305
|
+
item.formatS === "editSearch" &&
|
|
2306
|
+
getColumnWidgetOptions(item)?.multipleChoices
|
|
1830
2307
|
);
|
|
1831
2308
|
})
|
|
1832
2309
|
.map((item) => item.prop); */
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
loopHandleWidget,
|
|
23
23
|
traverseAllWidgetsNew,
|
|
24
24
|
columnFormatMap,
|
|
25
|
+
getColumnWidgetOptions,
|
|
25
26
|
} from "../../../components/xform/utils/util";
|
|
26
27
|
import {
|
|
27
28
|
containers,
|
|
@@ -995,8 +996,9 @@ modules = {
|
|
|
995
996
|
loopDo(item);
|
|
996
997
|
});
|
|
997
998
|
} else {
|
|
998
|
-
|
|
999
|
-
|
|
999
|
+
const opts = getColumnWidgetOptions(t);
|
|
1000
|
+
if (opts) {
|
|
1001
|
+
toDo2(null, opts);
|
|
1000
1002
|
}
|
|
1001
1003
|
}
|
|
1002
1004
|
};
|
|
@@ -1121,8 +1123,9 @@ modules = {
|
|
|
1121
1123
|
loopDo(item);
|
|
1122
1124
|
});
|
|
1123
1125
|
} else {
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
+
const opts = getColumnWidgetOptions(t);
|
|
1127
|
+
if (opts) {
|
|
1128
|
+
handleWfConfigData(null, opts);
|
|
1126
1129
|
}
|
|
1127
1130
|
}
|
|
1128
1131
|
};
|
|
@@ -2207,7 +2210,8 @@ modules = {
|
|
|
2207
2210
|
fieldDesc: item.label + "ID",
|
|
2208
2211
|
fieldName: item.prop,
|
|
2209
2212
|
});
|
|
2210
|
-
let vabSearchName =
|
|
2213
|
+
let vabSearchName =
|
|
2214
|
+
getColumnWidgetOptions(item)?.vabSearchName;
|
|
2211
2215
|
if (vabSearchName) {
|
|
2212
2216
|
itemFields.push({
|
|
2213
2217
|
fieldDesc: item.label,
|
|
@@ -2707,22 +2711,24 @@ modules = {
|
|
|
2707
2711
|
if (row.editWidget) {
|
|
2708
2712
|
return row.editWidget;
|
|
2709
2713
|
}
|
|
2710
|
-
|
|
2714
|
+
const editWidgetOptions = getColumnWidgetOptions(row, true);
|
|
2715
|
+
if (editWidgetOptions) {
|
|
2711
2716
|
let fieldWidget = this.copyNewFieldWidget(
|
|
2712
2717
|
this.getFieldWidgetByType(type)
|
|
2713
2718
|
);
|
|
2714
|
-
fieldWidget.options =
|
|
2719
|
+
fieldWidget.options = editWidgetOptions;
|
|
2715
2720
|
return fieldWidget;
|
|
2716
2721
|
}
|
|
2717
2722
|
} else {
|
|
2718
2723
|
if (row.widget) {
|
|
2719
2724
|
return row.widget;
|
|
2720
2725
|
}
|
|
2721
|
-
|
|
2726
|
+
const widgetOptions = getColumnWidgetOptions(row);
|
|
2727
|
+
if (widgetOptions) {
|
|
2722
2728
|
let fieldWidget = this.copyNewFieldWidget(
|
|
2723
2729
|
this.getFieldWidgetByType(type)
|
|
2724
2730
|
);
|
|
2725
|
-
fieldWidget.options =
|
|
2731
|
+
fieldWidget.options = widgetOptions;
|
|
2726
2732
|
return fieldWidget;
|
|
2727
2733
|
}
|
|
2728
2734
|
}
|