This commit is contained in:
ln1778 2024-09-13 12:04:24 +08:00
parent 57ef27b43d
commit 146a02cdd9
2 changed files with 34 additions and 18 deletions

View File

@ -9,9 +9,8 @@
<el-form label-position="left" size="small" :model="values" :inline="false" v-if="inputs.length>0" ref="queryformref"> <el-form label-position="left" size="small" :model="values" :inline="false" v-if="inputs.length>0" ref="queryformref">
<ag-row> <ag-row>
<ag-col :span="12" v-for="(item,index) in inputs" :key="index"> <ag-col :span="12" v-for="(item,index) in inputs" :key="index">
<el-form-item :label="item.label" :rules="item.rules" :prop="item.name"> <el-form-item :label="item.label" :rules="item.rules" :prop="item.name">
<ag-input :placeholder="item.placeholder" :value="item.value||''" closeable v-if="item.elem=='el-input'" @change="onSelect($event,item,index)"/> <ag-select :placeholder="item.placeholder" :value="item.value||''" closeable :options="item.options" style="width:100%" @change="onSelect($event,item,index)"/>
<ag-select :placeholder="item.placeholder" :value="item.value||''" closeable v-if="item.elem=='el-select'" :options="item.options" style="width:100%" @change="onSelect($event,item,index)"/>
</el-form-item> </el-form-item>
</ag-col> </ag-col>
</ag-row> </ag-row>
@ -53,6 +52,15 @@
return []; return [];
}, },
}, },
props:{
type: Object,
default: () => {
return {
lazyLoad (node, resolve) {
}
};
},
}
}, },
model: { model: {
prop: 'values', // prop 'value' prop: 'values', // prop 'value'
@ -61,14 +69,18 @@
mounted(){ mounted(){
let newinput=this.inputs.map((g)=>g.label); let newinput=this.inputs.map((g)=>g.label);
this.placeholder="请选择"+newinput.join("/"); this.placeholder="请选择"+newinput.join("/");
if(this.props.lazyLoad){
this.props.lazyLoad({level:0,pathLabels:this.values,value:""},(datas)=>{
this.inputs[index+1].options=datas;
});
}
}, },
data() { data() {
return { return {
values: {}, values: {},
placeholderValue:"", placeholderValue:"",
placeholder:"请选择", placeholder:"请选择",
popState:false, popState:false,
} }
}, },
methods: { methods: {
@ -76,22 +88,26 @@
this.values={}; this.values={};
this.$emit('onSearch',this.values); this.$emit('onSearch',this.values);
}, },
onSelect(value,item,index){ onSelect(value,item,index){
item.value=value; item.value=value;
this.$set(this.inputs,index,item); this.$set(this.inputs,index,item);
let newvalues={}; let newvalues={};
let newplaceholderValue=[]; let newplaceholderValue=[];
this.inputs.map((g)=>{ this.inputs.map((g)=>{
if(g.value&&g.name){ if(g.value&&g.name){
newvalues[g.name]=g.value; newvalues[g.name]=g.value;
g.options.find((f)=>f.value==g.value).label&&(newplaceholderValue.push(g.options.find((f)=>f.value==g.value).label)); g.options.find((f)=>f.value==g.value).label&&(newplaceholderValue.push(g.options.find((f)=>f.value==g.value).label));
} }
}); });
if(this.$listeners.change){ this.values=newvalues;
this.$emit('change',newvalues); if(this.$listeners.change){
} this.$emit('change',newvalues);
this.values=newvalues; }
this.placeholderValue=newplaceholderValue.join("/") this.props.lazyLoad({level:index+1,pathLabels:newvalues,value},(datas)=>{
this.inputs[index+1].options=datas;
});
this.placeholderValue=newplaceholderValue.join("/")
}, },
onCancel(){ onCancel(){
this.popState=false; this.popState=false;

View File

@ -218,7 +218,7 @@ export default {
}, },
{ {
label:"型号", label:"型号",
elem:'el-select', elem:'el-input',
name:"model", name:"model",
options: [] options: []
}, },