|
@@ -63,7 +63,7 @@
|
|
|
<el-form-item label="提前预约天数" prop="advanceDays">
|
|
<el-form-item label="提前预约天数" prop="advanceDays">
|
|
|
<el-input-number
|
|
<el-input-number
|
|
|
v-model="formData.advanceDays"
|
|
v-model="formData.advanceDays"
|
|
|
- :min="0"
|
|
|
|
|
|
|
+ :min="1"
|
|
|
:max="30"
|
|
:max="30"
|
|
|
style="width: 100%"
|
|
style="width: 100%"
|
|
|
:disabled="isDisabled"
|
|
:disabled="isDisabled"
|
|
@@ -136,6 +136,14 @@
|
|
|
自定义
|
|
自定义
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <el-switch
|
|
|
|
|
+ v-model="formData.appointmentEnabled"
|
|
|
|
|
+ active-text="启用"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ style="margin-right: 1vw"
|
|
|
|
|
+ inactive-text="关闭"
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
<el-button
|
|
<el-button
|
|
|
type="danger"
|
|
type="danger"
|
|
|
link
|
|
link
|
|
@@ -669,6 +677,20 @@ const isOverlap = (item1: AppointmentItem, item2: AppointmentItem): boolean => {
|
|
|
return s1 < e2 && s2 < e1
|
|
return s1 < e2 && s2 < e1
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const getDateDayOfMonth = (dateStr: string): number => {
|
|
|
|
|
+ const parts = dateStr.split('-')
|
|
|
|
|
+ if (parts.length !== 3) return -1
|
|
|
|
|
+ return Number(parts[2])
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const getDateWeekDay = (dateStr: string): number => {
|
|
|
|
|
+ const parts = dateStr.split('-').map(Number)
|
|
|
|
|
+ if (parts.length !== 3) return -1
|
|
|
|
|
+ const date = new Date(parts[0], parts[1] - 1, parts[2])
|
|
|
|
|
+ const day = date.getDay()
|
|
|
|
|
+ return day === 0 ? 7 : day
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const checkTimeOverlap = (group: AppointmentGroup, changedIndex: number) => {
|
|
const checkTimeOverlap = (group: AppointmentGroup, changedIndex: number) => {
|
|
|
const changedItem = group.items[changedIndex]
|
|
const changedItem = group.items[changedIndex]
|
|
|
if (!changedItem.startTime || !changedItem.endTime) return
|
|
if (!changedItem.startTime || !changedItem.endTime) return
|
|
@@ -698,7 +720,7 @@ const addAppointmentGroup = () => {
|
|
|
{
|
|
{
|
|
|
id: itemIdCounter,
|
|
id: itemIdCounter,
|
|
|
startTime: '08:00',
|
|
startTime: '08:00',
|
|
|
- endTime: '12:00',
|
|
|
|
|
|
|
+ endTime: '09:00',
|
|
|
limitCount: 100
|
|
limitCount: 100
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
@@ -861,10 +883,21 @@ const removePersonLimit = (index: number) => {
|
|
|
personLimits.value.splice(index, 1)
|
|
personLimits.value.splice(index, 1)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const validateAdvanceDays = (_rule: any, value: any, callback: any) => {
|
|
|
|
|
+ if (!value || value < 1) {
|
|
|
|
|
+ callback(new Error('提前预约天数最少为1'))
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback()
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const formRules: FormRules = reactive({
|
|
const formRules: FormRules = reactive({
|
|
|
ruleType: [{ required: true, message: '请选择放号规则', trigger: 'change' }],
|
|
ruleType: [{ required: true, message: '请选择放号规则', trigger: 'change' }],
|
|
|
startDay: [{ required: true, message: '请选择开始预约日', trigger: 'change' }],
|
|
startDay: [{ required: true, message: '请选择开始预约日', trigger: 'change' }],
|
|
|
- advanceDays: [{ required: true, message: '请输入提前预约天数', trigger: 'change' }]
|
|
|
|
|
|
|
+ advanceDays: [
|
|
|
|
|
+ { required: true, message: '请输入提前预约天数', trigger: 'change' },
|
|
|
|
|
+ { validator: validateAdvanceDays, trigger: 'change' }
|
|
|
|
|
+ ]
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const changeTen = (i: any[]) => {
|
|
const changeTen = (i: any[]) => {
|
|
@@ -963,15 +996,131 @@ const getSetting = async () => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const validateGroups = (): string | null => {
|
|
|
|
|
+ if (appointmentGroups.value.length === 0) {
|
|
|
|
|
+ return '请至少添加一个预约组'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const dailyGroups = appointmentGroups.value.filter((g) => g.cycleType === 'daily')
|
|
|
|
|
+ if (dailyGroups.length > 0 && appointmentGroups.value.length > 1) {
|
|
|
|
|
+ return '选择每天时,只能有一个预约组'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const weeklyGroups = appointmentGroups.value.filter((g) => g.cycleType === 'weekly')
|
|
|
|
|
+ const monthlyGroups = appointmentGroups.value.filter((g) => g.cycleType === 'monthly')
|
|
|
|
|
+
|
|
|
|
|
+ if (weeklyGroups.length > 0 && monthlyGroups.length > 0) {
|
|
|
|
|
+ return '每周和每月预约组不能同时存在'
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (weeklyGroups.length > 1) {
|
|
|
|
|
+ const usedDays = new Set<number>()
|
|
|
|
|
+ for (const group of weeklyGroups) {
|
|
|
|
|
+ for (const day of group.weeklyDays) {
|
|
|
|
|
+ if (usedDays.has(day)) {
|
|
|
|
|
+ return '不同每周预约组存在重复的星期'
|
|
|
|
|
+ }
|
|
|
|
|
+ usedDays.add(day)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (monthlyGroups.length > 1) {
|
|
|
|
|
+ const usedDays = new Set<number>()
|
|
|
|
|
+ for (const group of monthlyGroups) {
|
|
|
|
|
+ for (const day of group.monthlyDays) {
|
|
|
|
|
+ if (usedDays.has(day)) {
|
|
|
|
|
+ return '不同每月预约组存在重复的日期'
|
|
|
|
|
+ }
|
|
|
|
|
+ usedDays.add(day)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const customGroups = appointmentGroups.value.filter((g) => g.cycleType === 'custom')
|
|
|
|
|
+ if (customGroups.length > 1) {
|
|
|
|
|
+ const usedDates = new Set<string>()
|
|
|
|
|
+ for (const group of customGroups) {
|
|
|
|
|
+ for (const date of group.customDates) {
|
|
|
|
|
+ if (usedDates.has(date)) {
|
|
|
|
|
+ return '不同自定义预约组存在重复的日期'
|
|
|
|
|
+ }
|
|
|
|
|
+ usedDates.add(date)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (monthlyGroups.length > 0 && customGroups.length > 0) {
|
|
|
|
|
+ const usedDays = new Set<number>()
|
|
|
|
|
+ for (const group of monthlyGroups) {
|
|
|
|
|
+ for (const day of group.monthlyDays) {
|
|
|
|
|
+ usedDays.add(day)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (const group of customGroups) {
|
|
|
|
|
+ for (const date of group.customDates) {
|
|
|
|
|
+ const day = getDateDayOfMonth(date)
|
|
|
|
|
+ if (day > 0 && usedDays.has(day)) {
|
|
|
|
|
+ return `自定义日期 ${date} 与每月预约的 ${day}号冲突`
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (weeklyGroups.length > 0 && customGroups.length > 0) {
|
|
|
|
|
+ const usedDays = new Set<number>()
|
|
|
|
|
+ for (const group of weeklyGroups) {
|
|
|
|
|
+ for (const day of group.weeklyDays) {
|
|
|
|
|
+ usedDays.add(day)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for (const group of customGroups) {
|
|
|
|
|
+ for (const date of group.customDates) {
|
|
|
|
|
+ const day = getDateWeekDay(date)
|
|
|
|
|
+ if (day > 0 && usedDays.has(day)) {
|
|
|
|
|
+ return `自定义日期 ${date} 与每周预约冲突`
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (const group of appointmentGroups.value) {
|
|
|
|
|
+ if (group.cycleType === 'weekly' && group.weeklyDays.length === 0) {
|
|
|
|
|
+ return '存在未设置每周可预约日期的预约组'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (group.cycleType === 'monthly' && group.monthlyDays.length === 0) {
|
|
|
|
|
+ return '存在未设置每月可预约日期的预约组'
|
|
|
|
|
+ }
|
|
|
|
|
+ if (group.cycleType === 'custom' && group.customDates.length === 0) {
|
|
|
|
|
+ return '存在未设置自定义日期的预约组'
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return null
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const handleSubmit = async () => {
|
|
const handleSubmit = async () => {
|
|
|
if (!formRef.value) return
|
|
if (!formRef.value) return
|
|
|
if (!organizationId) {
|
|
if (!organizationId) {
|
|
|
message.error('请选择机构!')
|
|
message.error('请选择机构!')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!formData.advanceDays || formData.advanceDays < 1) {
|
|
|
|
|
+ message.error('提前预约天数最少为1')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const groupError = validateGroups()
|
|
|
|
|
+ if (groupError) {
|
|
|
|
|
+ message.error(groupError)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
for (const group of appointmentGroups.value) {
|
|
for (const group of appointmentGroups.value) {
|
|
|
for (let i = 0; i < group.items.length; i++) {
|
|
for (let i = 0; i < group.items.length; i++) {
|
|
|
const item = group.items[i]
|
|
const item = group.items[i]
|
|
|
|
|
+ if (!item.limitCount || item.limitCount <= 0) {
|
|
|
|
|
+ message.error('限制人数必须大于0')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if (
|
|
if (
|
|
|
item.startTime &&
|
|
item.startTime &&
|
|
|
item.endTime &&
|
|
item.endTime &&
|
|
@@ -1334,6 +1483,8 @@ onMounted(() => {
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
:deep(.date-selector-dialog) {
|
|
:deep(.date-selector-dialog) {
|
|
|
.date-selector-body {
|
|
.date-selector-body {
|
|
|
padding: 6px 0;
|
|
padding: 6px 0;
|