Files
SupplierSystem/miniprogram/components/stock-inbound-panel/index.wxml
T
雨天 8213c17166
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
feat(小程序入库): 待审核行支持一键入库
逐行本地校验后一次提交全部行;409 规格冲突确认后带 confirm_spec_conflict
重提(移动端路由本次补上该参数转发与 spec_conflicts 透传)。

失败行按 rowNumber 留在列表、成功行移除;报告随行绑定,绑定失败只提示
去 Web 补挂。逐行与一键共用 _submitInFlight 在途锁,防双击重复入库。
2026-10-21 19:15:00 +08:00

180 lines
11 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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-bar">
<view class="section">识别结果 · 待审核({{lines.length}})</view>
<view class="section-link" bindtap="openReportSheet">上传报告</view>
</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.reports && item.reports.length}}" class="line-reports">
<view class="report-chip" wx:for="{{item.reports}}" wx:for-item="r" wx:for-index="ri" wx:key="id">
<text class="report-chip-text">{{r.type_label}}{{r.report_no ? ' ' + r.report_no : ''}} ✓</text>
<text class="report-chip-del" data-index="{{index}}" data-report-id="{{r.id}}" catchtap="onReportChipRemove">✕</text>
</view>
</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
wx:if="{{lines.length}}"
class="btn batch-submit {{submitting ? 'is-disabled' : ''}}"
bindtap="submitAllLines"
>{{submitting && submittingIndex === -1 ? '入库中…' : '一键入库(' + lines.length + ')'}}</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>
<!-- 批次报告:上传 → 解析 → 挂到待入库行(2026-10-21) -->
<view wx:if="{{reportOpen}}" class="sheet-mask" catchtap="closeReportSheet">
<view class="sheet" catchtap="noop">
<view class="sheet-title">上传批次报告</view>
<view class="rp-row">
<text class="rp-label">报告类型</text>
<picker mode="selector" range="{{reportTypes}}" range-key="label" value="{{reportTypeIndex}}" bindchange="onReportTypeChange">
<view class="rp-pick">{{reportTypes[reportTypeIndex].label}} ▾</view>
</picker>
</view>
<view class="rp-row">
<text class="rp-label">报告编号</text>
<input class="sheet-input rp-input" placeholder="选填" value="{{reportNo}}" bindinput="onReportNoInput" />
</view>
<view class="btn btn--sm ghost {{reportBusy ? 'is-disabled' : ''}}" bindtap="pickReportSource">
{{reportParsed ? '重新上传报告' : '选择报告文件'}}
</view>
<view wx:if="{{reportParsed}}" class="rp-result">
<view class="rp-result-title">解析结果</view>
<view class="rp-names">{{reportNameText}}</view>
<view wx:if="{{reportParsed.produced_at}}" class="rp-meta">生产日期 {{reportParsed.produced_at}}</view>
<view class="rp-result-title">这份报告属于</view>
<scroll-view scroll-y class="rp-lines">
<view
class="rp-line {{item.picked ? 'is-picked' : ''}}"
wx:for="{{reportOptions}}"
wx:key="key"
data-key="{{item.key}}"
bindtap="toggleReportLine"
>
<text class="rp-check">{{item.picked ? '☑' : '☐'}}</text>
<text class="rp-line-name">{{item.name}}</text>
<text wx:if="{{item.spec}}" class="rp-line-spec">{{item.spec}}</text>
</view>
</scroll-view>
</view>
<view class="np-foot">
<view class="np-btn ghost" catchtap="closeReportSheet">取消</view>
<view class="np-btn primary {{reportBusy ? 'is-disabled' : ''}}" catchtap="applyReportToLines">确定</view>
</view>
</view>
</view>
</root-portal>