cloud-web-corejs 1.1.0-dev.67 → 1.1.0-dev.68
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
|
@@ -56,7 +56,7 @@ import {
|
|
|
56
56
|
*
|
|
57
57
|
* <base-autocomplete
|
|
58
58
|
* v-model="form.saleOrgId"
|
|
59
|
-
* :
|
|
59
|
+
* :label.sync="form.saleOrgName"
|
|
60
60
|
* :props="orgProps"
|
|
61
61
|
* :load="loadOrg"
|
|
62
62
|
* />
|
|
@@ -81,7 +81,7 @@ export default {
|
|
|
81
81
|
value: {
|
|
82
82
|
default: null,
|
|
83
83
|
},
|
|
84
|
-
|
|
84
|
+
label: {
|
|
85
85
|
default: null,
|
|
86
86
|
},
|
|
87
87
|
/**
|
|
@@ -166,7 +166,7 @@ export default {
|
|
|
166
166
|
data() {
|
|
167
167
|
return {
|
|
168
168
|
displayValue: null,
|
|
169
|
-
|
|
169
|
+
storedLabel: null,
|
|
170
170
|
isSelecting: false,
|
|
171
171
|
lastQueryKeyword: null,
|
|
172
172
|
querySeq: 0,
|
|
@@ -187,10 +187,10 @@ export default {
|
|
|
187
187
|
},
|
|
188
188
|
},
|
|
189
189
|
watch: {
|
|
190
|
-
|
|
191
|
-
this.
|
|
190
|
+
label(val) {
|
|
191
|
+
this.storedLabel = val ?? null;
|
|
192
192
|
if (!this.isSelecting) {
|
|
193
|
-
this.displayValue = this.
|
|
193
|
+
this.displayValue = this.storedLabel;
|
|
194
194
|
}
|
|
195
195
|
if (!hasValue(val)) {
|
|
196
196
|
this.lookupLabel(this.value);
|
|
@@ -202,8 +202,8 @@ export default {
|
|
|
202
202
|
},
|
|
203
203
|
},
|
|
204
204
|
created() {
|
|
205
|
-
this.
|
|
206
|
-
this.displayValue = this.
|
|
205
|
+
this.storedLabel = this.label ?? null;
|
|
206
|
+
this.displayValue = this.storedLabel;
|
|
207
207
|
this.lookupLabel(this.value);
|
|
208
208
|
},
|
|
209
209
|
methods: {
|
|
@@ -267,20 +267,20 @@ export default {
|
|
|
267
267
|
}
|
|
268
268
|
},
|
|
269
269
|
lookupLabel(id) {
|
|
270
|
-
if (!hasValue(id) || hasValue(this.
|
|
270
|
+
if (!hasValue(id) || hasValue(this.storedLabel)) return;
|
|
271
271
|
if (typeof this.loadById !== "function") return;
|
|
272
272
|
const seq = ++this.lookupSeq;
|
|
273
273
|
let settled = false;
|
|
274
274
|
const done = (row) => {
|
|
275
275
|
if (settled || seq !== this.lookupSeq) return;
|
|
276
276
|
settled = true;
|
|
277
|
-
if (this.value !== id || hasValue(this.
|
|
277
|
+
if (this.value !== id || hasValue(this.storedLabel)) return;
|
|
278
278
|
const record = Array.isArray(row) ? row[0] : row;
|
|
279
279
|
if (!record || typeof record !== "object") return;
|
|
280
280
|
const label = record[this.resolvedLabelField] ?? null;
|
|
281
|
-
this.
|
|
281
|
+
this.storedLabel = label;
|
|
282
282
|
this.displayValue = label;
|
|
283
|
-
this.$emit("update:
|
|
283
|
+
this.$emit("update:label", label);
|
|
284
284
|
};
|
|
285
285
|
try {
|
|
286
286
|
const ret = this.loadById(id, done);
|
|
@@ -304,10 +304,10 @@ export default {
|
|
|
304
304
|
const id = row[this.resolvedValueField] ?? null;
|
|
305
305
|
const label = row[this.resolvedLabelField] ?? null;
|
|
306
306
|
const oldValue = this.value;
|
|
307
|
-
this.
|
|
307
|
+
this.storedLabel = label;
|
|
308
308
|
this.displayValue = label;
|
|
309
309
|
this.$emit("input", id);
|
|
310
|
-
this.$emit("update:
|
|
310
|
+
this.$emit("update:label", label);
|
|
311
311
|
const filled = collectFill(row, this.fillConfig);
|
|
312
312
|
if (this.data) {
|
|
313
313
|
Object.keys(filled).forEach((key) => {
|
|
@@ -326,11 +326,11 @@ export default {
|
|
|
326
326
|
handleClear() {
|
|
327
327
|
this.isSelecting = true;
|
|
328
328
|
const oldValue = this.value;
|
|
329
|
-
this.
|
|
329
|
+
this.storedLabel = null;
|
|
330
330
|
this.displayValue = null;
|
|
331
331
|
this.resetQueryCache();
|
|
332
332
|
this.$emit("input", null);
|
|
333
|
-
this.$emit("update:
|
|
333
|
+
this.$emit("update:label", null);
|
|
334
334
|
this.$emit("change", null, oldValue, null);
|
|
335
335
|
this.$emit("clear");
|
|
336
336
|
this.$nextTick(() => {
|
|
@@ -347,8 +347,8 @@ export default {
|
|
|
347
347
|
handleBlur(event) {
|
|
348
348
|
setTimeout(() => {
|
|
349
349
|
if (this.isSelecting) return;
|
|
350
|
-
if (this.displayValue !== this.
|
|
351
|
-
this.displayValue = this.
|
|
350
|
+
if (this.displayValue !== this.storedLabel) {
|
|
351
|
+
this.displayValue = this.storedLabel;
|
|
352
352
|
}
|
|
353
353
|
}, 150);
|
|
354
354
|
this.$emit("blur", event);
|
|
@@ -157,4 +157,19 @@ export const constantRoutes = [
|
|
|
157
157
|
},
|
|
158
158
|
],
|
|
159
159
|
}] : []), */
|
|
160
|
+
{
|
|
161
|
+
path: "",
|
|
162
|
+
component: () => import("@/layout/index"),
|
|
163
|
+
children: [
|
|
164
|
+
{
|
|
165
|
+
path: "/demo/autocomplete",
|
|
166
|
+
component: () => import("@base/views/demo/autocomplete/index.vue"),
|
|
167
|
+
name: "demoAutocomplete",
|
|
168
|
+
meta: {
|
|
169
|
+
title: "用户自动完成示例",
|
|
170
|
+
icon: "user",
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
},
|
|
160
175
|
];
|
package/src/utils/request.js
CHANGED
|
@@ -42,6 +42,40 @@ function isBinaryRequestBody(data) {
|
|
|
42
42
|
return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(data);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
function isAbsoluteHttpUrl(url) {
|
|
46
|
+
return /^(https?:)?\/\//i.test(String(url || ""));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function toOrigin(url) {
|
|
50
|
+
try {
|
|
51
|
+
return new URL(String(url), window.location.href).origin;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 相对地址走当前 baseURL,视为本系统后台。绝对地址只有和后台同源才加密。
|
|
58
|
+
function isOwnBackendRequest(config) {
|
|
59
|
+
const rawUrl = String((config && config.url) || "");
|
|
60
|
+
let targetOrigin = "";
|
|
61
|
+
if (isAbsoluteHttpUrl(rawUrl)) {
|
|
62
|
+
targetOrigin = toOrigin(rawUrl);
|
|
63
|
+
} else {
|
|
64
|
+
const baseUrl =
|
|
65
|
+
config && config.baseURL != null && config.baseURL !== ""
|
|
66
|
+
? config.baseURL
|
|
67
|
+
: configUtil.baseUrl || "";
|
|
68
|
+
targetOrigin = isAbsoluteHttpUrl(baseUrl)
|
|
69
|
+
? toOrigin(baseUrl)
|
|
70
|
+
: window.location.origin;
|
|
71
|
+
}
|
|
72
|
+
const ownBase = configUtil.baseUrl || "";
|
|
73
|
+
const ownOrigin = isAbsoluteHttpUrl(ownBase)
|
|
74
|
+
? toOrigin(ownBase)
|
|
75
|
+
: window.location.origin;
|
|
76
|
+
return !!targetOrigin && targetOrigin === ownOrigin;
|
|
77
|
+
}
|
|
78
|
+
|
|
45
79
|
// 调用方已经 stringify 成对象或数组文本时直接加密,避免再包一层字符串。
|
|
46
80
|
function aesPlainText(data, useEmptyObject) {
|
|
47
81
|
if (typeof data === "string") {
|
|
@@ -89,7 +123,11 @@ service.interceptors.request.use(
|
|
|
89
123
|
);
|
|
90
124
|
}
|
|
91
125
|
const canEncryptBody = !isBinaryRequestBody(config.data);
|
|
92
|
-
if (
|
|
126
|
+
if (
|
|
127
|
+
settingConfig.requestAesEnabled === true &&
|
|
128
|
+
canEncryptBody &&
|
|
129
|
+
isOwnBackendRequest(config)
|
|
130
|
+
) {
|
|
93
131
|
config.data = wrapAesBody(config.data, true);
|
|
94
132
|
config.headers["Content-Type"] = "application/json;charset=UTF-8";
|
|
95
133
|
} else if (
|