更新
This commit is contained in:
@@ -11,13 +11,31 @@
|
|||||||
:disabled="isDisabled"
|
:disabled="isDisabled"
|
||||||
@change="change"
|
@change="change"
|
||||||
>
|
>
|
||||||
|
<template v-if="labelIsMore">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="(item, index) in list"
|
v-for="(item, index) in list"
|
||||||
:key="item.id + index"
|
:key="item.id + index"
|
||||||
|
:label="
|
||||||
|
item[config.labelKey[0]] +
|
||||||
|
'(' +
|
||||||
|
item[config.labelKey[1]] +
|
||||||
|
'-' +
|
||||||
|
item[config.labelKey[2]] +
|
||||||
|
')'
|
||||||
|
"
|
||||||
|
:value="item[config.valueKey]"
|
||||||
|
>
|
||||||
|
</el-option>
|
||||||
|
</template>
|
||||||
|
<template>
|
||||||
|
<el-option
|
||||||
|
v-for="(item, index) in list"
|
||||||
|
:key="index"
|
||||||
:label="item[config.labelKey]"
|
:label="item[config.labelKey]"
|
||||||
:value="item[config.valueKey]"
|
:value="item[config.valueKey]"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
|
</template>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -37,6 +55,8 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
text: "",
|
text: "",
|
||||||
|
labelIsMore: false,
|
||||||
|
// labelKeyArr:[],
|
||||||
list: [],
|
list: [],
|
||||||
isDisabled: false,
|
isDisabled: false,
|
||||||
};
|
};
|
||||||
@@ -44,48 +64,68 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
"config.echoId": {
|
"config.echoId": {
|
||||||
handler(nval, oval) {
|
handler(nval, oval) {
|
||||||
|
this.list = [];
|
||||||
|
// this.isDisabled = !!this.config.isDisabled;
|
||||||
if (nval) {
|
if (nval) {
|
||||||
this.remoteMethod(this.config.echoName);
|
let resultName = this.config.echoName.replace(/\s*/g, "");
|
||||||
|
if (!resultName) return;
|
||||||
|
this.remoteMethod(resultName);
|
||||||
}
|
}
|
||||||
this.isDisabled = !!this.config.isDisabled;
|
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
|
"config.isDisabled": {
|
||||||
|
handler(nval, oval) {
|
||||||
|
let type = this.$utils.typeJudgment(nval);
|
||||||
|
if (["Boolean", "String"].includes(type)) {
|
||||||
|
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: {
|
methods: {
|
||||||
// 远程搜索
|
// 远程搜索
|
||||||
remoteMethod(query) {
|
remoteMethod(query) {
|
||||||
if (query !== "") {
|
if (query !== "") {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
let params = {};
|
|
||||||
let type = this.$utils.typeJudgment(this.config.autocompleteKey);
|
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[this.config.autocompleteKey.key] = query;
|
||||||
params["enableMark"] = this.config.autocompleteKey.enableMark;
|
params["enableMark"] = this.config.autocompleteKey.enableMark;
|
||||||
}
|
}
|
||||||
if (type.includes("String")) {
|
if (["String", "Undefined", "Null"].includes(type)) {
|
||||||
|
// 接口为get类型时需将autocompleteKey值设为空
|
||||||
this.config.autocompleteKey
|
this.config.autocompleteKey
|
||||||
? (params[this.config.autocompleteKey] = query)
|
? (params[this.config.autocompleteKey] = query)
|
||||||
: (params["queryTypeGet"] = query);
|
: (params = query);
|
||||||
}
|
}
|
||||||
this.config.serveTarget(params).then((res) => {
|
this.config.serveTarget(params).then((res) => {
|
||||||
let timeInstance = setTimeout(() => {
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
clearTimeout(timeInstance);
|
|
||||||
if (res.data.length) {
|
if (res.data.length) {
|
||||||
this.list = res.data;
|
this.list = res.data;
|
||||||
} else this.list = [];
|
} else this.list = [];
|
||||||
}, 1000 * Math.random());
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.list = [];
|
this.list = [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
change(val) {
|
change(val) {
|
||||||
this.$emit("change", val);
|
this.$emit("change", val, this.list);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ export function isLicensePlate(no) {
|
|||||||
return instance.test(no);
|
return instance.test(no);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 类型判断
|
||||||
export function typeJudgment(object) {
|
export function typeJudgment(object) {
|
||||||
let res = {}.__proto__.toString.call(object);
|
let res = {}.__proto__.toString.call(object);
|
||||||
return res ? res : "";
|
let type = /(?<= ).+(?=\])/.exec(res);
|
||||||
|
return type.length ? type[0] : "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ export default {
|
|||||||
networkId,
|
networkId,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
this.loading = false;
|
||||||
if (res && res.code === 42014) {
|
if (res && res.code === 42014) {
|
||||||
serve
|
serve
|
||||||
.getRefineryByCustomerId(this.loginForm.username)
|
.getRefineryByCustomerId(this.loginForm.username)
|
||||||
@@ -154,7 +155,6 @@ export default {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log()
|
|
||||||
localStorage.setItem("customerToken", res.data.accessToken);
|
localStorage.setItem("customerToken", res.data.accessToken);
|
||||||
this.$router.replace("/");
|
this.$router.replace("/");
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
|
|
||||||
<autocomplete :params="parameter.params" :config="configAutocomplete" />
|
<autocomplete :params="parameter.params" :config="configAutocomplete" />
|
||||||
<!-- <el-input
|
<!-- <el-input
|
||||||
v-model="parameter.params.belongLibrary"
|
v-model="parameter.params.belongLibrary"
|
||||||
@@ -183,7 +184,7 @@ export default {
|
|||||||
],
|
],
|
||||||
configAutocomplete: {
|
configAutocomplete: {
|
||||||
serveTarget: serve.findByEntity,
|
serveTarget: serve.findByEntity,
|
||||||
autocomplateKey: "name",
|
autocompleteKey: "name",
|
||||||
valueKey: "refineryName",
|
valueKey: "refineryName",
|
||||||
placeholder: "炼厂名称",
|
placeholder: "炼厂名称",
|
||||||
querykey: "refineryId",
|
querykey: "refineryId",
|
||||||
|
|||||||
Reference in New Issue
Block a user