cloud-web-corejs 1.0.318 → 1.0.319

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.0.318",
4
+ "version": "1.0.319",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "check:package-resources": "node build/check-package-resources.js",
@@ -290,8 +290,9 @@ export default {
290
290
  let sourceLabelField = this.sourceLabelField;
291
291
  let id = item[valueField] ?? null;
292
292
  let label = item[sourceLabelField] ?? null;
293
+ let oldValue = deepClone(this.fieldModel);
293
294
 
294
- //存储 ID(提交字段)
295
+ //存储 ID(提交字段),onChange 由 setValue 触发一次
295
296
  this.setValue(id);
296
297
  //存储展示名称(持久化到表单数据 + 输入框)
297
298
  this.setShowValue(label);
@@ -299,22 +300,32 @@ export default {
299
300
  //回填其他字段
300
301
  this.fillBackFields(item);
301
302
 
302
- //触发 onChange 自定义事件
303
- if (this.field.options.onChange) {
304
- let fn = new Function(
305
- "value",
306
- "oldValue",
307
- "item",
308
- this.field.options.onChange
309
- );
310
- fn.call(this, id, this.oldFieldValue, item);
311
- }
303
+ //选中项通过 onSelect 获取
304
+ this.fireOnSelect(id, oldValue, item);
312
305
  } finally {
313
306
  this.$nextTick(() => {
314
307
  this.isSelecting = false;
315
308
  });
316
309
  }
317
310
  },
