优化预约表单并支持散客预约

This commit is contained in:
2026-10-20 13:29:55 +08:00
parent 4a7bd90088
commit c952a913e8
17 changed files with 1376 additions and 275 deletions
+48 -117
View File
@@ -1,136 +1,67 @@
<view class="page no-tab">
<view class="card form-card">
<view class="field customer-field">
<text class="field-label required">客户姓名</text>
<view class="customer-entry">
<input class="customer-name-input" value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerInput" placeholder="请输入客户姓名" />
<button class="customer-select-btn" catchtap="openCustomerSheet">选择已有客户</button>
</view>
<input class="customer-phone-input" value="{{form.phone}}" data-field="phone" bindinput="onCustomerInput" type="number" maxlength="11" placeholder="手机号(可选)" />
<text wx:if="{{form.customerUserId}}" class="customer-selected-tip">已关联系统客户</text>
<view class="page no-tab appointment-page">
<view class="card form-card style-section">
<view class="section-heading">
<view><text class="section-title-main">美甲款式</text><text class="section-caption">手动输入为主,也可快速选择已有款式</text></view>
<button class="link-action" bindtap="openProductModal">{{form.productId ? '更换款式' : '选择已有款式'}}</button>
</view>
<view class="field">
<text class="field-label required">预约日期</text>
<picker mode="date" value="{{form.appointmentDate}}" bindchange="onDateChange">
<view class="field-value">{{form.appointmentDate}}</view>
</picker>
<view wx:if="{{form.productId}}" class="selected-style-card">
<image wx:if="{{selectedProduct.coverImage}}" class="selected-style-image" src="{{selectedProduct.coverImage}}" mode="aspectFill"></image>
<view class="selected-style-copy"><text class="selected-style-title">{{selectedProduct.title}}</text><text class="selected-style-meta">参考价 {{selectedProductPriceText || '待定'}} · {{selectedProduct.durationText || '时长待定'}}</text></view>
<button class="switch-manual-action" bindtap="openManualProduct">手动录入</button>
</view>
<view class="field product-field" bindtap="openProductModal">
<text class="field-label required" bindtap="openProductModal">预约作品</text>
<button class="field-value product-value product-picker-button" bindtap="openProductModal">
<view><text>{{selectedProduct.title || form.manualProductTitle || '请选择预约作品'}}</text><text wx:if="{{selectedProductPriceText || form.manualProductPrice}}" class="product-selected-price">{{selectedProductPriceText || ('¥' + form.manualProductPrice)}}</text></view>
<text wx:if="{{form.manualProductTitle && !form.productId}}" class="manual-badge">手动</text>
</button>
<view wx:else class="style-name-row">
<input class="style-name-input" value="{{form.manualProductTitle}}" bindinput="onStyleTitleInput" placeholder="款式名称(选填)" />
<button class="image-action" bindtap="chooseManualProductImage" loading="{{manualImageUploading}}">{{form.manualProductImageUrl ? '更换图片' : '添加图片'}}</button>
</view>
<view class="field">
<text class="field-label required">预计时长</text>
<input value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" type="number" placeholder="请输入预约时长" />
<text class="unit">分钟</text>
<view wx:if="{{!form.productId && form.manualProductImageUrl}}" class="style-image-preview-row">
<image class="style-image-preview" src="{{form.manualProductImageUrl}}" mode="aspectFill"></image>
<button class="remove-image-action" bindtap="removeManualProductImage">移除图片</button>
</view>
<view class="field">
<text class="field-label">员工(可稍后分配)</text>
<view class="field-value reference-value" bindtap="openArtistSheet">
<text>{{selectedArtist.name || '暂不分配'}}</text>
<text class="reference-arrow">›</text>
</view>
</view>
<view class="field">
<text class="field-label required">预约时间</text>
<view class="field-value time-value {{form.appointmentTime ? '' : 'placeholder'}}" bindtap="openTimeSheet">
<view>
<text>{{form.appointmentTime || timeSelectTip}}</text>
<text wx:if="{{form.appointmentTime}}" class="time-range">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text>
</view>
<text class="time-arrow">›</text>
</view>
</view>
<view class="field textarea-field">
<text class="field-label">备注</text>
<textarea value="{{form.remark}}" data-field="remark" bindinput="onInput" placeholder="客户偏好、款式说明" />
<view class="style-number-row">
<view class="number-field"><text class="field-label required">成交金额</text><input type="digit" value="{{form.amount}}" data-field="amount" bindinput="onInput" placeholder="请输入实际金额" /><text class="number-unit">元</text></view>
<view class="number-field"><text class="field-label required">预计时长</text><input type="number" value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" placeholder="60" /><text class="number-unit">分钟</text></view>
</view>
<view class="style-remark-field"><text class="field-label">款式备注</text><textarea value="{{form.remark}}" data-field="remark" bindinput="onInput" placeholder="客户偏好、款式说明(选填)" /></view>
<text class="style-hint">名称和图片至少填写一项;名称为空时会使用客户姓名或“散客款式”。</text>
</view>
<view class="capacity-tip card">
<text class="tip-title">容量校验</text>
<text class="tip-text">已指定员工时会校验排班和冲突;暂不分配时只校验营业时间,后续分配时再完整校验。</text>
<view class="card form-card appointment-info-section">
<view class="section-heading"><view><text class="section-title-main">预约信息</text><text class="section-caption">时间默认使用滚轮选择</text></view></view>
<view class="field"><text class="field-label required">预约日期</text><picker mode="date" value="{{form.appointmentDate}}" bindchange="onDateChange"><view class="field-value">{{form.appointmentDate}}</view></picker></view>
<view class="field"><text class="field-label required">预约时间</text><view class="field-value time-value {{form.appointmentTime ? '' : 'placeholder'}}" bindtap="openTimeSheet"><view><text>{{form.appointmentTime || timeSelectTip}}</text><text wx:if="{{form.appointmentTime}}" class="time-range">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text></view><text class="time-arrow">›</text></view></view>
<view class="field"><text class="field-label">员工(可稍后分配)</text><view class="field-value reference-value" bindtap="openArtistSheet"><text>{{selectedArtist.name || '暂不分配'}}</text><text class="reference-arrow">›</text></view></view>
</view>
<view wx:if="{{draftSavedAtText}}" class="draft-tip card">
<text>{{draftSavedAtText}}</text>
<button class="text-btn draft-clear" bindtap="clearDraft">清空</button>
<view class="card form-card customer-section">
<view class="section-heading"><view><text class="section-title-main">客户</text><text class="section-caption">可留空,按散客保存</text></view></view>
<view class="customer-entry"><input class="customer-name-input" value="{{form.customerName}}" data-field="customerName" bindinput="onCustomerInput" placeholder="客户姓名(选填)" /><button class="customer-select-btn" catchtap="openCustomerSheet">选择已有客户</button></view>
<input class="customer-phone-input" value="{{form.phone}}" data-field="phone" bindinput="onCustomerInput" type="number" maxlength="11" placeholder="手机号(选填,填写时需同时填写姓名)" />
<view wx:if="{{customerSuggestions.length}}" class="customer-suggestion-list"><view wx:for="{{customerSuggestions}}" wx:key="id" class="customer-suggestion" data-index="{{index}}" bindtap="selectCustomerSuggestion"><text>{{item.name}}</text><text>{{item.phone || '未填写手机号'}}</text></view></view>
<text wx:if="{{form.customerUserId}}" class="customer-selected-tip">已关联系统客户</text>
</view>
<view wx:if="{{conflictTip}}" class="availability-tip card {{conflictLevel}}">
<text class="tip-title">时段检查</text>
<text class="tip-text">{{conflictTip}}</text>
</view>
<view class="capacity-tip card"><text class="tip-title">容量校验</text><text class="tip-text">已指定员工时会校验排班和冲突;暂不分配时不校验员工占用,后续分配时再完整校验。</text></view>
<view wx:if="{{draftSavedAtText}}" class="draft-tip card"><text>{{draftSavedAtText}}</text><button class="text-btn draft-clear" bindtap="clearDraft">清空</button></view>
<view wx:if="{{conflictTip}}" class="availability-tip card {{conflictLevel}}"><text class="tip-title">时段检查</text><text class="tip-text">{{conflictTip}}</text></view>
<entity-selector-sheet
visible="{{customerSheetVisible}}"
title="选择客户"
keyword="{{customerKeyword}}"
placeholder="搜索客户姓名或手机号"
items="{{customerOptions}}"
selected-id="{{form.customerUserId}}"
loading="{{customerLoading}}"
error-text="{{customerError}}"
empty-text="暂无匹配客户"
bind:search="onCustomerSearch"
bind:select="selectCustomer"
bind:retry="retryCustomerSearch"
bind:close="closeCustomerSheet"
/>
<entity-selector-sheet visible="{{customerSheetVisible}}" title="选择客户" keyword="{{customerKeyword}}" placeholder="搜索客户姓名或手机号" items="{{customerOptions}}" selected-id="{{form.customerUserId}}" loading="{{customerLoading}}" error-text="{{customerError}}" empty-text="暂无匹配客户" show-view-switch="{{true}}" view-mode="{{customerViewMode}}" sort-label="{{customerNewestFirst ? '最新添加' : '最早添加'}}" bind:search="onCustomerSearch" bind:select="selectCustomer" bind:retry="retryCustomerSearch" bind:changeview="changeCustomerView" bind:sort="toggleCustomerSort" bind:close="closeCustomerSheet" />
<entity-selector-sheet visible="{{artistSheetVisible}}" title="选择员工" keyword="{{artistKeyword}}" placeholder="搜索员工姓名" items="{{artistSelectorItems}}" selected-id="{{form.artistId}}" loading="{{false}}" error-text="{{artistError}}" empty-text="暂无匹配员工" action-text="快速新增员工" bind:search="onArtistSearch" bind:select="selectArtist" bind:retry="retryArtists" bind:action="addEmployeeFromSelector" bind:close="closeArtistSheet" />
<product-selector-sheet visible="{{productModalVisible}}" mode="list" title="选择已有款式" keyword="{{productKeyword}}" placeholder="搜索款式、标签、美甲师" items="{{filteredProducts}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无匹配款式" show-manual-action="{{false}}" bind:search="onProductSearch" bind:select="selectProduct" bind:retry="loadOptions" bind:close="closeProductModal" />
<entity-selector-sheet
visible="{{artistSheetVisible}}"
title="选择员工"
keyword="{{artistKeyword}}"
placeholder="搜索员工姓名"
items="{{artistSelectorItems}}"
selected-id="{{form.artistId}}"
loading="{{false}}"
error-text="{{artistError}}"
empty-text="暂无匹配员工"
action-text="快速新增员工"
bind:search="onArtistSearch"
bind:select="selectArtist"
bind:retry="retryArtists"
bind:action="addEmployeeFromSelector"
bind:close="closeArtistSheet"
/>
<product-selector-sheet visible="{{productModalVisible}}" mode="{{productSelectorMode}}" title="选择预约作品" keyword="{{productKeyword}}" placeholder="搜索作品、标签、美甲师" items="{{filteredProducts}}" selected-id="{{form.productId}}" loading="{{loadingProducts}}" error-text="{{productError}}" empty-text="暂无匹配作品" manual-form="{{manualProductDraft}}" manual-more-expanded="{{manualProductMoreExpanded}}" manual-image-url="{{manualProductDraft.imageUrl}}" manual-image-uploading="{{manualImageUploading}}" bind:search="onProductSearch" bind:select="selectProduct" bind:openmanual="openManualProduct" bind:backtolist="backToProductList" bind:manualinput="onManualProductInput" bind:togglemore="toggleManualProductMore" bind:chooseimage="chooseManualProductImage" bind:removeimage="removeManualProductImage" bind:confirmmanual="useManualProduct" bind:retry="loadOptions" bind:close="closeProductModal" />
<view wx:if="{{timeSheetVisible}}" class="modal-mask" bindtap="closeTimeSheet">
<view class="time-modal" catchtap="stopTap">
<view class="modal-head">
<view>
<text class="modal-title">选择预约时间</text>
<text class="modal-subtitle">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text>
</view>
<view class="modal-close" bindtap="closeTimeSheet">×</view>
</view>
<view wx:if="{{timeSheetVisible}}" class="modal-mask" bindtap="closeTimeSheet" catchtouchmove="stopTouchMove">
<view class="time-modal" catchtap="stopTap" catchtouchmove="stopTouchMove">
<view class="modal-head"><view><text class="modal-title">选择预约时间</text><text class="modal-subtitle">{{form.appointmentDate}} · {{selectedArtist.name || '待分配'}} · {{form.durationMinutes}}分钟</text></view><view class="modal-close" bindtap="closeTimeSheet" aria-label="关闭时间选择"></view></view>
<view class="time-mode-switch"><button class="{{timePickerMode === 'wheel' ? 'active' : ''}}" data-mode="wheel" bindtap="onTimePickerModeChange">滚轮选择</button><button class="{{timePickerMode === 'grid' ? 'active' : ''}}" data-mode="grid" bindtap="onTimePickerModeChange">15分钟时段</button></view>
<view wx:if="{{timeLoading}}" class="time-empty">正在计算可约时间...</view>
<view wx:elif="{{timeError}}" class="time-empty">{{timeError}}</view>
<view wx:elif="{{availableTimeGroups.length === 0}}" class="time-empty">当前没有可选时间</view>
<scroll-view wx:else class="time-list" scroll-y>
<view wx:for="{{availableTimeGroups}}" wx:key="key" class="time-group">
<text class="time-group-title">{{item.title}}</text>
<view class="time-grid">
<view wx:for="{{item.times}}" wx:for-item="time" wx:key="value" class="time-chip {{form.appointmentTime === time.value ? 'active' : ''}}" data-value="{{time.value}}" bindtap="selectAvailableTime">
<text>{{time.value}}</text>
<text>{{time.rangeText}}</text>
</view>
</view>
</view>
</scroll-view>
<block wx:elif="{{timePickerMode === 'wheel'}}">
<picker-view class="time-wheel" indicator-style="height: 76rpx;" value="{{timePickerValue}}" bindchange="onTimePickerChange"><picker-view-column><view wx:for="{{timePickerHours}}" wx:key="value" class="wheel-item {{item.disabled ? 'disabled' : ''}}">{{item.label}}</view></picker-view-column><picker-view-column><view wx:for="{{timePickerMinutes}}" wx:key="value" class="wheel-item {{item.disabled ? 'disabled' : ''}}">{{item.label}}</view></picker-view-column></picker-view>
<view class="time-wheel-caption">{{selectedTimeCandidate || '请选择时间'}}<text wx:if="{{timePickerCandidateStatus === 'occupied'}}"> · 已被占用</text><text wx:elif="{{timePickerCandidateStatus === 'off-shift'}}"> · 当前无排班</text></view>
<button class="time-confirm-btn" bindtap="confirmTimeSelection">确认时间</button>
</block>
<block wx:else><scroll-view class="time-list" scroll-y><view wx:for="{{timePickerGroups}}" wx:key="key" class="time-group"><text class="time-group-title">{{item.title}}</text><view class="time-grid"><view wx:for="{{item.times}}" wx:for-item="time" wx:key="value" class="time-chip {{selectedTimeCandidate === time.value ? 'active' : ''}} {{time.status !== 'available' ? 'disabled' : ''}}" data-value="{{time.value}}" bindtap="selectAvailableTime"><text>{{time.value}}</text><text>{{time.statusText || time.rangeText}}</text></view></view></view></scroll-view><button class="time-confirm-btn" bindtap="confirmTimeSelection">确认当前时间</button></block>
</view>
</view>
<view class="fixed-bottom">
<view wx:if="{{canCreateAppointment}}" class="action-row">
<button class="secondary-btn draft-btn" bindtap="saveDraft">保存草稿</button>
<button class="primary-btn submit-btn" loading="{{loading}}" bindtap="submit">提交预约</button>
</view>
</view>
<view class="fixed-bottom"><view wx:if="{{canCreateAppointment}}" class="action-row"><button class="secondary-btn draft-btn" bindtap="saveDraft">保存草稿</button><button class="primary-btn submit-btn" loading="{{loading}}" bindtap="submit">提交预约</button></view></view>
</view>