cloud-web-corejs 1.1.0-dev.67 → 1.1.0-dev.69
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
|
/**
|
|
@@ -156,7 +156,7 @@ export default {
|
|
|
156
156
|
},
|
|
157
157
|
suffixIcon: {
|
|
158
158
|
type: String,
|
|
159
|
-
default: "",
|
|
159
|
+
default: "el-icon-tickets",
|
|
160
160
|
},
|
|
161
161
|
popperClass: {
|
|
162
162
|
type: String,
|
|
@@ -166,8 +166,9 @@ export default {
|
|
|
166
166
|
data() {
|
|
167
167
|
return {
|
|
168
168
|
displayValue: null,
|
|
169
|
-
|
|
169
|
+
storedLabel: null,
|
|
170
170
|
isSelecting: false,
|
|
171
|
+
focused: false,
|
|
171
172
|
lastQueryKeyword: null,
|
|
172
173
|
querySeq: 0,
|
|
173
174
|
lookupSeq: 0,
|
|
@@ -187,10 +188,10 @@ export default {
|
|
|
187
188
|
},
|
|
188
189
|
},
|
|
189
190
|
watch: {
|
|
190
|
-
|
|
191
|
-
this.
|
|
191
|
+
label(val) {
|
|
192
|
+
this.storedLabel = val ?? null;
|
|
192
193
|
if (!this.isSelecting) {
|
|
193
|
-
this.displayValue = this.
|
|
194
|
+
this.displayValue = this.storedLabel;
|
|
194
195
|
}
|
|
195
196
|
if (!hasValue(val)) {
|
|
196
197
|
this.lookupLabel(this.value);
|
|
@@ -202,8 +203,8 @@ export default {
|
|
|
202
203
|
},
|
|
203
204
|
},
|
|
204
205
|
created() {
|
|
205
|
-
this.
|
|
206
|
-
this.displayValue = this.
|
|
206
|
+
this.storedLabel = this.label ?? null;
|
|
207
|
+
this.displayValue = this.storedLabel;
|
|
207
208
|
this.lookupLabel(this.value);
|
|
208
209
|
},
|
|
209
210
|
methods: {
|
|
@@ -247,6 +248,12 @@ export default {
|
|
|
247
248
|
const done = (rows) => {
|
|
248
249
|
if (settled || seq !== this.querySeq) return;
|
|
249
250
|
settled = true;
|
|
251
|
+
if (!this.focused) {
|
|
252
|
+
this.lastQueryKeyword = null;
|
|
253
|
+
this._lastSuggestions = null;
|
|
254
|
+
cb([]);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
250
257
|
const list = Array.isArray(rows) ? rows : [];
|
|
251
258
|
this._lastSuggestions = list;
|
|
252
259
|
cb(list);
|
|
@@ -267,20 +274,20 @@ export default {
|
|
|
267
274
|
}
|
|
268
275
|
},
|
|
269
276
|
lookupLabel(id) {
|
|
270
|
-
if (!hasValue(id) || hasValue(this.
|
|
277
|
+
if (!hasValue(id) || hasValue(this.storedLabel)) return;
|
|
271
278
|
if (typeof this.loadById !== "function") return;
|
|
272
279
|
const seq = ++this.lookupSeq;
|
|
273
280
|
let settled = false;
|
|
274
281
|
const done = (row) => {
|
|
275
282
|
if (settled || seq !== this.lookupSeq) return;
|
|
276
283
|
settled = true;
|
|
277
|
-
if (this.value !== id || hasValue(this.
|
|
284
|
+
if (this.value !== id || hasValue(this.storedLabel)) return;
|
|
278
285
|
const record = Array.isArray(row) ? row[0] : row;
|
|
279
286
|
if (!record || typeof record !== "object") return;
|
|
280
287
|
const label = record[this.resolvedLabelField] ?? null;
|
|
281
|
-
this.
|
|
288
|
+
this.storedLabel = label;
|
|
282
289
|
this.displayValue = label;
|
|
283
|
-
this.$emit("update:
|
|
290
|
+
this.$emit("update:label", label);
|
|
284
291
|
};
|
|
285
292
|
try {
|
|
286
293
|
const ret = this.loadById(id, done);
|
|
@@ -304,10 +311,10 @@ export default {
|
|
|
304
311
|
const id = row[this.resolvedValueField] ?? null;
|
|
305
312
|
const label = row[this.resolvedLabelField] ?? null;
|
|
306
313
|
const oldValue = this.value;
|
|
307
|
-
this.
|
|
314
|
+
this.storedLabel = label;
|
|
308
315
|
this.displayValue = label;
|
|
309
316
|
this.$emit("input", id);
|
|
310
|
-
this.$emit("update:
|
|
317
|
+
this.$emit("update:label", label);
|
|
311
318
|
const filled = collectFill(row, this.fillConfig);
|
|
312
319
|
if (this.data) {
|
|
313
320
|
Object.keys(filled).forEach((key) => {
|
|
@@ -326,11 +333,11 @@ export default {
|
|
|
326
333
|
handleClear() {
|
|
327
334
|
this.isSelecting = true;
|
|
328
335
|
const oldValue = this.value;
|
|
329
|
-
this.
|
|
336
|
+
this.storedLabel = null;
|
|
330
337
|
this.displayValue = null;
|
|
331
338
|
this.resetQueryCache();
|
|
332
339
|
this.$emit("input", null);
|
|
333
|
-
this.$emit("update:
|
|
340
|
+
this.$emit("update:label", null);
|
|
334
341
|
this.$emit("change", null, oldValue, null);
|
|
335
342
|
this.$emit("clear");
|
|
336
343
|
this.$nextTick(() => {
|
|
@@ -342,16 +349,31 @@ export default {
|
|
|
342
349
|
this.$emit("input-change", text);
|
|
343
350
|
},
|
|
344
351
|
handleFocus(event) {
|
|
352
|
+
this.focused = true;
|
|
353
|
+
const input = this.$refs.input;
|
|
354
|
+
if (input) input.suggestionDisabled = false;
|
|
345
355
|
this.$emit("focus", event);
|
|
346
356
|
},
|
|
347
357
|
handleBlur(event) {
|
|
358
|
+
this.focused = false;
|
|
359
|
+
this.$emit("blur", event);
|
|
348
360
|
setTimeout(() => {
|
|
349
361
|
if (this.isSelecting) return;
|
|
350
|
-
|
|
351
|
-
|
|
362
|
+
this.lastQueryKeyword = null;
|
|
363
|
+
this._lastSuggestions = null;
|
|
364
|
+
this.closeSuggestions();
|
|
365
|
+
if (this.displayValue !== this.storedLabel) {
|
|
366
|
+
this.displayValue = this.storedLabel;
|
|
352
367
|
}
|
|
353
368
|
}, 150);
|
|
354
|
-
|
|
369
|
+
},
|
|
370
|
+
closeSuggestions() {
|
|
371
|
+
const input = this.$refs.input;
|
|
372
|
+
if (!input) return;
|
|
373
|
+
input.activated = false;
|
|
374
|
+
input.suggestionDisabled = true;
|
|
375
|
+
input.highlightedIndex = -1;
|
|
376
|
+
if (Array.isArray(input.suggestions)) input.suggestions = [];
|
|
355
377
|
},
|
|
356
378
|
renderHighlight(item) {
|
|
357
379
|
const row = item || {};
|
|
@@ -379,6 +401,31 @@ export default {
|
|
|
379
401
|
</style>
|
|
380
402
|
|
|
381
403
|
<style lang="scss">
|
|
404
|
+
.base-autocomplete.el-autocomplete .el-input .el-input__suffix {
|
|
405
|
+
top: 0;
|
|
406
|
+
height: 100%;
|
|
407
|
+
display: flex;
|
|
408
|
+
align-items: center;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.base-autocomplete.el-autocomplete .el-input .el-input__suffix-inner {
|
|
412
|
+
display: inline-flex;
|
|
413
|
+
align-items: center;
|
|
414
|
+
height: 100%;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.base-autocomplete.el-autocomplete .el-input .el-input__icon {
|
|
418
|
+
float: none !important;
|
|
419
|
+
line-height: 1 !important;
|
|
420
|
+
display: inline-flex;
|
|
421
|
+
align-items: center;
|
|
422
|
+
justify-content: center;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.base-autocomplete.el-autocomplete .el-input__suffix-inner:has(.el-input__clear) > .el-input__icon:not(.el-input__clear) {
|
|
426
|
+
display: none;
|
|
427
|
+
}
|
|
428
|
+
|
|
382
429
|
.base-autocomplete-popper {
|
|
383
430
|
.el-autocomplete-suggestion__list li {
|
|
384
431
|
font-size: 13px;
|
|
@@ -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 (
|