weaver-e10-builder 1.6.0 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/commands/check.d.ts.map +1 -1
  2. package/dist/commands/check.js +109 -51
  3. package/dist/commands/check.js.map +1 -1
  4. package/dist/commands/form-attachment-setting.d.ts +3 -0
  5. package/dist/commands/form-attachment-setting.d.ts.map +1 -0
  6. package/dist/commands/form-attachment-setting.js +422 -0
  7. package/dist/commands/form-attachment-setting.js.map +1 -0
  8. package/dist/commands/form-data.d.ts.map +1 -1
  9. package/dist/commands/form-data.js +49 -1
  10. package/dist/commands/form-data.js.map +1 -1
  11. package/dist/commands/form-field-linkage.d.ts +6 -1
  12. package/dist/commands/form-field-linkage.d.ts.map +1 -1
  13. package/dist/commands/form-field-linkage.js +138 -31
  14. package/dist/commands/form-field-linkage.js.map +1 -1
  15. package/dist/commands/form.d.ts.map +1 -1
  16. package/dist/commands/form.js +47 -2
  17. package/dist/commands/form.js.map +1 -1
  18. package/dist/commands/project.d.ts.map +1 -1
  19. package/dist/commands/project.js +39 -6
  20. package/dist/commands/project.js.map +1 -1
  21. package/dist/services/form-attachment-settings.d.ts +110 -0
  22. package/dist/services/form-attachment-settings.d.ts.map +1 -0
  23. package/dist/services/form-attachment-settings.js +332 -0
  24. package/dist/services/form-attachment-settings.js.map +1 -0
  25. package/dist/services/form-attachment-upload.d.ts +30 -0
  26. package/dist/services/form-attachment-upload.d.ts.map +1 -0
  27. package/dist/services/form-attachment-upload.js +76 -0
  28. package/dist/services/form-attachment-upload.js.map +1 -0
  29. package/dist/services/form-data-openapi.d.ts +2 -0
  30. package/dist/services/form-data-openapi.d.ts.map +1 -1
  31. package/dist/services/form-data-openapi.js +1 -0
  32. package/dist/services/form-data-openapi.js.map +1 -1
  33. package/package.json +1 -1
  34. package/skill-docs/SKILL.md +163 -160
  35. package/skill-docs/_catalog.md +6 -4
  36. package/skill-docs/assets/sample/api/formApi.js +689 -510
  37. package/skill-docs/assets/sample/app/config.js +4 -0
  38. package/skill-docs/assets/sample/app/fields.js +25 -0
  39. package/skill-docs/assets/sample/entry.js +24 -22
  40. package/skill-docs/assets/sample/eslint.config.cjs +1 -0
  41. package/skill-docs/assets/sample/pages/Items.js +247 -0
  42. package/skill-docs/assets/sample/styles/prototypeStyles.js +137 -0
  43. package/skill-docs/references/coding/guide-edit-backfill.md +102 -150
  44. package/skill-docs/references/coding/guide-form-crud.md +195 -172
  45. package/skill-docs/references/coding/guide-html-to-react.md +250 -0
  46. package/skill-docs/references/coding/guide-page-code.md +194 -167
  47. package/skill-docs/references/coding/guide-page-export.md +27 -18
  48. package/skill-docs/references/coding/ref-compile-rules.md +7 -7
  49. package/skill-docs/references/common/map.md +2 -1
  50. package/skill-docs/references/common/ref-cli-commands.md +13 -6
  51. package/skill-docs/references/components/display-FilePreview.md +5 -4
  52. package/skill-docs/references/form/guide-field-linkage.md +4 -1
  53. package/skill-docs/references/form/guide-form-attachment-setting.md +95 -0
  54. package/skill-docs/references/form/guide-form-data.md +22 -1
  55. package/skill-docs/assets/sample/config/config.js +0 -0
  56. package/skill-docs/assets/sample/config/configLoad.js +0 -0
  57. package/skill-docs/assets/sample/config/configLoad_default.js +0 -0
  58. package/skill-docs/assets/sample/config/config_default.js +0 -0
  59. package/skill-docs/assets/sample/memo.md +0 -0
  60. package/skill-docs/assets/sample/readme.js +0 -8
