emis-frontend/src/views/emis/EmisBaseTools/TransProductCasPicker.vue

187 lines
4.2 KiB
Vue
Raw Normal View History

2024-05-12 21:27:19 +00:00
<template>
<el-cascader
:size="size"
:props="props"
:key="resetCascader"
v-model="svalue"
style="width: 100%"
clearable
filterable
2024-05-25 14:22:10 +00:00
@click.native="onClick"
2024-05-25 12:27:29 +00:00
@clear="onClear"
2024-05-25 14:22:10 +00:00
@blur="onBlur"
@change="onChange"
2024-05-12 21:27:19 +00:00
></el-cascader>
</template>
2024-05-31 00:36:52 +00:00
<!-- @input.native="searchFilter" -->
<!-- filterable -->
<!-- :before-filter="beforeFilter"
@input.native="searchFilter" -->
2024-05-12 21:27:19 +00:00
<script>
import { listSimpleEmisTransLine } from "@/api/emis/emisTransLine";
import { listSimpleEmisTransProduct } from "@/api/emis/emisTransProduct";
export default {
name: "TransProductCasPicker",
props: {
value: {
type: [String, Number,Array],
required: false
},
countryCode: {
type: String,
required: false
},
size:{
type: String,
required: false
}
},
data() {
return {
resetCascader:0,
svalue: this.value,
2024-05-25 14:22:10 +00:00
isInit: true,
2024-05-16 22:28:20 +00:00
lineCode:null,
prodCode:null,
2024-05-31 00:36:52 +00:00
searchVal:null,
2024-05-12 21:27:19 +00:00
props: {
// checkStrictly: true,
lazy: true,
lazyLoad: (node, resolve) => {
const nodes = [];
// level: 层级
// node 节点数据
// 一级菜单数据
2024-05-29 00:48:35 +00:00
let level = node.level;
// level==0 ? "1" : node.value;
2024-05-12 21:27:19 +00:00
let parentCode = node.value;
this.queryData(level,parentCode)
.then((res) => {
res.rows.map((item) => {
if(level==0){
let obj = {
value: item.lineCode,
label: item.lineName,
leaf: false,
};
nodes.push(obj);
}
else if(level==1){
let obj = {
value: item.prodCode,
2024-05-13 09:59:59 +00:00
label: item.prodName+"("+item.agingDesc+")",
2024-05-12 21:27:19 +00:00
leaf: true,
};
nodes.push(obj);
}
});
// resolve 节点返回
resolve(nodes);
})
.catch((error) => {
2024-05-31 23:31:01 +00:00
// console.log(error);
2024-05-12 21:27:19 +00:00
});
},
},
};
},
watch: {
value(newVal) {
this.svalue = newVal;
2024-05-29 00:48:35 +00:00
if(this.svalue!=null && this.svalue.length==2 && this.isInit) {
2024-05-16 22:28:20 +00:00
this.lineCode=this.svalue[0];
this.prodCode=this.svalue[1];
2024-05-25 14:22:10 +00:00
this.resetCascader++
2024-05-16 22:28:20 +00:00
}
2024-05-12 21:27:19 +00:00
},
countryCode(newVal) {
this.resetCascader++
}
},
created() {
2024-05-25 14:22:10 +00:00
2024-05-12 21:27:19 +00:00
},
methods: {
2024-05-31 00:36:52 +00:00
beforeFilter (val) {
return false;
},
searchFilter(el){
let val = el.target.value;
this.searchVal = val;
},
2024-05-25 12:27:29 +00:00
onClear(){
this.svalue = null;
this.$emit("input", this.svalue);
this.$emit("onChange", this.svalue);
},
2024-05-25 14:22:10 +00:00
onBlur(){
this.$emit("input", this.svalue);
this.$emit("onChange", this.svalue);
},
onClick(){
this.isInit = false;
2024-05-16 22:28:20 +00:00
this.lineCode=null;
this.prodCode=null;
this.queryData(0,0);
},
2024-05-25 14:22:10 +00:00
onChange(value) {
this.$emit("input", this.svalue);
this.$emit("onChange", this.svalue);
},
2024-05-31 00:36:52 +00:00
async queryData(level,parentCode,val) {
2024-05-16 22:28:20 +00:00
// 第1级是线路
2024-05-12 21:27:19 +00:00
if(level == 0){
let queryParams={
2024-05-25 14:22:10 +00:00
pageNum:1,
2024-05-31 00:36:52 +00:00
pageSize:500,
2024-05-16 22:28:20 +00:00
country:this.countryCode,
lineCode:this.lineCode,
2024-05-31 00:36:52 +00:00
lineName:this.searchVal
2024-05-12 21:27:19 +00:00
};
let res=await listSimpleEmisTransLine(queryParams);
return res;
}
// 产品
if(level == 1){
let queryParams={
2024-05-25 14:22:10 +00:00
pageNum:1,
2024-05-31 00:36:52 +00:00
pageSize:500,
2024-05-12 21:27:19 +00:00
transLineCode:parentCode,
2024-05-16 22:28:20 +00:00
prodCode:this.prodCode,
2024-05-12 21:27:19 +00:00
status:1
};
let res=await listSimpleEmisTransProduct(queryParams);
return res;
}
},
2024-05-25 14:22:10 +00:00
2024-05-12 21:27:19 +00:00
},
};
</script>
<style lang="scss" scoped>
.con {
display: inline-block;
}
.el-radio__inner {
border-radius: 0;
border: 0;
width: 170px;
height: 34px;
background-color: transparent;
cursor: pointer;
box-sizing: border-box;
position: absolute;
top: -18px;
left: -19px;
}
.el-radio__input.is-checked .el-radio__inner {
background: transparent;
}
</style>