352 lines
20 KiB
Plaintext
352 lines
20 KiB
Plaintext
<view class="page {{embedded ? 'is-embedded' : ''}}">
|
||
<view class="card">
|
||
<view wx:if="{{!embedded}}" class="seg-tabs">
|
||
<view class="seg-tab {{activeTab === 'work' ? 'active' : ''}}" data-tab="work" bindtap="switchTab">加工作业</view>
|
||
<view class="seg-tab {{activeTab === 'inspect' ? 'active' : ''}}" data-tab="inspect" bindtap="switchTab">加工验收</view>
|
||
<view class="seg-tab {{activeTab === 'done' ? 'active' : ''}}" data-tab="done" bindtap="switchTab">加工历史</view>
|
||
</view>
|
||
|
||
<view class="filter-row">
|
||
<view class="filter-chip {{dateField === 'delivery_date' ? 'active' : ''}}" data-field="delivery_date" bindtap="setDateField">配送日</view>
|
||
<view class="filter-chip {{dateField === 'created_at' ? 'active' : ''}}" data-field="created_at" bindtap="setDateField">下单日</view>
|
||
</view>
|
||
<view class="filter-row">
|
||
<view class="filter-chip {{viewMode === 'today' ? 'active' : ''}}" bindtap="showToday">今天</view>
|
||
<view class="filter-chip {{viewMode === 'week' ? 'active' : ''}}" bindtap="showWeekRange">近七天</view>
|
||
<picker mode="date" value="{{deliveryDate}}" bindchange="onDeliveryDateChange">
|
||
<view class="filter-chip {{viewMode === 'date' ? 'active' : ''}}">指定日</view>
|
||
</picker>
|
||
</view>
|
||
<view wx:if="{{periodSummary}}" class="period-summary">{{periodSummary}}</view>
|
||
|
||
<view class="list-head">
|
||
<view class="list-head-left">
|
||
<view class="section-mark"></view>
|
||
<view class="section-title">加工任务</view>
|
||
</view>
|
||
<view class="create-link" bindtap="openCreateForm">+ 创建独立加工</view>
|
||
</view>
|
||
|
||
<view wx:if="{{error}}" class="state-error">{{error}}</view>
|
||
<view wx:if="{{loading}}" class="state-box">加载中...</view>
|
||
<view wx:elif="{{!loading && rows.length === 0}}" class="empty-box">
|
||
<view class="empty-title">{{activeTab === 'work' ? '暂无待加工任务' : activeTab === 'inspect' ? '暂无待加工验收' : '暂无历史记录'}}</view>
|
||
<view class="empty-hint">{{activeTab === 'work' ? '仓内加工需求会汇总到这里,也可自行创建独立加工' : '可切换日期或状态查看'}}</view>
|
||
</view>
|
||
|
||
<view wx:for="{{rows}}" wx:key="id" class="task-card">
|
||
<view class="task-card-head">
|
||
<view class="task-name">{{item.item_name || '商品'}}</view>
|
||
<view class="task-status {{item.process_status === 20 ? 'is-doing' : item.process_status >= 40 ? 'is-done' : ''}}">{{item.statusText}}</view>
|
||
</view>
|
||
|
||
<view wx:if="{{item.is_demand}}" class="task-meta">
|
||
<text>{{item.task_code}}</text>
|
||
<text>已入库 {{item.net_weight_text}} / 需求 {{item.source_qty_text}}<text wx:if="{{item.display_unit}}" class="qty-unit">{{item.display_unit}}</text></text>
|
||
<text class="tag">仓内加工单</text>
|
||
</view>
|
||
<view wx:elif="{{item.source_type === 'standalone'}}" class="task-meta">
|
||
<text>{{item.task_code}}</text>
|
||
<text class="tag">独立加工</text>
|
||
</view>
|
||
<view wx:else class="task-meta">
|
||
<text>订单 {{item.order_code}}</text>
|
||
<text class="tag">仓内加工单</text>
|
||
</view>
|
||
|
||
<view class="task-meta">
|
||
<text wx:if="{{item.delivery_date_text}}">配送 {{item.delivery_date_text}}</text>
|
||
<text wx:if="{{item.processing_method}}">{{item.processing_method}}</text>
|
||
<text wx:if="{{!item.is_demand}}">验收 {{item.source_qty_text}}<text wx:if="{{item.display_unit}}" class="qty-unit">{{item.display_unit}}</text></text>
|
||
<text wx:if="{{item.display_unit_price}}">单价 ¥{{item.display_unit_price}}<text wx:if="{{item.display_unit}}">/{{item.display_unit}}</text></text>
|
||
</view>
|
||
|
||
<view wx:if="{{activeTab === 'work'}}" class="task-actions">
|
||
<view class="task-hint" wx:if="{{item.is_demand}}">从库存领料加工成品</view>
|
||
<view class="task-hint is-warn" wx:elif="{{!item.is_standalone && !item.inspection_completed}}">待完成到货验收后可开始加工</view>
|
||
<button wx:if="{{item.is_demand && item.can_start_work}}" class="btn-primary" size="mini" data-id="{{item.id}}" bindtap="openDemandPick">领料加工</button>
|
||
<button wx:elif="{{item.can_start_work}}" class="btn-primary" size="mini" data-id="{{item.id}}" bindtap="openWorkForm">
|
||
{{item.process_status === 10 ? '开始加工' : '提交完工'}}
|
||
</button>
|
||
</view>
|
||
|
||
<view wx:if="{{activeTab === 'inspect'}}" class="inspect-block">
|
||
<view class="kpi-row">
|
||
<view class="kpi-cell">
|
||
<text class="kpi-label">净重</text>
|
||
<text class="kpi-value">{{item.net_weight || '-'}}</text>
|
||
</view>
|
||
<view class="kpi-cell">
|
||
<text class="kpi-label">毛重</text>
|
||
<text class="kpi-value">{{item.gross_weight || '-'}}</text>
|
||
</view>
|
||
<view class="kpi-cell" wx:if="{{item.loss_qty_text}}">
|
||
<text class="kpi-label">损耗</text>
|
||
<text class="kpi-value">{{item.loss_qty_text}}</text>
|
||
</view>
|
||
</view>
|
||
<view class="task-meta" wx:if="{{item.process_unit_price || item.display_unit_price}}">
|
||
加工单价 ¥{{item.process_unit_price || item.display_unit_price}}<text wx:if="{{item.display_unit}}">/{{item.display_unit}}</text>
|
||
</view>
|
||
<view wx:if="{{item.photoRequired}}" class="photo-count">已上传 {{item.inspection_photo_count || 0}} 张加工后照片</view>
|
||
<picker mode="selector" range="{{grades}}" data-id="{{item.id}}" bindchange="onGradeChange">
|
||
<view class="field-picker">验收结果 {{item.input_grade || '合格'}} ▾</view>
|
||
</picker>
|
||
<view class="task-actions">
|
||
<button wx:if="{{item.photoRequired}}" class="btn-secondary" size="mini" data-id="{{item.id}}" bindtap="choosePhoto">拍照上传</button>
|
||
<button class="btn-secondary" size="mini" data-id="{{item.id}}" bindtap="rejectInspection">退回</button>
|
||
<button class="btn-primary" size="mini" data-id="{{item.id}}" bindtap="submitInspection">确认完成</button>
|
||
</view>
|
||
</view>
|
||
|
||
<view wx:if="{{activeTab === 'done'}}" class="task-meta">
|
||
<text>结果 {{item.result_label || item.quality_rating || '-'}}</text>
|
||
<text wx:if="{{item.net_weight}}">净重 {{item.net_weight}}</text>
|
||
<text wx:if="{{item.loss_qty_text}}">损耗 {{item.loss_qty_text}}</text>
|
||
<text wx:if="{{item.process_unit_price || item.display_unit_price}}">单价 ¥{{item.process_unit_price || item.display_unit_price}}</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view
|
||
wx:if="{{(activeTab === 'work' && !showWorkModal && !showCreateModal) || (activeTab === 'inspect' && !showCreateModal)}}"
|
||
class="bottom-bar-slot {{embedded ? 'bottom-bar-slot--embedded' : ''}}"
|
||
/>
|
||
</view>
|
||
|
||
<root-portal enable="{{true}}">
|
||
<view wx:if="{{(activeTab === 'work' && !showWorkModal && !showCreateModal) || (activeTab === 'inspect' && !showCreateModal)}}" class="stats-bar stats-bar-dual {{embedded ? 'stats-bar--embedded' : ''}}">
|
||
<view class="stats-item stats-item-qty">
|
||
<text class="stats-label">加工商品数</text>
|
||
<text class="stats-value">{{todayProcessItemCount || 0}}</text>
|
||
</view>
|
||
<view class="stats-divider"></view>
|
||
<view class="stats-item">
|
||
<text class="stats-label">{{statsPeriodLabel}}加工合计</text>
|
||
<text class="stats-value">¥{{todayProcessFeeText}}</text>
|
||
</view>
|
||
</view>
|
||
</root-portal>
|
||
|
||
<root-portal enable="{{true}}">
|
||
<view wx:if="{{showCreateModal}}" class="sheet-mask" catchtouchmove="stopCreateTap" bindtap="closeCreateForm">
|
||
<view class="sheet-card" catchtap="stopCreateTap" catchtouchmove="stopCreateTap">
|
||
<view class="sheet-head">
|
||
<view>
|
||
<view class="sheet-title">{{pickTaskId ? '需求单领料' : '创建独立加工'}}</view>
|
||
<view class="sheet-sub">{{pickTaskId ? '选择库存原料并填写数量,可多次领料' : '选库存商品填数量,确认后扣库存并记原料成本'}}</view>
|
||
<view wx:if="{{pickTaskId}}" class="sheet-demand">
|
||
<text>成品 {{pickDemandName}}</text>
|
||
<text class="sheet-demand-qty">需加工 {{pickDemandQtyText}}<text wx:if="{{pickDemandUnit}}" class="sheet-demand-unit">{{pickDemandUnit}}</text></text>
|
||
<text class="sheet-demand-qty">已入库 {{pickDemandInboundText}}<text wx:if="{{pickDemandUnit}}" class="sheet-demand-unit">{{pickDemandUnit}}</text></text>
|
||
</view>
|
||
</view>
|
||
<view class="sheet-close" bindtap="closeCreateForm">×</view>
|
||
</view>
|
||
<scroll-view scroll-y class="sheet-body" show-scrollbar="{{false}}">
|
||
<view class="field">
|
||
<text class="field-label">商品</text>
|
||
<input class="field-input" placeholder="输入品名或编码搜索" value="{{createForm.skuSearch}}" data-field="skuSearch" bindinput="onCreateInput" />
|
||
</view>
|
||
<view wx:if="{{createSkuOptions.length}}" class="sku-options">
|
||
<view wx:for="{{createSkuOptions}}" wx:key="sku_code" class="sku-option" catchtap="selectCreateSku" data-sku="{{item.sku_code}}">
|
||
<text class="sku-name">{{item.sku_name}}</text>
|
||
<text class="sku-meta">{{item.sku_code}} · 可用 {{item.available_qty}}<text wx:if="{{item.display_unit}}" class="qty-unit">{{item.display_unit}}</text></text>
|
||
</view>
|
||
</view>
|
||
<view wx:if="{{createForm.selectedSku}}" class="selected-sku">已选 {{createForm.selectedSku.sku_name}}</view>
|
||
<!-- 独立加工:多行原料(每行独立商品 + 数量,可删) -->
|
||
<view wx:if="{{!pickTaskId}}" class="field">
|
||
<text class="field-label">原料明细(可多行)</text>
|
||
<view wx:if="{{!createMaterials.length}}" class="sheet-sub">请在上方搜索并选择原料商品</view>
|
||
<view wx:for="{{createMaterials}}" wx:key="sku_code" class="selected-sku" style="display:flex;align-items:center;gap:8rpx;">
|
||
<text style="flex:1;">{{index + 1}}. {{item.sku_name}}(可用 {{item.available_qty}}{{item.display_unit}})</text>
|
||
<input class="field-input" style="width:140rpx;" type="digit" placeholder="数量" value="{{item.qty}}" data-sku="{{item.sku_code}}" bindinput="onCreateMaterialQty" />
|
||
<text style="color:#e11d48;" data-sku="{{item.sku_code}}" catchtap="removeCreateMaterial">删除</text>
|
||
</view>
|
||
</view>
|
||
<view class="field-grid">
|
||
<view wx:if="{{pickTaskId}}" class="field">
|
||
<text class="field-label">领料数量</text>
|
||
<input class="field-input" type="digit" placeholder="0" value="{{createForm.qty}}" data-field="qty" bindinput="onCreateInput" />
|
||
</view>
|
||
<view wx:if="{{!pickTaskId}}" class="field">
|
||
<text class="field-label">加工方式</text>
|
||
<input class="field-input" placeholder="切块 / 切丝" value="{{createForm.processingMethod}}" data-field="processingMethod" bindinput="onCreateInput" />
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">加工单价</text>
|
||
<input class="field-input" type="digit" placeholder="选填,不入账" value="{{createForm.processUnitPrice}}" data-field="processUnitPrice" bindinput="onCreateInput" />
|
||
</view>
|
||
<view class="field field-span">
|
||
<text class="field-label">备注</text>
|
||
<input class="field-input" placeholder="选填" value="{{createForm.remark}}" data-field="remark" bindinput="onCreateInput" />
|
||
</view>
|
||
</view>
|
||
</scroll-view>
|
||
<view class="sheet-actions">
|
||
<button class="btn-ghost" bindtap="closeCreateForm">取消</button>
|
||
<button class="btn-primary btn-block" loading="{{saving}}" bindtap="submitCreate">{{pickTaskId ? '确认领料' : '确认创建'}}</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</root-portal>
|
||
|
||
<root-portal enable="{{true}}">
|
||
<view wx:if="{{showOutputModal}}" class="sheet-mask" catchtouchmove="stopCreateTap" bindtap="closeOutputForm">
|
||
<view class="sheet-card" catchtap="stopCreateTap">
|
||
<view class="sheet-head">
|
||
<view>
|
||
<view class="sheet-title">申报加工成品</view>
|
||
<view class="sheet-sub">{{outputTaskCode}} · 原料投入合计 {{outputMaterialQty}}{{outputUnit}}</view>
|
||
</view>
|
||
<view class="sheet-close" bindtap="closeOutputForm">×</view>
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">成品明细(可多行)</text>
|
||
<!-- 受控输入框:只写回用户输入;搜不到时给「用该名称新建商品」入口(绝不用搜索结果覆盖输入框) -->
|
||
<input class="field-input" placeholder="搜索成品商品,点下方加入" value="{{outputSkuSearch}}" bindinput="onOutputSkuInput" />
|
||
<view wx:if="{{outputSkuOptions.length}}" class="sku-options">
|
||
<view wx:for="{{outputSkuOptions}}" wx:key="sku_code" class="sku-option" catchtap="addOutputSku" data-sku="{{item.sku_code}}">
|
||
<text class="sku-name">{{item.sku_name}}</text>
|
||
<text class="sku-meta">{{item.sku_code}}{{item.spec ? ' · ' + item.spec : ''}}</text>
|
||
</view>
|
||
</view>
|
||
<view wx:elif="{{outputSkuSearch}}" class="sku-options">
|
||
<view class="sku-option sku-option-create" catchtap="openOutputProductForm">
|
||
<text class="sku-name">搜不到「{{outputSkuSearch}}」,点此用该名称新建商品</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view wx:for="{{outputRows}}" wx:key="sku_code" class="loss-box">
|
||
<view class="loss-row">
|
||
<text>{{index + 1}}. {{item.sku_name}}</text>
|
||
<text style="color:#e11d48;" data-sku="{{item.sku_code}}" catchtap="removeOutputRow">删除</text>
|
||
</view>
|
||
<view class="field-grid">
|
||
<view class="field">
|
||
<text class="field-label">产出数量</text>
|
||
<input class="field-input" type="digit" placeholder="0" value="{{item.qty}}" data-sku="{{item.sku_code}}" bindinput="onOutputQtyInput" />
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">入库成本价(默认均分)</text>
|
||
<input class="field-input" type="digit" placeholder="自动" value="{{item.unit_cost}}" data-sku="{{item.sku_code}}" bindinput="onOutputCostInput" />
|
||
</view>
|
||
</view>
|
||
<view class="inherit-row">
|
||
<view class="inherit-toggle {{item.inherit_batch_report ? 'is-on' : ''}}" data-sku="{{item.sku_code}}" data-field="inherit_batch_report" catchtap="toggleOutputInherit">
|
||
<view class="inherit-check">{{item.inherit_batch_report ? '✓' : ''}}</view>
|
||
<text class="inherit-label">继承原料批次报告</text>
|
||
</view>
|
||
<view class="inherit-toggle {{item.inherit_inspection_report ? 'is-on' : ''}}" data-sku="{{item.sku_code}}" data-field="inherit_inspection_report" catchtap="toggleOutputInherit">
|
||
<view class="inherit-check">{{item.inherit_inspection_report ? '✓' : ''}}</view>
|
||
<text class="inherit-label">继承原料检验报告</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="loss-box">
|
||
<view class="loss-row">
|
||
<text>损耗数量(不填=自动差额)</text>
|
||
<text class="loss-value">{{outputLoss}}</text>
|
||
</view>
|
||
<view class="loss-hint">自动差额:{{outputAutoLoss}}{{outputUnit}}(可改,改后不再自动)</view>
|
||
<input class="field-input" type="digit" placeholder="自动" value="{{outputLoss}}" bindinput="onOutputLossInput" />
|
||
</view>
|
||
<view class="sheet-actions">
|
||
<button class="btn-ghost" bindtap="closeOutputForm">取消</button>
|
||
<button class="btn-primary btn-block" loading="{{saving}}" bindtap="submitOutput">确认完工并回仓</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 搜不到 → 新建成品商品(复用库存入库同一个建品接口与字段) -->
|
||
<view wx:if="{{showOutputProductModal}}" class="sheet-mask" catchtouchmove="stopCreateTap" bindtap="closeOutputProductForm">
|
||
<view class="sheet-card" catchtap="stopCreateTap">
|
||
<view class="sheet-head">
|
||
<view>
|
||
<view class="sheet-title">新建商品</view>
|
||
</view>
|
||
<view class="sheet-close" bindtap="closeOutputProductForm">×</view>
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">品名<text class="req-mark">*</text></text>
|
||
<input class="field-input" placeholder="商品名" value="{{outputProductForm.name}}" data-field="name" bindinput="onOutputProductField" />
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">分类<text class="req-mark">*</text></text>
|
||
<!-- 内联分类标签(不再弹滚轮选择器);末尾可就地新建分类 -->
|
||
<view class="cat-chips">
|
||
<view wx:for="{{outputCategoryOptions}}" wx:key="code" class="cat-chip {{outputProductForm.categoryIndex === index ? 'is-on' : ''}}" data-index="{{index}}" catchtap="pickOutputCategory">{{item.label}}</view>
|
||
<view class="cat-chip cat-chip-add" catchtap="toggleOutputCategoryCreate">+ 新建分类</view>
|
||
</view>
|
||
<view wx:if="{{outputCategoryCreating}}" class="cat-create-row">
|
||
<input class="field-input cat-create-input" placeholder="分类名" value="{{outputCategoryName}}" bindinput="onOutputCategoryNameInput" />
|
||
<view class="cat-create-btn {{creatingOutputCategory ? 'is-disabled' : ''}}" catchtap="submitOutputCategory">确定</view>
|
||
<view class="cat-create-cancel" catchtap="cancelOutputCategoryCreate">取消</view>
|
||
</view>
|
||
</view>
|
||
<view class="field-grid">
|
||
<view class="field">
|
||
<text class="field-label">规格</text>
|
||
<input class="field-input" placeholder="规格" value="{{outputProductForm.spec}}" data-field="spec" bindinput="onOutputProductField" />
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">单位</text>
|
||
<input class="field-input" placeholder="单位" value="{{outputProductForm.unit}}" data-field="unit" bindinput="onOutputProductField" />
|
||
</view>
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">生产地区</text>
|
||
<input class="field-input" placeholder="生产地区" value="{{outputProductForm.origin}}" data-field="origin" bindinput="onOutputProductField" />
|
||
</view>
|
||
<view class="sheet-actions">
|
||
<button class="btn-ghost" bindtap="closeOutputProductForm">取消</button>
|
||
<button class="btn-primary btn-block" loading="{{creatingOutputProduct}}" bindtap="submitOutputProduct">确定</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view wx:if="{{showWorkModal}}" class="sheet-mask" catchtouchmove="stopCreateTap" bindtap="closeWorkForm">
|
||
<view class="sheet-card" catchtap="stopCreateTap">
|
||
<view class="sheet-head">
|
||
<view>
|
||
<view class="sheet-title">{{workTaskStatus === 10 ? '开始加工' : '提交加工完工'}}</view>
|
||
<view class="sheet-sub">填写毛重、净重和加工单价;同品名会带出上次记录</view>
|
||
</view>
|
||
<view class="sheet-close" bindtap="closeWorkForm">×</view>
|
||
</view>
|
||
<view class="field-grid">
|
||
<view class="field">
|
||
<text class="field-label">毛重 ({{workUnit}})</text>
|
||
<input class="field-input" type="digit" placeholder="0" value="{{workForm.grossWeight}}" data-field="grossWeight" bindinput="onWorkInput" />
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">净重 ({{workUnit}})</text>
|
||
<input class="field-input" type="digit" placeholder="0" value="{{workForm.netWeight}}" data-field="netWeight" bindinput="onWorkInput" />
|
||
</view>
|
||
</view>
|
||
<view class="loss-box">
|
||
<view class="loss-row">
|
||
<text>加工损耗(毛重 − 净重)</text>
|
||
<text class="loss-value">{{workLossText}}</text>
|
||
</view>
|
||
<view class="loss-hint">入库不计损耗,仅在本环节登记</view>
|
||
</view>
|
||
<view class="field-grid">
|
||
<view class="field">
|
||
<text class="field-label">加工单价 (元/{{workUnit}})</text>
|
||
<input class="field-input" type="digit" placeholder="0" value="{{workForm.processUnitPrice}}" data-field="processUnitPrice" bindinput="onWorkInput" />
|
||
</view>
|
||
<view class="field">
|
||
<text class="field-label">备注</text>
|
||
<input class="field-input" placeholder="选填" value="{{workForm.remark}}" data-field="remark" bindinput="onWorkInput" />
|
||
</view>
|
||
</view>
|
||
<view class="sheet-actions">
|
||
<button class="btn-ghost" bindtap="closeWorkForm">取消</button>
|
||
<button class="btn-primary btn-block" loading="{{saving}}" bindtap="submitWork">完成加工</button>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</root-portal>
|