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

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.79",
4
+ "version": "1.1.0-dev.80",
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",
@@ -99,7 +99,10 @@
99
99
  `onSelect(dataId, formCode, value, oldValue, item, rowData, rowIndex)`
100
100
 
101
101
  - `item.level`:**固定**,当前选到的级别 `0` 省、`1` 市、`2` 区、`3` 镇。
102
- - `item.data`:**固定**,当前选中行的原始数据;`tree_path`、`tree_path_name` 需列表接口返回。
102
+ - `item.data`:**固定**,当前选中节点对应的后台行。
103
+ - `item.pathRows`:**固定**,从省到当前选中节点,每一级的后台行数组(与 `path` 下标一一对应)。
104
+ - `item.levels`:**固定**,同上,但每项为 `{ level, value, label, data }`。
105
+ - 整路径的 `tree_path`、`tree_path_name` 仍在**当前选中行** `item.data` 上(英文逗号分隔);各级单独字段可用 `item.pathRows[i]` 或 `item.levels[i].data`。
103
106
 
104
107
  只选到某一级时,更高级别写入,更低级别清空。
105
108
 
@@ -225,6 +228,7 @@ this.getFormRef().getWidgetRef("a1").reloadLazyNodes();
225
228
  | 详情回显 | 全称 a1 不入库时,**不必**在 `onMounted` 里回显 a1;分字段由详情接口赋值即可。 |
226
229
  | 只读展示 | 懒加载只读展示依赖已加载节点;未展开过的路径可能只显示原始值。 |
227
230
  | 自定义懒加载 | 未启用「请求后台脚本」时使用 `onLazyLoad(node, resolve)`,须调用 `resolve(节点数组)`;启用后**不执行** onLazyLoad。 |
231
+ | 请求失败重试 | 后台报错时不能把节点当成「已加载」。走请求访问时,失败会保持 `loaded=false`,再次展开同一节点会重新发包。成功但无子级时 `resolve([])` 仍视为已加载。 |
228
232
  | initLazyChecked | 若需仅用脚本展示全称且不写 formModel,可调用组件方法 `initLazyChecked([{ value, label }, ...])`;与「每次打开全称空白」场景二选一。 |
229
233
 
230
234
  ---
@@ -289,10 +289,18 @@ export default {
289
289
  this.rememberLazyNodes(node, nodes);
290
290
  resolve(nodes);
291
291
  };
292
+ const abortLazyLoad = () => {
293
+ if (settled) return;
294
+ settled = true;
295
+ if (node) {
296
+ node.loading = false;
297
+ node.loaded = false;
298
+ }
299
+ };
292
300
  try {
293
301
  this.handleCustomEvent(handler, ["node", "resolve"], [node, done]);
294
302
  } catch (e) {
295
- done([]);
303
+ abortLazyLoad();
296
304
  }
297
305
  },
298
306
  // 展开节点时复用「请求访问」的脚本编码。查询参数不参与懒加载
@@ -312,6 +320,15 @@ export default {
312
320
  this.rememberLazyNodes(node, nodes);
313
321
  resolve(nodes);
314
322
  };
323
+ // 请求失败不能 resolve([]):Element 会把 node.loaded 置 true,之后不再 lazyLoad
324
+ const abortLazyLoad = () => {
325
+ if (settled) return;
326
+ settled = true;
327
+ if (node) {
328
+ node.loading = false;
329
+ node.loaded = false;
330
+ }
331
+ };
315
332
  this.formHttp({
316
333
  scriptCode: this.field.options.formScriptCode || "getList",
317
334
  ...this.getQueryConditionHttpOption(),
@@ -328,8 +345,8 @@ export default {
328
345
  if (Array.isArray(handled)) rows = handled;
329
346
  done(rows);
330
347
  },
331
- fail: () => done([]),
332
- error: () => done([]),
348
+ fail: abortLazyLoad,
349
+ error: abortLazyLoad,
333
350
  });
334
351
  },
335
352
  // 传参脚本返回选中行上的其他字段。根节点没有选中行。
@@ -524,6 +541,13 @@ export default {
524
541
  : [];
525
542
  const toItem = (node) => {
526
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
+ }));
527
551
  return {
528
552
  value: node.value,
529
553
  label: node.label,
@@ -531,7 +555,11 @@ export default {
531
555
  level: path.length ? path.length - 1 : 0,
532
556
  path: path,
533
557
  pathLabels: node.pathLabels ? node.pathLabels.slice() : [],
558
+ // 当前选中节点对应的后台行
534
559
  data: node.data || null,
560
+ // 从根到当前每一级的完整行(含 tree_path 等)
561
+ pathRows: pathNodes.map((seg) => seg.data || null),
562
+ levels: levels,
535
563
  };
536
564
  };
537
565
  const item = this.field.options.multiple
@@ -258,7 +258,7 @@ modules = {
258
258
  this.eventHandlerCode =
259
259
  " /* item 为选中节点。清空走 onClear,不会进这里。\n" +
260
260
  " item.level:0 省、1 市、2 区、3 镇。\n" +
261
- " item.data 为当前行,tree_path、tree_path_name 以英文逗号分隔。 */";
261
+ " item.data 为当前选中行;item.pathRows / item.levels 为各级完整行。 */";
262
262
  }
263
263
  if (eventName === "onLazyLoad" && !this.optionModel["onLazyLoad"]) {
264
264
  this.eventHandlerCode =