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

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.82",
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",
@@ -102,16 +102,11 @@ tmixins = {
102
102
  editFileSuffix: null,
103
103
  beforeUploadFlag: false,
104
104
  uploadUrl: null,
105
-
106
- access_key_id: "HPUAQ1TAFXWGOKSNKCGW", // 你的ak
107
- secret_access_key: "Ns1nwPwikK67Acbhj3wlfUambjbdroqpk0TFv7qg", // 你的sk
108
- server: "https://obs.cn-south-1.myhuaweicloud.com", // 你的endPoint 记得加入https://
109
- Bucket: "gztw-file01", // 你的桶名
110
105
  };
111
106
  },
112
- beforeDestroy() {
113
- this.removePasteEvent();
114
- this.revokeUploadObjectUrls();
107
+ beforeDestroy() {
108
+ this.removePasteEvent();
109
+ this.revokeUploadObjectUrls();
115
110
  },
116
111
  filters: {
117
112
  btnText(btn) {
@@ -348,7 +343,7 @@ tmixins = {
348
343
  blurPasteEvent() {
349
344
  this.pasteAreaStatus = false;
350
345
  },
351
- handleClose() {
346
+ handleClose() {
352
347
  let target = this.$refs.upload;
353
348
  (target.uploadFiles || []).forEach((uploadFile) => {
354
349
  if (uploadFile.status == "uploading" || uploadFile.status == "ready") {
@@ -357,15 +352,15 @@ tmixins = {
357
352
  this.$t2("取消上传", "components.VabUpload.cancelUpload")
358
353
  );
359
354
  }
360
- });
361
- this.revokeUploadObjectUrls();
362
- this.pasteList = [];
363
- this.removePasteEvent();
364
- this.picture = "picture";
365
- this.clearFileInfo();
366
- this.dialogFormVisible = false;
367
- const destroyRoot = this.$destroyOnDialogClose;
368
- if (destroyRoot) this.$nextTick(destroyRoot);
355
+ });
356
+ this.revokeUploadObjectUrls();
357
+ this.pasteList = [];
358
+ this.removePasteEvent();
359
+ this.picture = "picture";
360
+ this.clearFileInfo();
361
+ this.dialogFormVisible = false;
362
+ const destroyRoot = this.$destroyOnDialogClose;
363
+ if (destroyRoot) this.$nextTick(destroyRoot);
369
364
  },
370
365
  clearFileInfo() {
371
366
  this.fileList = [];
@@ -1208,33 +1203,33 @@ tmixins = {
1208
1203
  }
1209
1204
  },
1210
1205
  //end
1211
- getShowImage(file, fileName) {
1206
+ getShowImage(file, fileName) {
1212
1207
  fileName = fileName || file.name;
1213
1208
  if (this.$commonFileUtil.isPictureFile(fileName)) {
1214
1209
  return file.showUrl || file.url;
1215
1210
  } else {
1216
1211
  return this.$commonFileUtil.getFileIconRequire(fileName);
1217
1212
  }
1218
- },
1219
- revokeUploadObjectUrl(url) {
1220
- if (typeof url === "string" && url.startsWith("blob:")) {
1221
- URL.revokeObjectURL(url);
1222
- }
1223
- },
1224
- revokeUploadObjectUrls() {
1225
- const files = [
1226
- ...(this.fileList || []),
1227
- ...(this.pasteList || []),
1228
- ...(this.$refs.upload?.uploadFiles || []),
1229
- ];
1230
- const urls = new Set();
1231
- files.forEach((file) => {
1232
- if (file?.showUrl) urls.add(file.showUrl);
1233
- if (file?.url) urls.add(file.url);
1234
- });
1235
- urls.forEach((url) => this.revokeUploadObjectUrl(url));
1236
- },
1237
- removeFile(sfile) {
1213
+ },
1214
+ revokeUploadObjectUrl(url) {
1215
+ if (typeof url === "string" && url.startsWith("blob:")) {
1216
+ URL.revokeObjectURL(url);
1217
+ }
1218
+ },
1219
+ revokeUploadObjectUrls() {
1220
+ const files = [
1221
+ ...(this.fileList || []),
1222
+ ...(this.pasteList || []),
1223
+ ...(this.$refs.upload?.uploadFiles || []),
1224
+ ];
1225
+ const urls = new Set();
1226
+ files.forEach((file) => {
1227
+ if (file?.showUrl) urls.add(file.showUrl);
1228
+ if (file?.url) urls.add(file.url);
1229
+ });
1230
+ urls.forEach((url) => this.revokeUploadObjectUrl(url));
1231
+ },
1232
+ removeFile(sfile) {
1238
1233
  var target = this.$refs.upload;
1239
1234
  var index;
1240
1235
  var fileList = target.uploadFiles;
@@ -1255,8 +1250,8 @@ tmixins = {
1255
1250
  }
1256
1251
  }
1257
1252
 
1258
- this.revokeUploadObjectUrl(sfile?.showUrl || sfile?.url);
1259
- target.uploadFiles.splice(index, 1);
1253
+ this.revokeUploadObjectUrl(sfile?.showUrl || sfile?.url);
1254
+ target.uploadFiles.splice(index, 1);
1260
1255
  this.handleChange(sfile, target.uploadFiles);
1261
1256
  },
1262
1257
  submitImage() {
@@ -1466,10 +1461,10 @@ tmixins = {
1466
1461
  this.pasteList.push(...fileList);
1467
1462
  }
1468
1463
  },
1469
- deletePasteFile(index) {
1470
- const file = this.pasteList[index];
1471
- this.revokeUploadObjectUrl(file?.showUrl || file?.url);
1472
- this.pasteList.splice(index, 1);
1464
+ deletePasteFile(index) {
1465
+ const file = this.pasteList[index];
1466
+ this.revokeUploadObjectUrl(file?.showUrl || file?.url);
1467
+ this.pasteList.splice(index, 1);
1473
1468
  },
1474
1469
  confirmPasteFile() {
1475
1470
  let target = this.$refs.upload;
@@ -1481,10 +1476,10 @@ tmixins = {
1481
1476
  fileRaw.fileName = name;
1482
1477
  return fileRaw;
1483
1478
  });
1484
- innerTarget.uploadFiles(files);
1485
- this.pasteList.forEach((file) =>
1486
- this.revokeUploadObjectUrl(file?.showUrl || file?.url)
1487
- );
1479
+ innerTarget.uploadFiles(files);
1480
+ this.pasteList.forEach((file) =>
1481
+ this.revokeUploadObjectUrl(file?.showUrl || file?.url)
1482
+ );
1488
1483
  this.$nextTick(() => {
1489
1484
  target.uploadFiles.forEach((uploadFile) => {
1490
1485
  let fileRaw = uploadFile.raw;
@@ -1494,7 +1489,7 @@ tmixins = {
1494
1489
  }
1495
1490
  });
1496
1491
  });
1497
- this.pasteList = [];
1492
+ this.pasteList = [];
1498
1493
  },
1499
1494
  changeFileName(file) {
1500
1495
  if (file.fileSuffix) {
@@ -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
  };