@@ -46,12 +46,17 @@ export declare function buildQuickSaveDesign(p: {
46
46
  selfFields: any[];
47
47
  srcFormObjId: string;
48
48
  srcFormName: string;
49
+ srcTableName?: string;
49
50
  conditions: QuickCondition[];
50
51
  queryFields: any[];
51
52
  assigns: QuickAssign[];
52
53
  /** 本表明细表;有明细目标时才会写进 formFields 与 Output.tableList。 */
53
54
  details: FormDetail[];
54
- /** 明细表 id → 依据值字段(源表查询结果列)。 */
55
+ /**
56
+ * 明细表 id → 依据值字段(源表查询结果列)。
57
+ * **不给 = 依据值选「表」**(查询结果整表),这是设计器里写明细的常规形态;
58
+ * 只有显式 `--basis 明细表=源表字段` 才走字段级依据。
59
+ */
55
60
  basis: Map<string, any>;
56
61
  }): any;
57
62
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"form-field-linkage.d.ts","sourceRoot":"","sources":["../../src/commands/form-field-linkage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiBpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAqG3E,uDAAuD;AACvD,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE;IAC7D,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAC;IACzE,cAAc,EAAE,GAAG,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAC9C,uBAAuB;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChG,GAAG,GAAG,CAwBN;AAYD,UAAU,UAAU;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,EAAE,CAAA;CAAE;AAsBhE,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CA4WtF;AA2bD,UAAU,WAAW;IAAG,QAAQ,EAAE,GAAG,CAAC;IAAC,WAAW,EAAE,GAAG,CAAC;IAAC,OAAO,CAAC,EAAE,UAAU,CAAC;CAAE;AAoEhF,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE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AC;IAAC,OAAO,EAAE,WAAW,EAAE,CAAC;IAC3C,sDAAsD;IACtD,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB;;;;OAIG;IACH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACzB,GAAG,GAAG,CA6RN"}
@@ -142,7 +142,11 @@ async function getFormId(client, baseUrl, appId, objId) {
142
142
  const f = await resolveFormRecord(client, baseUrl, appId, objId);
143
143
  if (!f?.formId)
144
144
  throw new Error(`无法获取 formId,请确认 objId=${objId}`);
145
- return { formId: String(f.formId), formName: f.formName || f.objName || f.name || '' };
145
+ return {
146
+ formId: String(f.formId),
147
+ formName: f.formName || f.objName || f.name || '',
148
+ tableName: String(f.tableName || ''),
149
+ };
146
150
  }
147
151
  /** 主表字段 + 明细表(字段联动可以把值写到明细表,需要 subFormId)。 */
148
152
  async function getFormMeta(client, baseUrl, objId, userId, tenantKey) {
@@ -475,7 +479,7 @@ export function registerFormFieldLinkageCommands(form, program) {
475
479
  .option('--condition <expr>', '查询条件:源表字段:算子:值;值写 @本表字段名 表示引用本表字段', collect, [])
476
480
  .option('--query-fields <list>', '查询字段:源表字段名,逗号分隔(不给则从 --assign 的源字段推导)')
477
481
  .option('--assign <expr>', '赋值:源表查询字段=本表目标字段(写「明细表名.字段名」则赋到明细表;可重复)', collect, [])
478
- .option('--basis <expr>', '明细行依据:明细表名=源表字段名(可重复;不给则取该表第一个赋值的源字段)', collect, [])
482
+ .option('--basis <expr>', '明细行依据:明细表名=源表字段名(可重复;不给则用查询结果整表,即设计器里的「选表」)', collect, [])
479
483
  .option('--detail-mode <mode>', '主表联动明细表时: add=添加明细(默认)/ cover=覆盖明细 / update=更新明细')
480
484
  .option('--detail-add <mode>', '明细表添加行时: override=删除已联动出的明细再添加(默认)/ append=累计添加明细')
481
485
  .option('--fission <onoff>', '联动出的值继续触发联动: on(默认)/ off')
@@ -594,6 +598,46 @@ export function registerFormFieldLinkageCommands(form, program) {
594
598
  console.log(opts.json ? JSON.stringify({ success: true, linkageId, esbAppId, inFields: inF, outFields: outF }) : `字段联动已创建: [${linkageId}] ${cmdOpts.trigger}→${lastHop.queryFieldName} in:${inF} out:${outF}`);
595
599
  });
596
600
  }
