cloud-web-corejs-haier 1.0.47 → 1.0.48
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
|
@@ -2446,30 +2446,53 @@ modules = {
|
|
|
2446
2446
|
let treeTaBm = newFormData.treeTaBm || [];
|
|
2447
2447
|
treeTaBm.push(formTemplateTableDTO.tableAlias);
|
|
2448
2448
|
newFormData.treeTaBm = treeTaBm;
|
|
2449
|
+
// 树的主键以 treeConfig.rowField 为准:transform 模式下 vxe 是用它
|
|
2450
|
+
// (xe-utils toArrayTree 的 key) 建树的,根节点判定必须与之同源,
|
|
2451
|
+
// 否则判出来的顶层节点和表格里的实际层级对不上。
|
|
2452
|
+
let idField = $grid.treeConfig.rowField || "id";
|
|
2449
2453
|
let tableDatas = this.$baseLodash.cloneDeep(
|
|
2450
2454
|
formDataModel[formTemplateTableDTO.name] || []
|
|
2451
2455
|
);
|
|
2456
|
+
// 根节点判定必须在下面清空临时 id 之前完成:新增子行的父 id 是
|
|
2457
|
+
// "row_xxx",清空后变成空值,之后再判定就会被误判成根节点,既提交成
|
|
2458
|
+
// 顶层节点又已嵌在父行的 children 里,造成重复与层级错乱。
|
|
2459
|
+
// 判定口径与 toArrayTree 一致:父值为空(null/undefined/""/0/"0")视为
|
|
2460
|
+
// 根;父值非空但父行不在本表数据里(过滤/查询后的孤儿行)也要收进顶层
|
|
2461
|
+
// 数组,否则整棵子树被静默丢弃——它的 parentField 原值保留不清空,
|
|
2462
|
+
// 后端据此重新挂接到既有父节点。
|
|
2463
|
+
let idSet = new Set();
|
|
2452
2464
|
tableDatas.forEach((tableData) => {
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
&& tableData.id.startsWith("row_")
|
|
2457
|
-
) {
|
|
2458
|
-
tableData.id = null;
|
|
2465
|
+
let id = tableData[idField];
|
|
2466
|
+
if (id !== null && id !== undefined && id !== "") {
|
|
2467
|
+
idSet.add(String(id));
|
|
2459
2468
|
}
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
tableData[parentField] = null;
|
|
2469
|
+
});
|
|
2470
|
+
let isRootFlags = tableDatas.map((tableData) => {
|
|
2471
|
+
let parentValue = tableData[parentField];
|
|
2472
|
+
if ([null, undefined, "", 0, "0"].includes(parentValue)) {
|
|
2473
|
+
return true;
|
|
2466
2474
|
}
|
|
2475
|
+
return !idSet.has(String(parentValue));
|
|
2476
|
+
});
|
|
2477
|
+
// 临时 id 要连字面量 id 一起清:新增行(addTreeRow)把 "row_xxx" 写在
|
|
2478
|
+
// row.id 上,复制(handleCopyTreeData)写在 rowField 上,来源不同,
|
|
2479
|
+
// 只清一个会把临时 id 提交给后端。rowField 缺省时两者是同一字段。
|
|
2480
|
+
let clearTempValue = (tableData, field) => {
|
|
2481
|
+
let value = tableData[field];
|
|
2482
|
+
if (value && value.startsWith && value.startsWith("row_")) {
|
|
2483
|
+
tableData[field] = null;
|
|
2484
|
+
}
|
|
2485
|
+
};
|
|
2486
|
+
tableDatas.forEach((tableData) => {
|
|
2487
|
+
clearTempValue(tableData, idField);
|
|
2488
|
+
if (idField !== "id") {
|
|
2489
|
+
clearTempValue(tableData, "id");
|
|
2490
|
+
}
|
|
2491
|
+
clearTempValue(tableData, parentField);
|
|
2467
2492
|
if (tableData[parentField] === undefined)
|
|
2468
2493
|
tableData[parentField] = null;
|
|
2469
2494
|
});
|
|
2470
|
-
tableDatas = tableDatas.filter((item) =>
|
|
2471
|
-
return item[parentField] === 0 || item[parentField] === null;
|
|
2472
|
-
});
|
|
2495
|
+
tableDatas = tableDatas.filter((item, index) => isRootFlags[index]);
|
|
2473
2496
|
newFormData[tableAlias] = tableDatas;
|
|
2474
2497
|
} else {
|
|
2475
2498
|
newFormData[tableAlias]
|