This commit is contained in:
xiaozhiyong
2023-02-23 16:08:14 +08:00
parent 2594c97ec2
commit 70d54bcfa5
14 changed files with 515 additions and 447 deletions

View File

@@ -58,27 +58,33 @@ export default {
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") && !type.includes("String")) {
// this.loading = false;
// this.$message.warning("config.autocompleteKey格式有误");
// return;
// }
let params = {};
if (type.includes("Object")) {
params[this.config.autocompleteKey.key] = query;
params["enableMark"] = this.config.autocompleteKey.enableMark;
}
if (type.includes("String")) {
if (
type.includes("String") ||
type.includes("Undefined") ||
type.includes("Null")
) {
// 接口为get类型时需将autocompleteKey值设为空
console.log();
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 = [];