601
+ /**
602
+ * Output 赋值公式:查询结果固定取第 0 行。
603
+ *
604
+ * 设计器按 `multTypeObj` 还原「设置查询数据」的取值方式:带节点 businessId 会显示成
605
+ * 「全部」,运行期拿到的是列表,赋不进单值字段;空下标 `[]` + childs 里的 `0`
606
+ * 才是「第 0 行」。查询条件是按数据 ID 精确过滤,结果最多一行,取第 0 行即可。
607
+ */
608
+ function buildOutputFormulaValue(p) {
609
+ const sid = String(p.srcField.fieldId);
610
+ const paramKey = `${p.srcFormObjId}[].field_${sid}`;
611
+ const parentName = `${p.srcFormName}[].${p.srcField.fieldName}`;
612
+ const rowRef = genSfId();
613
+ const formulaId = genSfId();
614
+ return {
615
+ paramKey, paramName: `field_${sid}`, showName: String(p.srcField.fieldName), paramType: 'string',
616
+ dataType: 'attribute', arrs: false, paramTypeString: 'STRING', dataTypeSting: 'ATTRIBUTE',
617
+ formulaId: '0', name: String(p.srcField.fieldName), source: p.sourceWId,
618
+ value: `FormData.${p.srcFormObjId}[${rowRef}].field_${sid}`, type: '3', formulaType: 'string',
619
+ frontId: genSfId(), businessId: genSfId(), id: formulaId, applicationId: p.esbAppId,
620
+ childs: [{
621
+ formulaType: 'string', name: '0', id: genSfId(), position: rowRef,
622
+ type: '1', value: '0', childs: [],
623
+ config: { tempFormulaId: formulaId, tempId: genSfId(), formulaVersion: 'V1' },
624
+ parentId: formulaId,
625
+ }],
626
+ config: {
627
+ paramKey, paramType: 'string',
628
+ parentName, newParentName: parentName,
629
+ comId: p.sourceWId, isMultCom: false, tableName: '表单数据',
630
+ fieldInfo: { tablePrimaryKey: 'FormData', paramKey }, switchType: 'assign',
631
+ formulaVersion: 'V1', parentComId: 0, multName: '', multKey: '',
632
+ multTypeObj: {
633
+ currentName: parentName, allName: parentName,
634
+ currentParamKey: `FormData.${p.srcFormObjId}[].field_${sid}`,
635
+ allParamKey: `FormData.${p.srcFormObjId}[].field_${sid}`,
636
+ },
637
+ },
638
+ parentId: '0', switchType: 'assign',
639
+ };
640
+ }
597
641
  // ─── saveDesign(FieldLinkage 触发 + N EnquiryForm 链式查询 + Output 赋值)───
