diff --git a/src/components/autocomplete/index.vue b/src/components/autocomplete/index.vue
index 126bba9..9055981 100644
--- a/src/components/autocomplete/index.vue
+++ b/src/components/autocomplete/index.vue
@@ -11,13 +11,31 @@
:disabled="isDisabled"
@change="change"
>
-
-
+
+
+
+
+
+
+
+
@@ -37,6 +55,8 @@ export default {
data() {
return {
text: "",
+ labelIsMore: false,
+ // labelKeyArr:[],
list: [],
isDisabled: false,
};
@@ -44,48 +64,68 @@ export default {
watch: {
"config.echoId": {
handler(nval, oval) {
+ this.list = [];
+ // this.isDisabled = !!this.config.isDisabled;
if (nval) {
- this.remoteMethod(this.config.echoName);
+ let resultName = this.config.echoName.replace(/\s*/g, "");
+ if (!resultName) return;
+ this.remoteMethod(resultName);
+ }
+ },
+ deep: true,
+ immediate: true,
+ },
+ "config.isDisabled": {
+ handler(nval, oval) {
+ let type = this.$utils.typeJudgment(nval);
+ if (["Boolean", "String"].includes(type)) {
+ this.isDisabled = !!this.config.isDisabled;
}
- this.isDisabled = !!this.config.isDisabled;
},
deep: true,
immediate: true,
},
},
+ created() {
+ let { labelKey } = this.config;
+ let type = this.$utils.typeJudgment(labelKey);
+ // console.log(type);
+ if (type === "Array") {
+ // let
+ this.labelIsMore = true;
+ // console.log(this.labelIsMore);
+ }
+ },
methods: {
// 远程搜索
remoteMethod(query) {
if (query !== "") {
this.loading = true;
- let params = {};
let type = this.$utils.typeJudgment(this.config.autocompleteKey);
- if (!type.includes("Object") && !type.includes("String")) return;
- if (type.includes("Object")) {
+ let params = {};
+ if (["Object"].includes(type)) {
params[this.config.autocompleteKey.key] = query;
params["enableMark"] = this.config.autocompleteKey.enableMark;
}
- if (type.includes("String")) {
+ if (["String", "Undefined", "Null"].includes(type)) {
+ // 接口为get类型时需将autocompleteKey值设为空
this.config.autocompleteKey
? (params[this.config.autocompleteKey] = query)
- : (params["queryTypeGet"] = query);
+ : (params = query);
}
this.config.serveTarget(params).then((res) => {
- let timeInstance = setTimeout(() => {
- this.loading = false;
- clearTimeout(timeInstance);
- if (res.data.length) {
- this.list = res.data;
- } else this.list = [];
- }, 1000 * Math.random());
+ this.loading = false;
+ if (res.data.length) {
+ this.list = res.data;
+ } else this.list = [];
});
} else {
this.list = [];
}
},
change(val) {
- this.$emit("change", val);
+ this.$emit("change", val, this.list);
},
},
};
diff --git a/src/utils/index.js b/src/utils/index.js
index d33d6ac..2e719e4 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -52,7 +52,9 @@ export function isLicensePlate(no) {
return instance.test(no);
}
+// 类型判断
export function typeJudgment(object) {
let res = {}.__proto__.toString.call(object);
- return res ? res : "";
+ let type = /(?<= ).+(?=\])/.exec(res);
+ return type.length ? type[0] : "";
}
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index 9ea2be5..bb65af6 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -145,6 +145,7 @@ export default {
networkId,
})
.then((res) => {
+ this.loading = false;
if (res && res.code === 42014) {
serve
.getRefineryByCustomerId(this.loginForm.username)
@@ -154,7 +155,6 @@ export default {
});
return;
}
- console.log()
localStorage.setItem("customerToken", res.data.accessToken);
this.$router.replace("/");
})
diff --git a/src/views/product/index.vue b/src/views/product/index.vue
index 71f65a1..9495e20 100644
--- a/src/views/product/index.vue
+++ b/src/views/product/index.vue
@@ -33,6 +33,7 @@
>
+