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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.1.0-dev.67",
4
+ "version": "1.1.0-dev.69",
5
5
  "scripts": {
6
6
  "build:ace-resources": "node build/build-ace-resources.js",
7
7
  "build:tinymce-resources": "node build/build-tinymce-resources.js",
@@ -56,7 +56,7 @@ import {
56
56
  *
57
57
  * <base-autocomplete
58
58
  * v-model="form.saleOrgId"
59
- * :name.sync="form.saleOrgName"
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
- name: {
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
- storedName: null,
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
- name(val) {
191
- this.storedName = val ?? null;
191
+ label(val) {
192
+ this.storedLabel = val ?? null;
192
193
  if (!this.isSelecting) {
193
- this.displayValue = this.storedName;
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.storedName = this.name ?? null;
206
- this.displayValue = this.storedName;
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.storedName)) return;
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.storedName)) return;
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.storedName = label;
288
+ this.storedLabel = label;
282
289
  this.displayValue = label;
283
- this.$emit("update:name", label);
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.storedName = label;
314
+ this.storedLabel = label;
308
315
  this.displayValue = label;
309
316
  this.$emit("input", id);
310
- this.$emit("update:name", label);
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.storedName = null;
336
+ this.storedLabel = null;
330
337
  this.displayValue = null;
331
338
  this.resetQueryCache();
332
339
  this.$emit("input", null);
333
- this.$emit("update:name", null);
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
- if (this.displayValue !== this.storedName) {
351
- this.displayValue = this.storedName;
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
- this.$emit("blur", event);
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
  ];
@@ -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 (settingConfig.requestAesEnabled === true && canEncryptBody) {
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 (