cloud-web-corejs 1.0.296 → 1.0.297

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.296",
4
+ "version": "1.0.297",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -6,20 +6,27 @@
6
6
  v-if="showWrap"
7
7
  :close-on-click-modal="false"
8
8
  width="501px"
9
- custom-class="dialog-style tips-dialog error"
9
+ :custom-class="structuredDetail ? `dialog-style tips-dialog error error-message-dialog${showTextFlag ? ' is-detail' : ''}` : 'dialog-style tips-dialog error'"
10
10
  :append-to-body="true"
11
11
  :modal="false"
12
12
  @close="closeDialog"
13
13
  v-el-drag-dialog
14
14
  >
15
15
  <div class="cont">
16
- <p v-if="!rmid">Error:</p>
16
+ <p v-if="!rmid && !errorLabel">Error:</p>
17
17
  <p v-if="rmid">Error({{ rmid }}):</p>
18
+ <p v-if="!rmid && errorLabel">Error({{ errorLabel }}):</p>
18
19
  <template v-if="!showTextFlag">
19
20
  <p v-html="text1"></p>
20
21
  </template>
21
- <p v-if="showTextFlag" v-html="text2"></p>
22
- <a href="javascript:void(0);" @click="showTextFlag = !showTextFlag">{{
22
+ <div v-if="showTextFlag && structuredDetail" class="error-detail-list">
23
+ <div v-for="(item, index) in detailItems" :key="index" class="error-detail-row" :class="{ 'is-summary': item.isSummary, 'is-section': item.isSection, 'is-cause': item.isCause }">
24
+ <span v-if="item.label" class="error-detail-label">{{ item.label }}</span>
25
+ <span v-if="item.value" class="error-detail-value">{{ item.value }}</span>
26
+ </div>
27
+ </div>
28
+ <p v-else-if="showTextFlag" class="error-detail-plain" v-html="text2"></p>
29
+ <a class="error-detail-toggle" href="javascript:void(0);" @click="showTextFlag = !showTextFlag">{{
23
30
  !showTextFlag
24
31
  ? $t2("详情", "components.errorMsg.detail")
25
32
  : $t2("收起", "components.errorMsg.collapse")
@@ -44,12 +51,19 @@
44
51
  <i class="icon"></i>
45
52
  <div class="cont">
46
53
  <p class="name">{{ title }}</p>
47
- <p class="txt" v-if="!rmid">Error:</p>
54
+ <p class="txt" v-if="!rmid && !errorLabel">Error:</p>
48
55
  <p class="txt" v-if="rmid">Error({{ rmid }}):</p>
56
+ <p class="txt" v-if="!rmid && errorLabel">Error({{ errorLabel }}):</p>
49
57
  <template v-if="!showTextFlag">
50
58
  <p class="txt">{{ text1 }}</p>
51
59
  </template>
52
- <p class="txt" v-if="showTextFlag" v-html="text2"></p>
60
+ <div v-if="showTextFlag && structuredDetail" class="error-detail-list">
61
+ <div v-for="(item, index) in detailItems" :key="index" class="error-detail-row" :class="{ 'is-summary': item.isSummary, 'is-section': item.isSection, 'is-cause': item.isCause }">
62
+ <span v-if="item.label" class="error-detail-label">{{ item.label }}</span>
63
+ <span v-if="item.value" class="error-detail-value">{{ item.value }}</span>
64
+ </div>
65
+ </div>
66
+ <p class="txt" v-else-if="showTextFlag" v-html="text2"></p>
53
67
  <a href="javascript:void(0);" @click="showTextFlag = !showTextFlag">{{
54
68
  !showTextFlag
55
69
  ? $t2("详情", "components.errorMsg.detail")
@@ -70,9 +84,56 @@
70
84
  import { mixins } from "./mixins";
71
85
 
72
86
  export default {
73
- // name: 'errorMsg',
87
+ name: "ErrorMessage",
74
88
  mixins: [mixins],
75
89
  };
76
90
  </script>
77
91
 
78
- <style></style>
92
+ <style lang="scss">
93
+ .error-message-dialog {
94
+ .el-dialog__body .cont {
95
+ padding: 18px 20px 16px;
96
+ max-height: min(520px, calc(100vh - 190px));
97
+ }
98
+ &.is-detail .el-dialog__body:after { display: none; }
99
+ }
100
+ .error-detail-list {
101
+ overflow: hidden; border: 1px solid #dfe6f1; border-radius: 6px;
102
+ background: rgba(255, 255, 255, 0.86);
103
+ }
104
+ .error-detail-row {
105
+ display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 12px;
106
+ padding: 7px 12px; border-bottom: 1px solid #edf0f5;
107
+ line-height: 1.55; word-break: break-word;
108
+ &:last-child { border-bottom: 0; }
109
+ &.is-summary, &.is-section { display: block; }
110
+ &.is-summary {
111
+ padding: 10px 12px; background: #edf4ff; color: #315f91; font-weight: 600;
112
+ }
113
+ &.is-section {
114
+ padding: 9px 12px 5px; border-bottom: 0; color: #303133; font-weight: 600;
115
+ }
116
+ &.is-cause {
117
+ position: relative; display: block; padding: 4px 12px 4px 30px; border-bottom: 0;
118
+ &:before {
119
+ content: ""; position: absolute; top: 13px; left: 17px;
120
+ width: 4px; height: 4px; border-radius: 50%; background: #8ca5c2;
121
+ }
122
+ .error-detail-label { margin-right: 4px; }
123
+ }
124
+ }
125
+ .error-detail-label { color: #606266; font-weight: 600; }
126
+ .error-detail-value { min-width: 0; color: #606266; }
127
+ .error-detail-toggle { display: inline-block; margin-top: 12px; }
128
+ .error-detail-plain { line-height: 1.65; word-break: break-word; }
129
+ .pop-tipsBox.error .error-detail-list {
130
+ max-height: 42vh; overflow: auto; text-align: left;
131
+ }
132
+ @media (max-width: 640px) {
133
+ .error-detail-row {
134
+ display: block;
135
+ .error-detail-label { display: block; margin-bottom: 2px; }
136
+ &.is-cause .error-detail-label { display: inline; }
137
+ }
138
+ }
139
+ </style>
@@ -14,6 +14,9 @@ tmixins = {
14
14
  },
15
15
  objx: Object,
16
16
  _errorMsg: null,
17
+ errorLabel: {
18
+ default: "",
19
+ },
17
20
  },
18
21
  created() {
19
22
  if (this.$baseEventBus.isMobile) {
@@ -26,6 +29,8 @@ tmixins = {
26
29
  title: this.$t2("提示", "components.errorMsg.title"),
27
30
  text1: "",
28
31
  text2: "",
32
+ detailItems: [],
33
+ structuredDetail: false,
29
34
  showWrap: false,
30
35
  showTextFlag: false,
31
36
  zIndex: null,
@@ -56,6 +61,26 @@ tmixins = {
56
61
  if (!text) return text;
57
62
  return text.replace(/(\r\n|\n|\r)/gm, "<br />");
58
63
  },
64
+ getDetailItems(text) {
65
+ let inCauseSection = false;
66
+ return String(text || "")
67
+ .split(/\r\n|\n|\r/)
68
+ .filter((line) => line.trim())
69
+ .map((line, index) => {
70
+ const separatorIndex = line.search(/[::]/);
71
+ const label = separatorIndex >= 0 ? line.slice(0, separatorIndex) : "";
72
+ const value = separatorIndex >= 0 ? line.slice(separatorIndex + 1).trim() : line;
73
+ const isSection = label === "可能原因";
74
+ if (isSection) inCauseSection = true;
75
+ return {
76
+ label,
77
+ value,
78
+ isSection,
79
+ isSummary: index === 0 && separatorIndex < 0,
80
+ isCause: inCauseSection && !isSection,
81
+ };
82
+ });
83
+ },
59
84
  showMsgBox: function () {
60
85
  this.removeEnterEvent();
61
86
  this.addEnterEvent();
@@ -79,8 +104,14 @@ tmixins = {
79
104
  );
80
105
  if (this._errorMsg) {
81
106
  this.text2 = this.getShowText(this._errorMsg);
107
+ this.structuredDetail = /(^|\n)状态码[::]/.test(this._errorMsg);
108
+ this.detailItems = this.structuredDetail
109
+ ? this.getDetailItems(this._errorMsg)
110
+ : [];
82
111
  } else {
83
112
  this.text2 = this.getShowText(content);
113
+ this.structuredDetail = false;
114
+ this.detailItems = [];
84
115
  }
85
116
  }
86
117
  this.showTextFlag = false;
@@ -11,6 +11,7 @@ import {
11
11
  isArrayValueWidgetType,
12
12
  isAttachmentWidgetType,
13
13
  isEmptyArrayFieldValue,
14
+ resolveElementFormItemProp,
14
15
  } from "../../../../../components/xform/utils/util";
15
16
  import FormValidators, {
16
17
  getRegExp,
@@ -346,19 +347,22 @@ modules = {
346
347
  );
347
348
  },
348
349
  getPropName: function () {
350
+ let propName;
349
351
  if (this.formItemProp) {
350
- return this.formItemProp;
352
+ propName = this.formItemProp;
351
353
  } else {
352
- return this.subFormItemFlag && !this.designState
353
- ? this.subFormName +
354
+ propName =
355
+ this.subFormItemFlag && !this.designState
356
+ ? this.subFormName +
354
357
  "." +
355
358
  this.subFormRowIndex +
356
359
  "." +
357
360
  this.fieldKeyName
358
- : this.getObjectFieldFlag() && !this.designState
359
- ? this.getObjectName() + "." + this.fieldKeyName
360
- : this.fieldKeyName;
361
+ : this.getObjectFieldFlag() && !this.designState
362
+ ? this.getObjectName() + "." + this.fieldKeyName
363
+ : this.fieldKeyName;
361
364
  }
365
+ return resolveElementFormItemProp(this.formModel, propName);
362
366
  },
363
367
  initFieldModel: function (flag) {
364
368
  let e = this;
@@ -256,6 +256,7 @@ import i18n from "../../../../../components/xform/utils/i18n";
256
256
  import {
257
257
  getSubFormNameByFieldId,
258
258
  isVabsearchMultiWidget,
259
+ resolveElementFormItemProp,
259
260
  } from "../../../../../components/xform/utils/util";
260
261
  import compareView from "../../../../../components/xform/form-render/compareView.vue";
261
262
  import {
@@ -307,6 +308,7 @@ export default {
307
308
  },
308
309
  inject: {
309
310
  getFormConfig: { default: () => () => ({}) },
311
+ globalModel: { default: () => ({ formModel: {} }) },
310
312
  getSubFormFieldFlag: { default: () => () => false },
311
313
  getSubFormName: { default: () => () => "" },
312
314
  tableParam: { default: null },
@@ -559,6 +561,12 @@ export default {
559
561
  getRules() {
560
562
  return this.rules;
561
563
  },
564
+ getFormModelForProp() {
565
+ return (this.globalModel && this.globalModel.formModel) || null;
566
+ },
567
+ resolveFormItemProp(propName) {
568
+ return resolveElementFormItemProp(this.getFormModelForProp(), propName);
569
+ },
562
570
  getPropName() {
563
571
  if (this.formItemProp === "false") {
564
572
  return null;
@@ -568,12 +576,14 @@ export default {
568
576
  // }
569
577
  if (this.tableParam && !this.tableParam.$table?.$parent?.$parent) {
570
578
  if (this.formItemProp) {
571
- return this.formItemProp;
579
+ return this.resolveFormItemProp(this.formItemProp);
572
580
  }
573
581
  return null;
574
582
  }
575
583
  if (this.tableParam && !!this.tableParam.$table?.$parent?.$parent) {
576
- return this.getColumnProp(this.field, this.tableParam);
584
+ return this.resolveFormItemProp(
585
+ this.getColumnProp(this.field, this.tableParam)
586
+ );
577
587
  }
578
588
  let o = this.field.options.name;
579
589
  let propName =
@@ -586,7 +596,7 @@ export default {
586
596
  ? this.getObjectName() + "." + o
587
597
  : o);
588
598
 
589
- return propName;
599
+ return this.resolveFormItemProp(propName);
590
600
  },
591
601
  getFieldKeyName(widget) {
592
602
  let o = widget.options.name;
@@ -3759,7 +3759,11 @@ modules = {
3759
3759
  let nullValue = newData.hasOwnProperty(field)
3760
3760
  ? null
3761
3761
  : this.getColumnNullValue(widget, defaultValueEnabled);
3762
- newData[field] = nullValue;
3762
+ // 带点 keyName 是 lookup 嵌套路径。写成字面量键后,XEUtils.get 会命中
3763
+ // 这个 null,不再走进 msdyn_substatus.Name 这类对象取值。
3764
+ if (typeof field !== "string" || field.indexOf(".") === -1) {
3765
+ newData[field] = nullValue;
3766
+ }
3763
3767
  if (this.isSingerlSearch(widget)) {
3764
3768
  let vabSearchName = widget.options.vabSearchName;
3765
3769
  if (vabSearchName) newData[vabSearchName] = null;
@@ -3796,7 +3800,7 @@ modules = {
3796
3800
  } else {
3797
3801
  if (widget) {
3798
3802
  this.handleWidgetNullValue(widget, newData, defaultValueEnabled);
3799
- } else {
3803
+ } else if (String(item.prop).indexOf(".") === -1) {
3800
3804
  newData[item.prop] = null;
3801
3805
  }
3802
3806
  }
@@ -1827,6 +1827,9 @@ modules = {
1827
1827
  let e = this;
1828
1828
  this.$off("fieldValidation"),
1829
1829
  this.$on("fieldValidation", function (t) {
1830
+ // 查询区带点 keyName 不会注册到 el-form-item,getPropName 为 null。
1831
+ // Element validateField(null) 会 warn「please pass correct props!」
1832
+ if (!t || !e.$refs.renderForm) return;
1830
1833
  e.$refs.renderForm.validateField(t);
1831
1834
  });
1832
1835
  },
@@ -121,6 +121,40 @@ export function isEmptyStr(str) {
121
121
  );
122
122
  }
123
123
 
124
+ /**
125
+ * Element el-form-item 的 prop 按 '.' / '[]' 拆成嵌套路径,中间对象不存在会抛
126
+ * "please transfer a valid prop path to form item"。
127
+ * 本系统大量 keyName 是 Dynamics 风格字面量键(如 msdyn_reportedbycontact.fullname),
128
+ * 存在 model["a.b"] 上而不是 model.a.b,不能交给 el-form-item。
129
+ */
130
+ export function isElementFormPropReachable(model, prop) {
131
+ if (prop == null || prop === "" || prop === false || prop === "false") {
132
+ return false;
133
+ }
134
+ const path = String(prop);
135
+ if (path.indexOf(".") === -1 && path.indexOf("[") === -1) {
136
+ return true;
137
+ }
138
+ if (model == null || typeof model !== "object") {
139
+ return false;
140
+ }
141
+ let tempObj = model;
142
+ const normalized = path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "");
143
+ const keyArr = normalized.split(".");
144
+ for (let i = 0; i < keyArr.length - 1; i++) {
145
+ const key = keyArr[i];
146
+ if (tempObj == null || typeof tempObj !== "object" || !(key in tempObj)) {
147
+ return false;
148
+ }
149
+ tempObj = tempObj[key];
150
+ }
151
+ return true;
152
+ }
153
+
154
+ export function resolveElementFormItemProp(model, prop) {
155
+ return isElementFormPropReachable(model, prop) ? prop : null;
156
+ }
157
+
124
158
  export const generateId = function () {
125
159
  return Math.floor(
126
160
  Math.random() * 100000 + Math.random() * 20000 + Math.random() * 5000
@@ -111,7 +111,7 @@ service.interceptors.request.use(
111
111
  }
112
112
  );
113
113
 
114
- function removeModel(config) {
114
+ function removeModel(config) {
115
115
  if (config) {
116
116
  if (config.modal !== false && config.ajaxOverlay) {
117
117
  config.ajaxOverlay.remove();
@@ -123,7 +123,76 @@ function removeModel(config) {
123
123
  }, 200);
124
124
  }
125
125
  }
126
- }
126
+ }
127
+
128
+ function getSafeRequestUrl(config) {
129
+ if (!config || !config.url) return t1("未知");
130
+ const rawUrl = String(config.url).split("?")[0].split("#")[0];
131
+ const baseUrl = config.baseURL || "";
132
+ if (/^https?:\/\//i.test(rawUrl)) return rawUrl;
133
+ return `${baseUrl || ""}${rawUrl}` || t1("未知");
134
+ }
135
+
136
+ function t1(path, values) {
137
+ const translate = Vue.prototype.$t1;
138
+ return typeof translate === "function" ? translate(path, values) : path;
139
+ }
140
+
141
+ function getRequestErrorMessage(error) {
142
+ const config = (error && error.config) || {};
143
+ const response = error && error.response;
144
+ const status = response && response.status;
145
+ const method = String(config.method || "GET").toUpperCase();
146
+ const requestUrl = getSafeRequestUrl(config);
147
+ const originalMessage = (error && error.message) || "未知错误";
148
+ let summary = t1("请求失败,请稍后重试。");
149
+
150
+ if (error && (error.code === "ECONNABORTED" || /timeout/i.test(originalMessage))) {
151
+ summary = t1("请求超时,请检查网络或稍后重试。");
152
+ } else if (!response) {
153
+ summary = t1("无法连接服务器,请检查网络、VPN/代理及服务状态后重试。");
154
+ } else if ([501, 502, 503, 504].includes(status)) {
155
+ summary = t1("网关或后端服务异常,请稍后重试或联系管理员。");
156
+ } else if (status >= 500) {
157
+ summary = t1("服务器暂时不可用,请稍后重试或联系管理员。");
158
+ } else if (status === 404) {
159
+ summary = t1("请求的服务地址不存在,请联系管理员检查接口配置。");
160
+ } else if (status === 403) {
161
+ summary = t1("服务器拒绝了本次请求,请检查访问权限。");
162
+ } else if (status === 401) {
163
+ summary = t1("登录状态已失效或无效,请重新登录。");
164
+ } else if (status >= 400) {
165
+ summary = t1("服务器未能处理本次请求,请检查输入后重试。");
166
+ }
167
+
168
+ const details = [
169
+ summary,
170
+ t1("请求:{method} {url}", { method, url: requestUrl }),
171
+ t1("状态码:{status}", {
172
+ status: status || t1("未收到服务器响应(浏览器未提供 HTTP 状态码)"),
173
+ }),
174
+ t1("错误码:{code}", { code: (error && error.code) || t1("无") }),
175
+ t1("原始错误:{message}", { message: originalMessage }),
176
+ t1("发生时间:{time}", { time: new Date().toLocaleString() }),
177
+ ];
178
+
179
+ if (!response) {
180
+ details.push(t1("可能原因:"));
181
+ details.push(t1("ERR_CONNECTION_RESET:连接被服务端、网关或安全设备重置;"));
182
+ details.push(t1("CORS:浏览器跨域配置异常;"));
183
+ details.push(t1("ERR_CERT_*:HTTPS 证书异常;"));
184
+ details.push(t1("请求长期 Pending:接口阻塞或连接未释放。"));
185
+ details.push(t1("实际 HTTP 状态码请在浏览器 Network 面板或网关日志中确认。"));
186
+ } else if ([501, 502, 503, 504].includes(status)) {
187
+ details.push(t1("501/502/503/504:网关或后端服务异常。"));
188
+ }
189
+
190
+ return {
191
+ summary,
192
+ details: details.join("\n"),
193
+ errorLabel: !response ? originalMessage : "",
194
+ };
195
+ }
127
196
 
128
197
  async function handleNickName(option) {
129
198
  let { vueTarget, res, callback, config } = option;
@@ -419,18 +488,24 @@ service.interceptors.response.use(
419
488
  if (config.modalStrictly !== true) {
420
489
  removeModel(config);
421
490
  }
422
- if (config.errorMsg !== false) {
423
- ErroreBox.msg({
424
- content: error.message,
425
- type: "error",
426
- });
427
- }
428
- } else {
429
- ErroreBox.msg({
430
- content: error.message,
431
- type: "error",
432
- });
433
- }
491
+ if (config.errorMsg !== false) {
492
+ const requestError = getRequestErrorMessage(error);
493
+ ErroreBox.msg({
494
+ content: requestError.summary,
495
+ _errorMsg: requestError.details,
496
+ errorLabel: requestError.errorLabel,
497
+ type: "error",
498
+ });
499
+ }
500
+ } else {
501
+ const requestError = getRequestErrorMessage(error);
502
+ ErroreBox.msg({
503
+ content: requestError.summary,
504
+ _errorMsg: requestError.details,
505
+ errorLabel: requestError.errorLabel,
506
+ type: "error",
507
+ });
508
+ }
434
509
  }
435
510
  return Promise.reject(error);
436
511
  }