Commit 6c80b5d7cddbec7e41800618e2dc829d420de9ea

Authored by gesilong
1 parent 0aa83bbb

commit:联调仓库收料单

  1 +import request from '@/utils/request'
  2 +import { ContentTypeEnum } from '@/utils/httpEnum'
  3 +
  4 +// 仓库收料单(对齐 PC 端 api/warehouse-manage/warehouse-material)
  5 +const baseUrl = '/procurement/warehouse/receive'
  6 +
  7 +/**
  8 + * 分页查询仓库收料单列表
  9 + * params: pageIndex, pageSize, weighingTicketCode, ticketDateStart, ticketDateEnd,
  10 + * planCode, supplierName, workshopId, flowNode, approvalStatus
  11 + */
  12 +export function warehouseReceiveQueryApi(params) {
  13 + return request({
  14 + url: baseUrl + '/query',
  15 + method: 'get',
  16 + params
  17 + })
  18 +}
  19 +
  20 +/**
  21 + * 码单编号可选数据(原料结算详情单,新增仓库收料单-选择弹窗)
  22 + * params: code(码单编号), supplierName(客户名称), workshopId(分厂ID)
  23 + */
  24 +export function warehouseReceiveSettleOptionsApi(params) {
  25 + return request({
  26 + url: baseUrl + '/settleOptions',
  27 + method: 'get',
  28 + params
  29 + })
  30 +}
  31 +
  32 +/**
  33 + * 按结算详情单ID带出原料结算详情单详情数据(含明细行默认值)
  34 + * params: settleDetailId-原料结算详情单ID
  35 + */
  36 +export function warehouseReceiveSettleDataApi(params) {
  37 + return request({
  38 + url: baseUrl + '/settleData',
  39 + method: 'get',
  40 + params
  41 + })
  42 +}
  43 +
  44 +/**
  45 + * 新增仓库收料单
  46 + */
  47 +export function warehouseReceiveCreateApi(data) {
  48 + return request({
  49 + url: baseUrl,
  50 + method: 'post',
  51 + data,
  52 + contentType: ContentTypeEnum.JSON
  53 + })
  54 +}
  55 +
  56 +/**
  57 + * 查询仓库收料单详情
  58 + * params: { id }
  59 + */
  60 +export function warehouseReceiveDetailApi(params) {
  61 + return request({
  62 + url: baseUrl,
  63 + method: 'get',
  64 + params
  65 + })
  66 +}
  67 +
  68 +/**
  69 + * 修改仓库收料单
  70 + */
  71 +export function warehouseReceiveUpdateApi(data) {
  72 + return request({
  73 + url: baseUrl,
  74 + method: 'put',
  75 + data,
  76 + contentType: ContentTypeEnum.JSON
  77 + })
  78 +}
  79 +
  80 +/**
  81 + * 提交审核
  82 + */
  83 +export function warehouseReceiveSubmitAuditApi(id) {
  84 + return request({
  85 + url: baseUrl + '/submit?id=' + id,
  86 + method: 'put'
  87 + })
  88 +}
  89 +
  90 +/**
  91 + * 取消收料单
  92 + */
  93 +export function warehouseReceiveCancelApi(id) {
  94 + return request({
  95 + url: baseUrl + '/cancel?id=' + id,
  96 + method: 'put'
  97 + })
  98 +}
  99 +
  100 +/**
  101 + * 分厂下拉数据(PC: base-data/maker,即 baseData/workshop)
  102 + */
  103 +export function workshopQueryApi(params) {
  104 + return request({
  105 + url: '/baseData/workshop/query',
  106 + method: 'get',
  107 + params
  108 + })
  109 +}
