新增管理师移动端前端模块
@@ -0,0 +1,6 @@
|
|||||||
|
VITE_API_BASE_URL=/api
|
||||||
|
VITE_ADMIN_API_BASE_URL=/admin/api
|
||||||
|
VITE_DEV_PROXY_TARGET=http://127.0.0.1:80
|
||||||
|
VITE_APP_NAME=甲屿店务
|
||||||
|
VITE_APP_TITLE=甲屿店务
|
||||||
|
VITE_APP_SHORT_NAME=指
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
VITE_API_BASE_URL=https://yunail.art/api
|
||||||
|
VITE_ADMIN_API_BASE_URL=https://yunail.art/admin/api
|
||||||
|
VITE_APP_NAME=甲屿店务
|
||||||
|
VITE_APP_TITLE=甲屿店务
|
||||||
|
VITE_APP_SHORT_NAME=指
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
|
||||||
|
<meta name="theme-color" content="#f8f5ef" />
|
||||||
|
<link rel="icon" type="image/png" href="%BASE_URL%assets/images/app-icon.png" />
|
||||||
|
<title>甲屿店务</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "fingertip-manager-mobile",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.1",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "vue-tsc -b && vite build",
|
||||||
|
"preview": "vite preview --host 0.0.0.0",
|
||||||
|
"test:unit": "vitest run"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^1.13.5",
|
||||||
|
"lucide-vue-next": "^0.468.0",
|
||||||
|
"pinia": "^3.0.4",
|
||||||
|
"vue": "^3.5.25",
|
||||||
|
"vue-router": "^4.6.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^24.10.13",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.2",
|
||||||
|
"@vue/tsconfig": "^0.8.1",
|
||||||
|
"jsdom": "^26.1.0",
|
||||||
|
"typescript": "~5.9.3",
|
||||||
|
"vite": "^7.3.1",
|
||||||
|
"vitest": "^3.2.4",
|
||||||
|
"vue-tsc": "^3.1.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.4 MiB |
|
After Width: | Height: | Size: 448 B |
|
After Width: | Height: | Size: 306 B |
|
After Width: | Height: | Size: 453 B |
|
After Width: | Height: | Size: 290 B |
|
After Width: | Height: | Size: 397 B |
|
After Width: | Height: | Size: 240 B |
|
After Width: | Height: | Size: 434 B |
|
After Width: | Height: | Size: 285 B |
@@ -0,0 +1,8 @@
|
|||||||
|
<template>
|
||||||
|
<RouterView />
|
||||||
|
<ToastHost />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import ToastHost from '@/components/ToastHost.vue'
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
const API_AUTH_FREE_PATHS = [
|
||||||
|
'/user/send-verification-code',
|
||||||
|
'/user/phone-login',
|
||||||
|
'/user/check/login-shops/phone/',
|
||||||
|
'/legal-agreement/current'
|
||||||
|
]
|
||||||
|
|
||||||
|
const ADMIN_AUTH_FREE_PATHS = [
|
||||||
|
'/auth/login',
|
||||||
|
'/auth/login-shops/',
|
||||||
|
'/auth/refresh'
|
||||||
|
]
|
||||||
|
|
||||||
|
const matchPath = (url: string | undefined, paths: string[]): boolean => {
|
||||||
|
const target = String(url || '')
|
||||||
|
return paths.some(path => target === path || target.startsWith(path))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const isApiAuthFreePath = (url: string | undefined): boolean => matchPath(url, API_AUTH_FREE_PATHS)
|
||||||
|
|
||||||
|
export const isAdminAuthFreePath = (url: string | undefined): boolean => matchPath(url, ADMIN_AUTH_FREE_PATHS)
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import { api, adminApi } from '@/api/client'
|
||||||
|
import type { LegalAgreement, LoginResponse, LoginShopSelectionResponse } from '@/types/common'
|
||||||
|
|
||||||
|
export interface PasswordLoginRequest {
|
||||||
|
account: string
|
||||||
|
password: string
|
||||||
|
shopId?: string | number
|
||||||
|
agreementAccepted: boolean
|
||||||
|
agreementVersions: Record<string, string>
|
||||||
|
clientType: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PhoneLoginRequest {
|
||||||
|
phone: string
|
||||||
|
verificationCode: string
|
||||||
|
shopId?: string | number
|
||||||
|
agreementAccepted: boolean
|
||||||
|
agreementVersions: Record<string, string>
|
||||||
|
clientType: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegisterRequest {
|
||||||
|
account: string
|
||||||
|
password: string
|
||||||
|
nickname: string
|
||||||
|
shopName: string
|
||||||
|
phone: string
|
||||||
|
verificationCode: string
|
||||||
|
agreementAccepted: boolean
|
||||||
|
agreementVersions: Record<string, string>
|
||||||
|
clientType: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const authApi = {
|
||||||
|
passwordLogin(data: PasswordLoginRequest): Promise<LoginResponse> {
|
||||||
|
return adminApi.post('/auth/login', data)
|
||||||
|
},
|
||||||
|
getPasswordLoginShops(account: string): Promise<LoginShopSelectionResponse> {
|
||||||
|
return adminApi.get(`/auth/login-shops/${encodeURIComponent(account)}`)
|
||||||
|
},
|
||||||
|
sendRegisterCode(phone: string): Promise<boolean> {
|
||||||
|
return api.post('/user/send-verification-code', { phone, sceneCode: 'PLANNING_MANAGER_REGISTER' })
|
||||||
|
},
|
||||||
|
sendLoginCode(phone: string): Promise<boolean> {
|
||||||
|
return api.post('/user/send-verification-code', { phone, sceneCode: 'USER_LOGIN_SMS_CODE' })
|
||||||
|
},
|
||||||
|
phoneLogin(data: PhoneLoginRequest): Promise<LoginResponse> {
|
||||||
|
return api.post('/user/phone-login', data)
|
||||||
|
},
|
||||||
|
getPhoneLoginShops(phone: string): Promise<LoginShopSelectionResponse> {
|
||||||
|
return api.get(`/user/check/login-shops/phone/${encodeURIComponent(phone)}`)
|
||||||
|
},
|
||||||
|
getCurrentAgreements(): Promise<LegalAgreement[]> {
|
||||||
|
return api.get('/legal-agreement/current')
|
||||||
|
},
|
||||||
|
register(data: RegisterRequest): Promise<LoginResponse> {
|
||||||
|
return adminApi.post('/auth/register', data)
|
||||||
|
},
|
||||||
|
switchShop(shopId: string | number): Promise<LoginResponse> {
|
||||||
|
return adminApi.post('/auth/switch-shop', { shopId })
|
||||||
|
},
|
||||||
|
logout(): Promise<boolean> {
|
||||||
|
return adminApi.post('/auth/logout')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import axios, { type AxiosError } from 'axios'
|
||||||
|
import router from '@/router'
|
||||||
|
import { ADMIN_API_BASE_URL, API_BASE_URL } from '@/config/api'
|
||||||
|
import { isAdminAuthFreePath, isApiAuthFreePath } from '@/api/auth-free-paths'
|
||||||
|
import { attachRequestSignature } from '@/utils/request-signature'
|
||||||
|
import { useSessionStore } from '@/stores/session'
|
||||||
|
import { useToastStore } from '@/stores/toast'
|
||||||
|
|
||||||
|
const api = axios.create({
|
||||||
|
baseURL: API_BASE_URL,
|
||||||
|
timeout: 60000,
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
})
|
||||||
|
|
||||||
|
const adminApi = axios.create({
|
||||||
|
baseURL: ADMIN_API_BASE_URL,
|
||||||
|
timeout: 60000,
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
})
|
||||||
|
|
||||||
|
const normalizeResponse = <T>(response: { data: { code?: number; message?: string; data: T } }): T => {
|
||||||
|
const payload = response.data
|
||||||
|
if (payload && payload.code !== undefined && payload.code !== 200) {
|
||||||
|
throw new Error(payload.message || '请求失败')
|
||||||
|
}
|
||||||
|
return payload.data as T
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleExpired = async (): Promise<void> => {
|
||||||
|
const session = useSessionStore()
|
||||||
|
session.clear()
|
||||||
|
await router.replace('/login')
|
||||||
|
}
|
||||||
|
|
||||||
|
api.interceptors.request.use(async config => {
|
||||||
|
const session = useSessionStore()
|
||||||
|
const authFree = isApiAuthFreePath(config.url)
|
||||||
|
if (!authFree && session.accessToken) {
|
||||||
|
config.headers.Authorization = `Bearer ${session.accessToken}`
|
||||||
|
}
|
||||||
|
return attachRequestSignature(config, session.accessToken, { authFree })
|
||||||
|
})
|
||||||
|
|
||||||
|
adminApi.interceptors.request.use(async config => {
|
||||||
|
const session = useSessionStore()
|
||||||
|
const authFree = isAdminAuthFreePath(config.url)
|
||||||
|
if (!authFree && session.accessToken) {
|
||||||
|
config.headers.Authorization = `Bearer ${session.accessToken}`
|
||||||
|
}
|
||||||
|
return attachRequestSignature(config, session.accessToken, { authFree })
|
||||||
|
})
|
||||||
|
|
||||||
|
const responseErrorHandler = async (error: AxiosError): Promise<never> => {
|
||||||
|
if (error.response?.status === 401) {
|
||||||
|
await handleExpired()
|
||||||
|
}
|
||||||
|
const message = (error.response?.data as { message?: string } | undefined)?.message || error.message || '请求失败'
|
||||||
|
useToastStore().error(message)
|
||||||
|
return Promise.reject(new Error(message))
|
||||||
|
}
|
||||||
|
|
||||||
|
api.interceptors.response.use(response => normalizeResponse(response), responseErrorHandler)
|
||||||
|
adminApi.interceptors.response.use(response => normalizeResponse(response), responseErrorHandler)
|
||||||
|
|
||||||
|
export { api, adminApi }
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { api, adminApi } from '@/api/client'
|
||||||
|
|
||||||
|
export interface ObjectStorageFile {
|
||||||
|
id: string | number
|
||||||
|
fileName?: string
|
||||||
|
fileUrl?: string
|
||||||
|
primaryUrl?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const fileApi = {
|
||||||
|
uploadObjectFile(file: File): Promise<ObjectStorageFile> {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
return adminApi.post('/object-storage-file/upload', formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
uploadProfileImage(file: File): Promise<string> {
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', file)
|
||||||
|
return api.post('/user/upload-profile-image', formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { adminApi } from '@/api/client'
|
||||||
|
import type { IdType, UserInfo } from '@/types/common'
|
||||||
|
import type { CustomerCreateRequest, CustomerPage } from '@/types/manager'
|
||||||
|
|
||||||
|
export interface CustomerListParams {
|
||||||
|
page: number
|
||||||
|
size: number
|
||||||
|
keyword?: string
|
||||||
|
hasOrder?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const managerCustomersApi = {
|
||||||
|
list(params: CustomerListParams): Promise<CustomerPage> {
|
||||||
|
return adminApi.get('/manager/customers', { params })
|
||||||
|
},
|
||||||
|
detail(id: IdType): Promise<UserInfo> {
|
||||||
|
return adminApi.get(`/manager/customers/${id}`)
|
||||||
|
},
|
||||||
|
create(data: CustomerCreateRequest): Promise<IdType> {
|
||||||
|
return adminApi.post('/manager/customers', data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { adminApi } from '@/api/client'
|
||||||
|
import type { IdType } from '@/types/common'
|
||||||
|
import type {
|
||||||
|
Artist,
|
||||||
|
ArtistSchedule,
|
||||||
|
ArtistScheduleException,
|
||||||
|
ArtistScheduleRule,
|
||||||
|
ArtistScheduleRuleSetting,
|
||||||
|
EmployeeCreateRequest
|
||||||
|
} from '@/types/manager'
|
||||||
|
|
||||||
|
export const managerEmployeesApi = {
|
||||||
|
list(): Promise<Artist[]> {
|
||||||
|
return adminApi.get('/manager/employees')
|
||||||
|
},
|
||||||
|
detail(userId: IdType): Promise<Artist> {
|
||||||
|
return adminApi.get(`/manager/employees/${userId}`)
|
||||||
|
},
|
||||||
|
save(data: Partial<Artist>): Promise<Artist> {
|
||||||
|
return adminApi.post('/manager/employees', data)
|
||||||
|
},
|
||||||
|
createUser(data: EmployeeCreateRequest): Promise<IdType> {
|
||||||
|
return adminApi.post('/manager/employees/users', data)
|
||||||
|
},
|
||||||
|
schedules(params: { artistId?: IdType; startDate?: string; endDate?: string }): Promise<ArtistSchedule[]> {
|
||||||
|
return adminApi.get('/manager/employees/schedules', { params })
|
||||||
|
},
|
||||||
|
saveSchedule(data: ArtistSchedule): Promise<ArtistSchedule> {
|
||||||
|
return adminApi.post('/manager/employees/schedules', data)
|
||||||
|
},
|
||||||
|
scheduleRule(params: { artistId: IdType }): Promise<ArtistScheduleRuleSetting> {
|
||||||
|
return adminApi.get('/manager/employees/schedule-rule', { params })
|
||||||
|
},
|
||||||
|
saveScheduleRule(data: ArtistScheduleRule): Promise<ArtistScheduleRule> {
|
||||||
|
return adminApi.post('/manager/employees/schedule-rule', data)
|
||||||
|
},
|
||||||
|
saveScheduleException(data: ArtistScheduleException): Promise<ArtistScheduleException> {
|
||||||
|
return adminApi.post('/manager/employees/schedule-exceptions', data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { adminApi } from '@/api/client'
|
||||||
|
import type { Appointment, AppointmentCreateRequest, PlanningCalendar } from '@/types/manager'
|
||||||
|
import type { IdType } from '@/types/common'
|
||||||
|
|
||||||
|
export interface CalendarParams {
|
||||||
|
startDate: string
|
||||||
|
endDate: string
|
||||||
|
artistId?: string | number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AppointmentMoveRequest {
|
||||||
|
appointmentDate: string
|
||||||
|
appointmentTime: string
|
||||||
|
artistId: string | number
|
||||||
|
}
|
||||||
|
|
||||||
|
export const managerPlanningApi = {
|
||||||
|
calendar(params: CalendarParams): Promise<PlanningCalendar> {
|
||||||
|
return adminApi.get('/manager/planning/calendar', { params })
|
||||||
|
},
|
||||||
|
createAppointment(data: AppointmentCreateRequest): Promise<Appointment> {
|
||||||
|
return adminApi.post('/manager/planning/appointments', data)
|
||||||
|
},
|
||||||
|
appointment(orderItemId: IdType): Promise<Appointment> {
|
||||||
|
return adminApi.get(`/manager/planning/appointments/${orderItemId}`)
|
||||||
|
},
|
||||||
|
moveAppointment(orderItemId: IdType, data: AppointmentMoveRequest): Promise<Appointment> {
|
||||||
|
return adminApi.put(`/manager/planning/appointments/${orderItemId}/time-artist`, data)
|
||||||
|
},
|
||||||
|
updateStatus(orderId: IdType, status: number): Promise<boolean> {
|
||||||
|
return adminApi.put(`/manager/planning/appointments/${orderId}/status`, { status })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { adminApi } from '@/api/client'
|
||||||
|
import type { PageResult } from '@/types/common'
|
||||||
|
import type { Product } from '@/types/manager'
|
||||||
|
|
||||||
|
export const managerProductsApi = {
|
||||||
|
list(params: { page: number; size: number; keyword?: string }): Promise<PageResult<Product> | Product[]> {
|
||||||
|
return adminApi.get('/manager/products', { params })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { adminApi } from '@/api/client'
|
||||||
|
import type { ShopInfo } from '@/types/manager'
|
||||||
|
|
||||||
|
export const managerShopApi = {
|
||||||
|
info(): Promise<ShopInfo> {
|
||||||
|
return adminApi.get('/manager/shop')
|
||||||
|
},
|
||||||
|
update(data: Partial<ShopInfo>): Promise<boolean> {
|
||||||
|
return adminApi.put('/manager/shop', data)
|
||||||
|
},
|
||||||
|
exportPreview(params: { type: string; startDate: string; endDate: string }): Promise<unknown> {
|
||||||
|
return adminApi.get('/export', { params })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { api } from '@/api/client'
|
||||||
|
import type { UserInfo } from '@/types/common'
|
||||||
|
|
||||||
|
export const userApi = {
|
||||||
|
info(): Promise<UserInfo> {
|
||||||
|
return api.get('/user/info')
|
||||||
|
},
|
||||||
|
update(data: Partial<UserInfo>): Promise<boolean> {
|
||||||
|
return api.put('/user/info', data)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<template>
|
||||||
|
<Teleport to="body">
|
||||||
|
<Transition name="modal-fade">
|
||||||
|
<div v-if="modelValue" class="modal-mask" @click="close">
|
||||||
|
<section class="modal-panel" @click.stop>
|
||||||
|
<div class="modal-panel__head">
|
||||||
|
<h2>{{ title }}</h2>
|
||||||
|
<button class="modal-panel__close" type="button" :disabled="closeDisabled" @click="close">×</button>
|
||||||
|
</div>
|
||||||
|
<slot />
|
||||||
|
<div v-if="$slots.footer" class="modal-panel__footer">
|
||||||
|
<slot name="footer" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</Teleport>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: boolean
|
||||||
|
title: string
|
||||||
|
closeDisabled?: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: boolean]
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const close = (): void => {
|
||||||
|
if (props.closeDisabled) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
emit('update:modelValue', false)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<div class="empty-state">
|
||||||
|
<div class="empty-state__mark">{{ mark }}</div>
|
||||||
|
<strong>{{ title }}</strong>
|
||||||
|
<span v-if="description">{{ description }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
withDefaults(defineProps<{
|
||||||
|
title: string
|
||||||
|
description?: string
|
||||||
|
mark?: string
|
||||||
|
}>(), {
|
||||||
|
mark: '空'
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<template>
|
||||||
|
<div class="loading-state">
|
||||||
|
<div class="loading-state__spinner"></div>
|
||||||
|
<span>{{ text }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
defineProps<{
|
||||||
|
text: string
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mobile-shell" :class="{ 'mobile-shell--tab': showTab }">
|
||||||
|
<header v-if="showHeader" class="mobile-header">
|
||||||
|
<button class="icon-button" type="button" aria-label="返回" @click="goBack">
|
||||||
|
<ChevronLeft :size="22" />
|
||||||
|
</button>
|
||||||
|
<h1>{{ title }}</h1>
|
||||||
|
<div class="mobile-header__side">
|
||||||
|
<slot name="header-action" />
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<main class="mobile-page" :class="{ 'mobile-page--plain': plain }">
|
||||||
|
<slot />
|
||||||
|
</main>
|
||||||
|
<TabBar v-if="showTab" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
|
import { ChevronLeft } from 'lucide-vue-next'
|
||||||
|
import TabBar from '@/components/TabBar.vue'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
title?: string
|
||||||
|
plain?: boolean
|
||||||
|
hideHeader?: boolean
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const showTab = computed(() => Boolean(route.meta.tab))
|
||||||
|
const showHeader = computed(() => !props.hideHeader && !showTab.value)
|
||||||
|
const title = computed(() => props.title || String(route.meta.title || '甲屿店务'))
|
||||||
|
|
||||||
|
const goBack = (): void => {
|
||||||
|
if (window.history.length > 1) {
|
||||||
|
router.back()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
router.replace('/planning')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<template>
|
||||||
|
<section class="section">
|
||||||
|
<div v-if="title || $slots.action" class="section__head">
|
||||||
|
<h2 v-if="title">{{ title }}</h2>
|
||||||
|
<slot name="action" />
|
||||||
|
</div>
|
||||||
|
<slot />
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
defineProps<{
|
||||||
|
title?: string
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<template>
|
||||||
|
<nav class="tabbar">
|
||||||
|
<RouterLink v-for="item in tabs" :key="item.path" class="tabbar__item" :to="item.path">
|
||||||
|
<img :src="isActive(item.path) ? item.activeIcon : item.icon" :alt="item.label" />
|
||||||
|
<span>{{ item.label }}</span>
|
||||||
|
</RouterLink>
|
||||||
|
</nav>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
|
const route = useRoute()
|
||||||
|
const assetPath = (path: string): string => `${import.meta.env.BASE_URL}${path.replace(/^\/+/, '')}`
|
||||||
|
|
||||||
|
const tabs = [
|
||||||
|
{ path: '/planning', label: '规划', icon: assetPath('assets/tabbar/planning.png'), activeIcon: assetPath('assets/tabbar/planning-active.png') },
|
||||||
|
{ path: '/customers', label: '客户', icon: assetPath('assets/tabbar/customers.png'), activeIcon: assetPath('assets/tabbar/customers-active.png') },
|
||||||
|
{ path: '/employees', label: '员工', icon: assetPath('assets/tabbar/employees.png'), activeIcon: assetPath('assets/tabbar/employees-active.png') },
|
||||||
|
{ path: '/profile', label: '我的', icon: assetPath('assets/tabbar/profile.png'), activeIcon: assetPath('assets/tabbar/profile-active.png') }
|
||||||
|
]
|
||||||
|
|
||||||
|
const isActive = (path: string): boolean => route.path === path || route.path.startsWith(`${path}/`)
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<template>
|
||||||
|
<Transition name="toast-fade">
|
||||||
|
<div v-if="toast.visible" class="toast-host" :class="`toast-host--${toast.kind}`">
|
||||||
|
{{ toast.message }}
|
||||||
|
</div>
|
||||||
|
</Transition>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useToastStore } from '@/stores/toast'
|
||||||
|
|
||||||
|
const toast = useToastStore()
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
const normalizeBaseUrl = (value: string | undefined, fallbackValue: string): string => {
|
||||||
|
const target = String(value || fallbackValue).trim()
|
||||||
|
return target.replace(/\/+$/, '')
|
||||||
|
}
|
||||||
|
|
||||||
|
const DEFAULT_API_BASE_URL = import.meta.env.DEV ? '/api' : 'https://yunail.art/api'
|
||||||
|
const DEFAULT_ADMIN_API_BASE_URL = import.meta.env.DEV ? '/admin/api' : 'https://yunail.art/admin/api'
|
||||||
|
|
||||||
|
export const API_BASE_URL = normalizeBaseUrl(import.meta.env.VITE_API_BASE_URL, DEFAULT_API_BASE_URL)
|
||||||
|
export const ADMIN_API_BASE_URL = normalizeBaseUrl(import.meta.env.VITE_ADMIN_API_BASE_URL, DEFAULT_ADMIN_API_BASE_URL)
|
||||||
|
export const APP_NAME = String(import.meta.env.VITE_APP_NAME || '甲屿店务')
|
||||||
|
export const APP_SHORT_NAME = String(import.meta.env.VITE_APP_SHORT_NAME || '指')
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { createApp } from 'vue'
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from './router'
|
||||||
|
import './styles/base.css'
|
||||||
|
|
||||||
|
const app = createApp(App)
|
||||||
|
|
||||||
|
app.use(createPinia())
|
||||||
|
app.use(router)
|
||||||
|
app.mount('#app')
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
||||||
|
import { useSessionStore } from '@/stores/session'
|
||||||
|
|
||||||
|
const routes: RouteRecordRaw[] = [
|
||||||
|
{ path: '/', redirect: '/planning' },
|
||||||
|
{ path: '/login', name: 'login', component: () => import('@/views/LoginView.vue'), meta: { public: true, hideTab: true } },
|
||||||
|
{ path: '/register', name: 'register', component: () => import('@/views/RegisterView.vue'), meta: { public: true, hideTab: true, title: '注册账号' } },
|
||||||
|
{ path: '/planning', name: 'planning', component: () => import('@/views/PlanningView.vue'), meta: { tab: true } },
|
||||||
|
{ path: '/customers', name: 'customers', component: () => import('@/views/CustomersView.vue'), meta: { tab: true } },
|
||||||
|
{ path: '/customers/:id', name: 'customer-detail', component: () => import('@/views/CustomerDetailView.vue'), meta: { title: '客户详情' } },
|
||||||
|
{ path: '/employees', name: 'employees', component: () => import('@/views/EmployeesView.vue'), meta: { tab: true } },
|
||||||
|
{ path: '/employees/:id', name: 'employee-detail', component: () => import('@/views/EmployeeDetailView.vue'), meta: { title: '员工详情' } },
|
||||||
|
{ path: '/employees/:id/schedule', name: 'schedule-setting', component: () => import('@/views/ScheduleSettingView.vue'), meta: { title: '排班设置' } },
|
||||||
|
{ path: '/employees/:id/leave', name: 'leave-management', component: () => import('@/views/LeaveManagementView.vue'), meta: { title: '请假管理' } },
|
||||||
|
{ path: '/employees/:id/color', name: 'color-setting', component: () => import('@/views/ColorSettingView.vue'), meta: { title: '颜色设置' } },
|
||||||
|
{ path: '/employees/:id/orders', name: 'employee-orders', component: () => import('@/views/EmployeeOrdersView.vue'), meta: { title: '员工作品/订单' } },
|
||||||
|
{ path: '/appointments/new', name: 'appointment-form', component: () => import('@/views/AppointmentFormView.vue'), meta: { title: '新建预约' } },
|
||||||
|
{ path: '/appointments/:id', name: 'appointment-detail', component: () => import('@/views/AppointmentDetailView.vue'), meta: { title: '预约详情' } },
|
||||||
|
{ path: '/appointments/:id/transfer', name: 'artist-transfer', component: () => import('@/views/ArtistTransferView.vue'), meta: { title: '改派预约' } },
|
||||||
|
{ path: '/profile', name: 'profile', component: () => import('@/views/ProfileView.vue'), meta: { tab: true } },
|
||||||
|
{ path: '/shop-settings', name: 'shop-settings', component: () => import('@/views/ShopSettingsView.vue'), meta: { title: '店铺设置' } },
|
||||||
|
{ path: '/export', name: 'export', component: () => import('@/views/ExportView.vue'), meta: { title: '导出' } },
|
||||||
|
{ path: '/password', name: 'password', component: () => import('@/views/PasswordView.vue'), meta: { title: '修改密码' } },
|
||||||
|
{ path: '/about', name: 'about', component: () => import('@/views/AboutView.vue'), meta: { title: '关于' } },
|
||||||
|
{ path: '/:pathMatch(.*)*', redirect: '/planning' }
|
||||||
|
]
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHistory('/fm-front/'),
|
||||||
|
routes
|
||||||
|
})
|
||||||
|
|
||||||
|
router.beforeEach(to => {
|
||||||
|
const session = useSessionStore()
|
||||||
|
if (!to.meta.public && !session.isLoggedIn) {
|
||||||
|
return '/login'
|
||||||
|
}
|
||||||
|
if ((to.name === 'login' || to.name === 'register') && session.isLoggedIn) {
|
||||||
|
return '/planning'
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import type { LoginResponse, UserInfo } from '@/types/common'
|
||||||
|
|
||||||
|
const SESSION_KEY = 'fingertip_manager_session'
|
||||||
|
const ACCESS_TOKEN_KEY = 'managerAccessToken'
|
||||||
|
const REFRESH_TOKEN_KEY = 'managerRefreshToken'
|
||||||
|
|
||||||
|
export interface ManagerSession {
|
||||||
|
accessToken: string
|
||||||
|
refreshToken: string
|
||||||
|
userInfo: UserInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
const readSession = (): ManagerSession | null => {
|
||||||
|
const raw = window.localStorage.getItem(SESSION_KEY) || window.sessionStorage.getItem(SESSION_KEY)
|
||||||
|
if (!raw) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return JSON.parse(raw) as ManagerSession
|
||||||
|
}
|
||||||
|
|
||||||
|
const writeSession = (session: ManagerSession, rememberMe: boolean): void => {
|
||||||
|
const primaryStorage = rememberMe ? window.localStorage : window.sessionStorage
|
||||||
|
const secondaryStorage = rememberMe ? window.sessionStorage : window.localStorage
|
||||||
|
const raw = JSON.stringify(session)
|
||||||
|
primaryStorage.setItem(SESSION_KEY, raw)
|
||||||
|
primaryStorage.setItem(ACCESS_TOKEN_KEY, session.accessToken)
|
||||||
|
primaryStorage.setItem(REFRESH_TOKEN_KEY, session.refreshToken)
|
||||||
|
secondaryStorage.removeItem(SESSION_KEY)
|
||||||
|
secondaryStorage.removeItem(ACCESS_TOKEN_KEY)
|
||||||
|
secondaryStorage.removeItem(REFRESH_TOKEN_KEY)
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearStoredSession = (): void => {
|
||||||
|
;[window.localStorage, window.sessionStorage].forEach(storage => {
|
||||||
|
storage.removeItem(SESSION_KEY)
|
||||||
|
storage.removeItem(ACCESS_TOKEN_KEY)
|
||||||
|
storage.removeItem(REFRESH_TOKEN_KEY)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useSessionStore = defineStore('session', {
|
||||||
|
state: () => ({
|
||||||
|
session: readSession()
|
||||||
|
}),
|
||||||
|
getters: {
|
||||||
|
accessToken: state => state.session?.accessToken || '',
|
||||||
|
refreshToken: state => state.session?.refreshToken || '',
|
||||||
|
userInfo: state => state.session?.userInfo || null,
|
||||||
|
isLoggedIn: state => Boolean(state.session?.accessToken && state.session?.userInfo)
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
setSession(payload: LoginResponse, rememberMe: boolean) {
|
||||||
|
const session: ManagerSession = {
|
||||||
|
accessToken: payload.accessToken,
|
||||||
|
refreshToken: payload.refreshToken,
|
||||||
|
userInfo: payload.userInfo
|
||||||
|
}
|
||||||
|
writeSession(session, rememberMe)
|
||||||
|
this.session = session
|
||||||
|
},
|
||||||
|
patchUserInfo(userInfo: UserInfo) {
|
||||||
|
if (!this.session) {
|
||||||
|
throw new Error('当前没有登录会话,无法更新用户信息')
|
||||||
|
}
|
||||||
|
const nextSession = { ...this.session, userInfo }
|
||||||
|
writeSession(nextSession, true)
|
||||||
|
this.session = nextSession
|
||||||
|
},
|
||||||
|
clear() {
|
||||||
|
clearStoredSession()
|
||||||
|
this.session = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export type ToastKind = 'info' | 'success' | 'error'
|
||||||
|
|
||||||
|
interface ToastState {
|
||||||
|
visible: boolean
|
||||||
|
message: string
|
||||||
|
kind: ToastKind
|
||||||
|
timer: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useToastStore = defineStore('toast', {
|
||||||
|
state: (): ToastState => ({
|
||||||
|
visible: false,
|
||||||
|
message: '',
|
||||||
|
kind: 'info',
|
||||||
|
timer: null
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
show(message: string, kind: ToastKind, durationMs: number) {
|
||||||
|
if (this.timer !== null) {
|
||||||
|
window.clearTimeout(this.timer)
|
||||||
|
}
|
||||||
|
this.visible = true
|
||||||
|
this.message = message
|
||||||
|
this.kind = kind
|
||||||
|
this.timer = window.setTimeout(() => {
|
||||||
|
this.visible = false
|
||||||
|
this.timer = null
|
||||||
|
}, durationMs)
|
||||||
|
},
|
||||||
|
info(message: string) {
|
||||||
|
this.show(message, 'info', 2200)
|
||||||
|
},
|
||||||
|
success(message: string) {
|
||||||
|
this.show(message, 'success', 1800)
|
||||||
|
},
|
||||||
|
error(message: string) {
|
||||||
|
this.show(message, 'error', 2600)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,544 @@
|
|||||||
|
:root {
|
||||||
|
--page-bg: #f8f5ef;
|
||||||
|
--card-bg: #fffdf8;
|
||||||
|
--ink: #26231f;
|
||||||
|
--muted: #8b8680;
|
||||||
|
--subtle: #f0ece5;
|
||||||
|
--border: #eee8df;
|
||||||
|
--accent: #2f6f62;
|
||||||
|
--accent-soft: #e5eee9;
|
||||||
|
--accent-light: #6f8f83;
|
||||||
|
--danger: #c45f5f;
|
||||||
|
--warning: #c56f36;
|
||||||
|
--shadow: 0 10px 28px rgba(58, 48, 34, 0.06);
|
||||||
|
color: var(--ink);
|
||||||
|
background: var(--page-bg);
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.45;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
html,
|
||||||
|
body,
|
||||||
|
#app {
|
||||||
|
min-height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
background: var(--page-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
min-width: 320px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
textarea,
|
||||||
|
select {
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
opacity: 0.62;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-shell {
|
||||||
|
min-height: 100vh;
|
||||||
|
background: var(--page-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-shell--tab {
|
||||||
|
padding-bottom: calc(84px + env(safe-area-inset-bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-page {
|
||||||
|
width: min(100%, 520px);
|
||||||
|
min-height: 100vh;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 14px 12px 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-page--plain {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 12;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 42px 1fr 42px;
|
||||||
|
align-items: center;
|
||||||
|
width: min(100%, 520px);
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
|
||||||
|
background: rgba(248, 245, 239, 0.94);
|
||||||
|
backdrop-filter: blur(14px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-header h1 {
|
||||||
|
margin: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 800;
|
||||||
|
text-align: center;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-header__side {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-button {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--card-bg);
|
||||||
|
color: #4e4942;
|
||||||
|
box-shadow: 0 6px 14px rgba(58, 48, 34, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
border: 1px solid rgba(50, 43, 34, 0.06);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: var(--card-bg);
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
margin-top: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section__head,
|
||||||
|
.row-between,
|
||||||
|
.row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section__head,
|
||||||
|
.row-between {
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section__head {
|
||||||
|
margin: 2px 2px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section__head h2 {
|
||||||
|
margin: 0;
|
||||||
|
color: #4c4740;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.muted {
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tag,
|
||||||
|
.chip {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 24px;
|
||||||
|
padding: 0 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--subtle);
|
||||||
|
color: #6d675f;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chip--active {
|
||||||
|
background: var(--accent-soft);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-btn,
|
||||||
|
.secondary-btn,
|
||||||
|
.danger-btn,
|
||||||
|
.text-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 42px;
|
||||||
|
padding: 0 16px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-weight: 800;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-btn,
|
||||||
|
.secondary-btn,
|
||||||
|
.danger-btn {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-btn {
|
||||||
|
background: var(--accent-light);
|
||||||
|
color: #fffdf8;
|
||||||
|
box-shadow: 0 12px 24px rgba(111, 143, 131, 0.22);
|
||||||
|
}
|
||||||
|
|
||||||
|
.secondary-btn {
|
||||||
|
border: 1px solid #d8d1c8;
|
||||||
|
background: var(--card-bg);
|
||||||
|
color: #514b44;
|
||||||
|
}
|
||||||
|
|
||||||
|
.danger-btn {
|
||||||
|
background: var(--danger);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-btn {
|
||||||
|
min-height: 32px;
|
||||||
|
padding: 0;
|
||||||
|
color: var(--accent);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-card {
|
||||||
|
padding: 4px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 58px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.field:last-child {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field--stack {
|
||||||
|
display: block;
|
||||||
|
padding: 14px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field label,
|
||||||
|
.field-label {
|
||||||
|
flex: 0 0 92px;
|
||||||
|
color: #625c55;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.required::after {
|
||||||
|
content: " *";
|
||||||
|
color: var(--warning);
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field input,
|
||||||
|
.field textarea,
|
||||||
|
.field select,
|
||||||
|
.field-value {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
width: 100%;
|
||||||
|
border: 0;
|
||||||
|
outline: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--ink);
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field textarea {
|
||||||
|
min-height: 108px;
|
||||||
|
padding: 10px 0;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
width: 100%;
|
||||||
|
height: 42px;
|
||||||
|
padding: 0 14px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 12px;
|
||||||
|
outline: 0;
|
||||||
|
background: var(--card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-card {
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-card__title {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--ink);
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 850;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-card__subtitle,
|
||||||
|
.list-card__meta {
|
||||||
|
margin-top: 4px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-card__actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-bottom {
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 20;
|
||||||
|
padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
|
||||||
|
background: rgba(248, 245, 239, 0.94);
|
||||||
|
backdrop-filter: blur(18px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-bottom__inner {
|
||||||
|
width: min(100%, 520px);
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fab {
|
||||||
|
position: fixed;
|
||||||
|
right: max(16px, calc((100vw - 520px) / 2 + 16px));
|
||||||
|
bottom: calc(92px + env(safe-area-inset-bottom));
|
||||||
|
z-index: 18;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 54px;
|
||||||
|
height: 54px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--accent-light);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 30px;
|
||||||
|
font-weight: 300;
|
||||||
|
box-shadow: 0 12px 26px rgba(111, 143, 131, 0.24);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabbar {
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 30;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
width: min(100%, 520px);
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
|
||||||
|
border-top: 1px solid rgba(50, 43, 34, 0.06);
|
||||||
|
background: rgba(255, 253, 248, 0.96);
|
||||||
|
box-shadow: 0 -8px 26px rgba(58, 48, 34, 0.07);
|
||||||
|
backdrop-filter: blur(18px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabbar__item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 4px;
|
||||||
|
min-height: 52px;
|
||||||
|
border-radius: 12px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabbar__item.router-link-active {
|
||||||
|
background: var(--accent-soft);
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tabbar__item img {
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-state,
|
||||||
|
.empty-state {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-height: 160px;
|
||||||
|
padding: 28px 16px;
|
||||||
|
color: var(--muted);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-state__spinner {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
border: 3px solid var(--accent-soft);
|
||||||
|
border-top-color: var(--accent);
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state__mark {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 52px;
|
||||||
|
height: 52px;
|
||||||
|
border-radius: 18px;
|
||||||
|
background: var(--subtle);
|
||||||
|
color: #6d675f;
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state strong {
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-mask {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 50;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 14px;
|
||||||
|
background: rgba(38, 35, 31, 0.34);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-panel {
|
||||||
|
width: min(100%, 500px);
|
||||||
|
max-height: min(84vh, 720px);
|
||||||
|
overflow: auto;
|
||||||
|
border-radius: 22px 22px 16px 16px;
|
||||||
|
background: var(--card-bg);
|
||||||
|
box-shadow: 0 18px 46px rgba(38, 35, 31, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-panel__head {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 16px;
|
||||||
|
border-bottom: 1px solid var(--border);
|
||||||
|
background: var(--card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-panel__head h2 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-panel__close {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--subtle);
|
||||||
|
color: #514b44;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-panel__footer {
|
||||||
|
position: sticky;
|
||||||
|
bottom: 0;
|
||||||
|
padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
background: var(--card-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-host {
|
||||||
|
position: fixed;
|
||||||
|
top: calc(16px + env(safe-area-inset-top));
|
||||||
|
left: 50%;
|
||||||
|
z-index: 80;
|
||||||
|
max-width: min(88vw, 420px);
|
||||||
|
transform: translateX(-50%);
|
||||||
|
padding: 10px 14px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(38, 35, 31, 0.92);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
text-align: center;
|
||||||
|
box-shadow: 0 10px 28px rgba(38, 35, 31, 0.16);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-host--success {
|
||||||
|
background: rgba(47, 111, 98, 0.94);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-host--error {
|
||||||
|
background: rgba(196, 95, 95, 0.94);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-fade-enter-active,
|
||||||
|
.toast-fade-leave-active,
|
||||||
|
.modal-fade-enter-active,
|
||||||
|
.modal-fade-leave-active {
|
||||||
|
transition: opacity 0.18s ease, transform 0.18s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-fade-enter-from,
|
||||||
|
.toast-fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translate(-50%, -8px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-fade-enter-from,
|
||||||
|
.modal-fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 720px) {
|
||||||
|
body {
|
||||||
|
background:
|
||||||
|
linear-gradient(90deg, rgba(240, 236, 229, 0.72), rgba(248, 245, 239, 0.96)),
|
||||||
|
var(--page-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.mobile-shell {
|
||||||
|
width: 520px;
|
||||||
|
margin: 0 auto;
|
||||||
|
box-shadow: 0 0 0 1px rgba(50, 43, 34, 0.04), 0 24px 80px rgba(58, 48, 34, 0.12);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
export type IdType = string | number
|
||||||
|
|
||||||
|
export interface PageResult<T> {
|
||||||
|
list: T[]
|
||||||
|
total: number
|
||||||
|
page?: number
|
||||||
|
size?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApiResult<T> {
|
||||||
|
code: number
|
||||||
|
message?: string
|
||||||
|
data: T
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserInfo {
|
||||||
|
id: IdType
|
||||||
|
account?: string
|
||||||
|
nickname?: string
|
||||||
|
phone?: string
|
||||||
|
contactPhone?: string
|
||||||
|
avatar?: string
|
||||||
|
wechatId?: string
|
||||||
|
signature?: string
|
||||||
|
type?: number
|
||||||
|
shopId?: IdType
|
||||||
|
shopName?: string
|
||||||
|
shopIds?: IdType[]
|
||||||
|
shopNames?: string[]
|
||||||
|
permissions?: string[]
|
||||||
|
createTime?: string
|
||||||
|
updateTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoginResponse {
|
||||||
|
accessToken: string
|
||||||
|
refreshToken: string
|
||||||
|
userInfo: UserInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoginShop {
|
||||||
|
id: IdType
|
||||||
|
shopName?: string
|
||||||
|
name?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LoginShopSelectionResponse {
|
||||||
|
allowShoplessLogin?: boolean
|
||||||
|
message?: string
|
||||||
|
shops: LoginShop[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LegalAgreement {
|
||||||
|
id: IdType
|
||||||
|
agreementType: 'USER_TERMS' | 'PRIVACY_POLICY'
|
||||||
|
agreementTypeName?: string
|
||||||
|
title: string
|
||||||
|
version: string
|
||||||
|
content: string
|
||||||
|
status?: number
|
||||||
|
effectiveTime?: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,177 @@
|
|||||||
|
import type { IdType, PageResult, UserInfo } from '@/types/common'
|
||||||
|
|
||||||
|
export interface Artist {
|
||||||
|
id: IdType
|
||||||
|
userId?: IdType
|
||||||
|
name: string
|
||||||
|
nickname?: string
|
||||||
|
phone?: string
|
||||||
|
color?: string
|
||||||
|
shortName?: string
|
||||||
|
avatar?: string
|
||||||
|
level?: string
|
||||||
|
enabled?: number
|
||||||
|
status?: number
|
||||||
|
description?: string
|
||||||
|
rangeCount?: number
|
||||||
|
shopId?: IdType
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Product {
|
||||||
|
id: IdType
|
||||||
|
title: string
|
||||||
|
price?: number | string
|
||||||
|
approximateDuration?: string
|
||||||
|
serviceDurationMinutes?: number
|
||||||
|
description?: string
|
||||||
|
imageUrls?: string[]
|
||||||
|
bookableArtists?: string
|
||||||
|
tags?: string
|
||||||
|
tagList?: string[]
|
||||||
|
tagInfos?: Array<{ tagName?: string }>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Appointment {
|
||||||
|
orderId?: IdType
|
||||||
|
orderItemId: IdType
|
||||||
|
customerUserId?: IdType
|
||||||
|
customerName?: string
|
||||||
|
customerPhone?: string
|
||||||
|
phone?: string
|
||||||
|
artistId?: IdType
|
||||||
|
artistName?: string
|
||||||
|
productId?: IdType
|
||||||
|
productTitle?: string
|
||||||
|
startTime?: string
|
||||||
|
endTime?: string
|
||||||
|
startMinute?: number
|
||||||
|
endMinute?: number
|
||||||
|
durationMinutes?: number
|
||||||
|
date?: string
|
||||||
|
status?: number
|
||||||
|
statusText?: string
|
||||||
|
remark?: string
|
||||||
|
manualProductTitle?: string
|
||||||
|
manualProductPrice?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArtistSchedule {
|
||||||
|
id?: IdType
|
||||||
|
artistId: IdType
|
||||||
|
date: string
|
||||||
|
startTime: string
|
||||||
|
endTime: string
|
||||||
|
status: number
|
||||||
|
capacity?: number
|
||||||
|
shopId?: IdType
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArtistScheduleRuleSetting {
|
||||||
|
rule?: ArtistScheduleRule
|
||||||
|
exceptions?: ArtistScheduleException[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArtistScheduleRule {
|
||||||
|
id?: IdType
|
||||||
|
artistId: IdType
|
||||||
|
shopId?: IdType
|
||||||
|
workDays: string
|
||||||
|
startTime: string
|
||||||
|
endTime: string
|
||||||
|
enabled?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ArtistScheduleException {
|
||||||
|
id?: IdType
|
||||||
|
artistId: IdType
|
||||||
|
shopId?: IdType
|
||||||
|
workDate: string
|
||||||
|
startTime?: string
|
||||||
|
endTime?: string
|
||||||
|
status: number
|
||||||
|
reason?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DaySummary {
|
||||||
|
date: string
|
||||||
|
totalCount: number
|
||||||
|
dayStatus?: string
|
||||||
|
artistCounts?: Array<{
|
||||||
|
artistId: IdType
|
||||||
|
artistName?: string
|
||||||
|
shortName?: string
|
||||||
|
color?: string
|
||||||
|
count: number
|
||||||
|
status?: string
|
||||||
|
}>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlanningCalendar {
|
||||||
|
businessStartTime?: string
|
||||||
|
businessEndTime?: string
|
||||||
|
artists?: Artist[]
|
||||||
|
appointments?: Appointment[]
|
||||||
|
schedules?: ArtistSchedule[]
|
||||||
|
daySummaries?: DaySummary[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AppointmentForm {
|
||||||
|
customerUserId: string
|
||||||
|
customerName: string
|
||||||
|
phone: string
|
||||||
|
appointmentDate: string
|
||||||
|
appointmentTime: string
|
||||||
|
productId: string
|
||||||
|
manualProductTitle: string
|
||||||
|
manualProductPrice: string
|
||||||
|
manualProductDescription: string
|
||||||
|
manualProductTags: string
|
||||||
|
manualProductTargetAudience: string
|
||||||
|
manualProductPrecautions: string
|
||||||
|
manualProductImageFileIds: string
|
||||||
|
manualProductImageUrl: string
|
||||||
|
durationMinutes: string
|
||||||
|
artistId: string
|
||||||
|
remark: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AppointmentCreateRequest = Omit<Partial<AppointmentForm>, 'durationMinutes' | 'manualProductPrice'> & {
|
||||||
|
customerUserId?: string
|
||||||
|
productId?: string
|
||||||
|
artistId: string
|
||||||
|
durationMinutes: number
|
||||||
|
manualProductPrice?: number
|
||||||
|
clientRequestId: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShopInfo {
|
||||||
|
id: IdType
|
||||||
|
shopName?: string
|
||||||
|
name?: string
|
||||||
|
phone?: string
|
||||||
|
address?: string
|
||||||
|
businessHours?: string
|
||||||
|
startTime?: string
|
||||||
|
endTime?: string
|
||||||
|
description?: string
|
||||||
|
logo?: string
|
||||||
|
imageUrl?: string
|
||||||
|
authorizationExpireTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CustomerCreateRequest {
|
||||||
|
nickname: string
|
||||||
|
phone: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EmployeeCreateRequest {
|
||||||
|
nickname: string
|
||||||
|
phone: string
|
||||||
|
account: string
|
||||||
|
password: string
|
||||||
|
contactPhone?: string
|
||||||
|
wechatId?: string
|
||||||
|
avatar?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type CustomerPage = PageResult<UserInfo>
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import { beforeEach, describe, expect, it } from 'vitest'
|
||||||
|
import { buildDraftKey, readDraftForm, removeDraftForm, writeDraftForm } from '@/utils/appointment-draft'
|
||||||
|
import type { AppointmentForm } from '@/types/manager'
|
||||||
|
import type { UserInfo } from '@/types/common'
|
||||||
|
|
||||||
|
const buildForm = (): AppointmentForm => ({
|
||||||
|
customerUserId: '',
|
||||||
|
customerName: '王女士',
|
||||||
|
phone: '13800138000',
|
||||||
|
appointmentDate: '2026-06-29',
|
||||||
|
appointmentTime: '13:00',
|
||||||
|
productId: '',
|
||||||
|
manualProductTitle: '法式护理',
|
||||||
|
manualProductPrice: '199',
|
||||||
|
manualProductDescription: '',
|
||||||
|
manualProductTags: '',
|
||||||
|
manualProductTargetAudience: '',
|
||||||
|
manualProductPrecautions: '',
|
||||||
|
manualProductImageFileIds: '',
|
||||||
|
manualProductImageUrl: '',
|
||||||
|
durationMinutes: '90',
|
||||||
|
artistId: '7',
|
||||||
|
remark: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('appointment draft storage', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
window.localStorage.clear()
|
||||||
|
window.sessionStorage.clear()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('scopes draft by user and shop', () => {
|
||||||
|
const userInfo: UserInfo = { id: 10, shopId: 20 }
|
||||||
|
|
||||||
|
expect(buildDraftKey(userInfo)).toBe('managerAppointmentDraft:10:20')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('writes, reads and removes draft form', () => {
|
||||||
|
const userInfo: UserInfo = { id: 10, shopId: 20 }
|
||||||
|
const form = buildForm()
|
||||||
|
|
||||||
|
writeDraftForm(userInfo, form)
|
||||||
|
expect(readDraftForm(userInfo)).toEqual(form)
|
||||||
|
|
||||||
|
removeDraftForm(userInfo)
|
||||||
|
expect(readDraftForm(userInfo)).toBeNull()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import type { AppointmentForm } from '@/types/manager'
|
||||||
|
import type { UserInfo } from '@/types/common'
|
||||||
|
import { readJson, removeStorage, writeJson } from '@/utils/storage'
|
||||||
|
|
||||||
|
const DRAFT_STORAGE_PREFIX = 'managerAppointmentDraft'
|
||||||
|
|
||||||
|
export const buildDraftKey = (userInfo: UserInfo | null): string => {
|
||||||
|
return `${DRAFT_STORAGE_PREFIX}:${userInfo?.id || 'guest'}:${userInfo?.shopId || 'default'}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export const readDraftForm = (userInfo: UserInfo | null): AppointmentForm | null => {
|
||||||
|
const draft = readJson<{ form?: AppointmentForm } | null>(buildDraftKey(userInfo), null)
|
||||||
|
return draft?.form || null
|
||||||
|
}
|
||||||
|
|
||||||
|
export const writeDraftForm = (userInfo: UserInfo | null, form: AppointmentForm): void => {
|
||||||
|
writeJson(buildDraftKey(userInfo), { form, savedAt: Date.now() })
|
||||||
|
}
|
||||||
|
|
||||||
|
export const removeDraftForm = (userInfo: UserInfo | null): void => {
|
||||||
|
removeStorage(buildDraftKey(userInfo))
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { buildAvailableTimeGroups } from '@/utils/available-times'
|
||||||
|
import type { AppointmentForm, PlanningCalendar } from '@/types/manager'
|
||||||
|
|
||||||
|
const buildForm = (): AppointmentForm => ({
|
||||||
|
customerUserId: '',
|
||||||
|
customerName: '王女士',
|
||||||
|
phone: '13800138000',
|
||||||
|
appointmentDate: '2026-06-29',
|
||||||
|
appointmentTime: '',
|
||||||
|
productId: '',
|
||||||
|
manualProductTitle: '基础护理',
|
||||||
|
manualProductPrice: '99',
|
||||||
|
manualProductDescription: '',
|
||||||
|
manualProductTags: '',
|
||||||
|
manualProductTargetAudience: '',
|
||||||
|
manualProductPrecautions: '',
|
||||||
|
manualProductImageFileIds: '',
|
||||||
|
manualProductImageUrl: '',
|
||||||
|
durationMinutes: '60',
|
||||||
|
artistId: '1',
|
||||||
|
remark: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('available time groups', () => {
|
||||||
|
it('builds slots from active schedules and removes busy conflicts', () => {
|
||||||
|
const calendar: PlanningCalendar = {
|
||||||
|
schedules: [
|
||||||
|
{ artistId: 1, date: '2026-06-29', startTime: '10:00', endTime: '12:45', status: 1 },
|
||||||
|
{ artistId: 2, date: '2026-06-29', startTime: '10:00', endTime: '12:00', status: 1 },
|
||||||
|
{ artistId: 1, date: '2026-06-30', startTime: '10:00', endTime: '12:00', status: 1 }
|
||||||
|
],
|
||||||
|
appointments: [
|
||||||
|
{ orderItemId: 100, artistId: 1, date: '2026-06-29', startTime: '2026-06-29 10:30:00', endTime: '2026-06-29 11:30:00', status: 1 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
const groups = buildAvailableTimeGroups(calendar, buildForm())
|
||||||
|
|
||||||
|
expect(groups).toHaveLength(1)
|
||||||
|
expect(groups[0]?.key).toBe('morning')
|
||||||
|
expect(groups[0]?.times.map(item => item.value)).toEqual(['11:30', '11:45'])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('ignores cancelled appointments', () => {
|
||||||
|
const calendar: PlanningCalendar = {
|
||||||
|
schedules: [{ artistId: 1, date: '2026-06-29', startTime: '10:00', endTime: '11:00', status: 1 }],
|
||||||
|
appointments: [{ orderItemId: 100, artistId: 1, date: '2026-06-29', startTime: '2026-06-29 10:00:00', endTime: '2026-06-29 11:00:00', status: 3 }]
|
||||||
|
}
|
||||||
|
|
||||||
|
const groups = buildAvailableTimeGroups(calendar, buildForm())
|
||||||
|
|
||||||
|
expect(groups[0]?.times.map(item => item.value)).toEqual(['10:00'])
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import type { Appointment, AppointmentForm, ArtistSchedule, PlanningCalendar } from '@/types/manager'
|
||||||
|
import { extractTimeText, normalizeDuration, resolveAppointmentDate, resolveAppointmentEndMinute, resolveAppointmentStartMinute } from '@/utils/planning'
|
||||||
|
import { minutesOfDay, timeFromMinutes } from '@/utils/date'
|
||||||
|
|
||||||
|
const TIME_SLOT_MINUTES = 15
|
||||||
|
|
||||||
|
export interface AvailableTime {
|
||||||
|
value: string
|
||||||
|
rangeText: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AvailableTimeGroup {
|
||||||
|
key: string
|
||||||
|
title: string
|
||||||
|
times: AvailableTime[]
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildTimeRangeLabel = (startMinute: number, durationMinutes: number): string => {
|
||||||
|
return `${timeFromMinutes(startMinute)}-${timeFromMinutes(startMinute + durationMinutes)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const getTimePeriod = (minute: number): { key: string; title: string } => {
|
||||||
|
if (minute < 12 * 60) {
|
||||||
|
return { key: 'morning', title: '上午' }
|
||||||
|
}
|
||||||
|
if (minute < 18 * 60) {
|
||||||
|
return { key: 'afternoon', title: '下午' }
|
||||||
|
}
|
||||||
|
return { key: 'evening', title: '晚上' }
|
||||||
|
}
|
||||||
|
|
||||||
|
const isCancelledAppointment = (item: Appointment): boolean => item.status === 3 || item.statusText === '已取消'
|
||||||
|
|
||||||
|
const buildBusyRanges = (appointments: Appointment[], form: AppointmentForm): Array<{ startMinute: number; endMinute: number }> => {
|
||||||
|
return appointments
|
||||||
|
.filter(item => String(item.artistId) === String(form.artistId))
|
||||||
|
.filter(item => resolveAppointmentDate(item) === form.appointmentDate)
|
||||||
|
.filter(item => !isCancelledAppointment(item))
|
||||||
|
.map(item => {
|
||||||
|
const startMinute = resolveAppointmentStartMinute(item)
|
||||||
|
return { startMinute, endMinute: resolveAppointmentEndMinute(item, startMinute) }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasBusyConflict = (startMinute: number, endMinute: number, ranges: Array<{ startMinute: number; endMinute: number }>): boolean => {
|
||||||
|
return ranges.some(range => startMinute < range.endMinute && endMinute > range.startMinute)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildAvailableTimeGroups = (calendar: PlanningCalendar, form: AppointmentForm): AvailableTimeGroup[] => {
|
||||||
|
const durationMinutes = normalizeDuration(form.durationMinutes)
|
||||||
|
if (!durationMinutes) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
const schedules = (calendar.schedules || [])
|
||||||
|
.filter((item: ArtistSchedule) => String(item.artistId) === String(form.artistId))
|
||||||
|
.filter(item => item.date === form.appointmentDate)
|
||||||
|
.filter(item => item.status === 1 && Number(item.capacity === undefined ? 1 : item.capacity) >= 1)
|
||||||
|
const busyRanges = buildBusyRanges(calendar.appointments || [], form)
|
||||||
|
const groupMap: Record<string, AvailableTimeGroup> = {
|
||||||
|
morning: { key: 'morning', title: '上午', times: [] },
|
||||||
|
afternoon: { key: 'afternoon', title: '下午', times: [] },
|
||||||
|
evening: { key: 'evening', title: '晚上', times: [] }
|
||||||
|
}
|
||||||
|
schedules.forEach(schedule => {
|
||||||
|
const scheduleStart = minutesOfDay(extractTimeText(schedule.startTime))
|
||||||
|
const scheduleEnd = minutesOfDay(extractTimeText(schedule.endTime))
|
||||||
|
for (let minute = scheduleStart; minute + durationMinutes <= scheduleEnd; minute += TIME_SLOT_MINUTES) {
|
||||||
|
const endMinute = minute + durationMinutes
|
||||||
|
if (!hasBusyConflict(minute, endMinute, busyRanges)) {
|
||||||
|
const period = getTimePeriod(minute)
|
||||||
|
const group = groupMap[period.key]
|
||||||
|
if (group) {
|
||||||
|
group.times.push({ value: timeFromMinutes(minute), rangeText: buildTimeRangeLabel(minute, durationMinutes) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return Object.values(groupMap)
|
||||||
|
.map(group => ({
|
||||||
|
...group,
|
||||||
|
times: group.times.filter((item, index, array) => array.findIndex(candidate => candidate.value === item.value) === index)
|
||||||
|
}))
|
||||||
|
.filter(group => group.times.length > 0)
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
import { endOfWeek, formatDate, monthGrid, startOfWeek, timeFromMinutes, minutesOfDay } from '@/utils/date'
|
||||||
|
|
||||||
|
describe('date utils', () => {
|
||||||
|
it('uses Monday as the first day of a week', () => {
|
||||||
|
expect(formatDate(startOfWeek('2026-06-28'))).toBe('2026-06-22')
|
||||||
|
expect(formatDate(endOfWeek('2026-06-28'))).toBe('2026-06-28')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('builds a 42-cell month grid with surrounding days', () => {
|
||||||
|
const grid = monthGrid('2026-06-15')
|
||||||
|
|
||||||
|
expect(grid).toHaveLength(42)
|
||||||
|
expect(grid[0]).toEqual({ date: '2026-06-01', day: 1, isCurrentMonth: true })
|
||||||
|
expect(grid[41]).toEqual({ date: '2026-07-12', day: 12, isCurrentMonth: false })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('converts time and minutes symmetrically', () => {
|
||||||
|
expect(minutesOfDay('13:45')).toBe(825)
|
||||||
|
expect(timeFromMinutes(825)).toBe('13:45')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
const pad = (value: number): string => String(value).padStart(2, '0')
|
||||||
|
|
||||||
|
export const toDate = (value: string | Date): Date => {
|
||||||
|
if (value instanceof Date) {
|
||||||
|
return new Date(value.getTime())
|
||||||
|
}
|
||||||
|
return new Date(String(value).replace(/-/g, '/'))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const formatDate = (value: string | Date): string => {
|
||||||
|
const target = toDate(value)
|
||||||
|
return `${target.getFullYear()}-${pad(target.getMonth() + 1)}-${pad(target.getDate())}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export const formatMonth = (value: string | Date): string => {
|
||||||
|
const target = toDate(value)
|
||||||
|
return `${target.getFullYear()}年${target.getMonth() + 1}月`
|
||||||
|
}
|
||||||
|
|
||||||
|
export const formatCnDate = (value: string | Date): string => {
|
||||||
|
const target = toDate(value)
|
||||||
|
return `${target.getMonth() + 1}月${target.getDate()}日`
|
||||||
|
}
|
||||||
|
|
||||||
|
export const addDays = (value: string | Date, days: number): Date => {
|
||||||
|
const target = toDate(value)
|
||||||
|
target.setDate(target.getDate() + days)
|
||||||
|
return target
|
||||||
|
}
|
||||||
|
|
||||||
|
export const addMonths = (value: string | Date, months: number): Date => {
|
||||||
|
const target = toDate(value)
|
||||||
|
target.setMonth(target.getMonth() + months)
|
||||||
|
return target
|
||||||
|
}
|
||||||
|
|
||||||
|
export const startOfWeek = (value: string | Date): Date => {
|
||||||
|
const target = toDate(value)
|
||||||
|
const day = target.getDay() || 7
|
||||||
|
target.setDate(target.getDate() - day + 1)
|
||||||
|
return target
|
||||||
|
}
|
||||||
|
|
||||||
|
export const endOfWeek = (value: string | Date): Date => addDays(startOfWeek(value), 6)
|
||||||
|
|
||||||
|
export const startOfMonth = (value: string | Date): Date => {
|
||||||
|
const target = toDate(value)
|
||||||
|
return new Date(target.getFullYear(), target.getMonth(), 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const endOfMonth = (value: string | Date): Date => {
|
||||||
|
const target = toDate(value)
|
||||||
|
return new Date(target.getFullYear(), target.getMonth() + 1, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const monthGrid = (value: string | Date): Array<{ date: string; day: number; isCurrentMonth: boolean }> => {
|
||||||
|
const first = startOfMonth(value)
|
||||||
|
const startOffset = (first.getDay() || 7) - 1
|
||||||
|
const gridStart = addDays(first, -startOffset)
|
||||||
|
return Array.from({ length: 42 }, (_item, index) => {
|
||||||
|
const current = addDays(gridStart, index)
|
||||||
|
return {
|
||||||
|
date: formatDate(current),
|
||||||
|
day: current.getDate(),
|
||||||
|
isCurrentMonth: current.getMonth() === first.getMonth()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const minutesOfDay = (value: string): number => {
|
||||||
|
const [hour, minute] = String(value || '00:00').split(':').map(Number)
|
||||||
|
return (hour || 0) * 60 + (minute || 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const timeFromMinutes = (minutes: number): string => {
|
||||||
|
const normalized = ((minutes % (24 * 60)) + 24 * 60) % (24 * 60)
|
||||||
|
return `${pad(Math.floor(normalized / 60))}:${pad(normalized % 60)}`
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import type { UserInfo } from '@/types/common'
|
||||||
|
|
||||||
|
export const canCreateAppointment = (userInfo: UserInfo | null): boolean => Number(userInfo?.type) !== 3
|
||||||
|
|
||||||
|
export const resolveRoleText = (type: number | undefined): string => {
|
||||||
|
const role = Number(type)
|
||||||
|
if (role === 4) {
|
||||||
|
return '平台管理员'
|
||||||
|
}
|
||||||
|
if (role === 3) {
|
||||||
|
return '美甲师'
|
||||||
|
}
|
||||||
|
if (role === 2) {
|
||||||
|
return '店长'
|
||||||
|
}
|
||||||
|
return '客户'
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import type { Appointment, Artist, DaySummary, PlanningCalendar } from '@/types/manager'
|
||||||
|
import { minutesOfDay, timeFromMinutes } from '@/utils/date'
|
||||||
|
|
||||||
|
export const resolveAppointmentDate = (item: Appointment): string => {
|
||||||
|
if (item.date) {
|
||||||
|
return item.date
|
||||||
|
}
|
||||||
|
return String(item.startTime || '').slice(0, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const extractTimeText = (value: string | undefined): string => {
|
||||||
|
const target = String(value || '')
|
||||||
|
if (target.includes('T') || target.includes(' ')) {
|
||||||
|
return target.slice(11, 16)
|
||||||
|
}
|
||||||
|
return target.slice(0, 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const resolveAppointmentStartMinute = (item: Appointment): number => {
|
||||||
|
if (item.startMinute !== undefined && item.startMinute !== null) {
|
||||||
|
return Number(item.startMinute)
|
||||||
|
}
|
||||||
|
return minutesOfDay(extractTimeText(item.startTime))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const resolveAppointmentEndMinute = (item: Appointment, startMinute: number): number => {
|
||||||
|
if (item.endMinute !== undefined && item.endMinute !== null) {
|
||||||
|
return Number(item.endMinute)
|
||||||
|
}
|
||||||
|
if (item.endTime) {
|
||||||
|
return minutesOfDay(extractTimeText(item.endTime))
|
||||||
|
}
|
||||||
|
return startMinute + Number(item.durationMinutes || 60)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const resolveAppointmentTimeText = (item: Appointment): string => {
|
||||||
|
const startMinute = resolveAppointmentStartMinute(item)
|
||||||
|
const duration = Number(item.durationMinutes || 60)
|
||||||
|
const startText = extractTimeText(item.startTime) || timeFromMinutes(startMinute)
|
||||||
|
const endText = extractTimeText(item.endTime) || timeFromMinutes(startMinute + duration)
|
||||||
|
return `${startText}-${endText}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export const summaryMap = (daySummaries: DaySummary[]): Record<string, DaySummary> => {
|
||||||
|
return daySummaries.reduce<Record<string, DaySummary>>((result, item) => {
|
||||||
|
result[item.date] = item
|
||||||
|
return result
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getCalendarArtists = (calendar: PlanningCalendar): Artist[] => Array.isArray(calendar.artists) ? calendar.artists : []
|
||||||
|
|
||||||
|
export const normalizeDuration = (value: string | number): number => {
|
||||||
|
const duration = Number(value)
|
||||||
|
return Number.isFinite(duration) && duration > 0 ? Math.floor(duration) : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
export const buildClientRequestId = (prefix: string): string => {
|
||||||
|
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
import type { InternalAxiosRequestConfig } from 'axios'
|
||||||
|
import { attachRequestSignature } from '@/utils/request-signature'
|
||||||
|
|
||||||
|
const buildConfig = (): InternalAxiosRequestConfig => ({
|
||||||
|
headers: {},
|
||||||
|
method: 'post',
|
||||||
|
baseURL: '/admin/api',
|
||||||
|
url: '/manager/planning/appointments',
|
||||||
|
params: { b: 2, a: 1 },
|
||||||
|
data: { name: 'test' }
|
||||||
|
} as InternalAxiosRequestConfig)
|
||||||
|
|
||||||
|
describe('request signature', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
window.localStorage.clear()
|
||||||
|
vi.restoreAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('adds device and signature headers for protected unsafe requests', async () => {
|
||||||
|
vi.spyOn(Date, 'now').mockReturnValue(1_789_999_999_000)
|
||||||
|
vi.spyOn(crypto, 'randomUUID').mockReturnValue('00000000-0000-4000-8000-000000000001')
|
||||||
|
vi.spyOn(crypto, 'getRandomValues').mockImplementation(array => {
|
||||||
|
const values = array as Uint32Array
|
||||||
|
values[0] = 10
|
||||||
|
values[1] = 20
|
||||||
|
return array
|
||||||
|
})
|
||||||
|
|
||||||
|
const config = await attachRequestSignature(buildConfig(), 'token-secret', { authFree: false })
|
||||||
|
|
||||||
|
expect(config.headers['X-Device-Id']).toBe('00000000-0000-4000-8000-000000000001')
|
||||||
|
expect(config.headers['X-Timestamp']).toBe('1789999999000')
|
||||||
|
expect(config.headers['X-Nonce']).toBe('1789999999000-00000000-0000-4000-8000-000000000001-ak')
|
||||||
|
expect(config.headers['X-Sign-Version']).toBe('v1')
|
||||||
|
expect(String(config.headers['X-Signature'])).toHaveLength(64)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('skips signature for auth-free requests but still attaches device id', async () => {
|
||||||
|
vi.spyOn(crypto, 'randomUUID').mockReturnValue('00000000-0000-4000-8000-000000000001')
|
||||||
|
|
||||||
|
const config = await attachRequestSignature(buildConfig(), 'token-secret', { authFree: true })
|
||||||
|
|
||||||
|
expect(config.headers['X-Device-Id']).toBe('00000000-0000-4000-8000-000000000001')
|
||||||
|
expect(config.headers['X-Signature']).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
import type { InternalAxiosRequestConfig } from 'axios'
|
||||||
|
|
||||||
|
const HEADER_TIMESTAMP = 'X-Timestamp'
|
||||||
|
const HEADER_NONCE = 'X-Nonce'
|
||||||
|
const HEADER_SIGNATURE = 'X-Signature'
|
||||||
|
const HEADER_SIGNATURE_VERSION = 'X-Sign-Version'
|
||||||
|
const DEVICE_ID_HEADER = 'X-Device-Id'
|
||||||
|
const DEVICE_ID_STORAGE_KEY = 'fingertip_manager_web_device_id'
|
||||||
|
const SIGNATURE_VERSION = 'v1'
|
||||||
|
|
||||||
|
type HeaderContainer = Record<string, unknown>
|
||||||
|
|
||||||
|
export interface RequestSignatureOptions {
|
||||||
|
authFree: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const isSafeMethod = (method: string): boolean => ['GET', 'HEAD', 'OPTIONS'].includes(method.toUpperCase())
|
||||||
|
|
||||||
|
const toHex = (bytes: ArrayBuffer): string => {
|
||||||
|
return Array.from(new Uint8Array(bytes)).map(value => value.toString(16).padStart(2, '0')).join('')
|
||||||
|
}
|
||||||
|
|
||||||
|
const sha256Hex = async (message: string): Promise<string> => {
|
||||||
|
const bytes = new TextEncoder().encode(message)
|
||||||
|
const digest = await crypto.subtle.digest('SHA-256', bytes)
|
||||||
|
return toHex(digest)
|
||||||
|
}
|
||||||
|
|
||||||
|
const hmacSha256Hex = async (secret: string, message: string): Promise<string> => {
|
||||||
|
const key = await crypto.subtle.importKey(
|
||||||
|
'raw',
|
||||||
|
new TextEncoder().encode(secret),
|
||||||
|
{ name: 'HMAC', hash: 'SHA-256' },
|
||||||
|
false,
|
||||||
|
['sign']
|
||||||
|
)
|
||||||
|
const signature = await crypto.subtle.sign('HMAC', key, new TextEncoder().encode(message))
|
||||||
|
return toHex(signature)
|
||||||
|
}
|
||||||
|
|
||||||
|
const randomNonce = (deviceId: string): string => {
|
||||||
|
const randomPart = crypto.getRandomValues(new Uint32Array(2))
|
||||||
|
const [first = 0, second = 0] = randomPart
|
||||||
|
return `${Date.now()}-${deviceId}-${first.toString(36)}${second.toString(36)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
const getDeviceId = (): string => {
|
||||||
|
const existing = window.localStorage.getItem(DEVICE_ID_STORAGE_KEY)
|
||||||
|
if (existing) {
|
||||||
|
return existing
|
||||||
|
}
|
||||||
|
const generated = crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random().toString(36).slice(2)}`
|
||||||
|
window.localStorage.setItem(DEVICE_ID_STORAGE_KEY, generated)
|
||||||
|
return generated
|
||||||
|
}
|
||||||
|
|
||||||
|
const setHeader = (headers: HeaderContainer, key: string, value: string): void => {
|
||||||
|
headers[key] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
const extractPath = (value: string): string => {
|
||||||
|
const target = String(value || '')
|
||||||
|
if (!target) {
|
||||||
|
return '/'
|
||||||
|
}
|
||||||
|
if (/^[a-z][a-z\d+\-.]*:\/\//i.test(target)) {
|
||||||
|
const parsed = new URL(target)
|
||||||
|
return parsed.pathname || '/'
|
||||||
|
}
|
||||||
|
return target.split('?')[0] || '/'
|
||||||
|
}
|
||||||
|
|
||||||
|
const toBackendRequestPath = (config: InternalAxiosRequestConfig): string => {
|
||||||
|
const baseURL = String(config.baseURL || '')
|
||||||
|
const url = String(config.url || '')
|
||||||
|
const basePath = extractPath(baseURL).replace(/\/+$/, '')
|
||||||
|
const urlPath = extractPath(url)
|
||||||
|
return `${basePath}${urlPath.startsWith('/') ? urlPath : `/${urlPath}`}`.replace(/^\/admin\/api/, '/admin')
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildCanonicalParams = (params: unknown): string => {
|
||||||
|
if (!params || typeof params !== 'object') {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
return Object.entries(params as Record<string, unknown>)
|
||||||
|
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
||||||
|
.sort(([left], [right]) => left.localeCompare(right))
|
||||||
|
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
|
||||||
|
.join('&')
|
||||||
|
}
|
||||||
|
|
||||||
|
const buildJsonPayload = (data: unknown): string => {
|
||||||
|
if (data === undefined || data === null || data instanceof FormData) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return JSON.stringify(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const attachRequestSignature = async (
|
||||||
|
config: InternalAxiosRequestConfig,
|
||||||
|
accessToken: string,
|
||||||
|
options: RequestSignatureOptions
|
||||||
|
): Promise<InternalAxiosRequestConfig> => {
|
||||||
|
config.headers = config.headers || {}
|
||||||
|
const headers = config.headers as HeaderContainer
|
||||||
|
const deviceId = getDeviceId()
|
||||||
|
setHeader(headers, DEVICE_ID_HEADER, deviceId)
|
||||||
|
const method = String(config.method || 'GET').toUpperCase()
|
||||||
|
if (options.authFree || !accessToken || isSafeMethod(method)) {
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
const timestamp = String(Date.now())
|
||||||
|
const nonce = randomNonce(deviceId)
|
||||||
|
const payload = buildJsonPayload(config.data)
|
||||||
|
const canonical = [
|
||||||
|
method,
|
||||||
|
toBackendRequestPath(config),
|
||||||
|
buildCanonicalParams(config.params),
|
||||||
|
await sha256Hex(payload),
|
||||||
|
timestamp,
|
||||||
|
nonce
|
||||||
|
].join('\n')
|
||||||
|
setHeader(headers, HEADER_TIMESTAMP, timestamp)
|
||||||
|
setHeader(headers, HEADER_NONCE, nonce)
|
||||||
|
setHeader(headers, HEADER_SIGNATURE_VERSION, SIGNATURE_VERSION)
|
||||||
|
setHeader(headers, HEADER_SIGNATURE, await hmacSha256Hex(accessToken, canonical))
|
||||||
|
return config
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
export const readJson = <T>(key: string, fallbackValue: T): T => {
|
||||||
|
const raw = window.localStorage.getItem(key)
|
||||||
|
if (!raw) {
|
||||||
|
return fallbackValue
|
||||||
|
}
|
||||||
|
return JSON.parse(raw) as T
|
||||||
|
}
|
||||||
|
|
||||||
|
export const writeJson = <T>(key: string, value: T): void => {
|
||||||
|
window.localStorage.setItem(key, JSON.stringify(value))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const removeStorage = (key: string): void => {
|
||||||
|
window.localStorage.removeItem(key)
|
||||||
|
window.sessionStorage.removeItem(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
const PLANNING_REFRESH_KEY = 'planningNeedRefresh'
|
||||||
|
|
||||||
|
export const markPlanningRefresh = (): void => {
|
||||||
|
window.localStorage.setItem(PLANNING_REFRESH_KEY, '1')
|
||||||
|
}
|
||||||
|
|
||||||
|
export const consumePlanningRefresh = (): boolean => {
|
||||||
|
const marked = window.localStorage.getItem(PLANNING_REFRESH_KEY) === '1'
|
||||||
|
if (marked) {
|
||||||
|
window.localStorage.removeItem(PLANNING_REFRESH_KEY)
|
||||||
|
}
|
||||||
|
return marked
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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="甲屿店务" />
|
||||||
|
<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 = 'fingertip_manager_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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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="例如:甲屿设计师" />
|
||||||
|
</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>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
},
|
||||||
|
"types": ["vite/client"],
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true
|
||||||
|
},
|
||||||
|
"include": ["src/**/*.ts", "src/**/*.vue"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{ "path": "./tsconfig.app.json" },
|
||||||
|
{ "path": "./tsconfig.node.json" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
"target": "ES2023",
|
||||||
|
"lib": ["ES2023"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"types": ["node"],
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"noEmit": true,
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true
|
||||||
|
},
|
||||||
|
"include": ["vite.config.ts", "vitest.config.ts"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { defineConfig, loadEnv } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import path from 'node:path'
|
||||||
|
|
||||||
|
export default defineConfig(({ mode }) => {
|
||||||
|
const env = loadEnv(mode, process.cwd(), '')
|
||||||
|
const proxyTarget = String(env.VITE_DEV_PROXY_TARGET || 'http://127.0.0.1:80').trim()
|
||||||
|
const proxyToCoreDirectly = /(^|:)81(\/|$)/.test(proxyTarget)
|
||||||
|
|
||||||
|
return {
|
||||||
|
base: '/fm-front/',
|
||||||
|
plugins: [vue()],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': path.resolve(__dirname, './src')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
port: 3001,
|
||||||
|
host: true,
|
||||||
|
proxy: {
|
||||||
|
'/admin/api': {
|
||||||
|
target: proxyTarget,
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: targetPath => proxyToCoreDirectly ? targetPath.replace(/^\/admin\/api/, '/admin') : targetPath
|
||||||
|
},
|
||||||
|
'/api': {
|
||||||
|
target: proxyTarget,
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: targetPath => proxyToCoreDirectly ? targetPath.replace(/^\/api/, '') : targetPath
|
||||||
|
}
|
||||||
|
},
|
||||||
|
allowedHosts: ['localhost', '127.0.0.1', '2666.online', 'wcy111.top']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { defineConfig } from 'vitest/config'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import path from 'node:path'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [vue()],
|
||||||
|
test: {
|
||||||
|
environment: 'jsdom',
|
||||||
|
globals: true
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': path.resolve(__dirname, './src')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
# FM-Front 移动端发布配置说明
|
||||||
|
|
||||||
|
更新时间:2026-06-29
|
||||||
|
|
||||||
|
## 访问路径
|
||||||
|
|
||||||
|
`FM-Front` 是管理师移动端 Web 模块,生产访问路径固定为:
|
||||||
|
|
||||||
|
```text
|
||||||
|
https://yunail.art/fm-front/
|
||||||
|
```
|
||||||
|
|
||||||
|
Vite `base` 固定为 `/fm-front/`,不能部署到域名根路径,否则静态资源路径会不匹配。
|
||||||
|
|
||||||
|
## 构建产物
|
||||||
|
|
||||||
|
`FM-Front` 独立执行:
|
||||||
|
|
||||||
|
```text
|
||||||
|
npm ci
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
构建产物目录为:
|
||||||
|
|
||||||
|
```text
|
||||||
|
FM-Front/dist
|
||||||
|
```
|
||||||
|
|
||||||
|
`scripts/package-release.ps1` 会先构建 `FD-Frontend`,再构建 `FM-Front`,发布包内包含:
|
||||||
|
|
||||||
|
```text
|
||||||
|
frontend/dist
|
||||||
|
frontend/dist/fm-front
|
||||||
|
frontend/fm-front-dist
|
||||||
|
```
|
||||||
|
|
||||||
|
其中 `frontend/dist/fm-front` 用于与现有 Web 前端一起部署,`frontend/fm-front-dist` 用于人工核查和独立备份。
|
||||||
|
|
||||||
|
## 生产部署目录
|
||||||
|
|
||||||
|
`scripts/deploy-fingertip-designer-production.ps1` 会把 `FD-Frontend/dist` 与 `FM-Front/dist` 合并为同一个 Web tar 包:
|
||||||
|
|
||||||
|
```text
|
||||||
|
dist/
|
||||||
|
dist/fm-front/
|
||||||
|
```
|
||||||
|
|
||||||
|
远端 Web 发布目录沿用:
|
||||||
|
|
||||||
|
```text
|
||||||
|
/opt/fingertip-designer-frontend
|
||||||
|
```
|
||||||
|
|
||||||
|
脚本解压后仍使用现有软链:
|
||||||
|
|
||||||
|
```text
|
||||||
|
/opt/fingertip-designer-frontend/current -> releases/{timestamp}/dist
|
||||||
|
```
|
||||||
|
|
||||||
|
因此 `/fm-front/` 实际对应:
|
||||||
|
|
||||||
|
```text
|
||||||
|
/opt/fingertip-designer-frontend/current/fm-front/
|
||||||
|
```
|
||||||
|
|
||||||
|
## 接口与鉴权
|
||||||
|
|
||||||
|
移动端 Web 复用现有后端接口,不新增后端配置:
|
||||||
|
|
||||||
|
```text
|
||||||
|
/admin/api
|
||||||
|
/api
|
||||||
|
```
|
||||||
|
|
||||||
|
请求签名、设备 ID、本地会话和鉴权刷新逻辑由 `FM-Front/src/api` 与 `FM-Front/src/utils/request-signature.ts` 维护。
|
||||||
|
|
||||||
|
## 回滚注意事项
|
||||||
|
|
||||||
|
回滚 Web 版本时,回滚单位是整个 Web `current` 软链;`FD-Frontend` 与 `FM-Front` 会一起回到上一个 Web 发布版本。
|
||||||
|
|
||||||
|
如只需临时下线移动端,可以在当前 Web 目录中移除 `fm-front` 子目录,但下一次发布会重新生成。
|
||||||
|
|
||||||
|
## 验证方式
|
||||||
|
|
||||||
|
发布前至少执行:
|
||||||
|
|
||||||
|
```text
|
||||||
|
cd FM-Front
|
||||||
|
npm ci
|
||||||
|
npm run test:unit
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
生产发布脚本的公开冒烟会检查:
|
||||||
|
|
||||||
|
```text
|
||||||
|
GET https://yunail.art/health/check
|
||||||
|
GET https://yunail.art/api/shop/list
|
||||||
|
GET https://yunail.art/fm-front/
|
||||||
|
```
|
||||||
@@ -495,12 +495,20 @@ function Build-ReleasePackage {
|
|||||||
Invoke-Native "npm" @("ci") $frontendRoot
|
Invoke-Native "npm" @("ci") $frontendRoot
|
||||||
}
|
}
|
||||||
Invoke-Native "npm" @("run", "build") $frontendRoot
|
Invoke-Native "npm" @("run", "build") $frontendRoot
|
||||||
|
|
||||||
|
Write-Step "构建 FM-Front"
|
||||||
|
$managerMobileRoot = Join-Path $resolvedRepoRoot "FM-Front"
|
||||||
|
if (-not (Test-Path -LiteralPath (Join-Path $managerMobileRoot "node_modules"))) {
|
||||||
|
Invoke-Native "npm" @("ci") $managerMobileRoot
|
||||||
|
}
|
||||||
|
Invoke-Native "npm" @("run", "build") $managerMobileRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
$coreJar = Join-Path $resolvedRepoRoot "FD-Core\target\FingertipDesigner-Core.jar"
|
$coreJar = Join-Path $resolvedRepoRoot "FD-Core\target\FingertipDesigner-Core.jar"
|
||||||
$gatewayJar = Join-Path $resolvedRepoRoot "FD-Gateway\target\FingertipDesigner-Gateway.jar"
|
$gatewayJar = Join-Path $resolvedRepoRoot "FD-Gateway\target\FingertipDesigner-Gateway.jar"
|
||||||
$frontendDist = Join-Path $resolvedRepoRoot "FD-Frontend\dist"
|
$frontendDist = Join-Path $resolvedRepoRoot "FD-Frontend\dist"
|
||||||
foreach ($requiredPath in @($coreJar, $gatewayJar, $frontendDist, $InitSqlPath)) {
|
$managerMobileDist = Join-Path $resolvedRepoRoot "FM-Front\dist"
|
||||||
|
foreach ($requiredPath in @($coreJar, $gatewayJar, $frontendDist, $managerMobileDist, $InitSqlPath)) {
|
||||||
if (-not (Test-Path -LiteralPath $requiredPath)) {
|
if (-not (Test-Path -LiteralPath $requiredPath)) {
|
||||||
throw "缺少发布产物:$requiredPath"
|
throw "缺少发布产物:$requiredPath"
|
||||||
}
|
}
|
||||||
@@ -521,7 +529,17 @@ function Build-ReleasePackage {
|
|||||||
if (Test-Path -LiteralPath $frontendArtifact) {
|
if (Test-Path -LiteralPath $frontendArtifact) {
|
||||||
Remove-Item -LiteralPath $frontendArtifact -Force
|
Remove-Item -LiteralPath $frontendArtifact -Force
|
||||||
}
|
}
|
||||||
Invoke-Native $tar.Source @("-czf", $frontendArtifact, "-C", (Join-Path $resolvedRepoRoot "FD-Frontend"), "dist")
|
$frontendStagingRoot = Join-Path $frontendDir "web-dist"
|
||||||
|
$frontendStagingDist = Join-Path $frontendStagingRoot "dist"
|
||||||
|
$managerMobileStagingDist = Join-Path $frontendStagingDist "fm-front"
|
||||||
|
if (Test-Path -LiteralPath $frontendStagingRoot) {
|
||||||
|
Remove-Item -LiteralPath $frontendStagingRoot -Recurse -Force
|
||||||
|
}
|
||||||
|
New-Item -ItemType Directory -Force -Path $frontendStagingRoot, $managerMobileStagingDist | Out-Null
|
||||||
|
Copy-Item -LiteralPath $frontendDist -Destination $frontendStagingRoot -Recurse -Force
|
||||||
|
Copy-Item -Path (Join-Path $managerMobileDist "*") -Destination $managerMobileStagingDist -Recurse -Force
|
||||||
|
Invoke-Native $tar.Source @("-czf", $frontendArtifact, "-C", $frontendStagingRoot, "dist")
|
||||||
|
Remove-Item -LiteralPath $frontendStagingRoot -Recurse -Force
|
||||||
|
|
||||||
$hashes = foreach ($artifact in @($coreArtifact, $gatewayArtifact, $frontendArtifact, $sqlArtifact)) {
|
$hashes = foreach ($artifact in @($coreArtifact, $gatewayArtifact, $frontendArtifact, $sqlArtifact)) {
|
||||||
$hash = Get-FileHash -LiteralPath $artifact -Algorithm SHA256
|
$hash = Get-FileHash -LiteralPath $artifact -Algorithm SHA256
|
||||||
@@ -750,6 +768,7 @@ function Write-ReleaseManifest {
|
|||||||
gatewayRemoteAppDir = $GatewayRemoteAppDir
|
gatewayRemoteAppDir = $GatewayRemoteAppDir
|
||||||
webRemoteDir = $WebRemoteDir
|
webRemoteDir = $WebRemoteDir
|
||||||
publicBaseUrl = $PublicBaseUrl
|
publicBaseUrl = $PublicBaseUrl
|
||||||
|
managerMobileWeb = "$PublicBaseUrl/fm-front/"
|
||||||
managerMiniProgramApi = "$PublicBaseUrl/api/admin"
|
managerMiniProgramApi = "$PublicBaseUrl/api/admin"
|
||||||
nacosNamespace = "FingertipDesigner"
|
nacosNamespace = "FingertipDesigner"
|
||||||
dryRun = [bool]$DryRun
|
dryRun = [bool]$DryRun
|
||||||
@@ -765,11 +784,12 @@ function Invoke-PublicSmokeTests {
|
|||||||
Write-Host "DryRun public smoke tests:"
|
Write-Host "DryRun public smoke tests:"
|
||||||
Write-Host "GET $PublicBaseUrl/health/check"
|
Write-Host "GET $PublicBaseUrl/health/check"
|
||||||
Write-Host "GET $PublicBaseUrl/api/shop/list"
|
Write-Host "GET $PublicBaseUrl/api/shop/list"
|
||||||
|
Write-Host "GET $PublicBaseUrl/fm-front/"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Step "生产公开冒烟"
|
Write-Step "生产公开冒烟"
|
||||||
foreach ($url in @("$PublicBaseUrl/health/check", "$PublicBaseUrl/api/shop/list")) {
|
foreach ($url in @("$PublicBaseUrl/health/check", "$PublicBaseUrl/api/shop/list", "$PublicBaseUrl/fm-front/")) {
|
||||||
Write-Host "GET $url"
|
Write-Host "GET $url"
|
||||||
$response = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 20
|
$response = Invoke-WebRequest -Uri $url -UseBasicParsing -TimeoutSec 20
|
||||||
Write-Host "Status $($response.StatusCode) Length $($response.RawContentLength)"
|
Write-Host "Status $($response.StatusCode) Length $($response.RawContentLength)"
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function Copy-Directory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
|
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
|
||||||
Copy-Item -LiteralPath $Source -Destination $Destination -Recurse -Force
|
Copy-Item -Path (Join-Path $Source "*") -Destination $Destination -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
function Copy-RequiredFile {
|
function Copy-RequiredFile {
|
||||||
@@ -110,13 +110,23 @@ if (-not (Test-Path -LiteralPath (Join-Path $frontendRoot "node_modules"))) {
|
|||||||
}
|
}
|
||||||
Invoke-Native "npm" @("run", "build") $frontendRoot
|
Invoke-Native "npm" @("run", "build") $frontendRoot
|
||||||
|
|
||||||
|
Write-Step "构建 FM-Front"
|
||||||
|
$managerMobileRoot = Join-Path $repoRoot "FM-Front"
|
||||||
|
if (-not (Test-Path -LiteralPath (Join-Path $managerMobileRoot "node_modules"))) {
|
||||||
|
Invoke-Native "npm" @("ci") $managerMobileRoot
|
||||||
|
}
|
||||||
|
Invoke-Native "npm" @("run", "build") $managerMobileRoot
|
||||||
|
|
||||||
$coreJar = Join-Path $repoRoot "FD-Core\target\FingertipDesigner-Core.jar"
|
$coreJar = Join-Path $repoRoot "FD-Core\target\FingertipDesigner-Core.jar"
|
||||||
$gatewayJar = Join-Path $repoRoot "FD-Gateway\target\FingertipDesigner-Gateway.jar"
|
$gatewayJar = Join-Path $repoRoot "FD-Gateway\target\FingertipDesigner-Gateway.jar"
|
||||||
$frontendDist = Join-Path $frontendRoot "dist"
|
$frontendDist = Join-Path $frontendRoot "dist"
|
||||||
|
$managerMobileDist = Join-Path $managerMobileRoot "dist"
|
||||||
|
|
||||||
Copy-RequiredFile $coreJar (Join-Path $backendDir "FingertipDesigner-Core.jar")
|
Copy-RequiredFile $coreJar (Join-Path $backendDir "FingertipDesigner-Core.jar")
|
||||||
Copy-RequiredFile $gatewayJar (Join-Path $backendDir "FingertipDesigner-Gateway.jar")
|
Copy-RequiredFile $gatewayJar (Join-Path $backendDir "FingertipDesigner-Gateway.jar")
|
||||||
Copy-Directory $frontendDist (Join-Path $frontendDir "dist")
|
Copy-Directory $frontendDist (Join-Path $frontendDir "dist")
|
||||||
|
Copy-Directory $managerMobileDist (Join-Path $frontendDir "fm-front-dist")
|
||||||
|
Copy-Directory $managerMobileDist (Join-Path $frontendDir "dist\fm-front")
|
||||||
Copy-Directory (Join-Path $repoRoot "FD-WeChat-Fronted") (Join-Path $miniProgramDir "FD-WeChat-Fronted")
|
Copy-Directory (Join-Path $repoRoot "FD-WeChat-Fronted") (Join-Path $miniProgramDir "FD-WeChat-Fronted")
|
||||||
Copy-Directory (Join-Path $repoRoot "FM-Wechat-Fronted") (Join-Path $miniProgramDir "FM-Wechat-Fronted")
|
Copy-Directory (Join-Path $repoRoot "FM-Wechat-Fronted") (Join-Path $miniProgramDir "FM-Wechat-Fronted")
|
||||||
Copy-RequiredFile $sqlPath (Join-Path $releaseDir "FingertipDesigner.sql")
|
Copy-RequiredFile $sqlPath (Join-Path $releaseDir "FingertipDesigner.sql")
|
||||||
@@ -127,6 +137,8 @@ $manifest = @(
|
|||||||
"- backend/FingertipDesigner-Core.jar",
|
"- backend/FingertipDesigner-Core.jar",
|
||||||
"- backend/FingertipDesigner-Gateway.jar",
|
"- backend/FingertipDesigner-Gateway.jar",
|
||||||
"- frontend/dist",
|
"- frontend/dist",
|
||||||
|
"- frontend/dist/fm-front",
|
||||||
|
"- frontend/fm-front-dist",
|
||||||
"- miniprograms/FD-WeChat-Fronted",
|
"- miniprograms/FD-WeChat-Fronted",
|
||||||
"- miniprograms/FM-Wechat-Fronted",
|
"- miniprograms/FM-Wechat-Fronted",
|
||||||
"- FingertipDesigner.sql",
|
"- FingertipDesigner.sql",
|
||||||
@@ -134,7 +146,8 @@ $manifest = @(
|
|||||||
"Nacos namespace: FingertipDesigner",
|
"Nacos namespace: FingertipDesigner",
|
||||||
"Database initialized by: scripts/sql/init/FingertipDesigner.sql",
|
"Database initialized by: scripts/sql/init/FingertipDesigner.sql",
|
||||||
"Database name: FingertipDesigner",
|
"Database name: FingertipDesigner",
|
||||||
"Manager mini program API: https://yunail.art/api/admin"
|
"Manager mini program API: https://yunail.art/api/admin",
|
||||||
|
"Manager mobile web: https://yunail.art/fm-front/"
|
||||||
)
|
)
|
||||||
$manifest | Set-Content -Encoding UTF8 (Join-Path $releaseDir "README.md")
|
$manifest | Set-Content -Encoding UTF8 (Join-Path $releaseDir "README.md")
|
||||||
|
|
||||||
|
|||||||