@steedos-labs/plugin-workflow 3.0.51 → 3.0.53

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.
@@ -139,7 +139,7 @@ function extractAggregationFieldRefs(formula) {
139
139
  * @returns {{ issues: object[], convertedResult: string|null }}
140
140
  */
141
141
  function checkFormula({ formula, tableFieldMap, formId, formName, formVersionType,
142
- field, fieldLocation, formulaSource, siblingCodes }) {
142
+ field, fieldLocation, formulaSource, siblingCodes, inSection }) {
143
143
 
144
144
  const fieldCode = field.code || '';
145
145
  const fieldType = field.type || '';
@@ -236,6 +236,21 @@ function checkFormula({ formula, tableFieldMap, formId, formName, formVersionTyp
236
236
  }
237
237
  }
238
238
 
239
+ // E6: 设计器 section 嵌套兼容性 — 检测设计器对 section 子字段传递 true 而非 tableFieldMap 的问题
240
+ if (inSection && convertedResult && tableFieldMap && Object.keys(tableFieldMap).length > 0) {
241
+ const designerResult = mapFormula(formula, true);
242
+ if (designerResult !== convertedResult) {
243
+ issues.push({
244
+ level: 'ERROR',
245
+ ruleId: 'E6',
246
+ ...baseInfo,
247
+ convertedResult,
248
+ errorDetail: `设计器兼容性: section 子字段公式转换结果与引擎不一致。引擎正确结果="${convertedResult}", 设计器结果="${designerResult}"。原因: flow_form_design.ejs 对 section 子字段传递 true 而非 tableFieldMap`,
249
+ siblingFields: siblingCodes,
250
+ });
251
+ }
252
+ }
253
+
239
254
  // W1: 除零风险(含除法且除数是字段引用)
240
255
  if (/\/\s*\{[^{}]+\}/.test(formula)) {
241
256
  issues.push({
@@ -278,9 +293,10 @@ function detectSafeCodeConflicts(codes) {
278
293
  * @param {object[]} fields
279
294
  * @param {object} tableFieldMap 顶层 getTableFieldMap 结果
280
295
  * @param {string} locationPrefix "top" 或 "table:{tableCode}"
281
- * @returns {object[]} 每项包含 field, formula, source, location, siblingCodes
296
+ * @param {boolean} inSection 是否嵌套在 section 内部
297
+ * @returns {object[]} 每项包含 field, formula, source, location, siblingCodes, inSection
282
298
  */
283
- function collectFormulaFields(fields, tableFieldMap, locationPrefix) {
299
+ function collectFormulaFields(fields, tableFieldMap, locationPrefix, inSection = false) {
284
300
  if (!Array.isArray(fields)) return [];
285
301
  const results = [];
286
302
 
@@ -293,7 +309,8 @@ function collectFormulaFields(fields, tableFieldMap, locationPrefix) {
293
309
  const childLocation = field.type === 'table'
294
310
  ? `table:${field.code}`
295
311
  : locationPrefix;
296
- results.push(...collectFormulaFields(field.fields, tableFieldMap, childLocation));
312
+ const childInSection = field.type === 'section' || inSection;
313
+ results.push(...collectFormulaFields(field.fields, tableFieldMap, childLocation, childInSection));
297
314
  }
298
315
 
299
316
  // formula 属性
@@ -304,6 +321,7 @@ function collectFormulaFields(fields, tableFieldMap, locationPrefix) {
304
321
  source: 'formula',
305
322
  location: locationPrefix,
306
323
  siblingCodes: siblingCodes.filter(c => c !== field.code),
324
+ inSection,
307
325
  });
308
326
  }
309
327
 
@@ -317,6 +335,7 @@ function collectFormulaFields(fields, tableFieldMap, locationPrefix) {
317
335
  source: 'default_value',
318
336
  location: locationPrefix,
319
337
  siblingCodes: siblingCodes.filter(c => c !== field.code),
338
+ inSection,
320
339
  });
321
340
  }
322
341
  }
@@ -352,7 +371,7 @@ function scanForm(form) {
352
371
  const tableFieldMap = getTableFieldMap(fields);
353
372
  const formulaFields = collectFormulaFields(fields, tableFieldMap, 'top');
354
373
 
355
- for (const { field, formula, source, location, siblingCodes } of formulaFields) {
374
+ for (const { field, formula, source, location, siblingCodes, inSection } of formulaFields) {
356
375
  const dedupeKey = JSON.stringify({ code: field.code, location, source, formula });
357
376
 
358
377
  // current 版本直接处理,history 版本若 current 已有则跳过
@@ -369,6 +388,7 @@ function scanForm(form) {
369
388
  fieldLocation: location,
370
389
  formulaSource: source,
371
390
  siblingCodes,
391
+ inSection,
372
392
  });
373
393
 
374
394
  const status = fieldIssues.length > 0
@@ -568,24 +568,25 @@ module.exports = {
568
568
  let spaceId = this.spaceId || this.doc?.space;
569
569
 
570
570
  let userSession = await auth.getSessionByUserId(userId, spaceId)
571
- let roles = userSession.roles;
572
- // 执行者的身份校验
573
- await desingerManager.checkSpaceUserBeforeUpdate(spaceId, userId, roles);
574
- // 更新表单
575
- await desingerManager.updateForm(this.id, form, updatedForms, updatedFlows, userId);
576
-
577
- const flows = await objectql.getObject('flows').directFind({
578
- filters: ['form', '=', this.id],
579
- fields: ['_id']
580
- });
581
-
582
- for (const flow of flows) {
583
- await objectql.getObject('flows').directUpdate(flow._id, {
584
- modified: new Date(),
585
- modified_by: userId
586
- })
571
+ if(userSession){
572
+ let roles = userSession.roles;
573
+ // 执行者的身份校验
574
+ await desingerManager.checkSpaceUserBeforeUpdate(spaceId, userId, roles);
575
+ // 更新表单
576
+ await desingerManager.updateForm(this.id, form, updatedForms, updatedFlows, userId);
577
+
578
+ const flows = await objectql.getObject('flows').directFind({
579
+ filters: ['form', '=', this.id],
580
+ fields: ['_id']
581
+ });
582
+
583
+ for (const flow of flows) {
584
+ await objectql.getObject('flows').directUpdate(flow._id, {
585
+ modified: new Date(),
586
+ modified_by: userId
587
+ })
588
+ }
587
589
  }
588
-
589
590
  }
590
591
 
591
592
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-labs/plugin-workflow",
3
- "version": "3.0.51",
3
+ "version": "3.0.53",
4
4
  "main": "package.service.js",
5
5
  "license": "MIT",
6
6
  "files": [