598
642
  function buildSaveDesign(p) {
599
643
  const eventId = genSfId();
@@ -637,8 +681,6 @@ function buildSaveDesign(p) {
637
681
  // Output(赋值:最后一跳的查询结果 → 本表目标字段)
638
682
  const outWId = genSfId();
639
683
  const lastHop = p.hops[p.hops.length - 1];
640
- const outBizId = genSfId();
641
- const outParamKey = `${lastHop.srcFormObjId}[].field_${lastHop.queryFieldId}`;
642
684
  const outputAction = {
643
685
  id: outWId, wId: outWId, nodeType: 'Normal', comType: 'Output', type: 'Output',
644
686
  previousId: prevWId, parentId: '0', name: '设置赋值字段', isAdd: true, isOpen: false, componentName: '终止', attr: { icon: 'Icon-termination-1' }, isControl: true,
@@ -646,7 +688,7 @@ function buildSaveDesign(p) {
646
688
  outputStatus: '1', pageAction: '0', reminder: '0', fixedData: [], triggerFlag: false, nextAction: false, customOutputData: '', currentApplication: p.esbAppId,
647
689
  fieldLinkCustomParamSetting: {
648
690
  customId: '', formType: 'output', businessModule: '',
649
- tableList: [{ id: genSfId(), formId: p.selfFormId, showName: p.selfFormName, orderNum: 0, main: true, isMain: true, fields: [{ id: genSfId(), paramName: '', showName: '', paramType: 'string', isRequired: false, fieldComments: '', skipNull: '0', assignFieldId: p.targetFieldId, fieldPath: `${p.selfFormId}.${p.targetFieldId}`, fieldType: 'Ebuilder', formulaValue: { paramKey: outParamKey, paramName: `field_${lastHop.queryFieldId}`, showName: lastHop.queryFieldName, paramType: 'string', dataType: 'attribute', arrs: false, paramTypeString: 'STRING', dataTypeSting: 'ATTRIBUTE', formulaId: '0', name: lastHop.queryFieldName, source: prevWId, value: `FormData.${lastHop.srcFormObjId}[${outBizId}].field_${lastHop.queryFieldId}`, type: '3', formulaType: 'string', config: { paramKey: outParamKey, paramType: 'string', parentName: `${lastHop.srcFormName}[].${lastHop.queryFieldName}`, newParentName: `${lastHop.srcFormName}[].${lastHop.queryFieldName}`, comId: prevWId, isMultCom: false, tableName: '表单数据', fieldInfo: { tablePrimaryKey: 'FormData', paramKey: outParamKey }, switchType: 'assign' }, switchType: 'assign' } }] }],
691
+ tableList: [{ id: genSfId(), formId: p.selfFormId, showName: p.selfFormName, orderNum: 0, main: true, isMain: true, fields: [{ id: genSfId(), paramName: '', showName: '', paramType: 'string', isRequired: false, fieldComments: '', skipNull: '0', assignFieldId: p.targetFieldId, fieldPath: `${p.selfFormId}.${p.targetFieldId}`, fieldType: 'Ebuilder', formulaValue: buildOutputFormulaValue({ srcFormObjId: lastHop.srcFormObjId, srcFormName: lastHop.srcFormName, srcField: { fieldId: lastHop.queryFieldId, fieldName: lastHop.queryFieldName }, sourceWId: prevWId, esbAppId: p.esbAppId }) }] }],
650
692
  deleteTableIds: [], appId: p.esbAppId,
651
693
  }, applicationId: p.esbAppId,
652
694
  },
@@ -912,7 +954,7 @@ async function addQuickLinkage(p) {
912
954
  console.error('快捷配置需要至少一个 --condition');
913
955
  process.exit(1);
914
956
  }
915
- const { formName: srcFormName } = await getFormId(client, baseUrl, appId, cmdOpts.sourceForm);
957
+ const { formName: srcFormName, tableName: srcTableName } = await getFormId(client, baseUrl, appId, cmdOpts.sourceForm);
916
958
  const srcFields = await getFormFields(client, baseUrl, cmdOpts.sourceForm, auth.userId, auth.tenantKey);
917
959
  const condList = cmdOpts.condition.map(expr => {
918
960
  const c = parseConditionExpr(expr, srcFields);
@@ -932,7 +974,7 @@ async function addQuickLinkage(p) {
932
974
  }
933
975
  return { srcField, targetField: findFieldId(detail.fields, t.field), subForm: detail };
934
976
  });
935
- // 明细行依据:用户指定,缺省取该表第一个赋值的源字段(设计器里「依据值本身」那种配置)
977
+ // 明细行依据:显式 --basis 才走字段级;缺省由 buildQuickSaveDesign 用「选表」
936
978
  const basis = new Map();
937
979
  for (const expr of cmdOpts.basis || []) {
938
980
  const i = expr.indexOf('=');
@@ -948,10 +990,8 @@ async function addQuickLinkage(p) {
948
990
  }
949
991
  basis.set(detail.id, findFieldId(srcFields, expr.slice(i + 1).trim()));
950
992
  }
951
- for (const a of assignPairs) {
952
- if (a.subForm && !basis.has(a.subForm.id))
953
- basis.set(a.subForm.id, a.srcField);
954
- }
993
+ // 不给 --basis 时用「选表」作为明细行依据(查询结果整表),不再默认取第一个赋值源字段。
994
+ // 字段级依据只在显式 --basis 明细表=源表字段 时使用。
955
995
  const queryNames = cmdOpts.queryFields
956
996
  ? cmdOpts.queryFields.split(',').map(s => s.trim()).filter(Boolean)
957
997
  : [];
@@ -985,7 +1025,7 @@ async function addQuickLinkage(p) {
985
1025
  const design = buildQuickSaveDesign({
986
1026
  esbAppId, sceneId, lightId: FIELD_LINKAGE_LIGHT_ID, appName: linkageName,
987
1027
  selfFormId, selfFormName, appId, selfFields,
988
- srcFormObjId: cmdOpts.sourceForm, srcFormName,
1028
+ srcFormObjId: cmdOpts.sourceForm, srcFormName, srcTableName,
989
1029
  conditions: condList,
990
1030
  queryFields, assigns: assignPairs,
991
1031
  details: selfDetails, basis,
@@ -1209,23 +1249,10 @@ export function buildQuickSaveDesign(p) {
1209
1249
  };
1210
1250
  const outWId = genSfId();
1211
1251
  const mainTableId = genSfId();
1212
- const baseFormulaValue = (sf) => {
1213
- const sid = String(sf.fieldId);
1214
- const paramKey = `${p.srcFormObjId}[].field_${sid}`;
1215
- return {
1216
- paramKey, paramName: `field_${sid}`, showName: String(sf.fieldName), paramType: 'string',
1217
- dataType: 'attribute', arrs: false, paramTypeString: 'STRING', dataTypeSting: 'ATTRIBUTE',
1218
- formulaId: '0', name: String(sf.fieldName), source: eqWId,
1219
- value: `FormData.${p.srcFormObjId}[${genSfId()}].field_${sid}`, type: '3', formulaType: 'string',
1220
- config: {
1221
- paramKey, paramType: 'string',
1222
- parentName: `${p.srcFormName}[].${sf.fieldName}`, newParentName: `${p.srcFormName}[].${sf.fieldName}`,
1223
- comId: eqWId, isMultCom: false, tableName: '表单数据',
1224
- fieldInfo: { tablePrimaryKey: 'FormData', paramKey }, switchType: 'assign',
1225
- },
1226
- switchType: 'assign',
1227
- };
1228
- };
1252
+ const baseFormulaValue = (sf) => buildOutputFormulaValue({
1253
+ srcFormObjId: p.srcFormObjId, srcFormName: p.srcFormName, srcField: sf,
1254
+ sourceWId: eqWId, esbAppId: p.esbAppId,
1255
+ });
1229
1256
  /** 明细字段被赋的源字段正好是「依据值」时,设计器存的是 esbAssignSelf。 */
1230
1257
  const buildAssignField = (a, tableId, basisField) => {
1231
1258
  const sf = a.srcField;
@@ -1278,6 +1305,83 @@ export function buildQuickSaveDesign(p) {
1278
1305
  applicationId: p.esbAppId, businessId: genSfId(), fieldType: 'string',
1279
1306
  };
1280
1307
  };
1308
+ // 「依据值 = 表」:设计器里选的是查询结果整表,而不是某个字段/数据ID。
1309
+ // 明细赋值走 type=10:value 只写 field_<源字段>,config.value/config.config 指回整表结果。
1310
+ const srcTableLabel = p.srcTableName ? `${p.srcFormName}(${p.srcTableName})` : p.srcFormName;
1311
+ const srcTableParentName = `${srcTableLabel}[]`;
1312
+ const srcTableValue = `FormData.${p.srcFormObjId}[]`;
1313
+ const srcTableParamKey = `${p.srcFormObjId}[]`;
1314
+ const buildSrcTableConfig = () => ({
1315
+ paramKey: srcTableParamKey,
1316
+ isMultCom: false,
1317
+ comType: 'EnquiryForm',
1318
+ switchType: 'assign',
1319
+ parentComId: 0,
1320
+ formulaVersion: 'V1',
1321
+ fieldInfo: { paramKey: srcTableParamKey, tablePrimaryKey: 'FormData' },
1322
+ tableName: '表单数据',
1323
+ paramType: 'string',
1324
+ parentName: srcTableParentName,
1325
+ multName: '',
1326
+ multKey: '',
1327
+ multTypeObj: {
1328
+ allName: srcTableParentName,
1329
+ currentName: srcTableParentName,
1330
+ currentParamKey: srcTableValue,
1331
+ allParamKey: srcTableValue,
1332
+ },
1333
+ comId: eqWId,
1334
+ newParentName: srcTableParentName,
1335
+ });
1336
+ const buildTableBasisValue = () => ({
1337
+ frontId: p.srcFormObjId,
1338
+ formulaType: 'json',
1339
+ name: srcTableLabel,
1340
+ businessId: genSfId(),
1341
+ id: genSfId(),
1342
+ source: eqWId,
1343
+ type: '3',
1344
+ applicationId: p.esbAppId,
1345
+ value: srcTableValue,
1346
+ childs: [],
1347
+ config: buildSrcTableConfig(),
1348
+ parentId: '0',
1349
+ });
1350
+ const buildTableBasisAssign = (a, tableId) => {
1351
+ const sf = a.srcField;
1352
+ const tf = a.targetField;
1353
+ const sid = String(sf.fieldId);
1354
+ return {
1355
+ id: genSfId(), paramName: '', showName: '', paramType: 'string', isRequired: false,
1356
+ fieldComments: '', skipNull: '1', assignFieldId: String(tf.fieldId),
1357
+ fieldPath: `${tableId}.${tf.fieldId}`, fieldType: String(tf.fieldKey || 'Text'), switchType: 'sub',
1358
+ formulaValue: {
1359
+ formulaType: 'string',
1360
+ name: String(sf.fieldName),
1361
+ businessId: genSfId(),
1362
+ id: genSfId(),
1363
+ type: '10',
1364
+ applicationId: p.esbAppId,
1365
+ value: `field_${sid}`,
1366
+ childs: [],
1367
+ config: {
1368
+ frontId: genSfId(),
1369
+ paramKey: `${p.srcFormObjId}[].field_${sid}`,
1370
+ basisType: 'formSetting',
1371
+ switchType: 'sub',
1372
+ level: 1,
1373
+ id: `field_${sid}`,
1374
+ source: eqWId,
1375
+ formulaVersion: 'V1',
1376
+ value: srcTableValue,
1377
+ config: buildSrcTableConfig(),
1378
+ originValue: `field_${sid}`,
1379
+ content: String(sf.fieldName),
1380
+ },
1381
+ parentId: '0',
1382
+ },
1383
+ };
1384
+ };
1281
1385
  const tableList = [{
1282
1386
  id: mainTableId, formId: p.selfFormId, showName: p.selfFormName, orderNum: 0,
1283
1387
  fields: p.assigns.filter(a => !a.subForm).map(a => buildAssignField(a, mainTableId)),
@@ -1289,11 +1393,14 @@ export function buildQuickSaveDesign(p) {
1289
1393
  continue;
1290
1394
  const detTableId = genSfId();
1291
1395
  const basisField = p.basis.get(det.id);
1396
+ // 显式 --basis 才走字段级依据;缺省是「选表」。
1292
1397
  tableList.push({
1293
1398
  id: detTableId, formId: det.id, showName: det.name, orderNum: 1,
1294
- fields: detAssigns.map(a => buildAssignField(a, detTableId, basisField)),
1399
+ fields: detAssigns.map(a => basisField
1400
+ ? buildAssignField(a, detTableId, basisField)
1401
+ : buildTableBasisAssign(a, detTableId)),
1295
1402
  main: false, isMain: false,
1296
- ...(basisField ? { basisValue: buildBasisValue(basisField) } : {}),
1403
+ basisValue: basisField ? buildBasisValue(basisField) : buildTableBasisValue(),
1297
1404
  });
1298
1405
  }
1299
1406
  const detailFormFields = p.details