import request from '@/config/axios'
|
|
/**
|
* 预约时段规则(queue_sequence 表)
|
*
|
* 业务说明:
|
* 该表记录**每个检查项目在每个预约时段的取号规则**:
|
* · queueSet / queueFull —— 普通患者在该时段的「起始序号」与「序号上限」
|
* · queueNo —— 当前已发到几号(取号时从此值往后发)
|
* · vip 三个字段同理
|
*
|
* 该表**原为每天自动生成**,现已改为**手工维护**(故需要维护界面)。
|
* 注意:每日重置仍在运行(`QueueSequenceMapper#initNumber` 会把
|
* `queue_no` 重置回 `queue_set`),所以维护时**主要改 queueSet / queueFull**。
|
*
|
* 时段值 timeSlot 为 `HHMMHHMM` 形式,如 `8000830` 表示 `08:00-08:30`
|
* (小时不补零,故 800 即 08:00)。可用下方 formatTimeSlot / parseTimeSlot 转换。
|
*/
|
export interface QueueSequenceVO {
|
id?: number // id(新增时留空)
|
checkType?: number // 检查项目(check_type.value)
|
timeSlot?: number // 时段(HHMMHHMM)
|
queueNo?: number // 普通:当前序号
|
queueSet?: number // 普通:起始序号(每日重置回到此值)
|
queueVipNo?: number // vip:当前序号
|
queueVipSet?: number // vip:起始序号
|
queueFull?: number // 普通:序号上限
|
queueVipFull?: number // vip:序号上限
|
createTime?: Date
|
}
|
|
// 排队 API
|
export const QueueSequenceApi = {
|
|
// 获得当天未满的VIP时间段
|
getTimeslotByCheckType: async (checkType: number) => {
|
return await request.get({ url: `/ecg/queue-sequence/get-timeslot-by-checktype?checkType=` + checkType })
|
},
|
|
// ==================== 预约时段维护(增 / 删 / 改 / 查) ====================
|
|
/** 分页查询预约时段规则 */
|
getQueueSequencePage: async (params: any) => {
|
return await request.get({ url: `/ecg/queue-sequence/page`, params })
|
},
|
|
/** 查询单条预约时段规则 */
|
getQueueSequence: async (id: number) => {
|
return await request.get({ url: `/ecg/queue-sequence/get?id=` + id })
|
},
|
|
/** 新增预约时段规则 */
|
createQueueSequence: async (data: QueueSequenceVO) => {
|
return await request.post({ url: `/ecg/queue-sequence/create`, data })
|
},
|
|
/** 修改预约时段规则 */
|
updateQueueSequence: async (data: QueueSequenceVO) => {
|
return await request.put({ url: `/ecg/queue-sequence/update`, data })
|
},
|
|
/** 删除预约时段规则 */
|
deleteQueueSequence: async (id: number) => {
|
return await request.delete({ url: `/ecg/queue-sequence/delete?id=` + id })
|
}
|
|
}
|
|
/**
|
* 把 `HHMMHHMM` 形式的时段值格式化为 `HH:mm-HH:mm`。
|
*
|
* 例:8000830 → "08:00-08:30";13301400 → "13:30-14:00"
|
* 无法解析时原样返回字符串。
|
*/
|
export function formatTimeSlot(timeSlot?: number | null): string {
|
if (timeSlot === null || timeSlot === undefined) return '-'
|
const s = String(timeSlot)
|
if (!/^\d{5,8}$/.test(s)) return s
|
// 约定:最后 4 位为结束 HHmm,其余为开始 HHmm
|
const endPart = s.slice(-4)
|
const startPart = s.slice(0, s.length - 4)
|
const fmt = (p: string): string => {
|
if (p.length < 3) return p
|
const mm = p.slice(-2)
|
const hh = p.slice(0, p.length - 2)
|
return `${hh.padStart(2, '0')}:${mm}`
|
}
|
return `${fmt(startPart)}-${fmt(endPart)}`
|
}
|
|
/**
|
* 把 `HH:mm-HH:mm` 解析回 `HHMMHHMM` 数值。
|
* 例:"08:00-08:30" → 8000830
|
* 解析失败返回 undefined。
|
*/
|
export function parseTimeSlot(text?: string | null): number | undefined {
|
if (!text) return undefined
|
const m = String(text).trim().match(/^(\d{1,2}):(\d{2})\s*-\s*(\d{1,2}):(\d{2})$/)
|
if (!m) return undefined
|
const [, h1, m1, h2, m2] = m
|
return Number(`${Number(h1)}${m1}${Number(h2)}${m2}`)
|
}
|