<a-form-item label="创建时间" field="createTime">
<a-range-picker v-model="dateRange"
:disabledDate="disabledDate"
@select="calendarPriceRangeChange"
value-format="YYYY-MM-DD HH:mm:ss" style="width: 254px" />
</a-form-item>
let selectPriceDate = ref('');//可选时间区间,逻辑自行修改
const offsetDays = 86400000 * 7; //最多选择7天
/**
* 查询的时候只能选择前七天或者后七天,禁用其他时间
* @param current
*/
function disabledDate(current :any) {
if (selectPriceDate.value) {
let selectV = moment(selectPriceDate.value, 'YYYY-MM-DD').valueOf();
return (
current > moment(new Date(selectV + offsetDays), 'YYYY-MM-DD') ||
current < moment(new Date(selectV - offsetDays), 'YYYY-MM-DD')
);
} else {
return false;
}
}
/**
* 点击时间
* @param date
*/
const calendarPriceRangeChange = (date:any) => {
selectPriceDate.value = date[0];
};