This commit is contained in:
ln1778 2024-09-09 15:24:33 +08:00
parent 2f9ddc22c0
commit b74f0ca3fc
4 changed files with 48 additions and 23 deletions

View File

@ -184,19 +184,27 @@ export default {
if (this.range) { if (this.range) {
if (!isEmpty(value) && value.length === 2 && value[0] && value[1]) { if (!isEmpty(value) && value.length === 2 && value[0] && value[1]) {
if(this.showTime){ if(this.showTime){
this.$emit("change", value); if(this.$listeners.change){
this.$emit("change", value);
}
}else{ }else{
this.$emit("change", [ if(this.$listeners.change){
`${value[0]} 00:00:00`, this.$emit("change", [
`${value[1]} 23:59:59`, `${value[0]} 00:00:00`,
]); `${value[1]} 23:59:59`,
]);
}
} }
} else { } else {
this.$emit("change", []); if(this.$listeners.change){
this.$emit("change", []);
}
} }
} else { } else {
this.$emit("change", value); if(this.$listeners.change){
this.$emit("change", value);
}
} }
}, },
}); });
@ -221,8 +229,7 @@ export default {
}, },
watch: { watch: {
value: { value: {
handler(newVal) { handler(newVal) {
console.log(newVal,'datevalue');
if (Array.isArray(newVal)&&this.range){ if (Array.isArray(newVal)&&this.range){
this.dateArr = [newVal[0] || "", newVal[1] || ""]; this.dateArr = [newVal[0] || "", newVal[1] || ""];
} else { } else {

View File

@ -152,10 +152,15 @@ export default {
}, },
methods: { methods: {
onSelect(value){ onSelect(value){
this.$emit("change", [value, this.value[1]||""]); if(this.$listeners.change){
this.$emit("change", [value, this.value[1]||""]);
}
}, },
onInputChange(val){ onInputChange(val){
this.$emit("change", [this.values[0] ||"",val]); if(this.$listeners.change){
this.$emit("change", [this.values[0] ||"",val]);
}
}, },
getStringWidth(text) { getStringWidth(text) {
let font = "13px"; let font = "13px";
@ -186,7 +191,10 @@ export default {
}, },
search(){ search(){
this.imeipopover=false; this.imeipopover=false;
this.$emit("onSrarch", this.value); if(this.$listeners.onSrarch){
this.$emit("onSrarch", this.value);
}
}, },
getAfterAgo(attr, prefix) { getAfterAgo(attr, prefix) {
const config = {}; const config = {};

View File

@ -59,7 +59,8 @@
model: { model: {
prop: 'values', // prop 'value' prop: 'values', // prop 'value'
event: 'onSearch' // value event: 'onSearch' // value
}, 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("/");
}, },
@ -73,6 +74,10 @@
} }
}, },
methods: { methods: {
onReset(){
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);
@ -84,24 +89,25 @@
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.$emit('change',newvalues); if(this.$listeners.change){
this.$emit('change',newvalues);
}
this.values=newvalues; this.values=newvalues;
this.placeholderValue=newplaceholderValue.join("/") this.placeholderValue=newplaceholderValue.join("/")
}, },
onCancel(){ onCancel(){
this.popState=false; this.popState=false;
this.$emit('cancel'); if(this.$listeners.onCancel){
this.$emit('onCancel');
}
}, },
onQuery(){ onQuery(){
console.log(this.$refs.queryformref,'this.$refs.queryformref');
if(this.$refs.queryformref){ if(this.$refs.queryformref){
this.$refs.queryformref.validate((valid) => { this.$refs.queryformref.validate((valid) => {
console.log(valid,"valid");
if (valid) { if (valid) {
this.$emit('onSearch',this.values); this.$emit('onSearch',this.values);
this.popState=false; this.popState=false;
} else { } else {
console.log('error submit!!');
return false; return false;
} }
}); });

View File

@ -52,10 +52,14 @@
}, },
methods: { methods: {
handleSizeChange(e){ handleSizeChange(e){
this.$emit('onSizeChange',e); if(this.$listeners.onSizeChange){
this.$emit('onSizeChange',e);
}
}, },
handleCurrentChange(e){ handleCurrentChange(e){
this.$emit('onCurrentChange',e); if(this.$listeners.onCurrentChange){
this.$emit('onCurrentChange',e);
}
} }
}, },
}; };