cloud-web-corejs 1.0.54-dev.781 → 1.0.54-dev.782

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.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/src/components/VabUpload/index.vue +242 -242
  3. package/src/components/VabUpload/mixins.js +1971 -1971
  4. package/src/components/obsUpload/index.vue +234 -234
  5. package/src/components/obsUpload/mixins.js +1542 -1542
  6. package/src/components/vb-tabs/x-tabs.vue +7 -3
  7. package/src/components/xform/docs//346/240/221/350/241/250rowField/346/224/266/346/225/233-/350/220/275/345/234/260/346/226/207/346/241/243.md +1427 -0
  8. package/src/components/xform/form-designer/form-widget/dialog/formDialog.vue +2 -2
  9. package/src/components/xform/form-designer/form-widget/dialog/formDrawer.vue +2 -2
  10. package/src/components/xform/form-designer/form-widget/dialog/searchFormDialog.vue +2 -2
  11. package/src/components/xform/form-designer/form-widget/field-widget/copy_button-widget.vue +11 -2
  12. package/src/components/xform/form-designer/form-widget/field-widget/vabUpload-widget.vue +369 -369
  13. package/src/components/xform/form-designer/setting-panel/property-editor/fileTypesSelect.vue +69 -23
  14. package/src/components/xform/form-render/container-item/data-table-item.vue +1 -1
  15. package/src/components/xform/form-render/container-item/data-table-mixin.js +1469 -428
  16. package/src/components/xform/form-render/indexMixin.js +379 -263
  17. package/src/components/xform/mixins/defaultHandle.js +234 -28
  18. package/src/components/xform/mixins/scriptHttp.js +4 -4
  19. package/src/components/xform/utils/treeTableUtil.js +1265 -0
  20. package/src/components/xform/utils/util.js +29 -14
  21. package/src/microRouter/index.js +3 -0
  22. package/src/mixins/tableTree/index.js +77 -14
  23. package/src/utils/menuAdapter.js +277 -277
  24. package/src/utils/resolveViewComponent.js +203 -203
  25. package/src/utils/vab.js +6 -3
  26. package/src/views/user/form/vform/render.vue +17 -2
  27. package/src/views/user/form/view/list.vue +11 -10
@@ -233,27 +233,42 @@ export const insertCustomCssToHead = function (cssCode, formId = "") {
233
233
  head.appendChild(newStyle);
234
234
  };
235
235
 
