cloud-web-corejs 1.1.0-dev.41 → 1.1.0-dev.43
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/errorMsg/index.vue +141 -8
- package/src/components/errorMsg/mixins.js +31 -0
- package/src/components/xform/form-designer/form-widget/field-widget/fieldMixin.js +10 -6
- package/src/components/xform/form-designer/form-widget/field-widget/form-item-wrapper.vue +13 -3
- package/src/components/xform/form-render/container-item/data-table-mixin.js +6 -2
- package/src/components/xform/form-render/indexMixin.js +3 -0
- package/src/components/xform/utils/util.js +34 -0
- package/src/utils/request.js +89 -14
package/package.json
CHANGED
|
@@ -6,20 +6,32 @@
|
|
|
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
|
-
<
|
|
22
|
-
|
|
22
|
+
<div v-if="showTextFlag && structuredDetail" class="error-detail-list">
|
|
23
|
+
<div
|
|
24
|
+
v-for="(item, index) in detailItems"
|
|
25
|
+
:key="index"
|
|
26
|
+
class="error-detail-row"
|
|
27
|
+
:class="{ 'is-summary': item.isSummary, 'is-section': item.isSection, 'is-cause': item.isCause }"
|
|
28
|
+
>
|
|
29
|
+
<span v-if="item.label" class="error-detail-label">{{ item.label }}</span>
|
|
30
|
+
<span v-if="item.value" class="error-detail-value">{{ item.value }}</span>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
<p v-else-if="showTextFlag" class="error-detail-plain" v-html="text2"></p>
|
|
34
|
+
<a class="error-detail-toggle" href="javascript:void(0);" @click="showTextFlag = !showTextFlag">{{
|
|
23
35
|
!showTextFlag
|
|
24
36
|
? $t2("详情", "components.errorMsg.detail")
|
|
25
37
|
: $t2("收起", "components.errorMsg.collapse")
|
|
@@ -44,12 +56,19 @@
|
|
|
44
56
|
<i class="icon"></i>
|
|
45
57
|
<div class="cont">
|
|
46
58
|
<p class="name">{{ title }}</p>
|
|
47
|
-
<p class="txt" v-if="!rmid">Error:</p>
|
|
59
|
+
<p class="txt" v-if="!rmid && !errorLabel">Error:</p>
|
|
48
60
|
<p class="txt" v-if="rmid">Error({{ rmid }}):</p>
|
|
61
|
+
<p class="txt" v-if="!rmid && errorLabel">Error({{ errorLabel }}):</p>
|
|
49
62
|
<template v-if="!showTextFlag">
|
|
50
63
|
<p class="txt">{{ text1 }}</p>
|
|
51
64
|
</template>
|
|
52
|
-
<
|
|
65
|
+
<div v-if="showTextFlag && structuredDetail" class="error-detail-list">
|
|
66
|
+
<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 }">
|
|
67
|
+
<span v-if="item.label" class="error-detail-label">{{ item.label }}</span>
|
|
68
|
+
<span v-if="item.value" class="error-detail-value">{{ item.value }}</span>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
<p class="txt" v-else-if="showTextFlag" v-html="text2"></p>
|
|
53
72
|
<el-link @click="showTextFlag = !showTextFlag" class="link-underline" :underline="false" type="primary">{{
|
|
54
73
|
!showTextFlag
|
|
55
74
|
? $t2("详情", "components.errorMsg.detail")
|
|
@@ -70,9 +89,123 @@
|
|
|
70
89
|
import { mixins } from "./mixins";
|
|
71
90
|
|
|
72
91
|
export default {
|
|
73
|
-
|
|
92
|
+
name: "ErrorMessage",
|
|
74
93
|
mixins: [mixins],
|
|
75
94
|
};
|
|
76
95
|
</script>
|
|
77
96
|
|
|
78
|
-
<style
|
|
97
|
+
<style lang="scss">
|
|
98
|
+
.error-message-dialog {
|
|
99
|
+
.el-dialog__body .cont {
|
|
100
|
+
padding: 18px 20px 16px;
|
|
101
|
+
max-height: min(520px, calc(100vh - 190px));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&.is-detail .el-dialog__body:after {
|
|
105
|
+
display: none;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.error-detail-list {
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
border: 1px solid #dfe6f1;
|
|
112
|
+
border-radius: 6px;
|
|
113
|
+
background: rgba(255, 255, 255, 0.86);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.error-detail-row {
|
|
117
|
+
display: grid;
|
|
118
|
+
grid-template-columns: 82px minmax(0, 1fr);
|
|
119
|
+
gap: 12px;
|
|
120
|
+
padding: 7px 12px;
|
|
121
|
+
border-bottom: 1px solid #edf0f5;
|
|
122
|
+
line-height: 1.55;
|
|
123
|
+
word-break: break-word;
|
|
124
|
+
|
|
125
|
+
&:last-child {
|
|
126
|
+
border-bottom: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
&.is-summary,
|
|
130
|
+
&.is-section {
|
|
131
|
+
display: block;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&.is-summary {
|
|
135
|
+
padding: 10px 12px;
|
|
136
|
+
background: #edf4ff;
|
|
137
|
+
color: #315f91;
|
|
138
|
+
font-weight: 600;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
&.is-section {
|
|
142
|
+
padding: 9px 12px 5px;
|
|
143
|
+
border-bottom: 0;
|
|
144
|
+
color: #303133;
|
|
145
|
+
font-weight: 600;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
&.is-cause {
|
|
149
|
+
position: relative;
|
|
150
|
+
display: block;
|
|
151
|
+
padding: 4px 12px 4px 30px;
|
|
152
|
+
border-bottom: 0;
|
|
153
|
+
|
|
154
|
+
&:before {
|
|
155
|
+
content: "";
|
|
156
|
+
position: absolute;
|
|
157
|
+
top: 13px;
|
|
158
|
+
left: 17px;
|
|
159
|
+
width: 4px;
|
|
160
|
+
height: 4px;
|
|
161
|
+
border-radius: 50%;
|
|
162
|
+
background: #8ca5c2;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.error-detail-label {
|
|
166
|
+
margin-right: 4px;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.error-detail-label {
|
|
172
|
+
color: #606266;
|
|
173
|
+
font-weight: 600;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.error-detail-value {
|
|
177
|
+
min-width: 0;
|
|
178
|
+
color: #606266;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.error-detail-toggle {
|
|
182
|
+
display: inline-block;
|
|
183
|
+
margin-top: 12px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.error-detail-plain {
|
|
187
|
+
line-height: 1.65;
|
|
188
|
+
word-break: break-word;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.pop-tipsBox.error .error-detail-list {
|
|
192
|
+
max-height: 42vh;
|
|
193
|
+
overflow: auto;
|
|
194
|
+
text-align: left;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@media (max-width: 640px) {
|
|
198
|
+
.error-detail-row {
|
|
199
|
+
display: block;
|
|
200
|
+
|
|
201
|
+
.error-detail-label {
|
|
202
|
+
display: block;
|
|
203
|
+
margin-bottom: 2px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&.is-cause .error-detail-label {
|
|
207
|
+
display: inline;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
</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,
|
|
@@ -366,19 +367,22 @@ modules = {
|
|
|
366
367
|
);
|
|
367
368
|
},
|
|
368
369
|
getPropName: function () {
|
|
370
|
+
let propName;
|
|
369
371
|
if (this.formItemProp) {
|
|
370
|
-
|
|
372
|
+
propName = this.formItemProp;
|
|
371
373
|
} else {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
+
propName =
|
|
375
|
+
this.subFormItemFlag && !this.designState
|
|
376
|
+
? this.subFormName +
|
|
374
377
|
"." +
|
|
375
378
|
this.subFormRowIndex +
|
|
376
379
|
"." +
|
|
377
380
|
this.fieldKeyName
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
+
: this.getObjectFieldFlag() && !this.designState
|
|
382
|
+
? this.getObjectName() + "." + this.fieldKeyName
|
|
383
|
+
: this.fieldKeyName;
|
|
381
384
|
}
|
|
385
|
+
return resolveElementFormItemProp(this.formModel, propName);
|
|
382
386
|
},
|
|
383
387
|
initFieldModel: function (flag) {
|
|
384
388
|
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 },
|
|
@@ -567,6 +569,12 @@ export default {
|
|
|
567
569
|
getRules() {
|
|
568
570
|
return this.rules;
|
|
569
571
|
},
|
|
572
|
+
getFormModelForProp() {
|
|
573
|
+
return (this.globalModel && this.globalModel.formModel) || null;
|
|
574
|
+
},
|
|
575
|
+
resolveFormItemProp(propName) {
|
|
576
|
+
return resolveElementFormItemProp(this.getFormModelForProp(), propName);
|
|
577
|
+
},
|
|
570
578
|
getPropName() {
|
|
571
579
|
if (this.formItemProp === "false") {
|
|
572
580
|
return null;
|
|
@@ -576,12 +584,14 @@ export default {
|
|
|
576
584
|
// }
|
|
577
585
|
if (this.tableParam && !this.tableParam.$table?.$parent?.$parent) {
|
|
578
586
|
if (this.formItemProp) {
|
|
579
|
-
return this.formItemProp;
|
|
587
|
+
return this.resolveFormItemProp(this.formItemProp);
|
|
580
588
|
}
|
|
581
589
|
return null;
|
|
582
590
|
}
|
|
583
591
|
if (this.tableParam && !!this.tableParam.$table?.$parent?.$parent) {
|
|
584
|
-
return this.
|
|
592
|
+
return this.resolveFormItemProp(
|
|
593
|
+
this.getColumnProp(this.field, this.tableParam)
|
|
594
|
+
);
|
|
585
595
|
}
|
|
586
596
|
let o = this.field.options.name;
|
|
587
597
|
let propName =
|
|
@@ -594,7 +604,7 @@ export default {
|
|
|
594
604
|
? this.getObjectName() + "." + o
|
|
595
605
|
: o);
|
|
596
606
|
|
|
597
|
-
return propName;
|
|
607
|
+
return this.resolveFormItemProp(propName);
|
|
598
608
|
},
|
|
599
609
|
getFieldKeyName(widget) {
|
|
600
610
|
let o = widget.options.name;
|
|
@@ -4234,7 +4234,11 @@ modules = {
|
|
|
4234
4234
|
let nullValue = newData.hasOwnProperty(field)
|
|
4235
4235
|
? null
|
|
4236
4236
|
: this.getColumnNullValue(widget, defaultValueEnabled);
|
|
4237
|
-
|
|
4237
|
+
// 带点 keyName 是 lookup 嵌套路径。写成字面量键后,XEUtils.get 会命中
|
|
4238
|
+
// 这个 null,不再走进 msdyn_substatus.Name 这类对象取值。
|
|
4239
|
+
if (typeof field !== "string" || field.indexOf(".") === -1) {
|
|
4240
|
+
newData[field] = nullValue;
|
|
4241
|
+
}
|
|
4238
4242
|
if (this.isSingerlSearch(widget)) {
|
|
4239
4243
|
let vabSearchName = widget.options.vabSearchName;
|
|
4240
4244
|
if (vabSearchName) newData[vabSearchName] = null;
|
|
@@ -4271,7 +4275,7 @@ modules = {
|
|
|
4271
4275
|
} else {
|
|
4272
4276
|
if (widget) {
|
|
4273
4277
|
this.handleWidgetNullValue(widget, newData, defaultValueEnabled);
|
|
4274
|
-
} else {
|
|
4278
|
+
} else if (String(item.prop).indexOf(".") === -1) {
|
|
4275
4279
|
newData[item.prop] = null;
|
|
4276
4280
|
}
|
|
4277
4281
|
}
|
|
@@ -1871,6 +1871,9 @@ modules = {
|
|
|
1871
1871
|
let e = this;
|
|
1872
1872
|
this.$off("fieldValidation"),
|
|
1873
1873
|
this.$on("fieldValidation", function (t) {
|
|
1874
|
+
// 查询区带点 keyName 不会注册到 el-form-item,getPropName 为 null。
|
|
1875
|
+
// Element validateField(null) 会 warn「please pass correct props!」
|
|
1876
|
+
if (!t || !e.$refs.renderForm) return;
|
|
1874
1877
|
e.$refs.renderForm.validateField(t);
|
|
1875
1878
|
});
|
|
1876
1879
|
},
|
|
@@ -141,6 +141,40 @@ export function isEmptyStr(str) {
|
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Element el-form-item 的 prop 按 '.' / '[]' 拆成嵌套路径,中间对象不存在会抛
|
|
146
|
+
* "please transfer a valid prop path to form item"。
|
|
147
|
+
* 本系统大量 keyName 是 Dynamics 风格字面量键(如 msdyn_reportedbycontact.fullname),
|
|
148
|
+
* 存在 model["a.b"] 上而不是 model.a.b,不能交给 el-form-item。
|
|
149
|
+
*/
|
|
150
|
+
export function isElementFormPropReachable(model, prop) {
|
|
151
|
+
if (prop == null || prop === "" || prop === false || prop === "false") {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
const path = String(prop);
|
|
155
|
+
if (path.indexOf(".") === -1 && path.indexOf("[") === -1) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (model == null || typeof model !== "object") {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
let tempObj = model;
|
|
162
|
+
const normalized = path.replace(/\[(\w+)\]/g, ".$1").replace(/^\./, "");
|
|
163
|
+
const keyArr = normalized.split(".");
|
|
164
|
+
for (let i = 0; i < keyArr.length - 1; i++) {
|
|
165
|
+
const key = keyArr[i];
|
|
166
|
+
if (tempObj == null || typeof tempObj !== "object" || !(key in tempObj)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
tempObj = tempObj[key];
|
|
170
|
+
}
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function resolveElementFormItemProp(model, prop) {
|
|
175
|
+
return isElementFormPropReachable(model, prop) ? prop : null;
|
|
176
|
+
}
|
|
177
|
+
|
|
144
178
|
export const generateId = function () {
|
|
145
179
|
return Math.floor(
|
|
146
180
|
Math.random() * 100000 + Math.random() * 20000 + Math.random() * 5000
|
package/src/utils/request.js
CHANGED
|
@@ -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
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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
|
}
|