问题:哨兵客户 __RETAIL__ 会出现在小程序客户列表,但小程序走普通下单 (服务层无 RETAIL 分支),而自动推进又显式排除散客 ⇒ 单子容易卡在流程里。 新增 POST /mobile/order-entry/retail-orders:录单角色 + 客户范围校验, 与 Web 同源调 submitRetailOrder(entryChannel=MP,不校验下单时间窗口)。 小程序选中散客后:不要求配送日期、不做预算校验、只允许已建档商品, 成功后提示到「订单管理」点「确认扣除并完结」;界面加「只扣库存」提示。 普通录单行为逐字不变。
459 lines
19 KiB
Plaintext
459 lines
19 KiB
Plaintext
<view class="page-wrap {{embedded ? 'is-embedded' : ''}}" style="{{wrapStyle}}">
|
||
<view class="page-atmosphere" aria-hidden="true"></view>
|
||
<view class="page-scroll {{embedded ? 'page-scroll--flow' : 'page-scroll--shell'}}">
|
||
<view class="card shell-card">
|
||
<view class="page-hero">
|
||
<view class="section-title">录单</view>
|
||
<view wx:if="{{branchText}}" class="text-muted branch-hint">{{branchText}} · 仅显示本公司客户</view>
|
||
</view>
|
||
<view wx:if="{{error}}" class="text-error error-banner">{{error}}</view>
|
||
<view wx:if="{{loading}}" class="loading-row">
|
||
<van-loading size="18px" color="#059669">加载客户中...</van-loading>
|
||
</view>
|
||
|
||
<picker mode="selector" range="{{customers}}" range-key="company_name" bindchange="onCustomerChange">
|
||
<view class="picker">
|
||
<view class="picker-icon">
|
||
<van-icon name="shop-o" size="16px" color="#047857" />
|
||
</view>
|
||
<view class="picker-text">
|
||
<text class="picker-label">客户</text>
|
||
<text class="picker-value">{{customerIndex >= 0 ? customers[customerIndex].company_name : '请选择客户'}}</text>
|
||
</view>
|
||
<van-icon name="arrow-down" size="14px" color="#059669" />
|
||
</view>
|
||
</picker>
|
||
|
||
<!-- 散客录单:与 Web 同口径(只扣库存、无备货/分拣/配送) -->
|
||
<view wx:if="{{retailMode}}" class="retail-hint">只扣库存:无采购、无分拣、无配送;库存不足会拦住</view>
|
||
|
||
<view class="delivery-row">
|
||
<view class="delivery-cell delivery-cell--date">
|
||
<picker mode="date" value="{{deliveryDate}}" start="{{deliveryDateStart}}" bindchange="onDeliveryDateChange">
|
||
<view class="delivery-picker">
|
||
<text class="delivery-label">配送日期</text>
|
||
<text class="delivery-value">{{deliveryDate}}</text>
|
||
</view>
|
||
</picker>
|
||
</view>
|
||
<view wx:if="{{customerDeliveryDeadline}}" class="delivery-cell delivery-cell--slot">
|
||
<view class="delivery-picker">
|
||
<text class="delivery-label">须送达时刻</text>
|
||
<text class="delivery-value">{{customerDeliveryDeadline}}</text>
|
||
</view>
|
||
</view>
|
||
<view wx:if="{{customerIndex >= 0}}" class="delivery-cell delivery-cell--address">
|
||
<view class="delivery-picker delivery-picker--address">
|
||
<text class="delivery-label">配送地址</text>
|
||
<textarea
|
||
class="address-input"
|
||
placeholder="未维护配送地址,可在此填写"
|
||
value="{{deliveryAddress}}"
|
||
maxlength="200"
|
||
auto-height
|
||
bindinput="onDeliveryAddressInput"
|
||
/>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view wx:if="{{customerIndex < 0}}" class="panel-hint mode-hint">请先选择客户与配送信息,再使用图片或语音录单</view>
|
||
|
||
<view class="mode-row">
|
||
<view
|
||
wx:for="{{entryModes}}"
|
||
wx:key="key"
|
||
class="mode-chip {{entryMode === item.key ? 'active' : ''}}"
|
||
data-mode="{{item.key}}"
|
||
bindtap="switchEntryMode"
|
||
>{{item.label}}</view>
|
||
</view>
|
||
|
||
<view wx:if="{{customerIndex >= 0}}" class="toolbar-row">
|
||
<button
|
||
class="btn-secondary toolbar-btn"
|
||
disabled="{{prefilling}}"
|
||
loading="{{prefilling}}"
|
||
bindtap="handlePrefill"
|
||
>AI预填</button>
|
||
<button class="btn-secondary toolbar-btn" bindtap="clearAllItems">清空</button>
|
||
</view>
|
||
|
||
<view wx:if="{{budgetMessage && customerIndex >= 0}}" class="budget budget-{{budgetLevel}}">{{budgetMessage}}</view>
|
||
|
||
<view wx:if="{{entryMode === 'image'}}" class="entry-panel">
|
||
<view class="panel-head">
|
||
<view class="panel-icon">
|
||
<van-icon name="photograph" size="16px" color="#047857" />
|
||
</view>
|
||
<view class="panel-title">图片录单</view>
|
||
</view>
|
||
<view class="panel-hint">拍照或从相册选择订单图片,自动识别商品</view>
|
||
<view wx:if="{{imagePreview}}" class="image-preview-wrap">
|
||
<image class="image-preview" src="{{imagePreview}}" mode="aspectFit" />
|
||
<view class="clear-image" bindtap="clearImagePreview">清除图片</view>
|
||
</view>
|
||
<view class="image-actions">
|
||
<button
|
||
class="btn-secondary image-btn"
|
||
disabled="{{customerIndex < 0 || parsing}}"
|
||
bindtap="chooseImageFromCamera"
|
||
>拍照</button>
|
||
<button
|
||
class="btn-secondary image-btn"
|
||
disabled="{{customerIndex < 0 || parsing}}"
|
||
bindtap="chooseImageFromAlbum"
|
||
>从相册选择</button>
|
||
</view>
|
||
<view wx:if="{{parsing}}" class="parsing-hint">
|
||
<van-loading size="16px" color="#059669">正在识别图片...</van-loading>
|
||
</view>
|
||
</view>
|
||
|
||
<view wx:if="{{entryMode === 'voice'}}" class="entry-panel">
|
||
<view class="panel-head">
|
||
<view class="panel-icon">
|
||
<van-icon name="volume-o" size="16px" color="#047857" />
|
||
</view>
|
||
<view class="panel-title">语音录单</view>
|
||
</view>
|
||
<view class="panel-hint">说出商品与数量,例如:苹果5斤、鸡蛋2板</view>
|
||
<button
|
||
class="btn-secondary voice-btn {{recording ? 'recording' : ''}}"
|
||
disabled="{{customerIndex < 0 || parsing}}"
|
||
bindtap="onRecordTap"
|
||
>{{recording ? '结束录音' : '开始录音'}}</button>
|
||
<view wx:if="{{inputText}}" class="voice-result">
|
||
<view class="voice-result-label">识别文字</view>
|
||
<text>{{inputText}}</text>
|
||
</view>
|
||
<view wx:if="{{parsing}}" class="parsing-hint">
|
||
<van-loading size="16px" color="#059669">正在解析语音...</van-loading>
|
||
</view>
|
||
</view>
|
||
|
||
<view wx:if="{{entryMode === 'text'}}" class="entry-panel">
|
||
<view class="panel-head">
|
||
<view class="panel-icon">
|
||
<van-icon name="edit" size="16px" color="#047857" />
|
||
</view>
|
||
<view class="panel-title">文字录单</view>
|
||
</view>
|
||
<view class="panel-hint">输入商品清单,一行或多行均可</view>
|
||
<textarea
|
||
class="text-input order-text-input"
|
||
placeholder="例:苹果5斤、鸡蛋2板、土豆10斤"
|
||
value="{{inputText}}"
|
||
disabled="{{customerIndex < 0}}"
|
||
adjust-position="{{embedded}}"
|
||
data-scroll-target=".order-text-input"
|
||
bindfocus="onRemarkFocus"
|
||
bindblur="onTextInputBlur"
|
||
bindinput="onInputTextChange"
|
||
/>
|
||
<button
|
||
class="btn-secondary parse-btn"
|
||
loading="{{parsing}}"
|
||
disabled="{{customerIndex < 0}}"
|
||
bindtap="onParseTextTap"
|
||
>解析订单</button>
|
||
</view>
|
||
|
||
<view class="items-header">
|
||
<view class="section-head-inline">
|
||
<view class="section-mark"></view>
|
||
<text>商品明细</text>
|
||
</view>
|
||
<text class="items-count">共 {{items.length}} 项</text>
|
||
</view>
|
||
<view wx:if="{{unmatchedItems.length}}" class="unmatched-hint">{{unmatchedItems.length}} 个商品未匹配映射库</view>
|
||
<view class="toggle-pair">
|
||
<view class="toggle-chip">
|
||
<text class="toggle-chip-label">智能分类</text>
|
||
<switch class="toggle-chip-switch" checked="{{smartClassifyEnabled}}" bindchange="onSmartClassifyChange" color="#059669" />
|
||
</view>
|
||
<view class="toggle-chip">
|
||
<text class="toggle-chip-label">显示成本价</text>
|
||
<switch class="toggle-chip-switch" checked="{{showCostPrice}}" bindchange="onShowCostPriceChange" color="#059669" />
|
||
</view>
|
||
</view>
|
||
|
||
<view class="items-list">
|
||
<view wx:for="{{items}}" wx:key="_uid" id="item-card-{{index}}" class="item-card {{item.name_mismatch ? 'item-card-name-mismatch' : ''}} {{activeCategoryIndex === index || activeSkuIndex === index ? 'cat-dropdown-open' : ''}}">
|
||
<view class="item-card-top">
|
||
<view class="item-seq">{{index + 1}}</view>
|
||
<view class="item-field item-field-name">
|
||
<view wx:if="{{item.name_mismatch}}" class="name-mismatch-hint">录单名与商品库不一致(库名:{{item.catalog_sku_name}})</view>
|
||
<view class="sku-search-wrap">
|
||
<input
|
||
class="item-control item-control-name"
|
||
placeholder="录单名称(映射前)"
|
||
value="{{item.item_name}}"
|
||
adjust-position="{{embedded}}"
|
||
hold-keyboard
|
||
data-index="{{index}}"
|
||
data-field="item_name"
|
||
bindfocus="onSkuNameFocus"
|
||
bindblur="onSkuNameBlur"
|
||
bindinput="updateItem"
|
||
/>
|
||
<view
|
||
wx:if="{{activeSkuIndex === index}}"
|
||
class="sku-suggestions"
|
||
catchtap=""
|
||
>
|
||
<view wx:if="{{skuSearching}}" class="sku-suggestion sku-suggestion-muted">搜索中...</view>
|
||
<view
|
||
wx:for="{{skuSuggestions}}"
|
||
wx:for-item="sku"
|
||
wx:for-index="sidx"
|
||
wx:key="sku_code"
|
||
class="sku-suggestion"
|
||
data-index="{{index}}"
|
||
data-sidx="{{sidx}}"
|
||
catchtap="pickSkuSuggestion"
|
||
>
|
||
<view class="sku-suggestion-name">{{sku.sku_name}}</view>
|
||
<view class="sku-suggestion-meta">
|
||
{{sku.sku_code}} · {{sku.unit || '斤'}}
|
||
<text wx:if="{{sku.from_quote}}"> · 客户报价 ¥{{sku.sale_price}}</text>
|
||
</view>
|
||
</view>
|
||
<view
|
||
wx:if="{{skuCanCreate}}"
|
||
class="sku-suggestion sku-suggestion-add"
|
||
data-index="{{index}}"
|
||
catchtap="chooseCreateSku"
|
||
>新建商品「{{skuQuery}}」</view>
|
||
<view
|
||
wx:if="{{!skuSearching && !skuSuggestions.length && !skuCanCreate}}"
|
||
class="sku-suggestion sku-suggestion-muted"
|
||
>暂无可选商品</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="item-remove" data-index="{{index}}" bindtap="removeItem">
|
||
<van-icon name="cross" size="14px" color="#a1a1aa" />
|
||
</view>
|
||
</view>
|
||
|
||
<view class="item-meta-row">
|
||
<view wx:if="{{item.mapping_status}}" class="item-status">{{item.mapping_status}}</view>
|
||
<picker
|
||
mode="selector"
|
||
range="{{processingMethods}}"
|
||
data-index="{{index}}"
|
||
bindchange="onProcessingMethodPick"
|
||
>
|
||
<view class="proc-chip">
|
||
<text class="proc-chip-label">加工</text>
|
||
<text class="proc-chip-value">{{item.processing_method || '原材料'}}</text>
|
||
<text class="cat-arrow">▾</text>
|
||
</view>
|
||
</picker>
|
||
</view>
|
||
|
||
<view wx:if="{{item.show_processing_owner}}" class="owner-row">
|
||
<view
|
||
class="owner-chip {{item.processing_owner === 'supplier' ? 'on' : ''}}"
|
||
data-index="{{index}}"
|
||
data-owner="supplier"
|
||
bindtap="onProcessingOwnerTap"
|
||
>供应商已加工</view>
|
||
<view
|
||
class="owner-chip {{item.processing_owner === 'warehouse' ? 'on' : ''}}"
|
||
data-index="{{index}}"
|
||
data-owner="warehouse"
|
||
bindtap="onProcessingOwnerTap"
|
||
>仓内加工</view>
|
||
</view>
|
||
|
||
<view wx:if="{{item.show_process_unit_price}}" class="item-metrics process-price-row">
|
||
<view class="metric-cell metric-cell-wide">
|
||
<text class="metric-label">加工单价</text>
|
||
<input
|
||
class="item-control item-control-num"
|
||
type="digit"
|
||
placeholder="选填"
|
||
value="{{item.process_unit_price}}"
|
||
adjust-position="{{embedded}}"
|
||
data-index="{{index}}"
|
||
data-field="process_unit_price"
|
||
bindfocus="onNumericFocus"
|
||
bindblur="onNumericBlur"
|
||
bindinput="updateItem"
|
||
/>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="item-metrics {{showCostPrice ? 'with-cost' : ''}}">
|
||
<view class="metric-cell">
|
||
<text class="metric-label">数量</text>
|
||
<input
|
||
class="item-control item-control-num"
|
||
type="digit"
|
||
placeholder="数"
|
||
value="{{item.quantity}}"
|
||
adjust-position="{{embedded}}"
|
||
data-index="{{index}}"
|
||
data-field="quantity"
|
||
bindfocus="onNumericFocus"
|
||
bindblur="onNumericBlur"
|
||
bindinput="updateItem"
|
||
/>
|
||
</view>
|
||
<view class="metric-cell">
|
||
<text class="metric-label">单位</text>
|
||
<input
|
||
class="item-control item-control-unit"
|
||
placeholder="单位"
|
||
value="{{item.unit}}"
|
||
adjust-position="{{embedded}}"
|
||
hold-keyboard
|
||
data-index="{{index}}"
|
||
data-field="unit"
|
||
bindfocus="onItemFieldFocus"
|
||
bindblur="onItemFieldBlur"
|
||
bindinput="updateItem"
|
||
/>
|
||
</view>
|
||
<view class="metric-cell">
|
||
<text class="metric-label">单价</text>
|
||
<input
|
||
class="item-control item-control-num"
|
||
type="digit"
|
||
placeholder="单价"
|
||
value="{{item.price}}"
|
||
adjust-position="{{embedded}}"
|
||
data-index="{{index}}"
|
||
data-field="price"
|
||
bindfocus="onNumericFocus"
|
||
bindblur="onNumericBlur"
|
||
bindinput="updateItem"
|
||
/>
|
||
</view>
|
||
<view wx:if="{{showCostPrice}}" class="metric-cell metric-cell-cost">
|
||
<text class="metric-label">成本</text>
|
||
<input
|
||
class="item-control item-control-num item-control-cost"
|
||
type="digit"
|
||
placeholder="成本"
|
||
value="{{item.cost_price}}"
|
||
adjust-position="{{embedded}}"
|
||
data-index="{{index}}"
|
||
data-field="cost_price"
|
||
bindfocus="onNumericFocus"
|
||
bindblur="onNumericBlur"
|
||
bindinput="updateItem"
|
||
/>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="item-row item-row-secondary">
|
||
<view class="item-field item-field-cat">
|
||
<view class="cat-picker-wrap">
|
||
<view
|
||
class="item-control item-control-cat {{item.category_has_value ? 'cat-filled' : 'cat-empty'}}"
|
||
data-index="{{index}}"
|
||
bindtap="toggleCategoryDropdown"
|
||
>
|
||
<text class="cat-label">{{item.category_display}}</text>
|
||
<text class="cat-arrow">▾</text>
|
||
</view>
|
||
<view
|
||
wx:if="{{activeCategoryIndex === index}}"
|
||
class="cat-dropdown-panel"
|
||
catchtap=""
|
||
>
|
||
<view class="cat-dropdown-search-wrap">
|
||
<input
|
||
class="cat-dropdown-search"
|
||
placeholder="输入关键字搜索分类"
|
||
value="{{categoryDropdownQuery}}"
|
||
focus="{{categorySearchFocus}}"
|
||
adjust-position="{{embedded}}"
|
||
hold-keyboard
|
||
confirm-type="search"
|
||
bindfocus="onCategorySearchFocus"
|
||
bindinput="onCategoryDropdownSearch"
|
||
/>
|
||
</view>
|
||
<scroll-view scroll-y class="cat-dropdown-list">
|
||
<view
|
||
wx:for="{{categoryDropdownOptions}}"
|
||
wx:for-item="opt"
|
||
wx:for-index="sidx"
|
||
wx:key="category_code"
|
||
class="cat-dropdown-item {{opt.category_code === categoryDropdownCurrentCode ? 'selected' : ''}}"
|
||
data-sidx="{{sidx}}"
|
||
catchtap="pickCategoryFromDropdown"
|
||
>{{opt.label || opt.category_name}}</view>
|
||
<view wx:if="{{!categoryDropdownOptions.length}}" class="cat-dropdown-empty text-muted">无匹配分类</view>
|
||
</scroll-view>
|
||
<view class="cat-dropdown-footer" catchtap="openQuickCategoryFromDropdown">+ 新建分类</view>
|
||
</view>
|
||
</view>
|
||
<view class="cat-add-btn" data-index="{{index}}" bindtap="openQuickCategory">+</view>
|
||
</view>
|
||
<view class="item-field item-field-amount">
|
||
<text class="item-amount-label">小计</text>
|
||
<text class="item-amount-value">¥{{item.amountText}}</text>
|
||
</view>
|
||
</view>
|
||
<view class="item-row">
|
||
<input
|
||
class="item-control"
|
||
placeholder="明细备注(可选)"
|
||
value="{{item.remark}}"
|
||
maxlength="500"
|
||
adjust-position="{{embedded}}"
|
||
hold-keyboard
|
||
data-index="{{index}}"
|
||
data-field="remark"
|
||
bindfocus="onItemFieldFocus"
|
||
bindblur="onItemFieldBlur"
|
||
bindinput="updateItem"
|
||
/>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<button class="btn-secondary add-item-btn" bindtap="addItem">添加商品</button>
|
||
|
||
<view class="submit-panel">
|
||
<view class="order-total">预估合计:¥{{orderTotal}}</view>
|
||
<textarea
|
||
class="textarea order-remark-input"
|
||
placeholder="备注"
|
||
value="{{remark}}"
|
||
style="height: 72rpx;"
|
||
auto-height="{{false}}"
|
||
maxlength="200"
|
||
adjust-position="{{embedded}}"
|
||
data-scroll-target=".order-remark-input"
|
||
bindfocus="onRemarkFocus"
|
||
bindblur="onRemarkBlur"
|
||
bindinput="onRemarkInput"
|
||
/>
|
||
<button class="btn-primary submit" loading="{{submitting}}" disabled="{{submitting || budgetBlocked}}" bindtap="submitOrder">
|
||
{{budgetBlocked ? '预算不足,无法提交' : '提交订单'}}
|
||
</button>
|
||
</view>
|
||
<view class="items-scroll-spacer" style="height: {{scrollSpacerHeight}}px;"></view>
|
||
</view>
|
||
</view>
|
||
|
||
<root-portal enable="{{true}}">
|
||
<view wx:if="{{showQuickCategoryModal}}" class="modal-mask" bindtap="closeQuickCategoryModal">
|
||
<view class="modal-card" catchtap="">
|
||
<view class="modal-title">新建分类</view>
|
||
<input class="modal-input" placeholder="分类名称" value="{{quickCategoryName}}" bindinput="onQuickCategoryNameInput" />
|
||
<view class="modal-actions">
|
||
<button class="btn-secondary modal-btn" bindtap="closeQuickCategoryModal">取消</button>
|
||
<button class="btn-primary modal-btn" loading="{{creatingCategory}}" bindtap="submitQuickCategory">创建</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</root-portal>
|
||
</view>
|