Commit ea6a0ed8 by tang

feat: 查询只能输入中英文字符和数字

parent a2eb745a
...@@ -112,6 +112,9 @@ export default { ...@@ -112,6 +112,9 @@ export default {
params.firmName = this.search.code params.firmName = this.search.code
} }
this.searchCodeShow = this.search.code; this.searchCodeShow = this.search.code;
if(this.hasSpecialString(this.searchCodeShow)){
return true
}
this.showResult = true; this.showResult = true;
const searchGlnRes = await this.$api.search.searchBike(params); const searchGlnRes = await this.$api.search.searchBike(params);
const {returnCode, data} = searchGlnRes; const {returnCode, data} = searchGlnRes;
......
...@@ -108,6 +108,9 @@ export default { ...@@ -108,6 +108,9 @@ export default {
}, },
async handleSearch() { async handleSearch() {
this.searchCodeShow = this.search.code; this.searchCodeShow = this.search.code;
if(this.hasSpecialString(this.searchCodeShow)){
return true
}
this.showResult = true; this.showResult = true;
const params = { const params = {
"code": this.search.code, "code": this.search.code,
......
...@@ -124,8 +124,19 @@ export default { ...@@ -124,8 +124,19 @@ export default {
this.captchaPath = window.URL.createObjectURL(res.body); this.captchaPath = window.URL.createObjectURL(res.body);
}); });
}, },
hasSpecialString(string){
const regName =/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/;
if(!regName.test(string)){
this.$message.error('查询值只能包含中英文字符和数字!');
return true;
}
return true
},
async handleSearch() { async handleSearch() {
this.searchCodeShow = this.search.code; this.searchCodeShow = this.search.code;
if(this.hasSpecialString(this.searchCodeShow)){
return true
}
this.showResult = true; this.showResult = true;
const params = {...this.search}; const params = {...this.search};
const searchGlnRes = await this.$api.search.searchGln(params); const searchGlnRes = await this.$api.search.searchGln(params);
......
...@@ -100,6 +100,9 @@ export default { ...@@ -100,6 +100,9 @@ export default {
captcha: this.captcha, captcha: this.captcha,
}; };
this.searchCodeShow = this.search.code; this.searchCodeShow = this.search.code;
if(this.hasSpecialString(this.searchCodeShow)){
return true
}
this.showResult = true; this.showResult = true;
const searchGlnRes = await this.$api.search.searchGlossary(params); const searchGlnRes = await this.$api.search.searchGlossary(params);
const {returnCode, data} = searchGlnRes; const {returnCode, data} = searchGlnRes;
......
...@@ -387,8 +387,6 @@ export default { ...@@ -387,8 +387,6 @@ export default {
}, },
async handleSearchCompany() { async handleSearchCompany() {
this.showResult = true;
this.resultType = 'company'
if (this.company === CODE) { if (this.company === CODE) {
this.searchCodeShow = this.companySearch.code; this.searchCodeShow = this.companySearch.code;
} else if (this.company === NAME) { } else if (this.company === NAME) {
...@@ -396,6 +394,11 @@ export default { ...@@ -396,6 +394,11 @@ export default {
} else { } else {
this.searchCodeShow = this.companySearch.address; this.searchCodeShow = this.companySearch.address;
} }
if(this.hasSpecialString(this.searchCodeShow)){
return true
}
this.showResult = true;
this.resultType = 'company'
const params = {type: this.company, uuid: this.uuid, code: this.searchCodeShow, captcha: this.captcha,}; const params = {type: this.company, uuid: this.uuid, code: this.searchCodeShow, captcha: this.captcha,};
const searchGlnRes = await this.$api.search.searchInternal(params); const searchGlnRes = await this.$api.search.searchInternal(params);
const {returnCode, data} = searchGlnRes; const {returnCode, data} = searchGlnRes;
...@@ -422,6 +425,9 @@ export default { ...@@ -422,6 +425,9 @@ export default {
if (!this.productSearch.code) { if (!this.productSearch.code) {
return this.$message.error('请输入商品条码'); return this.$message.error('请输入商品条码');
} }
if(this.hasSpecialString(this.productSearch.code)){
return true
}
this.showResult = true; this.showResult = true;
this.resultType = 'product'; this.resultType = 'product';
const params = {code: this.productSearch.code}; const params = {code: this.productSearch.code};
......
...@@ -129,8 +129,6 @@ export default { ...@@ -129,8 +129,6 @@ export default {
}, },
methods: { methods: {
async handleSearchCompany() { async handleSearchCompany() {
this.showResult = true;
const params = { const params = {
shortCode: "", shortCode: "",
firmName: "", firmName: "",
...@@ -140,13 +138,22 @@ export default { ...@@ -140,13 +138,22 @@ export default {
}; };
if (this.company === CODE) { if (this.company === CODE) {
params.shortCode = this.companySearch.code; params.shortCode = this.companySearch.code;
if(this.hasSpecialString(this.companySearch.code)){
return true
}
} else if (this.company === NAME) { } else if (this.company === NAME) {
params.firmName = this.companySearch.name; params.firmName = this.companySearch.name;
if(this.hasSpecialString(this.companySearch.name)){
return true
}
} else { } else {
params.registerAddress = this.companySearch.address; params.registerAddress = this.companySearch.address;
if(this.hasSpecialString(this.companySearch.address)){
return true
}
} }
this.showResult = true;
const searchGlnRes = await this.$api.search.searchGetList(params); const searchGlnRes = await this.$api.search.searchGetList(params);
console.log(searchGlnRes)
const {returnCode, data} = searchGlnRes; const {returnCode, data} = searchGlnRes;
if (returnCode === "0") { if (returnCode === "0") {
// this.result = data; // this.result = data;
......
...@@ -21,5 +21,13 @@ export default { ...@@ -21,5 +21,13 @@ export default {
this.captchaPath = window.URL.createObjectURL(res.body); this.captchaPath = window.URL.createObjectURL(res.body);
}); });
}, },
hasSpecialString(string){
const regName =/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/;
if(!regName.test(string)){
this.$message.error('查询值只能包含中英文字符和数字!');
return true;
}
return true
}
}, },
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment