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

@ -10,8 +10,7 @@
<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,6 +69,11 @@
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 {
@ -68,7 +81,6 @@
placeholderValue:"", placeholderValue:"",
placeholder:"请选择", placeholder:"请选择",
popState:false, popState:false,
} }
}, },
methods: { methods: {
@ -80,18 +92,22 @@
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));
}
});
this.values=newvalues;
if(this.$listeners.change){
this.$emit('change',newvalues);
} }
}); this.props.lazyLoad({level:index+1,pathLabels:newvalues,value},(datas)=>{
if(this.$listeners.change){ this.inputs[index+1].options=datas;
this.$emit('change',newvalues); });
} this.placeholderValue=newplaceholderValue.join("/")
this.values=newvalues;
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: []
}, },