cloud-web-corejs 1.0.294 → 1.0.296
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 +1 -1
- package/src/components/xform/form-render/container-item/data-table-item.vue +1 -1
- package/src/components/xform/form-render/container-item/data-table-mixin.js +43 -13
- package/src/components/xform/form-render/index.vue +1 -0
- package/src/components/xform/styles/detail.scss +6 -0
- package/src/components/xform/utils/treeTableUtil.js +27 -0
- package/src/index.js +4 -2
- package/src/router/index.js +7 -0
- package/src/utils/request.js +10 -5
- package/src/utils/runtimeRecovery.js +105 -0
package/package.json
CHANGED
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
isTemporaryTreeKey,
|
|
71
71
|
syncTreeKeyReferences,
|
|
72
72
|
sanitizeTreeRow,
|
|
73
|
+
stripTreeContainers,
|
|
73
74
|
} from "../../utils/treeTableUtil";
|
|
74
75
|
import { tableTreeMixins } from "../../../../mixins/tableTree/index.js";
|
|
75
76
|
|
|
@@ -233,6 +234,15 @@ modules = {
|
|
|
233
234
|
customClass: function () {
|
|
234
235
|
return this.widget.options.customClass || "";
|
|
235
236
|
},
|
|
237
|
+
/**
|
|
238
|
+
* 查询表 / 配了 tableHeight 的表才跟父级对高度(内部滚动)。
|
|
239
|
+
* 详情里的树表没设高度时必须跟着行数长,滚动交给页面的 .d-cont,
|
|
240
|
+
* 否则 auto-resize 会把表格撑满视口,页面滚动条消失。
|
|
241
|
+
*/
|
|
242
|
+
tableAutoResize() {
|
|
243
|
+
let options = this.widget.options || {};
|
|
244
|
+
return !!(options.isQueryTable || options.tableHeight);
|
|
245
|
+
},
|
|
236
246
|
singleRowSelectFlag: function () {
|
|
237
247
|
return !this.widget.options.showCheckBox;
|
|
238
248
|
},
|
|
@@ -2701,7 +2711,7 @@ modules = {
|
|
|
2701
2711
|
}
|
|
2702
2712
|
: {}),
|
|
2703
2713
|
config: {
|
|
2704
|
-
height:
|
|
2714
|
+
...(height ? { height } : {}),
|
|
2705
2715
|
showFooter,
|
|
2706
2716
|
pagerConfig,
|
|
2707
2717
|
treeConfig,
|
|
@@ -3831,7 +3841,7 @@ modules = {
|
|
|
3831
3841
|
let newData = this.createNewTableData();
|
|
3832
3842
|
tableRows.push(newData);
|
|
3833
3843
|
}
|
|
3834
|
-
this.setValue(tableRows);
|
|
3844
|
+
this.setValue(this.stripTreeContainerRows(tableRows));
|
|
3835
3845
|
this.$nextTick(() => {
|
|
3836
3846
|
this.handleWbs();
|
|
3837
3847
|
});
|
|
@@ -4815,7 +4825,7 @@ modules = {
|
|
|
4815
4825
|
await reconcileGrid.clearActived();
|
|
4816
4826
|
}
|
|
4817
4827
|
if (rebuildTreeAfterSave && !responseAlreadyApplied) {
|
|
4818
|
-
this.setValue(treeTableRows);
|
|
4828
|
+
this.setValue(this.stripTreeContainerRows(treeTableRows));
|
|
4819
4829
|
treeSnapshotApplied = true;
|
|
4820
4830
|
await new Promise((resolve) => this.$nextTick(resolve));
|
|
4821
4831
|
}
|
|
@@ -4987,7 +4997,7 @@ modules = {
|
|
|
4987
4997
|
} else {
|
|
4988
4998
|
tableRows.splice(0, 0, newRow);
|
|
4989
4999
|
}
|
|
4990
|
-
this.setValue(tableRows);
|
|
5000
|
+
this.setValue(this.stripTreeContainerRows(tableRows));
|
|
4991
5001
|
this.$nextTick(() => {
|
|
4992
5002
|
this.handleWbs();
|
|
4993
5003
|
if (isEditTable) {
|
|
@@ -5009,7 +5019,7 @@ modules = {
|
|
|
5009
5019
|
} else {
|
|
5010
5020
|
tableRows.splice(0, 0, newRow);
|
|
5011
5021
|
}
|
|
5012
|
-
this.setValue(tableRows);
|
|
5022
|
+
this.setValue(this.stripTreeContainerRows(tableRows));
|
|
5013
5023
|
this.$nextTick(() => {
|
|
5014
5024
|
this.handleWbs();
|
|
5015
5025
|
// setValue 已浅克隆所有行,obj.row 是失效引用,须按 _X_ROW_KEY 找回新行
|
|
@@ -5097,7 +5107,7 @@ modules = {
|
|
|
5097
5107
|
});
|
|
5098
5108
|
this.validateNewTreeRows(newRows, treeContext);
|
|
5099
5109
|
tableRows.push(...newRows);
|
|
5100
|
-
this.setValue(tableRows);
|
|
5110
|
+
this.setValue(this.stripTreeContainerRows(tableRows));
|
|
5101
5111
|
this.$nextTick(() => {
|
|
5102
5112
|
this.handleWbs();
|
|
5103
5113
|
if (parent) {
|
|
@@ -5106,6 +5116,26 @@ modules = {
|
|
|
5106
5116
|
}
|
|
5107
5117
|
});
|
|
5108
5118
|
},
|
|
5119
|
+
/**
|
|
5120
|
+
* 去掉 VXE 建树时写回行对象的容器字段(children / mapChildren)。
|
|
5121
|
+
*
|
|
5122
|
+
* 删除、排序这类「改扁平数组再整表重载」的操作必须先剥容器:容器是上一次
|
|
5123
|
+
* 渲染的产物,已被移出数组的节点仍挂在存活父行下,setValue 里的
|
|
5124
|
+
* canonicalizeTreeInput 会顺着容器把它们收回来,删除与排序因此静默失效。
|
|
5125
|
+
*
|
|
5126
|
+
* 只对 isTreeTable(强制 transform,父子关系由 parentField 表达)生效;
|
|
5127
|
+
* 靠 children 表达层级的表原样返回,剥掉会丢层级。
|
|
5128
|
+
* @param {Array} rows 取自表单模型的扁平活动行。
|
|
5129
|
+
* @returns {Array} 可安全交给 setValue 的行数组。
|
|
5130
|
+
*/
|
|
5131
|
+
stripTreeContainerRows(rows) {
|
|
5132
|
+
if (!this.widget.options.isTreeTable) {
|
|
5133
|
+
return rows || [];
|
|
5134
|
+
}
|
|
5135
|
+
return stripTreeContainers(rows || [], {
|
|
5136
|
+
fields: this.getTreeFields(),
|
|
5137
|
+
});
|
|
5138
|
+
},
|
|
5109
5139
|
/**
|
|
5110
5140
|
* 收集节点全部后代的 _X_ROW_KEY(不含节点自身)。
|
|
5111
5141
|
* 兼容嵌套结构(children 字段)与扁平结构(parentField 关联)两种数据形态。
|
|
@@ -5185,7 +5215,7 @@ modules = {
|
|
|
5185
5215
|
});
|
|
5186
5216
|
}
|
|
5187
5217
|
let newRows = tableRows.filter((item) => !delKeys.has(item._X_ROW_KEY));
|
|
5188
|
-
this.setValue(newRows);
|
|
5218
|
+
this.setValue(this.stripTreeContainerRows(newRows));
|
|
5189
5219
|
this.$nextTick(() => {
|
|
5190
5220
|
this.handleWbs();
|
|
5191
5221
|
});
|
|
@@ -5443,7 +5473,7 @@ modules = {
|
|
|
5443
5473
|
} else {
|
|
5444
5474
|
tableRows.splice(0, 0, newRow);
|
|
5445
5475
|
}
|
|
5446
|
-
this.setValue(tableRows);
|
|
5476
|
+
this.setValue(this.stripTreeContainerRows(tableRows));
|
|
5447
5477
|
this.$nextTick(() => {
|
|
5448
5478
|
this.handleWbs();
|
|
5449
5479
|
});
|
|
@@ -5460,7 +5490,7 @@ modules = {
|
|
|
5460
5490
|
} else {
|
|
5461
5491
|
tableRows.splice(0, 0, newRow);
|
|
5462
5492
|
}
|
|
5463
|
-
this.setValue(tableRows);
|
|
5493
|
+
this.setValue(this.stripTreeContainerRows(tableRows));
|
|
5464
5494
|
this.$nextTick(() => {
|
|
5465
5495
|
this.handleWbs();
|
|
5466
5496
|
// setValue 已浅克隆所有行,obj.row 是失效引用,须按 _X_ROW_KEY 找回新行
|
|
@@ -5657,7 +5687,7 @@ modules = {
|
|
|
5657
5687
|
);
|
|
5658
5688
|
tableRows.splice(currentIndex, 1);
|
|
5659
5689
|
tableRows.splice(prevIndex, 0, row);
|
|
5660
|
-
this.setValue(tableRows);
|
|
5690
|
+
this.setValue(this.stripTreeContainerRows(tableRows));
|
|
5661
5691
|
this.$nextTick(() => {
|
|
5662
5692
|
this.handleWbs();
|
|
5663
5693
|
});
|
|
@@ -5706,7 +5736,7 @@ modules = {
|
|
|
5706
5736
|
);
|
|
5707
5737
|
tableRows.splice(currentIndex, 1);
|
|
5708
5738
|
tableRows.splice(nextIndex, 0, row);
|
|
5709
|
-
this.setValue(tableRows);
|
|
5739
|
+
this.setValue(this.stripTreeContainerRows(tableRows));
|
|
5710
5740
|
this.$nextTick(() => {
|
|
5711
5741
|
this.handleWbs();
|
|
5712
5742
|
});
|
|
@@ -5783,7 +5813,7 @@ modules = {
|
|
|
5783
5813
|
rows.forEach((row, index1) => {
|
|
5784
5814
|
items.splice(index + index1, 0, row);
|
|
5785
5815
|
});
|
|
5786
|
-
this.setValue(items);
|
|
5816
|
+
this.setValue(this.stripTreeContainerRows(items));
|
|
5787
5817
|
this.$nextTick(() => {
|
|
5788
5818
|
this.handleWbs();
|
|
5789
5819
|
});
|
|
@@ -6123,7 +6153,7 @@ modules = {
|
|
|
6123
6153
|
if (this.designState) return;
|
|
6124
6154
|
this.$on("setFormData", (o) => {
|
|
6125
6155
|
let rows = this.formModel[this.fieldKeyName] || [];
|
|
6126
|
-
this.setValue(rows);
|
|
6156
|
+
this.setValue(this.stripTreeContainerRows(rows));
|
|
6127
6157
|
});
|
|
6128
6158
|
},
|
|
6129
6159
|
/** @param {Object} widget 组件 schema。@param {Array<String>} ignoreFields 忽略字段。@returns {Boolean} 是否处理禁用状态。 */
|
|
@@ -713,6 +713,33 @@ export const validateTreeGraph = (
|
|
|
713
713
|
};
|
|
714
714
|
};
|
|
715
715
|
|
|
716
|
+
/**
|
|
717
|
+
* 剥离 VXE 就地写在行对象上的树容器字段,返回浅拷贝。
|
|
718
|
+
*
|
|
719
|
+
* transform 模式下 vxe 用 XEUtils.toArrayTree 建树,会把子节点数组直接挂回行
|
|
720
|
+
* 对象(children 与 mapChildren 两份),而表单模型保存的正是这批活动行。删除 /
|
|
721
|
+
* 排序只改扁平数组、不动这些容器,容器里的引用随即成为过期快照:再经
|
|
722
|
+
* canonicalizeTreeInput 时会顺着它们把已删节点收回来、按旧顺序还原兄弟节点,
|
|
723
|
+
* 表现为「删除没效果」「上移下移没效果」且不报错。
|
|
724
|
+
*
|
|
725
|
+
* 扁平数据 + parentField 是树关系的唯一事实源,容器只是渲染产物,重建前一律剥掉。
|
|
726
|
+
* 注意:只适用于 transform 树表的活动行;靠 children 表达层级的嵌套输入不可调用。
|
|
727
|
+
* @param {Array} rows 取自表单模型的扁平活动行。
|
|
728
|
+
* @param {Object} options fields 为已解析的树字段。
|
|
729
|
+
* @returns {Array} 去掉容器字段的浅拷贝行数组。
|
|
730
|
+
*/
|
|
731
|
+
export const stripTreeContainers = (rows, { fields } = {}) => {
|
|
732
|
+
let resolvedFields = fields || resolveTreeFields();
|
|
733
|
+
if (!Array.isArray(rows)) return [];
|
|
734
|
+
return rows.map((row) => {
|
|
735
|
+
if (!isObject(row) || Array.isArray(row)) return row;
|
|
736
|
+
let next = { ...row };
|
|
737
|
+
delete next[resolvedFields.childrenField];
|
|
738
|
+
delete next[resolvedFields.mapChildrenField];
|
|
739
|
+
return next;
|
|
740
|
+
});
|
|
741
|
+
};
|
|
742
|
+
|
|
716
743
|
export const canonicalizeTreeInput = (
|
|
717
744
|
source,
|
|
718
745
|
{ fields, identityConfig, strict = true } = {}
|
package/src/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import router, { resetRouter } from "@base/router";
|
|
|
13
13
|
import settings from "@/settings";
|
|
14
14
|
import { setToken as setAuthToken } from "@base/utils/auth";
|
|
15
15
|
import { loadViewComponentAsync } from "@base/utils/resolveViewComponent";
|
|
16
|
+
import { installRuntimeRecovery } from "@base/utils/runtimeRecovery";
|
|
16
17
|
|
|
17
18
|
import "@/icons"; // icon
|
|
18
19
|
import "@base/permission"; // permission control
|
|
@@ -269,10 +270,11 @@ if (process.env.NODE_ENV === "production") {
|
|
|
269
270
|
mockXHR() */
|
|
270
271
|
}
|
|
271
272
|
|
|
272
|
-
Vue.use(Element, {
|
|
273
|
+
Vue.use(Element, {
|
|
273
274
|
size: Cookies.get("size") || "medium", // set element-ui default size
|
|
274
275
|
// locale: enLang // 如果使用中文,无需设置,请删除
|
|
275
|
-
});
|
|
276
|
+
});
|
|
277
|
+
installRuntimeRecovery();
|
|
276
278
|
|
|
277
279
|
// register global utility filters
|
|
278
280
|
Object.keys(filters).forEach((key) => {
|
package/src/router/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Vue from "vue";
|
|
2
2
|
import Router from "vue-router";
|
|
3
|
+
import { promptRefreshForUpdate } from "@base/utils/runtimeRecovery";
|
|
3
4
|
|
|
4
5
|
Vue.use(Router);
|
|
5
6
|
|
|
@@ -19,6 +20,12 @@ const createRouter = () =>
|
|
|
19
20
|
|
|
20
21
|
const router = createRouter();
|
|
21
22
|
|
|
23
|
+
router.onError((error) => {
|
|
24
|
+
const msg = (error && error.message) || "";
|
|
25
|
+
if (!/Loading (CSS )?chunk .* failed|ChunkLoadError/i.test(msg)) return;
|
|
26
|
+
promptRefreshForUpdate(error);
|
|
27
|
+
});
|
|
28
|
+
|
|
22
29
|
export function resetRouter() {
|
|
23
30
|
const newRouter = createRouter();
|
|
24
31
|
router.matcher = newRouter.matcher; // reset router
|
package/src/utils/request.js
CHANGED
|
@@ -8,7 +8,8 @@ import ErroreBox from "../components/errorMsg/index.js";
|
|
|
8
8
|
import PopupManager from "element-ui/src/utils/popup/popup-manager.js";
|
|
9
9
|
import settingConfig from "@/settings.js";
|
|
10
10
|
import { encode } from "js-base64";
|
|
11
|
-
import { encrypt } from "@base/utils/aes";
|
|
11
|
+
import { encrypt } from "@base/utils/aes";
|
|
12
|
+
import { handleRequestNetworkError } from "@base/utils/runtimeRecovery";
|
|
12
13
|
|
|
13
14
|
let configUtil = {
|
|
14
15
|
baseUrl: process.env.VUE_APP_BASE_API,
|
|
@@ -397,10 +398,14 @@ service.interceptors.response.use(
|
|
|
397
398
|
// 那个 else 分支无条件弹 ErroreBox —— 而 ErroreBox 是弹窗不是 toast,取消 N 个
|
|
398
399
|
// 在途请求就会连弹 N 个错误框。config.errorMsg 那条逃生口在 if (config) 里面,
|
|
399
400
|
// Cancel 走不到,所以只能在这里拦。调用方按需自行 catch。
|
|
400
|
-
if (axios.isCancel(error)) {
|
|
401
|
-
return Promise.reject(error);
|
|
402
|
-
}
|
|
403
|
-
let config = error.config;
|
|
401
|
+
if (axios.isCancel(error)) {
|
|
402
|
+
return Promise.reject(error);
|
|
403
|
+
}
|
|
404
|
+
let config = error.config;
|
|
405
|
+
if (handleRequestNetworkError()) {
|
|
406
|
+
if (config && config.modalStrictly !== true) removeModel(config);
|
|
407
|
+
return Promise.reject(error);
|
|
408
|
+
}
|
|
404
409
|
if (
|
|
405
410
|
error.response &&
|
|
406
411
|
error.response.data &&
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Message, MessageBox } from "element-ui";
|
|
2
|
+
import { isChunkLoadError } from "@base/utils/chunkLoadError";
|
|
3
|
+
|
|
4
|
+
let installed = false;
|
|
5
|
+
let offlineMessage = null;
|
|
6
|
+
let refreshPromptVisible = false;
|
|
7
|
+
let assetFailedWhileOffline = false;
|
|
8
|
+
|
|
9
|
+
function isOffline() {
|
|
10
|
+
return typeof navigator !== "undefined" && navigator.onLine === false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getAssetUrl(target) {
|
|
14
|
+
if (!target || !target.tagName) return "";
|
|
15
|
+
const tagName = target.tagName.toUpperCase();
|
|
16
|
+
if (tagName !== "SCRIPT" && tagName !== "LINK") return "";
|
|
17
|
+
return target.src || target.href || "";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function showOfflineMessage() {
|
|
21
|
+
if (offlineMessage) return;
|
|
22
|
+
offlineMessage = Message({
|
|
23
|
+
message: "网络连接已断开,请检查网络;恢复后可继续操作",
|
|
24
|
+
type: "warning",
|
|
25
|
+
duration: 0,
|
|
26
|
+
showClose: true,
|
|
27
|
+
onClose: () => {
|
|
28
|
+
offlineMessage = null;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function closeOfflineMessage(showRecovered) {
|
|
34
|
+
if (offlineMessage) {
|
|
35
|
+
offlineMessage.close();
|
|
36
|
+
offlineMessage = null;
|
|
37
|
+
}
|
|
38
|
+
if (showRecovered) Message.success("网络连接已恢复");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function promptRefreshForUpdate(error) {
|
|
42
|
+
if (isOffline()) {
|
|
43
|
+
showOfflineMessage();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (refreshPromptVisible) return;
|
|
47
|
+
refreshPromptVisible = true;
|
|
48
|
+
console.error("[runtime-recovery] 页面静态资源加载失败:", error);
|
|
49
|
+
MessageBox.confirm(
|
|
50
|
+
"检测到页面资源已失效,可能系统已发布新版本。刷新页面后即可继续使用。",
|
|
51
|
+
"系统更新提示",
|
|
52
|
+
{
|
|
53
|
+
confirmButtonText: "立即刷新",
|
|
54
|
+
cancelButtonText: "稍后处理",
|
|
55
|
+
closeOnClickModal: false,
|
|
56
|
+
type: "warning",
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
.then(() => window.location.reload())
|
|
60
|
+
.catch(() => {})
|
|
61
|
+
.then(() => {
|
|
62
|
+
refreshPromptVisible = false;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function handleRequestNetworkError() {
|
|
67
|
+
if (!isOffline()) return false;
|
|
68
|
+
showOfflineMessage();
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function installRuntimeRecovery() {
|
|
73
|
+
if (installed || typeof window === "undefined") return;
|
|
74
|
+
installed = true;
|
|
75
|
+
|
|
76
|
+
window.addEventListener("offline", showOfflineMessage);
|
|
77
|
+
window.addEventListener("online", () => {
|
|
78
|
+
const shouldRefresh = assetFailedWhileOffline;
|
|
79
|
+
assetFailedWhileOffline = false;
|
|
80
|
+
closeOfflineMessage(!shouldRefresh);
|
|
81
|
+
if (shouldRefresh) promptRefreshForUpdate(new Error("断网期间页面资源加载失败"));
|
|
82
|
+
});
|
|
83
|
+
window.addEventListener(
|
|
84
|
+
"error",
|
|
85
|
+
(event) => {
|
|
86
|
+
const assetUrl = getAssetUrl(event.target);
|
|
87
|
+
if (!assetUrl || !/\/static\/(js|css)\//i.test(assetUrl)) return;
|
|
88
|
+
if (isOffline()) {
|
|
89
|
+
assetFailedWhileOffline = true;
|
|
90
|
+
showOfflineMessage();
|
|
91
|
+
}
|
|
92
|
+
else promptRefreshForUpdate(event.error || new Error(`静态资源加载失败: ${assetUrl}`));
|
|
93
|
+
},
|
|
94
|
+
true
|
|
95
|
+
);
|
|
96
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
97
|
+
if (isOffline()) {
|
|
98
|
+
showOfflineMessage();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (isChunkLoadError(event.reason)) promptRefreshForUpdate(event.reason);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (isOffline()) showOfflineMessage();
|
|
105
|
+
}
|