| | |
| | | <el-date-picker class="command-date-picker" |
| | | popper-class="command-date-picker-popper" v-model="flyDateRange" |
| | | type="datetimerange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" |
| | | :disabled-date="disabledFlyDate" :disabled-time="disabledFlyTime" |
| | | value-format="YYYY-MM-DD HH:mm:ss" clearable /> |
| | | </el-form-item> |
| | | <el-form-item label="关联派出所" prop="policeStationId"> |
| | |
| | | deviceIds: fieldRules(false), |
| | | } |
| | | |
| | | function isSameDay (left, right) { |
| | | return ( |
| | | left.getFullYear() === right.getFullYear() && |
| | | left.getMonth() === right.getMonth() && |
| | | left.getDate() === right.getDate() |
| | | ) |
| | | } |
| | | |
| | | const disabledFlyDate = time => { |
| | | const startOfToday = new Date() |
| | | startOfToday.setHours(0, 0, 0, 0) |
| | | return time.getTime() < startOfToday.getTime() |
| | | } |
| | | |
| | | const disabledFlyTime = date => { |
| | | if (!date) return {} |
| | | const now = new Date() |
| | | if (!isSameDay(date, now)) return {} |
| | | const currentHour = now.getHours() |
| | | const currentMinute = now.getMinutes() |
| | | const currentSecond = now.getSeconds() |
| | | return { |
| | | disabledHours: () => Array.from({ length: currentHour }, (_, index) => index), |
| | | disabledMinutes: hour => |
| | | hour === currentHour ? Array.from({ length: currentMinute }, (_, index) => index) : [], |
| | | disabledSeconds: (hour, minute) => |
| | | hour === currentHour && minute === currentMinute |
| | | ? Array.from({ length: currentSecond }, (_, index) => index) |
| | | : [], |
| | | } |
| | | } |
| | | |
| | | // 关闭弹框 |
| | | function handleCancel () { |
| | | visible.value = false |