@@ -693,6 +693,38 @@ @@ -693,6 +693,38 @@
693 } 693 }
694 }, 694 },
695 { 695 {
  696 + "path": "pages/warehouse-material/index",
  697 + "style": {
  698 + "navigationBarTitleText": "仓库收料单",
  699 + "navigationBarBackgroundColor": "#ffffff",
  700 + "navigationBarTextStyle": "black"
  701 + }
  702 + },
  703 + {
  704 + "path": "pages/warehouse-material/add",
  705 + "style": {
  706 + "navigationBarTitleText": "新增仓库收料单",
  707 + "navigationBarBackgroundColor": "#ffffff",
  708 + "navigationBarTextStyle": "black"
  709 + }
  710 + },
  711 + {
  712 + "path": "pages/warehouse-material/detail",
  713 + "style": {
  714 + "navigationBarTitleText": "仓库收料单详情",
  715 + "navigationBarBackgroundColor": "#ffffff",
  716 + "navigationBarTextStyle": "black"
  717 + }
  718 + },
  719 + {
  720 + "path": "pages/warehouse-material/modify",
  721 + "style": {
  722 + "navigationBarTitleText": "编辑仓库收料单",
  723 + "navigationBarBackgroundColor": "#ffffff",
  724 + "navigationBarTextStyle": "black"
  725 + }
  726 + },
  727 + {
696 "path": "pages/order_list/index", 728 "path": "pages/order_list/index",
697 "style": { 729 "style": {
698 "navigationBarTitleText": "订货单列表", 730 "navigationBarTitleText": "订货单列表",
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <!-- 基础信息 -->
  5 + <uni-list>
  6 + <uni-list-item class="select-item" :class="form.settleDetailId ? 'is-filled' : 'is-empty'" clickable
  7 + @click="openSettleSheet" :rightText="form.weighingTicketCode || '请选择结算详情单'" showArrow>
  8 + <template v-slot:body>
  9 + <view class="item-title"><text class="required">*</text><text>码单编号</text></view>
  10 + </template>
  11 + </uni-list-item>
  12 + <uni-list-item title="日期">
  13 + <template v-slot:footer>
  14 + <uni-easyinput :value="form.ticketDate" :inputBorder="false" disabled placeholder="选择结算详情单后自动带出" />
  15 + </template>
  16 + </uni-list-item>
  17 + <uni-list-item title="材料来源">
  18 + <template v-slot:footer>
  19 + <uni-easyinput :value="form.materialSource" :inputBorder="false" disabled placeholder="选择结算详情单后自动带出" />
  20 + </template>
  21 + </uni-list-item>
  22 + <uni-list-item title="计划单编号">
  23 + <template v-slot:footer>
  24 + <uni-easyinput :value="form.planCodes" :inputBorder="false" disabled placeholder="选择结算详情单后自动带出" />
  25 + </template>
  26 + </uni-list-item>
  27 + <uni-list-item title="分厂">
  28 + <template v-slot:footer>
  29 + <uni-easyinput :value="form.workshopName" :inputBorder="false" disabled placeholder="选择结算详情单后自动带出" />
  30 + </template>
  31 + </uni-list-item>
  32 + </uni-list>
  33 +
  34 + <!-- 明细数据(可编辑) -->
  35 + <view class="sub-table">
  36 + <view class="header">
  37 + <image class="opCollapse" src="/static/images/title.png" />
  38 + <text class="title">明细数据</text>
  39 + </view>
  40 + <view class="add-list">
  41 + <view v-if="!lineList.length" class="empty-tip">选择结算详情单后自动带出</view>
  42 + <view v-for="(item, idx) in lineList" :key="'l-' + (item.rowId || idx)" class="block">
  43 + <uni-list>
  44 + <uni-list-item title="材料编号">
  45 + <template v-slot:footer>
  46 + <uni-easyinput :value="item.category" :inputBorder="false" disabled />
  47 + </template>
  48 + </uni-list-item>
  49 + <uni-list-item title="材料名称">
  50 + <template v-slot:footer>
  51 + <uni-easyinput :value="item.name" :inputBorder="false" disabled />
  52 + </template>
  53 + </uni-list-item>
  54 + <uni-list-item title="规格型号">
  55 + <template v-slot:footer>
  56 + <uni-easyinput :value="item.specModel" :inputBorder="false" disabled />
  57 + </template>
  58 + </uni-list-item>
  59 + <uni-list-item title="单位">
  60 + <template v-slot:footer>
  61 + <uni-easyinput :value="item.unit" :inputBorder="false" disabled />
  62 + </template>
  63 + </uni-list-item>
  64 + <uni-list-item>
  65 + <template v-slot:body>
  66 + <view class="item-title"><text class="required">*</text><text>数量(采购数)</text></view>
  67 + </template>
  68 + <template v-slot:footer>
  69 + <uni-easyinput v-model="item.purchaseQuantity" type="digit" :inputBorder="false" placeholder="请输入采购数" @input="recalcTaxAmount(item)" />
  70 + </template>
  71 + </uni-list-item>
  72 + <uni-list-item>
  73 + <template v-slot:body>
  74 + <view class="item-title"><text class="required">*</text><text>数量(实收数)</text></view>
  75 + </template>
  76 + <template v-slot:footer>
  77 + <uni-easyinput v-model="item.actualQuantity" type="digit" :inputBorder="false" placeholder="请输入实收数" />
  78 + </template>
  79 + </uni-list-item>
  80 + <uni-list-item>
  81 + <template v-slot:body>
  82 + <view class="item-title"><text class="required">*</text><text>含税单价</text></view>
  83 + </template>
  84 + <template v-slot:footer>
  85 + <uni-easyinput v-model="item.taxPrice" type="digit" :inputBorder="false" placeholder="请输入含税单价" @input="recalcTaxAmount(item)" />
  86 + </template>
  87 + </uni-list-item>
  88 + <uni-list-item title="含税金额">
  89 + <template v-slot:footer>
  90 + <uni-easyinput :value="item.taxAmount" :inputBorder="false" disabled placeholder="单价×采购数自动计算" />
  91 + </template>
  92 + </uni-list-item>
  93 + <uni-list-item title="不含税单价">
  94 + <template v-slot:footer>
  95 + <uni-easyinput :value="item.noTaxPrice" :inputBorder="false" disabled />
  96 + </template>
  97 + </uni-list-item>
  98 + <uni-list-item title="不含税金额">
  99 + <template v-slot:footer>
  100 + <uni-easyinput :value="item.noTaxAmount" :inputBorder="false" disabled />
  101 + </template>
  102 + </uni-list-item>
  103 + <uni-list-item title="备注">
  104 + <template v-slot:footer>
  105 + <uni-easyinput v-model="item.remark" :inputBorder="false" placeholder="请输入备注" />
  106 + </template>
  107 + </uni-list-item>
  108 + </uni-list>
  109 + </view>
  110 + </view>
  111 + </view>
  112 +
  113 + <!-- 合计 -->
  114 + <view class="total-card">
  115 + <view class="total-title">合计</view>
  116 + <view class="total-body">
  117 + <view class="total-item">
  118 + <text class="total-label">采购数</text>
  119 + <text class="total-value">{{ purchaseQuantityCap }}</text>
  120 + </view>
  121 + <view class="total-item">
  122 + <text class="total-label">实收数</text>
  123 + <text class="total-value">{{ totalActualQuantity || '-' }}</text>
  124 + </view>
  125 + <view class="total-item">
  126 + <text class="total-label">含税金额</text>
  127 + <text class="total-value">{{ totalTaxAmount || '-' }}</text>
  128 + </view>
  129 + </view>
  130 + </view>
  131 +
  132 + <!-- 其他信息 -->
  133 + <view class="remark-section">
  134 + <view class="header">
  135 + <image class="opCollapse" src="/static/images/title.png" />
  136 + <text class="title">其他信息</text>
  137 + </view>
  138 + <view class="section-content">
  139 + <view class="remark-group">
  140 + <view class="remark-label">备注</view>
  141 + <uni-easyinput v-model="form.remark" type="textarea" :inputBorder="false" placeholder="请输入备注" maxlength="2000" autoHeight />
  142 + </view>
  143 +
  144 + <!-- 附件 -->
  145 + <view class="form-group">
  146 + <view class="item-title"><text class="required">*</text><text>附件</text></view>
  147 + <view class="upload-btn" @click="selectFile">上传文件</view>
  148 + <view v-if="!fileList.length" class="empty-tip">请上传附件</view>
  149 + <view v-for="(file, idx) in fileList" :key="file.fileId || idx" class="file-item">
  150 + <text class="file-name">{{ file.fileName || '未命名文件' }}</text>
  151 + <text class="file-del" @click="removeFile(idx)">删除</text>
  152 + </view>
  153 + </view>
  154 + </view>
  155 + </view>
  156 +
  157 + <view class="footer">
  158 + <button class="btn submit" type="primary" @click="onSubmit">保存</button>
  159 + </view>
  160 + </scroll-view>
  161 +
  162 + <RelateSelectSheet :visible.sync="settleSheet.visible" title="选择结算详情单" :multiple="false"
  163 + :fetchFn="settleSheet.fetchFn" :display-fields="settleSheet.displayFields"
  164 + row-key="settleDetailId" :selectedKeys.sync="settleSheet.selectedKeys" @confirm="onSettleConfirm" />
  165 + </view>
  166 +</template>
  167 +
  168 +<script>
  169 +import RelateSelectSheet from '@/components/relate-select/index.vue'
  170 +import {
  171 + warehouseReceiveSettleOptionsApi,
  172 + warehouseReceiveSettleDataApi,
  173 + warehouseReceiveCreateApi
  174 +} from '@/api/procure-manage/warehouseMaterial.js'
  175 +import { getDicByCodes } from '@/utils/dic.js'
  176 +import upload from '@/utils/upload'
  177 +import { uploadFileApi } from '@/api/base.js'
  178 +
  179 +export default {
  180 + name: 'AddWarehouseMaterial',
  181 + components: { RelateSelectSheet },
  182 + data() {
  183 + return {
  184 + form: {
  185 + settleDetailId: '',
  186 + weighingTicketId: '',
  187 + weighingTicketCode: '',
  188 + ticketDate: '',
  189 + materialSource: '',
  190 + planCodes: '',
  191 + workshopId: '',
  192 + workshopName: '',
  193 + supplierName: '',
  194 + remark: '',
  195 + attachmentFileIds: '',
  196 + attachmentFileNames: ''
  197 + },
  198 + dicOptions: { SETTLE_TYPE: [] },
  199 + // 选中的结算详情单行
  200 + selectedSettleRow: null,
  201 + // 明细数据(选择结算详情单后带出)
  202 + lineList: [],
  203 + // 计划ID集合(由结算详情单带出)
  204 + planIds: [],
  205 + // 附件列表 [{ fileId, fileName }]
  206 + fileList: [],
  207 + settleSheet: {
  208 + visible: false,
  209 + fetchFn: null,
  210 + displayFields: [
  211 + { label: '码单编号', field: 'weighingTicketCode' },
  212 + { label: '日期', field: 'ticketDate' },
  213 + { label: '材料来源', field: 'materialSource' },
  214 + { label: '分厂', field: 'workshopName' },
  215 + { label: '结算类型', field: 'settleType', map: {} }
  216 + ],
  217 + selectedKeys: []
  218 + }
  219 + }
  220 + },
  221 + computed: {
  222 + // 合计-采购数(保留两位)
  223 + totalPurchaseQuantity() {
  224 + const list = this.lineList || []
  225 + return Number(list.reduce((sum, row) => sum + Number(row.purchaseQuantity || 0), 0).toFixed(2))
  226 + },
  227 + // 合计-实收数(保留两位)
  228 + totalActualQuantity() {
  229 + const list = this.lineList || []
  230 + return Number(list.reduce((sum, row) => sum + Number(row.actualQuantity || 0), 0).toFixed(2))
  231 + },
  232 + // 合计-含税金额(保留两位)
  233 + totalTaxAmount() {
  234 + const list = this.lineList || []
  235 + return Number(list.reduce((sum, row) => sum + Number(row.taxAmount || 0), 0).toFixed(2))
  236 + },
  237 + // 合计-采购数大写(中文大写+公斤)
  238 + purchaseQuantityCap() {
  239 + if (!(this.lineList || []).length) return '-'
  240 + return numberToChineseUpper(this.totalPurchaseQuantity) + '公斤'
  241 + }
  242 + },
  243 + created() {
  244 + this.settleSheet.fetchFn = this.fetchSettleList.bind(this)
  245 + this.loadDicData()
  246 + },
  247 + methods: {
  248 + async loadDicData() {
  249 + try {
  250 + const results = await getDicByCodes(['SETTLE_TYPE'])
  251 + const items = (results.SETTLE_TYPE && results.SETTLE_TYPE.data) || []
  252 + this.dicOptions.SETTLE_TYPE = items
  253 + // 结算类型显示映射
  254 + const map = {}
  255 + items.forEach(it => { map[it.code != null ? String(it.code) : ''] = it.name || '' })
  256 + this.settleSheet.displayFields[4].map = map
  257 + } catch (e) {
  258 + this.dicOptions = { SETTLE_TYPE: [] }
  259 + }
  260 + },
  261 + // 结算详情单选择弹窗数据源(接口不分页,包装为组件所需格式)
  262 + fetchSettleList({ pageIndex, pageSize, extra }) {
  263 + const keyword = (extra && extra.keyword) || ''
  264 + const params = {
  265 + code: keyword || undefined
  266 + }
  267 + return warehouseReceiveSettleOptionsApi(params).then(res => {
  268 + const datas = (res && res.data) || []
  269 + const records = (Array.isArray(datas) ? datas : []).map(it => ({ ...it }))
  270 + return { records, totalCount: records.length, hasNext: false }
  271 + }).catch(() => ({ records: [], totalCount: 0, hasNext: false }))
  272 + },
  273 + openSettleSheet() {
  274 + this.settleSheet.selectedKeys = this.selectedSettleRow ? [this.selectedSettleRow.settleDetailId || this.selectedSettleRow.id] : []
  275 + this.settleSheet.visible = true
  276 + },
  277 + // 结算详情单选择回调:主表信息由选中行带出,选中后按结算详情单ID查询详情带出明细默认值
  278 + onSettleConfirm({ items }) {
  279 + const row = (items || [])[0]
  280 + if (!row) return
  281 + this.selectedSettleRow = row
  282 + this.form.settleDetailId = row.settleDetailId || row.id || ''
  283 + this.form.weighingTicketId = row.weighingTicketId || ''
  284 + this.form.weighingTicketCode = row.weighingTicketCode || ''
  285 + // 日期 = 结算详情单日期 + 一天
  286 + this.form.ticketDate = this.addOneDay(row.ticketDate)
  287 + this.form.materialSource = row.materialSource || ''
  288 + this.form.planCodes = row.planCodes || ''
  289 + this.form.workshopId = row.workshopId || ''
  290 + this.form.workshopName = row.workshopName || ''
  291 + this.form.supplierName = row.supplierName || ''
  292 + // 按结算详情单ID查询详情(带出明细行默认值)
  293 + const settleDetailId = this.form.settleDetailId
  294 + if (!settleDetailId) return
  295 + uni.showLoading({ title: '加载中...', mask: true })
  296 + warehouseReceiveSettleDataApi({ settleDetailId })
  297 + .then(res => {
  298 + const data = res && res.data ? (res.data.data || res.data) : {}
  299 + const lines = Array.isArray(data.lines) ? data.lines : []
  300 + // 计划ID集合:由明细行计划ID去重
  301 + this.planIds = Array.from(new Set(lines.map(l => l.procurementPlanId).filter(Boolean)))
  302 + // 明细数据:由结算详情单详情带出(采购数/实收数/含税单价等默认值由后端计算)
  303 + this.lineList = lines.map(item => this.buildLine(item))
  304 + })
  305 + .catch(() => {
  306 + this.planIds = []
  307 + this.lineList = []
  308 + })
  309 + .finally(() => {
  310 + uni.hideLoading()
  311 + })
  312 + },
  313 + // 由结算详情单明细构建收料单明细行(默认值由后端计算直出)
  314 + buildLine(item) {
  315 + return {
  316 + rowId: genRowId(),
  317 + settleLineId: item.settleLineId || item.id || '',
  318 + procurementPlanId: item.procurementPlanId || '',
  319 + productId: item.productId || '',
  320 + category: item.category || '',
  321 + name: item.name || '',
  322 + specModel: item.specModel || '',
  323 + unit: item.unit || 'kg',
  324 + purchaseQuantity: item.purchaseQuantity == null ? '' : item.purchaseQuantity,
  325 + actualQuantity: item.actualQuantity == null ? '' : item.actualQuantity,
  326 + taxPrice: item.taxPrice == null ? '' : item.taxPrice,
  327 + taxAmount: item.taxAmount == null ? '' : item.taxAmount,
  328 + noTaxPrice: item.noTaxPrice == null ? '' : item.noTaxPrice,
  329 + noTaxAmount: item.noTaxAmount == null ? '' : item.noTaxAmount,
  330 + settleType: item.settleType || '',
  331 + remark: item.remark || ''
  332 + }
  333 + },
  334 + // 含税金额 = 含税单价 * 采购数(单价或采购数为空则金额为空)
  335 + recalcTaxAmount(row) {
  336 + const price = row.taxPrice
  337 + const qty = row.purchaseQuantity
  338 + const hasPrice = price !== null && price !== undefined && price !== ''
  339 + const hasQty = qty !== null && qty !== undefined && qty !== ''
  340 + if (hasPrice && hasQty) {
  341 + row.taxAmount = Math.round(Number(price) * Number(qty) * 100) / 100
  342 + } else {
  343 + row.taxAmount = ''
  344 + }
  345 + },
  346 + // 日期 = 指定日期 + 一天(格式 YYYY-MM-DD)
  347 + addOneDay(dateStr) {
  348 + if (!dateStr) return ''
  349 + const d = new Date(String(dateStr).replace(/-/g, '/'))
  350 + if (isNaN(d.getTime())) return dateStr
  351 + d.setDate(d.getDate() + 1)
  352 + const p = n => String(n).padStart(2, '0')
  353 + return d.getFullYear() + '-' + p(d.getMonth() + 1) + '-' + p(d.getDate())
  354 + },
  355 + // 选择并上传文件(多文件逐个追加)
  356 + selectFile() {
  357 + if (typeof uni !== 'undefined' && typeof uni.chooseMessageFile === 'function') {
  358 + uni.chooseMessageFile({
  359 + count: 9,
  360 + type: 'all',
  361 + success: async res => {
  362 + const files = (res && res.tempFiles) || []
  363 + if (!files.length) return
  364 + uni.showLoading({ title: '上传中...', mask: true })
  365 + try {
  366 + for (const f of files) {
  367 + const name = f.name || 'file'
  368 + const r = await upload({ url: '/sw/filebox/uploadFile', filePath: f.path, name: 'file' })
  369 + const d = r && r.data ? r.data : r
  370 + const id = (d && (d.id || d.fileId || (d.data && (d.data.id || d.data.fileId))))
  371 + ? String(d.id || d.fileId || d.data.id || d.data.fileId)
  372 + : ''
  373 + if (id) this.fileList.push({ fileId: id, fileName: name })
  374 + }
  375 + } catch (e) {
  376 + uni.showToast({ title: '上传失败', icon: 'none' })
  377 + } finally {
  378 + uni.hideLoading()
  379 + }
  380 + },
  381 + fail: () => {
  382 + uni.showToast({ title: '未选择文件', icon: 'none' })
  383 + }
  384 + })
  385 + return
  386 + }
  387 + // H5 兜底:动态创建原生 input
  388 + try {
  389 + const self = this
  390 + const input = document.createElement('input')
  391 + input.type = 'file'
  392 + input.multiple = true
  393 + input.style.position = 'fixed'
  394 + input.style.left = '-9999px'
  395 + document.body.appendChild(input)
  396 + input.addEventListener('change', self.onFileChange)
  397 + input.click()
  398 + setTimeout(() => { document.body.removeChild(input) }, 1000)
  399 + } catch (e) {
  400 + uni.showToast({ title: '无法打开文件选择', icon: 'none' })
  401 + }
  402 + },
  403 + async onFileChange(e) {
  404 + const files = (e && e.target && e.target.files) || []
  405 + if (!files.length) return
  406 + uni.showLoading({ title: '上传中...', mask: true })
  407 + try {
  408 + for (const file of files) {
  409 + const name = file.name || ''
  410 + const fd = new FormData()
  411 + fd.append('file', file, name)
  412 + const d = await uploadFileApi(fd)
  413 + const data = d && d.data ? d.data : d
  414 + const id = (data && (data.id || data.fileId || (data.data && (data.data.id || data.data.fileId))))
  415 + ? String(data.id || data.fileId || data.data.id || data.data.fileId)
  416 + : ''
  417 + if (id) this.fileList.push({ fileId: id, fileName: name })
  418 + }
  419 + } catch (e2) {
  420 + uni.showToast({ title: '上传失败', icon: 'none' })
  421 + } finally {
  422 + uni.hideLoading()
  423 + if (e && e.target) e.target.value = ''
  424 + }
  425 + },
  426 + // 删除附件并同步 attachmentFileIds / attachmentFileNames
  427 + removeFile(idx) {
  428 + this.fileList.splice(idx, 1)
  429 + this.form.attachmentFileIds = this.fileList.map(x => x.fileId).filter(Boolean).join(',')
  430 + this.form.attachmentFileNames = this.fileList.map(x => x.fileName).filter(Boolean).join(',')
  431 + },
  432 + validate() {
  433 + if (!this.form.settleDetailId) return this.tip('请选择码单编号')
  434 + if (!this.form.ticketDate) return this.tip('日期不能为空')
  435 + if (!this.form.materialSource) return this.tip('材料来源不能为空')
  436 + if (!this.form.workshopName) return this.tip('分厂不能为空')
  437 + const lines = this.lineList || []
  438 + if (!lines.length) return this.tip('明细数据不能为空')
  439 + for (let i = 0; i < lines.length; i++) {
  440 + const row = lines[i]
  441 + if (row.purchaseQuantity === '' || row.purchaseQuantity == null) return this.tip(`明细第${i + 1}行:请输入采购数`)
  442 + if (row.actualQuantity === '' || row.actualQuantity == null) return this.tip(`明细第${i + 1}行:请输入实收数`)
  443 + if (row.taxPrice === '' || row.taxPrice == null) return this.tip(`明细第${i + 1}行:请输入含税单价`)
  444 + }
  445 + if (!this.fileList.length) return this.tip('请上传附件')
  446 + return true
  447 + },
  448 + tip(msg) {
  449 + uni.showToast({ title: msg, icon: 'none' })
  450 + return false
  451 + },
  452 + buildSubmitData() {
  453 + return {
  454 + settleDetailId: this.form.settleDetailId,
  455 + weighingTicketId: this.form.weighingTicketId,
  456 + weighingTicketCode: this.form.weighingTicketCode,
  457 + ticketDate: this.form.ticketDate,
  458 + materialSource: this.form.materialSource,
  459 + planCodes: this.form.planCodes,
  460 + planIds: this.planIds,
  461 + workshopId: this.form.workshopId,
  462 + workshopName: this.form.workshopName,
  463 + supplierName: this.form.supplierName,
  464 + remark: this.form.remark || '',
  465 + attachmentFileIds: this.fileList.map(x => x.fileId).filter(Boolean).join(','),
  466 + attachmentFileNames: this.fileList.map(x => x.fileName).filter(Boolean).join(','),
  467 + totalActualQuantity: String(this.totalActualQuantity),
  468 + totalTaxAmount: String(this.totalTaxAmount),
  469 + // 收料单明细(合计-采购数大写由后端计算,不提交)
  470 + lines: (this.lineList || []).map(item => ({
  471 + settleLineId: item.settleLineId || '',
  472 + procurementPlanId: item.procurementPlanId || '',
  473 + productId: item.productId || '',
  474 + category: item.category || '',
  475 + name: item.name || '',
  476 + specModel: item.specModel || '',
  477 + unit: item.unit || '',
  478 + purchaseQuantity: item.purchaseQuantity == null ? '' : String(item.purchaseQuantity),
  479 + actualQuantity: item.actualQuantity == null ? '' : String(item.actualQuantity),
  480 + taxPrice: item.taxPrice == null ? '' : String(item.taxPrice),
  481 + taxAmount: item.taxAmount == null ? '' : String(item.taxAmount),
  482 + noTaxPrice: item.noTaxPrice == null ? '' : String(item.noTaxPrice),
  483 + noTaxAmount: item.noTaxAmount == null ? '' : String(item.noTaxAmount),
  484 + settleType: item.settleType || '',
  485 + remark: item.remark || ''
  486 + }))
  487 + }
  488 + },
  489 + async onSubmit() {
  490 + if (!this.validate()) return
  491 + const confirmRes = await new Promise(resolve => {
  492 + uni.showModal({ title: '提示', content: '确定保存仓库收料单吗?', confirmText: '确定', cancelText: '取消', success: resolve })
  493 + })
  494 + if (!(confirmRes && confirmRes.confirm)) return
  495 + uni.showLoading({ title: '提交中...', mask: true })
  496 + warehouseReceiveCreateApi(this.buildSubmitData())
  497 + .then(() => {
  498 + uni.hideLoading()
  499 + uni.showToast({ title: '保存成功', icon: 'none' })
  500 + try { uni.setStorageSync('WAREHOUSE_MATERIAL_LIST_NEED_REFRESH', '1') } catch (e) {}
  501 + setTimeout(() => { uni.navigateBack() }, 400)
  502 + })
  503 + .catch(e => {
  504 + uni.hideLoading()
  505 + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' })
  506 + })
  507 + }
  508 + }
  509 +}
  510 +
  511 +// 生成前端临时行 id
  512 +function genRowId() {
  513 + return 'row_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8)
  514 +}
  515 +
  516 +// 数字转中文大写(对齐 PC 端 useReceiveForm.ts,保留位权读法,不含货币单位)
  517 +function numberToChineseUpper(num) {
  518 + if (num === null || num === undefined || num === '' || isNaN(Number(num))) return '零'
  519 + const n = Number(num)
  520 + if (!isFinite(n)) return '零'
  521 +
  522 + const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
  523 + const smallUnits = ['', '拾', '佰', '仟']
  524 + const bigUnits = ['', '万', '亿', '兆']
  525 +
  526 + const negative = n < 0
  527 + const abs = Math.abs(n)
  528 + const parts = abs.toString().split('.')
  529 + const intStrRaw = parts[0]
  530 + const decStrRaw = parts[1] || ''
  531 + const s = intStrRaw
  532 + const len = s.length
  533 +
  534 + let intPart = ''
  535 + let zeroFlag = false
  536 + for (let i = 0; i < len; i++) {
  537 + const d = parseInt(s[i], 10)
  538 + const pos = len - 1 - i
  539 + const unitIdx = pos % 4
  540 + const groupIdx = Math.floor(pos / 4)
  541 + if (d !== 0) {
  542 + if (zeroFlag) {
  543 + intPart += digit[0]
  544 + zeroFlag = false
  545 + }
  546 + intPart += digit[d] + smallUnits[unitIdx]
  547 + } else {
  548 + zeroFlag = true
  549 + }
  550 + if (unitIdx === 0) {
  551 + const start = Math.max(0, len - (groupIdx + 1) * 4)
  552 + const end = len - groupIdx * 4
  553 + const groupDigits = s.slice(start, end)
  554 + if (!/^0+$/.test(groupDigits)) {
  555 + intPart += bigUnits[groupIdx] || ''
  556 + }
  557 + }
  558 + }
  559 + if (intPart === '') intPart = digit[0]
  560 +
  561 + let result = intPart
  562 + if (decStrRaw) {
  563 + const decChars = decStrRaw
  564 + .split('')
  565 + .map(c => digit[parseInt(c, 10)])
  566 + .join('')
  567 + result += '点' + decChars
  568 + }
  569 + return (negative ? '负' : '') + result
  570 +}
  571 +</script>
  572 +
  573 +<style lang="scss" scoped>
  574 +.page {
  575 + display: flex;
  576 + flex-direction: column;
  577 + height: 100%;
  578 +}
  579 +
  580 +.scroll {
  581 + flex: 1;
  582 + padding: 12rpx 0 200rpx !important;
  583 +}
  584 +
  585 +.footer {
  586 + z-index: 2;
  587 + position: fixed;
  588 + left: 0;
  589 + right: 0;
  590 + bottom: 0;
  591 + padding: 32rpx;
  592 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  593 + background: #fff;
  594 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  595 +
  596 + .btn {
  597 + height: 80rpx;
  598 + line-height: 80rpx;
  599 + border-radius: 12rpx;
  600 + font-size: 32rpx;
  601 + }
  602 +
  603 + .submit {
  604 + background: $theme-primary;
  605 + color: #fff;
  606 + }
  607 +}
  608 +
  609 +::v-deep .uni-list {
  610 + .uni-easyinput {
  611 + display: flex;
  612 +
  613 + .uni-input-input {
  614 + color: rgba(0, 0, 0, 0.9);
  615 + }
  616 + }
  617 +
  618 + .uni-input-placeholder {
  619 + z-index: 1;
  620 + }
  621 +
  622 + .uni-input-input {
  623 + background-color: #ffffff;
  624 + }
  625 +
  626 + background: transparent;
  627 +
  628 + &-item {
  629 + &__extra-text {
  630 + font-size: 32rpx;
  631 + }
  632 +
  633 + &__content-title {
  634 + font-size: 32rpx;
  635 + color: rgba(0, 0, 0, 0.9);
  636 + }
  637 +
  638 + &__container {
  639 + padding: 32rpx;
  640 +
  641 + .uni-easyinput {
  642 + &__placeholder-class {
  643 + font-size: 32rpx;
  644 + color: rgba(0, 0, 0, 0.4);
  645 + }
  646 +
  647 + &__content {
  648 + border: none;
  649 + background-color: #ffffff !important;
  650 +
  651 + &-input {
  652 + padding-left: 0 !important;
  653 + height: 48rpx;
  654 + line-height: 48rpx;
  655 + font-size: 32rpx;
  656 + }
  657 +
  658 + .content-clear-icon {
  659 + font-size: 44rpx !important;
  660 + }
  661 + }
  662 + }
  663 +
  664 + .item-title,
  665 + .uni-list-item__content {
  666 + flex: none;
  667 + min-height: 48rpx;
  668 + line-height: 48rpx;
  669 + font-size: 32rpx;
  670 + position: relative;
  671 + width: 240rpx;
  672 + margin-right: 32rpx;
  673 + color: rgba(0, 0, 0, 0.9);
  674 +
  675 + .required {
  676 + color: red;
  677 + position: absolute;
  678 + top: 50%;
  679 + transform: translateY(-50%);
  680 + left: -16rpx;
  681 + }
  682 + }
  683 + }
  684 +
  685 + &.select-item {
  686 + &.is-empty {
  687 + .uni-list-item__extra-text {
  688 + color: rgba(0, 0, 0, 0.4) !important;
  689 + }
  690 + }
  691 +
  692 + &.is-filled {
  693 + .uni-list-item__extra-text {
  694 + color: rgba(0, 0, 0, 0.9) !important;
  695 + }
  696 + }
  697 + }
  698 + }
  699 +}
  700 +
  701 +.picker-value {
  702 + font-size: 32rpx;
  703 + color: rgba(0, 0, 0, 0.9);
  704 + line-height: 48rpx;
  705 + text-align: right;
  706 + min-height: 48rpx;
  707 +
  708 + &.placeholder {
  709 + color: rgba(0, 0, 0, 0.4);
  710 + }
  711 +}
  712 +
  713 +.sub-table,
  714 +.remark-section {
  715 + margin-top: 20rpx;
  716 + background: #fff;
  717 +}
  718 +
  719 +.header {
  720 + display: flex;
  721 + align-items: center;
  722 + padding: 24rpx 32rpx;
  723 + border-bottom: 1rpx solid #f0f0f0;
  724 +
  725 + .opCollapse {
  726 + width: 32rpx;
  727 + height: 28rpx;
  728 + margin-right: 16rpx;
  729 + margin-top: 8rpx;
  730 + }
  731 +
  732 + .title {
  733 + font-size: 32rpx;
  734 + color: rgba(0, 0, 0, 0.9);
  735 + font-weight: 600;
  736 + flex: 1;
  737 + }
  738 +}
  739 +
  740 +.add-list {
  741 + padding: 0 0 16rpx;
  742 +
  743 + .empty-tip {
  744 + text-align: center;
  745 + padding: 60rpx 0;
  746 + color: rgba(0, 0, 0, 0.4);
  747 + font-size: 28rpx;
  748 + }
  749 +
  750 + .block {
  751 + border-bottom: 1rpx solid #f0f0f0;
  752 +
  753 + &:last-child {
  754 + border-bottom: none;
  755 + }
  756 + }
  757 +}
  758 +
  759 +.total-card {
  760 + margin-top: 20rpx;
  761 + background: #fff;
  762 + padding: 24rpx 32rpx;
  763 +
  764 + .total-title {
  765 + font-size: 32rpx;
  766 + font-weight: 600;
  767 + color: rgba(0, 0, 0, 0.9);
  768 + margin-bottom: 20rpx;
  769 + }
  770 +
  771 + .total-body {
  772 + display: flex;
  773 + flex-wrap: wrap;
  774 +
  775 + .total-item {
  776 + width: 50%;
  777 + display: flex;
  778 + align-items: center;
  779 + margin-bottom: 20rpx;
  780 +
  781 + &:nth-last-child(-n + 2) {
  782 + margin-bottom: 0;
  783 + }
  784 +
  785 + .total-label {
  786 + font-size: 28rpx;
  787 + color: rgba(0, 0, 0, 0.6);
  788 + margin-right: 16rpx;
  789 + }
  790 +
  791 + .total-value {
  792 + font-size: 28rpx;
  793 + color: rgba(0, 0, 0, 0.9);
  794 + font-weight: 500;
  795 + }
  796 + }
  797 + }
  798 +}
  799 +
  800 +.section-content {
  801 + padding: 32rpx;
  802 +}
  803 +
  804 +.form-group {
  805 + margin-top: 24rpx;
  806 +
  807 + .item-title {
  808 + display: flex;
  809 + align-items: center;
  810 + font-size: 32rpx;
  811 + color: rgba(0, 0, 0, 0.9);
  812 + margin-bottom: 20rpx;
  813 + position: relative;
  814 + padding-left: 16rpx;
  815 +
  816 + .required {
  817 + color: red;
  818 + position: absolute;
  819 + left: 0;
  820 + }
  821 + }
  822 +
  823 + .upload-btn {
  824 + display: inline-block;
  825 + height: 64rpx;
  826 + line-height: 64rpx;
  827 + padding: 0 32rpx;
  828 + font-size: 28rpx;
  829 + border-radius: 8rpx;
  830 + background: $theme-primary;
  831 + color: #fff;
  832 + }
  833 +
  834 + .empty-tip {
  835 + text-align: center;
  836 + padding: 24rpx 0;
  837 + color: rgba(0, 0, 0, 0.4);
  838 + font-size: 28rpx;
  839 + }
  840 +
  841 + .file-item {
  842 + display: flex;
  843 + align-items: center;
  844 + justify-content: space-between;
  845 + padding: 20rpx 24rpx;
  846 + margin-top: 16rpx;
  847 + background: #fafafa;
  848 + border-radius: 8rpx;
  849 +
  850 + .file-name {
  851 + flex: 1;
  852 + font-size: 28rpx;
  853 + color: rgba(0, 0, 0, 0.9);
  854 + word-break: break-all;
  855 + margin-right: 20rpx;
  856 + }
  857 +
  858 + .file-del {
  859 + flex-shrink: 0;
  860 + font-size: 26rpx;
  861 + color: #d54941;
  862 + }
  863 + }
  864 +}
  865 +
  866 +.remark-group {
  867 + margin-bottom: 32rpx;
  868 +
  869 + .remark-label {
  870 + display: flex;
  871 + align-items: center;
  872 + font-size: 32rpx;
  873 + color: rgba(0, 0, 0, 0.9);
  874 + margin-bottom: 16rpx;
  875 + }
  876 +}
  877 +</style>
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <view class="detail-page">
  5 + <!-- 基础信息 -->
  6 + <view class="section">
  7 + <text class="row company">{{ safeText(form.weighingTicketCode) }}</text>
  8 + <view class="row"><text class="label">日期</text><text class="value">{{ safeText(form.ticketDate) }}</text></view>
  9 + <view class="row"><text class="label">材料来源</text><text class="value">{{ safeText(form.materialSource) }}</text></view>
  10 + <view class="row"><text class="label">计划单编号</text><text class="value">{{ safeText(form.planCode) }}</text></view>
  11 + <view class="row"><text class="label">分厂</text><text class="value">{{ safeText(form.workshopName) }}</text></view>
  12 + </view>
  13 +
  14 + <!-- 明细数据 -->
  15 + <view class="sub-table">
  16 + <view class="sub-header">
  17 + <image class="sub-bar" src="/static/images/title.png" />
  18 + <text class="sub-title">明细数据</text>
  19 + <view class="sub-toggle" @click="toggle('line')">
  20 + <image class="sub-toggle_icon" :src="collapse.line ? '/static/images/down.png' : '/static/images/up.png'" />
  21 + <text class="sub-toggle_text">{{ collapse.line ? '展开' : '收起' }}</text>
  22 + </view>
  23 + </view>
  24 + <view v-if="!collapse.line" class="sub-body">
  25 + <view v-if="!lineList.length" class="empty-tip">暂无明细</view>
  26 + <view v-for="(item, idx) in lineList" :key="'l-' + (item.id || idx)" class="card">
  27 + <view class="card-index">第 {{ idx + 1 }} 行</view>
  28 + <view class="row"><text class="label">材料编号</text><text class="value">{{ safeText(item.category) }}</text></view>
  29 + <view class="row"><text class="label">材料名称</text><text class="value">{{ safeText(item.name) }}</text></view>
  30 + <view class="row"><text class="label">规格型号</text><text class="value">{{ safeText(item.specModel) }}</text></view>
  31 + <view class="row"><text class="label">单位</text><text class="value">{{ safeText(item.unit) }}</text></view>
  32 + <view class="row"><text class="label">数量(采购数)</text><text class="value">{{ formatNumber(item.purchaseQuantity) }}</text></view>
  33 + <view class="row"><text class="label">数量(实收数)</text><text class="value">{{ formatNumber(item.actualQuantity) }}</text></view>
  34 + <view class="row"><text class="label">含税价格(单价)</text><text class="value">{{ formatNumber(item.taxPrice) }}</text></view>
  35 + <view class="row"><text class="label">含税价格(金额)</text><text class="value">{{ formatNumber(item.taxAmount) }}</text></view>
  36 + <view class="row"><text class="label">不含税价格(单价)</text><text class="value">{{ formatNumber(item.noTaxPrice) }}</text></view>
  37 + <view class="row"><text class="label">不含税价格(金额)</text><text class="value">{{ formatNumber(item.noTaxAmount) }}</text></view>
  38 + </view>
  39 + </view>
  40 + </view>
  41 +
  42 + <!-- 合计 -->
  43 + <view class="total-card">
  44 + <view class="total-title">合计</view>
  45 + <view class="total-body">
  46 + <view class="total-item">
  47 + <text class="total-label">采购数</text>
  48 + <text class="total-value">{{ purchaseQuantityCap }}</text>
  49 + </view>
  50 + <view class="total-item">
  51 + <text class="total-label">实收数</text>
  52 + <text class="total-value">{{ formatNumber(form.totalActualQuantity) }}</text>
  53 + </view>
  54 + <view class="total-item">
  55 + <text class="total-label">含税金额</text>
  56 + <text class="total-value">{{ formatNumber(form.totalTaxAmount) }}</text>
  57 + </view>
  58 + </view>
  59 + </view>
  60 +
  61 + <!-- 网价对比 -->
  62 + <view class="sub-table">
  63 + <view class="sub-header">
  64 + <image class="sub-bar" src="/static/images/title.png" />
  65 + <text class="sub-title">网价对比</text>
  66 + </view>
  67 + <view class="sub-body">
  68 + <view class="card">
  69 + <view class="row"><text class="label">原料</text><text class="value">上海有色网1#电铜</text></view>
  70 + <view class="row"><text class="label">计划单时间</text><text class="value">{{ safeText(formatDateOnly(form.planTime)) }}</text></view>
  71 + <view class="row"><text class="label">计划单时间网价均价</text><text class="value">{{ formatNumber(form.planOnlinePrice) }}</text></view>
  72 + <view class="row"><text class="label">过磅码单时间</text><text class="value">{{ safeText(formatDateOnly(form.ticketTime)) }}</text></view>
  73 + <view class="row"><text class="label">过磅码单时间网价均价</text><text class="value">{{ formatNumber(form.ticketOnlinePrice) }}</text></view>
  74 + <view class="row"><text class="label">两日网价均差</text><text class="value">{{ formatNumber(form.priceDiff) }}</text></view>
  75 + </view>
  76 + <view v-if="priceWarn" class="price-warn">两日价格均差超过800</view>
  77 + </view>
  78 + </view>
  79 +
  80 + <!-- 其他信息 -->
  81 + <view class="title-header">
  82 + <image class="title-header_icon" src="/static/images/title.png" />
  83 + <span>其他信息</span>
  84 + </view>
  85 + <view class="section">
  86 + <view class="remark-label">备注</view>
  87 + <text class="remark-text">{{ safeText(form.remark) }}</text>
  88 + <view class="remark-label">附件</view>
  89 + <view v-if="!fileList.length" class="empty-tip">暂无附件</view>
  90 + <view v-for="(file, idx) in fileList" :key="file.fileId || idx" class="file-item"
  91 + @click="downloadAttachment(file)">
  92 + <text class="file-name">{{ file.fileName || '未命名文件' }}</text>
  93 + </view>
  94 + </view>
  95 + </view>
  96 + </scroll-view>
  97 + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  98 + </view>
  99 +</template>
  100 +
  101 +<script>
  102 +import DetailButtons from '@/components/detail-buttons/index.vue'
  103 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  104 +import { warehouseReceiveDetailApi, warehouseReceiveSubmitAuditApi, warehouseReceiveCancelApi } from '@/api/procure-manage/warehouseMaterial.js'
  105 +import { getInfo } from '@/api/login.js'
  106 +import { downloadFile } from '@/utils/downloadFile.js'
  107 +
  108 +export default {
  109 + name: 'WarehouseMaterialDetail',
  110 + components: { DetailButtons },
  111 + data() {
  112 + return {
  113 + id: '',
  114 + form: {},
  115 + lineList: [],
  116 + currentUserId: '',
  117 + collapse: { line: false },
  118 + dicOptions: {
  119 + AUDIT_STATUS: []
  120 + },
  121 + buttons: [
  122 + { text: '修改', visible: true, variant: 'outline', event: 'edit' },
  123 + { text: '提交审核', visible: true, variant: 'outline', event: 'submitAudit' },
  124 + { text: '审核', visible: true, variant: 'primary', event: 'audit' },
  125 + { text: '审核详情', visible: true, variant: 'outline', event: 'auditDetail' },
  126 + { text: '取消', visible: true, variant: 'outline', event: 'cancel' }
  127 + ]
  128 + }
  129 + },
  130 + computed: {
  131 + // 合计-采购数(明细行采购数求和后转中文大写+公斤)
  132 + purchaseQuantityCap() {
  133 + if (!(this.lineList || []).length) return '-'
  134 + const total = (this.lineList || []).reduce(
  135 + (sum, row) => sum + Number(row.purchaseQuantity || 0), 0
  136 + )
  137 + return numberToChineseUpper(Number(total.toFixed(2))) + '公斤'
  138 + },
  139 + isMine() {
  140 + return this.form.createById === this.currentUserId
  141 + },
  142 + displayButtons() {
  143 + const status = this.form.approvalStatus || ''
  144 + const isDraft = status === 'DRAFT'
  145 + const isRefuse = status === 'REFUSE'
  146 + const isAudit = status === 'AUDIT'
  147 + const showExamine = this.form.showExamine === true
  148 + const showExamineDetail = this.form.showExamineDetail === true
  149 + const isMine = this.isMine
  150 +
  151 + return [
  152 + {
  153 + ...this.buttons[0],
  154 + visible: (isDraft || isRefuse) && isMine && this.$auth.hasPermi('warehouse-manage:warehouse-material:modify')
  155 + },
  156 + {
  157 + ...this.buttons[1],
  158 + visible: (isDraft || isRefuse) && isMine && this.$auth.hasPermi('warehouse-manage:warehouse-material:submit')
  159 + },
  160 + {
  161 + ...this.buttons[2],
  162 + visible: isAudit && showExamine && this.$auth.hasPermi('warehouse-manage:warehouse-material:approve')
  163 + },
  164 + {
  165 + ...this.buttons[3],
  166 + visible: showExamineDetail && this.$auth.hasPermi('warehouse-manage:warehouse-material:review')
  167 + },
  168 + {
  169 + ...this.buttons[4],
  170 + visible: (isDraft || isRefuse) && this.$auth.hasPermi('warehouse-manage:warehouse-material:cancel')
  171 + }
  172 + ]
  173 + },
  174 + // 附件列表(ids 与 names 按位置一一对应)
  175 + fileList() {
  176 + const ids = splitCsv(this.form.attachmentFileIds)
  177 + const names = splitCsv(this.form.attachmentFileNames)
  178 + const len = Math.max(ids.length, names.length)
  179 + const list = []
  180 + for (let i = 0; i < len; i++) {
  181 + list.push({ fileId: ids[i] || '', fileName: names[i] || '' })
  182 + }
  183 + return list
  184 + }
  185 + },
  186 + onLoad(query) {
  187 + this.id = (query && query.id) || ''
  188 + this.loadDicData()
  189 + this.loadDetail()
  190 + this.getUserInfo()
  191 + },
  192 + onShow() {
  193 + let needRefresh = ''
  194 + try { needRefresh = uni.getStorageSync('WAREHOUSE_MATERIAL_DETAIL_NEED_REFRESH') } catch (e) {}
  195 + if (!needRefresh) return
  196 + try { uni.removeStorageSync('WAREHOUSE_MATERIAL_DETAIL_NEED_REFRESH') } catch (e) {}
  197 + this.loadDetail()
  198 + },
  199 + methods: {
  200 + toggle(key) {
  201 + this.collapse = { ...this.collapse, [key]: !this.collapse[key] }
  202 + },
  203 + async loadDicData() {
  204 + try {
  205 + const results = await getDicByCodes(['AUDIT_STATUS'])
  206 + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || []
  207 + } catch (e) {
  208 + this.dicOptions = { AUDIT_STATUS: [] }
  209 + }
  210 + },
  211 + async getUserInfo() {
  212 + try {
  213 + const res = await getInfo()
  214 + this.currentUserId = (res && (res.id || (res.data && res.data.id))) || ''
  215 + } catch (e) {
  216 + this.currentUserId = ''
  217 + }
  218 + },
  219 + loadDetail() {
  220 + if (!this.id) {
  221 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  222 + return
  223 + }
  224 + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true })
  225 + warehouseReceiveDetailApi({ id: this.id })
  226 + .then(res => {
  227 + const data = res && res.data ? (res.data.data || res.data) : {}
  228 + this.form = Object.assign({}, data)
  229 + this.lineList = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : []
  230 + })
  231 + .catch(() => {
  232 + uni.showToast({ title: '详情加载失败', icon: 'none' })
  233 + })
  234 + .finally(() => {
  235 + uni.hideLoading && uni.hideLoading()
  236 + })
  237 + },
  238 + // 附件下载
  239 + downloadAttachment(file) {
  240 + const id = file && file.fileId
  241 + const fileName = file && file.fileName
  242 + if (!id) return
  243 + downloadFile(id, fileName)
  244 + },
  245 + handleButtonClick(btn) {
  246 + if (!btn || btn.disabled || !btn.visible) return
  247 + const e = btn.event || ''
  248 + if (e === 'edit') return this.onEdit()
  249 + if (e === 'submitAudit') return this.onSubmitAudit()
  250 + if (e === 'audit') return this.onAudit()
  251 + if (e === 'auditDetail') return this.onAuditDetail()
  252 + if (e === 'cancel') return this.onCancel()
  253 + },
  254 + onEdit() {
  255 + uni.navigateTo({ url: '/pages/warehouse-material/modify?id=' + this.id })
  256 + },
  257 + onAudit() {
  258 + const id = this.id || (this.form && this.form.id) || ''
  259 + if (!id) return
  260 + uni.setStorageSync('contractType', 'RECEIVE_ORDER')
  261 + uni.setStorageSync('sourceBusinessId', id)
  262 + uni.navigateTo({ url: '/pages/flow/audit' })
  263 + },
  264 + onAuditDetail() {
  265 + const id = this.id || (this.form && this.form.id) || ''
  266 + if (!id) return
  267 + uni.setStorageSync('contractType', 'RECEIVE_ORDER')
  268 + uni.setStorageSync('sourceBusinessId', id)
  269 + uni.navigateTo({ url: '/pages/flow/audit_detail' })
  270 + },
  271 + refreshListFlags() {
  272 + try {
  273 + uni.setStorageSync('WAREHOUSE_MATERIAL_LIST_NEED_REFRESH', '1')
  274 + uni.setStorageSync('WAREHOUSE_MATERIAL_DETAIL_NEED_REFRESH', '1')
  275 + } catch (e) {}
  276 + },
  277 + runWithConfirm(opts) {
  278 + const title = opts.title || '提示'
  279 + const content = opts.content || ''
  280 + const run = opts.run
  281 + const loading = opts.loading || '处理中'
  282 + const successText = opts.successText || '操作成功'
  283 + const failText = opts.failText || '操作失败'
  284 + if (!this.id) {
  285 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  286 + return
  287 + }
  288 + uni.showModal({
  289 + title,
  290 + content,
  291 + confirmText: '确定',
  292 + cancelText: '取消',
  293 + success: res => {
  294 + if (!res || !res.confirm) return
  295 + uni.showLoading({ title: loading, mask: true })
  296 + Promise.resolve(run(this.id))
  297 + .then(() => {
  298 + uni.hideLoading()
  299 + uni.showToast({ title: successText, icon: 'none' })
  300 + this.refreshListFlags()
  301 + this.loadDetail()
  302 + })
  303 + .catch(e => {
  304 + uni.hideLoading()
  305 + uni.showToast({ title: (e && (e.msg || e.message)) || failText, icon: 'none' })
  306 + })
  307 + }
  308 + })
  309 + },
  310 + onSubmitAudit() {
  311 + this.runWithConfirm({
  312 + title: '提交审核确认',
  313 + content: '确认提交审核吗?',
  314 + loading: '提交中',
  315 + successText: '提交审核成功',
  316 + failText: '提交审核失败',
  317 + run: id => warehouseReceiveSubmitAuditApi(id)
  318 + })
  319 + },
  320 + onCancel() {
  321 + this.runWithConfirm({
  322 + title: '取消确认',
  323 + content: '确认取消该收料单吗?',
  324 + loading: '处理中',
  325 + successText: '取消成功',
  326 + failText: '取消失败',
  327 + run: id => warehouseReceiveCancelApi(id)
  328 + })
  329 + },
  330 + safeText(v) {
  331 + const s = v == null ? '' : String(v)
  332 + return s.trim() ? s : '-'
  333 + },
  334 + formatNumber(v) {
  335 + if (v === null || v === undefined || v === '') return '-'
  336 + const n = Number(v)
  337 + if (isNaN(n)) return String(v)
  338 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  339 + },
  340 + formatDateOnly(v) {
  341 + const s = v == null ? '' : String(v).trim()
  342 + if (!s) return ''
  343 + if (s.length >= 10) return s.slice(0, 10)
  344 + return s
  345 + }
  346 + }
  347 +}
  348 +
  349 +// 逗号分隔字符串转数组
  350 +function splitCsv(val) {
  351 + if (!val) return []
  352 + if (Array.isArray(val)) return val
  353 + return String(val).split(',').filter(Boolean)
  354 +}
  355 +
  356 +// 数字转中文大写(对齐 PC 端 useReceiveForm.ts,保留位权读法,不含货币单位)
  357 +function numberToChineseUpper(num) {
  358 + if (num === null || num === undefined || num === '' || isNaN(Number(num))) return '零'
  359 + const n = Number(num)
  360 + if (!isFinite(n)) return '零'
  361 +
  362 + const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
  363 + const smallUnits = ['', '拾', '佰', '仟']
  364 + const bigUnits = ['', '万', '亿', '兆']
  365 +
  366 + const negative = n < 0
  367 + const abs = Math.abs(n)
  368 + const parts = abs.toString().split('.')
  369 + const intStrRaw = parts[0]
  370 + const decStrRaw = parts[1] || ''
  371 + const s = intStrRaw
  372 + const len = s.length
  373 +
  374 + let intPart = ''
  375 + let zeroFlag = false
  376 + for (let i = 0; i < len; i++) {
  377 + const d = parseInt(s[i], 10)
  378 + const pos = len - 1 - i
  379 + const unitIdx = pos % 4
  380 + const groupIdx = Math.floor(pos / 4)
  381 + if (d !== 0) {
  382 + if (zeroFlag) {
  383 + intPart += digit[0]
  384 + zeroFlag = false
  385 + }
  386 + intPart += digit[d] + smallUnits[unitIdx]
  387 + } else {
  388 + zeroFlag = true
  389 + }
  390 + if (unitIdx === 0) {
  391 + const start = Math.max(0, len - (groupIdx + 1) * 4)
  392 + const end = len - groupIdx * 4
  393 + const groupDigits = s.slice(start, end)
  394 + if (!/^0+$/.test(groupDigits)) {
  395 + intPart += bigUnits[groupIdx] || ''
  396 + }
  397 + }
  398 + }
  399 + if (intPart === '') intPart = digit[0]
  400 +
  401 + let result = intPart
  402 + if (decStrRaw) {
  403 + const decChars = decStrRaw
  404 + .split('')
  405 + .map(c => digit[parseInt(c, 10)])
  406 + .join('')
  407 + result += '点' + decChars
  408 + }
  409 + return (negative ? '负' : '') + result
  410 +}
  411 +</script>
  412 +
  413 +<style lang="scss" scoped>
  414 +.page {
  415 + display: flex;
  416 + flex-direction: column;
  417 + height: 100%;
  418 +}
  419 +.scroll {
  420 + flex: 1;
  421 + padding: 8rpx 0 144rpx;
  422 +}
  423 +.detail-page {
  424 + background: #f3f3f3;
  425 +}
  426 +.section {
  427 + padding: 32rpx;
  428 + background: #fff;
  429 + margin-bottom: 20rpx;
  430 +}
  431 +.title-header {
  432 + display: flex;
  433 + align-items: center;
  434 + padding: 24rpx 32rpx 12rpx;
  435 + background-color: #ffffff;
  436 + .title-header_icon { width: 36rpx; height: 36rpx; margin-right: 12rpx; }
  437 + span { font-size: 34rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); }
  438 +}
  439 +.row {
  440 + display: flex;
  441 + margin-bottom: 28rpx;
  442 + &:last-child { margin-bottom: 0; }
  443 + &.company {
  444 + font-size: 36rpx;
  445 + font-weight: 600;
  446 + color: rgba(0, 0, 0, 0.9);
  447 + padding-top: 8rpx;
  448 + line-height: 50rpx;
  449 + }
  450 + .label {
  451 + max-width: 420rpx;
  452 + margin-right: 20rpx;
  453 + line-height: 32rpx;
  454 + font-size: 28rpx;
  455 + color: rgba(0, 0, 0, 0.6);
  456 + }
  457 + .value {
  458 + flex: 1;
  459 + line-height: 32rpx;
  460 + font-size: 28rpx;
  461 + color: rgba(0, 0, 0, 0.9);
  462 + text-align: right;
  463 + word-break: break-all;
  464 + }
  465 +}
  466 +.remark-label {
  467 + display: flex;
  468 + align-items: center;
  469 + font-size: 32rpx;
  470 + color: rgba(0, 0, 0, 0.9);
  471 + margin-bottom: 16rpx;
  472 +}
  473 +.remark-text {
  474 + font-size: 28rpx;
  475 + color: rgba(0, 0, 0, 0.9);
  476 + line-height: 1.6;
  477 + white-space: pre-wrap;
  478 + margin-bottom: 32rpx;
  479 +}
  480 +.empty-tip {
  481 + text-align: center;
  482 + padding: 24rpx 0;
  483 + color: rgba(0, 0, 0, 0.4);
  484 + font-size: 28rpx;
  485 +}
  486 +.file-item {
  487 + display: flex;
  488 + align-items: center;
  489 + justify-content: space-between;
  490 + padding: 20rpx 24rpx;
  491 + margin-bottom: 16rpx;
  492 + background: #fafafa;
  493 + border-radius: 8rpx;
  494 +
  495 + &:last-child {
  496 + margin-bottom: 0;
  497 + }
  498 +
  499 + .file-name {
  500 + flex: 1;
  501 + font-size: 28rpx;
  502 + color: $theme-primary;
  503 + word-break: break-all;
  504 + margin-right: 20rpx;
  505 + }
  506 +}
  507 +.sub-table {
  508 + background: #fff;
  509 + margin-bottom: 20rpx;
  510 +}
  511 +.sub-header {
  512 + display: flex;
  513 + align-items: center;
  514 + padding: 16rpx 0 16rpx 32rpx;
  515 + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; }
  516 + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; }
  517 + .sub-toggle {
  518 + display: flex;
  519 + align-items: center;
  520 + padding: 0 12rpx;
  521 + height: 56rpx;
  522 + .sub-toggle_icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; }
  523 + .sub-toggle_text { font-size: 26rpx; color: rgba(0, 0, 0, 0.6); }
  524 + }
  525 +}
  526 +.sub-body {
  527 + padding: 0 32rpx 24rpx;
  528 + .empty-tip {
  529 + text-align: center;
  530 + padding: 60rpx 0;
  531 + color: rgba(0, 0, 0, 0.4);
  532 + font-size: 28rpx;
  533 + }
  534 + .card {
  535 + position: relative;
  536 + background: #fafafa;
  537 + border-radius: 12rpx;
  538 + padding: 32rpx 28rpx 20rpx;
  539 + margin-bottom: 24rpx;
  540 + .card-index {
  541 + position: absolute;
  542 + top: 0;
  543 + right: 0;
  544 + background: rgba(24, 144, 255, 0.08);
  545 + color: $theme-primary;
  546 + font-size: 22rpx;
  547 + line-height: 36rpx;
  548 + padding: 0 16rpx;
  549 + border-bottom-left-radius: 12rpx;
  550 + border-top-right-radius: 12rpx;
  551 + }
  552 + .row {
  553 + align-items: center;
  554 + justify-content: space-between;
  555 + padding: 14rpx 0;
  556 + margin-bottom: 0;
  557 + border-bottom: 1rpx dashed #f2f2f2;
  558 + &:last-child { border-bottom: none; }
  559 + .label {
  560 + flex-shrink: 0;
  561 + width: 220rpx;
  562 + max-width: none;
  563 + margin-right: 0;
  564 + font-size: 28rpx;
  565 + color: rgba(0, 0, 0, 0.6);
  566 + line-height: 40rpx;
  567 + }
  568 + .value {
  569 + flex: 1;
  570 + text-align: right;
  571 + font-size: 28rpx;
  572 + color: rgba(0, 0, 0, 0.9);
  573 + line-height: 40rpx;
  574 + overflow: hidden;
  575 + text-overflow: ellipsis;
  576 + white-space: nowrap;
  577 + }
  578 + }
  579 + }
  580 + .price-warn {
  581 + margin-top: 26rpx;
  582 + text-align: center;
  583 + color: #f5222d;
  584 + font-size: 30rpx;
  585 + }
  586 +}
  587 +.total-card {
  588 + background: #fff;
  589 + padding: 24rpx 32rpx;
  590 + margin-bottom: 20rpx;
  591 +
  592 + .total-title {
  593 + font-size: 32rpx;
  594 + font-weight: 600;
  595 + color: rgba(0, 0, 0, 0.9);
  596 + margin-bottom: 20rpx;
  597 + }
  598 +
  599 + .total-body {
  600 + display: flex;
  601 + flex-wrap: wrap;
  602 +
  603 + .total-item {
  604 + width: 50%;
  605 + display: flex;
  606 + align-items: center;
  607 + margin-bottom: 20rpx;
  608 +
  609 + &:nth-last-child(-n + 2) {
  610 + margin-bottom: 0;
  611 + }
  612 +
  613 + .total-label {
  614 + font-size: 28rpx;
  615 + color: rgba(0, 0, 0, 0.6);
  616 + margin-right: 16rpx;
  617 + }
  618 +
  619 + .total-value {
  620 + font-size: 28rpx;
  621 + color: rgba(0, 0, 0, 0.9);
  622 + font-weight: 500;
  623 + word-break: break-all;
  624 + }
  625 + }
  626 + }
  627 +}
  628 +</style>
  1 +<template>
  2 + <view class="page">
  3 + <view class="ticket-list-fixed">
  4 + <view class="search-row">
  5 + <uni-search-bar
  6 + v-model="searchKeyword"
  7 + radius="6"
  8 + placeholder="请输入码单编号"
  9 + clearButton="auto"
  10 + cancelButton="none"
  11 + bgColor="#F3F3F3"
  12 + textColor="rgba(0,0,0,0.4)"
  13 + @confirm="search"
  14 + @input="onSearchInput"
  15 + />
  16 + <view class="tool-icons">
  17 + <image
  18 + v-if="$auth.hasPermi('warehouse-manage:warehouse-material:add')"
  19 + class="tool-icon"
  20 + src="/static/images/dev_manage/add_icon.png"
  21 + @click="onAdd"
  22 + />
  23 + <image class="tool-icon" src="/static/images/dev_manage/filter_icon.png" @click="openFilter" />
  24 + </view>
  25 + </view>
  26 + </view>
  27 +
  28 + <view class="list-box">
  29 + <card-list
  30 + ref="cardRef"
  31 + :fetch-fn="fetchList"
  32 + :query="query"
  33 + :extra="extraParams"
  34 + row-key="id"
  35 + :enable-refresh="true"
  36 + :enable-load-more="true"
  37 + @loaded="onCardLoaded"
  38 + @error="onCardError"
  39 + >
  40 + <template v-slot="{ item }">
  41 + <view class="card" @click="onCardClick(item)">
  42 + <view class="card-header">
  43 + <text class="title omit2">{{ item.weighingTicketCode || '-' }}</text>
  44 + <text :class="['status', `status_${item.approvalStatus}`]">{{ getAuditStatusText(item.approvalStatus) }}</text>
  45 + </view>
  46 + <view class="info-row">
  47 + <text>日期</text>
  48 + <text>{{ formatDateOnly(item.ticketDate) }}</text>
  49 + </view>
  50 + <view class="info-row">
  51 + <text>计划编号</text>
  52 + <text>{{ item.planCode || '-' }}</text>
  53 + </view>
  54 + <view class="info-row">
  55 + <text>材料来源</text>
  56 + <text>{{ item.materialSource || '-' }}</text>
  57 + </view>
  58 + <view class="info-row">
  59 + <text>分厂</text>
  60 + <text>{{ item.workshopName || '-' }}</text>
  61 + </view>
  62 + <view class="info-row">
  63 + <text>流程节点</text>
  64 + <text>{{ getFlowNodeText(item.flowNode) }}</text>
  65 + </view>
  66 + <view class="info-row">
  67 + <text>创建时间</text>
  68 + <text>{{ formatDateTime(item.createTime) }}</text>
  69 + </view>
  70 + </view>
  71 + </template>
  72 + </card-list>
  73 + </view>
  74 +
  75 + <filter-modal
  76 + :visible.sync="filterVisible"
  77 + :value.sync="filterForm"
  78 + title="筛选"
  79 + @reset="onFilterReset"
  80 + @confirm="onFilterConfirm"
  81 + >
  82 + <template v-slot="{ model }">
  83 + <view class="filter-form">
  84 + <view class="form-item">
  85 + <view class="label">码单编号</view>
  86 + <input class="input" v-model="model.weighingTicketCode" placeholder="请输入码单编号" />
  87 + </view>
  88 + <view class="form-item">
  89 + <view class="label">计划编号</view>
  90 + <input class="input" v-model="model.planCode" placeholder="请输入计划编号" />
  91 + </view>
  92 + <view class="form-item">
  93 + <view class="label">客户名称</view>
  94 + <input class="input" v-model="model.supplierName" placeholder="请输入客户名称" />
  95 + </view>
  96 + <view class="form-item">
  97 + <view class="label">分厂</view>
  98 + <picker mode="selector" :range="workshopLabels" @change="onWorkshopChange">
  99 + <view class="fake-select">
  100 + <text v-if="workshopLabel" class="value">{{ workshopLabel }}</text>
  101 + <text v-else class="placeholder">请选择分厂</text>
  102 + </view>
  103 + </picker>
  104 + </view>
  105 + <view class="form-item">
  106 + <view class="label">流程节点</view>
  107 + <picker mode="selector" :range="flowNodeLabels" @change="onFlowNodeChange">
  108 + <view class="fake-select">
  109 + <text v-if="flowNodeLabel" class="value">{{ flowNodeLabel }}</text>
  110 + <text v-else class="placeholder">请选择流程节点</text>
  111 + </view>
  112 + </picker>
  113 + </view>
  114 + <view class="form-item">
  115 + <view class="label">审核状态</view>
  116 + <uni-data-checkbox
  117 + mode="tag"
  118 + :multiple="false"
  119 + :value-field="'value'"
  120 + :text-field="'text'"
  121 + v-model="model.approvalStatus"
  122 + :localdata="approvalStatusOptions"
  123 + />
  124 + </view>
  125 + <view class="form-item">
  126 + <view class="label">日期</view>
  127 + <uni-datetime-picker type="daterange" v-model="model.timeRange" start="2023-01-01" />
  128 + </view>
  129 + </view>
  130 + </template>
  131 + </filter-modal>
  132 + </view>
  133 +</template>
  134 +
  135 +<script>
  136 +import CardList from '@/components/card/index.vue'
  137 +import FilterModal from '@/components/filter/index.vue'
  138 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  139 +import { warehouseReceiveQueryApi, workshopQueryApi } from '@/api/procure-manage/warehouseMaterial.js'
  140 +
  141 +export default {
  142 + name: 'WarehouseMaterialList',
  143 + components: { CardList, FilterModal },
  144 + data() {
  145 + return {
  146 + searchKeyword: '',
  147 + searchKeywordDebounced: '',
  148 + searchDebounceTimer: null,
  149 + query: {
  150 + weighingTicketCode: '',
  151 + planCode: '',
  152 + supplierName: '',
  153 + workshopId: '',
  154 + flowNode: '',
  155 + approvalStatus: '',
  156 + timeRange: []
  157 + },
  158 + extraParams: {},
  159 + currentItems: [],
  160 + filterVisible: false,
  161 + filterForm: {
  162 + weighingTicketCode: '',
  163 + planCode: '',
  164 + supplierName: '',
  165 + workshopId: '',
  166 + flowNode: '',
  167 + approvalStatus: '',
  168 + timeRange: []
  169 + },
  170 + approvalStatusOptions: [
  171 + { value: '', text: '全部' },
  172 + { value: 'DRAFT', text: '草稿' },
  173 + { value: 'AUDIT', text: '审核中' },
  174 + { value: 'PASS', text: '审核通过' },
  175 + { value: 'REFUSE', text: '已驳回' },
  176 + { value: 'CANCEL', text: '已取消' }
  177 + ],
  178 + workshopOptions: [],
  179 + workshopLabel: '',
  180 + flowNodeLabel: '',
  181 + dicOptions: {
  182 + AUDIT_STATUS: [],
  183 + RECEIVE_FLOW_NODE: []
  184 + }
  185 + }
  186 + },
  187 + computed: {
  188 + workshopLabels() {
  189 + return ['全部'].concat(this.workshopOptions.map(it => it.label))
  190 + },
  191 + flowNodeLabels() {
  192 + return ['全部'].concat((this.dicOptions.RECEIVE_FLOW_NODE || []).map(it => it.name))
  193 + },
  194 + extraCombined() {
  195 + return {
  196 + keyword: this.searchKeywordDebounced || undefined
  197 + }
  198 + }
  199 + },
  200 + watch: {
  201 + extraCombined: {
  202 + deep: true,
  203 + handler(v) {
  204 + this.extraParams = v
  205 + },
  206 + immediate: true
  207 + }
  208 + },
  209 + created() {
  210 + this.loadDicData()
  211 + this.loadWorkshopOptions()
  212 + },
  213 + onShow() {
  214 + let needRefresh = ''
  215 + try { needRefresh = uni.getStorageSync('WAREHOUSE_MATERIAL_LIST_NEED_REFRESH') } catch (e) {}
  216 + if (!needRefresh) return
  217 + try { uni.removeStorageSync('WAREHOUSE_MATERIAL_LIST_NEED_REFRESH') } catch (e) {}
  218 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.reload) {
  219 + this.$refs.cardRef.reload()
  220 + }
  221 + },
  222 + onReachBottom() {
  223 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.onLoadMore) {
  224 + this.$refs.cardRef.onLoadMore()
  225 + }
  226 + },
  227 + beforeDestroy() {
  228 + if (this.searchDebounceTimer) {
  229 + clearTimeout(this.searchDebounceTimer)
  230 + this.searchDebounceTimer = null
  231 + }
  232 + },
  233 + methods: {
  234 + async loadDicData() {
  235 + try {
  236 + const results = await getDicByCodes(['AUDIT_STATUS', 'RECEIVE_FLOW_NODE'])
  237 + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || []
  238 + this.dicOptions.RECEIVE_FLOW_NODE = (results.RECEIVE_FLOW_NODE && results.RECEIVE_FLOW_NODE.data) || []
  239 + } catch (e) {
  240 + this.dicOptions = { AUDIT_STATUS: [], RECEIVE_FLOW_NODE: [] }
  241 + }
  242 + },
  243 + async loadWorkshopOptions() {
  244 + try {
  245 + const res = await workshopQueryApi({ pageIndex: 1, pageSize: 9999 })
  246 + const _data = (res && res.data) || {}
  247 + const datas = _data.datas || _data.list || _data.records || []
  248 + this.workshopOptions = datas.map(item => ({
  249 + label: item.name || '',
  250 + value: item.id || ''
  251 + })).filter(it => it.value)
  252 + } catch (e) {
  253 + this.workshopOptions = []
  254 + }
  255 + },
  256 + getAuditStatusText(status) {
  257 + const v = status == null ? '' : String(status)
  258 + if (!v) return '-'
  259 + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v
  260 + },
  261 + getFlowNodeText(node) {
  262 + const v = node == null ? '' : String(node)
  263 + if (!v) return '-'
  264 + return getDicName('RECEIVE_FLOW_NODE', v, this.dicOptions.RECEIVE_FLOW_NODE) || v
  265 + },
  266 + formatDateOnly(v) {
  267 + const s = v == null ? '' : String(v).trim()
  268 + if (!s) return '-'
  269 + if (s.length >= 10) return s.slice(0, 10)
  270 + return s
  271 + },
  272 + formatDateTime(v) {
  273 + const s = v == null ? '' : String(v).trim()
  274 + if (!s) return '-'
  275 + return s.replace('T', ' ').slice(0, 19)
  276 + },
  277 + onCardLoaded({ items }) {
  278 + this.currentItems = items
  279 + },
  280 + onCardError() {
  281 + uni.showToast({ title: '列表加载失败', icon: 'none' })
  282 + },
  283 + onAdd() {
  284 + uni.navigateTo({ url: '/pages/warehouse-material/add' })
  285 + },
  286 + onSearchInput() {
  287 + if (this.searchDebounceTimer) clearTimeout(this.searchDebounceTimer)
  288 + this.searchDebounceTimer = setTimeout(() => {
  289 + this.searchKeywordDebounced = this.searchKeyword
  290 + this.searchDebounceTimer = null
  291 + }, 1200)
  292 + },
  293 + search(e) {
  294 + const val = e && e.value != null ? e.value : this.searchKeyword
  295 + this.searchKeyword = val
  296 + this.searchKeywordDebounced = val
  297 + },
  298 + onWorkshopChange(e) {
  299 + const idx = Number(e.detail.value)
  300 + if (idx <= 0) {
  301 + this.filterForm.workshopId = ''
  302 + this.workshopLabel = ''
  303 + } else {
  304 + const opt = this.workshopOptions[idx - 1]
  305 + this.filterForm.workshopId = opt ? opt.value : ''
  306 + this.workshopLabel = opt ? opt.label : ''
  307 + }
  308 + },
  309 + onFlowNodeChange(e) {
  310 + const idx = Number(e.detail.value)
  311 + if (idx <= 0) {
  312 + this.filterForm.flowNode = ''
  313 + this.flowNodeLabel = ''
  314 + } else {
  315 + const opt = (this.dicOptions.RECEIVE_FLOW_NODE || [])[idx - 1]
  316 + this.filterForm.flowNode = opt ? (opt.code != null ? String(opt.code) : '') : ''
  317 + this.flowNodeLabel = opt ? (opt.name || '') : ''
  318 + }
  319 + },
  320 + openFilter() {
  321 + this.filterForm = {
  322 + weighingTicketCode: this.query.weighingTicketCode || '',
  323 + planCode: this.query.planCode || '',
  324 + supplierName: this.query.supplierName || '',
  325 + workshopId: this.query.workshopId || '',
  326 + flowNode: this.query.flowNode || '',
  327 + approvalStatus: this.query.approvalStatus || '',
  328 + timeRange: Array.isArray(this.query.timeRange) ? this.query.timeRange.slice(0) : []
  329 + }
  330 + const foundWorkshop = this.workshopOptions.find(it => it.value === this.filterForm.workshopId)
  331 + this.workshopLabel = foundWorkshop ? foundWorkshop.label : ''
  332 + const foundFlowNode = (this.dicOptions.RECEIVE_FLOW_NODE || []).find(it => String(it.code) === String(this.filterForm.flowNode))
  333 + this.flowNodeLabel = foundFlowNode ? (foundFlowNode.name || '') : ''
  334 + this.filterVisible = true
  335 + },
  336 + onFilterReset(payload) {
  337 + this.filterForm = payload
  338 + this.workshopLabel = ''
  339 + this.flowNodeLabel = ''
  340 + },
  341 + onFilterConfirm(payload) {
  342 + this.query = {
  343 + weighingTicketCode: payload.weighingTicketCode || '',
  344 + planCode: payload.planCode || '',
  345 + supplierName: payload.supplierName || '',
  346 + workshopId: payload.workshopId || '',
  347 + flowNode: payload.flowNode || '',
  348 + approvalStatus: payload.approvalStatus || '',
  349 + timeRange: Array.isArray(payload.timeRange) ? payload.timeRange : []
  350 + }
  351 + },
  352 + fetchList({ pageIndex, pageSize, query, extra }) {
  353 + const q = query || {}
  354 + const e = extra || {}
  355 + const range = Array.isArray(q.timeRange) ? q.timeRange : []
  356 + const keyword = e.keyword || ''
  357 + const params = {
  358 + pageIndex,
  359 + pageSize,
  360 + weighingTicketCode: q.weighingTicketCode || keyword || '',
  361 + ticketDateStart: range && range.length === 2 ? range[0] + ' 00:00:00' : '',
  362 + ticketDateEnd: range && range.length === 2 ? range[1] + ' 00:00:00' : '',
  363 + planCode: q.planCode || '',
  364 + supplierName: q.supplierName || '',
  365 + workshopId: q.workshopId || '',
  366 + flowNode: q.flowNode || '',
  367 + approvalStatus: q.approvalStatus || ''
  368 + }
  369 + return warehouseReceiveQueryApi(params)
  370 + .then(res => {
  371 + const _data = (res && res.data) || {}
  372 + let records = _data.datas || _data.list || _data.records || []
  373 + const totalCount = _data.totalCount || _data.count || 0
  374 + const hasNext = _data.hasNext || false
  375 + records = records.map(it => ({ ...it }))
  376 + return { records, totalCount, hasNext }
  377 + })
  378 + .catch(() => {
  379 + this.onCardError()
  380 + return { records: [], totalCount: 0, hasNext: false }
  381 + })
  382 + },
  383 + onCardClick(item) {
  384 + const id = item && item.id
  385 + if (!id) {
  386 + uni.showToast({ title: '缺少ID', icon: 'none' })
  387 + return
  388 + }
  389 + uni.navigateTo({ url: '/pages/warehouse-material/detail?id=' + id })
  390 + }
  391 + }
  392 +}
  393 +</script>
  394 +
  395 +<style lang="scss" scoped>
  396 +.page {
  397 + display: flex;
  398 + flex-direction: column;
  399 + height: 100vh;
  400 +}
  401 +.ticket-list-fixed {
  402 + position: fixed;
  403 + top: 96rpx;
  404 + left: 0;
  405 + right: 0;
  406 + z-index: 2;
  407 + background: #fff;
  408 + .search-row {
  409 + display: flex;
  410 + align-items: center;
  411 + padding: 16rpx 32rpx;
  412 + .uni-searchbar { padding: 0; flex: 1; }
  413 + .tool-icons {
  414 + display: flex;
  415 + .tool-icon { width: 48rpx; height: 48rpx; display: block; margin-left: 32rpx; }
  416 + }
  417 + }
  418 +}
  419 +::v-deep .uni-searchbar__box {
  420 + height: 80rpx !important;
  421 + justify-content: start;
  422 + .uni-searchbar__box-search-input { font-size: 32rpx !important; }
  423 +}
  424 +.list-box {
  425 + flex: 1;
  426 + padding-top: 168rpx;
  427 + .card { position: relative; }
  428 + .card-header {
  429 + margin-bottom: 28rpx;
  430 + position: relative;
  431 + .title { font-size: 36rpx; font-weight: 600; line-height: 50rpx; color: rgba(0, 0, 0, 0.9); width: 578rpx; }
  432 + .status {
  433 + position: absolute;
  434 + top: -32rpx;
  435 + right: -12rpx;
  436 + height: 48rpx;
  437 + line-height: 48rpx;
  438 + font-weight: 600;
  439 + color: #fff;
  440 + font-size: 24rpx;
  441 + padding: 0 14rpx;
  442 + border-radius: 6rpx;
  443 + box-sizing: content-box;
  444 +
  445 + &.status_AUDIT { background: $theme-primary; }
  446 + &.status_PASS { background: #2ba471; }
  447 + &.status_REFUSE { background: #d54941; }
  448 + &.status_DRAFT { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); }
  449 + &.status_CANCEL { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); }
  450 + }
  451 + }
  452 + .info-row {
  453 + display: flex;
  454 + align-items: center;
  455 + color: rgba(0, 0, 0, 0.6);
  456 + font-size: 28rpx;
  457 + margin-bottom: 24rpx;
  458 + height: 32rpx;
  459 + &:last-child { margin-bottom: 0; }
  460 + text {
  461 + width: 50%;
  462 + &:last-child {
  463 + color: rgba(0, 0, 0, 0.9);
  464 + width: 50%;
  465 + overflow: hidden;
  466 + text-overflow: ellipsis;
  467 + white-space: nowrap;
  468 + }
  469 + }
  470 + }
  471 +}
  472 +.filter-form {
  473 + .form-item { margin-bottom: 24rpx; }
  474 + .label { margin-bottom: 20rpx; color: rgba(0, 0, 0, 0.9); height: 44rpx; line-height: 44rpx; font-size: 30rpx; }
  475 + .input {
  476 + width: 100%;
  477 + height: 72rpx;
  478 + line-height: 72rpx;
  479 + padding: 0 24rpx;
  480 + border: 1rpx solid #e7e7e7;
  481 + border-radius: 8rpx;
  482 + font-size: 28rpx;
  483 + color: rgba(0, 0, 0, 0.9);
  484 + background: #fff;
  485 + box-sizing: border-box;
  486 + }
  487 + .fake-select {
  488 + height: 72rpx;
  489 + line-height: 72rpx;
  490 + padding: 0 24rpx;
  491 + border: 1rpx solid #e7e7e7;
  492 + border-radius: 8rpx;
  493 + font-size: 28rpx;
  494 + .placeholder { color: #999; }
  495 + .value { color: rgba(0, 0, 0, 0.9); }
  496 + }
  497 +}
  498 +</style>
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <!-- 基础信息(只读) -->
  5 + <uni-list>
  6 + <uni-list-item title="码单编号">
  7 + <template v-slot:footer>
  8 + <uni-easyinput :value="form.weighingTicketCode" :inputBorder="false" disabled />
  9 + </template>
  10 + </uni-list-item>
  11 + <uni-list-item title="日期">
  12 + <template v-slot:footer>
  13 + <uni-easyinput :value="form.ticketDate" :inputBorder="false" disabled />
  14 + </template>
  15 + </uni-list-item>
  16 + <uni-list-item title="材料来源">
  17 + <template v-slot:footer>
  18 + <uni-easyinput :value="form.materialSource" :inputBorder="false" disabled />
  19 + </template>
  20 + </uni-list-item>
  21 + <uni-list-item title="计划单编号">
  22 + <template v-slot:footer>
  23 + <uni-easyinput :value="form.planCode" :inputBorder="false" disabled />
  24 + </template>
  25 + </uni-list-item>
  26 + <uni-list-item title="分厂">
  27 + <template v-slot:footer>
  28 + <uni-easyinput :value="form.workshopName" :inputBorder="false" disabled />
  29 + </template>
  30 + </uni-list-item>
  31 + </uni-list>
  32 +
  33 + <!-- 明细数据(可编辑) -->
  34 + <view class="sub-table">
  35 + <view class="header">
  36 + <image class="opCollapse" src="/static/images/title.png" />
  37 + <text class="title">明细数据</text>
  38 + </view>
  39 + <view class="add-list">
  40 + <view v-if="!lineList.length" class="empty-tip">暂无明细</view>
  41 + <view v-for="(item, idx) in lineList" :key="'l-' + (item.rowId || idx)" class="block">
  42 + <uni-list>
  43 + <uni-list-item title="材料编号">
  44 + <template v-slot:footer>
  45 + <uni-easyinput :value="item.category" :inputBorder="false" disabled />
  46 + </template>
  47 + </uni-list-item>
  48 + <uni-list-item title="材料名称">
  49 + <template v-slot:footer>
  50 + <uni-easyinput :value="item.name" :inputBorder="false" disabled />
  51 + </template>
  52 + </uni-list-item>
  53 + <uni-list-item title="规格型号">
  54 + <template v-slot:footer>
  55 + <uni-easyinput :value="item.specModel" :inputBorder="false" disabled />
  56 + </template>
  57 + </uni-list-item>
  58 + <uni-list-item title="单位">
  59 + <template v-slot:footer>
  60 + <uni-easyinput :value="item.unit" :inputBorder="false" disabled />
  61 + </template>
  62 + </uni-list-item>
  63 + <uni-list-item>
  64 + <template v-slot:body>
  65 + <view class="item-title"><text class="required">*</text><text>数量(采购数)</text></view>
  66 + </template>
  67 + <template v-slot:footer>
  68 + <uni-easyinput v-model="item.purchaseQuantity" type="digit" :inputBorder="false" placeholder="请输入采购数" @input="recalcTaxAmount(item)" />
  69 + </template>
  70 + </uni-list-item>
  71 + <uni-list-item>
  72 + <template v-slot:body>
  73 + <view class="item-title"><text class="required">*</text><text>数量(实收数)</text></view>
  74 + </template>
  75 + <template v-slot:footer>
  76 + <uni-easyinput v-model="item.actualQuantity" type="digit" :inputBorder="false" placeholder="请输入实收数" />
  77 + </template>
  78 + </uni-list-item>
  79 + <uni-list-item>
  80 + <template v-slot:body>
  81 + <view class="item-title"><text class="required">*</text><text>含税单价</text></view>
  82 + </template>
  83 + <template v-slot:footer>
  84 + <uni-easyinput v-model="item.taxPrice" type="digit" :inputBorder="false" placeholder="请输入含税单价" @input="recalcTaxAmount(item)" />
  85 + </template>
  86 + </uni-list-item>
  87 + <uni-list-item title="含税金额">
  88 + <template v-slot:footer>
  89 + <uni-easyinput :value="item.taxAmount" :inputBorder="false" disabled placeholder="单价×采购数自动计算" />
  90 + </template>
  91 + </uni-list-item>
  92 + <uni-list-item title="不含税单价">
  93 + <template v-slot:footer>
  94 + <uni-easyinput :value="item.noTaxPrice" :inputBorder="false" disabled />
  95 + </template>
  96 + </uni-list-item>
  97 + <uni-list-item title="不含税金额">
  98 + <template v-slot:footer>
  99 + <uni-easyinput :value="item.noTaxAmount" :inputBorder="false" disabled />
  100 + </template>
  101 + </uni-list-item>
  102 + <uni-list-item title="备注">
  103 + <template v-slot:footer>
  104 + <uni-easyinput v-model="item.remark" :inputBorder="false" placeholder="请输入备注" />
  105 + </template>
  106 + </uni-list-item>
  107 + </uni-list>
  108 + </view>
  109 + </view>
  110 + </view>
  111 +
  112 + <!-- 合计 -->
  113 + <view class="total-card">
  114 + <view class="total-title">合计</view>
  115 + <view class="total-body">
  116 + <view class="total-item">
  117 + <text class="total-label">采购数</text>
  118 + <text class="total-value">{{ purchaseQuantityCap }}</text>
  119 + </view>
  120 + <view class="total-item">
  121 + <text class="total-label">实收数</text>
  122 + <text class="total-value">{{ totalActualQuantity || '-' }}</text>
  123 + </view>
  124 + <view class="total-item">
  125 + <text class="total-label">含税金额</text>
  126 + <text class="total-value">{{ totalTaxAmount || '-' }}</text>
  127 + </view>
  128 + </view>
  129 + </view>
  130 +
  131 + <!-- 其他信息 -->
  132 + <view class="remark-section">
  133 + <view class="header">
  134 + <image class="opCollapse" src="/static/images/title.png" />
  135 + <text class="title">其他信息</text>
  136 + </view>
  137 + <view class="section-content">
  138 + <view class="remark-group">
  139 + <view class="remark-label">备注</view>
  140 + <uni-easyinput v-model="form.remark" type="textarea" :inputBorder="false" placeholder="请输入备注" maxlength="2000" autoHeight />
  141 + </view>
  142 +
  143 + <!-- 附件 -->
  144 + <view class="form-group">
  145 + <view class="item-title"><text class="required">*</text><text>附件</text></view>
  146 + <view class="upload-btn" @click="selectFile">上传文件</view>
  147 + <view v-if="!fileList.length" class="empty-tip">请上传附件</view>
  148 + <view v-for="(file, idx) in fileList" :key="file.fileId || idx" class="file-item">
  149 + <text class="file-name">{{ file.fileName || '未命名文件' }}</text>
  150 + <text class="file-del" @click="removeFile(idx)">删除</text>
  151 + </view>
  152 + </view>
  153 + </view>
  154 + </view>
  155 +
  156 + <view class="footer">
  157 + <button class="btn submit" type="primary" @click="onSubmit">保存</button>
  158 + </view>
  159 + </scroll-view>
  160 + </view>
  161 +</template>
  162 +
  163 +<script>
  164 +import {
  165 + warehouseReceiveDetailApi,
  166 + warehouseReceiveUpdateApi
  167 +} from '@/api/procure-manage/warehouseMaterial.js'
  168 +import upload from '@/utils/upload'
  169 +import { uploadFileApi } from '@/api/base.js'
  170 +
  171 +export default {
  172 + name: 'ModifyWarehouseMaterial',
  173 + data() {
  174 + return {
  175 + id: '',
  176 + form: {
  177 + id: '',
  178 + settleDetailId: '',
  179 + weighingTicketCode: '',
  180 + ticketDate: '',
  181 + materialSource: '',
  182 + planCode: '',
  183 + workshopName: '',
  184 + remark: ''
  185 + },
  186 + // 明细数据(详情回显,采购数/实收数/含税单价可编辑)
  187 + lineList: [],
  188 + // 附件列表(详情回显,可上传/删除)
  189 + fileList: []
  190 + }
  191 + },
  192 + computed: {
  193 + // 合计-采购数(保留两位)
  194 + totalPurchaseQuantity() {
  195 + const list = this.lineList || []
  196 + return Number(list.reduce((sum, row) => sum + Number(row.purchaseQuantity || 0), 0).toFixed(2))
  197 + },
  198 + // 合计-实收数(保留两位)
  199 + totalActualQuantity() {
  200 + const list = this.lineList || []
  201 + return Number(list.reduce((sum, row) => sum + Number(row.actualQuantity || 0), 0).toFixed(2))
  202 + },
  203 + // 合计-含税金额(保留两位)
  204 + totalTaxAmount() {
  205 + const list = this.lineList || []
  206 + return Number(list.reduce((sum, row) => sum + Number(row.taxAmount || 0), 0).toFixed(2))
  207 + },
  208 + // 合计-采购数大写(中文大写+公斤,编辑提交时传给后端)
  209 + purchaseQuantityCap() {
  210 + if (!(this.lineList || []).length) return '-'
  211 + return numberToChineseUpper(this.totalPurchaseQuantity) + '公斤'
  212 + }
  213 + },
  214 + onLoad(query) {
  215 + this.id = (query && query.id) || ''
  216 + },
  217 + created() {
  218 + this.loadDetail()
  219 + },
  220 + methods: {
  221 + loadDetail() {
  222 + if (!this.id) {
  223 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  224 + return
  225 + }
  226 + uni.showLoading({ title: '加载中...', mask: true })
  227 + warehouseReceiveDetailApi({ id: this.id })
  228 + .then(res => {
  229 + const data = res && res.data ? (res.data.data || res.data) : {}
  230 + this.form = {
  231 + id: data.id || this.id,
  232 + settleDetailId: data.settleDetailId || '',
  233 + weighingTicketCode: data.weighingTicketCode || '',
  234 + ticketDate: data.ticketDate || '',
  235 + materialSource: data.materialSource || '',
  236 + planCode: data.planCode || '',
  237 + workshopName: data.workshopName || '',
  238 + remark: data.remark || ''
  239 + }
  240 + // 明细回显(采购数/实收数/含税单价等以详情返回为准)
  241 + this.lineList = (Array.isArray(data.lines) ? data.lines : []).map(item => ({
  242 + rowId: genRowId(),
  243 + settleLineId: item.settleLineId || item.id || '',
  244 + procurementPlanId: item.procurementPlanId || '',
  245 + productId: item.productId || '',
  246 + category: item.category || '',
  247 + name: item.name || '',
  248 + specModel: item.specModel || '',
  249 + unit: item.unit || 'kg',
  250 + purchaseQuantity: item.purchaseQuantity == null ? '' : item.purchaseQuantity,
  251 + actualQuantity: item.actualQuantity == null ? '' : item.actualQuantity,
  252 + taxPrice: item.taxPrice == null ? '' : item.taxPrice,
  253 + taxAmount: item.taxAmount == null ? '' : item.taxAmount,
  254 + noTaxPrice: item.noTaxPrice == null ? '' : item.noTaxPrice,
  255 + noTaxAmount: item.noTaxAmount == null ? '' : item.noTaxAmount,
  256 + settleType: item.settleType || '',
  257 + remark: item.remark || ''
  258 + }))
  259 + // 附件回显:ids 与 names 按位置一一对应
  260 + const ids = splitCsv(data.attachmentFileIds)
  261 + const names = splitCsv(data.attachmentFileNames)
  262 + const len = Math.max(ids.length, names.length)
  263 + const list = []
  264 + for (let i = 0; i < len; i++) {
  265 + list.push({ fileId: ids[i] || '', fileName: names[i] || '' })
  266 + }
  267 + this.fileList = list
  268 + })
  269 + .catch(() => {
  270 + uni.showToast({ title: '加载详情失败', icon: 'none' })
  271 + })
  272 + .finally(() => {
  273 + uni.hideLoading()
  274 + })
  275 + },
  276 + // 含税金额 = 含税单价 * 采购数(单价或采购数为空则金额为空)
  277 + recalcTaxAmount(row) {
  278 + const price = row.taxPrice
  279 + const qty = row.purchaseQuantity
  280 + const hasPrice = price !== null && price !== undefined && price !== ''
  281 + const hasQty = qty !== null && qty !== undefined && qty !== ''
  282 + if (hasPrice && hasQty) {
  283 + row.taxAmount = Math.round(Number(price) * Number(qty) * 100) / 100
  284 + } else {
  285 + row.taxAmount = ''
  286 + }
  287 + },
  288 + // 选择并上传文件(多文件逐个追加)
  289 + selectFile() {
  290 + if (typeof uni !== 'undefined' && typeof uni.chooseMessageFile === 'function') {
  291 + uni.chooseMessageFile({
  292 + count: 9,
  293 + type: 'all',
  294 + success: async res => {
  295 + const files = (res && res.tempFiles) || []
  296 + if (!files.length) return
  297 + uni.showLoading({ title: '上传中...', mask: true })
  298 + try {
  299 + for (const f of files) {
  300 + const name = f.name || 'file'
  301 + const r = await upload({ url: '/sw/filebox/uploadFile', filePath: f.path, name: 'file' })
  302 + const d = r && r.data ? r.data : r
  303 + const id = (d && (d.id || d.fileId || (d.data && (d.data.id || d.data.fileId))))
  304 + ? String(d.id || d.fileId || d.data.id || d.data.fileId)
  305 + : ''
  306 + if (id) this.fileList.push({ fileId: id, fileName: name })
  307 + }
  308 + } catch (e) {
  309 + uni.showToast({ title: '上传失败', icon: 'none' })
  310 + } finally {
  311 + uni.hideLoading()
  312 + }
  313 + },
  314 + fail: () => {
  315 + uni.showToast({ title: '未选择文件', icon: 'none' })
  316 + }
  317 + })
  318 + return
  319 + }
  320 + // H5 兜底:动态创建原生 input
  321 + try {
  322 + const self = this
  323 + const input = document.createElement('input')
  324 + input.type = 'file'
  325 + input.multiple = true
  326 + input.style.position = 'fixed'
  327 + input.style.left = '-9999px'
  328 + document.body.appendChild(input)
  329 + input.addEventListener('change', self.onFileChange)
  330 + input.click()
  331 + setTimeout(() => { document.body.removeChild(input) }, 1000)
  332 + } catch (e) {
  333 + uni.showToast({ title: '无法打开文件选择', icon: 'none' })
  334 + }
  335 + },
  336 + async onFileChange(e) {
  337 + const files = (e && e.target && e.target.files) || []
  338 + if (!files.length) return
  339 + uni.showLoading({ title: '上传中...', mask: true })
  340 + try {
  341 + for (const file of files) {
  342 + const name = file.name || ''
  343 + const fd = new FormData()
  344 + fd.append('file', file, name)
  345 + const d = await uploadFileApi(fd)
  346 + const data = d && d.data ? d.data : d
  347 + const id = (data && (data.id || data.fileId || (data.data && (data.data.id || data.data.fileId))))
  348 + ? String(data.id || data.fileId || data.data.id || data.data.fileId)
  349 + : ''
  350 + if (id) this.fileList.push({ fileId: id, fileName: name })
  351 + }
  352 + } catch (e2) {
  353 + uni.showToast({ title: '上传失败', icon: 'none' })
  354 + } finally {
  355 + uni.hideLoading()
  356 + if (e && e.target) e.target.value = ''
  357 + }
  358 + },
  359 + // 删除附件
  360 + removeFile(idx) {
  361 + this.fileList.splice(idx, 1)
  362 + },
  363 + validate() {
  364 + const lines = this.lineList || []
  365 + if (!lines.length) return this.tip('明细数据不能为空')
  366 + for (let i = 0; i < lines.length; i++) {
  367 + const row = lines[i]
  368 + if (row.purchaseQuantity === '' || row.purchaseQuantity == null) return this.tip(`明细第${i + 1}行:请输入采购数`)
  369 + if (row.actualQuantity === '' || row.actualQuantity == null) return this.tip(`明细第${i + 1}行:请输入实收数`)
  370 + if (row.taxPrice === '' || row.taxPrice == null) return this.tip(`明细第${i + 1}行:请输入含税单价`)
  371 + }
  372 + if (!this.fileList.length) return this.tip('请上传附件')
  373 + return true
  374 + },
  375 + tip(msg) {
  376 + uni.showToast({ title: msg, icon: 'none' })
  377 + return false
  378 + },
  379 + buildSubmitData() {
  380 + return {
  381 + id: this.form.id,
  382 + settleDetailId: this.form.settleDetailId,
  383 + ticketDate: this.form.ticketDate,
  384 + materialSource: this.form.materialSource,
  385 + remark: this.form.remark || '',
  386 + attachmentFileIds: this.fileList.map(x => x.fileId).filter(Boolean).join(','),
  387 + attachmentFileNames: this.fileList.map(x => x.fileName).filter(Boolean).join(','),
  388 + // 合计-采购数大写由前端换算提交
  389 + totalPurchaseQuantityCap: (this.lineList || []).length ? numberToChineseUpper(this.totalPurchaseQuantity) + '公斤' : '',
  390 + totalActualQuantity: String(this.totalActualQuantity),
  391 + totalTaxAmount: String(this.totalTaxAmount),
  392 + // 收料单明细
  393 + lines: (this.lineList || []).map(item => ({
  394 + settleLineId: item.settleLineId || '',
  395 + procurementPlanId: item.procurementPlanId || '',
  396 + productId: item.productId || '',
  397 + category: item.category || '',
  398 + name: item.name || '',
  399 + specModel: item.specModel || '',
  400 + unit: item.unit || '',
  401 + purchaseQuantity: item.purchaseQuantity == null ? '' : String(item.purchaseQuantity),
  402 + actualQuantity: item.actualQuantity == null ? '' : String(item.actualQuantity),
  403 + taxPrice: item.taxPrice == null ? '' : String(item.taxPrice),
  404 + taxAmount: item.taxAmount == null ? '' : String(item.taxAmount),
  405 + noTaxPrice: item.noTaxPrice == null ? '' : String(item.noTaxPrice),
  406 + noTaxAmount: item.noTaxAmount == null ? '' : String(item.noTaxAmount),
  407 + settleType: item.settleType || '',
  408 + remark: item.remark || ''
  409 + }))
  410 + }
  411 + },
  412 + async onSubmit() {
  413 + if (!this.validate()) return
  414 + const confirmRes = await new Promise(resolve => {
  415 + uni.showModal({ title: '提示', content: '确定保存仓库收料单吗?', confirmText: '确定', cancelText: '取消', success: resolve })
  416 + })
  417 + if (!(confirmRes && confirmRes.confirm)) return
  418 + uni.showLoading({ title: '提交中...', mask: true })
  419 + warehouseReceiveUpdateApi(this.buildSubmitData())
  420 + .then(() => {
  421 + uni.hideLoading()
  422 + uni.showToast({ title: '保存成功', icon: 'none' })
  423 + try {
  424 + uni.setStorageSync('WAREHOUSE_MATERIAL_LIST_NEED_REFRESH', '1')
  425 + uni.setStorageSync('WAREHOUSE_MATERIAL_DETAIL_NEED_REFRESH', '1')
  426 + } catch (e) {}
  427 + setTimeout(() => { uni.navigateBack() }, 400)
  428 + })
  429 + .catch(e => {
  430 + uni.hideLoading()
  431 + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' })
  432 + })
  433 + }
  434 + }
  435 +}
  436 +
  437 +// 生成前端临时行 id
  438 +function genRowId() {
  439 + return 'row_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8)
  440 +}
  441 +
  442 +// 逗号分隔字符串转数组
  443 +function splitCsv(val) {
  444 + if (!val) return []
  445 + if (Array.isArray(val)) return val
  446 + return String(val).split(',').filter(Boolean)
  447 +}
  448 +
  449 +// 数字转中文大写(对齐 PC 端 useReceiveForm.ts,保留位权读法,不含货币单位)
  450 +function numberToChineseUpper(num) {
  451 + if (num === null || num === undefined || num === '' || isNaN(Number(num))) return '零'
  452 + const n = Number(num)
  453 + if (!isFinite(n)) return '零'
  454 +
  455 + const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
  456 + const smallUnits = ['', '拾', '佰', '仟']
  457 + const bigUnits = ['', '万', '亿', '兆']
  458 +
  459 + const negative = n < 0
  460 + const abs = Math.abs(n)
  461 + const parts = abs.toString().split('.')
  462 + const intStrRaw = parts[0]
  463 + const decStrRaw = parts[1] || ''
  464 + const s = intStrRaw
  465 + const len = s.length
  466 +
  467 + let intPart = ''
  468 + let zeroFlag = false
  469 + for (let i = 0; i < len; i++) {
  470 + const d = parseInt(s[i], 10)
  471 + const pos = len - 1 - i
  472 + const unitIdx = pos % 4
  473 + const groupIdx = Math.floor(pos / 4)
  474 + if (d !== 0) {
  475 + if (zeroFlag) {
  476 + intPart += digit[0]
  477 + zeroFlag = false
  478 + }
  479 + intPart += digit[d] + smallUnits[unitIdx]
  480 + } else {
  481 + zeroFlag = true
  482 + }
  483 + if (unitIdx === 0) {
  484 + const start = Math.max(0, len - (groupIdx + 1) * 4)
  485 + const end = len - groupIdx * 4
  486 + const groupDigits = s.slice(start, end)
  487 + if (!/^0+$/.test(groupDigits)) {
  488 + intPart += bigUnits[groupIdx] || ''
  489 + }
  490 + }
  491 + }
  492 + if (intPart === '') intPart = digit[0]
  493 +
  494 + let result = intPart
  495 + if (decStrRaw) {
  496 + const decChars = decStrRaw
  497 + .split('')
  498 + .map(c => digit[parseInt(c, 10)])
  499 + .join('')
  500 + result += '点' + decChars
  501 + }
  502 + return (negative ? '负' : '') + result
  503 +}
  504 +</script>
  505 +
  506 +<style lang="scss" scoped>
  507 +.page {
  508 + display: flex;
  509 + flex-direction: column;
  510 + height: 100%;
  511 +}
  512 +
  513 +.scroll {
  514 + flex: 1;
  515 + padding: 12rpx 0 200rpx !important;
  516 +}
  517 +
  518 +.footer {
  519 + z-index: 2;
  520 + position: fixed;
  521 + left: 0;
  522 + right: 0;
  523 + bottom: 0;
  524 + padding: 32rpx;
  525 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  526 + background: #fff;
  527 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  528 +
  529 + .btn {
  530 + height: 80rpx;
  531 + line-height: 80rpx;
  532 + border-radius: 12rpx;
  533 + font-size: 32rpx;
  534 + }
  535 +
  536 + .submit {
  537 + background: $theme-primary;
  538 + color: #fff;
  539 + }
  540 +}
  541 +
  542 +::v-deep .uni-list {
  543 + .uni-easyinput {
  544 + display: flex;
  545 +
  546 + .uni-input-input {
  547 + color: rgba(0, 0, 0, 0.9);
  548 + }
  549 + }
  550 +
  551 + .uni-input-placeholder {
  552 + z-index: 1;
  553 + }
  554 +
  555 + .uni-input-input {
  556 + background-color: #ffffff;
  557 + }
  558 +
  559 + background: transparent;
  560 +
  561 + &-item {
  562 + &__extra-text {
  563 + font-size: 32rpx;
  564 + }
  565 +
  566 + &__content-title {
  567 + font-size: 32rpx;
  568 + color: rgba(0, 0, 0, 0.9);
  569 + }
  570 +
  571 + &__container {
  572 + padding: 32rpx;
  573 +
  574 + .uni-easyinput {
  575 + &__placeholder-class {
  576 + font-size: 32rpx;
  577 + color: rgba(0, 0, 0, 0.4);
  578 + }
  579 +
  580 + &__content {
  581 + border: none;
  582 + background-color: #ffffff !important;
  583 +
  584 + &-input {
  585 + padding-left: 0 !important;
  586 + height: 48rpx;
  587 + line-height: 48rpx;
  588 + font-size: 32rpx;
  589 + }
  590 +
  591 + .content-clear-icon {
  592 + font-size: 44rpx !important;
  593 + }
  594 + }
  595 + }
  596 +
  597 + .item-title,
  598 + .uni-list-item__content {
  599 + flex: none;
  600 + min-height: 48rpx;
  601 + line-height: 48rpx;
  602 + font-size: 32rpx;
  603 + position: relative;
  604 + width: 240rpx;
  605 + margin-right: 32rpx;
  606 + color: rgba(0, 0, 0, 0.9);
  607 +
  608 + .required {
  609 + color: red;
  610 + position: absolute;
  611 + top: 50%;
  612 + transform: translateY(-50%);
  613 + left: -16rpx;
  614 + }
  615 + }
  616 + }
  617 + }
  618 +}
  619 +
  620 +.sub-table,
  621 +.remark-section {
  622 + margin-top: 20rpx;
  623 + background: #fff;
  624 +}
  625 +
  626 +.header {
  627 + display: flex;
  628 + align-items: center;
  629 + padding: 24rpx 32rpx;
  630 + border-bottom: 1rpx solid #f0f0f0;
  631 +
  632 + .opCollapse {
  633 + width: 32rpx;
  634 + height: 28rpx;
  635 + margin-right: 16rpx;
  636 + margin-top: 8rpx;
  637 + }
  638 +
  639 + .title {
  640 + font-size: 32rpx;
  641 + color: rgba(0, 0, 0, 0.9);
  642 + font-weight: 600;
  643 + flex: 1;
  644 + }
  645 +}
  646 +
  647 +.add-list {
  648 + padding: 0 0 16rpx;
  649 +
  650 + .empty-tip {
  651 + text-align: center;
  652 + padding: 60rpx 0;
  653 + color: rgba(0, 0, 0, 0.4);
  654 + font-size: 28rpx;
  655 + }
  656 +
  657 + .block {
  658 + border-bottom: 1rpx solid #f0f0f0;
  659 +
  660 + &:last-child {
  661 + border-bottom: none;
  662 + }
  663 + }
  664 +}
  665 +
  666 +.total-card {
  667 + margin-top: 20rpx;
  668 + background: #fff;
  669 + padding: 24rpx 32rpx;
  670 +
  671 + .total-title {
  672 + font-size: 32rpx;
  673 + font-weight: 600;
  674 + color: rgba(0, 0, 0, 0.9);
  675 + margin-bottom: 20rpx;
  676 + }
  677 +
  678 + .total-body {
  679 + display: flex;
  680 + flex-wrap: wrap;
  681 +
  682 + .total-item {
  683 + width: 50%;
  684 + display: flex;
  685 + align-items: center;
  686 + margin-bottom: 20rpx;
  687 +
  688 + &:nth-last-child(-n + 2) {
  689 + margin-bottom: 0;
  690 + }
  691 +
  692 + .total-label {
  693 + font-size: 28rpx;
  694 + color: rgba(0, 0, 0, 0.6);
  695 + margin-right: 16rpx;
  696 + }
  697 +
  698 + .total-value {
  699 + font-size: 28rpx;
  700 + color: rgba(0, 0, 0, 0.9);
  701 + font-weight: 500;
  702 + }
  703 + }
  704 + }
  705 +}
  706 +
  707 +.section-content {
  708 + padding: 32rpx;
  709 +}
  710 +
  711 +.form-group {
  712 + margin-top: 24rpx;
  713 +
  714 + .item-title {
  715 + display: flex;
  716 + align-items: center;
  717 + font-size: 32rpx;
  718 + color: rgba(0, 0, 0, 0.9);
  719 + margin-bottom: 20rpx;
  720 + position: relative;
  721 + padding-left: 16rpx;
  722 +
  723 + .required {
  724 + color: red;
  725 + position: absolute;
  726 + left: 0;
  727 + }
  728 + }
  729 +
  730 + .upload-btn {
  731 + display: inline-block;
  732 + height: 64rpx;
  733 + line-height: 64rpx;
  734 + padding: 0 32rpx;
  735 + font-size: 28rpx;
  736 + border-radius: 8rpx;
  737 + background: $theme-primary;
  738 + color: #fff;
  739 + }
  740 +
  741 + .empty-tip {
  742 + text-align: center;
  743 + padding: 24rpx 0;
  744 + color: rgba(0, 0, 0, 0.4);
  745 + font-size: 28rpx;
  746 + }
  747 +
  748 + .file-item {
  749 + display: flex;
  750 + align-items: center;
  751 + justify-content: space-between;
  752 + padding: 20rpx 24rpx;
  753 + margin-top: 16rpx;
  754 + background: #fafafa;
  755 + border-radius: 8rpx;
  756 +
  757 + .file-name {
  758 + flex: 1;
  759 + font-size: 28rpx;
  760 + color: rgba(0, 0, 0, 0.9);
  761 + word-break: break-all;
  762 + margin-right: 20rpx;
  763 + }
  764 +
  765 + .file-del {
  766 + flex-shrink: 0;
  767 + font-size: 26rpx;
  768 + color: #d54941;
  769 + }
  770 + }
  771 +}
  772 +
  773 +.remark-group {
  774 + margin-bottom: 32rpx;
  775 +
  776 + .remark-label {
  777 + display: flex;
  778 + align-items: center;
  779 + font-size: 32rpx;
  780 + color: rgba(0, 0, 0, 0.9);
  781 + margin-bottom: 16rpx;
  782 + }
  783 +}
  784 +</style>
  1 +<template>
  2 + <view class="detail-page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <!-- 基础信息 -->
  5 + <view class="section">
  6 + <text class="row company">{{ safeText(form.weighingTicketCode) }}</text>
  7 + <view class="row"><text class="label">日期</text><text class="value">{{ safeText(form.ticketDate) }}</text></view>
  8 + <view class="row"><text class="label">材料来源</text><text class="value">{{ safeText(form.materialSource) }}</text></view>
  9 + <view class="row"><text class="label">计划单编号</text><text class="value">{{ safeText(form.planCode) }}</text></view>
  10 + <view class="row"><text class="label">分厂</text><text class="value">{{ safeText(form.workshopName) }}</text></view>
  11 + </view>
  12 +
  13 + <!-- 明细数据 -->
  14 + <view class="sub-table">
  15 + <view class="sub-header">
  16 + <image class="sub-bar" src="/static/images/title.png" />
  17 + <text class="sub-title">明细数据</text>
  18 + </view>
  19 + <view class="sub-body">
  20 + <view v-if="!lineList.length" class="empty-tip">暂无明细</view>
  21 + <view v-for="(item, idx) in lineList" :key="'l-' + (item.id || idx)" class="card">
  22 + <view class="card-index">第 {{ idx + 1 }} 行</view>
  23 + <view class="row"><text class="label">材料编号</text><text class="value">{{ safeText(item.category) }}</text></view>
  24 + <view class="row"><text class="label">材料名称</text><text class="value">{{ safeText(item.name) }}</text></view>
  25 + <view class="row"><text class="label">规格型号</text><text class="value">{{ safeText(item.specModel) }}</text></view>
  26 + <view class="row"><text class="label">单位</text><text class="value">{{ safeText(item.unit) }}</text></view>
  27 + <view class="row"><text class="label">数量(采购数)</text><text class="value">{{ formatNumber(item.purchaseQuantity) }}</text></view>
  28 + <view class="row actual-row">
  29 + <view class="label"><text v-if="canEditActualQuantity" class="required">*</text><text>数量(实收数)</text></view>
  30 + <view class="actual-value">
  31 + <uni-easyinput v-if="canEditActualQuantity" v-model="item.actualQuantity" type="digit"
  32 + :inputBorder="false" placeholder="请输入实收数" />
  33 + <text v-else class="value">{{ formatNumber(item.actualQuantity) }}</text>
  34 + </view>
  35 + </view>
  36 + <view class="row"><text class="label">含税价格(单价)</text><text class="value">{{ formatNumber(item.taxPrice) }}</text></view>
  37 + <view class="row"><text class="label">含税价格(金额)</text><text class="value">{{ formatNumber(item.taxAmount) }}</text></view>
  38 + <view class="row"><text class="label">不含税价格(单价)</text><text class="value">{{ formatNumber(item.noTaxPrice) }}</text></view>
  39 + <view class="row"><text class="label">不含税价格(金额)</text><text class="value">{{ formatNumber(item.noTaxAmount) }}</text></view>
  40 + </view>
  41 + </view>
  42 + </view>
  43 +
  44 + <!-- 其他信息 -->
  45 + <view class="title-header">
  46 + <image class="title-header_icon" src="/static/images/title.png" />
  47 + <span>其他信息</span>
  48 + </view>
  49 + <view class="total-card">
  50 + <view class="total-title">合计</view>
  51 + <view class="total-body">
  52 + <view class="total-item">
  53 + <text class="total-label">采购数</text>
  54 + <text class="total-value">{{ purchaseQuantityCap }}</text>
  55 + </view>
  56 + <view class="total-item">
  57 + <text class="total-label">实收数</text>
  58 + <text class="total-value">{{ formatNumber(form.totalActualQuantity) }}</text>
  59 + </view>
  60 + <view class="total-item">
  61 + <text class="total-label">含税金额</text>
  62 + <text class="total-value">{{ formatNumber(form.totalTaxAmount) }}</text>
  63 + </view>
  64 + </view>
  65 + </view>
  66 + <view class="section">
  67 + <view class="remark-label">备注</view>
  68 + <text class="remark-text">{{ safeText(form.remark) }}</text>
  69 + <view class="remark-label">附件</view>
  70 + <view v-if="!fileList.length" class="empty-tip">暂无附件</view>
  71 + <view v-for="(file, idx) in fileList" :key="file.fileId || idx" class="file-item"
  72 + @click="downloadAttachment(file)">
  73 + <text class="file-name">{{ file.fileName || '未命名文件' }}</text>
  74 + </view>
  75 + </view>
  76 + </scroll-view>
  77 + </view>
  78 +</template>
  79 +
  80 +<script>
  81 +import { warehouseReceiveDetailApi } from '@/api/procure-manage/warehouseMaterial.js'
  82 +import { getInstanceByBusinessIdApi } from '@/api/flow.js'
  83 +import { downloadFile } from '@/utils/downloadFile.js'
  84 +
  85 +// 数量(实收数)可修改的流程节点 code(各分厂仓库统计员环节,对齐 PC 端 viewer.vue)
  86 +const EDITABLE_ACTUAL_QUANTITY_NODE_CODES = [
  87 + 'receive_order_yfccktjy',
  88 + 'receive_order_efccktjy',
  89 + 'receive_order_sfccktjy',
  90 + 'receive_order_ztfccktjy'
  91 +]
  92 +
  93 +export default {
  94 + name: 'WarehouseMaterialViewer',
  95 + props: {
  96 + id: { type: [String, Number], default: '' },
  97 + // 当前审核节点编码(审核页透传,备用;可编辑判断以按业务ID查询流程实例结果为准)
  98 + nodeCode: { type: String, default: '' }
  99 + },
  100 + data() {
  101 + return {
  102 + // 业务数据全量(详情接口返回,getFormValues 提交 variables 用)
  103 + bizData: {},
  104 + form: {},
  105 + lineList: [],
  106 + // 当前审核节点是否允许修改数量(实收数)
  107 + canEditActualQuantity: false
  108 + }
  109 + },
  110 + computed: {
  111 + // 合计-采购数(明细行采购数求和后转中文大写+公斤)
  112 + purchaseQuantityCap() {
  113 + if (!(this.lineList || []).length) return '-'
  114 + const total = (this.lineList || []).reduce(
  115 + (sum, row) => sum + Number(row.purchaseQuantity || 0), 0
  116 + )
  117 + return numberToChineseUpper(Number(total.toFixed(2))) + '公斤'
  118 + },
  119 + // 附件列表(ids 与 names 按位置一一对应)
  120 + fileList() {
  121 + const ids = splitCsv(this.bizData.attachmentFileIds)
  122 + const names = splitCsv(this.bizData.attachmentFileNames)
  123 + const len = Math.max(ids.length, names.length)
  124 + const list = []
  125 + for (let i = 0; i < len; i++) {
  126 + list.push({ fileId: ids[i] || '', fileName: names[i] || '' })
  127 + }
  128 + return list
  129 + }
  130 + },
  131 + created() {
  132 + if (this.nodeCode && EDITABLE_ACTUAL_QUANTITY_NODE_CODES.includes(this.nodeCode)) {
  133 + this.canEditActualQuantity = true
  134 + }
  135 + },
  136 + watch: {
  137 + id: {
  138 + immediate: true,
  139 + handler(val) {
  140 + const v = (val !== undefined && val !== null) ? String(val) : ''
  141 + if (v) this.loadDetail(v)
  142 + }
  143 + }
  144 + },
  145 + methods: {
  146 + loadDetail(id) {
  147 + warehouseReceiveDetailApi({ id })
  148 + .then(res => {
  149 + const data = res && res.data ? (res.data.data || res.data) : {}
  150 + // 保留业务数据全量(getFormValues 提交 variables 用)
  151 + this.bizData = Object.assign({}, data)
  152 + this.form = {
  153 + weighingTicketCode: data.weighingTicketCode || '',
  154 + ticketDate: data.ticketDate || '',
  155 + materialSource: data.materialSource || '',
  156 + planCode: data.planCode || '',
  157 + workshopName: data.workshopName || '',
  158 + totalActualQuantity: data.totalActualQuantity == null ? '' : data.totalActualQuantity,
  159 + totalTaxAmount: data.totalTaxAmount == null ? '' : data.totalTaxAmount,
  160 + remark: data.remark || ''
  161 + }
  162 + this.lineList = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : []
  163 + // 按流程实例当前节点判断数量(实收数)是否可修改
  164 + this.loadFlowNode()
  165 + })
  166 + .catch(() => {
  167 + uni.showToast({ title: '详情加载失败', icon: 'none' })
  168 + })
  169 + },
  170 + // 查询流程实例:当前审核节点为各分厂仓库统计员环节时,数量(实收数)可修改
  171 + loadFlowNode() {
  172 + this.canEditActualQuantity = false
  173 + const id = this.id == null ? '' : String(this.id)
  174 + if (!id) return
  175 + getInstanceByBusinessIdApi({ businessId: id, operateType: 'AUDIT' })
  176 + .then(res => {
  177 + const data = res && res.data ? res.data : {}
  178 + const nodeCode = data.nodeCode || this.nodeCode || ''
  179 + this.canEditActualQuantity = EDITABLE_ACTUAL_QUANTITY_NODE_CODES.includes(nodeCode)
  180 + })
  181 + .catch(() => {
  182 + // 查询失败时退回审核页透传的节点编码
  183 + this.canEditActualQuantity = EDITABLE_ACTUAL_QUANTITY_NODE_CODES.includes(this.nodeCode || '')
  184 + })
  185 + },
  186 + // 附件下载
  187 + downloadAttachment(file) {
  188 + const id = file && file.fileId
  189 + const fileName = file && file.fileName
  190 + if (!id) return
  191 + downloadFile(id, fileName)
  192 + },
  193 + // 供流程审核页获取业务表单数据(variables,含审核环节修改后的明细实收数)
  194 + getFormValues() {
  195 + return { ...this.bizData, lines: this.lineList }
  196 + },
  197 + // 供流程审核页审批通过前校验(审批表单只读,无需校验)
  198 + checkForm() {
  199 + return true
  200 + },
  201 + safeText(v) {
  202 + const s = v == null ? '' : String(v)
  203 + return s.trim() ? s : '-'
  204 + },
  205 + formatNumber(v) {
  206 + if (v === null || v === undefined || v === '') return '-'
  207 + const n = Number(v)
  208 + if (isNaN(n)) return String(v)
  209 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  210 + }
  211 + }
  212 +}
  213 +
  214 +// 逗号分隔字符串转数组
  215 +function splitCsv(val) {
  216 + if (!val) return []
  217 + if (Array.isArray(val)) return val
  218 + return String(val).split(',').filter(Boolean)
  219 +}
  220 +
  221 +// 数字转中文大写(对齐 PC 端 useReceiveForm.ts,保留位权读法,不含货币单位)
  222 +function numberToChineseUpper(num) {
  223 + if (num === null || num === undefined || num === '' || isNaN(Number(num))) return '零'
  224 + const n = Number(num)
  225 + if (!isFinite(n)) return '零'
  226 +
  227 + const digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']
  228 + const smallUnits = ['', '拾', '佰', '仟']
  229 + const bigUnits = ['', '万', '亿', '兆']
  230 +
  231 + const negative = n < 0
  232 + const abs = Math.abs(n)
  233 + const parts = abs.toString().split('.')
  234 + const intStrRaw = parts[0]
  235 + const decStrRaw = parts[1] || ''
  236 + const s = intStrRaw
  237 + const len = s.length
  238 +
  239 + let intPart = ''
  240 + let zeroFlag = false
  241 + for (let i = 0; i < len; i++) {
  242 + const d = parseInt(s[i], 10)
  243 + const pos = len - 1 - i
  244 + const unitIdx = pos % 4
  245 + const groupIdx = Math.floor(pos / 4)
  246 + if (d !== 0) {
  247 + if (zeroFlag) {
  248 + intPart += digit[0]
  249 + zeroFlag = false
  250 + }
  251 + intPart += digit[d] + smallUnits[unitIdx]
  252 + } else {
  253 + zeroFlag = true
  254 + }
  255 + if (unitIdx === 0) {
  256 + const start = Math.max(0, len - (groupIdx + 1) * 4)
  257 + const end = len - groupIdx * 4
  258 + const groupDigits = s.slice(start, end)
  259 + if (!/^0+$/.test(groupDigits)) {
  260 + intPart += bigUnits[groupIdx] || ''
  261 + }
  262 + }
  263 + }
  264 + if (intPart === '') intPart = digit[0]
  265 +
  266 + let result = intPart
  267 + if (decStrRaw) {
  268 + const decChars = decStrRaw
  269 + .split('')
  270 + .map(c => digit[parseInt(c, 10)])
  271 + .join('')
  272 + result += '点' + decChars
  273 + }
  274 + return (negative ? '负' : '') + result
  275 +}
  276 +</script>
  277 +
  278 +<style lang="scss" scoped>
  279 +.detail-page {
  280 + background: #f3f3f3;
  281 + min-height: 100%;
  282 +}
  283 +.scroll {
  284 + flex: 1;
  285 + padding: 8rpx 0;
  286 +}
  287 +.section {
  288 + padding: 32rpx;
  289 + background: #fff;
  290 + margin-bottom: 20rpx;
  291 +}
  292 +.title-header {
  293 + display: flex;
  294 + align-items: center;
  295 + padding: 24rpx 32rpx 12rpx;
  296 + background-color: #ffffff;
  297 + .title-header_icon { width: 36rpx; height: 36rpx; margin-right: 12rpx; }
  298 + span { font-size: 34rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); }
  299 +}
  300 +.row {
  301 + display: flex;
  302 + margin-bottom: 28rpx;
  303 + &:last-child { margin-bottom: 0; }
  304 + &.company {
  305 + font-size: 36rpx;
  306 + font-weight: 600;
  307 + color: rgba(0, 0, 0, 0.9);
  308 + padding-top: 8rpx;
  309 + line-height: 50rpx;
  310 + }
  311 + &.actual-row {
  312 + align-items: center;
  313 + justify-content: space-between;
  314 + .label {
  315 + flex-shrink: 0;
  316 + width: 220rpx;
  317 + max-width: none;
  318 + margin-right: 0;
  319 + font-size: 28rpx;
  320 + color: rgba(0, 0, 0, 0.6);
  321 + line-height: 40rpx;
  322 + position: relative;
  323 + .required {
  324 + color: red;
  325 + position: absolute;
  326 + left: -16rpx;
  327 + }
  328 + }
  329 + .actual-value {
  330 + flex: 1;
  331 + min-height: 48rpx;
  332 + .value { font-size: 28rpx; }
  333 +
  334 + ::v-deep .uni-easyinput {
  335 + display: flex;
  336 + }
  337 +
  338 + ::v-deep .uni-easyinput__content {
  339 + border: none;
  340 + background-color: transparent !important;
  341 + }
  342 +
  343 + ::v-deep .uni-input-input {
  344 + text-align: right;
  345 + font-size: 28rpx;
  346 + color: rgba(0, 0, 0, 0.9);
  347 + }
  348 + }
  349 + }
  350 + .label {
  351 + max-width: 420rpx;
  352 + margin-right: 20rpx;
  353 + line-height: 32rpx;
  354 + font-size: 28rpx;
  355 + color: rgba(0, 0, 0, 0.6);
  356 + }
  357 + .value {
  358 + flex: 1;
  359 + line-height: 32rpx;
  360 + font-size: 28rpx;
  361 + color: rgba(0, 0, 0, 0.9);
  362 + text-align: right;
  363 + word-break: break-all;
  364 + }
  365 +}
  366 +.remark-label {
  367 + display: flex;
  368 + align-items: center;
  369 + font-size: 32rpx;
  370 + color: rgba(0, 0, 0, 0.9);
  371 + margin-bottom: 16rpx;
  372 +}
  373 +.remark-text {
  374 + font-size: 28rpx;
  375 + color: rgba(0, 0, 0, 0.9);
  376 + line-height: 1.6;
  377 + white-space: pre-wrap;
  378 + margin-bottom: 32rpx;
  379 +}
  380 +.empty-tip {
  381 + text-align: center;
  382 + padding: 24rpx 0;
  383 + color: rgba(0, 0, 0, 0.4);
  384 + font-size: 28rpx;
  385 +}
  386 +.file-item {
  387 + display: flex;
  388 + align-items: center;
  389 + justify-content: space-between;
  390 + padding: 20rpx 24rpx;
  391 + margin-bottom: 16rpx;
  392 + background: #fafafa;
  393 + border-radius: 8rpx;
  394 +
  395 + &:last-child {
  396 + margin-bottom: 0;
  397 + }
  398 +
  399 + .file-name {
  400 + flex: 1;
  401 + font-size: 28rpx;
  402 + color: $theme-primary;
  403 + word-break: break-all;
  404 + margin-right: 20rpx;
  405 + }
  406 +}
  407 +.total-card {
  408 + background: #fff;
  409 + margin-bottom: 20rpx;
  410 + padding: 24rpx 32rpx;
  411 + .total-title {
  412 + font-size: 32rpx;
  413 + font-weight: 600;
  414 + color: rgba(0, 0, 0, 0.9);
  415 + margin-bottom: 20rpx;
  416 + }
  417 + .total-body {
  418 + display: flex;
  419 + flex-wrap: wrap;
  420 + .total-item {
  421 + width: 50%;
  422 + display: flex;
  423 + align-items: center;
  424 + margin-bottom: 20rpx;
  425 + &:nth-last-child(-n + 2) { margin-bottom: 0; }
  426 + .total-label {
  427 + font-size: 28rpx;
  428 + color: rgba(0, 0, 0, 0.6);
  429 + margin-right: 16rpx;
  430 + }
  431 + .total-value {
  432 + font-size: 28rpx;
  433 + color: rgba(0, 0, 0, 0.9);
  434 + font-weight: 500;
  435 + word-break: break-all;
  436 + }
  437 + }
  438 + }
  439 +}
  440 +.sub-table {
  441 + background: #fff;
  442 + margin-bottom: 20rpx;
  443 +}
  444 +.sub-header {
  445 + display: flex;
  446 + align-items: center;
  447 + padding: 16rpx 0 16rpx 32rpx;
  448 + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; }
  449 + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; }
  450 +}
  451 +.sub-body {
  452 + padding: 0 32rpx 24rpx;
  453 + .empty-tip {
  454 + text-align: center;
  455 + padding: 60rpx 0;
  456 + color: rgba(0, 0, 0, 0.4);
  457 + font-size: 28rpx;
  458 + }
  459 + .card {
  460 + position: relative;
  461 + background: #fafafa;
  462 + border-radius: 12rpx;
  463 + padding: 32rpx 28rpx 20rpx;
  464 + margin-bottom: 24rpx;
  465 + .card-index {
  466 + position: absolute;
  467 + top: 0;
  468 + right: 0;
  469 + background: rgba(24, 144, 255, 0.08);
  470 + color: $theme-primary;
  471 + font-size: 22rpx;
  472 + line-height: 36rpx;
  473 + padding: 0 16rpx;
  474 + border-bottom-left-radius: 12rpx;
  475 + border-top-right-radius: 12rpx;
  476 + }
  477 + .row {
  478 + align-items: center;
  479 + justify-content: space-between;
  480 + padding: 14rpx 0;
  481 + margin-bottom: 0;
  482 + border-bottom: 1rpx dashed #f2f2f2;
  483 + &:last-child { border-bottom: none; }
  484 + .label {
  485 + flex-shrink: 0;
  486 + width: 220rpx;
  487 + max-width: none;
  488 + margin-right: 0;
  489 + font-size: 28rpx;
  490 + color: rgba(0, 0, 0, 0.6);
  491 + line-height: 40rpx;
  492 + }
  493 + .value {
  494 + flex: 1;
  495 + text-align: right;
  496 + font-size: 28rpx;
  497 + color: rgba(0, 0, 0, 0.9);
  498 + line-height: 40rpx;
  499 + overflow: hidden;
  500 + text-overflow: ellipsis;
  501 + white-space: nowrap;
  502 + }
  503 + }
  504 + }
  505 +}
  506 +</style>
