@gct-paas/word 0.2.10 → 0.2.11
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/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @gct-paas/word v0.2.
|
|
1
|
+
/*! @gct-paas/word v0.2.11 */
|
|
2
2
|
import { Fragment, Suspense, Teleport, Transition, TransitionGroup, cloneVNode, computed, createApp, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, getCurrentInstance, getCurrentScope, guardReactiveProps, h, inject, isRef, isVNode, markRaw, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeMount, onBeforeUnmount, onMounted, onScopeDispose, onUnmounted, openBlock, provide, reactive, readonly, ref, render, renderList, renderSlot, resolveComponent, resolveDynamicComponent, shallowRef, toDisplayString, toHandlers, toRaw, toRef, toValue, unref, useAttrs, useCssVars, useModel, useSlots, vModelRadio, vModelText, vShow, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
|
|
3
3
|
import Rt, { PopperWrapper } from "floating-vue";
|
|
4
4
|
import VueKonva from "vue-konva";
|
|
@@ -99735,6 +99735,7 @@ async function fetchAutofillSource(field, context) {
|
|
|
99735
99735
|
}
|
|
99736
99736
|
/** 默认值-数据填充 */
|
|
99737
99737
|
async function loadDefaultValueByAutofillRules(instances, autofillRules, field, context, autofillEnabled, rawData) {
|
|
99738
|
+
if (field.belongingObject && field.fieldType === FIELD_TYPE.PRODUCT && !field.subFieldKey && !field.isLinkedModelField) return {};
|
|
99738
99739
|
if (!resolveAutofillEnabled({
|
|
99739
99740
|
autofillEnabled,
|
|
99740
99741
|
autofillRules
|
|
@@ -137042,6 +137043,66 @@ var init_date_object = __esmMin((() => {
|
|
|
137042
137043
|
init_date_object_context();
|
|
137043
137044
|
}));
|
|
137044
137045
|
//#endregion
|
|
137046
|
+
//#region src/runtime/canvas/table/render/material-consume/object-product-autofill.ts
|
|
137047
|
+
init_useWidgetInitializer();
|
|
137048
|
+
init_useDependency();
|
|
137049
|
+
init_date_object();
|
|
137050
|
+
init_field_type();
|
|
137051
|
+
init_computed();
|
|
137052
|
+
init_autofill_runtime();
|
|
137053
|
+
init_types$7();
|
|
137054
|
+
init_core$1();
|
|
137055
|
+
/** 首次填报初始化:准备实际生效的对象物料默认值及对应详情。 */
|
|
137056
|
+
async function prepareObjectProductAutofills({ enabled, instances, objectInitialValues = [], rawData, context, defaultDataMap }) {
|
|
137057
|
+
const pending = [];
|
|
137058
|
+
if (!enabled || !objectInitialValues.length) return pending;
|
|
137059
|
+
const productRecords = /* @__PURE__ */ new Map();
|
|
137060
|
+
for (const instance of instances) {
|
|
137061
|
+
var _instance$widgetMeta, _instance$widgetMeta2;
|
|
137062
|
+
const field = (_instance$widgetMeta = instance.widgetMeta) === null || _instance$widgetMeta === void 0 ? void 0 : _instance$widgetMeta.field;
|
|
137063
|
+
const props = (_instance$widgetMeta2 = instance.widgetMeta) === null || _instance$widgetMeta2 === void 0 ? void 0 : _instance$widgetMeta2.props;
|
|
137064
|
+
if (!(field === null || field === void 0 ? void 0 : field.belongingObject) || !props || field.fieldType !== FIELD_TYPE.PRODUCT || field.subFieldKey || field.isLinkedModelField || !resolveAutofillEnabled(props)) continue;
|
|
137065
|
+
const rules = props.autofillRules;
|
|
137066
|
+
if (!Array.isArray(rules) || !rules.some((rule) => !!rule.fromField && !!rule.toField)) continue;
|
|
137067
|
+
const fieldKey = getLastSegment$1(field.fieldLink);
|
|
137068
|
+
const configured = objectInitialValues.find((item) => item.objectField === field.belongingObject);
|
|
137069
|
+
if (!(configured === null || configured === void 0 ? void 0 : configured.values) || !Object.prototype.hasOwnProperty.call(configured.values, fieldKey)) continue;
|
|
137070
|
+
const value = configured.values[fieldKey];
|
|
137071
|
+
if (typeof value !== "string" || value === "" || rawData[fieldKey] !== value) continue;
|
|
137072
|
+
let sourceData = productRecords.get(value);
|
|
137073
|
+
if (!sourceData) {
|
|
137074
|
+
const fetched = await fetchAutofillSource(field, {
|
|
137075
|
+
...context,
|
|
137076
|
+
[FIELD_TYPE.PRODUCT]: value
|
|
137077
|
+
});
|
|
137078
|
+
if (!fetched || typeof fetched !== "object" || Array.isArray(fetched) || Object.keys(fetched).length === 0) throw new Error(`对象初始化数据填充失败,字段 ${fieldKey}:未获取到物料 ${value} 的详情`);
|
|
137079
|
+
sourceData = fetched;
|
|
137080
|
+
productRecords.set(value, sourceData);
|
|
137081
|
+
}
|
|
137082
|
+
defaultDataMap[field.valuePath] = value;
|
|
137083
|
+
pending.push({
|
|
137084
|
+
field,
|
|
137085
|
+
value,
|
|
137086
|
+
sourceData,
|
|
137087
|
+
rules
|
|
137088
|
+
});
|
|
137089
|
+
}
|
|
137090
|
+
return pending;
|
|
137091
|
+
}
|
|
137092
|
+
/** 表格初始化完成后按实际行数填充,hydrate 写入属于初始化基线。 */
|
|
137093
|
+
function applyObjectProductAutofills(doc, pending) {
|
|
137094
|
+
for (const item of pending) {
|
|
137095
|
+
if (doc.dataManager.get(item.field.valuePath) !== item.value) continue;
|
|
137096
|
+
const updates = applyAutofillRules(item.sourceData, item.rules, {
|
|
137097
|
+
needReplacePathIndexPlaceholder: true,
|
|
137098
|
+
sourceValuePath: item.field.valuePath,
|
|
137099
|
+
rawData: doc.dataManager.getRawData(),
|
|
137100
|
+
doc
|
|
137101
|
+
});
|
|
137102
|
+
if (Object.keys(updates).length) doc.dataManager.setMultiple(updates, "hydrate");
|
|
137103
|
+
}
|
|
137104
|
+
}
|
|
137105
|
+
//#endregion
|
|
137045
137106
|
//#region src/sdk/doc-runtime/factories/document-initializer.ts
|
|
137046
137107
|
init_core();
|
|
137047
137108
|
init_field_type();
|
|
@@ -137053,12 +137114,9 @@ init_form_state();
|
|
|
137053
137114
|
init_enum();
|
|
137054
137115
|
init_check_table();
|
|
137055
137116
|
init_wait_for_data_settle();
|
|
137056
|
-
init_useWidgetInitializer();
|
|
137057
|
-
init_useDependency();
|
|
137058
137117
|
init_data();
|
|
137059
137118
|
init_material_consume();
|
|
137060
137119
|
init_table$1();
|
|
137061
|
-
init_date_object();
|
|
137062
137120
|
init_sub_field_config();
|
|
137063
137121
|
init_core$1();
|
|
137064
137122
|
/**
|
|
@@ -137227,7 +137285,7 @@ function applyDocumentInitMappings(doc, initMap) {
|
|
|
137227
137285
|
return { pathCount: Object.keys(initMap).length };
|
|
137228
137286
|
}
|
|
137229
137287
|
async function initializeDocumentEngine(props, payload, result) {
|
|
137230
|
-
var _payload$deviceConfig, _payload$deviceConfig2;
|
|
137288
|
+
var _payload$deviceConfig, _payload$deviceConfig2, _docModel$document$co;
|
|
137231
137289
|
const { id, requestInfo, fillModeType, paramsConfig, tmplBomC } = result;
|
|
137232
137290
|
const materialNo = (paramsConfig === null || paramsConfig === void 0 ? void 0 : paramsConfig.materialNo) || requestInfo.materialNo;
|
|
137233
137291
|
const { mainModelKey, fieldList, masterSlaveList } = await prepareDocumentFieldContext({
|
|
@@ -137277,6 +137335,14 @@ async function initializeDocumentEngine(props, payload, result) {
|
|
|
137277
137335
|
fieldList,
|
|
137278
137336
|
masterSlaveList
|
|
137279
137337
|
});
|
|
137338
|
+
const pendingObjectAutofills = await prepareObjectProductAutofills({
|
|
137339
|
+
enabled: fillModeType === DocModeTypeConst.Fill && requestInfo.instanceStatus === "UNFILLED",
|
|
137340
|
+
instances,
|
|
137341
|
+
objectInitialValues: ((_docModel$document$co = docModel.document.config) === null || _docModel$document$co === void 0 || (_docModel$document$co = _docModel$document$co.dataInit) === null || _docModel$document$co === void 0 ? void 0 : _docModel$document$co.objectInitialValues) ?? [],
|
|
137342
|
+
rawData,
|
|
137343
|
+
context: defaultQueryIds,
|
|
137344
|
+
defaultDataMap
|
|
137345
|
+
});
|
|
137280
137346
|
const docRuntimeMeta = {
|
|
137281
137347
|
...requestInfo,
|
|
137282
137348
|
/** 本次打开的检验表快照,保存时由宿主写入 frontConfig.checkTableConfig */
|
|
@@ -137328,6 +137394,7 @@ async function initializeDocumentEngine(props, payload, result) {
|
|
|
137328
137394
|
initMaterialConsumeTableConfig(doc, subConfig, tmplBomC);
|
|
137329
137395
|
getSubFieldConfig(doc.paramsConfig).init(subConfig);
|
|
137330
137396
|
await tableRuntime.onInit();
|
|
137397
|
+
applyObjectProductAutofills(doc, pendingObjectAutofills);
|
|
137331
137398
|
dateObjectRuntime.onInit();
|
|
137332
137399
|
await runDocumentPostLoadEnrichFlush(doc);
|
|
137333
137400
|
await waitForDataManagerSettle(doc);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Doc } from '../../../../../core';
|
|
2
|
+
import { FieldDataBindingMeta } from '../../../../../core/widget';
|
|
3
|
+
import { AutofillRule } from '../../../../../suites/shared/panel/config/editor/ref-autofill-editor/types';
|
|
4
|
+
export interface PreparedObjectProductAutofill {
|
|
5
|
+
field: FieldDataBindingMeta;
|
|
6
|
+
value: string;
|
|
7
|
+
sourceData: Record<string, unknown>;
|
|
8
|
+
rules: AutofillRule[];
|
|
9
|
+
}
|
|
10
|
+
interface PrepareOptions {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
instances: any[];
|
|
13
|
+
objectInitialValues?: readonly {
|
|
14
|
+
objectField: string;
|
|
15
|
+
values?: Record<string, unknown>;
|
|
16
|
+
}[];
|
|
17
|
+
rawData: Record<string, unknown>;
|
|
18
|
+
context: Record<string, unknown>;
|
|
19
|
+
defaultDataMap: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
/** 首次填报初始化:准备实际生效的对象物料默认值及对应详情。 */
|
|
22
|
+
export declare function prepareObjectProductAutofills({ enabled, instances, objectInitialValues, rawData, context, defaultDataMap, }: PrepareOptions): Promise<PreparedObjectProductAutofill[]>;
|
|
23
|
+
/** 表格初始化完成后按实际行数填充,hydrate 写入属于初始化基线。 */
|
|
24
|
+
export declare function applyObjectProductAutofills(doc: Doc, pending: readonly PreparedObjectProductAutofill[]): void;
|
|
25
|
+
export {};
|