优化预约作品选择和日期时间选择
This commit is contained in:
@@ -1,9 +1,25 @@
|
|||||||
import { adminApi } from '@/api/client'
|
import { adminApi } from '@/api/client'
|
||||||
import type { PageResult } from '@/types/common'
|
import type { IdType, PageResult } from '@/types/common'
|
||||||
import type { Product } from '@/types/manager'
|
import type { Product } from '@/types/manager'
|
||||||
|
|
||||||
|
export interface ProductCreateRequest {
|
||||||
|
title: string
|
||||||
|
description?: string
|
||||||
|
targetAudience?: string
|
||||||
|
precautions?: string
|
||||||
|
imageFileIds?: string
|
||||||
|
price: number
|
||||||
|
tags?: string
|
||||||
|
approximateDuration?: string
|
||||||
|
bookableArtists?: string
|
||||||
|
frontVisible: number
|
||||||
|
}
|
||||||
|
|
||||||
export const managerProductsApi = {
|
export const managerProductsApi = {
|
||||||
list(params: { page: number; size: number; keyword?: string }): Promise<PageResult<Product> | Product[]> {
|
list(params: { page: number; size: number; keyword?: string }): Promise<PageResult<Product> | Product[]> {
|
||||||
return adminApi.get('/manager/products', { params })
|
return adminApi.get('/manager/products', { params })
|
||||||
|
},
|
||||||
|
create(data: ProductCreateRequest): Promise<IdType> {
|
||||||
|
return adminApi.post('/product/create', data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { adminApi } from '@/api/client'
|
||||||
|
import type { IdType } from '@/types/common'
|
||||||
|
|
||||||
|
export interface ManagerTag {
|
||||||
|
id: IdType
|
||||||
|
tagName: string
|
||||||
|
displayName?: string
|
||||||
|
textColor?: string
|
||||||
|
bgColor?: string
|
||||||
|
borderColor?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const managerTagsApi = {
|
||||||
|
listAll(): Promise<ManagerTag[]> {
|
||||||
|
return adminApi.get('/tag/list/all')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<button class="field-value picker-trigger" type="button" @click="openSheet">
|
||||||
|
{{ displayValue }}
|
||||||
|
</button>
|
||||||
|
<DatePickerSheet
|
||||||
|
:model-value="modelValue"
|
||||||
|
:open="sheetOpen"
|
||||||
|
:title="title"
|
||||||
|
@update:model-value="updateValue"
|
||||||
|
@update:open="updateOpen"
|
||||||
|
@confirm="confirmValue"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import DatePickerSheet from '@/components/DatePickerSheet.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: string
|
||||||
|
placeholder: string
|
||||||
|
title: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: string]
|
||||||
|
confirm: [value: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const sheetOpen = ref(false)
|
||||||
|
const displayValue = computed(() => props.modelValue || props.placeholder)
|
||||||
|
|
||||||
|
const openSheet = (): void => {
|
||||||
|
sheetOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateOpen = (value: boolean): void => {
|
||||||
|
sheetOpen.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateValue = (value: string): void => {
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmValue = (value: string): void => {
|
||||||
|
emit('confirm', value)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.picker-trigger {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 40px;
|
||||||
|
padding: 0;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
<template>
|
||||||
|
<BaseModal :model-value="open" :title="title" @update:model-value="handleOpenChange">
|
||||||
|
<div class="date-picker-sheet">
|
||||||
|
<div class="date-picker-sheet__month">
|
||||||
|
<button type="button" aria-label="上个月" @click="moveMonth(-1)">
|
||||||
|
<ChevronLeft :size="18" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<strong>{{ monthTitle }}</strong>
|
||||||
|
<button type="button" aria-label="下个月" @click="moveMonth(1)">
|
||||||
|
<ChevronRight :size="18" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="date-picker-sheet__week">
|
||||||
|
<span v-for="weekday in weekdays" :key="weekday">{{ weekday }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="date-picker-sheet__grid">
|
||||||
|
<button
|
||||||
|
v-for="day in monthDays"
|
||||||
|
:key="day.date"
|
||||||
|
:class="{
|
||||||
|
'is-muted': !day.isCurrentMonth,
|
||||||
|
'is-selected': day.isSelected
|
||||||
|
}"
|
||||||
|
type="button"
|
||||||
|
@click="selectDate(day.date)"
|
||||||
|
>
|
||||||
|
{{ day.day }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="date-picker-sheet__value">{{ draft.draftValue }}</div>
|
||||||
|
<button class="primary-btn" type="button" @click="confirmSelection">确定</button>
|
||||||
|
</div>
|
||||||
|
</BaseModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { ChevronLeft, ChevronRight } from 'lucide-vue-next'
|
||||||
|
import BaseModal from '@/components/BaseModal.vue'
|
||||||
|
import { addMonths, formatDate, formatMonth } from '@/utils/date'
|
||||||
|
import {
|
||||||
|
buildDatePickerMonth,
|
||||||
|
confirmPickerDraft,
|
||||||
|
createPickerDraft,
|
||||||
|
resolveMonthCursor,
|
||||||
|
updatePickerDraft,
|
||||||
|
type PickerDraft
|
||||||
|
} from '@/utils/picker-options'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: string
|
||||||
|
open: boolean
|
||||||
|
title: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: string]
|
||||||
|
'update:open': [value: boolean]
|
||||||
|
confirm: [value: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const today = formatDate(new Date())
|
||||||
|
const weekdays = ['日', '一', '二', '三', '四', '五', '六']
|
||||||
|
const draft = ref<PickerDraft>(createPickerDraft(props.modelValue, today))
|
||||||
|
const monthCursor = ref(resolveMonthCursor(draft.value.draftValue))
|
||||||
|
|
||||||
|
const monthTitle = computed(() => formatMonth(monthCursor.value))
|
||||||
|
const monthDays = computed(() => buildDatePickerMonth(formatDate(monthCursor.value), draft.value.draftValue))
|
||||||
|
|
||||||
|
const syncDraftFromModel = (): void => {
|
||||||
|
draft.value = createPickerDraft(props.modelValue, today)
|
||||||
|
monthCursor.value = resolveMonthCursor(draft.value.draftValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOpenChange = (value: boolean): void => {
|
||||||
|
emit('update:open', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const moveMonth = (months: number): void => {
|
||||||
|
monthCursor.value = addMonths(monthCursor.value, months)
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectDate = (value: string): void => {
|
||||||
|
draft.value = updatePickerDraft(draft.value, value)
|
||||||
|
monthCursor.value = resolveMonthCursor(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmSelection = (): void => {
|
||||||
|
const value = confirmPickerDraft(draft.value)
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
emit('confirm', value)
|
||||||
|
emit('update:open', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => props.open, value => {
|
||||||
|
if (value) {
|
||||||
|
syncDraftFromModel()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => props.modelValue, () => {
|
||||||
|
if (!props.open) {
|
||||||
|
syncDraftFromModel()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.date-picker-sheet {
|
||||||
|
display: grid;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__month {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 44px 1fr 44px;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__month strong {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__month button {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 44px;
|
||||||
|
height: 36px;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__week,
|
||||||
|
.date-picker-sheet__grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(7, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__week {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__grid {
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__grid button {
|
||||||
|
aspect-ratio: 1;
|
||||||
|
min-width: 0;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: var(--ink);
|
||||||
|
font-weight: 760;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__grid button.is-muted {
|
||||||
|
color: #bbb4aa;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__grid button.is-selected {
|
||||||
|
background: var(--accent);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-picker-sheet__value {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<button class="field-value picker-trigger" type="button" @click="openSheet">
|
||||||
|
{{ displayValue }}
|
||||||
|
</button>
|
||||||
|
<TimePickerSheet
|
||||||
|
:model-value="modelValue"
|
||||||
|
:open="sheetOpen"
|
||||||
|
:title="title"
|
||||||
|
@update:model-value="updateValue"
|
||||||
|
@update:open="updateOpen"
|
||||||
|
@confirm="confirmValue"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref } from 'vue'
|
||||||
|
import TimePickerSheet from '@/components/TimePickerSheet.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: string
|
||||||
|
placeholder: string
|
||||||
|
title: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: string]
|
||||||
|
confirm: [value: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const sheetOpen = ref(false)
|
||||||
|
const displayValue = computed(() => props.modelValue || props.placeholder)
|
||||||
|
|
||||||
|
const openSheet = (): void => {
|
||||||
|
sheetOpen.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateOpen = (value: boolean): void => {
|
||||||
|
sheetOpen.value = value
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateValue = (value: string): void => {
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmValue = (value: string): void => {
|
||||||
|
emit('confirm', value)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.picker-trigger {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 40px;
|
||||||
|
padding: 0;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
<template>
|
||||||
|
<BaseModal :model-value="open" :title="title" @update:model-value="handleOpenChange">
|
||||||
|
<div class="time-picker-sheet">
|
||||||
|
<div class="time-picker-sheet__wheels">
|
||||||
|
<div ref="hourColumn" class="time-picker-sheet__column" aria-label="小时">
|
||||||
|
<button
|
||||||
|
v-for="hour in hourOptions"
|
||||||
|
:key="hour"
|
||||||
|
:class="{ 'is-selected': hour === draftHour }"
|
||||||
|
type="button"
|
||||||
|
@click="selectHour(hour)"
|
||||||
|
>
|
||||||
|
{{ hour }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div ref="minuteColumn" class="time-picker-sheet__column" aria-label="分钟">
|
||||||
|
<button
|
||||||
|
v-for="minute in minuteOptions"
|
||||||
|
:key="minute"
|
||||||
|
:class="{ 'is-selected': minute === draftMinute }"
|
||||||
|
type="button"
|
||||||
|
@click="selectMinute(minute)"
|
||||||
|
>
|
||||||
|
{{ minute }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="time-picker-sheet__value">{{ draftTime }}</div>
|
||||||
|
<button class="primary-btn" type="button" @click="confirmSelection">确认</button>
|
||||||
|
</div>
|
||||||
|
</BaseModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, nextTick, ref, watch } from 'vue'
|
||||||
|
import BaseModal from '@/components/BaseModal.vue'
|
||||||
|
import {
|
||||||
|
buildHourOptions,
|
||||||
|
buildMinuteOptions,
|
||||||
|
confirmPickerDraft,
|
||||||
|
createPickerDraft,
|
||||||
|
joinTimeParts,
|
||||||
|
normalizeTimeParts,
|
||||||
|
updatePickerDraft,
|
||||||
|
type PickerDraft
|
||||||
|
} from '@/utils/picker-options'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: string
|
||||||
|
open: boolean
|
||||||
|
title: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: string]
|
||||||
|
'update:open': [value: boolean]
|
||||||
|
confirm: [value: string]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const hourOptions = buildHourOptions()
|
||||||
|
const minuteOptions = buildMinuteOptions()
|
||||||
|
const draft = ref<PickerDraft>(createPickerDraft(props.modelValue, '00:00'))
|
||||||
|
const draftHour = ref(normalizeTimeParts(draft.value.draftValue).hour)
|
||||||
|
const draftMinute = ref(normalizeTimeParts(draft.value.draftValue).minute)
|
||||||
|
const hourColumn = ref<HTMLElement | null>(null)
|
||||||
|
const minuteColumn = ref<HTMLElement | null>(null)
|
||||||
|
const draftTime = computed(() => joinTimeParts(draftHour.value, draftMinute.value))
|
||||||
|
|
||||||
|
const scrollColumnToSelected = (column: HTMLElement | null): void => {
|
||||||
|
const selected = column?.querySelector('.is-selected')
|
||||||
|
if (selected instanceof HTMLElement) {
|
||||||
|
selected.scrollIntoView({ block: 'center' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const scrollSelectedIntoView = async (): Promise<void> => {
|
||||||
|
await nextTick()
|
||||||
|
scrollColumnToSelected(hourColumn.value)
|
||||||
|
scrollColumnToSelected(minuteColumn.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const syncDraftFromModel = (): void => {
|
||||||
|
draft.value = createPickerDraft(props.modelValue, '00:00')
|
||||||
|
const parts = normalizeTimeParts(draft.value.draftValue)
|
||||||
|
draftHour.value = parts.hour
|
||||||
|
draftMinute.value = parts.minute
|
||||||
|
}
|
||||||
|
|
||||||
|
const syncDraftTime = (): void => {
|
||||||
|
draft.value = updatePickerDraft(draft.value, draftTime.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleOpenChange = (value: boolean): void => {
|
||||||
|
emit('update:open', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectHour = (value: string): void => {
|
||||||
|
draftHour.value = value
|
||||||
|
syncDraftTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectMinute = (value: string): void => {
|
||||||
|
draftMinute.value = value
|
||||||
|
syncDraftTime()
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmSelection = (): void => {
|
||||||
|
syncDraftTime()
|
||||||
|
const value = confirmPickerDraft(draft.value)
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
emit('confirm', value)
|
||||||
|
emit('update:open', false)
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => props.open, value => {
|
||||||
|
if (value) {
|
||||||
|
syncDraftFromModel()
|
||||||
|
void scrollSelectedIntoView()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(() => props.modelValue, () => {
|
||||||
|
if (!props.open) {
|
||||||
|
syncDraftFromModel()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.time-picker-sheet {
|
||||||
|
display: grid;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-sheet__wheels {
|
||||||
|
position: relative;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
min-height: 236px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-sheet__wheels::before {
|
||||||
|
position: absolute;
|
||||||
|
top: 96px;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 44px;
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
content: "";
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-sheet__column {
|
||||||
|
display: grid;
|
||||||
|
grid-auto-rows: 44px;
|
||||||
|
max-height: 236px;
|
||||||
|
overflow-y: auto;
|
||||||
|
scroll-snap-type: y proximity;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-sheet__column::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-sheet__column button {
|
||||||
|
color: #aaa39b;
|
||||||
|
font-size: 16px;
|
||||||
|
scroll-snap-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-sheet__column button.is-selected {
|
||||||
|
color: var(--ink);
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 860;
|
||||||
|
}
|
||||||
|
|
||||||
|
.time-picker-sheet__value {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import {
|
||||||
|
buildDatePickerMonth,
|
||||||
|
buildHourOptions,
|
||||||
|
buildMinuteOptions,
|
||||||
|
cancelPickerDraft,
|
||||||
|
confirmPickerDraft,
|
||||||
|
createPickerDraft,
|
||||||
|
joinTimeParts,
|
||||||
|
normalizeTimeParts,
|
||||||
|
updatePickerDraft
|
||||||
|
} from '@/utils/picker-options'
|
||||||
|
|
||||||
|
describe('picker options', () => {
|
||||||
|
it('builds a sunday-first month grid with selected date', () => {
|
||||||
|
const days = buildDatePickerMonth('2026-07-02', '2026-07-02')
|
||||||
|
|
||||||
|
expect(days).toHaveLength(42)
|
||||||
|
expect(days.slice(0, 7).map(item => item.date)).toEqual([
|
||||||
|
'2026-06-28',
|
||||||
|
'2026-06-29',
|
||||||
|
'2026-06-30',
|
||||||
|
'2026-07-01',
|
||||||
|
'2026-07-02',
|
||||||
|
'2026-07-03',
|
||||||
|
'2026-07-04'
|
||||||
|
])
|
||||||
|
expect(days.find(item => item.date === '2026-07-02')?.isSelected).toBe(true)
|
||||||
|
expect(days.find(item => item.date === '2026-06-30')?.isCurrentMonth).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('builds hour and minute options', () => {
|
||||||
|
expect(buildHourOptions()[0]).toBe('00')
|
||||||
|
expect(buildHourOptions()[23]).toBe('23')
|
||||||
|
expect(buildMinuteOptions()[0]).toBe('00')
|
||||||
|
expect(buildMinuteOptions()[59]).toBe('59')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('normalizes and joins time values', () => {
|
||||||
|
expect(normalizeTimeParts('7:5')).toEqual({ hour: '07', minute: '05' })
|
||||||
|
expect(normalizeTimeParts('30:90')).toEqual({ hour: '23', minute: '59' })
|
||||||
|
expect(joinTimeParts('9', '8')).toBe('09:08')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('keeps committed value unchanged until confirm', () => {
|
||||||
|
const draft = createPickerDraft('2026-07-02', '2026-07-01')
|
||||||
|
const changedDraft = updatePickerDraft(draft, '2026-07-08')
|
||||||
|
|
||||||
|
expect(cancelPickerDraft(changedDraft)).toBe('2026-07-02')
|
||||||
|
expect(confirmPickerDraft(changedDraft)).toBe('2026-07-08')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import { addDays, formatDate, startOfMonth, toDate } from '@/utils/date'
|
||||||
|
|
||||||
|
export interface DatePickerDay {
|
||||||
|
date: string
|
||||||
|
day: number
|
||||||
|
isCurrentMonth: boolean
|
||||||
|
isSelected: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PickerDraft {
|
||||||
|
committedValue: string
|
||||||
|
draftValue: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const pad = (value: number): string => String(value).padStart(2, '0')
|
||||||
|
|
||||||
|
export const buildDatePickerMonth = (monthValue: string, selectedDate: string): DatePickerDay[] => {
|
||||||
|
const first = startOfMonth(monthValue)
|
||||||
|
const gridStart = addDays(first, -first.getDay())
|
||||||
|
return Array.from({ length: 42 }, (_item, index) => {
|
||||||
|
const current = addDays(gridStart, index)
|
||||||
|
const date = formatDate(current)
|
||||||
|
return {
|
||||||
|
date,
|
||||||
|
day: current.getDate(),
|
||||||
|
isCurrentMonth: current.getMonth() === first.getMonth(),
|
||||||
|
isSelected: date === selectedDate
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildHourOptions = (): string[] => {
|
||||||
|
return Array.from({ length: 24 }, (_item, index) => pad(index))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildMinuteOptions = (): string[] => {
|
||||||
|
return Array.from({ length: 60 }, (_item, index) => pad(index))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const normalizeTimeParts = (value: string): { hour: string; minute: string } => {
|
||||||
|
const [rawHour, rawMinute] = String(value || '00:00').split(':')
|
||||||
|
const hourNumber = Number(rawHour)
|
||||||
|
const minuteNumber = Number(rawMinute)
|
||||||
|
const hour = Number.isFinite(hourNumber) ? Math.min(Math.max(hourNumber, 0), 23) : 0
|
||||||
|
const minute = Number.isFinite(minuteNumber) ? Math.min(Math.max(minuteNumber, 0), 59) : 0
|
||||||
|
return {
|
||||||
|
hour: pad(hour),
|
||||||
|
minute: pad(minute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const joinTimeParts = (hour: string, minute: string): string => {
|
||||||
|
const normalized = normalizeTimeParts(`${hour}:${minute}`)
|
||||||
|
return `${normalized.hour}:${normalized.minute}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export const createPickerDraft = (modelValue: string, fallbackValue: string): PickerDraft => {
|
||||||
|
const committedValue = modelValue || fallbackValue
|
||||||
|
return {
|
||||||
|
committedValue,
|
||||||
|
draftValue: committedValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const updatePickerDraft = (draft: PickerDraft, draftValue: string): PickerDraft => {
|
||||||
|
return {
|
||||||
|
committedValue: draft.committedValue,
|
||||||
|
draftValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const confirmPickerDraft = (draft: PickerDraft): string => draft.draftValue
|
||||||
|
|
||||||
|
export const cancelPickerDraft = (draft: PickerDraft): string => draft.committedValue
|
||||||
|
|
||||||
|
export const resolveMonthCursor = (value: string): Date => {
|
||||||
|
return toDate(value || formatDate(new Date()))
|
||||||
|
}
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field"><label class="required">预约日期</label><input v-model="form.appointmentDate" type="date" @change="onDateChange" /></div>
|
<div class="field"><label class="required">预约日期</label><DatePickerField v-model="form.appointmentDate" placeholder="请选择日期" title="日期选择" @confirm="onDateChange" /></div>
|
||||||
<div class="field"><label class="required">预约作品</label><button class="field-value picker-value" type="button" @click="productModalVisible = true">{{ selectedProductTitle }}</button></div>
|
<div class="field"><label class="required">预约作品</label><button class="field-value picker-value" type="button" @click="productModalVisible = true">{{ selectedProductTitle }}</button></div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="required">预计时长</label>
|
<label class="required">预计时长</label>
|
||||||
@@ -78,45 +78,102 @@
|
|||||||
<BaseModal
|
<BaseModal
|
||||||
:model-value="productModalVisible"
|
:model-value="productModalVisible"
|
||||||
title="选择预约作品"
|
title="选择预约作品"
|
||||||
:has-unsaved-changes="manualProductChanged"
|
|
||||||
@update:model-value="updateProductModalVisible"
|
@update:model-value="updateProductModalVisible"
|
||||||
>
|
>
|
||||||
<div class="product-modal">
|
<div class="product-modal">
|
||||||
<input v-model.trim="productKeyword" class="search-input" placeholder="搜索作品、标签、美甲师" @input="filterProducts" />
|
<div class="product-modal__actions">
|
||||||
|
<input v-model.trim="productKeyword" class="search-input" placeholder="搜索作品、标签、美甲师" @input="filterProducts" />
|
||||||
|
<button class="secondary-btn product-add-btn" type="button" @click="openCreateProductModal">新增</button>
|
||||||
|
</div>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<button v-for="product in filteredProducts" :key="String(product.id)" class="product-card" type="button" @click="selectProduct(product)">
|
<button v-for="product in filteredProducts" :key="String(product.id)" class="product-card" type="button" @click="selectProduct(product)">
|
||||||
<img v-if="product.coverImage" :src="product.coverImage" alt="" />
|
<div class="product-card__cover">
|
||||||
<div>
|
<img v-if="product.coverImage" :src="product.coverImage" alt="" />
|
||||||
|
<span v-else>作品</span>
|
||||||
|
</div>
|
||||||
|
<div class="product-card__body">
|
||||||
<strong>{{ product.title }}</strong>
|
<strong>{{ product.title }}</strong>
|
||||||
<span>{{ product.priceText }} · {{ product.durationText || '时长待定' }}</span>
|
<p v-if="product.description">{{ product.description }}</p>
|
||||||
<small>{{ product.artistText }}</small>
|
|
||||||
<div v-if="product.tagList.length > 0" class="tag-row">
|
<div v-if="product.tagList.length > 0" class="tag-row">
|
||||||
<i v-for="tag in product.tagList" :key="tag">{{ tag }}</i>
|
<i v-for="tag in product.tagList" :key="tag">{{ tag }}</i>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="product-card__meta">
|
||||||
|
<span>{{ product.priceText }}</span>
|
||||||
|
<span>{{ product.durationText || '时长待定' }}</span>
|
||||||
|
</div>
|
||||||
|
<small>{{ product.artistText }}</small>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<EmptyState v-if="filteredProducts.length === 0" title="暂无匹配作品" description="可以调整关键词或手动新增预约作品" />
|
<EmptyState v-if="filteredProducts.length === 0" title="暂无匹配作品" description="可以调整关键词或新增作品" />
|
||||||
</div>
|
</div>
|
||||||
<PageSection title="手动新增预约作品">
|
</div>
|
||||||
<div class="manual-form">
|
</BaseModal>
|
||||||
<input v-model.trim="form.manualProductTitle" class="search-input" placeholder="作品名称" />
|
|
||||||
<input v-model.trim="form.manualProductPrice" class="search-input" inputmode="decimal" placeholder="价格" />
|
<BaseModal
|
||||||
<input v-model.trim="form.manualProductTags" class="search-input" placeholder="标签,逗号分隔" />
|
:model-value="productCreateModalVisible"
|
||||||
<textarea v-model.trim="form.manualProductDescription" class="search-input textarea" placeholder="作品说明"></textarea>
|
title="新增作品"
|
||||||
<input v-model.trim="form.manualProductTargetAudience" class="search-input" placeholder="适合人群(选填)" />
|
:close-disabled="creatingProduct"
|
||||||
<input v-model.trim="form.manualProductPrecautions" class="search-input" placeholder="注意事项(选填)" />
|
:has-unsaved-changes="productCreateChanged"
|
||||||
<div class="manual-image-row">
|
@update:model-value="updateProductCreateModalVisible"
|
||||||
<img v-if="form.manualProductImageUrl" :src="form.manualProductImageUrl" alt="" />
|
>
|
||||||
<div v-else class="manual-image-placeholder">图</div>
|
<div class="product-create-form">
|
||||||
<label class="secondary-btn image-upload">
|
<div class="field field--stack">
|
||||||
{{ manualImageUploading ? '上传中...' : '上传图片' }}
|
<label class="required">作品名称</label>
|
||||||
<input type="file" accept="image/*" :disabled="manualImageUploading" @change="uploadManualProductImage" />
|
<input v-model.trim="productCreateForm.title" class="search-input" placeholder="请输入作品名称" />
|
||||||
</label>
|
</div>
|
||||||
<button v-if="form.manualProductImageUrl" class="text-btn" type="button" @click="removeManualProductImage">移除</button>
|
<div class="field field--stack">
|
||||||
</div>
|
<label class="required">价格</label>
|
||||||
<button class="secondary-btn" type="button" @click="useManualProduct">使用手动作品</button>
|
<input v-model.trim="productCreateForm.price" class="search-input" inputmode="decimal" placeholder="请输入价格" />
|
||||||
|
</div>
|
||||||
|
<div class="field field--stack">
|
||||||
|
<label class="required">时长</label>
|
||||||
|
<input v-model.trim="productCreateForm.durationMinutes" class="search-input" inputmode="numeric" placeholder="请输入分钟数" />
|
||||||
|
</div>
|
||||||
|
<div class="field field--stack">
|
||||||
|
<label>作品说明</label>
|
||||||
|
<textarea v-model.trim="productCreateForm.description" class="search-input textarea" placeholder="请输入作品说明"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="field field--stack">
|
||||||
|
<label>适合人群</label>
|
||||||
|
<textarea v-model.trim="productCreateForm.targetAudience" class="search-input textarea" placeholder="请输入适合人群"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="field field--stack">
|
||||||
|
<label>注意事项</label>
|
||||||
|
<textarea v-model.trim="productCreateForm.precautions" class="search-input textarea" placeholder="请输入注意事项"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="field field--stack">
|
||||||
|
<label>作品首图</label>
|
||||||
|
<div class="manual-image-row">
|
||||||
|
<img v-if="productCreateForm.imageUrl" :src="productCreateForm.imageUrl" alt="" />
|
||||||
|
<div v-else class="manual-image-placeholder">图</div>
|
||||||
|
<label class="secondary-btn image-upload">
|
||||||
|
{{ productImageUploading ? '上传中...' : '上传图片' }}
|
||||||
|
<input type="file" accept="image/*" :disabled="productImageUploading" @change="uploadProductCreateImage" />
|
||||||
|
</label>
|
||||||
|
<button v-if="productCreateForm.imageUrl" class="text-btn" type="button" @click="removeProductCreateImage">移除</button>
|
||||||
</div>
|
</div>
|
||||||
</PageSection>
|
</div>
|
||||||
|
<div class="field field--stack">
|
||||||
|
<label>标签</label>
|
||||||
|
<div class="choice-grid">
|
||||||
|
<label v-for="tag in tagOptions" :key="String(tag.id)" class="choice-chip">
|
||||||
|
<input v-model="productCreateForm.tagIds" type="checkbox" :value="String(tag.id)" />
|
||||||
|
<span>{{ tag.displayName || tag.tagName }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field field--stack">
|
||||||
|
<label>可预约员工</label>
|
||||||
|
<div class="choice-grid">
|
||||||
|
<label v-for="artist in artists" :key="String(resolveArtistUserId(artist))" class="choice-chip">
|
||||||
|
<input v-model="productCreateForm.bookableArtistIds" type="checkbox" :value="String(resolveArtistUserId(artist))" />
|
||||||
|
<span>{{ artist.name || artist.nickname }}</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="primary-btn" type="button" :disabled="creatingProduct || productImageUploading" @click="createProduct">
|
||||||
|
{{ creatingProduct ? '保存中...' : '保存并选择' }}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</BaseModal>
|
</BaseModal>
|
||||||
|
|
||||||
@@ -168,14 +225,15 @@
|
|||||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import BaseModal from '@/components/BaseModal.vue'
|
import BaseModal from '@/components/BaseModal.vue'
|
||||||
|
import DatePickerField from '@/components/DatePickerField.vue'
|
||||||
import EmptyState from '@/components/EmptyState.vue'
|
import EmptyState from '@/components/EmptyState.vue'
|
||||||
import LoadingState from '@/components/LoadingState.vue'
|
import LoadingState from '@/components/LoadingState.vue'
|
||||||
import MobileShell from '@/components/MobileShell.vue'
|
import MobileShell from '@/components/MobileShell.vue'
|
||||||
import PageSection from '@/components/PageSection.vue'
|
|
||||||
import { managerCustomersApi } from '@/api/managerCustomers'
|
import { managerCustomersApi } from '@/api/managerCustomers'
|
||||||
import { managerEmployeesApi } from '@/api/managerEmployees'
|
import { managerEmployeesApi } from '@/api/managerEmployees'
|
||||||
import { managerPlanningApi } from '@/api/managerPlanning'
|
import { managerPlanningApi } from '@/api/managerPlanning'
|
||||||
import { managerProductsApi } from '@/api/managerProducts'
|
import { managerProductsApi, type ProductCreateRequest } from '@/api/managerProducts'
|
||||||
|
import { managerTagsApi, type ManagerTag } from '@/api/managerTags'
|
||||||
import { fileApi } from '@/api/file'
|
import { fileApi } from '@/api/file'
|
||||||
import type { AppointmentForm, Artist, Product } from '@/types/manager'
|
import type { AppointmentForm, Artist, Product } from '@/types/manager'
|
||||||
import type { UserInfo } from '@/types/common'
|
import type { UserInfo } from '@/types/common'
|
||||||
@@ -214,10 +272,66 @@ interface CustomerCreateForm {
|
|||||||
phone: string
|
phone: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ProductCreateForm {
|
||||||
|
title: string
|
||||||
|
price: string
|
||||||
|
durationMinutes: string
|
||||||
|
description: string
|
||||||
|
targetAudience: string
|
||||||
|
precautions: string
|
||||||
|
imageFileIds: string
|
||||||
|
imageUrl: string
|
||||||
|
tagIds: string[]
|
||||||
|
bookableArtistIds: string[]
|
||||||
|
}
|
||||||
|
|
||||||
const APPOINTMENT_MODAL_STATE_DRAFT_NAME = 'appointment-modal-state'
|
const APPOINTMENT_MODAL_STATE_DRAFT_NAME = 'appointment-modal-state'
|
||||||
const CUSTOMER_CREATE_DRAFT_NAME = 'appointment-customer-create'
|
const CUSTOMER_CREATE_DRAFT_NAME = 'appointment-customer-create'
|
||||||
|
const PRODUCT_CREATE_DRAFT_NAME = 'appointment-product-create'
|
||||||
const CUSTOMER_PHONE_PATTERN = /^1[3-9]\d{9}$/
|
const CUSTOMER_PHONE_PATTERN = /^1[3-9]\d{9}$/
|
||||||
|
|
||||||
|
const normalizeStringArray = (value: string[] | undefined): string[] => {
|
||||||
|
if (!Array.isArray(value)) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
return value.map(item => String(item || '').trim()).filter(Boolean)
|
||||||
|
}
|
||||||
|
|
||||||
|
const isSameStringArray = (left: string[], right: string[]): boolean => {
|
||||||
|
return left.length === right.length && left.every((item, index) => item === right[index])
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildEmptyProductCreateForm = (): ProductCreateForm => ({
|
||||||
|
title: '',
|
||||||
|
price: '',
|
||||||
|
durationMinutes: '',
|
||||||
|
description: '',
|
||||||
|
targetAudience: '',
|
||||||
|
precautions: '',
|
||||||
|
imageFileIds: '',
|
||||||
|
imageUrl: '',
|
||||||
|
tagIds: [],
|
||||||
|
bookableArtistIds: []
|
||||||
|
})
|
||||||
|
|
||||||
|
const normalizeProductCreateForm = (value: ProductCreateForm | undefined): ProductCreateForm => {
|
||||||
|
if (!value) {
|
||||||
|
return buildEmptyProductCreateForm()
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
title: value.title || '',
|
||||||
|
price: value.price || '',
|
||||||
|
durationMinutes: value.durationMinutes || '',
|
||||||
|
description: value.description || '',
|
||||||
|
targetAudience: value.targetAudience || '',
|
||||||
|
precautions: value.precautions || '',
|
||||||
|
imageFileIds: value.imageFileIds || '',
|
||||||
|
imageUrl: value.imageUrl || '',
|
||||||
|
tagIds: normalizeStringArray(value.tagIds),
|
||||||
|
bookableArtistIds: normalizeStringArray(value.bookableArtistIds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const session = useSessionStore()
|
const session = useSessionStore()
|
||||||
@@ -225,6 +339,7 @@ const toast = useToastStore()
|
|||||||
const baseForm = readDraftForm(session.userInfo)
|
const baseForm = readDraftForm(session.userInfo)
|
||||||
const modalStateDraft = readFormModalDraft<AppointmentModalState>(session.userInfo, APPOINTMENT_MODAL_STATE_DRAFT_NAME)
|
const modalStateDraft = readFormModalDraft<AppointmentModalState>(session.userInfo, APPOINTMENT_MODAL_STATE_DRAFT_NAME)
|
||||||
const createCustomerDraft = readFormModalDraft<CustomerCreateForm>(session.userInfo, CUSTOMER_CREATE_DRAFT_NAME)
|
const createCustomerDraft = readFormModalDraft<CustomerCreateForm>(session.userInfo, CUSTOMER_CREATE_DRAFT_NAME)
|
||||||
|
const createProductDraft = readFormModalDraft<ProductCreateForm>(session.userInfo, PRODUCT_CREATE_DRAFT_NAME)
|
||||||
const form = reactive<AppointmentForm>({
|
const form = reactive<AppointmentForm>({
|
||||||
customerUserId: String(route.query.customerUserId || baseForm?.customerUserId || ''),
|
customerUserId: String(route.query.customerUserId || baseForm?.customerUserId || ''),
|
||||||
customerName: String(route.query.customerName || baseForm?.customerName || ''),
|
customerName: String(route.query.customerName || baseForm?.customerName || ''),
|
||||||
@@ -257,11 +372,15 @@ const createCustomerForm = reactive<CustomerCreateForm>({
|
|||||||
nickname: createCustomerDraft?.form.nickname || '',
|
nickname: createCustomerDraft?.form.nickname || '',
|
||||||
phone: createCustomerDraft?.form.phone || ''
|
phone: createCustomerDraft?.form.phone || ''
|
||||||
})
|
})
|
||||||
|
const productCreateForm = reactive<ProductCreateForm>(normalizeProductCreateForm(createProductDraft?.form))
|
||||||
|
const productCreateBaseline = ref<ProductCreateForm>(buildEmptyProductCreateForm())
|
||||||
const products = ref<ProductCard[]>([])
|
const products = ref<ProductCard[]>([])
|
||||||
const filteredProducts = ref<ProductCard[]>([])
|
const filteredProducts = ref<ProductCard[]>([])
|
||||||
const productKeyword = ref('')
|
const productKeyword = ref('')
|
||||||
const productModalVisible = ref(Boolean(modalStateDraft?.open && modalStateDraft.form.productModalVisible))
|
const productModalVisible = ref(Boolean(modalStateDraft?.open && modalStateDraft.form.productModalVisible))
|
||||||
|
const productCreateModalVisible = ref(Boolean(createProductDraft?.open))
|
||||||
const artists = ref<Artist[]>([])
|
const artists = ref<Artist[]>([])
|
||||||
|
const tagOptions = ref<ManagerTag[]>([])
|
||||||
const selectedProduct = ref<ProductCard | null>(null)
|
const selectedProduct = ref<ProductCard | null>(null)
|
||||||
const timeSheetVisible = ref(Boolean(modalStateDraft?.open && modalStateDraft.form.timeSheetVisible))
|
const timeSheetVisible = ref(Boolean(modalStateDraft?.open && modalStateDraft.form.timeSheetVisible))
|
||||||
const availableTimeGroups = ref<AvailableTimeGroup[]>([])
|
const availableTimeGroups = ref<AvailableTimeGroup[]>([])
|
||||||
@@ -270,7 +389,8 @@ const timeSelectTip = ref('请先选择美甲师并填写时长')
|
|||||||
const conflictTip = ref('')
|
const conflictTip = ref('')
|
||||||
const conflictLevel = ref<'free' | 'danger'>('free')
|
const conflictLevel = ref<'free' | 'danger'>('free')
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const manualImageUploading = ref(false)
|
const creatingProduct = ref(false)
|
||||||
|
const productImageUploading = ref(false)
|
||||||
const selectedCustomerReady = computed(() => {
|
const selectedCustomerReady = computed(() => {
|
||||||
return Boolean(form.customerUserId)
|
return Boolean(form.customerUserId)
|
||||||
})
|
})
|
||||||
@@ -295,17 +415,18 @@ const selectedCustomerDisplay = computed<CustomerDisplay>(() => {
|
|||||||
const createCustomerChanged = computed(() => {
|
const createCustomerChanged = computed(() => {
|
||||||
return Boolean(createCustomerForm.nickname || createCustomerForm.phone)
|
return Boolean(createCustomerForm.nickname || createCustomerForm.phone)
|
||||||
})
|
})
|
||||||
const manualProductChanged = computed(() => {
|
const productCreateChanged = computed(() => {
|
||||||
return Boolean(
|
const baseline = productCreateBaseline.value
|
||||||
form.manualProductTitle
|
return productCreateForm.title !== baseline.title
|
||||||
|| form.manualProductPrice
|
|| productCreateForm.price !== baseline.price
|
||||||
|| form.manualProductTags
|
|| productCreateForm.durationMinutes !== baseline.durationMinutes
|
||||||
|| form.manualProductDescription
|
|| productCreateForm.description !== baseline.description
|
||||||
|| form.manualProductTargetAudience
|
|| productCreateForm.targetAudience !== baseline.targetAudience
|
||||||
|| form.manualProductPrecautions
|
|| productCreateForm.precautions !== baseline.precautions
|
||||||
|| form.manualProductImageFileIds
|
|| productCreateForm.imageFileIds !== baseline.imageFileIds
|
||||||
|| form.manualProductImageUrl
|
|| productCreateForm.imageUrl !== baseline.imageUrl
|
||||||
)
|
|| !isSameStringArray(productCreateForm.tagIds, baseline.tagIds)
|
||||||
|
|| !isSameStringArray(productCreateForm.bookableArtistIds, baseline.bookableArtistIds)
|
||||||
})
|
})
|
||||||
const appointmentFormChanged = computed(() => {
|
const appointmentFormChanged = computed(() => {
|
||||||
return Boolean(
|
return Boolean(
|
||||||
@@ -392,6 +513,56 @@ const updateCreateCustomerModalVisible = (value: boolean): void => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const snapshotProductCreateForm = (): ProductCreateForm => ({
|
||||||
|
title: productCreateForm.title,
|
||||||
|
price: productCreateForm.price,
|
||||||
|
durationMinutes: productCreateForm.durationMinutes,
|
||||||
|
description: productCreateForm.description,
|
||||||
|
targetAudience: productCreateForm.targetAudience,
|
||||||
|
precautions: productCreateForm.precautions,
|
||||||
|
imageFileIds: productCreateForm.imageFileIds,
|
||||||
|
imageUrl: productCreateForm.imageUrl,
|
||||||
|
tagIds: [...productCreateForm.tagIds],
|
||||||
|
bookableArtistIds: [...productCreateForm.bookableArtistIds]
|
||||||
|
})
|
||||||
|
|
||||||
|
const applyProductCreateForm = (value: ProductCreateForm): void => {
|
||||||
|
productCreateForm.title = value.title
|
||||||
|
productCreateForm.price = value.price
|
||||||
|
productCreateForm.durationMinutes = value.durationMinutes
|
||||||
|
productCreateForm.description = value.description
|
||||||
|
productCreateForm.targetAudience = value.targetAudience
|
||||||
|
productCreateForm.precautions = value.precautions
|
||||||
|
productCreateForm.imageFileIds = value.imageFileIds
|
||||||
|
productCreateForm.imageUrl = value.imageUrl
|
||||||
|
productCreateForm.tagIds = [...value.tagIds]
|
||||||
|
productCreateForm.bookableArtistIds = [...value.bookableArtistIds]
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetProductCreateForm = (): void => {
|
||||||
|
applyProductCreateForm(buildEmptyProductCreateForm())
|
||||||
|
productCreateBaseline.value = buildEmptyProductCreateForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
const syncProductCreateDraft = (): void => {
|
||||||
|
if (!productCreateModalVisible.value) {
|
||||||
|
removeFormModalDraft(session.userInfo, PRODUCT_CREATE_DRAFT_NAME)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!productCreateChanged.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writeFormModalDraft(session.userInfo, PRODUCT_CREATE_DRAFT_NAME, snapshotProductCreateForm(), true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateProductCreateModalVisible = (value: boolean): void => {
|
||||||
|
productCreateModalVisible.value = value
|
||||||
|
if (!value) {
|
||||||
|
removeFormModalDraft(session.userInfo, PRODUCT_CREATE_DRAFT_NAME)
|
||||||
|
resetProductCreateForm()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const selectedProductTitle = computed(() => {
|
const selectedProductTitle = computed(() => {
|
||||||
if (selectedProduct.value) {
|
if (selectedProduct.value) {
|
||||||
return selectedProduct.value.title
|
return selectedProduct.value.title
|
||||||
@@ -456,11 +627,13 @@ const filterProducts = (): void => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const loadOptions = async (): Promise<void> => {
|
const loadOptions = async (): Promise<void> => {
|
||||||
const [productData, employeeData] = await Promise.all([
|
const [productData, employeeData, tagData] = await Promise.all([
|
||||||
managerProductsApi.list({ page: 1, size: 100 }),
|
managerProductsApi.list({ page: 1, size: 100 }),
|
||||||
managerEmployeesApi.list()
|
managerEmployeesApi.list(),
|
||||||
|
managerTagsApi.listAll()
|
||||||
])
|
])
|
||||||
artists.value = employeeData
|
artists.value = employeeData
|
||||||
|
tagOptions.value = tagData
|
||||||
form.artistId = normalizeArtistSelectionId(form.artistId, artists.value)
|
form.artistId = normalizeArtistSelectionId(form.artistId, artists.value)
|
||||||
const productList = Array.isArray(productData) ? productData : productData.list
|
const productList = Array.isArray(productData) ? productData : productData.list
|
||||||
products.value = productList.map(product => normalizeProduct(product, artists.value))
|
products.value = productList.map(product => normalizeProduct(product, artists.value))
|
||||||
@@ -578,38 +751,86 @@ const selectProduct = (product: ProductCard): void => {
|
|||||||
void refreshAvailableTimes()
|
void refreshAvailableTimes()
|
||||||
}
|
}
|
||||||
|
|
||||||
const useManualProduct = (): void => {
|
const openCreateProductModal = (): void => {
|
||||||
const title = form.manualProductTitle.trim()
|
|
||||||
const price = Number(form.manualProductPrice)
|
|
||||||
if (!title || Number.isNaN(price) || price < 0) {
|
|
||||||
toast.error('请填写手动预约作品名称和价格')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
form.productId = ''
|
|
||||||
selectedProduct.value = null
|
|
||||||
updateProductModalVisible(false)
|
updateProductModalVisible(false)
|
||||||
|
if (!productCreateChanged.value && form.artistId) {
|
||||||
|
productCreateForm.bookableArtistIds = [form.artistId]
|
||||||
|
}
|
||||||
|
productCreateBaseline.value = snapshotProductCreateForm()
|
||||||
|
productCreateModalVisible.value = true
|
||||||
|
syncProductCreateDraft()
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadManualProductImage = async (event: Event): Promise<void> => {
|
const uploadProductCreateImage = async (event: Event): Promise<void> => {
|
||||||
const input = event.target as HTMLInputElement
|
const input = event.target as HTMLInputElement
|
||||||
const file = input.files?.[0]
|
const file = input.files?.[0]
|
||||||
if (!file) {
|
if (!file) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
manualImageUploading.value = true
|
productImageUploading.value = true
|
||||||
try {
|
try {
|
||||||
const uploaded = await fileApi.uploadObjectFile(file)
|
const uploaded = await fileApi.uploadObjectFile(file)
|
||||||
form.manualProductImageFileIds = String(uploaded.id)
|
productCreateForm.imageFileIds = String(uploaded.id)
|
||||||
form.manualProductImageUrl = uploaded.primaryUrl || uploaded.fileUrl || ''
|
productCreateForm.imageUrl = uploaded.primaryUrl || uploaded.fileUrl || ''
|
||||||
} finally {
|
} finally {
|
||||||
input.value = ''
|
input.value = ''
|
||||||
manualImageUploading.value = false
|
productImageUploading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeManualProductImage = (): void => {
|
const removeProductCreateImage = (): void => {
|
||||||
form.manualProductImageFileIds = ''
|
productCreateForm.imageFileIds = ''
|
||||||
form.manualProductImageUrl = ''
|
productCreateForm.imageUrl = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildProductCreatePayload = (): ProductCreateRequest | null => {
|
||||||
|
const title = productCreateForm.title.trim()
|
||||||
|
const price = Number(productCreateForm.price)
|
||||||
|
const durationMinutes = normalizeDuration(productCreateForm.durationMinutes)
|
||||||
|
if (!title || Number.isNaN(price) || price < 0 || !durationMinutes) {
|
||||||
|
toast.error('请填写作品名称、价格和时长')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
title,
|
||||||
|
price,
|
||||||
|
description: productCreateForm.description.trim() || undefined,
|
||||||
|
targetAudience: productCreateForm.targetAudience.trim() || undefined,
|
||||||
|
precautions: productCreateForm.precautions.trim() || undefined,
|
||||||
|
imageFileIds: productCreateForm.imageFileIds || undefined,
|
||||||
|
tags: productCreateForm.tagIds.join(';') || undefined,
|
||||||
|
approximateDuration: `${durationMinutes}分钟`,
|
||||||
|
bookableArtists: productCreateForm.bookableArtistIds.join(',') || undefined,
|
||||||
|
frontVisible: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const createProduct = async (): Promise<void> => {
|
||||||
|
if (productImageUploading.value) {
|
||||||
|
toast.error('图片上传完成后再保存作品')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const payload = buildProductCreatePayload()
|
||||||
|
if (!payload) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
creatingProduct.value = true
|
||||||
|
try {
|
||||||
|
const productId = await managerProductsApi.create(payload)
|
||||||
|
await loadOptions()
|
||||||
|
const createdProduct = products.value.find(product => String(product.id) === String(productId))
|
||||||
|
if (!createdProduct) {
|
||||||
|
throw new Error(`作品已创建但未在列表中返回,作品ID:${productId}`)
|
||||||
|
}
|
||||||
|
updateProductCreateModalVisible(false)
|
||||||
|
selectProduct(createdProduct)
|
||||||
|
toast.success('作品已新增')
|
||||||
|
} catch (error) {
|
||||||
|
const message = error instanceof Error ? error.message : '新增作品失败'
|
||||||
|
toast.error(message)
|
||||||
|
} finally {
|
||||||
|
creatingProduct.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const refreshAvailableTimes = async (): Promise<void> => {
|
const refreshAvailableTimes = async (): Promise<void> => {
|
||||||
@@ -744,6 +965,8 @@ watch(productModalVisible, syncAppointmentModalState)
|
|||||||
watch(timeSheetVisible, syncAppointmentModalState)
|
watch(timeSheetVisible, syncAppointmentModalState)
|
||||||
watch(createCustomerForm, syncCreateCustomerDraft, { deep: true })
|
watch(createCustomerForm, syncCreateCustomerDraft, { deep: true })
|
||||||
watch(createCustomerModalVisible, syncCreateCustomerDraft)
|
watch(createCustomerModalVisible, syncCreateCustomerDraft)
|
||||||
|
watch(productCreateForm, syncProductCreateDraft, { deep: true })
|
||||||
|
watch(productCreateModalVisible, syncProductCreateDraft)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -999,43 +1222,89 @@ watch(createCustomerModalVisible, syncCreateCustomerDraft)
|
|||||||
}
|
}
|
||||||
|
|
||||||
.product-modal,
|
.product-modal,
|
||||||
|
.product-create-form,
|
||||||
.time-sheet {
|
.time-sheet {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.product-modal__actions {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr auto;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-add-btn {
|
||||||
|
min-width: 72px;
|
||||||
|
}
|
||||||
|
|
||||||
.product-card {
|
.product-card {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 72px 1fr;
|
grid-template-columns: 76px 1fr;
|
||||||
gap: 10px;
|
gap: 12px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 14px;
|
border: 1px solid var(--border);
|
||||||
background: var(--subtle);
|
border-radius: 12px;
|
||||||
|
background: var(--card-bg);
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.product-card img {
|
.product-card__cover {
|
||||||
width: 72px;
|
display: grid;
|
||||||
height: 72px;
|
width: 76px;
|
||||||
|
height: 76px;
|
||||||
|
place-items: center;
|
||||||
|
overflow: hidden;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
|
background: var(--subtle);
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__cover img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
.product-card strong,
|
.product-card__body {
|
||||||
.product-card span,
|
min-width: 0;
|
||||||
.product-card small {
|
}
|
||||||
|
|
||||||
|
.product-card__body strong,
|
||||||
|
.product-card__body p,
|
||||||
|
.product-card__body small {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.product-card span,
|
.product-card__body strong,
|
||||||
.product-card small {
|
.product-card__body p {
|
||||||
margin-top: 3px;
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card__body p,
|
||||||
|
.product-card__body small {
|
||||||
|
margin: 3px 0 0;
|
||||||
color: var(--muted);
|
color: var(--muted);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.product-card__meta {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 8px;
|
||||||
|
color: var(--ink);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 850;
|
||||||
|
}
|
||||||
|
|
||||||
.tag-row {
|
.tag-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
@@ -1053,11 +1322,6 @@ watch(createCustomerModalVisible, syncCreateCustomerDraft)
|
|||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
}
|
}
|
||||||
|
|
||||||
.manual-form {
|
|
||||||
display: grid;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.manual-image-row {
|
.manual-image-row {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 72px 1fr auto;
|
grid-template-columns: 72px 1fr auto;
|
||||||
@@ -1102,6 +1366,39 @@ watch(createCustomerModalVisible, syncCreateCustomerDraft)
|
|||||||
resize: vertical;
|
resize: vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.choice-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.choice-chip {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.choice-chip input {
|
||||||
|
position: absolute;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.choice-chip span {
|
||||||
|
padding: 7px 10px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--card-bg);
|
||||||
|
color: var(--ink);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 760;
|
||||||
|
}
|
||||||
|
|
||||||
|
.choice-chip input:checked + span {
|
||||||
|
border-color: var(--accent);
|
||||||
|
background: var(--accent-soft);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
.time-sheet h3 {
|
.time-sheet h3 {
|
||||||
margin: 0 0 8px;
|
margin: 0 0 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,11 @@
|
|||||||
<section v-if="!loadError" class="card form-card section">
|
<section v-if="!loadError" class="card form-card section">
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label required">新日期</span>
|
<span class="field-label required">新日期</span>
|
||||||
<input v-model="form.date" class="field-value" type="date" @change="loadArtists" />
|
<DatePickerField v-model="form.date" placeholder="请选择日期" title="日期选择" @confirm="loadArtists" />
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label required">新时间</span>
|
<span class="field-label required">新时间</span>
|
||||||
<input v-model="form.time" class="field-value" type="time" min="10:00" max="22:00" />
|
<TimePickerField v-model="form.time" placeholder="请选择时间" title="选择时间" />
|
||||||
</label>
|
</label>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -50,8 +50,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import DatePickerField from '@/components/DatePickerField.vue'
|
||||||
import EmptyState from '@/components/EmptyState.vue'
|
import EmptyState from '@/components/EmptyState.vue'
|
||||||
import LoadingState from '@/components/LoadingState.vue'
|
import LoadingState from '@/components/LoadingState.vue'
|
||||||
|
import TimePickerField from '@/components/TimePickerField.vue'
|
||||||
import { managerPlanningApi } from '@/api/managerPlanning'
|
import { managerPlanningApi } from '@/api/managerPlanning'
|
||||||
import type { Artist } from '@/types/manager'
|
import type { Artist } from '@/types/manager'
|
||||||
import type { IdType } from '@/types/common'
|
import type { IdType } from '@/types/common'
|
||||||
|
|||||||
@@ -10,11 +10,11 @@
|
|||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label">开始日期</span>
|
<span class="field-label">开始日期</span>
|
||||||
<input v-model="startDate" class="field-value" type="date" @change="loadPreview" />
|
<DatePickerField v-model="startDate" placeholder="请选择开始日期" title="日期选择" @confirm="loadPreview" />
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label">结束日期</span>
|
<span class="field-label">结束日期</span>
|
||||||
<input v-model="endDate" class="field-value" type="date" @change="loadPreview" />
|
<DatePickerField v-model="endDate" placeholder="请选择结束日期" title="日期选择" @confirm="loadPreview" />
|
||||||
</label>
|
</label>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
|
import DatePickerField from '@/components/DatePickerField.vue'
|
||||||
import EmptyState from '@/components/EmptyState.vue'
|
import EmptyState from '@/components/EmptyState.vue'
|
||||||
import LoadingState from '@/components/LoadingState.vue'
|
import LoadingState from '@/components/LoadingState.vue'
|
||||||
import MobileShell from '@/components/MobileShell.vue'
|
import MobileShell from '@/components/MobileShell.vue'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<MobileShell title="请假管理">
|
<MobileShell title="请假管理">
|
||||||
<section class="card form-card">
|
<section class="card form-card">
|
||||||
<div class="field"><label class="required">请假日期</label><input v-model="form.workDate" type="date" /></div>
|
<div class="field"><label class="required">请假日期</label><DatePickerField v-model="form.workDate" placeholder="请选择日期" title="日期选择" /></div>
|
||||||
<div class="field"><label>原因</label><input v-model.trim="form.reason" placeholder="请输入请假原因" /></div>
|
<div class="field"><label>原因</label><input v-model.trim="form.reason" placeholder="请输入请假原因" /></div>
|
||||||
</section>
|
</section>
|
||||||
<button class="primary-btn section" type="button" :disabled="saving" @click="saveLeave">{{ saving ? '保存中...' : '保存请假' }}</button>
|
<button class="primary-btn section" type="button" :disabled="saving" @click="saveLeave">{{ saving ? '保存中...' : '保存请假' }}</button>
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref } from 'vue'
|
import { reactive, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
import DatePickerField from '@/components/DatePickerField.vue'
|
||||||
import MobileShell from '@/components/MobileShell.vue'
|
import MobileShell from '@/components/MobileShell.vue'
|
||||||
import { managerEmployeesApi } from '@/api/managerEmployees'
|
import { managerEmployeesApi } from '@/api/managerEmployees'
|
||||||
import { formatDate } from '@/utils/date'
|
import { formatDate } from '@/utils/date'
|
||||||
|
|||||||
@@ -34,22 +34,22 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field"><label class="required">开始时间</label><input v-model="ruleForm.startTime" type="time" @change="markCustom" /></div>
|
<div class="field"><label class="required">开始时间</label><TimePickerField v-model="ruleForm.startTime" placeholder="请选择时间" title="选择时间" @confirm="markCustom" /></div>
|
||||||
<div class="field"><label class="required">结束时间</label><input v-model="ruleForm.endTime" type="time" @change="markCustom" /></div>
|
<div class="field"><label class="required">结束时间</label><TimePickerField v-model="ruleForm.endTime" placeholder="请选择时间" title="选择时间" @confirm="markCustom" /></div>
|
||||||
</section>
|
</section>
|
||||||
<button class="primary-btn section" type="button" :disabled="saving" @click="saveRule">{{ saving ? '保存中...' : '保存排班规则' }}</button>
|
<button class="primary-btn section" type="button" :disabled="saving" @click="saveRule">{{ saving ? '保存中...' : '保存排班规则' }}</button>
|
||||||
|
|
||||||
<PageSection title="新增例外">
|
<PageSection title="新增例外">
|
||||||
<section class="card form-card">
|
<section class="card form-card">
|
||||||
<div class="field"><label class="required">日期</label><input v-model="exceptionForm.workDate" type="date" /></div>
|
<div class="field"><label class="required">日期</label><DatePickerField v-model="exceptionForm.workDate" placeholder="请选择日期" title="日期选择" /></div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>类型</label>
|
<label>类型</label>
|
||||||
<select v-model="exceptionForm.exceptionType">
|
<select v-model="exceptionForm.exceptionType">
|
||||||
<option v-for="item in exceptionTypes" :key="item.value" :value="item.value">{{ item.label }}</option>
|
<option v-for="item in exceptionTypes" :key="item.value" :value="item.value">{{ item.label }}</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="exceptionForm.exceptionType !== 'REST'" class="field"><label>开始时间</label><input v-model="exceptionForm.startTime" type="time" /></div>
|
<div v-if="exceptionForm.exceptionType !== 'REST'" class="field"><label>开始时间</label><TimePickerField v-model="exceptionForm.startTime" placeholder="请选择时间" title="选择时间" /></div>
|
||||||
<div v-if="exceptionForm.exceptionType !== 'REST'" class="field"><label>结束时间</label><input v-model="exceptionForm.endTime" type="time" /></div>
|
<div v-if="exceptionForm.exceptionType !== 'REST'" class="field"><label>结束时间</label><TimePickerField v-model="exceptionForm.endTime" placeholder="请选择时间" title="选择时间" /></div>
|
||||||
<div class="field"><label>原因</label><input v-model.trim="exceptionForm.remark" placeholder="选填" /></div>
|
<div class="field"><label>原因</label><input v-model.trim="exceptionForm.remark" placeholder="选填" /></div>
|
||||||
</section>
|
</section>
|
||||||
<button class="secondary-btn section" type="button" :disabled="saving" @click="saveException">保存例外</button>
|
<button class="secondary-btn section" type="button" :disabled="saving" @click="saveException">保存例外</button>
|
||||||
@@ -76,10 +76,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
import { computed, onMounted, reactive, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
import DatePickerField from '@/components/DatePickerField.vue'
|
||||||
import EmptyState from '@/components/EmptyState.vue'
|
import EmptyState from '@/components/EmptyState.vue'
|
||||||
import LoadingState from '@/components/LoadingState.vue'
|
import LoadingState from '@/components/LoadingState.vue'
|
||||||
import MobileShell from '@/components/MobileShell.vue'
|
import MobileShell from '@/components/MobileShell.vue'
|
||||||
import PageSection from '@/components/PageSection.vue'
|
import PageSection from '@/components/PageSection.vue'
|
||||||
|
import TimePickerField from '@/components/TimePickerField.vue'
|
||||||
import { managerEmployeesApi } from '@/api/managerEmployees'
|
import { managerEmployeesApi } from '@/api/managerEmployees'
|
||||||
import type { Artist, ArtistScheduleException } from '@/types/manager'
|
import type { Artist, ArtistScheduleException } from '@/types/manager'
|
||||||
import { formatDate } from '@/utils/date'
|
import { formatDate } from '@/utils/date'
|
||||||
|
|||||||
@@ -58,11 +58,11 @@
|
|||||||
|
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label">营业开始</span>
|
<span class="field-label">营业开始</span>
|
||||||
<input v-model="form.startTime" class="field-value" type="time" @change="markCustom" />
|
<TimePickerField v-model="form.startTime" placeholder="请选择时间" title="选择时间" @confirm="markCustom" />
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label">营业结束</span>
|
<span class="field-label">营业结束</span>
|
||||||
<input v-model="form.endTime" class="field-value" type="time" @change="markCustom" />
|
<TimePickerField v-model="form.endTime" placeholder="请选择时间" title="选择时间" @confirm="markCustom" />
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label">排班备注</span>
|
<span class="field-label">排班备注</span>
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<section class="card form-card">
|
<section class="card form-card">
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label">日期</span>
|
<span class="field-label">日期</span>
|
||||||
<input v-model="exceptionForm.workDate" type="date" />
|
<DatePickerField v-model="exceptionForm.workDate" placeholder="请选择日期" title="日期选择" />
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label">类型</span>
|
<span class="field-label">类型</span>
|
||||||
@@ -85,11 +85,11 @@
|
|||||||
</label>
|
</label>
|
||||||
<label v-if="exceptionForm.exceptionType !== 'REST'" class="field">
|
<label v-if="exceptionForm.exceptionType !== 'REST'" class="field">
|
||||||
<span class="field-label">开始时间</span>
|
<span class="field-label">开始时间</span>
|
||||||
<input v-model="exceptionForm.startTime" type="time" />
|
<TimePickerField v-model="exceptionForm.startTime" placeholder="请选择时间" title="选择时间" />
|
||||||
</label>
|
</label>
|
||||||
<label v-if="exceptionForm.exceptionType !== 'REST'" class="field">
|
<label v-if="exceptionForm.exceptionType !== 'REST'" class="field">
|
||||||
<span class="field-label">结束时间</span>
|
<span class="field-label">结束时间</span>
|
||||||
<input v-model="exceptionForm.endTime" type="time" />
|
<TimePickerField v-model="exceptionForm.endTime" placeholder="请选择时间" title="选择时间" />
|
||||||
</label>
|
</label>
|
||||||
<label class="field">
|
<label class="field">
|
||||||
<span class="field-label">备注</span>
|
<span class="field-label">备注</span>
|
||||||
@@ -134,10 +134,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, reactive, ref } from 'vue'
|
import { computed, onMounted, reactive, ref } from 'vue'
|
||||||
import BaseModal from '@/components/BaseModal.vue'
|
import BaseModal from '@/components/BaseModal.vue'
|
||||||
|
import DatePickerField from '@/components/DatePickerField.vue'
|
||||||
import EmptyState from '@/components/EmptyState.vue'
|
import EmptyState from '@/components/EmptyState.vue'
|
||||||
import LoadingState from '@/components/LoadingState.vue'
|
import LoadingState from '@/components/LoadingState.vue'
|
||||||
import MobileShell from '@/components/MobileShell.vue'
|
import MobileShell from '@/components/MobileShell.vue'
|
||||||
import PageSection from '@/components/PageSection.vue'
|
import PageSection from '@/components/PageSection.vue'
|
||||||
|
import TimePickerField from '@/components/TimePickerField.vue'
|
||||||
import { managerShopApi } from '@/api/managerShop'
|
import { managerShopApi } from '@/api/managerShop'
|
||||||
import type { ShopScheduleException } from '@/types/manager'
|
import type { ShopScheduleException } from '@/types/manager'
|
||||||
import { formatDate } from '@/utils/date'
|
import { formatDate } from '@/utils/date'
|
||||||
|
|||||||
Reference in New Issue
Block a user