@@ -33,6 +33,7 @@ import WeightTicketViewer from '@/pages/weight-ticket/weightTicketViewer.vue' @@ -33,6 +33,7 @@ import WeightTicketViewer from '@/pages/weight-ticket/weightTicketViewer.vue'
33 import SampleSubmissionViewer from '@/pages/sample-submission/sampleSubmissionViewer.vue' 33 import SampleSubmissionViewer from '@/pages/sample-submission/sampleSubmissionViewer.vue'
34 import MaterialTestViewer from '@/pages/material-test/materialTestViewer.vue' 34 import MaterialTestViewer from '@/pages/material-test/materialTestViewer.vue'
35 import MaterialSettlementViewer from '@/pages/material-settlement/materialSettlementViewer.vue' 35 import MaterialSettlementViewer from '@/pages/material-settlement/materialSettlementViewer.vue'
  36 +import WarehouseMaterialViewer from '@/pages/warehouse-material/warehouseMaterialViewer.vue'
36 37
37 export default function registerComponents(Vue) { 38 export default function registerComponents(Vue) {
38 Vue.component('CustomerDevelopViewer', CustomerDevelopViewer) 39 Vue.component('CustomerDevelopViewer', CustomerDevelopViewer)
@@ -70,4 +71,5 @@ export default function registerComponents(Vue) { @@ -70,4 +71,5 @@ export default function registerComponents(Vue) {
70 Vue.component('SampleSubmissionViewer', SampleSubmissionViewer) 71 Vue.component('SampleSubmissionViewer', SampleSubmissionViewer)
71 Vue.component('MaterialTestViewer', MaterialTestViewer) 72 Vue.component('MaterialTestViewer', MaterialTestViewer)
72 Vue.component('MaterialSettlementViewer', MaterialSettlementViewer) 73 Vue.component('MaterialSettlementViewer', MaterialSettlementViewer)
  74 + Vue.component('WarehouseMaterialViewer', WarehouseMaterialViewer)
73 } 75 }
@@ -177,6 +177,12 @@ export const getSysFlowComponentPath = (bizFlag) => { @@ -177,6 +177,12 @@ export const getSysFlowComponentPath = (bizFlag) => {
177 case 'SETTLE_DETAIL_EDIT': // 原料结算详情单 177 case 'SETTLE_DETAIL_EDIT': // 原料结算详情单
178 componentPath = 'MaterialSettlementViewer'; // 原料结算详情单-审批 178 componentPath = 'MaterialSettlementViewer'; // 原料结算详情单-审批
179 break; 179 break;
  180 + case 'RECEIVE_ORDER': // 仓库收料单
  181 + componentPath = 'WarehouseMaterialViewer'; // 仓库收料单-审批详情
  182 + break;
  183 + case 'RECEIVE_ORDER_EDIT': // 仓库收料单
  184 + componentPath = 'WarehouseMaterialViewer'; // 仓库收料单-审批
  185 + break;
180 } 186 }
181 return componentPath; 187 return componentPath;
182 }; 188 };