<DatePicker
placeholder=" "
value="{
path:'OtherModel>endDate'
}"
valueState="None"
valueFormat="yyyy-MM-dd"
displayFormat="yyyy-MM-dd"
change=".onEndDateChange"
maxDate="{FCDataJsonModel>/maxDate}"
required="true"
editable= "{= ${OtherModel>/useKey} ==='all'? true : false}"
>
</DatePicker>
onEndDateChange(oEvent){
const sValue = oEvent.getParameter('value');
const endDate = new Date(sValue).getTime();
let oControl = oEvent.getSource();
let object = oControl.getBindingContext("OtherModel").getObject();
let tag = /^\d{1,4}(-)(1[0-2]|0?[1-9])\1(0?[1-9]|[1-2]\d|30|31)$/.test(object.endDate);
if(!tag) {
MessageBox.error("非法的日期格式");
oEvent.getSource().setValue("");
}
if(object.startDate) {
let startDate = new Date(object.startDate).getTime();
if(startDate > endDate) {
oEvent.getSource().setValue("");
MessageBox.error("结束日期不能早于开始日期");
}
}
},