cloud-web-corejs 1.1.0-dev.80 → 1.1.0-dev.81

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.1.0-dev.80",
4
+ "version": "1.1.0-dev.81",
5
5
  "scripts": {
6
6
  "build:ace-resources": "node build/build-ace-resources.js",
7
7
  "build:tinymce-resources": "node build/build-tinymce-resources.js",
@@ -50,7 +50,7 @@
50
50
  |--------------|------|
51
51
  | **父级字段** | 传到后台的参数名,与数据集父级字段一致。可留空,留空时请求使用 `f_parent`(不会自动写回输入框)。值取当前节点「关联字段」,可以是 ID 或编码。 |
52
52
  | **有子节点标识** | 返回行里表示是否还有下级。可留空,留空时按 `f_has_child` 判断。`true`/`1` 可展开,`false`/`0` 为末级。 |
53
- | **传参脚本** | 可选。签名 `lazyParamScript(dataId, formCode, row)`。`row` 为当前选中行,根节点为 `null`。返回对象并入 `data`。**不使用**「请求访问」里的查询参数。 |
53
+ | **传参脚本** | 可选。签名见下文。展开**当前节点**拉下一级时执行;`row` 为该节点行,根节点 `row`/`level` 为 `null`。另有 `level`、`path`、`pathLabels`、`pathRows`、`levels`(与 onSelect 的 item 含义一致)。返回对象并入 `data`。**不使用**「请求访问」里的查询参数。 |
54
54
 
55
55
  ### 步骤 3:请求访问
56
56
 
@@ -139,13 +139,17 @@ this.getWidgetRef("a9").setValue(null);
139
139
 
140
140
  ### 3.3 传参脚本 lazyParamScript(可选)
141
141
 
142
- 展开非根节点时,把选中行其他字段带入 `data`:
142
+ 展开某节点请求下一级时执行(不是 onSelect)。除 `row` 外还可拿层级序号和各级行:
143
143
 
144
144
  ```js
145
- // lazyParamScript(dataId, formCode, row)
145
+ // lazyParamScript(dataId, formCode, row, level, path, pathLabels, pathRows, levels)
146
+ // 第一次展开根:row、level 均为 null,pathRows、levels 为空数组
146
147
  if (!row) return {};
148
+ // level:当前展开节点 0 省、1 市、2 区、3 镇
149
+ // pathRows[i]、levels[i].data 为第 i 级完整行
147
150
  return {
148
- f_code: row.f_code
151
+ f_code: row.f_code,
152
+ expand_level: level
149
153
  };
150
154
  ```
151
155
 
@@ -349,13 +349,49 @@ export default {
349
349
  error: abortLazyLoad,
350
350
  });
351
351
  },
352
+ // 展开节点时的路径上下文(与 onSelect 的 item 字段含义一致)
353
+ buildCascaderNodePathContext(node) {
354
+ if (!node || node.root || node.level === 0) {
355
+ return {
356
+ row: null,
357
+ level: null,
358
+ path: [],
359
+ pathLabels: [],
360
+ pathRows: [],
361
+ levels: [],
362
+ };
363
+ }
364
+ const path = node.path ? node.path.slice() : [];
365
+ const pathNodes = node.pathNodes || [];
366
+ const levels = pathNodes.map((seg, index) => ({
367
+ level: index,
368
+ value: seg.value,
369
+ label: seg.label,
370
+ data: seg.data || null,
371
+ }));
372
+ return {
373
+ row: node.data || null,
374
+ level: path.length ? path.length - 1 : 0,
375
+ path: path,
376
+ pathLabels: node.pathLabels ? node.pathLabels.slice() : [],
377
+ pathRows: pathNodes.map((seg) => seg.data || null),
378
+ levels: levels,
379
+ };
380
+ },
352
381
  // 传参脚本返回选中行上的其他字段。根节点没有选中行。
353
382
  resolveLazyRowParam(node) {
354
- const row = node && node.level > 0 ? node.data || null : null;
383
+ const ctx = this.buildCascaderNodePathContext(node);
355
384
  const rowParam = this.handleCustomEvent(
356
385
  this.field.options.lazyParamScript,
357
- ["row"],
358
- [row]
386
+ ["row", "level", "path", "pathLabels", "pathRows", "levels"],
387
+ [
388
+ ctx.row,
389
+ ctx.level,
390
+ ctx.path,
391
+ ctx.pathLabels,
392
+ ctx.pathRows,
393
+ ctx.levels,
394
+ ]
359
395
  );
360
396
  if (!rowParam || typeof rowParam !== "object" || Array.isArray(rowParam)) {
361
397
  return {};
@@ -540,26 +576,16 @@ export default {
540
576
  ? (editor.getCheckedNodes(false) || []).filter(Boolean)
541
577
  : [];
542
578
  const toItem = (node) => {
543
- const path = node.path ? node.path.slice() : [];
544
- const pathNodes = node.pathNodes || [];
545
- const levels = pathNodes.map((seg, index) => ({
546
- level: index,
547
- value: seg.value,
548
- label: seg.label,
549
- data: seg.data || null,
550
- }));
579
+ const ctx = this.buildCascaderNodePathContext(node);
551
580
  return {
552
581
  value: node.value,
553
582
  label: node.label,
554
- // 0 省、1 市、2 区、3 镇,对应当前选中节点
555
- level: path.length ? path.length - 1 : 0,
556
- path: path,
557
- pathLabels: node.pathLabels ? node.pathLabels.slice() : [],
558
- // 当前选中节点对应的后台行
559
- data: node.data || null,
560
- // 从根到当前每一级的完整行(含 tree_path 等)
561
- pathRows: pathNodes.map((seg) => seg.data || null),
562
- levels: levels,
583
+ level: ctx.level == null ? 0 : ctx.level,
584
+ path: ctx.path,
585
+ pathLabels: ctx.pathLabels,
586
+ data: ctx.row,
587
+ pathRows: ctx.pathRows,
588
+ levels: ctx.levels,
563
589
  };
564
590
  };
565
591
  const item = this.field.options.multiple
@@ -243,7 +243,9 @@ modules = {
243
243
  }
244
244
  if (eventName === "lazyParamScript" && !this.optionModel["lazyParamScript"]) {
245
245
  this.eventHandlerCode =
246
- " /* row 为当前选中行,根节点为 null。返回对象会并入请求 data。 */\n" +
246
+ " /* 展开节点请求下一级时执行。根节点 row 为 null,level 为 null。\n" +
247
+ " level:0 省、1 市、2 区、3 镇(当前展开节点)。\n" +
248
+ " pathRows / levels 为从根到当前展开节点的各级完整行。返回对象并入 data。 */\n" +
247
249
  " if (!row) return {};\n" +
248
250
  " return {\n" +
249
251
  " f_code: row.f_code\n" +
@@ -75,7 +75,16 @@ export default {
75
75
  },
76
76
  },
77
77
  lazyParamEventParams() {
78
- return ["dataId", "formCode", "row"];
78
+ return [
79
+ "dataId",
80
+ "formCode",
81
+ "row",
82
+ "level",
83
+ "path",
84
+ "pathLabels",
85
+ "pathRows",
86
+ "levels",
87
+ ];
79
88
  },
80
89
  },
81
90
  };