小程序识别结果逐行入库;保质期拆数值与单位(AI 三选一或人手选)落库原文;选择商品弹层 root-portal 防 tab 遮挡,并预填 AI 品名。 Co-authored-by: Cursor <cursoragent@cursor.com>
115 lines
7.5 KiB
Plaintext
115 lines
7.5 KiB
Plaintext
<view class="page {{embedded ? 'is-embedded' : ''}}">
|
||
<view class="card">
|
||
<view class="thumb-list" wx:if="{{imageList.length}}">
|
||
<view class="thumb" wx:for="{{imageList}}" wx:key="key" data-index="{{index}}" bindtap="onImagePreview">
|
||
<image class="thumb-img" src="{{item.path}}" mode="aspectFill" />
|
||
<view class="thumb-del" data-index="{{index}}" catchtap="onImageDelete">✕</view>
|
||
</view>
|
||
</view>
|
||
<view class="row">
|
||
<view class="btn btn--sm ghost flex" bindtap="chooseImageFromCamera">拍照</view>
|
||
<view class="btn btn--sm ghost flex" bindtap="chooseImageFromAlbum">相册</view>
|
||
</view>
|
||
<view class="btn {{(!imageList.length || recognizing) ? 'is-disabled' : ''}}" bindtap="recognizeAll">{{recognizing ? '识别中…' : '开始识别'}}</view>
|
||
<view wx:if="{{imageList.length}}" class="link" bindtap="clearImages">清除全部图片</view>
|
||
</view>
|
||
|
||
<view class="card">
|
||
<view class="section">识别结果 · 待审核({{lines.length}})</view>
|
||
<view wx:if="{{!lines.length}}" class="hint">还没有商品:可先识别,或点下方「手动加一行」。</view>
|
||
|
||
<view class="line" wx:for="{{lines}}" wx:key="key">
|
||
<view class="line-head">
|
||
<text class="line-idx">{{index + 1}}</text>
|
||
<text class="badge {{item.sku_code ? 'badge-ok' : 'badge-new'}}">{{item.sku_code ? item.sku_code : '待新建'}}</text>
|
||
<view class="line-actions">
|
||
<view
|
||
class="line-inbound {{submitting ? 'is-disabled' : ''}}"
|
||
data-index="{{index}}"
|
||
catchtap="submitLine"
|
||
>{{submitting && submittingIndex === index ? '…' : '入库'}}</view>
|
||
<view class="line-del" data-index="{{index}}" catchtap="onLineRemove">✕</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="line-row">
|
||
<view class="cell cell--name cell-pick {{item.item_name ? '' : 'cell-pick--empty'}}" data-index="{{index}}" bindtap="openProductSheet">{{item.item_name || '品名'}} ▾</view>
|
||
<input class="input cell cell--spec" placeholder="规格" data-index="{{index}}" data-field="spec" value="{{item.spec}}" bindinput="onLineField" />
|
||
<input class="input cell cell--qty" type="digit" placeholder="数量" data-index="{{index}}" data-field="qty" value="{{item.qty}}" bindinput="onLineField" />
|
||
<input class="input cell cell--unit" placeholder="单位" data-index="{{index}}" data-field="unit" value="{{item.unit}}" bindinput="onLineField" />
|
||
<input class="input cell cell--cost" type="digit" placeholder="成本价" data-index="{{index}}" data-field="unit_cost" value="{{item.unit_cost}}" bindinput="onLineField" />
|
||
</view>
|
||
|
||
<view class="line-row">
|
||
<view class="cell cell--cat cell-pick {{item.category_code ? '' : 'cell-pick--empty'}}" data-index="{{index}}" bindtap="openCategorySheet">{{item.category_name || '分类'}} ▾</view>
|
||
<picker class="cell cell--date" mode="date" value="{{item.production_date}}" end="{{productionDateEnd}}" data-index="{{index}}" bindchange="onLineProd">
|
||
<view class="cell-pick {{item.production_date ? '' : 'cell-pick--empty'}}">{{item.production_date || '生产日期'}} ▾</view>
|
||
</picker>
|
||
<input class="input cell cell--shelf-num" type="digit" placeholder="保质期" data-index="{{index}}" value="{{item.shelf_life_value}}" bindinput="onLineShelfValue" />
|
||
<picker class="cell cell--shelf-unit" mode="selector" range="{{shelfLifeUnits}}" value="{{item.shelf_life_unit_index}}" data-index="{{index}}" bindchange="onLineShelfUnit">
|
||
<view class="cell-pick {{item.shelf_life_unit ? '' : 'cell-pick--empty'}}">{{item.shelf_life_unit || '单位'}} ▾</view>
|
||
</picker>
|
||
<view class="cell cell--zone cell-pick {{item.storage_zone ? '' : 'cell-pick--empty'}}" data-index="{{index}}" bindtap="openZoneSheet">{{item.storage_zone || '存放区域'}} ▾</view>
|
||
<input class="input cell cell--origin" placeholder="生产地区" data-index="{{index}}" data-field="origin" value="{{item.origin}}" bindinput="onLineField" />
|
||
</view>
|
||
|
||
<view wx:if="{{!item.sku_code && item.candidates.length}}" class="cand">
|
||
<view class="cand-chips">
|
||
<view class="cand-chip" wx:for="{{item.candidates}}" wx:for-item="c" wx:key="sku_code" data-index="{{index}}" data-sku="{{c.sku_code}}" catchtap="onLinePickCandidate">{{c.sku_name}}{{c.spec ? ' · ' + c.spec : ''}}</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="link" bindtap="addEmptyLine">+ 手动加一行</view>
|
||
</view>
|
||
|
||
</view>
|
||
|
||
<!-- 必须 root-portal:嵌在 home 的 .home-purchase-embed.anim-rise 内时,
|
||
transform 会困住 position:fixed,弹层会被底部 tab 栏盖住(与其它面板同修法)。 -->
|
||
<root-portal enable="{{true}}">
|
||
<view wx:if="{{sheetOpen}}" class="sheet-mask" catchtap="closeSheet">
|
||
<view class="sheet" catchtap="noop">
|
||
<view class="sheet-title">{{sheetType === 'newProduct' ? '新建商品' : (sheetType === 'product' ? '选择商品' : (sheetType === 'category' ? '选择分类' : '选择存放区域'))}}</view>
|
||
|
||
<block wx:if="{{sheetType !== 'newProduct'}}">
|
||
<input class="sheet-input" placeholder="{{sheetType === 'product' ? '搜索已有商品,或输入新商品名' : (sheetType === 'category' ? '搜索或输入新分类' : '搜索或输入新区域')}}" value="{{sheetQuery}}" bindinput="onSheetInput" confirm-type="done" />
|
||
<scroll-view scroll-y class="sheet-list">
|
||
<view wx:if="{{sheetCanCreate}}" class="sheet-item sheet-item-create" bindtap="onSheetCreate">{{sheetCreateLabel}}</view>
|
||
<view class="sheet-item" wx:for="{{sheetList}}" wx:key="code" data-code="{{item.code}}" data-label="{{item.label}}" bindtap="onSheetPick">{{item.label}}</view>
|
||
<view wx:if="{{!sheetList.length && !sheetCanCreate}}" class="sheet-empty">没有匹配项,输入名称可新建</view>
|
||
</scroll-view>
|
||
</block>
|
||
|
||
<view wx:else class="np-form">
|
||
<view class="np-row">
|
||
<text class="np-label">品名</text>
|
||
<input class="np-input" placeholder="商品名" value="{{newProduct.name}}" data-field="name" bindinput="onNewProductField" />
|
||
</view>
|
||
<view class="np-row">
|
||
<text class="np-label">分类</text>
|
||
<picker mode="selector" range="{{categoryOptions}}" range-key="label" value="{{newProduct.categoryIndex}}" bindchange="onNewProductCategory">
|
||
<view class="np-pick">{{categoryOptions[newProduct.categoryIndex].label || '选择分类'}} ▾</view>
|
||
</picker>
|
||
</view>
|
||
<view class="np-row">
|
||
<text class="np-label">规格</text>
|
||
<input class="np-input" placeholder="规格" value="{{newProduct.spec}}" data-field="spec" bindinput="onNewProductField" />
|
||
</view>
|
||
<view class="np-row">
|
||
<text class="np-label">单位</text>
|
||
<input class="np-input" placeholder="单位" value="{{newProduct.unit}}" data-field="unit" bindinput="onNewProductField" />
|
||
</view>
|
||
<view class="np-row">
|
||
<text class="np-label">生产地区</text>
|
||
<input class="np-input" placeholder="生产地区" value="{{newProduct.origin}}" data-field="origin" bindinput="onNewProductField" />
|
||
</view>
|
||
<view class="np-foot">
|
||
<view class="np-btn ghost" catchtap="closeSheet">取消</view>
|
||
<view class="np-btn primary {{creatingProduct ? 'is-disabled' : ''}}" catchtap="submitNewProduct">确定</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</root-portal>
|