@gct-paas/word 0.1.30 → 0.1.32

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
@@ -20594,7 +20594,8 @@ function safeParseJson(data, fallback = null, validator2) {
20594
20594
  }
20595
20595
  function generateValuePath(fieldLink, subFieldKey) {
20596
20596
  if (subFieldKey) {
20597
- return `$.${subFieldKey}[n].${fieldLink}`;
20597
+ const connector = subFieldKey.includes(":") ? "" : "[n]";
20598
+ return `$.${subFieldKey}${connector}.${fieldLink}`;
20598
20599
  } else {
20599
20600
  return `$.${fieldLink}`;
20600
20601
  }
@@ -26668,12 +26669,6 @@ function distributeInteger(total, count) {
26668
26669
  }
26669
26670
  return result;
26670
26671
  }
26671
- const mainData2WordData = (data) => {
26672
- const entries = Object.entries(data).map(([key, value]) => {
26673
- return [`$.${key}`, value];
26674
- });
26675
- return Object.fromEntries(entries);
26676
- };
26677
26672
  class TextUtil {
26678
26673
  /** 字体度量缓存限制 */
26679
26674
  static FONT_METRICS_CACHE_LIMIT = 80;
@@ -38116,21 +38111,13 @@ class InsertField extends CommandBase {
38116
38111
  const cursor = this.doc.cursorManager;
38117
38112
  const { nodeId, offset: offset2, side } = cursor.getCursor();
38118
38113
  const {
38119
- valuePath: _valuePath,
38120
- widgetMeta,
38121
- mainModelFields
38114
+ valuePath,
38115
+ widgetMeta
38122
38116
  } = this.payload;
38123
38117
  const mapper = this.doc.layoutMapper;
38124
38118
  const node = mapper.getBaseMetaNodeById(nodeId);
38125
38119
  const run = node.raw;
38126
38120
  const wp = mapper.getModelNodeById(run.parent.modelRef.id);
38127
- let valuePath = _valuePath;
38128
- if (run.modelRef?.valuePath2D) {
38129
- const [subTableKey, dataGroup2DKey] = run.modelRef.valuePath2D.replace("$.", "").split(":") || [];
38130
- const subTableModelKey = mainModelFields.find((f) => f.key === subTableKey)?.bindInfo;
38131
- const dataGroup2DModelKey = mainModelFields.find((f) => f.key === dataGroup2DKey)?.bindInfo;
38132
- valuePath = `$.${subTableModelKey}:${dataGroup2DModelKey}.${valuePath.replace("$.", "")}`;
38133
- }
38134
38121
  const wr = new WrField({ text: valuePath, valuePath, widgetMeta });
38135
38122
  if (!this.validateFieldPath(valuePath, wp)) {
38136
38123
  console.warn("字段路径不合法,无法插入字段", valuePath);
@@ -40640,8 +40627,8 @@ class TextHandler {
40640
40627
  return id;
40641
40628
  }
40642
40629
  static get2DInfo(context) {
40643
- const { xDataIndex, yDataIndex, valuePath } = context.cell?.subRenderer || {};
40644
- return { xDataIndex, yDataIndex, valuePath2D: valuePath };
40630
+ const { xDataIndex, yDataIndex } = context.cell?.subRenderer || {};
40631
+ return { xDataIndex, yDataIndex };
40645
40632
  }
40646
40633
  /**
40647
40634
  * 合并部分run
@@ -40846,8 +40833,8 @@ class FieldBaseHandler {
40846
40833
  return id;
40847
40834
  }
40848
40835
  static get2DInfo(context) {
40849
- const { xDataIndex, yDataIndex, valuePath } = context.cell?.subRenderer || {};
40850
- return { xDataIndex, yDataIndex, valuePath2D: valuePath };
40836
+ const { xDataIndex, yDataIndex } = context.cell?.subRenderer || {};
40837
+ return { xDataIndex, yDataIndex };
40851
40838
  }
40852
40839
  static getValue(ctx, valuePath) {
40853
40840
  const { context } = ctx;
@@ -45926,6 +45913,7 @@ class DataManager {
45926
45913
  /**
45927
45914
  * 设置整个原始数据
45928
45915
  * @param data 新的 JSON 数据
45916
+ * @param defaultsMap 默认值, 字段值为 undefined 时才懒填充,不覆盖接口数据
45929
45917
  */
45930
45918
  setRawData(data, defaultsMap) {
45931
45919
  const oldData = this.rawData;
@@ -45935,6 +45923,58 @@ class DataManager {
45935
45923
  this.setDefaults(defaultsMap);
45936
45924
  }
45937
45925
  }
45926
+ /**
45927
+ * 将初始化数据直接写入 rawData(仅填充空值,不覆盖接口数据)
45928
+ * 与 defaults(懒填充)不同,此方法在初始化阶段一次性写入
45929
+ *
45930
+ * 支持两种子表路径形式:
45931
+ * - `[n]` 通配符:展开到 rawData 中已有的每一行(无则创建一行),如 `$.sub[n].field`
45932
+ * - 真实下标:直接写入指定行,如 `$.sub[0].field`
45933
+ *
45934
+ * 处理顺序:先展开 `[n]` 通配符,再写入真实下标路径。
45935
+ * 这样可以保证:参数映射(`[n]`)先铺好默认值,自定义数据源(真实下标)再精确覆盖。
45936
+ */
45937
+ applyInitData(initDataMap) {
45938
+ for (const [path2, value] of Object.entries(initDataMap)) {
45939
+ if (value === void 0 || value === null) continue;
45940
+ if (path2.includes("[n]")) {
45941
+ this.applyInitDataWildcard(path2, value);
45942
+ }
45943
+ }
45944
+ for (const [path2, value] of Object.entries(initDataMap)) {
45945
+ if (value === void 0 || value === null) continue;
45946
+ if (!path2.includes("[n]")) {
45947
+ const existing = this.getByPath(this.rawData, path2);
45948
+ if (existing === void 0 || existing === null) {
45949
+ try {
45950
+ this.setByPath(this.rawData, path2, value);
45951
+ } catch (e) {
45952
+ console.warn(`applyInitData: failed to set path "${path2}"`, e);
45953
+ }
45954
+ }
45955
+ }
45956
+ }
45957
+ }
45958
+ applyInitDataWildcard(path2, value) {
45959
+ const match = path2.match(/^\$\.([^[.]+)\[n\]/);
45960
+ if (!match) return;
45961
+ const subTableKey = match[1];
45962
+ let subTableArray = this.rawData?.[subTableKey];
45963
+ if (!Array.isArray(subTableArray) || subTableArray.length === 0) {
45964
+ subTableArray = [{ ...DEFAULT_EMPTY_ITEM }];
45965
+ }
45966
+ for (let i = 0; i < subTableArray.length; i++) {
45967
+ const realPath = replacePathIndexPlaceholder(i, path2);
45968
+ const existing = this.getByPath(this.rawData, realPath);
45969
+ if (existing === void 0 || existing === null) {
45970
+ try {
45971
+ this.setByPath(this.rawData, realPath, value);
45972
+ } catch (e) {
45973
+ console.warn(`applyInitData: failed to set path "${realPath}"`, e);
45974
+ }
45975
+ }
45976
+ }
45977
+ }
45938
45978
  /**
45939
45979
  * 内部方法:根据路径获取值
45940
45980
  */
@@ -50226,6 +50266,28 @@ const apiFetchers = {
50226
50266
  totalCount: totalCount || 0
50227
50267
  };
50228
50268
  },
50269
+ fetchOne: async (id) => {
50270
+ if (!id) return {};
50271
+ const result = await api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey(
50272
+ {
50273
+ modelCategory: API_CONFIG.ENTITY_CATEGORY,
50274
+ modelKey: API_CONFIG.LOT_DEFAULTS.modelKey,
50275
+ bsKey: API_CONFIG.LOT_DEFAULTS.bsKey
50276
+ },
50277
+ {},
50278
+ {
50279
+ query: { "material_no_.like": id },
50280
+ pageSize: 20,
50281
+ pageNo: 1
50282
+ }
50283
+ );
50284
+ const { data = [], totalPage, dict, totalCount } = result || {};
50285
+ return {
50286
+ data: transformSourceDataList(data || [], dict) || [],
50287
+ totalPage,
50288
+ totalCount: totalCount || 0
50289
+ };
50290
+ },
50229
50291
  transformers: {
50230
50292
  toOptions(items) {
50231
50293
  const transformer = createTransformer("material_no_", "material_no_");
@@ -50430,7 +50492,7 @@ async function fetchLabelAndFill(defaults2, valuePath, id, fetcher, props, fallb
50430
50492
  defaults2 ??= {};
50431
50493
  defaults2[valuePath] = id;
50432
50494
  try {
50433
- const isSingle = fetcher === "rdo2ref";
50495
+ const isSingle = fetcher === "rdo2ref" || fetcher === "lot2sn";
50434
50496
  const result = isSingle ? await apiFetchers[fetcher].getOptionById(id, props) : await apiFetchers[fetcher].getOptionByIds(getValue$1(id, true), props);
50435
50497
  const list = Array.isArray(result) ? result : result ? [result] : [];
50436
50498
  const labels = list.map((i) => i?.label).filter(Boolean);
@@ -50447,7 +50509,7 @@ async function fetchLabelAndFill(defaults2, valuePath, id, fetcher, props, fallb
50447
50509
  }
50448
50510
  return defaults2;
50449
50511
  }
50450
- async function enrichApiDefaultValues(defaults2, rule, valuePath, fieldMeta, context, loadFieldByKey) {
50512
+ async function enrichApiDefaultValues(defaults2, rule, valuePath, fieldMeta, context, loadFieldByKey, options) {
50451
50513
  if (!rule || !("fetcher" in rule)) {
50452
50514
  return defaults2;
50453
50515
  }
@@ -50468,7 +50530,8 @@ async function enrichApiDefaultValues(defaults2, rule, valuePath, fieldMeta, con
50468
50530
  return defaults2;
50469
50531
  }
50470
50532
  const apiRule = rule;
50471
- if (apiRule.onlyMainModelFieldsCanRequest && fieldMeta.subFieldKey) {
50533
+ const allowSubModelRequest = options?.allowSubModelRequest ?? false;
50534
+ if (apiRule.onlyMainModelFieldsCanRequest && fieldMeta.subFieldKey && !allowSubModelRequest) {
50472
50535
  return defaults2;
50473
50536
  }
50474
50537
  const modelKey = getLastSegment(fieldMeta.modelLink);
@@ -50504,7 +50567,16 @@ async function fetchAutofillSource(field, context) {
50504
50567
  return data;
50505
50568
  }
50506
50569
  async function computeFieldDefaultValue(params) {
50507
- const { fieldType, fieldMeta, valuePath, value, props, getFieldManifest, loadFieldByKey } = params;
50570
+ const {
50571
+ fieldType,
50572
+ fieldMeta,
50573
+ valuePath,
50574
+ value,
50575
+ props,
50576
+ getFieldManifest,
50577
+ loadFieldByKey,
50578
+ allowSubModelRequest
50579
+ } = params;
50508
50580
  const result = {};
50509
50581
  const manifest2 = getFieldManifest(fieldType);
50510
50582
  const rule = manifest2?.computed?.defaultValueRule;
@@ -50533,7 +50605,10 @@ async function computeFieldDefaultValue(params) {
50533
50605
  valuePath,
50534
50606
  fieldMeta,
50535
50607
  fakeContext,
50536
- loadFieldByKey
50608
+ loadFieldByKey,
50609
+ {
50610
+ allowSubModelRequest
50611
+ }
50537
50612
  );
50538
50613
  }
50539
50614
  Object.assign(result, defaults2);
@@ -51007,14 +51082,6 @@ const builtinFieldColumns = [
51007
51082
  name: "字段类型"
51008
51083
  }
51009
51084
  ];
51010
- const DEFAULT_FROM_STATE = {
51011
- _DICT: {},
51012
- //翻译的字段
51013
- _OPCT: {},
51014
- //关联模型字段完全体
51015
- _MCTABLE: {}
51016
- // 物料消耗表业务数据
51017
- };
51018
51085
  function getDefaultQueryIdsByFieldType(payload) {
51019
51086
  const defaultQueryIds = {
51020
51087
  [FIELD_TYPE.MATERIAL_NO]: payload.materialNumber,
@@ -51069,13 +51136,13 @@ async function loadDefaultValuesByFields(instances, ctx, context, masterSlaveLis
51069
51136
  await Promise.all(promises);
51070
51137
  return defaultDataMap;
51071
51138
  }
51072
- const handleParameterMapping = (parameterMapping, paramsConfig, subTableInfo, fieldPermission) => {
51139
+ const handleParameterMapping = async (parameterMapping, paramsConfig, fieldPermission, instances, ctx) => {
51073
51140
  if (!parameterMapping.length || !paramsConfig) {
51074
51141
  return {};
51075
51142
  }
51076
51143
  const referenceMap = new Map(Object.entries(paramsConfig));
51077
- const paramMap = { ...cloneDeep(DEFAULT_FROM_STATE) };
51078
- const subMappedFields = {};
51144
+ const paramMap = {};
51145
+ console.log("TJ::parameterMapping", parameterMapping);
51079
51146
  const paramsMapList = parameterMapping.map((item) => {
51080
51147
  return item.toFields.map((f) => {
51081
51148
  return {
@@ -51099,90 +51166,75 @@ const handleParameterMapping = (parameterMapping, paramsConfig, subTableInfo, fi
51099
51166
  return item?.paramMapType === type4 === isBuiltin && (!field || !field.readonly);
51100
51167
  })
51101
51168
  );
51102
- const processParamItem = (item) => {
51169
+ const processParamItem = async (item) => {
51103
51170
  if (!referenceMap.has(item.formKey)) return;
51104
51171
  const value = referenceMap.get(item.formKey);
51105
- const formattedValue = toFormatValue(item.fieldType, value);
51106
- const target = item?.subModel ? (subMappedFields[item.subFieldKey] ??= {}, subMappedFields[item.subFieldKey]) : paramMap;
51107
- merge(target, { [item.field]: formattedValue });
51108
- };
51109
- [...builtinParams, ...compParams].forEach(processParamItem);
51110
- Object.entries(subMappedFields).forEach(([key, value]) => {
51111
- const subTableConfig = subTableInfo.find(({ field }) => field === key);
51112
- if (!subTableConfig) return;
51113
- const data = [value];
51114
- let data2d;
51115
- const { childInitRowLen, key: tableKey } = subTableConfig;
51116
- const is2DTable = subTableConfig.subTable2d && tableKey === "dyn" || subTableConfig.checkTable2d && tableKey === "newfixed";
51117
- if (is2DTable) {
51118
- const emptyList = Array.from({ length: childInitRowLen });
51119
- data2d = data.map((fInfo) => {
51120
- const group_ = `${tableKey}${uuid()}`;
51121
- return emptyList.map((_2) => {
51122
- return {
51123
- ...fInfo,
51124
- group_
51125
- };
51126
- });
51127
- }).flat();
51172
+ const valuePath = generateValuePath(item.field, item?.subModel ? item.subFieldKey : "");
51173
+ const widget = instances.find((instance2) => {
51174
+ const fieldMeta = instance2.widgetMeta?.field;
51175
+ if (item?.subModel) {
51176
+ return item.field === getLastSegment(fieldMeta?.fieldLink) && item.subFieldKey === fieldMeta?.subFieldKey;
51177
+ }
51178
+ return item.field === getLastSegment(fieldMeta?.fieldLink) && !fieldMeta?.subFieldKey;
51179
+ });
51180
+ if (widget) {
51181
+ const computed2 = await computeFieldDefaultValue({
51182
+ fieldType: item.fieldType,
51183
+ fieldMeta: widget.widgetMeta.field,
51184
+ valuePath,
51185
+ value: toFormatValue(item.fieldType, value),
51186
+ props: widget.widgetMeta.props ?? {},
51187
+ getFieldManifest: ctx.getFieldManifest.bind(ctx),
51188
+ loadFieldByKey: async (modelKey, fieldKey) => ctx.runtime.loadFieldByKey(modelKey, fieldKey),
51189
+ allowSubModelRequest: true
51190
+ });
51191
+ merge(paramMap, computed2);
51192
+ } else {
51193
+ merge(paramMap, { [valuePath]: toFormatValue(item.fieldType, value) });
51128
51194
  }
51129
- merge(paramMap, {
51130
- [key]: {
51131
- data: data2d || data,
51132
- dict: {}
51133
- }
51134
- });
51135
- });
51195
+ };
51196
+ await Promise.all([...builtinParams, ...compParams].map(processParamItem));
51136
51197
  return paramMap;
51137
51198
  };
51138
- const getFormDataItem = (onFieldMap, subTableInfo, result) => {
51139
- const formDataItem = { ...cloneDeep(DEFAULT_FROM_STATE) };
51140
- if (result?.data?.length) {
51141
- const firstData = cloneDeep(result.data[0]);
51142
- onFieldMap.forEach((item) => {
51143
- if (item.subModel === 0) {
51144
- const mappedFields = item.fields.reduce(
51145
- (prev, { isFieldModel, leftFieldKey, fieldLink, rightFieldKey }) => {
51146
- prev[leftFieldKey] = isFieldModel ? firstData?.__FOREIGN__?.[fieldLink] : firstData[rightFieldKey];
51147
- return prev;
51148
- },
51149
- {}
51150
- );
51151
- merge(formDataItem, mappedFields);
51152
- } else if (item.subModel === 1) {
51153
- const sInfo = subTableInfo.find((aa2) => aa2.field === item.subFieldKey) || {};
51154
- const fieldList = result.data.map(
51155
- (data) => item.fields.reduce(
51156
- (prev, { isFieldModel, leftFieldKey, fieldLink, rightFieldKey }) => {
51157
- prev[leftFieldKey] = isFieldModel ? data?.__FOREIGN__?.[fieldLink] : data[rightFieldKey];
51158
- return prev;
51159
- },
51160
- {}
51161
- )
51162
- );
51163
- let fieldList2d;
51164
- if (sInfo.subTable2d && sInfo.key === "dyn" || sInfo.checkTable2d && sInfo.key === "newfixed") {
51165
- const emptyList = Array.from({ length: sInfo.childInitRowLen });
51166
- fieldList2d = fieldList.map((fInfo) => {
51167
- const group_ = `${sInfo.key}${uuid()}`;
51168
- return emptyList.map((_2) => {
51169
- return {
51170
- ...fInfo,
51171
- group_
51172
- };
51173
- });
51174
- }).flat();
51199
+ const buildPathMapFromApiResult = (onFieldMap, result, subTableInfo) => {
51200
+ const pathMap = {};
51201
+ const { data = [], dict = {} } = result;
51202
+ if (!data?.length) return pathMap;
51203
+ const getLabelFromDict = (srcKey, value) => {
51204
+ const entry = dict?.[srcKey]?.[value];
51205
+ if (entry == null) return void 0;
51206
+ return Array.isArray(entry) ? entry[0] : entry;
51207
+ };
51208
+ onFieldMap.forEach((item) => {
51209
+ if (item.subModel === 0) {
51210
+ const firstRow = data[0];
51211
+ item.fields.forEach(({ isFieldModel, leftFieldKey, fieldLink, rightFieldKey }) => {
51212
+ const srcKey = rightFieldKey;
51213
+ const value = isFieldModel ? firstRow?.__FOREIGN__?.[fieldLink] : firstRow?.[srcKey];
51214
+ if (value != null) {
51215
+ const valuePath = generateValuePath(leftFieldKey, "");
51216
+ pathMap[valuePath] = value;
51217
+ const label = getLabelFromDict(srcKey, value);
51218
+ if (label != null) pathMap[`${valuePath}_lb_`] = label;
51175
51219
  }
51176
- merge(formDataItem, {
51177
- [item.subFieldKey]: {
51178
- data: fieldList2d || fieldList,
51179
- dict: result.dict ?? {}
51220
+ });
51221
+ } else if (item.subModel === 1) {
51222
+ data.forEach(
51223
+ (rowData, index2) => item.fields.forEach(({ isFieldModel, leftFieldKey, fieldLink, rightFieldKey }) => {
51224
+ const srcKey = rightFieldKey;
51225
+ const value = isFieldModel ? rowData?.__FOREIGN__?.[fieldLink] : rowData?.[srcKey];
51226
+ if (value != null) {
51227
+ const valuePath = generateValuePath(leftFieldKey, item.subFieldKey);
51228
+ const runtimeValuePath = replacePathIndexPlaceholder(index2, valuePath);
51229
+ pathMap[runtimeValuePath] = value;
51230
+ const label = getLabelFromDict(srcKey, value);
51231
+ if (label != null) pathMap[`${runtimeValuePath}_lb_`] = label;
51180
51232
  }
51181
- });
51182
- }
51183
- });
51184
- }
51185
- return formDataItem;
51233
+ })
51234
+ );
51235
+ }
51236
+ });
51237
+ return pathMap;
51186
51238
  };
51187
51239
  const handleCustomDataSource = async (customDataSource, paramsConfig, subTableInfo, instanceId) => {
51188
51240
  if (!customDataSource.length || !paramsConfig) {
@@ -51237,24 +51289,15 @@ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableIn
51237
51289
  metaInfo = await api.apaas.modelMeta.getInfo({ id: info.joinModelKey });
51238
51290
  }
51239
51291
  if (metaInfo && metaInfo.type === "RDO" && info.joinModelKey === "em_product") {
51240
- const promise = api.apaas.onlineFormInstance.getGetRelatedProduct({
51241
- id: instanceId
51242
- }).then((res) => {
51243
- return getFormDataItem(info.onFieldMap, subTableInfo, {
51244
- data: res ? [res] : []
51245
- });
51246
- });
51292
+ const promise = api.apaas.onlineFormInstance.getGetRelatedProduct({ id: instanceId }).then(
51293
+ (res) => buildPathMapFromApiResult(info.onFieldMap, { data: res ? [res] : [] })
51294
+ );
51247
51295
  promises.push(promise);
51248
51296
  } else if (info.joinModelType === JoinModelTypeEum.SqlModel) {
51249
51297
  if (finalSQL) {
51250
- const promise = api.apaas.dataSource.postSelect({
51251
- key: info.joinModelKey,
51252
- sql: finalSQL
51253
- }).then((res) => {
51254
- return getFormDataItem(info.onFieldMap, subTableInfo, {
51255
- data: res ?? []
51256
- });
51257
- });
51298
+ const promise = api.apaas.dataSource.postSelect({ key: info.joinModelKey, sql: finalSQL }).then(
51299
+ (res) => buildPathMapFromApiResult(info.onFieldMap, { data: res ?? [] })
51300
+ );
51258
51301
  promises.push(promise);
51259
51302
  }
51260
51303
  } else if (info.joinModelType === JoinModelTypeEum.IpaasModel) {
@@ -51267,36 +51310,30 @@ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableIn
51267
51310
  queryParameters: metaIpaas.metaQuery,
51268
51311
  uriParameters: metaIpaas.metaUri
51269
51312
  }).then((res) => {
51270
- const formDataItem = { ...cloneDeep(DEFAULT_FROM_STATE) };
51313
+ const ipaasPathMap = {};
51271
51314
  info.onFieldMap.forEach((item) => {
51272
51315
  if (item.subModel === 0) {
51273
- const mappedFields = jsonSchemaUtils.processJsonSchemaSubModel0(item, res);
51274
- merge(formDataItem, mappedFields);
51275
- } else if (item.subModel === 1) {
51276
- const sInfo = subTableInfo.find((aa2) => aa2.field === item.subFieldKey) || {};
51277
- const fieldList = jsonSchemaUtils.processJsonSchemaSubModel1(item, res);
51278
- let fieldList2d;
51279
- if (sInfo.subTable2d && sInfo.key === "dyn" || sInfo.checkTable2d && sInfo.key === "newfixed") {
51280
- const emptyList = Array.from({ length: sInfo.childInitRowLen });
51281
- fieldList2d = fieldList.map((fInfo) => {
51282
- const group_ = `${sInfo.key}${uuid()}`;
51283
- return emptyList.map((_2) => {
51284
- return {
51285
- ...fInfo,
51286
- group_
51287
- };
51288
- });
51289
- }).flat();
51290
- }
51291
- merge(formDataItem, {
51292
- [item.subFieldKey]: {
51293
- data: fieldList2d || fieldList,
51294
- dict: {}
51316
+ const fields = jsonSchemaUtils.processJsonSchemaSubModel0(item, res);
51317
+ Object.entries(fields).forEach(([key, value]) => {
51318
+ if (value != null) {
51319
+ const valuePath = generateValuePath(key, "");
51320
+ ipaasPathMap[valuePath] = value;
51295
51321
  }
51296
51322
  });
51323
+ } else if (item.subModel === 1) {
51324
+ let rows = jsonSchemaUtils.processJsonSchemaSubModel1(item, res);
51325
+ rows.forEach((rowData, index2) => {
51326
+ Object.entries(rowData).forEach(([key, value]) => {
51327
+ if (value != null) {
51328
+ const valuePath = generateValuePath(key, item.subFieldKey);
51329
+ const runtimeValuePath = replacePathIndexPlaceholder(index2, valuePath);
51330
+ ipaasPathMap[runtimeValuePath] = value;
51331
+ }
51332
+ });
51333
+ });
51297
51334
  }
51298
51335
  });
51299
- return formDataItem;
51336
+ return ipaasPathMap;
51300
51337
  });
51301
51338
  promises.push(promise);
51302
51339
  }
@@ -51306,8 +51343,9 @@ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableIn
51306
51343
  protocolKey: info.joinModelKey,
51307
51344
  instId: instanceId
51308
51345
  });
51309
- const promise = getFormDataItem(info.onFieldMap, subTableInfo, res);
51310
- promises.push(promise);
51346
+ promises.push(
51347
+ Promise.resolve(buildPathMapFromApiResult(info.onFieldMap, res))
51348
+ );
51311
51349
  }
51312
51350
  } else {
51313
51351
  const query = info.query.filter((item) => {
@@ -51341,24 +51379,23 @@ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableIn
51341
51379
  foreignFields
51342
51380
  },
51343
51381
  ...params
51344
- }).then((res) => {
51345
- return getFormDataItem(info.onFieldMap, subTableInfo, res);
51346
- });
51382
+ }).then((res) => buildPathMapFromApiResult(info.onFieldMap, res));
51347
51383
  promises.push(promise);
51348
51384
  }
51349
51385
  }
51350
51386
  }
51351
- return Promise.all(promises);
51387
+ const results = await Promise.all(promises);
51388
+ return results.reduce((merged, map2) => merge(merged, map2), {});
51352
51389
  };
51353
- const loadDataInitValues = async (runtimeJson, paramsConfig, subTableInfo, fieldPermission, instanceId) => {
51354
- const { document: document2 } = JSON.parse(runtimeJson || "{}");
51355
- if (!document2?.config?.dataInit) return {};
51356
- const { parameterMapping = [], customDataSource = [] } = document2.config.dataInit;
51357
- const paramMap = handleParameterMapping(
51390
+ const loadDataInitValues = async (dataInitConfig, paramsConfig, subTableInfo, fieldPermission, instanceId, instances, ctx) => {
51391
+ if (!dataInitConfig) return { paramMap: {}, dsRawData: {} };
51392
+ const { parameterMapping = [], customDataSource = [] } = dataInitConfig || {};
51393
+ const paramMap = await handleParameterMapping(
51358
51394
  parameterMapping,
51359
51395
  paramsConfig,
51360
- subTableInfo,
51361
- fieldPermission
51396
+ fieldPermission,
51397
+ instances,
51398
+ ctx
51362
51399
  );
51363
51400
  const dsMap = await handleCustomDataSource(
51364
51401
  customDataSource,
@@ -51366,10 +51403,7 @@ const loadDataInitValues = async (runtimeJson, paramsConfig, subTableInfo, field
51366
51403
  subTableInfo,
51367
51404
  instanceId
51368
51405
  );
51369
- return {
51370
- ...mainData2WordData(paramMap),
51371
- ...mainData2WordData(dsMap)
51372
- };
51406
+ return { paramMap, dsMap };
51373
51407
  };
51374
51408
  const collectLinkedModelFields = (instances) => {
51375
51409
  const mainFields = /* @__PURE__ */ new Set();
@@ -51557,15 +51591,17 @@ async function initializeDocumentEngine(props, payload, result) {
51557
51591
  masterSlaveList
51558
51592
  );
51559
51593
  console.log("默认值集合 ===>", defaultDataMap);
51560
- const dataInitMap = await loadDataInitValues(
51561
- requestInfo.runtimeJson || "",
51594
+ const { paramMap, dsMap } = await loadDataInitValues(
51595
+ cloneRuntimeJson?.document?.config?.dataInit,
51562
51596
  paramsConfig,
51563
- [],
51564
- // JSW TODO: subTableInfo
51597
+ docModel.getSubTableInfoList(),
51565
51598
  JSON.parse(requestInfo.processFieldPermission || "[]"),
51566
- id
51599
+ id,
51600
+ instances,
51601
+ payload.ctx
51567
51602
  );
51568
- console.log("数据初始化集合 ===>", dataInitMap);
51603
+ console.log("TJ::数据初始化集合/参数映射 ===>", paramMap);
51604
+ console.log("TJ::数据初始化集合/自定义数据源 ===>", dsMap);
51569
51605
  const interfaceData = await fetchRenderData({
51570
51606
  info: requestInfo,
51571
51607
  fetchConfig: {
@@ -51599,10 +51635,8 @@ async function initializeDocumentEngine(props, payload, result) {
51599
51635
  docRuntimeMeta,
51600
51636
  fieldModelQuery: payload.ctx.runtime
51601
51637
  });
51602
- doc.dataManager.setRawData(rawData, {
51603
- ...defaultDataMap,
51604
- ...dataInitMap
51605
- });
51638
+ doc.dataManager.setRawData(rawData, defaultDataMap);
51639
+ doc.dataManager.applyInitData({ ...paramMap, ...dsMap });
51606
51640
  doc.docRuntimeMeta.handleInfo.initRawDataSnapshot = cloneDeep(doc.dataManager.getRawData());
51607
51641
  const docInfo = snapshotDocInfo(doc);
51608
51642
  return {
@@ -55673,10 +55707,11 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
55673
55707
  dataGroup2DList.push({
55674
55708
  subTableId: cell.subRenderer.id,
55675
55709
  subTableType: cell.subRenderer.type,
55710
+ subTableValuePath: cell.subRenderer.valuePath,
55676
55711
  dataGroup2DAreaRange: cell.subRenderer?.dataGroup2DAreaRange
55677
55712
  });
55678
55713
  });
55679
- dataGroup2DList.forEach(({ subTableId, subTableType, dataGroup2DAreaRange }) => {
55714
+ dataGroup2DList.forEach(({ subTableId, subTableType, subTableValuePath, dataGroup2DAreaRange }) => {
55680
55715
  if (!dataGroup2DAreaRange?.start) return;
55681
55716
  const {
55682
55717
  start: { row: startRow, col: startCol },
@@ -55695,6 +55730,7 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
55695
55730
  subRenderer: {
55696
55731
  id: subTableId,
55697
55732
  type: subTableType,
55733
+ valuePath: subTableValuePath,
55698
55734
  dataIndex: fakeDataIndex,
55699
55735
  xDataIndex: fakeDataIndex
55700
55736
  }
@@ -55941,7 +55977,11 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
55941
55977
  pos: dataGroupTypePos.value[id],
55942
55978
  onMouseenter: ($event) => onMouseenter(id, "data-group-first"),
55943
55979
  onMouseleave,
55944
- onClick: ($event) => handleAction(layer.type, { regionId: id, subFieldKey: layer.valuePath })
55980
+ onClick: ($event) => handleAction(layer.type, {
55981
+ regionId: id,
55982
+ subFieldKey: layer.valuePath,
55983
+ isDataGroup2DClicked: true
55984
+ })
55945
55985
  }, null, 8, ["uuid", "isPreview", "layer", "pos", "onMouseenter", "onClick"])) : createCommentVNode("", true)
55946
55986
  ]),
55947
55987
  _: 2
@@ -59763,15 +59803,20 @@ const _sfc_main$2i = /* @__PURE__ */ defineComponent({
59763
59803
  const createFieldToWidget = createDesignFieldToWidgetFactory(designCtx.getFieldManifest);
59764
59804
  const subFieldKey = computed(() => {
59765
59805
  if (!interCtx.panelData) return "";
59766
- const s = getLastSegment(interCtx.panelData.context.subFieldKey);
59767
- return s.includes(":") ? s.split(":")[0] : s;
59806
+ return getLastSegment(interCtx.panelData.context.subFieldKey);
59768
59807
  });
59769
59808
  const modelKey = computed(() => {
59770
59809
  if (!interCtx.panelData) return "";
59771
59810
  const mainModelKey = interCtx.panelData.context.mainModelKey;
59772
59811
  if (!mainModelKey) return "";
59773
- if (subFieldKey.value) {
59774
- const field = designCtx.runtime.getFieldList(mainModelKey)?.find((f) => f.key === subFieldKey.value);
59812
+ const fullSubKey = subFieldKey.value;
59813
+ if (fullSubKey) {
59814
+ let singleSubKey = fullSubKey;
59815
+ if (fullSubKey.includes(":")) {
59816
+ const keyIndex = interCtx.panelData.context.isDataGroup2DClicked ? 1 : 0;
59817
+ singleSubKey = fullSubKey.split(":")[keyIndex];
59818
+ }
59819
+ const field = designCtx.runtime.getFieldList(mainModelKey)?.find((f) => f.key === singleSubKey);
59775
59820
  return field?.bindInfo ?? "";
59776
59821
  }
59777
59822
  return mainModelKey;
@@ -59884,7 +59929,7 @@ const _sfc_main$2i = /* @__PURE__ */ defineComponent({
59884
59929
  };
59885
59930
  }
59886
59931
  });
59887
- const ToolkitContentFields = /* @__PURE__ */ _export_sfc(_sfc_main$2i, [["__scopeId", "data-v-c740a237"]]);
59932
+ const ToolkitContentFields = /* @__PURE__ */ _export_sfc(_sfc_main$2i, [["__scopeId", "data-v-3fbe453b"]]);
59888
59933
  function createDesignPaperWidgetToWidgetFactory(getPaperWidgetManifest) {
59889
59934
  return function(widget, opts = {}) {
59890
59935
  const manifest2 = getPaperWidgetManifest(widget.type);
@@ -60046,21 +60091,12 @@ const _sfc_main$2g = /* @__PURE__ */ defineComponent({
60046
60091
  title: "",
60047
60092
  onClose: _cache[4] || (_cache[4] = ($event) => handleToolkitClose("data-init")),
60048
60093
  onVisibleChange: _cache[5] || (_cache[5] = ($event) => handleVisibleChange("data-init", $event))
60049
- }),
60050
- createVNode(ToolkitItem, {
60051
- noDropdown: "",
60052
- icon: "icon-shujumoxing",
60053
- version: "v1",
60054
- label: "数据加载",
60055
- title: "",
60056
- onClose: _cache[6] || (_cache[6] = ($event) => handleToolkitClose("data-load")),
60057
- onVisibleChange: _cache[7] || (_cache[7] = ($event) => handleVisibleChange("data-load", $event))
60058
60094
  })
60059
60095
  ]);
60060
60096
  };
60061
60097
  }
60062
60098
  });
60063
- const Toolkit = /* @__PURE__ */ _export_sfc(_sfc_main$2g, [["__scopeId", "data-v-dddcd6f8"]]);
60099
+ const Toolkit = /* @__PURE__ */ _export_sfc(_sfc_main$2g, [["__scopeId", "data-v-7ebf8ab6"]]);
60064
60100
  const _hoisted_1$1A = { class: "designer_panel-wrapper" };
60065
60101
  const _hoisted_2$10 = { class: "panel-breadcrumb" };
60066
60102
  const _hoisted_3$L = {
@@ -61665,8 +61701,6 @@ const _sfc_main$22 = /* @__PURE__ */ defineComponent({
61665
61701
  setup(__props) {
61666
61702
  const { docInst } = useDocPubApiContext();
61667
61703
  const interCtx = useInteractionContext();
61668
- const modelKey = toRef(docInst.value, "mainModelKey");
61669
- const { fields: mainModelFields } = useModelData(modelKey);
61670
61704
  const pageStageRef = ref(null);
61671
61705
  const scrollRef = ref(null);
61672
61706
  function canDrop(e, isOutOfFlow) {
@@ -61701,7 +61735,6 @@ const _sfc_main$22 = /* @__PURE__ */ defineComponent({
61701
61735
  docInst.value.execute(CommandType.insertField, {
61702
61736
  valuePath: widgetMeta.field?.valuePath,
61703
61737
  widgetMeta,
61704
- mainModelFields: mainModelFields.value || [],
61705
61738
  doCallback(data) {
61706
61739
  if (!data) return;
61707
61740
  const focus = Array.isArray(data) ? data[data.length - 1] : data;
@@ -61791,7 +61824,7 @@ const _sfc_main$22 = /* @__PURE__ */ defineComponent({
61791
61824
  };
61792
61825
  }
61793
61826
  });
61794
- const EditableCanvas = /* @__PURE__ */ _export_sfc(_sfc_main$22, [["__scopeId", "data-v-02d21574"]]);
61827
+ const EditableCanvas = /* @__PURE__ */ _export_sfc(_sfc_main$22, [["__scopeId", "data-v-85f53514"]]);
61795
61828
  const useDocDesignLayoutProps = () => {
61796
61829
  const provideProps = (props) => {
61797
61830
  provide(DOC_DESIGN_LAYOUT_PROPS, props);
@@ -61886,7 +61919,7 @@ const _hoisted_7$b = { style: { "padding": "0 12px" } };
61886
61919
  const _sfc_main$21 = /* @__PURE__ */ defineComponent({
61887
61920
  __name: "doc-design-layout",
61888
61921
  props: {
61889
- IOTPermission: { type: Boolean, default: true }
61922
+ IOTPermission: { type: Boolean, default: false }
61890
61923
  },
61891
61924
  setup(__props, { expose: __expose }) {
61892
61925
  const props = __props;
@@ -61920,10 +61953,6 @@ const _sfc_main$21 = /* @__PURE__ */ defineComponent({
61920
61953
  const onImportTemplate = () => {
61921
61954
  handleUploadFile();
61922
61955
  };
61923
- const onImportData = (mainData) => {
61924
- const data = mainData2WordData(mainData);
61925
- docInst.value?.dataManager.patch(data);
61926
- };
61927
61956
  onFileUpload(async (files) => {
61928
61957
  const file = files?.[0];
61929
61958
  if (!file) return;
@@ -61948,8 +61977,7 @@ const _sfc_main$21 = /* @__PURE__ */ defineComponent({
61948
61977
  }
61949
61978
  );
61950
61979
  __expose({
61951
- onImportTemplate,
61952
- onImportData
61980
+ onImportTemplate
61953
61981
  });
61954
61982
  return (_ctx, _cache) => {
61955
61983
  return openBlock(), createBlock(unref(GctLayout), {
@@ -62005,7 +62033,7 @@ const _sfc_main$21 = /* @__PURE__ */ defineComponent({
62005
62033
  };
62006
62034
  }
62007
62035
  });
62008
- const docDesignLayout = /* @__PURE__ */ _export_sfc(_sfc_main$21, [["__scopeId", "data-v-041003c9"]]);
62036
+ const docDesignLayout = /* @__PURE__ */ _export_sfc(_sfc_main$21, [["__scopeId", "data-v-744401de"]]);
62009
62037
  function convertPxToPaperSize(pageSize, customSize) {
62010
62038
  if (pageSize === PageSizeEnumConst.A3) {
62011
62039
  return {
@@ -63030,6 +63058,13 @@ const manifest$A = {
63030
63058
  defaultProps: {
63031
63059
  ...commonDefaultProps,
63032
63060
  autofillRules: []
63061
+ },
63062
+ computed: {
63063
+ defaultValueRule: {
63064
+ type: "api",
63065
+ fetcher: "ref",
63066
+ onlyMainModelFieldsCanRequest: true
63067
+ }
63033
63068
  }
63034
63069
  };
63035
63070
  const __vite_glob_0_13$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -63071,6 +63106,13 @@ const manifest$y = {
63071
63106
  defaultProps: {
63072
63107
  ...commonDefaultProps,
63073
63108
  autofillRules: []
63109
+ },
63110
+ computed: {
63111
+ defaultValueRule: {
63112
+ type: "api",
63113
+ fetcher: "ref",
63114
+ onlyMainModelFieldsCanRequest: true
63115
+ }
63074
63116
  }
63075
63117
  };
63076
63118
  const __vite_glob_0_15$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -63225,6 +63267,13 @@ const manifest$r = {
63225
63267
  defaultProps: {
63226
63268
  ...commonDefaultProps,
63227
63269
  autofillRules: []
63270
+ },
63271
+ computed: {
63272
+ defaultValueRule: {
63273
+ type: "api",
63274
+ fetcher: "ref",
63275
+ onlyMainModelFieldsCanRequest: true
63276
+ }
63228
63277
  }
63229
63278
  };
63230
63279
  const __vite_glob_0_22 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -63244,6 +63293,13 @@ const manifest$q = {
63244
63293
  defaultProps: {
63245
63294
  ...commonDefaultProps,
63246
63295
  autofillRules: []
63296
+ },
63297
+ computed: {
63298
+ defaultValueRule: {
63299
+ type: "api",
63300
+ fetcher: "rdo2ref",
63301
+ onlyMainModelFieldsCanRequest: true
63302
+ }
63247
63303
  }
63248
63304
  };
63249
63305
  const __vite_glob_0_23 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -63262,6 +63318,13 @@ const manifest$p = {
63262
63318
  propsSchema: "schema:field-business",
63263
63319
  defaultProps: {
63264
63320
  ...commonDefaultProps
63321
+ },
63322
+ computed: {
63323
+ defaultValueRule: {
63324
+ type: "api",
63325
+ fetcher: "lot2sn",
63326
+ onlyMainModelFieldsCanRequest: true
63327
+ }
63265
63328
  }
63266
63329
  };
63267
63330
  const __vite_glob_0_24 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -63303,6 +63366,13 @@ const manifest$n = {
63303
63366
  defaultProps: {
63304
63367
  ...commonDefaultProps,
63305
63368
  autofillRules: []
63369
+ },
63370
+ computed: {
63371
+ defaultValueRule: {
63372
+ type: "api",
63373
+ fetcher: "ref",
63374
+ onlyMainModelFieldsCanRequest: true
63375
+ }
63306
63376
  }
63307
63377
  };
63308
63378
  const __vite_glob_0_26 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -63415,7 +63485,10 @@ const manifest$i = {
63415
63485
  ...styleDefaultProps
63416
63486
  },
63417
63487
  computed: {
63418
- defaultValueRule: labelResolveEnumConfig,
63488
+ defaultValueRule: {
63489
+ ...labelResolveEnumConfig,
63490
+ isMulti: true
63491
+ },
63419
63492
  propRules: {
63420
63493
  computedOptions: optionsMapEnumConfig
63421
63494
  }
@@ -63551,6 +63624,13 @@ const manifest$c = {
63551
63624
  defaultProps: {
63552
63625
  ...commonDefaultProps,
63553
63626
  autofillRules: []
63627
+ },
63628
+ computed: {
63629
+ defaultValueRule: {
63630
+ type: "api",
63631
+ fetcher: "ref",
63632
+ onlyMainModelFieldsCanRequest: true
63633
+ }
63554
63634
  }
63555
63635
  };
63556
63636
  const __vite_glob_0_37 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -67405,14 +67485,17 @@ const _sfc_main$1y = /* @__PURE__ */ defineComponent({
67405
67485
  const designCtx = useDesignSuiteContext();
67406
67486
  const getFieldOptions = (modelKey) => {
67407
67487
  if (!modelKey) return [];
67408
- return designCtx.runtime.getFieldList(modelKey).filter((f) => f.createTime === "USER_DEFINED").map(({ key, name }) => ({ label: name, value: key }));
67488
+ return designCtx.runtime.getFieldList(modelKey).filter((f) => f.createType === "USER_DEFINED").map(({ key, name }) => ({ label: name, value: key }));
67409
67489
  };
67410
67490
  const props = __props;
67411
67491
  const sheetReadonly = ref(false);
67412
67492
  const optionsMap = computed(() => {
67413
67493
  const { mainModelKey, subFieldKey } = props.active.context;
67494
+ if (!mainModelKey || !subFieldKey) {
67495
+ return { row: [], col: [] };
67496
+ }
67414
67497
  const mainFields = designCtx.runtime.getFieldList(mainModelKey);
67415
- const [rowFieldKey, colFieldKey] = subFieldKey?.replace("$.", "").split(":") ?? [];
67498
+ const [rowFieldKey, colFieldKey] = subFieldKey.replace("$.", "").split(":") ?? [];
67416
67499
  const rowModelKey = mainFields.find((f) => f.key === rowFieldKey)?.bindInfo;
67417
67500
  const colModelKey = mainFields.find((f) => f.key === colFieldKey)?.bindInfo;
67418
67501
  return {
@@ -67489,11 +67572,11 @@ const _sfc_main$1y = /* @__PURE__ */ defineComponent({
67489
67572
  size: "small",
67490
67573
  allowClear: "",
67491
67574
  disabled: sheetReadonly.value,
67492
- value: unref(regionProps).refColField,
67493
- "onUpdate:value": _cache[1] || (_cache[1] = ($event) => unref(regionProps).refColField = $event),
67575
+ modelValue: unref(regionProps).refColField,
67576
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(regionProps).refColField = $event),
67494
67577
  placeholder: "请选择关联主键",
67495
67578
  options: optionsMap.value.col
67496
- }, null, 8, ["disabled", "value", "options"])
67579
+ }, null, 8, ["disabled", "modelValue", "options"])
67497
67580
  ]),
67498
67581
  _: 1
67499
67582
  }),
@@ -67506,11 +67589,11 @@ const _sfc_main$1y = /* @__PURE__ */ defineComponent({
67506
67589
  size: "small",
67507
67590
  allowClear: "",
67508
67591
  disabled: sheetReadonly.value,
67509
- value: unref(regionProps).refRowField,
67510
- "onUpdate:value": _cache[2] || (_cache[2] = ($event) => unref(regionProps).refRowField = $event),
67592
+ modelValue: unref(regionProps).refRowField,
67593
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(regionProps).refRowField = $event),
67511
67594
  placeholder: "请选择动态表关联关系建立",
67512
67595
  options: optionsMap.value.row
67513
- }, null, 8, ["disabled", "value", "options"])
67596
+ }, null, 8, ["disabled", "modelValue", "options"])
67514
67597
  ]),
67515
67598
  _: 1
67516
67599
  })
@@ -67522,7 +67605,7 @@ const _sfc_main$1y = /* @__PURE__ */ defineComponent({
67522
67605
  };
67523
67606
  }
67524
67607
  });
67525
- const DataGroup2DPanel = /* @__PURE__ */ _export_sfc(_sfc_main$1y, [["__scopeId", "data-v-09b6985e"]]);
67608
+ const DataGroup2DPanel = /* @__PURE__ */ _export_sfc(_sfc_main$1y, [["__scopeId", "data-v-6a36dc19"]]);
67526
67609
  const schema$6 = {
67527
67610
  key: "data-group-2d.basic",
67528
67611
  title: [