311
+ /**
312
+ * 下拉选中事件。回填完成后触发,入参为选中项 item。
313
+ */
314
+ fireOnSelect(value, oldValue, item) {
315
+ if (!this.field.options.onSelect) return;
316
+ let tableParam = this.tableParam;
317
+ this.handleCustomEvent(
318
+ this.field.options.onSelect,
319
+ ["value", "oldValue", "item", "rowData", "rowIndex"],
320
+ [
321
+ value,
322
+ oldValue,
323
+ item,
324
+ tableParam ? tableParam.row : null,
325
+ tableParam ? tableParam.rowIndex : null,
326
+ ]
327
+ );
328
+ },
318
329
  /**
319
330
  * 清空:同时清除 ID 与名称
320
331
  */
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <el-form-item label="onSelect" label-width="150px">
3
+ <a href="javascript:void(0);" class="a-link link-oneLind" @click="editEventHandler('onSelect', eventParams)">
4
+ <span>{{ optionModel.onSelect }}</span>
5
+ <i class="el-icon-edit"></i>
6
+ </a>
7
+ </el-form-item>
8
+ </template>
9
+
10
+ <script>
11
+ import i18n from "../../../../../../components/xform/utils/i18n";
12
+ import eventMixin from "../../../../../../components/xform/form-designer/setting-panel/property-editor/event-handler/eventMixin";
13
+
14
+ export default {
15
+ name: "onSelect-editor",
16
+ mixins: [i18n, eventMixin],
17
+ props: {
18
+ designer: Object,
19
+ selectedWidget: Object,
20
+ optionModel: Object,
21
+ },
22
+ data() {
23
+ return {
24
+ eventParams: ["dataId", "formCode", "value", "oldValue", "item", "rowData", "rowIndex"],
25
+ };
26
+ },
27
+ };
28
+ </script>
29
+
30
+ <style scoped></style>
@@ -249,6 +249,7 @@ const EVENT_PROPERTIES = {
249
249
  onClick: "onClick-editor",
250
250
  onInput: "onInput-editor",
251
251
  onChange: "onChange-editor",
252
+ onSelect: "onSelect-editor",
252
253
  onFocus: "onFocus-editor",
253
254
  onBlur: "onBlur-editor",
254
255
  onRemoteQuery: "onRemoteQuery-editor",
@@ -1024,6 +1024,7 @@ const autocompleteConfig = {
1024
1024
  onCreated: "",
1025
1025
  onMounted: "",
1026
1026
  onChange: "",
1027
+ onSelect: "",
1027
1028
  onFocus: "",
1028
1029
  onBlur: "",
1029
1030
  onInput: "",
@@ -35,6 +35,37 @@ service = axios.create({
35
35
  //timeout: 5000 // request timeout
36
36
  });
37
37
 
38
+ function isBinaryRequestBody(data) {
39
+ if (typeof FormData !== "undefined" && data instanceof FormData) return true;
40
+ if (typeof Blob !== "undefined" && data instanceof Blob) return true;
41
+ if (typeof ArrayBuffer !== "undefined" && data instanceof ArrayBuffer) return true;
42
+ return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(data);
43
+ }
44
+
45
+ // 调用方已经 stringify 成对象或数组文本时直接加密,避免再包一层字符串。
46
+ function aesPlainText(data, useEmptyObject) {
47
+ if (typeof data === "string") {
48
+ try {
49
+ const parsed = JSON.parse(data);
50
+ if (parsed !== null && typeof parsed === "object") {
51
+ return data;
52
+ }
53
+ } catch (e) {
54
+ // 普通字符串继续序列化
55
+ }
56
+ }
57
+ if (data === undefined && useEmptyObject) {
58
+ return JSON.stringify({});
59
+ }
60
+ return JSON.stringify(data);
61
+ }
62
+
63
+ function wrapAesBody(data, useEmptyObject) {
64
+ return {
65
+ _aeenboda: encrypt(aesPlainText(data, useEmptyObject)),
66
+ };
67
+ }
68
+
38
69
  // request interceptor
39
70
  service.interceptors.request.use(
40
71
  (config) => {
@@ -57,10 +88,9 @@ service.interceptors.request.use(
57
88
  config.filterConfig
58
89
  );
59
90
  }
60
- if (settingConfig.requestAesEnabled === true) {
61
- config.data = {
62
- _aeenboda: encrypt(JSON.stringify(config.data === undefined ? {} : config.data)),
63
- };
91
+ const canEncryptBody = !isBinaryRequestBody(config.data);
92
+ if (settingConfig.requestAesEnabled === true && canEncryptBody) {
93
+ config.data = wrapAesBody(config.data, true);
64
94
  config.headers["Content-Type"] = "application/json;charset=UTF-8";
65
95
  } else if (
66
96
  (config.headers["Content-Type"] === "application/x-www-form-urlencoded" ||
@@ -71,13 +101,14 @@ service.interceptors.request.use(
71
101
  ) {
72
102
  config.data = qs.stringify(config.data);
73
103
  } else if (
104
+ canEncryptBody &&
74
105
  settingConfig.base64Urls &&
75
106
  settingConfig.base64Urls.includes(config.url)
76
107
  ) {
77
108
  // config.data = {"_baenboda": encode(JSON.stringify(config.data))};
78
- config.data = { _aeenboda: encrypt(JSON.stringify(config.data)) };
79
- } else if (config.aes) {
80
- config.data = { _aeenboda: encrypt(JSON.stringify(config.data)) };
109
+ config.data = wrapAesBody(config.data);
110
+ } else if (canEncryptBody && config.aes) {
111
+ config.data = wrapAesBody(config.data);
81
112
  }
82
113
 
83
114
  if (config.modal !== false && config.loadingTarget) {
@@ -516,7 +547,7 @@ service.interceptors.response.use(
516
547
  // 所以只有整批请求全军覆没时才暴露出来 —— 正好就是详情页 mounted 一口气发
517
548
  // 8+ 个 isLoading + modalStrictly 请求、网络一抖就整页白屏且滚动被锁死的场景。
518
549
  // 下面两处一律 removeModel:正常情况下本来也会被别的请求关掉,行为不变。
519
- if (handleRequestNetworkError()) {
550
+ if (handleRequestNetworkError()) {
520
551
  removeModel(config);
521
552
  return swallowError ? Promise.resolve() : Promise.reject(error);
522
553
  }
@@ -550,7 +581,7 @@ service.interceptors.response.use(
550
581
  });
551
582
  }
552
583
  }
553
- return swallowError ? Promise.resolve() : Promise.reject(error);
584
+ return swallowError ? Promise.resolve() : Promise.reject(error);
554
585
  }
555
586
  );
556
587