统一甲屿云命名体系

This commit is contained in:
2026-06-29 23:26:43 +08:00
parent 48c47fe3ff
commit bc8a7d8d4c
1268 changed files with 3477 additions and 3511 deletions
+64
View File
@@ -0,0 +1,64 @@
<template>
<div class="about-page">
<section class="card brand-card">
<img class="logo" :src="appIconUrl" alt="甲屿云" />
<strong>甲屿云</strong>
<span>专为美甲店店长设计的预约排班日历子系统</span>
</section>
<section class="card about-list section">
<div class="row-between">
<span>版本</span>
<span class="muted">0.0.1</span>
</div>
<div class="row-between">
<span>定位</span>
<span class="muted">规划 / 客户 / 员工 / 我的</span>
</div>
</section>
</div>
</template>
<script setup lang="ts">
const appIconUrl = `${import.meta.env.BASE_URL}assets/images/app-icon.png`
</script>
<style scoped>
.brand-card {
display: grid;
place-items: center;
gap: 10px;
padding: 28px 18px;
text-align: center;
}
.logo {
width: 68px;
height: 68px;
border-radius: 18px;
object-fit: cover;
}
.brand-card strong {
font-size: 20px;
}
.brand-card span {
max-width: 260px;
color: var(--muted);
font-size: 13px;
}
.about-list {
padding: 4px 14px;
}
.about-list .row-between {
min-height: 52px;
border-bottom: 1px solid var(--border);
}
.about-list .row-between:last-child {
border-bottom: 0;
}
</style>
@@ -0,0 +1,220 @@
<template>
<div class="detail-view">
<LoadingState v-if="loading" text="预约详情加载中" />
<EmptyState v-else-if="loadError" title="预约详情加载失败" :description="loadError">
<template #action>
<button class="secondary-btn" type="button" @click="loadDetail">重试</button>
</template>
</EmptyState>
<template v-else-if="appointment">
<section class="card detail-card">
<div class="detail-head">
<div class="detail-person">
<div class="avatar">{{ avatarText }}</div>
<div class="detail-person__copy">
<strong>{{ appointment.customerName || '到店客户' }}</strong>
<span>{{ appointment.phone || appointment.customerPhone || '未留手机号' }}</span>
</div>
</div>
<div class="detail-actions">
<span class="tag">{{ appointment.statusText || '待处理' }}</span>
<button class="text-btn" type="button" @click="goTransfer">改派</button>
</div>
</div>
<div class="detail-grid">
<div>
<span>项目</span>
<strong>{{ appointment.productTitle || appointment.manualProductTitle || '预约项目' }}</strong>
</div>
<div>
<span>美甲师</span>
<strong>{{ appointment.artistName || '未分配' }}</strong>
</div>
<div>
<span>时间</span>
<strong>{{ timeText }}</strong>
</div>
<div>
<span>时长</span>
<strong>{{ appointment.durationMinutes || '-' }} 分钟</strong>
</div>
</div>
</section>
<PageSection title="备注">
<div class="card note-card">{{ appointment.remark || '暂无备注' }}</div>
</PageSection>
<div class="fixed-bottom">
<div class="fixed-bottom__inner button-row">
<button class="secondary-btn" type="button" :disabled="saving" @click="updateStatus(1)">确认</button>
<button class="primary-btn" type="button" :disabled="saving" @click="updateStatus(2)">完成</button>
<button class="danger-btn" type="button" :disabled="saving" @click="updateStatus(3)">取消</button>
</div>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import PageSection from '@/components/PageSection.vue'
import { managerPlanningApi } from '@/api/managerPlanning'
import type { Appointment } from '@/types/manager'
import { useToastStore } from '@/stores/toast'
import { markPlanningRefresh } from '@/utils/storage'
const route = useRoute()
const router = useRouter()
const toast = useToastStore()
const appointment = ref<Appointment | null>(null)
const loading = ref(false)
const saving = ref(false)
const loadError = ref('')
const appointmentId = computed(() => String(route.params.id || ''))
const avatarText = computed(() => String(appointment.value?.customerName || '客').slice(0, 1))
const timeText = computed(() => {
const item = appointment.value
const start = String(item?.startTime || item?.date || '').slice(0, 16)
const end = String(item?.endTime || '').slice(11, 16)
if (!start && !end) {
return '-'
}
return `${start || '-'} - ${end || '-'}`
})
const loadDetail = async (): Promise<void> => {
loading.value = true
loadError.value = ''
try {
appointment.value = await managerPlanningApi.appointment(appointmentId.value)
} catch (error) {
appointment.value = null
loadError.value = error instanceof Error ? error.message : '预约详情加载失败'
} finally {
loading.value = false
}
}
const updateStatus = async (status: number): Promise<void> => {
if (!appointment.value?.orderId) {
toast.error('当前预约缺少订单 ID,无法更新状态')
return
}
saving.value = true
try {
await managerPlanningApi.updateStatus(appointment.value.orderId, status)
markPlanningRefresh()
toast.success('已更新')
await loadDetail()
} finally {
saving.value = false
}
}
const goTransfer = async (): Promise<void> => {
await router.push(`/appointments/${appointmentId.value}/transfer`)
}
onMounted(loadDetail)
</script>
<style scoped>
.detail-view {
padding-bottom: 82px;
}
.detail-card,
.note-card {
padding: 16px;
}
.detail-head,
.detail-person,
.detail-actions {
display: flex;
align-items: center;
}
.detail-head {
justify-content: space-between;
gap: 12px;
}
.detail-person {
min-width: 0;
gap: 12px;
}
.avatar {
display: grid;
flex: 0 0 44px;
place-items: center;
width: 44px;
height: 44px;
border-radius: 16px;
background: var(--accent-soft);
color: var(--accent);
font-size: 18px;
font-weight: 900;
}
.detail-person__copy {
display: grid;
min-width: 0;
gap: 3px;
}
.detail-person__copy strong,
.detail-person__copy span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.detail-person__copy span {
color: var(--muted);
font-size: 12px;
}
.detail-actions {
flex-direction: column;
align-items: flex-end;
gap: 8px;
}
.detail-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
margin-top: 18px;
}
.detail-grid div {
display: grid;
gap: 4px;
min-width: 0;
}
.detail-grid span {
color: var(--muted);
font-size: 12px;
}
.detail-grid strong {
overflow-wrap: anywhere;
font-size: 14px;
}
.note-card {
min-height: 86px;
color: #4d4840;
white-space: pre-wrap;
}
</style>
@@ -0,0 +1,463 @@
<template>
<MobileShell title="新建预约">
<div v-if="draftSavedAtText" class="card draft-tip">
<span>{{ draftSavedAtText }}</span>
<button class="text-btn" type="button" @click="clearDraft">清空</button>
</div>
<section class="card form-card">
<div class="field"><label class="required">客户姓名</label><input v-model.trim="form.customerName" placeholder="请输入客户姓名" @input="scheduleCustomerSearch" /></div>
<div class="field"><label class="required">手机号</label><input v-model.trim="form.phone" inputmode="numeric" placeholder="请输入手机号" @input="scheduleCustomerSearch" /></div>
<div v-if="customerOptions.length > 0" class="customer-options">
<button v-for="customer in customerOptions" :key="String(customer.id)" type="button" @click="selectCustomer(customer)">
<strong>{{ customer.nickname || customer.account }}</strong>
<span>{{ customer.phone || customer.contactPhone }}</span>
</button>
</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><button class="field-value picker-value" type="button" @click="productModalVisible = true">{{ selectedProductTitle }}</button></div>
<div class="field"><label class="required">预计时长</label><input v-model.trim="form.durationMinutes" inputmode="numeric" placeholder="分钟" @input="refreshAvailableTimes" /></div>
<div class="field"><label class="required">指定员工</label><select v-model="form.artistId" @change="refreshAvailableTimes"><option value="">请选择员工</option><option v-for="artist in artists" :key="String(artist.id)" :value="String(artist.id)">{{ artist.name || artist.nickname }}</option></select></div>
<div class="field"><label class="required">预约时间</label><button class="field-value picker-value" type="button" @click="openTimeSheet">{{ form.appointmentTime || timeSelectTip }}</button></div>
<div class="field field--stack"><label>备注</label><textarea v-model.trim="form.remark" placeholder="请输入预约备注"></textarea></div>
</section>
<div v-if="conflictTip" class="conflict-tip" :class="`conflict-tip--${conflictLevel}`">{{ conflictTip }}</div>
<div class="fixed-bottom">
<div class="fixed-bottom__inner button-row">
<button class="secondary-btn" type="button" @click="saveDraft">保存草稿</button>
<button class="primary-btn" type="button" :disabled="loading" @click="submit">{{ loading ? '提交中...' : '提交预约' }}</button>
</div>
</div>
<BaseModal v-model="productModalVisible" title="选择预约作品">
<div class="product-modal">
<input v-model.trim="productKeyword" class="search-input" placeholder="搜索作品" @input="filterProducts" />
<div class="list">
<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>
<strong>{{ product.title }}</strong>
<span>{{ product.priceText }} · {{ product.durationText || '时长待定' }}</span>
<small>{{ product.artistText }}</small>
</div>
</button>
</div>
<PageSection title="手动新增预约作品">
<div class="manual-form">
<input v-model.trim="form.manualProductTitle" class="search-input" placeholder="作品名称" />
<input v-model.trim="form.manualProductPrice" class="search-input" inputmode="decimal" placeholder="价格" />
<input v-model.trim="form.manualProductTags" class="search-input" placeholder="标签,逗号分隔" />
<textarea v-model.trim="form.manualProductDescription" class="search-input textarea" placeholder="作品说明"></textarea>
<button class="secondary-btn" type="button" @click="useManualProduct">使用手动作品</button>
</div>
</PageSection>
</div>
</BaseModal>
<BaseModal v-model="timeSheetVisible" title="选择可约时间">
<div class="time-sheet">
<LoadingState v-if="timeLoading" text="正在计算可约时间" />
<EmptyState v-else-if="availableTimeGroups.length === 0" title="暂无可约时间" :description="timeSelectTip" />
<section v-for="group in availableTimeGroups" v-else :key="group.key">
<h3>{{ group.title }}</h3>
<div class="time-grid">
<button v-for="time in group.times" :key="time.value" type="button" @click="selectAvailableTime(time.value)">
<strong>{{ time.value }}</strong>
<span>{{ time.rangeText }}</span>
</button>
</div>
</section>
</div>
</BaseModal>
</MobileShell>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import BaseModal from '@/components/BaseModal.vue'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import MobileShell from '@/components/MobileShell.vue'
import PageSection from '@/components/PageSection.vue'
import { managerCustomersApi } from '@/api/managerCustomers'
import { managerEmployeesApi } from '@/api/managerEmployees'
import { managerPlanningApi } from '@/api/managerPlanning'
import { managerProductsApi } from '@/api/managerProducts'
import type { AppointmentForm, Artist, Product } from '@/types/manager'
import type { UserInfo } from '@/types/common'
import { useSessionStore } from '@/stores/session'
import { useToastStore } from '@/stores/toast'
import { formatDate, minutesOfDay, timeFromMinutes } from '@/utils/date'
import { buildAvailableTimeGroups, type AvailableTimeGroup } from '@/utils/available-times'
import { buildClientRequestId, normalizeDuration } from '@/utils/planning'
import { readDraftForm, removeDraftForm, writeDraftForm } from '@/utils/appointment-draft'
import { markPlanningRefresh } from '@/utils/storage'
interface ProductCard extends Product {
coverImage: string
priceText: string
durationText: string
artistText: string
}
const route = useRoute()
const router = useRouter()
const session = useSessionStore()
const toast = useToastStore()
const baseForm = readDraftForm(session.userInfo)
const form = reactive<AppointmentForm>({
customerUserId: '',
customerName: String(route.query.customerName || baseForm?.customerName || ''),
phone: String(route.query.phone || baseForm?.phone || ''),
appointmentDate: String(route.query.date || baseForm?.appointmentDate || formatDate(new Date())),
appointmentTime: baseForm?.appointmentTime || '',
productId: baseForm?.productId || '',
manualProductTitle: baseForm?.manualProductTitle || '',
manualProductPrice: baseForm?.manualProductPrice || '',
manualProductDescription: baseForm?.manualProductDescription || '',
manualProductTags: baseForm?.manualProductTags || '',
manualProductTargetAudience: baseForm?.manualProductTargetAudience || '',
manualProductPrecautions: baseForm?.manualProductPrecautions || '',
manualProductImageFileIds: baseForm?.manualProductImageFileIds || '',
manualProductImageUrl: baseForm?.manualProductImageUrl || '',
durationMinutes: baseForm?.durationMinutes || '',
artistId: String(route.query.artistId || baseForm?.artistId || ''),
remark: baseForm?.remark || ''
})
const draftSavedAtText = ref(baseForm ? '已恢复本机草稿' : '')
const customerOptions = ref<UserInfo[]>([])
const customerTimer = ref<number | null>(null)
const products = ref<ProductCard[]>([])
const filteredProducts = ref<ProductCard[]>([])
const productKeyword = ref('')
const productModalVisible = ref(false)
const artists = ref<Artist[]>([])
const selectedProduct = ref<ProductCard | null>(null)
const timeSheetVisible = ref(false)
const availableTimeGroups = ref<AvailableTimeGroup[]>([])
const timeLoading = ref(false)
const timeSelectTip = ref('请先选择美甲师并填写时长')
const conflictTip = ref('')
const conflictLevel = ref<'free' | 'danger'>('free')
const loading = ref(false)
const selectedProductTitle = computed(() => {
if (selectedProduct.value) {
return selectedProduct.value.title
}
if (form.manualProductTitle) {
return form.manualProductTitle
}
return '请选择作品'
})
const normalizeProduct = (product: Product): ProductCard => {
const imageUrls = Array.isArray(product.imageUrls) ? product.imageUrls : []
const durationText = product.approximateDuration || (product.serviceDurationMinutes ? `${product.serviceDurationMinutes}分钟` : '')
return {
...product,
coverImage: imageUrls[0] || '',
priceText: product.price || product.price === 0 ? `¥${product.price}` : '价格待定',
durationText,
artistText: '全部美甲师'
}
}
const filterProducts = (): void => {
const keyword = productKeyword.value.toLowerCase()
filteredProducts.value = products.value.filter(product => {
if (!keyword) {
return true
}
return [product.title, product.priceText, product.durationText, product.artistText].some(value => String(value || '').toLowerCase().includes(keyword))
})
}
const loadOptions = async (): Promise<void> => {
const [productData, employeeData] = await Promise.all([
managerProductsApi.list({ page: 1, size: 100 }),
managerEmployeesApi.list()
])
const productList = Array.isArray(productData) ? productData : productData.list
products.value = productList.map(normalizeProduct)
filteredProducts.value = products.value
artists.value = employeeData
if (form.productId) {
selectedProduct.value = products.value.find(item => String(item.id) === String(form.productId)) || null
}
}
const scheduleCustomerSearch = (): void => {
if (customerTimer.value !== null) {
window.clearTimeout(customerTimer.value)
}
customerTimer.value = window.setTimeout(() => {
void searchCustomers()
}, 250)
}
const searchCustomers = async (): Promise<void> => {
const keyword = form.customerName || form.phone
const data = await managerCustomersApi.list({ page: 1, size: 20, keyword })
customerOptions.value = data.list || []
}
const selectCustomer = (customer: UserInfo): void => {
form.customerUserId = String(customer.id)
form.customerName = customer.nickname || customer.account || ''
form.phone = customer.phone || customer.contactPhone || ''
customerOptions.value = []
}
const onDateChange = async (): Promise<void> => {
form.appointmentTime = ''
await refreshAvailableTimes()
}
const selectProduct = (product: ProductCard): void => {
selectedProduct.value = product
form.productId = String(product.id)
form.manualProductTitle = ''
form.manualProductPrice = ''
form.durationMinutes = String(Number.parseInt(product.approximateDuration || '', 10) || product.serviceDurationMinutes || form.durationMinutes)
productModalVisible.value = false
void refreshAvailableTimes()
}
const useManualProduct = (): 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
productModalVisible.value = false
}
const refreshAvailableTimes = async (): Promise<void> => {
const durationMinutes = normalizeDuration(form.durationMinutes)
if (!form.appointmentDate || !form.artistId || !durationMinutes) {
availableTimeGroups.value = []
timeSelectTip.value = '请先选择美甲师并填写时长'
return
}
timeLoading.value = true
try {
const calendar = await managerPlanningApi.calendar({ startDate: form.appointmentDate, endDate: form.appointmentDate, artistId: form.artistId })
availableTimeGroups.value = buildAvailableTimeGroups(calendar, form)
timeSelectTip.value = availableTimeGroups.value.length > 0 ? '请选择预约时间' : '当前美甲师当天暂无可约时间'
} finally {
timeLoading.value = false
}
}
const openTimeSheet = async (): Promise<void> => {
if (!form.appointmentDate || !form.artistId || !normalizeDuration(form.durationMinutes)) {
toast.error('请先选择美甲师并填写时长')
return
}
timeSheetVisible.value = true
await refreshAvailableTimes()
}
const selectAvailableTime = (value: string): void => {
form.appointmentTime = value
timeSheetVisible.value = false
void checkAvailability()
}
const checkAvailability = async (): Promise<{ ok: boolean; tip?: string }> => {
if (!form.appointmentDate || !form.appointmentTime || !form.artistId || !normalizeDuration(form.durationMinutes)) {
conflictTip.value = ''
return { ok: true }
}
const startMinute = minutesOfDay(form.appointmentTime)
const endMinute = startMinute + normalizeDuration(form.durationMinutes)
if (startMinute < minutesOfDay('10:00') || endMinute > minutesOfDay('22:00')) {
conflictTip.value = '该时间超出营业时间 10:00-22:00'
conflictLevel.value = 'danger'
return { ok: false, tip: conflictTip.value }
}
conflictTip.value = `当前时段 ${form.appointmentTime}-${timeFromMinutes(endMinute)} 可预约`
conflictLevel.value = 'free'
return { ok: true, tip: conflictTip.value }
}
const submit = async (): Promise<void> => {
const hasManualProduct = form.manualProductTitle.trim() && form.manualProductPrice.trim()
if (!form.customerName || !form.phone || (!form.productId && !hasManualProduct) || !form.artistId || !form.appointmentTime) {
toast.error('请补全预约信息')
return
}
const durationMinutes = normalizeDuration(form.durationMinutes)
if (!durationMinutes) {
toast.error('请填写预约时长')
return
}
const availability = await checkAvailability()
if (!availability.ok) {
toast.error(availability.tip || '该时段已被预约')
return
}
loading.value = true
try {
const payload = {
...form,
customerUserId: form.customerUserId || undefined,
productId: form.productId || undefined,
artistId: form.artistId,
durationMinutes,
manualProductPrice: hasManualProduct ? Number(form.manualProductPrice) : undefined,
clientRequestId: buildClientRequestId('manager-appointment')
}
const result = await managerPlanningApi.createAppointment(payload)
removeDraftForm(session.userInfo)
markPlanningRefresh()
toast.success('预约已创建')
await router.replace(`/appointments/${result.orderItemId}`)
} finally {
loading.value = false
}
}
const saveDraft = (): void => {
writeDraftForm(session.userInfo, { ...form })
draftSavedAtText.value = '草稿已保存到本机'
toast.success('草稿已保存')
}
const clearDraft = (): void => {
removeDraftForm(session.userInfo)
draftSavedAtText.value = ''
toast.success('草稿已清空')
}
onMounted(async () => {
await loadOptions()
await searchCustomers()
await refreshAvailableTimes()
})
</script>
<style scoped>
.draft-tip {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
padding: 10px 12px;
color: var(--accent);
font-weight: 800;
}
.customer-options {
display: grid;
gap: 6px;
padding: 8px 0;
}
.customer-options button {
display: flex;
justify-content: space-between;
padding: 8px 10px;
border-radius: 10px;
background: var(--subtle);
}
.picker-value {
justify-content: flex-start;
color: var(--ink);
text-align: left;
}
.conflict-tip {
margin-top: 12px;
padding: 10px 12px;
border-radius: 12px;
background: var(--accent-soft);
color: var(--accent);
font-weight: 800;
}
.conflict-tip--danger {
background: #fff0ee;
color: var(--danger);
}
.product-modal,
.time-sheet {
display: grid;
gap: 12px;
padding: 14px;
}
.product-card {
display: grid;
grid-template-columns: 72px 1fr;
gap: 10px;
width: 100%;
padding: 10px;
border-radius: 14px;
background: var(--subtle);
text-align: left;
}
.product-card img {
width: 72px;
height: 72px;
border-radius: 12px;
object-fit: cover;
}
.product-card strong,
.product-card span,
.product-card small {
display: block;
}
.product-card span,
.product-card small {
margin-top: 3px;
color: var(--muted);
font-size: 12px;
}
.manual-form {
display: grid;
gap: 8px;
}
.textarea {
min-height: 88px;
padding: 12px;
resize: vertical;
}
.time-sheet h3 {
margin: 0 0 8px;
}
.time-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
}
.time-grid button {
display: grid;
gap: 2px;
padding: 10px 4px;
border-radius: 12px;
background: var(--accent-soft);
color: var(--accent);
}
.time-grid span {
font-size: 11px;
}
</style>
@@ -0,0 +1,157 @@
<template>
<div class="transfer-view">
<LoadingState v-if="loadingArtists" text="美甲师加载中" />
<EmptyState v-else-if="loadError" title="美甲师列表加载失败" :description="loadError">
<template #action>
<button class="secondary-btn" type="button" @click="loadArtists">重试</button>
</template>
</EmptyState>
<EmptyState v-else-if="artists.length === 0" title="暂无可选美甲师" description="当前日期没有可改派的员工" />
<div v-else class="list">
<button
v-for="artist in artists"
:key="artist.id"
class="card transfer-card"
:class="{ 'transfer-card--active': String(selectedArtistId) === String(artist.id) }"
type="button"
@click="selectedArtistId = artist.id"
>
<span class="artist-dot" :style="{ backgroundColor: artist.color || '#6f8f83' }"></span>
<span class="transfer-card__main">
<strong>{{ artist.name || artist.nickname || '美甲师' }}</strong>
<small>{{ artist.status === 0 ? '停用' : '可选择' }}</small>
</span>
<span class="tag">可选择</span>
</button>
</div>
<section v-if="!loadError" class="card form-card section">
<label class="field">
<span class="field-label required">新日期</span>
<input v-model="form.date" class="field-value" type="date" @change="loadArtists" />
</label>
<label class="field">
<span class="field-label required">新时间</span>
<input v-model="form.time" class="field-value" type="time" min="10:00" max="22:00" />
</label>
</section>
<div v-if="!loadError" class="fixed-bottom">
<div class="fixed-bottom__inner">
<button class="primary-btn" type="button" :disabled="saving" @click="submit">
{{ saving ? '改派中...' : '确认改派' }}
</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import { managerPlanningApi } from '@/api/managerPlanning'
import type { Artist } from '@/types/manager'
import type { IdType } from '@/types/common'
import { formatDate } from '@/utils/date'
import { useToastStore } from '@/stores/toast'
import { markPlanningRefresh } from '@/utils/storage'
const route = useRoute()
const router = useRouter()
const toast = useToastStore()
const artists = ref<Artist[]>([])
const selectedArtistId = ref<IdType | ''>('')
const loadingArtists = ref(false)
const saving = ref(false)
const loadError = ref('')
const form = reactive({
date: formatDate(new Date()),
time: '13:00'
})
const loadArtists = async (): Promise<void> => {
loadingArtists.value = true
loadError.value = ''
try {
const calendar = await managerPlanningApi.calendar({ startDate: form.date, endDate: form.date })
artists.value = calendar.artists || []
selectedArtistId.value = ''
} catch (error) {
artists.value = []
selectedArtistId.value = ''
loadError.value = error instanceof Error ? error.message : '美甲师列表加载失败'
} finally {
loadingArtists.value = false
}
}
const submit = async (): Promise<void> => {
if (!selectedArtistId.value) {
toast.error('请选择美甲师')
return
}
saving.value = true
try {
await managerPlanningApi.moveAppointment(String(route.params.id || ''), {
artistId: selectedArtistId.value,
appointmentDate: form.date,
appointmentTime: form.time
})
markPlanningRefresh()
toast.success('已改派')
await router.back()
} finally {
saving.value = false
}
}
onMounted(loadArtists)
</script>
<style scoped>
.transfer-view {
padding-bottom: 88px;
}
.transfer-card {
display: grid;
grid-template-columns: 18px 1fr auto;
align-items: center;
gap: 10px;
width: 100%;
padding: 14px;
text-align: left;
}
.transfer-card--active {
border-color: rgba(47, 111, 98, 0.38);
background: var(--accent-soft);
}
.artist-dot {
width: 12px;
height: 12px;
border-radius: 50%;
}
.transfer-card__main {
display: grid;
gap: 2px;
min-width: 0;
}
.transfer-card__main strong,
.transfer-card__main small {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.transfer-card__main small {
color: var(--muted);
}
</style>
@@ -0,0 +1,62 @@
<template>
<MobileShell title="颜色设置">
<section class="color-grid">
<button v-for="color in presets" :key="color" class="color-swatch" :class="{ active: selected === color }" :style="{ backgroundColor: color }" type="button" @click="selectColor(color)"></button>
</section>
<section class="card form-card section">
<div class="field"><label>自定义色值</label><input v-model.trim="customColor" placeholder="#6F8F83" /></div>
</section>
<button class="primary-btn section" type="button" @click="applyCustom">应用自定义颜色</button>
<button class="secondary-btn section" type="button" @click="save">保存</button>
</MobileShell>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import MobileShell from '@/components/MobileShell.vue'
import { useToastStore } from '@/stores/toast'
const toast = useToastStore()
const presets = ['#6F8F83', '#C58C6D', '#8B6F8F', '#6F7F8F', '#B86B6B', '#B8A36B', '#7A9D96', '#9D7A7A']
const defaultColor = presets[0] as string
const selected = ref(defaultColor)
const customColor = ref(defaultColor)
const selectColor = (color: string): void => {
selected.value = color
customColor.value = color
}
const applyCustom = (): void => {
if (!/^#[0-9a-fA-F]{6}$/.test(customColor.value)) {
toast.error('请输入6位色值')
return
}
selected.value = customColor.value.toUpperCase()
customColor.value = selected.value
}
const save = (): void => {
toast.success('已保存到本地')
}
</script>
<style scoped>
.color-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
}
.color-swatch {
aspect-ratio: 1;
border: 4px solid transparent;
border-radius: 18px;
box-shadow: var(--shadow);
}
.color-swatch.active {
border-color: var(--card-bg);
outline: 3px solid var(--accent);
}
</style>
@@ -0,0 +1,101 @@
<template>
<MobileShell title="客户详情">
<LoadingState v-if="loading" text="正在加载客户" />
<template v-else-if="customer">
<section class="card customer-card">
<div class="avatar">{{ firstName }}</div>
<div>
<h2>{{ customer.nickname || customer.account || '未命名客户' }}</h2>
<p>{{ customer.phone || customer.contactPhone || '未填写手机号' }}</p>
</div>
</section>
<PageSection title="客户信息">
<section class="card form-card">
<div class="field"><label>登录账号</label><div class="field-value">{{ customer.account || '未设置' }}</div></div>
<div class="field"><label>联系电话</label><div class="field-value">{{ customer.contactPhone || customer.phone || '未设置' }}</div></div>
<div class="field"><label>注册时间</label><div class="field-value">{{ customer.createTime || '暂无' }}</div></div>
</section>
</PageSection>
<button class="primary-btn section" type="button" @click="createAppointment">为客户预约</button>
</template>
<EmptyState v-else title="客户不存在" />
</MobileShell>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import MobileShell from '@/components/MobileShell.vue'
import PageSection from '@/components/PageSection.vue'
import { managerCustomersApi } from '@/api/managerCustomers'
import type { UserInfo } from '@/types/common'
import { useToastStore } from '@/stores/toast'
import { useSessionStore } from '@/stores/session'
import { canCreateAppointment } from '@/utils/permissions'
const route = useRoute()
const router = useRouter()
const toast = useToastStore()
const session = useSessionStore()
const loading = ref(false)
const customer = ref<UserInfo | null>(null)
const firstName = computed(() => String(customer.value?.nickname || customer.value?.account || '客').slice(0, 1))
const loadCustomer = async (): Promise<void> => {
loading.value = true
try {
customer.value = await managerCustomersApi.detail(String(route.params.id))
} finally {
loading.value = false
}
}
const createAppointment = (): void => {
if (!canCreateAppointment(session.userInfo)) {
toast.error('美甲师账号只能查看预约')
return
}
const name = encodeURIComponent(customer.value?.nickname || customer.value?.account || '')
const phone = encodeURIComponent(customer.value?.phone || customer.value?.contactPhone || '')
void router.push(`/appointments/new?customerName=${name}&phone=${phone}`)
}
onMounted(() => {
void loadCustomer()
})
</script>
<style scoped>
.customer-card {
display: flex;
align-items: center;
gap: 14px;
padding: 18px;
}
.avatar {
display: grid;
place-items: center;
width: 58px;
height: 58px;
border-radius: 20px;
background: var(--accent-soft);
color: var(--accent);
font-size: 24px;
font-weight: 900;
}
.customer-card h2,
.customer-card p {
margin: 0;
}
.customer-card p {
margin-top: 4px;
color: var(--muted);
}
</style>
+112
View File
@@ -0,0 +1,112 @@
<template>
<MobileShell>
<div class="toolbar-card card">
<input v-model.trim="keyword" class="search-input" placeholder="搜索客户姓名或手机号" @keyup.enter="loadCustomers" />
<button class="secondary-btn" type="button" @click="loadCustomers">搜索</button>
</div>
<LoadingState v-if="loading" text="正在加载客户" />
<EmptyState v-else-if="customers.length === 0" title="暂无客户" description="新增客户后会显示在这里" />
<section v-else class="list section">
<article v-for="customer in customers" :key="String(customer.id)" class="card list-card" @click="router.push(`/customers/${customer.id}`)">
<div class="row-between">
<div>
<h2 class="list-card__title">{{ customer.nickname || customer.account || '未命名客户' }}</h2>
<div class="list-card__subtitle">{{ customer.phone || customer.contactPhone || '未填写手机号' }}</div>
</div>
<span class="tag">{{ customer.createTime ? '已建档' : '客户' }}</span>
</div>
</article>
</section>
<button class="fab" type="button" @click="openCreate">+</button>
<BaseModal v-model="createModalVisible" title="新增客户">
<div class="modal-form">
<div class="field">
<label class="required">客户姓名</label>
<input v-model.trim="createForm.nickname" placeholder="请输入客户姓名" />
</div>
<div class="field">
<label class="required">手机号</label>
<input v-model.trim="createForm.phone" inputmode="numeric" placeholder="请输入手机号" />
</div>
<button class="primary-btn" type="button" :disabled="creating" @click="createCustomer">
{{ creating ? '新增中...' : '保存客户' }}
</button>
</div>
</BaseModal>
</MobileShell>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import BaseModal from '@/components/BaseModal.vue'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import MobileShell from '@/components/MobileShell.vue'
import { managerCustomersApi } from '@/api/managerCustomers'
import type { UserInfo } from '@/types/common'
import { useToastStore } from '@/stores/toast'
const router = useRouter()
const toast = useToastStore()
const keyword = ref('')
const loading = ref(false)
const customers = ref<UserInfo[]>([])
const createModalVisible = ref(false)
const creating = ref(false)
const createForm = reactive({ nickname: '', phone: '' })
const loadCustomers = async (): Promise<void> => {
loading.value = true
try {
const data = await managerCustomersApi.list({ page: 1, size: 50, keyword: keyword.value })
customers.value = data.list || []
} finally {
loading.value = false
}
}
const openCreate = (): void => {
createForm.nickname = ''
createForm.phone = ''
createModalVisible.value = true
}
const createCustomer = async (): Promise<void> => {
if (!createForm.nickname || !createForm.phone) {
toast.error('请填写客户姓名和手机号')
return
}
creating.value = true
try {
await managerCustomersApi.create({ nickname: createForm.nickname, phone: createForm.phone })
toast.success('客户已新增')
createModalVisible.value = false
await loadCustomers()
} finally {
creating.value = false
}
}
onMounted(() => {
void loadCustomers()
})
</script>
<style scoped>
.toolbar-card {
display: grid;
grid-template-columns: 1fr 84px;
gap: 8px;
padding: 12px;
}
.modal-form {
display: grid;
gap: 12px;
padding: 14px;
}
</style>
@@ -0,0 +1,135 @@
<template>
<MobileShell title="员工详情">
<LoadingState v-if="loading" text="正在加载员工" />
<template v-else-if="employee">
<section class="card employee-hero">
<div class="employee-avatar" :style="{ backgroundColor: employee.color || '#e5eee9' }">
<img v-if="employee.avatar" :src="employee.avatar" alt="" />
<span v-else>{{ (employee.name || employee.nickname || '员').slice(0, 1) }}</span>
</div>
<div>
<h2>{{ employee.name || employee.nickname || '未命名员工' }}</h2>
<p>{{ employee.phone || '未填写手机号' }}</p>
</div>
</section>
<section class="card form-card section">
<div class="field"><label>员工编号</label><div class="field-value">{{ employee.userId || employee.id }}</div></div>
<div class="field"><label>级别</label><div class="field-value">{{ employee.level || '美甲师' }}</div></div>
<div class="field"><label>预约颜色</label><div class="field-value color-line"><span class="color-dot" :style="{ backgroundColor: employee.color || '#b8b0a6' }"></span>{{ employee.color || '未设置' }}</div></div>
</section>
<section class="card menu-list section">
<button v-for="item in menus" :key="item.path" class="menu-row" type="button" @click="router.push(item.path)">
<span>{{ item.title }}</span>
<span>›</span>
</button>
</section>
</template>
<EmptyState v-else title="员工不存在" />
</MobileShell>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import MobileShell from '@/components/MobileShell.vue'
import { managerEmployeesApi } from '@/api/managerEmployees'
import type { Artist } from '@/types/manager'
const route = useRoute()
const router = useRouter()
const loading = ref(false)
const employee = ref<Artist | null>(null)
const employeeId = computed(() => String(route.params.id))
const menus = computed(() => [
{ title: '排班设置', path: `/employees/${employeeId.value}/schedule` },
{ title: '请假管理', path: `/employees/${employeeId.value}/leave` },
{ title: '颜色设置', path: `/employees/${employeeId.value}/color` },
{ title: '员工作品/订单', path: `/employees/${employeeId.value}/orders` }
])
const loadEmployee = async (): Promise<void> => {
loading.value = true
try {
employee.value = await managerEmployeesApi.detail(employeeId.value)
} finally {
loading.value = false
}
}
onMounted(() => {
void loadEmployee()
})
</script>
<style scoped>
.employee-hero {
display: flex;
align-items: center;
gap: 14px;
padding: 18px;
}
.employee-avatar {
display: grid;
place-items: center;
width: 62px;
height: 62px;
overflow: hidden;
border-radius: 22px;
color: var(--accent);
font-size: 24px;
font-weight: 900;
}
.employee-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.employee-hero h2,
.employee-hero p {
margin: 0;
}
.employee-hero p {
margin-top: 4px;
color: var(--muted);
}
.color-line {
display: flex;
align-items: center;
gap: 8px;
}
.color-dot {
width: 16px;
height: 16px;
border-radius: 50%;
}
.menu-list {
overflow: hidden;
}
.menu-row {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
min-height: 54px;
padding: 0 14px;
border-bottom: 1px solid var(--border);
color: var(--ink);
font-weight: 800;
}
.menu-row:last-child {
border-bottom: 0;
}
</style>
@@ -0,0 +1,10 @@
<template>
<MobileShell title="员工作品/订单">
<EmptyState title="暂无员工作品/订单" description="当前小程序页面为返回入口,Web 端按现状保留轻量视图。" mark="单" />
</MobileShell>
</template>
<script setup lang="ts">
import EmptyState from '@/components/EmptyState.vue'
import MobileShell from '@/components/MobileShell.vue'
</script>
+160
View File
@@ -0,0 +1,160 @@
<template>
<MobileShell>
<LoadingState v-if="loading" text="正在加载员工" />
<EmptyState v-else-if="employees.length === 0" title="暂无员工" description="新增美甲师后会显示在这里" />
<section v-else class="list">
<article v-for="employee in employees" :key="String(employee.userId || employee.id)" class="card employee-card" @click="router.push(`/employees/${employee.userId || employee.id}`)">
<div class="employee-avatar" :style="{ backgroundColor: employee.color || '#e5eee9' }">
<img v-if="employee.avatar" :src="employee.avatar" alt="" />
<span v-else>{{ (employee.name || employee.nickname || '员').slice(0, 1) }}</span>
</div>
<div class="employee-card__body">
<h2>{{ employee.name || employee.nickname || '未命名员工' }}</h2>
<p>{{ employee.phone || '未填写手机号' }}</p>
<div class="employee-tags">
<span class="tag">{{ employee.level || '美甲师' }}</span>
<span class="tag">{{ employee.enabled === 0 || employee.status === 0 ? '已停用' : '可预约' }}</span>
</div>
</div>
</article>
</section>
<button class="fab" type="button" @click="openCreate">+</button>
<BaseModal v-model="createModalVisible" title="新增员工">
<div class="modal-form">
<div class="field"><label class="required">姓名</label><input v-model.trim="createForm.nickname" placeholder="请输入姓名" /></div>
<div class="field"><label class="required">手机号</label><input v-model.trim="createForm.phone" inputmode="numeric" placeholder="请输入手机号" /></div>
<div class="field"><label class="required">登录账号</label><input v-model.trim="createForm.account" placeholder="请输入登录账号" /></div>
<div class="field"><label class="required">初始密码</label><input v-model="createForm.password" type="password" placeholder="请输入初始密码" /></div>
<div class="field"><label>微信号</label><input v-model.trim="createForm.wechatId" placeholder="请输入微信号" /></div>
<button class="primary-btn" type="button" :disabled="creating" @click="createEmployee">{{ creating ? '新增中...' : '保存员工' }}</button>
</div>
</BaseModal>
</MobileShell>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import BaseModal from '@/components/BaseModal.vue'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import MobileShell from '@/components/MobileShell.vue'
import { managerEmployeesApi } from '@/api/managerEmployees'
import type { Artist } from '@/types/manager'
import { useToastStore } from '@/stores/toast'
const router = useRouter()
const toast = useToastStore()
const loading = ref(false)
const employees = ref<Artist[]>([])
const createModalVisible = ref(false)
const creating = ref(false)
const createForm = reactive({
nickname: '',
phone: '',
account: '',
password: '',
wechatId: ''
})
const loadEmployees = async (): Promise<void> => {
loading.value = true
try {
employees.value = await managerEmployeesApi.list()
} finally {
loading.value = false
}
}
const openCreate = (): void => {
createForm.nickname = ''
createForm.phone = ''
createForm.account = ''
createForm.password = ''
createForm.wechatId = ''
createModalVisible.value = true
}
const createEmployee = async (): Promise<void> => {
if (!createForm.nickname || !createForm.phone || !createForm.account || !createForm.password || !createForm.wechatId) {
toast.error('请补全美甲师信息')
return
}
creating.value = true
try {
await managerEmployeesApi.createUser({
nickname: createForm.nickname,
phone: createForm.phone,
account: createForm.account,
password: createForm.password,
contactPhone: createForm.phone,
wechatId: createForm.wechatId
})
toast.success('美甲师已新增')
createModalVisible.value = false
await loadEmployees()
} finally {
creating.value = false
}
}
onMounted(() => {
void loadEmployees()
})
</script>
<style scoped>
.employee-card {
display: flex;
gap: 12px;
padding: 14px;
}
.employee-avatar {
display: grid;
place-items: center;
flex: 0 0 58px;
width: 58px;
height: 58px;
overflow: hidden;
border-radius: 20px;
color: var(--accent);
font-size: 22px;
font-weight: 900;
}
.employee-avatar img {
width: 100%;
height: 100%;
object-fit: cover;
}
.employee-card__body {
min-width: 0;
flex: 1;
}
.employee-card h2,
.employee-card p {
margin: 0;
}
.employee-card p {
margin-top: 4px;
color: var(--muted);
}
.employee-tags {
display: flex;
gap: 6px;
margin-top: 8px;
}
.modal-form {
display: grid;
gap: 12px;
padding: 14px;
}
</style>
+213
View File
@@ -0,0 +1,213 @@
<template>
<div class="export-view">
<section class="card form-card">
<label class="field">
<span class="field-label">导出类型</span>
<select v-model="type" @change="loadPreview">
<option v-for="item in types" :key="item" :value="item">{{ item }}</option>
</select>
</label>
<label class="field">
<span class="field-label">开始日期</span>
<input v-model="startDate" class="field-value" type="date" @change="loadPreview" />
</label>
<label class="field">
<span class="field-label">结束日期</span>
<input v-model="endDate" class="field-value" type="date" @change="loadPreview" />
</label>
</section>
<section class="card preview-card section">
<div class="preview-head">
<strong>数据预览</strong>
<span>最多展示 10 条</span>
</div>
<LoadingState v-if="previewLoading" text="预览加载中" />
<EmptyState v-else-if="previewError" title="预览加载失败" :description="previewError" />
<EmptyState v-else-if="previewRows.length === 0" title="暂无可预览数据" description="调整日期后再试" />
<div v-else class="preview-scroll">
<table>
<thead>
<tr>
<th v-for="column in previewColumns" :key="column">{{ column }}</th>
</tr>
</thead>
<tbody>
<tr v-for="row in previewRows" :key="row.key">
<td v-for="column in previewColumns" :key="`${row.key}-${column}`">{{ row[column] }}</td>
</tr>
</tbody>
</table>
</div>
</section>
<div class="fixed-bottom">
<div class="fixed-bottom__inner">
<button class="primary-btn" type="button" @click="exportExcel">导出 Excel</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import { managerCustomersApi } from '@/api/managerCustomers'
import { managerEmployeesApi } from '@/api/managerEmployees'
import { managerPlanningApi } from '@/api/managerPlanning'
import { formatDate, startOfMonth } from '@/utils/date'
import { useToastStore } from '@/stores/toast'
import type { Appointment, Artist } from '@/types/manager'
import type { UserInfo } from '@/types/common'
type ExportType = '订单数据' | '客户数据' | '员工数据'
type PreviewRow = { key: string } & Record<string, string>
const PREVIEW_SIZE = 10
const types: ExportType[] = ['订单数据', '客户数据', '员工数据']
const toast = useToastStore()
const type = ref<ExportType>('订单数据')
const startDate = ref(formatDate(startOfMonth(new Date())))
const endDate = ref(formatDate(new Date()))
const previewColumns = ref<string[]>([])
const previewRows = ref<PreviewRow[]>([])
const previewLoading = ref(false)
const previewError = ref('')
const shortDateTime = (value: unknown): string => {
const text = String(value || '')
return text.length > 16 ? text.slice(0, 16) : text || '-'
}
const timeRange = (item: Appointment): string => {
const start = String(item.startTime || '').slice(11, 16)
const end = String(item.endTime || '').slice(11, 16)
if (!start && !end) {
return '-'
}
return `${start || '-'}-${end || '-'}`
}
const scheduleSummary = (item: Artist): string => {
const source = item as Artist & { scheduleModeSummary?: string; scheduleMode?: string; scheduleTimeSummary?: string; ruleTimeSummary?: string }
const mode = source.scheduleModeSummary || source.scheduleMode || ''
const time = source.scheduleTimeSummary || source.ruleTimeSummary || ''
return [mode, time].filter(Boolean).join(' ') || '未设置'
}
const loadOrderPreview = async (): Promise<void> => {
const data = await managerPlanningApi.calendar({ startDate: startDate.value, endDate: endDate.value })
previewColumns.value = ['日期', '客户', '项目', '美甲师', '时间', '状态']
previewRows.value = (data.appointments || []).slice(0, PREVIEW_SIZE).map((item, index) => ({
key: `order-${item.orderItemId || index}`,
日期: item.date || String(item.startTime || '').slice(0, 10) || '-',
客户: item.customerName || '到店客户',
项目: item.productTitle || '预约作品',
美甲师: item.artistName || '未分配',
时间: timeRange(item),
状态: item.statusText || '-'
}))
}
const loadCustomerPreview = async (): Promise<void> => {
const data = await managerCustomersApi.list({ page: 1, size: PREVIEW_SIZE })
previewColumns.value = ['客户', '手机号', '最近时间']
previewRows.value = (data.list || []).slice(0, PREVIEW_SIZE).map((item: UserInfo & { name?: string; lastOrderTime?: string; lastConsumeTime?: string }, index) => ({
key: `customer-${item.id || index}`,
客户: item.nickname || item.name || item.account || '客户',
手机号: item.contactPhone || item.phone || '-',
最近时间: shortDateTime(item.lastOrderTime || item.lastConsumeTime)
}))
}
const loadEmployeePreview = async (): Promise<void> => {
const list = await managerEmployeesApi.list()
previewColumns.value = ['员工', '手机号', '排班', '状态']
previewRows.value = list.slice(0, PREVIEW_SIZE).map((item, index) => ({
key: `employee-${item.id || item.userId || index}`,
员工: item.nickname || item.name || '美甲师',
手机号: item.phone || '-',
排班: scheduleSummary(item),
状态: Number(item.status) === 0 ? '停用' : '启用'
}))
}
const loadPreview = async (): Promise<void> => {
previewLoading.value = true
previewError.value = ''
try {
if (type.value === '客户数据') {
await loadCustomerPreview()
} else if (type.value === '员工数据') {
await loadEmployeePreview()
} else {
await loadOrderPreview()
}
} catch (error) {
previewRows.value = []
previewError.value = error instanceof Error ? error.message : '预览数据加载失败'
} finally {
previewLoading.value = false
}
}
const exportExcel = (): void => {
toast.success('导出任务已创建')
}
onMounted(loadPreview)
</script>
<style scoped>
.export-view {
padding-bottom: 86px;
}
.preview-card {
padding: 14px;
}
.preview-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 10px;
}
.preview-head span {
color: var(--muted);
font-size: 12px;
}
.preview-scroll {
overflow-x: auto;
padding-bottom: 2px;
}
table {
width: max-content;
min-width: 100%;
border-collapse: collapse;
}
th,
td {
min-width: 88px;
padding: 10px 8px;
border-bottom: 1px solid var(--border);
text-align: left;
white-space: nowrap;
}
th {
color: #5c554e;
font-size: 12px;
}
td {
color: #3e3932;
font-size: 13px;
}
</style>
@@ -0,0 +1,42 @@
<template>
<MobileShell title="请假管理">
<section class="card form-card">
<div class="field"><label class="required">请假日期</label><input v-model="form.workDate" type="date" /></div>
<div class="field"><label>原因</label><input v-model.trim="form.reason" placeholder="请输入请假原因" /></div>
</section>
<button class="primary-btn section" type="button" :disabled="saving" @click="saveLeave">{{ saving ? '保存中...' : '保存请假' }}</button>
</MobileShell>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue'
import { useRoute } from 'vue-router'
import MobileShell from '@/components/MobileShell.vue'
import { managerEmployeesApi } from '@/api/managerEmployees'
import { formatDate } from '@/utils/date'
import { useToastStore } from '@/stores/toast'
const route = useRoute()
const toast = useToastStore()
const saving = ref(false)
const form = reactive({ workDate: formatDate(new Date()), reason: '' })
const saveLeave = async (): Promise<void> => {
if (!form.workDate) {
toast.error('请选择日期后保存')
return
}
saving.value = true
try {
await managerEmployeesApi.saveScheduleException({
artistId: String(route.params.id),
workDate: form.workDate,
status: 0,
reason: form.reason
})
toast.success('请假已保存')
} finally {
saving.value = false
}
}
</script>
+487
View File
@@ -0,0 +1,487 @@
<template>
<MobileShell plain hide-header>
<div class="auth-page">
<section class="brand-block">
<img class="brand-block__logo" :src="appIconUrl" alt="Jayu Salon" />
<h1>{{ APP_NAME }}</h1>
<p>美甲店预约排班管理</p>
</section>
<section class="card auth-card">
<div class="mode-tabs">
<button type="button" :class="{ active: loginMode === 'password' }" @click="switchMode('password')">密码登录</button>
<button type="button" :class="{ active: loginMode === 'phone' }" @click="switchMode('phone')">验证码登录</button>
</div>
<div v-if="loginMode === 'password'" class="field">
<label class="required">账号</label>
<input v-model.trim="form.account" placeholder="请输入账号" autocomplete="username" />
</div>
<div v-if="loginMode === 'password'" class="field">
<label class="required">密码</label>
<input v-model="form.password" type="password" placeholder="请输入密码" autocomplete="current-password" />
</div>
<div v-if="loginMode === 'phone'" class="field">
<label class="required">手机号</label>
<input v-model.trim="form.phone" inputmode="numeric" placeholder="请输入手机号" />
</div>
<div v-if="loginMode === 'phone'" class="field code-field">
<label class="required">验证码</label>
<input v-model.trim="form.code" inputmode="numeric" placeholder="请输入验证码" />
<button class="code-btn" type="button" :disabled="codeLoading || countdown > 0" @click="sendLoginCode">
{{ countdown > 0 ? `${countdown}s` : '获取' }}
</button>
</div>
<button class="check-row" type="button" @click="agreementAccepted = !agreementAccepted">
<span class="check-box" :class="{ checked: agreementAccepted }">{{ agreementAccepted ? '✓' : '' }}</span>
<span>我已阅读并同意</span>
<button class="inline-link" type="button" @click.stop="openAgreement('USER_TERMS')">《用户协议》</button>
<span>和</span>
<button class="inline-link" type="button" @click.stop="openAgreement('PRIVACY_POLICY')">《隐私政策》</button>
</button>
<button v-if="agreementError" class="agreement-error" type="button" @click="loadAgreements">
{{ agreementError }},点此重试
</button>
<button class="check-row" type="button" @click="rememberMe = !rememberMe">
<span class="check-box" :class="{ checked: rememberMe }">{{ rememberMe ? '✓' : '' }}</span>
<span>记住我,保持登录更久</span>
</button>
<button class="primary-btn login-btn" type="button" :disabled="loading || agreementLoading" @click="submit">
{{ agreementLoading ? '协议加载中...' : loading ? '登录中...' : '登录' }}
</button>
<div class="auth-links">
<button class="text-btn" type="button" @click="toast.info('请联系店铺管理员重置密码')">忘记密码</button>
<RouterLink class="text-btn" to="/register">注册账号</RouterLink>
</div>
</section>
</div>
<BaseModal v-model="shopSelectVisible" title="选择店铺">
<div class="shop-options">
<button
v-for="shop in shopOptions"
:key="String(shop.id)"
class="shop-option"
type="button"
:disabled="switchingShop"
@click="loginWithShop(shop.id)"
>
<span class="shop-option__icon">店</span>
<span>
<strong>{{ shop.shopName || shop.name || `店铺 ${shop.id}` }}</strong>
<small>ID {{ shop.id }}</small>
</span>
</button>
</div>
</BaseModal>
<BaseModal v-model="agreementModalVisible" :title="selectedAgreement?.title || '协议详情'">
<div class="agreement-body">
<div class="muted">版本:{{ selectedAgreement?.version || '-' }}</div>
<p>{{ selectedAgreement?.content || '暂无协议内容' }}</p>
<button class="primary-btn" type="button" @click="agreementModalVisible = false">我知道了</button>
</div>
</BaseModal>
</MobileShell>
</template>
<script setup lang="ts">
import { onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import BaseModal from '@/components/BaseModal.vue'
import MobileShell from '@/components/MobileShell.vue'
import { APP_NAME } from '@/config/api'
import { authApi, type PasswordLoginRequest, type PhoneLoginRequest } from '@/api/auth'
import type { IdType, LegalAgreement, LoginResponse, LoginShop } from '@/types/common'
import { useSessionStore } from '@/stores/session'
import { useToastStore } from '@/stores/toast'
import { readJson, writeJson } from '@/utils/storage'
type LoginMode = 'password' | 'phone'
const PHONE_REGEX = /^1[3-9]\d{9}$/
const LOGIN_PREFERENCE_KEY = 'jayu_salon_login_preference'
interface LoginPreference {
loginMode?: LoginMode
account?: string
phone?: string
rememberMe?: boolean
}
const router = useRouter()
const session = useSessionStore()
const toast = useToastStore()
const appIconUrl = `${import.meta.env.BASE_URL}assets/images/app-icon.png`
const preference = readJson<LoginPreference>(LOGIN_PREFERENCE_KEY, {})
const loginMode = ref<LoginMode>(preference.loginMode || 'password')
const form = reactive({
account: preference.account || '',
password: '',
phone: preference.phone || '',
code: ''
})
const rememberMe = ref(Boolean(preference.rememberMe))
const agreementAccepted = ref(false)
const agreementLoading = ref(false)
const agreementError = ref('')
const agreements = ref<LegalAgreement[]>([])
const selectedAgreement = ref<LegalAgreement | null>(null)
const agreementModalVisible = ref(false)
const loading = ref(false)
const codeLoading = ref(false)
const countdown = ref(0)
const countdownTimer = ref<number | null>(null)
const shopSelectVisible = ref(false)
const switchingShop = ref(false)
const shopOptions = ref<LoginShop[]>([])
const switchMode = (mode: LoginMode): void => {
loginMode.value = mode
}
const savePreference = (): void => {
writeJson<LoginPreference>(LOGIN_PREFERENCE_KEY, {
loginMode: loginMode.value,
account: form.account,
phone: form.phone,
rememberMe: rememberMe.value
})
}
const startCountdown = (): void => {
countdown.value = 60
countdownTimer.value = window.setInterval(() => {
countdown.value -= 1
if (countdown.value <= 0 && countdownTimer.value !== null) {
window.clearInterval(countdownTimer.value)
countdownTimer.value = null
}
}, 1000)
}
const loadAgreements = async (): Promise<LegalAgreement[]> => {
agreementLoading.value = true
agreementError.value = ''
try {
agreements.value = await authApi.getCurrentAgreements()
return agreements.value
} catch (error) {
agreementError.value = error instanceof Error ? error.message : '协议内容加载失败'
return []
} finally {
agreementLoading.value = false
}
}
const openAgreement = async (type: LegalAgreement['agreementType']): Promise<void> => {
const latestAgreements = agreements.value.length > 0 ? agreements.value : await loadAgreements()
selectedAgreement.value = latestAgreements.find(item => item.agreementType === type) || null
if (!selectedAgreement.value) {
toast.error(agreementError.value || '协议内容暂不可用')
return
}
agreementModalVisible.value = true
}
const buildAgreementVersions = (): Record<string, string> => {
return agreements.value.reduce<Record<string, string>>((result, item) => {
result[item.agreementType] = item.version
return result
}, {})
}
const validateAgreement = (): boolean => {
if (!agreementAccepted.value) {
toast.error('请先阅读并同意用户协议和隐私政策')
return false
}
if (agreementLoading.value || agreements.value.length === 0) {
toast.error(agreementError.value || '协议版本加载中,请稍后再试')
return false
}
return true
}
const sendLoginCode = async (): Promise<void> => {
if (!PHONE_REGEX.test(form.phone)) {
toast.error('请输入正确手机号')
return
}
codeLoading.value = true
try {
await authApi.sendLoginCode(form.phone)
toast.success('验证码已发送')
startCountdown()
} finally {
codeLoading.value = false
}
}
const buildPasswordRequest = (shopId?: IdType): PasswordLoginRequest => ({
account: form.account,
password: form.password,
shopId,
agreementAccepted: agreementAccepted.value,
agreementVersions: buildAgreementVersions(),
clientType: 'MANAGER_WEB'
})
const buildPhoneRequest = (shopId?: IdType): PhoneLoginRequest => ({
phone: form.phone,
verificationCode: form.code,
shopId,
agreementAccepted: agreementAccepted.value,
agreementVersions: buildAgreementVersions(),
clientType: 'MANAGER_WEB'
})
const resolveLoginResponse = async (shopId?: IdType): Promise<LoginResponse> => {
if (loginMode.value === 'password') {
return authApi.passwordLogin(buildPasswordRequest(shopId))
}
return authApi.phoneLogin(buildPhoneRequest(shopId))
}
const openShopSelector = async (): Promise<boolean> => {
const selection = loginMode.value === 'password'
? await authApi.getPasswordLoginShops(form.account)
: await authApi.getPhoneLoginShops(form.phone)
const shops = Array.isArray(selection.shops) ? selection.shops : []
if (shops.length <= 1) {
return false
}
shopOptions.value = shops
shopSelectVisible.value = true
return true
}
const loginWithShop = async (shopId: IdType): Promise<void> => {
switchingShop.value = true
try {
const response = await resolveLoginResponse(shopId)
session.setSession(response, rememberMe.value)
savePreference()
toast.success('登录成功')
await router.replace('/planning')
} finally {
switchingShop.value = false
}
}
const submit = async (): Promise<void> => {
if (!validateAgreement()) {
return
}
if (loginMode.value === 'password' && (!form.account || !form.password)) {
toast.error('请填写账号和密码')
return
}
if (loginMode.value === 'phone' && (!PHONE_REGEX.test(form.phone) || !form.code)) {
toast.error('请输入正确手机号和验证码')
return
}
loading.value = true
try {
const selectorOpened = await openShopSelector()
if (selectorOpened) {
return
}
const response = await resolveLoginResponse()
session.setSession(response, rememberMe.value)
savePreference()
toast.success('登录成功')
await router.replace('/planning')
} finally {
loading.value = false
}
}
onMounted(() => {
void loadAgreements()
})
onBeforeUnmount(() => {
if (countdownTimer.value !== null) {
window.clearInterval(countdownTimer.value)
}
})
</script>
<style scoped>
.auth-page {
min-height: 100vh;
padding: 44px 16px 32px;
}
.brand-block {
display: grid;
justify-items: center;
margin-bottom: 22px;
text-align: center;
}
.brand-block__logo {
width: 74px;
height: 74px;
border-radius: 20px;
object-fit: cover;
box-shadow: var(--shadow);
}
.brand-block h1 {
margin: 14px 0 4px;
font-size: 24px;
letter-spacing: 0;
}
.brand-block p {
margin: 0;
color: var(--muted);
}
.auth-card {
padding: 14px;
}
.mode-tabs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-bottom: 10px;
padding: 4px;
border-radius: 14px;
background: var(--subtle);
}
.mode-tabs button {
min-height: 38px;
border-radius: 12px;
color: var(--muted);
font-weight: 800;
}
.mode-tabs .active {
background: var(--card-bg);
color: var(--accent);
box-shadow: 0 6px 16px rgba(58, 48, 34, 0.06);
}
.code-field {
gap: 8px;
}
.code-btn {
flex: 0 0 68px;
height: 34px;
border-radius: 999px;
background: var(--accent-soft);
color: var(--accent);
font-size: 12px;
font-weight: 800;
}
.check-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 4px;
width: 100%;
margin-top: 12px;
color: #5f5951;
text-align: left;
}
.check-box {
display: inline-flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
border: 1px solid #cfc7bd;
border-radius: 6px;
color: #fff;
font-size: 12px;
}
.check-box.checked {
border-color: var(--accent);
background: var(--accent);
}
.inline-link,
.agreement-error {
padding: 0;
color: var(--accent);
font-weight: 800;
}
.agreement-error {
margin-top: 8px;
text-align: left;
}
.login-btn {
margin-top: 16px;
}
.auth-links {
display: flex;
justify-content: space-between;
margin-top: 10px;
}
.shop-options {
display: grid;
gap: 10px;
padding: 14px;
}
.shop-option {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
padding: 12px;
border-radius: 14px;
background: var(--subtle);
text-align: left;
}
.shop-option__icon {
display: grid;
place-items: center;
width: 42px;
height: 42px;
border-radius: 14px;
background: var(--accent-soft);
color: var(--accent);
font-weight: 900;
}
.shop-option strong,
.shop-option small {
display: block;
}
.shop-option small {
margin-top: 2px;
color: var(--muted);
}
.agreement-body {
display: grid;
gap: 12px;
padding: 14px;
}
.agreement-body p {
max-height: 52vh;
overflow: auto;
margin: 0;
white-space: pre-wrap;
}
</style>
+54
View File
@@ -0,0 +1,54 @@
<template>
<div class="password-view">
<section class="card form-card">
<label class="field">
<span class="field-label">原密码</span>
<input v-model.trim="form.oldPassword" type="password" autocomplete="current-password" />
</label>
<label class="field">
<span class="field-label">新密码</span>
<input v-model.trim="form.newPassword" type="password" autocomplete="new-password" />
</label>
<label class="field">
<span class="field-label">确认密码</span>
<input v-model.trim="form.confirmPassword" type="password" autocomplete="new-password" />
</label>
</section>
<div class="fixed-bottom">
<div class="fixed-bottom__inner">
<button class="primary-btn" type="button" @click="save">保存密码</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { reactive } from 'vue'
import { useToastStore } from '@/stores/toast'
const toast = useToastStore()
const form = reactive({
oldPassword: '',
newPassword: '',
confirmPassword: ''
})
const save = (): void => {
if (!form.newPassword || !form.confirmPassword) {
toast.error('请填写新密码')
return
}
if (form.newPassword !== form.confirmPassword) {
toast.error('两次密码不一致')
return
}
toast.success('已提交')
}
</script>
<style scoped>
.password-view {
padding-bottom: 86px;
}
</style>
+910
View File
@@ -0,0 +1,910 @@
<template>
<MobileShell>
<section class="card control-card">
<div class="date-row">
<button class="icon-button" type="button" @click="shiftRange(-1)"><ChevronLeft :size="20" /></button>
<div class="date-row__center">
<strong>{{ dateTitle }}</strong>
<span>{{ businessStartTime }}-{{ businessEndTime }}</span>
</div>
<div class="date-row__tools">
<button class="today-btn" type="button" @click="goToday">今</button>
<button class="icon-button" type="button" @click="shiftRange(1)"><ChevronRight :size="20" /></button>
</div>
</div>
<div class="segmented">
<button v-for="mode in viewModes" :key="mode.value" type="button" :class="{ active: viewMode === mode.value }" @click="switchView(mode.value)">
{{ mode.label }}
</button>
</div>
<div class="artist-filter">
<button class="chip" :class="{ 'chip--active': !selectedArtistId }" type="button" @click="selectArtist('')">全部员工</button>
<button
v-for="artist in artists"
:key="String(artist.id)"
class="chip artist-chip"
:class="{ 'chip--active': String(selectedArtistId) === String(artist.id) }"
type="button"
@click="selectArtist(artist.id)"
>
<span class="dot" :style="{ backgroundColor: artist.color || '#b8b0a6' }"></span>
{{ artist.name || artist.nickname }}
<small>{{ artist.rangeCount || 0 }}</small>
</button>
</div>
</section>
<section v-if="calendarError" class="calendar-error-card">
<div>
<strong>规划数据加载失败</strong>
<p>{{ calendarError }}</p>
</div>
<button class="secondary-btn" type="button" @click="loadCalendar">重试</button>
</section>
<LoadingState v-else-if="loading" text="正在加载规划" />
<template v-else>
<section v-if="viewMode === 'day'" class="section">
<div class="day-summary">
<div class="card summary-item"><strong>{{ dayTotal }}</strong><span>今日预约</span></div>
<div class="card summary-item"><strong>{{ freeArtistCount }}</strong><span>可插单员工</span></div>
<div class="card summary-item"><strong>{{ pendingCount }}</strong><span>待确认</span></div>
</div>
<div class="card day-board">
<div class="time-axis">
<span v-for="hour in hours" :key="hour.value" :style="{ top: `${hour.top}px` }">{{ hour.label }}</span>
</div>
<div class="lane-scroll">
<div class="lanes" :style="{ width: `${laneWidth}px`, minHeight: `${timelineHeight}px` }">
<div v-for="lane in dayLanes" :key="String(lane.id)" class="artist-lane" :style="{ width: `${laneItemWidth}px` }">
<div class="lane-head">
<span class="dot" :style="{ backgroundColor: lane.color || '#b8b0a6' }"></span>
{{ lane.name || lane.nickname }}
</div>
<button
v-for="block in lane.blocks"
:key="String(block.orderItemId)"
class="appointment-block"
:class="{ pending: block.status === 0 }"
type="button"
:style="{ top: `${block.top}px`, height: `${block.height}px`, borderLeftColor: lane.color || '#b8b0a6' }"
@click="openAppointment(block.orderItemId)"
>
<strong>{{ block.customerName || '客户' }}</strong>
<span>{{ block.timeText }} · {{ block.productTitle || block.manualProductTitle || '预约作品' }}</span>
<small>{{ block.statusText || '待处理' }}</small>
</button>
<div v-if="lane.blocks.length === 0" class="lane-empty">全天可约</div>
</div>
</div>
</div>
</div>
</section>
<section v-if="viewMode === 'week'" class="section">
<div class="week-strip">
<button
v-for="day in weekDays"
:key="day.date"
class="card week-day-card"
:class="{ active: day.date === currentDateText }"
type="button"
@click="selectDate(day.date)"
>
<span>{{ day.weekName }}</span>
<strong>{{ day.day }}</strong>
<small>{{ day.totalCount }}单</small>
</button>
</div>
<div class="card week-grid">
<div class="week-grid__head">
<strong>本周排班密度</strong>
<span>{{ weekRange }}</span>
</div>
<div v-for="day in weekDays" :key="`${day.date}-line`" class="week-line">
<span>{{ day.weekName }} {{ day.day }}</span>
<div class="week-line__bars" :class="{ empty: day.totalCount === 0 }">
<div
v-for="count in day.artistCounts"
:key="String(count.artistId)"
class="week-count-bar"
:style="{ width: `${count.barWidth}%`, backgroundColor: count.color }"
>
{{ count.shortName }}{{ count.count }}
</div>
</div>
</div>
</div>
</section>
<section v-if="viewMode === 'month'" class="section">
<div class="month-toolbar">
<span>月历显示</span>
<div class="month-mode-switch">
<button v-for="mode in monthDisplayModes" :key="mode.value" :class="{ active: monthDisplayMode === mode.value }" type="button" @click="monthDisplayMode = mode.value">
{{ mode.label }}
</button>
</div>
<button v-if="monthDisplayMode === 'rows'" class="row-name-switch" :class="{ active: monthRowLabelVisible }" type="button" @click="monthRowLabelVisible = !monthRowLabelVisible">
姓名
</button>
</div>
<div class="card month-card">
<div class="month-week-head">
<span v-for="label in weekLabels" :key="label">{{ label }}</span>
</div>
<div class="month-grid">
<button
v-for="day in monthDays"
:key="day.date"
class="month-cell"
:class="{ selected: day.date === currentDateText, 'out-month': !day.isCurrentMonth }"
type="button"
@click="selectDate(day.date)"
>
<span class="month-day">{{ day.day }}</span>
<span v-if="!day.isPast && day.dayStatus === 'full'" class="day-mark full">满</span>
<span v-else-if="!day.isPast && day.dayStatus === 'rest'" class="day-mark rest">休</span>
<div v-if="monthDisplayMode === 'count'" class="month-bars">
<span v-for="count in day.artistCounts.filter(item => item.count > 0)" :key="String(count.artistId)" :style="{ backgroundColor: count.color }">
{{ count.shortName }}{{ count.count }}
</span>
<small v-if="day.totalCount === 0">空</small>
</div>
<div v-else-if="monthDisplayMode === 'blocks'" class="month-blocks">
<span v-for="block in day.expandedBlocks" :key="block.key" :style="{ backgroundColor: block.color }"></span>
<small v-if="day.totalCount === 0">空</small>
</div>
<div v-else class="month-blocks month-blocks--rows">
<span v-for="block in day.rowBlocks" :key="block.key" :style="{ backgroundColor: block.color }">{{ monthRowLabelVisible ? block.artistName : '' }}</span>
<small v-if="day.totalCount === 0">空</small>
</div>
</button>
</div>
</div>
</section>
</template>
<button v-if="canCreate && !calendarError" class="fab" type="button" @click="createAppointment">+</button>
</MobileShell>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { ChevronLeft, ChevronRight } from 'lucide-vue-next'
import MobileShell from '@/components/MobileShell.vue'
import LoadingState from '@/components/LoadingState.vue'
import { managerPlanningApi } from '@/api/managerPlanning'
import type { Appointment, Artist, DaySummary } from '@/types/manager'
import type { IdType } from '@/types/common'
import { useSessionStore } from '@/stores/session'
import { useToastStore } from '@/stores/toast'
import { canCreateAppointment } from '@/utils/permissions'
import {
addDays,
addMonths,
endOfMonth,
endOfWeek,
formatCnDate,
formatDate,
formatMonth,
monthGrid,
minutesOfDay,
startOfMonth,
startOfWeek,
timeFromMinutes
} from '@/utils/date'
import { resolveAppointmentDate, resolveAppointmentStartMinute, resolveAppointmentTimeText, summaryMap } from '@/utils/planning'
type ViewMode = 'day' | 'week' | 'month'
type MonthDisplayMode = 'count' | 'blocks' | 'rows'
interface NormalizedCount {
artistId: IdType
artistName?: string
shortName?: string
color: string
count: number
status?: string
width?: number
barWidth?: number
}
interface MonthBlock {
key: string
artistId: IdType
color: string
shortName?: string
artistName?: string
}
interface MonthDay {
date: string
day: number
isCurrentMonth: boolean
isPast: boolean
totalCount: number
dayStatus: string
artistCounts: NormalizedCount[]
expandedBlocks: MonthBlock[]
rowBlocks: MonthBlock[]
}
interface WeekDay {
date: string
weekName: string
day: number
totalCount: number
artistCounts: NormalizedCount[]
}
interface DayLane extends Artist {
blocks: Array<Appointment & { top: number; height: number; timeText: string }>
}
const router = useRouter()
const session = useSessionStore()
const toast = useToastStore()
const viewModes: Array<{ value: ViewMode; label: string }> = [
{ value: 'day', label: '日' },
{ value: 'week', label: '周' },
{ value: 'month', label: '月' }
]
const monthDisplayModes: Array<{ value: MonthDisplayMode; label: string }> = [
{ value: 'count', label: '单量' },
{ value: 'blocks', label: '点阵' },
{ value: 'rows', label: '横条' }
]
const weekLabels = ['一', '二', '三', '四', '五', '六', '日']
const viewMode = ref<ViewMode>('month')
const monthDisplayMode = ref<MonthDisplayMode>('count')
const monthRowLabelVisible = ref(false)
const currentDateText = ref(formatDate(new Date()))
const selectedArtistId = ref<IdType | ''>('')
const businessStartTime = ref('10:00')
const businessEndTime = ref('22:00')
const artists = ref<Artist[]>([])
const appointments = ref<Appointment[]>([])
const daySummaries = ref<DaySummary[]>([])
const loading = ref(false)
const calendarError = ref('')
const canCreate = computed(() => canCreateAppointment(session.userInfo))
const dateTitle = computed(() => {
const range = resolveRange()
if (viewMode.value === 'month') {
return formatMonth(currentDateText.value)
}
if (viewMode.value === 'week') {
return `${formatCnDate(range.start)} - ${formatCnDate(range.end)}`
}
return formatCnDate(currentDateText.value)
})
const weekRange = computed(() => {
const range = resolveRange()
return `${formatCnDate(range.start)} - ${formatCnDate(range.end)}`
})
const resolveRange = (): { start: string; end: string } => {
if (viewMode.value === 'week') {
return { start: formatDate(startOfWeek(currentDateText.value)), end: formatDate(endOfWeek(currentDateText.value)) }
}
if (viewMode.value === 'month') {
return { start: formatDate(startOfMonth(currentDateText.value)), end: formatDate(endOfMonth(currentDateText.value)) }
}
return { start: currentDateText.value, end: currentDateText.value }
}
const normalizeArtistCounts = (counts: NonNullable<DaySummary['artistCounts']>): NormalizedCount[] => {
const artistMap = artists.value.reduce<Record<string, Artist>>((result, artist) => {
result[String(artist.id)] = artist
return result
}, {})
return counts.map(count => {
const artist = artistMap[String(count.artistId)]
return {
artistId: count.artistId,
artistName: count.artistName || artist?.name,
shortName: count.shortName || artist?.shortName || String(count.artistName || artist?.name || '?').slice(0, 1),
color: count.color || artist?.color || '#b8b0a6',
count: Number(count.count || 0),
status: count.status
}
})
}
const buildExpandedBlocks = (counts: NormalizedCount[]): MonthBlock[] => {
return counts.flatMap(count => Array.from({ length: count.count }, (_item, index) => ({
key: `${count.artistId}-${index}`,
artistId: count.artistId,
color: count.color,
shortName: count.shortName,
artistName: count.artistName
})))
}
const buildMonthDays = (): MonthDay[] => {
const map = summaryMap(daySummaries.value)
const todayText = formatDate(new Date())
const artistTemplate = artists.value.map(artist => ({
artistId: artist.id,
artistName: artist.name,
shortName: artist.shortName,
color: artist.color,
count: 0,
status: 'free'
}))
return monthGrid(currentDateText.value).map(day => {
const summary = map[day.date]
const artistCounts = normalizeArtistCounts(summary?.artistCounts || artistTemplate)
return {
...day,
isPast: day.date < todayText,
totalCount: summary?.totalCount || 0,
dayStatus: summary?.dayStatus || 'free',
artistCounts,
expandedBlocks: buildExpandedBlocks(artistCounts),
rowBlocks: buildExpandedBlocks(artistCounts)
}
})
}
const buildWeekDays = (): WeekDay[] => {
const start = startOfWeek(currentDateText.value)
const map = summaryMap(daySummaries.value)
return weekLabels.map((label, index) => {
const target = addDays(start, index)
const date = formatDate(target)
const summary = map[date]
const counts = normalizeArtistCounts(summary?.artistCounts || [])
.filter(count => count.count > 0)
.map(count => ({
...count,
width: Math.max(12, Math.min(100, count.count * 22)),
barWidth: Math.max(14, Math.min(100, count.count * 18))
}))
return { date, weekName: `周${label}`, day: target.getDate(), totalCount: summary?.totalCount || 0, artistCounts: counts }
})
}
const buildDayLanes = (): DayLane[] => {
const startMinute = minutesOfDay(businessStartTime.value)
const filteredArtists = selectedArtistId.value
? artists.value.filter(item => String(item.id) === String(selectedArtistId.value))
: artists.value
const dayAppointments = appointments.value.filter(item => resolveAppointmentDate(item) === currentDateText.value)
return filteredArtists.map(artist => {
const blocks = dayAppointments
.filter(item => String(item.artistId) === String(artist.id))
.map(item => {
const itemStart = resolveAppointmentStartMinute(item)
return {
...item,
top: Math.max(0, itemStart - startMinute) + 54,
height: Math.max(64, item.durationMinutes || 60),
timeText: resolveAppointmentTimeText(item)
}
})
return { ...artist, blocks }
})
}
const monthDays = computed(buildMonthDays)
const weekDays = computed(buildWeekDays)
const dayLanes = computed(buildDayLanes)
const hours = computed(() => {
const startMinute = minutesOfDay(businessStartTime.value)
const endMinute = minutesOfDay(businessEndTime.value)
const result: Array<{ value: number; label: string; top: number }> = []
for (let cursor = startMinute; cursor <= endMinute; cursor += 60) {
result.push({ value: cursor, label: timeFromMinutes(cursor), top: cursor - startMinute + 54 })
}
return result
})
const timelineHeight = computed(() => Math.max(560, minutesOfDay(businessEndTime.value) - minutesOfDay(businessStartTime.value)) + 54)
const laneItemWidth = 248
const laneWidth = computed(() => Math.max(720, dayLanes.value.length * laneItemWidth))
const dayAppointments = computed(() => appointments.value.filter(item => resolveAppointmentDate(item) === currentDateText.value))
const dayTotal = computed(() => dayAppointments.value.length)
const freeArtistCount = computed(() => dayLanes.value.filter(item => item.blocks.length === 0).length)
const pendingCount = computed(() => dayAppointments.value.filter(item => item.status === 0).length)
const loadCalendar = async (): Promise<void> => {
const range = resolveRange()
loading.value = true
try {
const data = await managerPlanningApi.calendar({
startDate: range.start,
endDate: range.end,
artistId: selectedArtistId.value || undefined
})
businessStartTime.value = String(data.businessStartTime || '10:00').slice(0, 5)
businessEndTime.value = String(data.businessEndTime || '22:00').slice(0, 5)
artists.value = data.artists || []
appointments.value = data.appointments || []
daySummaries.value = data.daySummaries || []
calendarError.value = ''
} catch (error) {
artists.value = []
appointments.value = []
daySummaries.value = []
calendarError.value = error instanceof Error ? error.message : '规划数据加载失败'
toast.error('规划数据加载失败')
} finally {
loading.value = false
}
}
const switchView = async (mode: ViewMode): Promise<void> => {
viewMode.value = mode
await loadCalendar()
}
const selectArtist = (id: IdType | ''): void => {
selectedArtistId.value = id
}
const selectDate = (date: string): void => {
currentDateText.value = date
if (viewMode.value === 'month') {
viewMode.value = 'day'
void loadCalendar()
}
}
const shiftRange = async (direction: number): Promise<void> => {
if (viewMode.value === 'month') {
currentDateText.value = formatDate(addMonths(currentDateText.value, direction))
} else if (viewMode.value === 'week') {
currentDateText.value = formatDate(addDays(currentDateText.value, direction * 7))
} else {
currentDateText.value = formatDate(addDays(currentDateText.value, direction))
}
await loadCalendar()
}
const goToday = async (): Promise<void> => {
currentDateText.value = formatDate(new Date())
await loadCalendar()
}
const createAppointment = (): void => {
if (!canCreate.value) {
toast.error('美甲师账号只能查看预约')
return
}
void router.push({ path: '/appointments/new', query: { date: currentDateText.value, artistId: String(selectedArtistId.value || '') } })
}
const openAppointment = (id: IdType): void => {
void router.push(`/appointments/${id}`)
}
onMounted(() => {
void loadCalendar()
})
</script>
<style scoped>
.control-card {
padding: 12px;
}
.date-row,
.date-row__tools {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.date-row__center {
display: grid;
justify-items: center;
}
.date-row__center strong {
font-size: 17px;
}
.date-row__center span {
color: var(--muted);
font-size: 12px;
}
.today-btn {
width: 36px;
height: 36px;
border-radius: 50%;
background: var(--accent-soft);
color: var(--accent);
font-weight: 900;
}
.segmented {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
margin-top: 12px;
padding: 4px;
border-radius: 14px;
background: var(--subtle);
}
.segmented button,
.month-mode-switch button,
.row-name-switch {
min-height: 34px;
border-radius: 12px;
color: var(--muted);
font-weight: 800;
}
.segmented .active,
.month-mode-switch .active,
.row-name-switch.active {
background: var(--card-bg);
color: var(--accent);
box-shadow: 0 6px 16px rgba(58, 48, 34, 0.06);
}
.artist-filter,
.week-strip {
display: flex;
gap: 8px;
margin-top: 12px;
overflow-x: auto;
padding-bottom: 2px;
}
.artist-chip {
gap: 6px;
white-space: nowrap;
}
.dot {
display: inline-block;
flex: 0 0 8px;
width: 8px;
height: 8px;
border-radius: 50%;
}
.calendar-error-card {
display: grid;
grid-template-columns: 1fr 92px;
gap: 12px;
margin-top: 14px;
padding: 14px;
border-radius: 12px;
background: #fff4ee;
color: #8c4a30;
}
.calendar-error-card p {
margin: 4px 0 0;
}
.day-summary {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
.summary-item {
display: grid;
justify-items: center;
padding: 14px 6px;
}
.summary-item strong {
color: var(--accent);
font-size: 22px;
}
.summary-item span {
color: var(--muted);
font-size: 12px;
}
.day-board {
position: relative;
min-height: 620px;
margin-top: 12px;
overflow: hidden;
}
.time-axis {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 54px;
border-right: 1px solid var(--border);
background: rgba(255, 253, 248, 0.92);
}
.time-axis span {
position: absolute;
right: 8px;
color: var(--muted);
font-size: 11px;
}
.lane-scroll {
margin-left: 54px;
overflow-x: auto;
}
.lanes {
display: flex;
position: relative;
}
.artist-lane {
position: relative;
flex: 0 0 auto;
min-height: 620px;
border-right: 1px solid var(--border);
}
.lane-head {
position: sticky;
top: 0;
z-index: 1;
display: flex;
align-items: center;
gap: 6px;
height: 54px;
padding: 0 10px;
background: var(--card-bg);
font-weight: 800;
}
.appointment-block {
position: absolute;
right: 8px;
left: 8px;
display: grid;
align-content: start;
gap: 3px;
overflow: hidden;
padding: 8px;
border-left: 4px solid var(--accent);
border-radius: 10px;
background: #f7f2ea;
color: var(--ink);
text-align: left;
}
.appointment-block.pending {
background: #fff0de;
}
.appointment-block strong,
.appointment-block span,
.appointment-block small {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.appointment-block span,
.appointment-block small {
color: var(--muted);
font-size: 11px;
}
.lane-empty {
position: absolute;
top: 88px;
right: 12px;
left: 12px;
color: #b0a79d;
text-align: center;
}
.week-day-card {
display: grid;
justify-items: center;
flex: 0 0 86px;
padding: 12px 8px;
}
.week-day-card.active {
color: var(--accent);
outline: 2px solid var(--accent-soft);
}
.week-day-card strong {
font-size: 22px;
}
.week-grid {
margin-top: 12px;
padding: 14px;
}
.week-grid__head,
.week-line {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.week-grid__head span,
.week-line > span {
color: var(--muted);
font-size: 12px;
}
.week-line {
margin-top: 12px;
}
.week-line__bars {
display: flex;
align-items: center;
flex: 1;
min-height: 28px;
overflow: hidden;
border-radius: 999px;
background: var(--subtle);
}
.week-line__bars.empty::before {
content: "空";
margin-left: 12px;
color: #b0a79d;
font-size: 12px;
}
.week-count-bar {
display: grid;
place-items: center;
min-width: 28px;
height: 28px;
color: #fff;
font-size: 11px;
font-weight: 800;
}
.month-toolbar {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
}
.month-toolbar > span {
flex: 1;
font-weight: 800;
}
.month-mode-switch {
display: flex;
gap: 4px;
padding: 3px;
border-radius: 12px;
background: var(--subtle);
}
.month-mode-switch button {
min-height: 30px;
padding: 0 8px;
font-size: 12px;
}
.row-name-switch {
min-height: 30px;
padding: 0 10px;
background: var(--subtle);
font-size: 12px;
}
.month-card {
padding: 10px;
}
.month-week-head,
.month-grid {
display: grid;
grid-template-columns: repeat(7, minmax(0, 1fr));
}
.month-week-head span {
padding-bottom: 8px;
color: var(--muted);
font-size: 12px;
text-align: center;
}
.month-cell {
position: relative;
min-height: 78px;
padding: 6px 4px;
border: 1px solid var(--border);
background: transparent;
text-align: left;
}
.month-cell.selected {
background: var(--accent-soft);
}
.month-cell.out-month {
color: #b7afa5;
background: #faf7f0;
}
.month-day {
font-weight: 900;
}
.day-mark {
position: absolute;
top: 4px;
right: 4px;
border-radius: 999px;
padding: 1px 4px;
color: #fff;
font-size: 10px;
}
.day-mark.full {
background: var(--danger);
}
.day-mark.rest {
background: #9b948b;
}
.month-bars,
.month-blocks {
display: flex;
flex-wrap: wrap;
gap: 3px;
margin-top: 4px;
}
.month-bars span {
max-width: 100%;
overflow: hidden;
border-radius: 6px;
padding: 1px 4px;
color: #fff;
font-size: 10px;
text-overflow: ellipsis;
white-space: nowrap;
}
.month-bars small,
.month-blocks small {
color: #b0a79d;
}
.month-blocks span {
width: 8px;
height: 8px;
border-radius: 50%;
}
.month-blocks--rows {
display: grid;
gap: 2px;
}
.month-blocks--rows span {
width: 100%;
height: 8px;
overflow: hidden;
border-radius: 999px;
color: #fff;
font-size: 8px;
line-height: 8px;
}
</style>
+338
View File
@@ -0,0 +1,338 @@
<template>
<MobileShell>
<section class="card profile-card">
<div class="profile-main">
<div class="shop-logo">指</div>
<div class="profile-copy">
<strong>{{ shopName }}</strong>
<span>{{ phoneText }}</span>
</div>
</div>
<span class="role-badge">{{ roleText }}</span>
</section>
<section class="card menu-list section">
<button v-for="item in menus" :key="item.title" class="menu-row" type="button" @click="go(item)">
<span>{{ item.title }}</span>
<ChevronRight :size="18" aria-hidden="true" />
</button>
</section>
<BaseModal v-model="editModalVisible" title="个人信息" :close-disabled="profileSaving || avatarUploading">
<div class="profile-avatar-row">
<img v-if="profileForm.avatar" class="profile-avatar profile-avatar--image" :src="profileForm.avatar" alt="头像" />
<div v-else class="profile-avatar">头像</div>
<label class="secondary-btn avatar-btn">
{{ avatarUploading ? '上传中...' : '上传头像' }}
<input class="hidden-file" type="file" accept="image/*" :disabled="avatarUploading || profileSaving" @change="uploadAvatar" />
</label>
<button v-if="profileForm.avatar" class="text-btn" type="button" @click="profileForm.avatar = ''">移除</button>
</div>
<div class="profile-form">
<label class="field">
<span class="field-label required">昵称</span>
<input v-model.trim="profileForm.nickname" placeholder="请输入昵称" />
</label>
<div class="field readonly-field">
<span class="field-label">登录账号</span>
<strong>{{ userInfo?.account || '未设置' }}</strong>
</div>
<div class="field readonly-field">
<span class="field-label">身份</span>
<strong>{{ roleText }}</strong>
</div>
<div class="field readonly-field">
<span class="field-label">登录手机号</span>
<strong>{{ userInfo?.phone || '未绑定' }}</strong>
</div>
<label class="field">
<span class="field-label">联系电话</span>
<input v-model.trim="profileForm.contactPhone" inputmode="tel" placeholder="请输入联系电话" />
</label>
<label class="field">
<span class="field-label">微信号</span>
<input v-model.trim="profileForm.wechatId" placeholder="请输入微信号" />
</label>
<label class="field field--stack">
<span class="field-label">签名</span>
<textarea v-model.trim="profileForm.signature" placeholder="请输入个人签名"></textarea>
</label>
</div>
<template #footer>
<button class="primary-btn" type="button" :disabled="profileSaving || avatarUploading" @click="saveProfile">
{{ profileSaving ? '保存中...' : '保存个人信息' }}
</button>
</template>
</BaseModal>
</MobileShell>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import { ChevronRight } from 'lucide-vue-next'
import BaseModal from '@/components/BaseModal.vue'
import MobileShell from '@/components/MobileShell.vue'
import { fileApi } from '@/api/file'
import { userApi } from '@/api/user'
import { useSessionStore } from '@/stores/session'
import { useToastStore } from '@/stores/toast'
import type { UserInfo } from '@/types/common'
interface ProfileMenu {
title: string
url?: string
action?: 'editProfile'
}
const router = useRouter()
const session = useSessionStore()
const toast = useToastStore()
const editModalVisible = ref(false)
const profileSaving = ref(false)
const avatarUploading = ref(false)
const userInfo = ref<UserInfo | null>(session.userInfo)
const profileForm = reactive({
nickname: '',
avatar: '',
contactPhone: '',
wechatId: '',
signature: ''
})
const menus: ProfileMenu[] = [
{ title: '个人信息', action: 'editProfile' },
{ title: '店铺设置', url: '/shop-settings' },
{ title: '数据导出', url: '/export' },
{ title: '修改密码', url: '/password' },
{ title: '关于系统', url: '/about' }
]
const roleText = computed(() => {
const role = Number(userInfo.value?.type)
if (role === 2) return '店长'
if (role === 3) return '美甲师'
if (role === 4) return '管理员'
return '管理端'
})
const shopName = computed(() => userInfo.value?.shopName || '甲屿云')
const phoneText = computed(() => userInfo.value?.contactPhone || userInfo.value?.phone || userInfo.value?.account || '店长端')
const syncProfileToSession = (profile: UserInfo): void => {
const currentUserInfo: Partial<UserInfo> = session.userInfo || {}
const nextUserInfo: UserInfo = {
...currentUserInfo,
id: profile.id || currentUserInfo.id || '',
account: profile.account || currentUserInfo.account,
nickname: profile.nickname || '',
avatar: profile.avatar || '',
phone: profile.phone || currentUserInfo.phone || '',
contactPhone: profile.contactPhone || '',
wechatId: profile.wechatId || '',
signature: profile.signature || '',
type: profile.type || currentUserInfo.type,
shopId: profile.shopId || currentUserInfo.shopId,
shopName: profile.shopName || currentUserInfo.shopName
}
session.patchUserInfo(nextUserInfo)
userInfo.value = nextUserInfo
}
const loadProfile = async (): Promise<void> => {
try {
const profile = await userApi.info()
syncProfileToSession(profile)
} catch (error) {
toast.error(error instanceof Error ? error.message : '个人信息加载失败')
}
}
const openEditProfile = (): void => {
const profile: Partial<UserInfo> = userInfo.value || {}
profileForm.nickname = profile.nickname || ''
profileForm.avatar = profile.avatar || ''
profileForm.contactPhone = profile.contactPhone || ''
profileForm.wechatId = profile.wechatId || ''
profileForm.signature = profile.signature || ''
editModalVisible.value = true
}
const go = async (item: ProfileMenu): Promise<void> => {
if (item.action === 'editProfile') {
openEditProfile()
return
}
if (item.url) {
await router.push(item.url)
}
}
const uploadAvatar = async (event: Event): Promise<void> => {
const target = event.target as HTMLInputElement
const file = target.files?.[0]
target.value = ''
if (!file) {
return
}
avatarUploading.value = true
try {
profileForm.avatar = await fileApi.uploadProfileImage(file)
} finally {
avatarUploading.value = false
}
}
const saveProfile = async (): Promise<void> => {
const nickname = profileForm.nickname.trim()
if (!nickname) {
toast.error('请填写昵称')
return
}
profileSaving.value = true
try {
await userApi.update({
nickname,
avatar: profileForm.avatar,
contactPhone: profileForm.contactPhone.trim(),
wechatId: profileForm.wechatId.trim(),
signature: profileForm.signature.trim()
})
const profile = await userApi.info()
syncProfileToSession(profile)
editModalVisible.value = false
toast.success('已保存')
} finally {
profileSaving.value = false
}
}
onMounted(loadProfile)
</script>
<style scoped>
.profile-card {
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
padding: 18px;
}
.profile-main {
display: flex;
align-items: center;
min-width: 0;
gap: 12px;
}
.shop-logo,
.profile-avatar {
display: grid;
place-items: center;
background: var(--accent-soft);
color: var(--accent);
font-weight: 900;
}
.shop-logo {
flex: 0 0 48px;
width: 48px;
height: 48px;
border-radius: 18px;
font-size: 22px;
}
.profile-copy {
display: grid;
min-width: 0;
gap: 4px;
}
.profile-copy strong,
.profile-copy span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.profile-copy span {
color: var(--muted);
font-size: 12px;
}
.role-badge {
flex: 0 0 auto;
padding: 5px 10px;
border-radius: 999px;
background: var(--subtle);
color: #6b645c;
font-size: 12px;
font-weight: 800;
}
.menu-list {
overflow: hidden;
}
.menu-row {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
min-height: 54px;
padding: 0 16px;
border-bottom: 1px solid var(--border);
color: #3e3932;
font-weight: 750;
}
.menu-row:last-child {
border-bottom: 0;
}
.profile-avatar-row {
display: flex;
align-items: center;
gap: 10px;
padding: 14px 16px;
}
.profile-avatar {
flex: 0 0 54px;
width: 54px;
height: 54px;
border-radius: 18px;
object-fit: cover;
}
.profile-avatar--image {
background: var(--subtle);
}
.avatar-btn {
position: relative;
width: auto;
min-width: 108px;
}
.hidden-file {
position: absolute;
inset: 0;
opacity: 0;
}
.profile-form {
padding: 0 16px 12px;
}
.readonly-field strong {
overflow: hidden;
color: #504a43;
font-size: 13px;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>
+202
View File
@@ -0,0 +1,202 @@
<template>
<MobileShell title="注册账号">
<section class="card form-card">
<div class="field">
<label class="required">手机号</label>
<input v-model.trim="form.phone" inputmode="numeric" placeholder="请输入手机号" />
</div>
<div class="field code-field">
<label class="required">验证码</label>
<input v-model.trim="form.code" inputmode="numeric" placeholder="请输入验证码" />
<button class="code-btn" type="button" :disabled="codeLoading || countdown > 0" @click="sendCode">
{{ countdown > 0 ? `${countdown}s` : '获取' }}
</button>
</div>
<div class="field">
<label class="required">店铺名称</label>
<input v-model.trim="form.shopName" placeholder="例如:Jayu Artist" />
</div>
<div class="field">
<label class="required">昵称</label>
<input v-model.trim="form.nickname" placeholder="请输入昵称" />
</div>
<div class="field">
<label class="required">账号</label>
<input v-model.trim="form.account" placeholder="默认可填写手机号" />
</div>
<div class="field">
<label class="required">密码</label>
<input v-model="form.password" type="password" placeholder="请输入密码" />
</div>
<div class="field">
<label class="required">确认密码</label>
<input v-model="form.confirmPassword" type="password" placeholder="请再次输入密码" />
</div>
</section>
<button class="check-row" type="button" @click="agreementAccepted = !agreementAccepted">
<span class="check-box" :class="{ checked: agreementAccepted }">{{ agreementAccepted ? '✓' : '' }}</span>
<span>我已阅读并同意用户协议和隐私政策</span>
</button>
<div class="fixed-bottom">
<div class="fixed-bottom__inner">
<button class="primary-btn" type="button" :disabled="loading" @click="submit">
{{ loading ? '注册中...' : '注册并登录' }}
</button>
</div>
</div>
</MobileShell>
</template>
<script setup lang="ts">
import { onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { useRouter } from 'vue-router'
import MobileShell from '@/components/MobileShell.vue'
import { authApi } from '@/api/auth'
import { useSessionStore } from '@/stores/session'
import { useToastStore } from '@/stores/toast'
import type { LegalAgreement } from '@/types/common'
const PHONE_REGEX = /^1[3-9]\d{9}$/
const router = useRouter()
const session = useSessionStore()
const toast = useToastStore()
const form = reactive({
phone: '',
code: '',
shopName: '',
nickname: '',
account: '',
password: '',
confirmPassword: ''
})
const loading = ref(false)
const codeLoading = ref(false)
const countdown = ref(0)
const countdownTimer = ref<number | null>(null)
const agreementAccepted = ref(false)
const agreements = ref<LegalAgreement[]>([])
const startCountdown = (): void => {
countdown.value = 60
countdownTimer.value = window.setInterval(() => {
countdown.value -= 1
if (countdown.value <= 0 && countdownTimer.value !== null) {
window.clearInterval(countdownTimer.value)
countdownTimer.value = null
}
}, 1000)
}
const sendCode = async (): Promise<void> => {
if (!PHONE_REGEX.test(form.phone)) {
toast.error('请输入正确手机号')
return
}
codeLoading.value = true
try {
await authApi.sendRegisterCode(form.phone)
toast.success('验证码已发送')
startCountdown()
} finally {
codeLoading.value = false
}
}
const agreementVersions = (): Record<string, string> => {
return agreements.value.reduce<Record<string, string>>((result, item) => {
result[item.agreementType] = item.version
return result
}, {})
}
const submit = async (): Promise<void> => {
if (!form.phone || !form.code || !form.shopName || !form.nickname || !form.account || !form.password) {
toast.error('请补全注册信息')
return
}
if (form.password !== form.confirmPassword) {
toast.error('两次密码不一致')
return
}
if (!agreementAccepted.value) {
toast.error('请先同意用户协议和隐私政策')
return
}
loading.value = true
try {
const response = await authApi.register({
phone: form.phone,
verificationCode: form.code,
shopName: form.shopName,
nickname: form.nickname,
account: form.account,
password: form.password,
agreementAccepted: agreementAccepted.value,
agreementVersions: agreementVersions(),
clientType: 'MANAGER_WEB'
})
session.setSession(response, true)
toast.success('注册成功')
await router.replace('/planning')
} finally {
loading.value = false
}
}
onMounted(async () => {
agreements.value = await authApi.getCurrentAgreements()
})
onBeforeUnmount(() => {
if (countdownTimer.value !== null) {
window.clearInterval(countdownTimer.value)
}
})
</script>
<style scoped>
.code-field {
gap: 8px;
}
.code-btn {
flex: 0 0 68px;
height: 34px;
border-radius: 999px;
background: var(--accent-soft);
color: var(--accent);
font-size: 12px;
font-weight: 800;
}
.check-row {
display: flex;
align-items: center;
gap: 8px;
width: 100%;
margin-top: 14px;
color: #5f5951;
text-align: left;
}
.check-box {
display: inline-flex;
align-items: center;
justify-content: center;
flex: 0 0 18px;
width: 18px;
height: 18px;
border: 1px solid #cfc7bd;
border-radius: 6px;
color: #fff;
font-size: 12px;
}
.check-box.checked {
border-color: var(--accent);
background: var(--accent);
}
</style>
@@ -0,0 +1,114 @@
<template>
<MobileShell title="排班设置">
<LoadingState v-if="loading" text="正在加载排班" />
<template v-else>
<section class="card form-card">
<div class="field"><label>员工</label><div class="field-value">{{ employee?.name || employee?.nickname || route.params.id }}</div></div>
<div class="field"><label class="required">工作日</label><input v-model.trim="ruleForm.workDays" placeholder="例如:1,2,3,4,5" /></div>
<div class="field"><label class="required">开始时间</label><input v-model="ruleForm.startTime" type="time" /></div>
<div class="field"><label class="required">结束时间</label><input v-model="ruleForm.endTime" type="time" /></div>
</section>
<button class="primary-btn section" type="button" :disabled="saving" @click="saveRule">{{ saving ? '保存中...' : '保存排班规则' }}</button>
<PageSection title="新增例外">
<section class="card form-card">
<div class="field"><label class="required">日期</label><input v-model="exceptionForm.workDate" type="date" /></div>
<div class="field"><label>开始时间</label><input v-model="exceptionForm.startTime" type="time" /></div>
<div class="field"><label>结束时间</label><input v-model="exceptionForm.endTime" type="time" /></div>
<div class="field"><label>状态</label><select v-model.number="exceptionForm.status"><option :value="1">可预约</option><option :value="0">休息</option></select></div>
<div class="field"><label>原因</label><input v-model.trim="exceptionForm.reason" placeholder="选填" /></div>
</section>
<button class="secondary-btn section" type="button" :disabled="saving" @click="saveException">保存例外</button>
</PageSection>
<PageSection title="已配置例外">
<EmptyState v-if="exceptions.length === 0" title="暂无例外" />
<section v-else class="list">
<article v-for="item in exceptions" :key="String(item.id || item.workDate)" class="card list-card">
<div class="row-between">
<div>
<h2 class="list-card__title">{{ item.workDate }}</h2>
<div class="list-card__subtitle">{{ item.status === 1 ? `${item.startTime || '-'} - ${item.endTime || '-'}` : '休息' }}</div>
</div>
<span class="tag">{{ item.status === 1 ? '可预约' : '休息' }}</span>
</div>
</article>
</section>
</PageSection>
</template>
</MobileShell>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { useRoute } from 'vue-router'
import EmptyState from '@/components/EmptyState.vue'
import LoadingState from '@/components/LoadingState.vue'
import MobileShell from '@/components/MobileShell.vue'
import PageSection from '@/components/PageSection.vue'
import { managerEmployeesApi } from '@/api/managerEmployees'
import type { Artist, ArtistScheduleException } from '@/types/manager'
import { formatDate } from '@/utils/date'
import { useToastStore } from '@/stores/toast'
const route = useRoute()
const toast = useToastStore()
const loading = ref(false)
const saving = ref(false)
const employee = ref<Artist | null>(null)
const exceptions = ref<ArtistScheduleException[]>([])
const ruleForm = reactive({ workDays: '1,2,3,4,5', startTime: '10:00', endTime: '22:00' })
const exceptionForm = reactive({ workDate: formatDate(new Date()), startTime: '10:00', endTime: '18:00', status: 0, reason: '' })
const artistId = (): string => String(route.params.id)
const loadData = async (): Promise<void> => {
loading.value = true
try {
employee.value = await managerEmployeesApi.detail(artistId())
const setting = await managerEmployeesApi.scheduleRule({ artistId: artistId() })
if (setting.rule) {
ruleForm.workDays = setting.rule.workDays || ruleForm.workDays
ruleForm.startTime = String(setting.rule.startTime || ruleForm.startTime).slice(0, 5)
ruleForm.endTime = String(setting.rule.endTime || ruleForm.endTime).slice(0, 5)
}
exceptions.value = setting.exceptions || []
} finally {
loading.value = false
}
}
const saveRule = async (): Promise<void> => {
if (!ruleForm.workDays || !ruleForm.startTime || !ruleForm.endTime) {
toast.error('请填写排班规则')
return
}
saving.value = true
try {
await managerEmployeesApi.saveScheduleRule({ artistId: artistId(), workDays: ruleForm.workDays, startTime: ruleForm.startTime, endTime: ruleForm.endTime, enabled: 1 })
toast.success('排班规则已保存')
await loadData()
} finally {
saving.value = false
}
}
const saveException = async (): Promise<void> => {
if (!exceptionForm.workDate) {
toast.error('请补全例外日期')
return
}
saving.value = true
try {
await managerEmployeesApi.saveScheduleException({ artistId: artistId(), ...exceptionForm })
toast.success('例外已保存')
await loadData()
} finally {
saving.value = false
}
}
onMounted(() => {
void loadData()
})
</script>
@@ -0,0 +1,130 @@
<template>
<div class="settings-view">
<LoadingState v-if="loading" text="店铺信息加载中" />
<section v-else class="card form-card">
<label class="field">
<span class="field-label">店铺名称</span>
<input v-model.trim="form.shopName" placeholder="请输入店铺名称" />
</label>
<label class="field">
<span class="field-label">营业开始</span>
<input v-model="form.startTime" class="field-value" type="time" />
</label>
<label class="field">
<span class="field-label">营业结束</span>
<input v-model="form.endTime" class="field-value" type="time" />
</label>
<label class="field">
<span class="field-label">默认时长</span>
<input v-model.trim="form.defaultDuration" inputmode="numeric" placeholder="60" />
<span class="muted">分钟</span>
</label>
<label class="field field--stack">
<span class="field-label">预约规则</span>
<textarea v-model.trim="form.rule" placeholder="例如:必须选择已有作品作为项目来源"></textarea>
</label>
</section>
<div class="help-list">
<button class="card help-row" type="button" @click="showDurationHelp">
<Clock :size="18" aria-hidden="true" />
<span>默认时长说明</span>
</button>
<button class="card help-row" type="button" @click="showRuleHelp">
<Info :size="18" aria-hidden="true" />
<span>预约规则说明</span>
</button>
</div>
<div class="fixed-bottom">
<div class="fixed-bottom__inner">
<button class="primary-btn" type="button" :disabled="saving" @click="save">
{{ saving ? '保存中...' : '保存设置' }}
</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { Clock, Info } from 'lucide-vue-next'
import LoadingState from '@/components/LoadingState.vue'
import { managerShopApi } from '@/api/managerShop'
import { useToastStore } from '@/stores/toast'
const toast = useToastStore()
const loading = ref(false)
const saving = ref(false)
const form = reactive({
shopName: '甲屿云',
startTime: '10:00',
endTime: '22:00',
defaultDuration: '60',
rule: '必须选择已有作品作为项目来源'
})
const loadInfo = async (): Promise<void> => {
loading.value = true
try {
const info = await managerShopApi.info()
form.shopName = info.shopName || info.name || form.shopName
form.startTime = info.startTime || form.startTime
form.endTime = info.endTime || form.endTime
form.rule = info.description || form.rule
} finally {
loading.value = false
}
}
const showDurationHelp = (): void => {
window.alert('用于手动创建预约或未选择作品时的默认服务时长,会影响可约时间校验和预约结束时间估算。')
}
const showRuleHelp = (): void => {
window.alert('这是店铺给员工看的预约备注或说明文案,不参与自动排班、容量或冲突校验。')
}
const save = async (): Promise<void> => {
saving.value = true
try {
await managerShopApi.update({
shopName: form.shopName,
name: form.shopName,
startTime: form.startTime,
endTime: form.endTime,
businessHours: `${form.startTime}-${form.endTime}`,
description: form.rule
})
toast.success('已保存')
} finally {
saving.value = false
}
}
onMounted(loadInfo)
</script>
<style scoped>
.settings-view {
padding-bottom: 86px;
}
.help-list {
display: grid;
gap: 10px;
margin-top: 14px;
}
.help-row {
display: flex;
align-items: center;
gap: 10px;
width: 100%;
min-height: 48px;
padding: 0 14px;
color: #504a43;
font-weight: 760;
text-align: left;
}
</style>