liunan #10

Merged
liunan merged 47 commits from liunan into master 2024-09-13 14:43:34 +08:00
2 changed files with 88 additions and 16 deletions
Showing only changes of commit baa8568ea8 - Show all commits

View File

@ -10,7 +10,7 @@
> >
<span class="el-dropdown-link"> <span class="el-dropdown-link">
<span> <span>
<span :class="{ color: checkedList.length }">{{ dropdownvalue }}</span <span :class="{ color: checkedList.length }">{{ checkedList.length==0?placeholder:dropdownvalue }}</span
><span class="list-length" v-if="valuelength >= 1" ><span class="list-length" v-if="valuelength >= 1"
>+ {{ valuelength }}</span >+ {{ valuelength }}</span
></span ></span
@ -89,9 +89,14 @@
olddatas:[ olddatas:[
{label:"方法1",value:"1"}, {label:"方法1",value:"1"},
{label:"方法2",value:"2"} {label:"方法2",value:"2"}
] ],
oldvalue:[]
}; };
}, },
model: {
prop: 'value', // prop 'value'
event: 'onSearch' // value
},
mounted() { mounted() {
if(this.datas&&Array.isArray(this.datas)){ if(this.datas&&Array.isArray(this.datas)){
this.dataList = this.datas; this.dataList = this.datas;
@ -103,6 +108,26 @@
} }
if(this.value){ if(this.value){
this.checkedList=this.value; this.checkedList=this.value;
const filters=this.olddatas.filter((f)=>{
return this.checkedList.find((c)=>c==f.value);
});
if(filters.length>0){
const [onedatas,...otherdatas]=filters;
this.valuelength=otherdatas.length;
this.dropdownvalue=onedatas.label;
if(filters.length==this.olddatas.length){
this.checkAll=true;
this.isIndeterminate=false;
}else{
this.checkAll=false;
this.isIndeterminate=true;
}
}else{
this.valuelength=0;
this.dropdownvalue="";
this.checkAll=false;
this.isIndeterminate=false;
}
} }
}else{ }else{
this.olddatas=Object.assign([],this.dataList); this.olddatas=Object.assign([],this.dataList);
@ -121,6 +146,26 @@
} }
if(this.value){ if(this.value){
this.checkedList=this.value; this.checkedList=this.value;
const filters=this.olddatas.filter((f)=>{
return this.checkedList.find((c)=>c==f.value);
});
if(filters.length>0){
const [onedatas,...otherdatas]=filters;
this.valuelength=otherdatas.length;
this.dropdownvalue=onedatas.label;
if(filters.length==this.olddatas.length){
this.checkAll=true;
this.isIndeterminate=false;
}else{
this.checkAll=false;
this.isIndeterminate=true;
}
}else{
this.valuelength=0;
this.dropdownvalue="";
this.checkAll=false;
this.isIndeterminate=false;
}
} }
} else{ } else{
this.olddatas=Object.assign([],this.dataList); this.olddatas=Object.assign([],this.dataList);
@ -136,8 +181,9 @@
this.isIndeterminate = false; this.isIndeterminate = false;
this.checkAll=false; this.checkAll=false;
}, },
checkeddown(val){ checkeddown(val){
console.log(val,"val") this.oldvalue={list:this.checkedList,checkAll:this.checkAll,isIndeterminate:this.isIndeterminate};
}, },
dropdownchange(){ dropdownchange(){
@ -152,21 +198,42 @@
this.isIndeterminate = false; this.isIndeterminate = false;
this.checkAll=val; this.checkAll=val;
}, },
confirm(e){ confirm(e,type){
if(e&&type=="only"){
this.checkedList=[e.value];
if(this.olddatas.length!=1){
this.isIndeterminate=true;
this.checkAll=false;
}else{
this.isIndeterminate=false;
this.checkAll=true;
}
if(e&&e.label=="only"){
const filters=this.olddatas.filter((f)=>{ const filters=this.olddatas.filter((f)=>{
return e.value.find((c)=>c==f.value); return f.value==e.value
}); });
const [onedatas,...otherdatas]=filters;
this.valuelength=otherdatas.length;
this.dropdownvalue=onedatas.label;
if(this.$listeners.onSearch){ if(this.$listeners.onSearch){
this.$emit("onSearch",[e.value]); this.$emit("onSearch",[e.value]);
} }
if(filters.length==0){
this.valuelength=0;
this.dropdownvalue="";
this.$refs.multioncheckref.hide();
return;
}
const [onedatas,...otherdatas]=filters;
this.valuelength=otherdatas.length;
this.dropdownvalue=onedatas.label;
}else{ }else{
if(this.checkedList.length==0){
this.valuelength=0;
this.dropdownvalue="";
if(this.$listeners.onSearch){
this.$emit("onSearch",this.checkedList);
}
this.$refs.multioncheckref.hide();
return;
}
const filters=this.olddatas.filter((f)=>{ const filters=this.olddatas.filter((f)=>{
return this.checkedList.find((c)=>c==f.value); return this.checkedList.find((c)=>c==f.value);
}); });
@ -193,6 +260,10 @@
} }
}, },
cancel(){ cancel(){
this.checkedList=this.oldvalue.list;
this.isIndeterminate=this.oldvalue.isIndeterminate;
this.checkAll=this.oldvalue.checkAll;
this.$refs.multioncheckref.hide(); this.$refs.multioncheckref.hide();
} }

View File

@ -54,7 +54,7 @@
</agUpdate> </agUpdate>
<ag-form :data="formdata" label-width="120px" label-position="right" v-model="formvalue"> <ag-form :data="formdata" label-width="120px" label-position="right" v-model="formvalue">
</ag-form> </ag-form>
<ag-mution-checkbox :datas="checklist" @onSearch="onCheckSearch"> </ag-mution-checkbox> <ag-mution-checkbox :datas="checklist" @onSearch="onCheckSearch" placeholder="请选择" v-model="checkvalue"> </ag-mution-checkbox>
<!-- <el-input agMultionCheckbox <!-- <el-input agMultionCheckbox
size="small" size="small"
placeholder="请输入内容" placeholder="请输入内容"
@ -141,6 +141,7 @@ export default {
}, },
inputValue:"", inputValue:"",
date_value:null, date_value:null,
checkvalue:['2'],
value: "选项1", value: "选项1",
a_value: "59584", a_value: "59584",
values: ["4",""], values: ["4",""],
@ -471,7 +472,7 @@ export default {
this.$refs.ttt.values; this.$refs.ttt.values;
}, },
onCheckSearch(val){ onCheckSearch(val){
console.log(val,'onCheckSearch'); console.log(val,'onCheckSearch',this.checkvalue);
}, },
changes(val) { changes(val) {
console.log(val); console.log(val);