236
+ /**
237
+ * 注入表单全局函数(formConfig.functions):把代码执行在【真实全局作用域】,
238
+ * 使表单各类事件脚本能引用到其中定义的函数。
239
+ *
240
+ * 为什么不再插 <script>:事件脚本一律由 new Function 创建,其作用域链恒为真实全局作用域;
241
+ * 而 qiankun 沙箱 patch 了 head/body 的 appendChild,子应用里动态 script 不会进 DOM,
242
+ * 改由 execScripts 以 (function(window){with(window){...}}).bind(proxy) 包裹执行——
243
+ * `function foo(){}` 落在包裹函数的作用域里、`window.foo=` 落在 proxy 上,两者在真实
244
+ * window 上都不存在,调用侧必然 ReferenceError 且被各处 try/catch 吞掉(静默失效)。
245
+ *
246
+ * 间接 eval 由规范保证在全局作用域、非严格模式下求值,函数声明因此成为真实 window 的属性,
247
+ * 与 new Function 的取值环境对齐;qiankun 对 `eval` 有显式特判(proxySandbox 返回原生 eval),
248
+ * 主应用形态与子应用形态行为一致。
249
+ *
250
+ * 函数名与 formId 参数保持不变:调用方(含 haier 分支)沿用此签名,改名只增加同步面。
251
+ * 现已不产生 DOM 节点、无需按 id 清理,formId 仅用于 sourceURL 定位。
252
+ */
236
253
  export const insertGlobalFunctionsToHtml = function (
237
254
  functionsCode,
238
255
  formId = ""
239
256
  ) {
240
- let bodyEle = document.getElementsByTagName("body")[0];
241
- let oldScriptEle = document.getElementById("v_form_global_functions");
242
- !!oldScriptEle && bodyEle.removeChild(oldScriptEle); //先清除后插入!!
243
- if (!!formId) {
244
- oldScriptEle = document.getElementById(
245
- "v_form_global_functions" + "-" + formId
246
- );
247
- !!oldScriptEle && bodyEle.removeChild(oldScriptEle); //先清除后插入!!
257
+ if (!functionsCode || typeof functionsCode !== "string") {
258
+ return;
248
259
  }
249
-
250
- let newScriptEle = document.createElement("script");
251
- newScriptEle.id = !!formId
260
+ let sourceName = !!formId
252
261
  ? "v_form_global_functions" + "-" + formId
253
262
  : "v_form_global_functions";
254
- newScriptEle.type = "text/javascript";
255
- newScriptEle.innerHTML = functionsCode;
256
- bodyEle.appendChild(newScriptEle);
263
+ try {
264
+ // (0, eval) 是间接调用形式,不可简写为 eval(...):直接 eval 会继承当前模块作用域,
265
+ // 函数声明将落在模块内而非真实 window 上。sourceURL 让 devtools 里可定位、可下断点。
266
+ (0, eval)(functionsCode + "\n//# sourceURL=" + sourceName + ".js");
267
+ } catch (e) {
268
+ // 原先 <script> 注入时语法/运行时错误只进 window.onerror、不影响表单渲染,
269
+ // 这里必须同样吞掉:否则会中断 initFormObject 整条表单初始化链路
270
+ console.error("[xform] 表单全局函数执行失败:" + sourceName, e);
271
+ }
257
272
  };
258
273
 
259
274
  export const optionExists = function (optionsObj, optionName) {
@@ -258,6 +258,9 @@ function activateMicroApp(key) {
258
258
  const loadingInstance = Loading.service({
259
259
  target: appMain || wrapper,
260
260
  text: "加载中…",
261
+ // 全局 .el-loading-spinner 的转圈伪元素是 position:fixed(按全屏遮罩写的),
262
+ // 局部遮罩下会跑到视口中心、与文字错位,靠这个类在样式里纠正(见 style.scss)
263
+ customClass: "micro-loading",
261
264
  });
262
265
  if (appMain && loadingInstance.$el && loadingInstance.$el.style) {
263
266
  loadingInstance.$el.style.top = wrapper.offsetTop + "px";
@@ -1,4 +1,11 @@
1
1
  /**version-1.0*/
2
+ import {
3
+ resolveTreeFields,
4
+ resolveTreeIdentityConfig,
5
+ treeKeyEquals,
6
+ isTemporaryTreeKey,
7
+ } from "../../components/xform/utils/treeTableUtil";
8
+
2
9
  let mixins = {};
3
10
  mixins = {
4
11
  components: {},
@@ -39,6 +46,8 @@ mixins = {
39
46
  let that = this;
40
47
  let $grid = obj.$table.$xegrid;
41
48
  let originOption = $grid.originOption;
49
+ let treeContext = this.resolveTableTreeContext($grid);
50
+ let physicalIdField = treeContext.identityConfig.physicalIdField;
42
51
  let formData = commonDataUtil.handleForm(obj.row);
43
52
  that.$http({
44
53
  url: originOption.editSaveUrl || '',
@@ -50,7 +59,12 @@ mixins = {
50
59
  type: 'success',
51
60
  message: '保存成功!'
52
61
  });
53
- if (obj.row.id == res.objx.id) {
62
+ if (
63
+ treeKeyEquals(
64
+ obj.row[physicalIdField],
65
+ res.objx[physicalIdField]
66
+ )
67
+ ) {
54
68
  $grid.clearActived().then(() => {
55
69
  Object.assign(obj.row, res.objx);
56
70
  });
@@ -62,17 +76,27 @@ mixins = {
62
76
  }
63
77
  })
64
78
  },
65
- findAllRows(rows,grid) {
79
+ findAllRows(rows, grid, visited) {
66
80
  let newRows = [];
67
- let childrenField = grid.treeConfig?.childrenField;
68
- if (!childrenField) {
69
- return rows;
70
- }
81
+ let fields = this.resolveTableTreeContext(grid).fields;
82
+ let childrenFields = [
83
+ fields.childrenField,
84
+ fields.mapChildrenField,
85
+ ].filter((field, index, values) => field && values.indexOf(field) === index);
86
+ let seen = visited || new WeakSet();
71
87
  for (let i = 0; i < rows.length; i++) {
72
88
  let row = rows[i];
89
+ if (!row || typeof row !== "object" || seen.has(row)) {
90
+ continue;
91
+ }
92
+ seen.add(row);
73
93
  newRows.push(row);
74
- if (row[childrenField]) {
75
- let cRows = this.findAllRows(row[childrenField],grid);
94
+ for (let j = 0; j < childrenFields.length; j++) {
95
+ let children = row[childrenFields[j]];
96
+ if (!Array.isArray(children)) {
97
+ continue;
98
+ }
99
+ let cRows = this.findAllRows(children, grid, seen);
76
100
  if (cRows) {
77
101
  newRows = newRows.concat(cRows);
78
102
  }
@@ -90,7 +114,7 @@ mixins = {
90
114
  let rows = this.findAllRows(fullData,$grid);
91
115
  for (let i = 0; i < rows.length; i++) {
92
116
  let row = rows[i];
93
- if (!this.hasSaveRow(row)) {
117
+ if (!this.hasSaveRow(row, $grid)) {
94
118
  return true;
95
119
  }
96
120
  }
@@ -98,7 +122,7 @@ mixins = {
98
122
  let rows = this.findAllRows(tableData,$grid);
99
123
  for (let i = 0; i < rows.length; i++) {
100
124
  let row = rows[i];
101
- if (!this.hasSaveRow(row)) {
125
+ if (!this.hasSaveRow(row, $grid)) {
102
126
  return true;
103
127
  }
104
128
  }
@@ -186,12 +210,51 @@ mixins = {
186
210
  });
187
211
  });
188
212
  },
189
- hasSaveRow(row) {
190
- if (!row || !row.id || row.id.toString().indexOf("row_") == 0) {
213
+ resolveTableTreeContext($grid) {
214
+ let grid = $grid
215
+ || (typeof this.getGridTable === "function"
216
+ ? this.getGridTable()
217
+ : null);
218
+ let originOption = grid?.params?.originOption || grid?.originOption || {};
219
+ let treeConfig = this.resolvedTreeConfig
220
+ || grid?.treeConfig
221
+ || originOption.config?.treeConfig
222
+ || { rowField: "id" };
223
+ let fields = resolveTreeFields(treeConfig, { strict: false });
224
+ let identityConfig = this.resolvedTreeIdentityConfig
225
+ || originOption.treeIdentityConfig
226
+ || resolveTreeIdentityConfig(treeConfig, {});
227
+ return { fields, identityConfig };
228
+ },
229
+ hasSaveRow(row, $grid) {
230
+ if (!row) {
231
+ return false;
232
+ }
233
+ let treeContext = this.resolveTableTreeContext($grid);
234
+ let physicalIdField = treeContext.identityConfig.physicalIdField || "id";
235
+ let physicalId = row[physicalIdField];
236
+ if (physicalId == null || physicalId === "") {
237
+ return false;
238
+ }
239
+ if (
240
+ physicalIdField === treeContext.fields.rowField
241
+ && isTemporaryTreeKey(
242
+ row,
243
+ treeContext.fields.rowField,
244
+ treeContext.identityConfig
245
+ )
246
+ ) {
247
+ return false;
248
+ }
249
+ // 兼容仅写入 row_*、尚无显式 marker 的历史默认 id 新行。
250
+ if (
251
+ physicalIdField === "id"
252
+ && treeContext.fields.rowField === "id"
253
+ && physicalId.toString().indexOf("row_") === 0
254
+ ) {
191
255
  return false;
192
- } else {
193
- return true;
194
256
  }
257
+ return true;
195
258
  }
196
259
  }
197
260
  }