Commit 8fdd94a0ac611e41ad6898b2975bd65d8118935e

Authored by gesilong
2 parents 7f8820ab 7684cdd5

Merge branch 'cjerp-3.0' into publish_cjerp

# Conflicts:
#	pages/domestic-plan/productRel.vue

Too many changes to show.

To preserve performance only 18 of 51 files are displayed.

  1 +import request from '@/utils/request'
  2 +import { ContentTypeEnum } from '@/utils/httpEnum'
  3 +
  4 +// 化验送样单(对齐 PC 端 api/warehouse-manage/sample-submission)
  5 +const baseUrl = '/procurement/assay/apply'
  6 +
  7 +/**
  8 + * 生成送样单编号(直接返回编号字符串)
  9 + */
  10 +export function assayApplyGenerateCodeApi() {
  11 + return request({
  12 + url: baseUrl + '/generateCode',
  13 + method: 'get'
  14 + })
  15 +}
  16 +
  17 +/**
  18 + * 分页查询化验送样单列表
  19 + * params: pageIndex, pageSize, weighingTicketCode, productName,
  20 + * planCode, approvalStatus, createBy, deleted(boolean)
  21 + */
  22 +export function assayApplyQueryApi(params) {
  23 + return request({
  24 + url: baseUrl + '/query',
  25 + method: 'get',
  26 + params
  27 + })
  28 +}
  29 +
  30 +/**
  31 + * 分页查询可选过磅码单列表(码单编号选择)
  32 + * params: pageIndex, pageSize, code, workshopId
  33 + */
  34 +export function assayApplyTicketPageApi(params) {
  35 + return request({
  36 + url: baseUrl + '/ticketPage',
  37 + method: 'get',
  38 + params
  39 + })
  40 +}
  41 +
  42 +/**
  43 + * 根据过磅码单ID查询码单数据(含计划编号下拉选项 planOptions)
  44 + */
  45 +export function assayApplyTicketDataApi(ticketId) {
  46 + return request({
  47 + url: baseUrl + '/ticketData',
  48 + method: 'get',
  49 + params: { ticketId }
  50 + })
  51 +}
  52 +
  53 +/**
  54 + * 根据过磅码单与采购计划查询过磅品种下拉选项
  55 + * params: { ticketId(可选), planId }
  56 + */
  57 +export function assayApplyBreedOptionsApi(params) {
  58 + return request({
  59 + url: baseUrl + '/breedOptions',
  60 + method: 'get',
  61 + params
  62 + })
  63 +}
  64 +
  65 +/**
  66 + * 新增化验送样单
  67 + * data: { weighingTicketId, procurementPlanId, productId, department }
  68 + */
  69 +export function assayApplyCreateApi(data) {
  70 + return request({
  71 + url: baseUrl,
  72 + method: 'post',
  73 + data,
  74 + contentType: ContentTypeEnum.JSON
  75 + })
  76 +}
  77 +
  78 +/**
  79 + * 查询化验送样单详情
  80 + */
  81 +export function assayApplyDetailApi(params) {
  82 + return request({
  83 + url: baseUrl,
  84 + method: 'get',
  85 + params
  86 + })
  87 +}
  88 +
  89 +/**
  90 + * 修改化验送样单
  91 + * data: { id, weighingTicketId, procurementPlanId, productId, department }
  92 + */
  93 +export function assayApplyUpdateApi(data) {
  94 + return request({
  95 + url: baseUrl,
  96 + method: 'put',
  97 + data,
  98 + contentType: ContentTypeEnum.JSON
  99 + })
  100 +}
  101 +
  102 +/**
  103 + * 提交审核
  104 + */
  105 +export function assayApplySubmitApi(id) {
  106 + return request({
  107 + url: baseUrl + '/submit?id=' + id,
  108 + method: 'put'
  109 + })
  110 +}
  111 +
  112 +/**
  113 + * 取消化验送样单
  114 + */
  115 +export function assayApplyCancelApi(id) {
  116 + return request({
  117 + url: baseUrl + '/cancel?id=' + id,
  118 + method: 'put'
  119 + })
  120 +}
... ...
  1 +import request from '@/utils/request'
  2 +import { ContentTypeEnum } from '@/utils/httpEnum'
  3 +
  4 +// 原料化验报告单(对齐 PC 端 api/warehouse-manage/material-test)
  5 +const baseUrl = '/procurement/assay/report'
  6 +
  7 +/**
  8 + * 分页查询化验报告单列表
  9 + * params: pageIndex, pageSize, weighingTicketCode, reportDateStart, reportDateEnd,
  10 + * supplierName, workshopId, approvalStatus, flowNode, createBy,
  11 + * startTime, endTime
  12 + */
  13 +export function assayReportQueryApi(params) {
  14 + return request({
  15 + url: baseUrl + '/query',
  16 + method: 'get',
  17 + params
  18 + })
  19 +}
  20 +
  21 +/**
  22 + * 分页查询可选过磅码单列表(码单编号选择)
  23 + * params: pageIndex, pageSize, code, supplierName, workshopId
  24 + */
  25 +export function assayReportTicketPageApi(params) {
  26 + return request({
  27 + url: baseUrl + '/ticketPage',
  28 + method: 'get',
  29 + params
  30 + })
  31 +}
  32 +
  33 +/**
  34 + * 根据过磅码单ID查询码单数据(含计划编号下拉选项 planOptions)
  35 + */
  36 +export function assayReportPlanOptionsApi(ticketId) {
  37 + return request({
  38 + url: baseUrl + '/planOptions',
  39 + method: 'get',
  40 + params: { ticketId }
  41 + })
  42 +}
  43 +
  44 +/**
  45 + * 查询所选计划下的过磅品种下拉选项
  46 + * params: { ticketId(可选), planId }
  47 + */
  48 +export function assayReportProductOptionsApi(params) {
  49 + return request({
  50 + url: baseUrl + '/productOptions',
  51 + method: 'get',
  52 + params
  53 + })
  54 +}
  55 +
  56 +/**
  57 + * 查询化验明细(送样单)选项
  58 + * params: { ticketId(可选), planId(可选), productId(可选) }
  59 + */
  60 +export function assayReportApplyOptionsApi(params) {
  61 + return request({
  62 + url: baseUrl + '/applyOptions',
  63 + method: 'get',
  64 + params
  65 + })
  66 +}
  67 +
  68 +/**
  69 + * 新增化验报告单
  70 + * data: { weighingTicketId, reportDate, procurementPlanId, productId,
  71 + * lines: [{ assayApplyId, cu, zn, pb, fe, p, sn, ni, al, cd, cr6, hg, bi }] }
  72 + */
  73 +export function assayReportCreateApi(data) {
  74 + return request({
  75 + url: baseUrl,
  76 + method: 'post',
  77 + data,
  78 + contentType: ContentTypeEnum.JSON
  79 + })
  80 +}
  81 +
  82 +/**
  83 + * 查询化验报告单详情
  84 + */
  85 +export function assayReportDetailApi(params) {
  86 + return request({
  87 + url: baseUrl,
  88 + method: 'get',
  89 + params
  90 + })
  91 +}
  92 +
  93 +/**
  94 + * 修改化验报告单
  95 + * data: { id, weighingTicketId, reportDate, procurementPlanId, productId, lines }
  96 + */
  97 +export function assayReportUpdateApi(data) {
  98 + return request({
  99 + url: baseUrl,
  100 + method: 'put',
  101 + data,
  102 + contentType: ContentTypeEnum.JSON
  103 + })
  104 +}
  105 +
  106 +/**
  107 + * 提交化验报告单审核
  108 + */
  109 +export function assayReportSubmitAuditApi(id) {
  110 + return request({
  111 + url: baseUrl + '/submit?id=' + id,
  112 + method: 'put'
  113 + })
  114 +}
  115 +/**
  116 + * 提交
  117 + */
  118 +export function assayReportSubmitApproveApi(id) {
  119 + return request({
  120 + url: baseUrl + '/approve?id=' + id,
  121 + method: 'put'
  122 + })
  123 +}
  124 +/**
  125 + * 取消化验报告单
  126 + */
  127 +export function assayReportCancelApi(id) {
  128 + return request({
  129 + url: baseUrl + '/cancel?id=' + id,
  130 + method: 'put'
  131 + })
  132 +}
  133 +/**
  134 + * 作废化验报告单
  135 + */
  136 +export function assayReportInvalidApi(id) {
  137 + return request({
  138 + url: baseUrl + '/delete?id=' + id,
  139 + method: 'put'
  140 + })
  141 +}
  142 +
  143 +/**
  144 + * 修改意向(是否有质量问题、处理意见)
  145 + * data: { id, hasQualityProblem, processOpinion }
  146 + */
  147 +export function assayReportQualityApi(data) {
  148 + return request({
  149 + url: baseUrl + '/quality',
  150 + method: 'put',
  151 + data,
  152 + contentType: ContentTypeEnum.JSON
  153 + })
  154 +}
  155 +
  156 +/**
  157 + * 分厂下拉数据(PC: base-data/maker,即 baseData/workshop)
  158 + */
  159 +export function workshopQueryApi(params) {
  160 + return request({
  161 + url: '/baseData/workshop/query',
  162 + method: 'get',
  163 + params
  164 + })
  165 +}
... ...
  1 +import request from '@/utils/request'
  2 +import { ContentTypeEnum } from '@/utils/httpEnum'
  3 +
  4 +// 原料结算详情单(对齐 PC 端 api/warehouse-manage/material-settlement)
  5 +const baseUrl = '/procurement/material/settle'
  6 +
  7 +/**
  8 + * 分页查询原料结算详情单列表
  9 + * params: pageIndex, pageSize, weighingTicketCode, planCode, workshopId,
  10 + * flowNode, approvalStatus, ticketDateStart, ticketDateEnd, deleted(boolean)
  11 + */
  12 +export function materialSettleQueryApi(params) {
  13 + return request({
  14 + url: baseUrl + '/query',
  15 + method: 'get',
  16 + params
  17 + })
  18 +}
  19 +
  20 +/**
  21 + * 分页查询可选过磅码单列表(码单编号选择弹窗)
  22 + * params: pageIndex, pageSize, code, supplierName, workshopId
  23 + */
  24 +export function materialSettleTicketPageApi(params) {
  25 + return request({
  26 + url: baseUrl + '/ticketPage',
  27 + method: 'get',
  28 + params
  29 + })
  30 +}
  31 +
  32 +/**
  33 + * 根据过磅码单ID查询可选采购计划下拉选项
  34 + */
  35 +export function materialSettlePlanOptionsApi(params) {
  36 + return request({
  37 + url: baseUrl + '/planOptions',
  38 + method: 'get',
  39 + params
  40 + })
  41 +}
  42 +
  43 +/**
  44 + * 根据采购计划ID查询可选品种下拉选项
  45 + */
  46 +export function materialSettlePlanLineOptionsApi(params) {
  47 + return request({
  48 + url: baseUrl + '/planLineOptions',
  49 + method: 'get',
  50 + params
  51 + })
  52 +}
  53 +
  54 +/**
  55 + * 新增原料结算详情单
  56 + */
  57 +export function materialSettleCreateApi(data) {
  58 + return request({
  59 + url: baseUrl,
  60 + method: 'post',
  61 + data,
  62 + contentType: ContentTypeEnum.JSON
  63 + })
  64 +}
  65 +
  66 +/**
  67 + * 查询原料结算详情单详情
  68 + */
  69 +export function materialSettleDetailApi(params) {
  70 + return request({
  71 + url: baseUrl,
  72 + method: 'get',
  73 + params
  74 + })
  75 +}
  76 +
  77 +/**
  78 + * 修改原料结算详情单(提交结构与新增一致,额外携带主键)
  79 + */
  80 +export function materialSettleUpdateApi(data) {
  81 + return request({
  82 + url: baseUrl,
  83 + method: 'put',
  84 + data,
  85 + contentType: ContentTypeEnum.JSON
  86 + })
  87 +}
  88 +
  89 +/**
  90 + * 提交审核
  91 + */
  92 +export function materialSettleSubmitAuditApi(id) {
  93 + return request({
  94 + url: baseUrl + '/submit?id=' + id,
  95 + method: 'put'
  96 + })
  97 +}
  98 +
  99 +/**
  100 + * 退回(审核通过后退回草稿)
  101 + */
  102 +export function materialSettleReturnDraftApi(id) {
  103 + return request({
  104 + url: baseUrl + '/returnDraft?id=' + id,
  105 + method: 'put'
  106 + })
  107 +}
  108 +
  109 +/**
  110 + * 取消结算单
  111 + */
  112 +export function materialSettleCancelApi(id) {
  113 + return request({
  114 + url: baseUrl + '/cancel?id=' + id,
  115 + method: 'put'
  116 + })
  117 +}
  118 +
  119 +/**
  120 + * 品种(类别)下拉数据(PC: base-data/variety,即 baseData/product/variety)
  121 + */
  122 +export function productVarietyQueryApi(params) {
  123 + return request({
  124 + url: '/baseData/product/variety/query',
  125 + method: 'get',
  126 + params
  127 + })
  128 +}
... ...
  1 +import request from '@/utils/request'
  2 +import { ContentTypeEnum } from '@/utils/httpEnum'
  3 +
  4 +// 买断入库核算单(对齐 PC 端 api/warehouse-manage/outright-purchase)
  5 +const baseUrl = '/procurement/buyout/account'
  6 +
  7 +/**
  8 + * 分页查询买断入库核算单列表
  9 + * params: pageIndex, pageSize, weighingTicketCode, planCodes, incomingUnit,
  10 + * workshopId, flowNode, approvalStatus, startTime, endTime, deleted(boolean)
  11 + */
  12 +export function outrightPurchaseQueryApi(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 outrightPurchaseSettleOptionsApi(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 outrightPurchaseSettleDataApi(params) {
  37 + return request({
  38 + url: baseUrl + '/settleData',
  39 + method: 'get',
  40 + params
  41 + })
  42 +}
  43 +
  44 +/**
  45 + * 新增买断入库核算单
  46 + */
  47 +export function outrightPurchaseCreateApi(data) {
  48 + return request({
  49 + url: baseUrl,
  50 + method: 'post',
  51 + data,
  52 + contentType: ContentTypeEnum.JSON
  53 + })
  54 +}
  55 +
  56 +/**
  57 + * 修改买断入库核算单
  58 + */
  59 +export function outrightPurchaseUpdateApi(data) {
  60 + return request({
  61 + url: baseUrl,
  62 + method: 'put',
  63 + data,
  64 + contentType: ContentTypeEnum.JSON
  65 + })
  66 +}
  67 +
  68 +/**
  69 + * 提交审核
  70 + */
  71 +export function outrightPurchaseSubmitAuditApi(id) {
  72 + return request({
  73 + url: baseUrl + '/submit?id=' + id,
  74 + method: 'put'
  75 + })
  76 +}
  77 +
  78 +/**
  79 + * 取消核算单
  80 + */
  81 +export function outrightPurchaseCancelApi(id) {
  82 + return request({
  83 + url: baseUrl + '/cancel?id=' + id,
  84 + method: 'put'
  85 + })
  86 +}
  87 +
  88 +/**
  89 + * 查询买断入库核算单详情
  90 + * params: { id }
  91 + */
  92 +export function outrightPurchaseDetailApi(params) {
  93 + return request({
  94 + url: baseUrl,
  95 + method: 'get',
  96 + params
  97 + })
  98 +}
... ...
... ... @@ -156,6 +156,15 @@ export function procurementPlanStopApi(id) {
156 156 })
157 157 }
158 158
  159 +export function procurementPlanDiffQuantityExceededApi(data) {
  160 + return request({
  161 + url: '/procurement/plan/diffQuantityExceeded',
  162 + method: 'put',
  163 + data,
  164 + contentType: ContentTypeEnum.JSON
  165 + })
  166 +}
  167 +
159 168 export function procurementPlanChangeSubmitApi(id) {
160 169 return request({
161 170 url: '/procurement/plan/change/submit?id=' + id,
... ...
  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 +}
... ...
  1 +import request from '@/utils/request'
  2 +import { ContentTypeEnum } from '@/utils/httpEnum'
  3 +
  4 +// 过磅码单(对齐 PC 端 api/warehouse-manage/weight-ticket)
  5 +const baseUrl = '/procurement/weighing/ticket'
  6 +
  7 +/**
  8 + * 分页查询过磅单列表
  9 + * params: pageIndex, pageSize, code, planCode, supplierName, companyShortId,
  10 + * approvalStatus, createBy, startTime, endTime, deleted(boolean)
  11 + */
  12 +export function weighTicketQueryApi(params) {
  13 + return request({
  14 + url: baseUrl + '/query',
  15 + method: 'get',
  16 + params
  17 + })
  18 +}
  19 +
  20 +/**
  21 + * 生成过磅单编号(直接返回编号字符串)
  22 + */
  23 +export function weighTicketGenerateCodeApi() {
  24 + return request({
  25 + url: baseUrl + '/generateCode',
  26 + method: 'get'
  27 + })
  28 +}
  29 +
  30 +/**
  31 + * 查询过磅单可选计划列表
  32 + * params: pageIndex, pageSize, code(计划编号), companyName(收料单位)
  33 + */
  34 +export function weighingTicketPlansApi(params) {
  35 + return request({
  36 + url: baseUrl + '/weighingTicketPlans',
  37 + method: 'get',
  38 + params
  39 + })
  40 +}
  41 +
  42 +/**
  43 + * 根据计划id集合查询计划明细行
  44 + * ids: 计划id数组
  45 + */
  46 +export function weighTicketPlanLinesApi(ids) {
  47 + return request({
  48 + url: baseUrl + '/planLines',
  49 + method: 'get',
  50 + params: { ids: (ids || []).join(',') }
  51 + })
  52 +}
  53 +
  54 +/**
  55 + * 查询过磅单详情
  56 + */
  57 +export function weighTicketDetailApi(params) {
  58 + return request({
  59 + url: baseUrl,
  60 + method: 'get',
  61 + params
  62 + })
  63 +}
  64 +
  65 +/**
  66 + * 提交审核
  67 + */
  68 +export function weighTicketSubmitAuditApi(id) {
  69 + return request({
  70 + url: baseUrl + '/submit?id=' + id,
  71 + method: 'put'
  72 + })
  73 +}
  74 +
  75 +/**
  76 + * 作废过磅单
  77 + */
  78 +export function weighTicketCancelApi(id) {
  79 + return request({
  80 + url: baseUrl + '/delete?id=' + id,
  81 + method: 'put'
  82 + })
  83 +}
  84 +
  85 +/**
  86 + * 新增过磅单
  87 + */
  88 +export function weighTicketCreateApi(data) {
  89 + return request({
  90 + url: baseUrl + '/create',
  91 + method: 'post',
  92 + data,
  93 + contentType: ContentTypeEnum.JSON
  94 + })
  95 +}
  96 +
  97 +/**
  98 + * 修改过磅单
  99 + */
  100 +export function weighTicketUpdateApi(data) {
  101 + return request({
  102 + url: baseUrl,
  103 + method: 'put',
  104 + data,
  105 + contentType: ContentTypeEnum.JSON
  106 + })
  107 +}
  108 +
  109 +/**
  110 + * 上传签字凭证
  111 + * data: { id, fileIds(逗号分隔), fileNames(逗号分隔) }
  112 + */
  113 +export function weighTicketUploadSignApi(data) {
  114 + return request({
  115 + url: baseUrl + '/attachment/sign',
  116 + method: 'put',
  117 + data,
  118 + contentType: ContentTypeEnum.JSON
  119 + })
  120 +}
  121 +
  122 +/**
  123 + * 上传延期说明附件
  124 + * data: { id, fileIds(逗号分隔), fileNames(逗号分隔) }
  125 + */
  126 +export function weighTicketUploadDelayApi(data) {
  127 + return request({
  128 + url: baseUrl + '/attachment/delay',
  129 + method: 'put',
  130 + data,
  131 + contentType: ContentTypeEnum.JSON
  132 + })
  133 +}
  134 +
  135 +/**
  136 + * 公司简称下拉数据(PC: base-data/short-name)
  137 + */
  138 +export function companyShortQueryApi(params) {
  139 + return request({
  140 + url: '/basedata/company/short/query',
  141 + method: 'get',
  142 + params
  143 + })
  144 +}
... ...
... ... @@ -4,8 +4,8 @@ module.exports = {
4 4 themeColor: '#3d48a3',
5 5
6 6 // baseUrl: 'http://ft.wecando21cn.com/api',
7   - baseUrl: 'http://gjtd.ahcjxc.com:81/api',
8   - // baseUrl: 'http://erp.qgutech.com/api',
  7 + // baseUrl: 'http://gjtd.ahcjxc.com:81/api',
  8 + baseUrl: 'http://erp.qgutech.com/api',
9 9 // baseUrl: 'http://10.9.5.246:8081',
10 10 // 应用信息
11 11 appInfo: {
... ...
... ... @@ -541,6 +541,222 @@
541 541 }
542 542 },
543 543 {
  544 + "path": "pages/weight-ticket/index",
  545 + "style": {
  546 + "navigationBarTitleText": "过磅码单",
  547 + "navigationBarBackgroundColor": "#ffffff",
  548 + "navigationBarTextStyle": "black"
  549 + }
  550 + },
  551 + {
  552 + "path": "pages/weight-ticket/add",
  553 + "style": {
  554 + "navigationBarTitleText": "新增过磅码单",
  555 + "navigationBarBackgroundColor": "#ffffff",
  556 + "navigationBarTextStyle": "black"
  557 + }
  558 + },
  559 + {
  560 + "path": "pages/weight-ticket/detail",
  561 + "style": {
  562 + "navigationBarTitleText": "过磅码单详情",
  563 + "navigationBarBackgroundColor": "#ffffff",
  564 + "navigationBarTextStyle": "black"
  565 + }
  566 + },
  567 + {
  568 + "path": "pages/weight-ticket/modify",
  569 + "style": {
  570 + "navigationBarTitleText": "编辑过磅码单",
  571 + "navigationBarBackgroundColor": "#ffffff",
  572 + "navigationBarTextStyle": "black"
  573 + }
  574 + },
  575 + {
  576 + "path": "pages/weight-ticket/upload",
  577 + "style": {
  578 + "navigationBarTitleText": "上传附件",
  579 + "navigationBarBackgroundColor": "#ffffff",
  580 + "navigationBarTextStyle": "black"
  581 + }
  582 + },
  583 + {
  584 + "path": "pages/weight-ticket/reweigh",
  585 + "style": {
  586 + "navigationBarTitleText": "复磅",
  587 + "navigationBarBackgroundColor": "#ffffff",
  588 + "navigationBarTextStyle": "black"
  589 + }
  590 + },
  591 + {
  592 + "path": "pages/sample-submission/index",
  593 + "style": {
  594 + "navigationBarTitleText": "化验送样单",
  595 + "navigationBarBackgroundColor": "#ffffff",
  596 + "navigationBarTextStyle": "black"
  597 + }
  598 + },
  599 + {
  600 + "path": "pages/sample-submission/add",
  601 + "style": {
  602 + "navigationBarTitleText": "新增化验送样单",
  603 + "navigationBarBackgroundColor": "#ffffff",
  604 + "navigationBarTextStyle": "black"
  605 + }
  606 + },
  607 + {
  608 + "path": "pages/sample-submission/detail",
  609 + "style": {
  610 + "navigationBarTitleText": "化验送样单详情",
  611 + "navigationBarBackgroundColor": "#ffffff",
  612 + "navigationBarTextStyle": "black"
  613 + }
  614 + },
  615 + {
  616 + "path": "pages/sample-submission/modify",
  617 + "style": {
  618 + "navigationBarTitleText": "编辑化验送样单",
  619 + "navigationBarBackgroundColor": "#ffffff",
  620 + "navigationBarTextStyle": "black"
  621 + }
  622 + },
  623 + {
  624 + "path": "pages/material-test/index",
  625 + "style": {
  626 + "navigationBarTitleText": "原料化验报告单",
  627 + "navigationBarBackgroundColor": "#ffffff",
  628 + "navigationBarTextStyle": "black"
  629 + }
  630 + },
  631 + {
  632 + "path": "pages/material-test/add",
  633 + "style": {
  634 + "navigationBarTitleText": "新增原料化验报告单",
  635 + "navigationBarBackgroundColor": "#ffffff",
  636 + "navigationBarTextStyle": "black"
  637 + }
  638 + },
  639 + {
  640 + "path": "pages/material-test/detail",
  641 + "style": {
  642 + "navigationBarTitleText": "原料化验报告单详情",
  643 + "navigationBarBackgroundColor": "#ffffff",
  644 + "navigationBarTextStyle": "black"
  645 + }
  646 + },
  647 + {
  648 + "path": "pages/material-test/modify",
  649 + "style": {
  650 + "navigationBarTitleText": "编辑原料化验报告单",
  651 + "navigationBarBackgroundColor": "#ffffff",
  652 + "navigationBarTextStyle": "black"
  653 + }
  654 + },
  655 + {
  656 + "path": "pages/material-test/quality",
  657 + "style": {
  658 + "navigationBarTitleText": "修改意向",
  659 + "navigationBarBackgroundColor": "#ffffff",
  660 + "navigationBarTextStyle": "black"
  661 + }
  662 + },
  663 + {
  664 + "path": "pages/material-settlement/index",
  665 + "style": {
  666 + "navigationBarTitleText": "原料结算详情单",
  667 + "navigationBarBackgroundColor": "#ffffff",
  668 + "navigationBarTextStyle": "black"
  669 + }
  670 + },
  671 + {
  672 + "path": "pages/material-settlement/add",
  673 + "style": {
  674 + "navigationBarTitleText": "新增原料结算详情单",
  675 + "navigationBarBackgroundColor": "#ffffff",
  676 + "navigationBarTextStyle": "black"
  677 + }
  678 + },
  679 + {
  680 + "path": "pages/material-settlement/detail",
  681 + "style": {
  682 + "navigationBarTitleText": "原料结算详情单详情",
  683 + "navigationBarBackgroundColor": "#ffffff",
  684 + "navigationBarTextStyle": "black"
  685 + }
  686 + },
  687 + {
  688 + "path": "pages/material-settlement/modify",
  689 + "style": {
  690 + "navigationBarTitleText": "编辑原料结算详情单",
  691 + "navigationBarBackgroundColor": "#ffffff",
  692 + "navigationBarTextStyle": "black"
  693 + }
  694 + },
  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 + {
  728 + "path": "pages/outright-purchase/index",
  729 + "style": {
  730 + "navigationBarTitleText": "买断入库核算单",
  731 + "navigationBarBackgroundColor": "#ffffff",
  732 + "navigationBarTextStyle": "black"
  733 + }
  734 + },
  735 + {
  736 + "path": "pages/outright-purchase/add",
  737 + "style": {
  738 + "navigationBarTitleText": "新增买断入库核算单",
  739 + "navigationBarBackgroundColor": "#ffffff",
  740 + "navigationBarTextStyle": "black"
  741 + }
  742 + },
  743 + {
  744 + "path": "pages/outright-purchase/detail",
  745 + "style": {
  746 + "navigationBarTitleText": "买断入库核算单详情",
  747 + "navigationBarBackgroundColor": "#ffffff",
  748 + "navigationBarTextStyle": "black"
  749 + }
  750 + },
  751 + {
  752 + "path": "pages/outright-purchase/modify",
  753 + "style": {
  754 + "navigationBarTitleText": "编辑买断入库核算单",
  755 + "navigationBarBackgroundColor": "#ffffff",
  756 + "navigationBarTextStyle": "black"
  757 + }
  758 + },
  759 + {
544 760 "path": "pages/order_list/index",
545 761 "style": {
546 762 "navigationBarTitleText": "订货单列表",
... ...
... ... @@ -83,7 +83,7 @@
83 83 <script>
84 84 import DetailButtons from '@/components/detail-buttons/index.vue'
85 85 import ProductRel from './productRel.vue'
86   -import { procurementPlanDetailApi, procurementPlanGenerateContractApi, procurementPlanSubmitAuditApi, procurementPlanSubmitApi, procurementPlanStopApi } from '@/api/procure-manage/procurementPlan.js'
  86 +import { procurementPlanDetailApi, procurementPlanGenerateContractApi, procurementPlanSubmitAuditApi, procurementPlanSubmitApi, procurementPlanStopApi, procurementPlanDiffQuantityExceededApi } from '@/api/procure-manage/procurementPlan.js'
87 87 import { buyoutApplyCreateApi, buyoutApplyAbolishApi, buyoutApplyDeleteByPlanIdApi } from '@/api/procure-manage/buyout.js'
88 88 import { getDicByCodes, getDicName } from '@/utils/dic.js'
89 89 import { getInfo } from '@/api/login.js'
... ... @@ -142,6 +142,7 @@ export default {
142 142 { text: '生成买断操作申请单', variant: 'outline', event: 'generate' },
143 143 { text: '废除买断操作申请单', variant: 'danger', event: 'cancel' },
144 144 { text: '查看买断操作申请单', variant: 'outline', event: 'look' },
  145 + { text: '更改差值状态', variant: 'outline', event: 'change' },
145 146 // { text: '上传附件', variant: 'primary', event: 'upload' }
146 147 ]
147 148 }
... ... @@ -188,6 +189,7 @@ export default {
188 189 var ps = String(f.processStatus != null ? f.processStatus : '')
189 190 var aStatus = String(f.approvalStatus != null ? f.approvalStatus : '')
190 191 var SC = this.PROCESS_STATUS_CODE
  192 + const diffQuantityExceeded = this.form?.diffQuantityExceeded;
191 193 var inStatus = function (codes) { return codes.indexOf(ps) >= 0 }
192 194 console.log(SC,inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED, SC.REFUSE]),'SC')
193 195 var perms = {
... ... @@ -203,6 +205,7 @@ export default {
203 205 generate: this.hasPerm('plan-manage:domestic-plan:generate'),
204 206 cancel: this.hasPerm('plan-manage:domestic-plan:cancel'),
205 207 look: this.hasPerm('plan-manage:domestic-plan:look'),
  208 + change: this.hasPerm('plan-manage:domestic-plan:change'),
206 209 // upload: this.hasPerm('plan-manage:domestic-plan:upload')
207 210 }
208 211 var visibleMap = {
... ... @@ -218,7 +221,8 @@ export default {
218 221 generate: !!f.showGenerateBuyoutApply && inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED]) && perms.generate,
219 222 cancel: !!f.showAbolishBuyoutApply && inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED]) && perms.cancel,
220 223 look: inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED, SC.REFUSE, SC.ABORTED]) && perms.look,
221   - // uploadAttachment: inStatus([SC.COMPLETED]) && !!this.planRoleFlags.isPlanner && perms.uploadAttachment
  224 + change: inStatus(diffQuantityExceeded) && perms.change,
  225 + // // uploadAttachment: inStatus([SC.COMPLETED]) && !!this.planRoleFlags.isPlanner && perms.uploadAttachment
222 226 }
223 227 var out = []
224 228 for (var i = 0; i < this.buttonTemplates.length; i++) {
... ... @@ -434,6 +438,7 @@ export default {
434 438 if (e === 'cancel') return this.onAbolishBuyoutApply()
435 439 if (e === 'look') return this.onViewBuyoutApply()
436 440 if (e === 'uploadAttachment') return this.onUploadAttachment()
  441 + if (e === 'change') return this.onChangeDiffQuantityExceeded()
437 442 },
438 443
439 444 onView() {
... ... @@ -525,6 +530,16 @@ export default {
525 530 }
526 531 uni.navigateTo({ url: '/pages/domestic-plan/selectWorkshop?id=' + id })
527 532 },
  533 + onChangeDiffQuantityExceeded() {
  534 + this.runWithConfirm({
  535 + title: '更改差值状态',
  536 + content: '确定更改差值状态吗?',
  537 + loading: '处理中',
  538 + successText: '更改成功',
  539 + failText: '更改差值状态失败',
  540 + run: function (id) { return procurementPlanDiffQuantityExceededApi({ id: id, diffQuantityExceeded: false }) }
  541 + })
  542 + },
528 543 onSubmitSplit() {
529 544 this.runWithConfirm({
530 545 title: '提交',
... ...
... ... @@ -8,7 +8,7 @@
8 8 </view>
9 9 <view class="body">
10 10 <view v-if="tab === 'base'">
11   - <component :is="componentName" :id="auditCtx.businessId" ref="basicRef" />
  11 + <component :is="componentName" :id="auditCtx.businessId" :node-code="nodeCode" ref="basicRef" />
12 12 </view>
13 13 <view v-else>
14 14 <FlowTimeline :nodeList="nodeList" :isEnd="isEnd" />
... ... @@ -144,6 +144,8 @@ export default {
144 144 data() {
145 145 return {
146 146 tab: 'base',
  147 + // 当前审核节点编码(flow/instance/getByBusinessId 返回,透传给业务审批组件自行处理)
  148 + nodeCode: '',
147 149 auditCtx: {
148 150 taskId: '',
149 151 instanceId: '',
... ... @@ -256,6 +258,8 @@ export default {
256 258 // 2.在映射的地方,如果审核和审批详情不一样 就映射成两一个组件
257 259 const _data = res && res.data ? res.data : {};
258 260 const _ext = JSON.parse(_data.ext || '{}');
  261 + // 审核节点编码(如 assay_report_gyglkzg2 时需填写是否继续审批)
  262 + this.nodeCode = _data.nodeCode || ''
259 263 this.auditCtx = {
260 264 taskId: _data.taskId || '',
261 265 instanceId: _data.id || '',
... ...
... ... @@ -203,6 +203,42 @@ export default {
203 203 icon: '/static/images/index/draft_order.png',
204 204 link: '/pages/domestic-agreement/index',
205 205 name: 'DomesticAgreement'
  206 + },
  207 + {
  208 + text: '过磅码单',
  209 + icon: '/static/images/index/contract_foreign_unplan.png',
  210 + link: '/pages/weight-ticket/index',
  211 + name: 'WeightTicket'
  212 + },
  213 + {
  214 + text: '化验送样单',
  215 + icon: '/static/images/index/contract_unlocked_operation.png',
  216 + link: '/pages/sample-submission/index',
  217 + name: 'SampleSubmission'
  218 + },
  219 + {
  220 + text: '原料化验报告单',
  221 + icon: '/static/images/index/contract_retail.png',
  222 + link: '/pages/material-test/index',
  223 + name: 'MaterialTest'
  224 + },
  225 + {
  226 + text: '原料结算详情单',
  227 + icon: '/static/images/index/dev_manage.png',
  228 + link: '/pages/material-settlement/index',
  229 + name: 'MaterialSettlement'
  230 + },
  231 + {
  232 + text: '仓库收料单',
  233 + icon: '/static/images/index/credit_manage.png',
  234 + link: '/pages/warehouse-material/index',
  235 + name: 'WarehouseMaterial'
  236 + },
  237 + {
  238 + text: '买断入库核算单',
  239 + icon: '/static/images/index/draft_order.png',
  240 + link: '/pages/outright-purchase/index',
  241 + name: 'OutrightPurchase'
206 242 }
207 243 ]
208 244 },
... ...
  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.weighingTicketId ? 'is-filled' : 'is-empty'" clickable
  7 + @click="openTicketSheet" :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="ticketDateText" :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.code" :inputBorder="false" disabled placeholder="选择码单后自动带出" />
  20 + </template>
  21 + </uni-list-item>
  22 + <uni-list-item title="单位">
  23 + <template v-slot:footer>
  24 + <uni-easyinput v-model="form.supplierName" :inputBorder="false" disabled placeholder="选择码单后自动带出" />
  25 + </template>
  26 + </uni-list-item>
  27 + <uni-list-item title="分厂">
  28 + <template v-slot:footer>
  29 + <uni-easyinput v-model="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="!applyList.length" class="empty-tip">选择码单后自动带出</view>
  42 + <view v-for="(item, idx) in applyList" :key="'a-' + (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.quantity" :inputBorder="false" disabled />
  52 + </template>
  53 + </uni-list-item>
  54 + </uni-list>
  55 + </view>
  56 + </view>
  57 + </view>
  58 +
  59 + <!-- 详情明细(可编辑) -->
  60 + <view class="sub-table">
  61 + <view class="header">
  62 + <image class="opCollapse" src="/static/images/title.png" />
  63 + <text class="title">详情明细</text>
  64 + <view class="ops">
  65 + <image class="opAdd" @click="addRow" src="/static/images/plus.png" />
  66 + </view>
  67 + </view>
  68 + <view class="add-list">
  69 + <view v-if="!detailList.length" class="empty-tip">选择码单后自动带出,也可新增行</view>
  70 + <view v-for="(item, idx) in detailList" :key="'d-' + (item.rowId || idx)" class="block">
  71 + <uni-list>
  72 + <!-- 计划编号:插入行选择,码单带出行只读 -->
  73 + <uni-list-item v-if="!item.brought" class="select-item" :class="item.planCode ? 'is-filled' : 'is-empty'">
  74 + <template v-slot:body>
  75 + <view class="item-title"><text class="required">*</text><text>计划编号</text></view>
  76 + </template>
  77 + <template v-slot:footer>
  78 + <picker mode="selector" :range="planCodeLabels"
  79 + @change="(e) => handlePlanChange(idx, Number(e.detail.value))">
  80 + <view class="picker-value" :class="{ placeholder: !item.planCode }">
  81 + {{ item.planCode || '请选择计划编号' }}
  82 + </view>
  83 + </picker>
  84 + </template>
  85 + </uni-list-item>
  86 + <uni-list-item v-else title="计划编号">
  87 + <template v-slot:footer>
  88 + <uni-easyinput :value="item.planCode" :inputBorder="false" disabled />
  89 + </template>
  90 + </uni-list-item>
  91 +
  92 + <!-- 品种:插入行选择计划后可选,码单带出行只读 -->
  93 + <uni-list-item v-if="!item.brought" class="select-item" :class="item.productId ? 'is-filled' : 'is-empty'">
  94 + <template v-slot:body>
  95 + <view class="item-title"><text>品种</text></view>
  96 + </template>
  97 + <template v-slot:footer>
  98 + <picker mode="selector" :range="getProductLabels(item)" :disabled="!item.procurementPlanId"
  99 + @change="(e) => handleProductChange(idx, Number(e.detail.value))">
  100 + <view class="picker-value" :class="{ placeholder: !item.productName }">
  101 + {{ item.productName || (item.procurementPlanId ? '请选择品种' : '请先选择计划编号') }}
  102 + </view>
  103 + </picker>
  104 + </template>
  105 + </uni-list-item>
  106 + <uni-list-item v-else title="品种">
  107 + <template v-slot:footer>
  108 + <uni-easyinput :value="item.productName" :inputBorder="false" disabled />
  109 + </template>
  110 + </uni-list-item>
  111 +
  112 + <!-- 类别:插入行未选品种时不可选,其余可选 -->
  113 + <uni-list-item class="select-item" :class="item.category ? 'is-filled' : 'is-empty'">
  114 + <template v-slot:body>
  115 + <view class="item-title"><text>类别</text></view>
  116 + </template>
  117 + <template v-slot:footer>
  118 + <picker v-if="item.brought || item.productId" mode="selector" :range="varietyLabels"
  119 + @change="(e) => handleVarietyChange(idx, Number(e.detail.value))">
  120 + <view class="picker-value" :class="{ placeholder: !item.category }">
  121 + {{ item.category || '请选择类别' }}
  122 + </view>
  123 + </picker>
  124 + <uni-easyinput v-else :value="item.category" :inputBorder="false" disabled placeholder="请先选择品种" />
  125 + </template>
  126 + </uni-list-item>
  127 +
  128 + <!-- 名称:码单带出行/已选品种只读 -->
  129 + <uni-list-item title="名称">
  130 + <template v-slot:footer>
  131 + <uni-easyinput v-if="!item.brought && !item.productId" v-model="item.name" :inputBorder="false" placeholder="请输入名称" />
  132 + <uni-easyinput v-else :value="item.name" :inputBorder="false" disabled />
  133 + </template>
  134 + </uni-list-item>
  135 +
  136 + <uni-list-item title="过磅数">
  137 + <template v-slot:footer>
  138 + <uni-easyinput :value="item.weighQuantity" :inputBorder="false" disabled />
  139 + </template>
  140 + </uni-list-item>
  141 + <uni-list-item title="杂率(%)">
  142 + <template v-slot:footer>
  143 + <uni-easyinput v-model="item.impurityRate" type="digit" :inputBorder="false" placeholder="请输入杂率" />
  144 + </template>
  145 + </uni-list-item>
  146 + <uni-list-item title="折斤">
  147 + <template v-slot:footer>
  148 + <uni-easyinput v-model="item.foldWeight" type="digit" :inputBorder="false" placeholder="请输入折斤" />
  149 + </template>
  150 + </uni-list-item>
  151 + <uni-list-item title="退料">
  152 + <template v-slot:footer>
  153 + <uni-easyinput v-model="item.returnWeight" type="digit" :inputBorder="false" placeholder="请输入退料" />
  154 + </template>
  155 + </uni-list-item>
  156 + <uni-list-item title="入库净重">
  157 + <template v-slot:footer>
  158 + <uni-easyinput v-model="item.netWeight" type="digit" :inputBorder="false" placeholder="请输入入库净重" />
  159 + </template>
  160 + </uni-list-item>
  161 + <uni-list-item title="备注">
  162 + <template v-slot:footer>
  163 + <uni-easyinput v-model="item.remark" :inputBorder="false" placeholder="请输入备注" />
  164 + </template>
  165 + </uni-list-item>
  166 + </uni-list>
  167 + <view class="block-ops">
  168 + <div class="toggle" @click="insertRow(idx)">
  169 + <image src="/static/images/plus.png" class="icon" />插入
  170 + </div>
  171 + <div v-if="!item.brought" class="del" @click="delRow(idx)">
  172 + <image src="/static/images/delete.png" class="icon" />删除
  173 + </div>
  174 + </view>
  175 + </view>
  176 + </view>
  177 + </view>
  178 +
  179 + <!-- 合计 -->
  180 + <view class="total-card">
  181 + <view class="total-title">合计</view>
  182 + <view class="total-body">
  183 + <view class="total-item">
  184 + <text class="total-label">过磅数</text>
  185 + <text class="total-value">{{ totalSummary.totalWeighQuantity || '-' }}</text>
  186 + </view>
  187 + <view class="total-item">
  188 + <text class="total-label">折斤</text>
  189 + <text class="total-value">{{ totalSummary.totalFoldWeight || '-' }}</text>
  190 + </view>
  191 + <view class="total-item">
  192 + <text class="total-label">退料</text>
  193 + <text class="total-value">{{ totalSummary.totalReturnWeight || '-' }}</text>
  194 + </view>
  195 + <view class="total-item">
  196 + <text class="total-label">入库净重</text>
  197 + <text class="total-value">{{ totalSummary.totalNetWeight || '-' }}</text>
  198 + </view>
  199 + </view>
  200 + </view>
  201 +
  202 + <!-- 其他信息 -->
  203 + <view class="remark-section">
  204 + <view class="header">
  205 + <image class="opCollapse" src="/static/images/title.png" />
  206 + <text class="title">其他信息</text>
  207 + </view>
  208 + <view class="section-content">
  209 + <uni-list>
  210 + <uni-list-item class="select-item" :class="form.settleType ? 'is-filled' : 'is-empty'">
  211 + <template v-slot:body>
  212 + <view class="item-title"><text class="required">*</text><text>类型</text></view>
  213 + </template>
  214 + <template v-slot:footer>
  215 + <picker mode="selector" :range="settleTypeLabels" @change="onSettleTypeChange">
  216 + <view class="picker-value" :class="{ placeholder: !form.settleType }">
  217 + {{ settleTypeName || '请选择类型' }}
  218 + </view>
  219 + </picker>
  220 + </template>
  221 + </uni-list-item>
  222 + </uni-list>
  223 + <view class="remark-group">
  224 + <view class="remark-label">备注</view>
  225 + <uni-easyinput v-model="form.remark" type="textarea" :inputBorder="false" placeholder="请输入备注" maxlength="2000" autoHeight />
  226 + </view>
  227 + </view>
  228 + </view>
  229 +
  230 + <view class="footer">
  231 + <button class="btn submit" type="primary" @click="onSubmit">保存</button>
  232 + </view>
  233 + </scroll-view>
  234 +
  235 + <RelateSelectSheet :visible.sync="ticketSheet.visible" title="选择码单" :multiple="false"
  236 + :fetchFn="ticketSheet.fetchFn" :display-fields="ticketSheet.displayFields"
  237 + row-key="id" :selectedKeys.sync="ticketSheet.selectedKeys" @confirm="onTicketConfirm" />
  238 + </view>
  239 +</template>
  240 +
  241 +<script>
  242 +import RelateSelectSheet from '@/components/relate-select/index.vue'
  243 +import {
  244 + materialSettleTicketPageApi,
  245 + materialSettlePlanOptionsApi,
  246 + materialSettlePlanLineOptionsApi,
  247 + materialSettleCreateApi,
  248 + productVarietyQueryApi
  249 +} from '@/api/procure-manage/materialSettlement.js'
  250 +import { getDicByCodes } from '@/utils/dic.js'
  251 +
  252 +export default {
  253 + name: 'AddMaterialSettlement',
  254 + components: { RelateSelectSheet },
  255 + data() {
  256 + return {
  257 + form: {
  258 + weighingTicketId: '',
  259 + weighingTicketCode: '',
  260 + completeTime: '',
  261 + code: '',
  262 + supplierName: '',
  263 + workshopName: '',
  264 + settleType: '',
  265 + remark: ''
  266 + },
  267 + dicOptions: { SETTLE_TYPE: [] },
  268 + // 选中的码单行
  269 + selectedTicketRow: null,
  270 + // 申请净重明细(只读)
  271 + applyList: [],
  272 + // 详情明细(可编辑)
  273 + detailList: [],
  274 + // 计划编号下拉选项(当前码单可选计划)
  275 + planOptions: [],
  276 + // 品种(类别)下拉选项
  277 + varietyOptions: [],
  278 + ticketSheet: {
  279 + visible: false,
  280 + fetchFn: null,
  281 + displayFields: [
  282 + { label: '码单编号', field: 'code' },
  283 + { label: '供应商', field: 'supplierName' },
  284 + { label: '分厂', field: 'workshopName' },
  285 + { label: '创建人', field: 'createBy' },
  286 + { label: '完成时间', field: 'completeTime' }
  287 + ],
  288 + selectedKeys: []
  289 + }
  290 + }
  291 + },
  292 + computed: {
  293 + settleTypeLabels() {
  294 + return (this.dicOptions.SETTLE_TYPE || []).map(it => it.name)
  295 + },
  296 + settleTypeName() {
  297 + const found = (this.dicOptions.SETTLE_TYPE || []).find(it => String(it.code) === String(this.form.settleType))
  298 + return found ? found.name : ''
  299 + },
  300 + ticketDateText() {
  301 + const s = this.form.completeTime == null ? '' : String(this.form.completeTime)
  302 + return s ? s.slice(0, 10) : ''
  303 + },
  304 + planCodeLabels() {
  305 + return this.planOptions.map(o => o.label)
  306 + },
  307 + varietyLabels() {
  308 + return (this.varietyOptions || []).map(item =>
  309 + [item.productName, item.code].filter(Boolean).join(' ')
  310 + )
  311 + },
  312 + // 详情明细各数值列合计(过磅数/折斤/入库净重保留两位小数,退料取整)
  313 + totalSummary() {
  314 + const list = this.detailList || []
  315 + const sum = (field, fixed) => Number(
  316 + list.reduce((acc, row) => acc + Number(row[field] || 0), 0).toFixed(fixed)
  317 + )
  318 + return {
  319 + totalWeighQuantity: sum('weighQuantity', 2),
  320 + totalFoldWeight: sum('foldWeight', 2),
  321 + totalReturnWeight: sum('returnWeight', 0),
  322 + totalNetWeight: sum('netWeight', 2)
  323 + }
  324 + }
  325 + },
  326 + created() {
  327 + this.ticketSheet.fetchFn = this.fetchTickets.bind(this)
  328 + this.loadDicData()
  329 + this.loadVarietyOptions()
  330 + },
  331 + methods: {
  332 + async loadDicData() {
  333 + try {
  334 + const results = await getDicByCodes(['SETTLE_TYPE'])
  335 + this.dicOptions.SETTLE_TYPE = (results.SETTLE_TYPE && results.SETTLE_TYPE.data) || []
  336 + } catch (e) {
  337 + this.dicOptions = { SETTLE_TYPE: [] }
  338 + }
  339 + },
  340 + async loadVarietyOptions() {
  341 + try {
  342 + const res = await productVarietyQueryApi({ pageIndex: 1, pageSize: 9999 })
  343 + const _data = (res && res.data) || {}
  344 + this.varietyOptions = _data.datas || _data.list || _data.records || []
  345 + } catch (e) {
  346 + this.varietyOptions = []
  347 + }
  348 + },
  349 + onSettleTypeChange(e) {
  350 + const idx = Number(e.detail.value)
  351 + const opt = (this.dicOptions.SETTLE_TYPE || [])[idx]
  352 + this.form.settleType = opt && opt.code != null ? String(opt.code) : ''
  353 + },
  354 + // 码单选择弹窗数据源
  355 + fetchTickets({ pageIndex, pageSize, extra }) {
  356 + const keyword = (extra && extra.keyword) || ''
  357 + const params = {
  358 + pageIndex,
  359 + pageSize,
  360 + code: keyword || undefined
  361 + }
  362 + return materialSettleTicketPageApi(params).then(res => {
  363 + const _data = (res && res.data) || {}
  364 + const records = _data.datas || _data.list || _data.records || []
  365 + const totalCount = _data.totalCount || _data.count || 0
  366 + const hasNext = _data.hasNext || false
  367 + return { records, totalCount, hasNext }
  368 + }).catch(() => ({ records: [], totalCount: 0, hasNext: false }))
  369 + },
  370 + openTicketSheet() {
  371 + this.ticketSheet.selectedKeys = this.selectedTicketRow ? [this.selectedTicketRow.id] : []
  372 + this.ticketSheet.visible = true
  373 + },
  374 + // 码单选择回调:由所选码单行带出主表信息与明细数据
  375 + onTicketConfirm({ items }) {
  376 + const row = (items || [])[0]
  377 + if (!row) return
  378 + if (this.selectedTicketRow && this.selectedTicketRow.id === row.id) return
  379 + this.selectedTicketRow = row
  380 + this.form.weighingTicketId = row.id || ''
  381 + this.form.weighingTicketCode = row.code || ''
  382 + this.form.completeTime = row.completeTime || ''
  383 + // 计划编号:取码单过磅明细各行 planCode 去重后逗号拼接
  384 + const planCodes = Array.from(new Set((row.weighLines || []).map(it => it.planCode).filter(Boolean)))
  385 + this.form.code = planCodes.join(',')
  386 + this.form.supplierName = row.supplierName || ''
  387 + this.form.workshopName = row.workshopName || ''
  388 + this.form.settleType = row.settleType || ''
  389 + this.form.remark = row.remark || ''
  390 + // 申请净重明细:由码单带出
  391 + this.applyList = (row.applyLines || []).map(item => ({
  392 + rowId: genRowId(),
  393 + weighingTicketApplyLineId: item.weighingTicketApplyLineId || item.id || '',
  394 + category: item.category || '',
  395 + breedRelationshipId: item.breedRelationshipId || '',
  396 + quantity: item.quantity == null ? '' : item.quantity
  397 + }))
  398 + // 详情明细:由码单过磅明细带出(不可删除,计划编号/品种/过磅数不可编辑)
  399 + this.detailList = (row.weighLines || []).map(item => ({
  400 + rowId: genRowId(),
  401 + brought: true,
  402 + procurementPlanId: item.procurementPlanId || '',
  403 + planCode: item.planCode || '',
  404 + productId: item.productId || '',
  405 + productName: item.productName || '',
  406 + category: item.category || '',
  407 + breedRelationshipId: item.breedRelationshipId || '',
  408 + name: item.name || item.invoiceProductName || '',
  409 + weighQuantity: item.quantity == null ? '' : item.quantity,
  410 + impurityRate: '',
  411 + foldWeight: '',
  412 + returnWeight: '',
  413 + netWeight: '',
  414 + remark: ''
  415 + }))
  416 + // 加载当前码单可选计划下拉
  417 + this.loadPlanOptions(this.form.weighingTicketId)
  418 + },
  419 + loadPlanOptions(ticketId) {
  420 + if (!ticketId) {
  421 + this.planOptions = []
  422 + return
  423 + }
  424 + materialSettlePlanOptionsApi({ ticketId })
  425 + .then(res => {
  426 + const list = (res && res.data) || []
  427 + this.planOptions = (list || []).map(item => ({
  428 + label: item.planCode || '',
  429 + value: item.planId || item.id || ''
  430 + }))
  431 + })
  432 + .catch(() => {
  433 + this.planOptions = []
  434 + })
  435 + },
  436 + // 计划编号改选:重置品种与类别带出并加载该计划下可选品种
  437 + handlePlanChange(idx, optIdx) {
  438 + const opt = this.planOptions[optIdx]
  439 + if (!opt) return
  440 + const row = this.detailList[idx]
  441 + row.procurementPlanId = opt.value
  442 + row.planCode = opt.label
  443 + row.productId = ''
  444 + row.productName = ''
  445 + row.name = ''
  446 + row.weighQuantity = ''
  447 + row.category = ''
  448 + row.breedRelationshipId = ''
  449 + row.productOptions = []
  450 + materialSettlePlanLineOptionsApi({ planId: opt.value })
  451 + .then(res => {
  452 + const list = (res && res.data) || []
  453 + row.productOptions = (list || []).map(line => ({
  454 + label: line.productName || '',
  455 + value: line.productId || '',
  456 + name: line.name || '',
  457 + weighQuantity: line.weighQuantity == null ? (line.quantity == null ? '' : line.quantity) : line.weighQuantity,
  458 + category: line.category || '',
  459 + breedRelationshipId: line.breedRelationshipId || ''
  460 + }))
  461 + })
  462 + .catch(() => {
  463 + row.productOptions = []
  464 + })
  465 + },
  466 + getProductLabels(item) {
  467 + return (item.productOptions || []).map(o => o.label)
  468 + },
  469 + // 品种改选:带出名称、过磅数与类别;清空时同步清空带出数据
  470 + handleProductChange(idx, optIdx) {
  471 + const row = this.detailList[idx]
  472 + const item = (row.productOptions || [])[optIdx]
  473 + if (!item) {
  474 + row.productName = ''
  475 + row.name = ''
  476 + row.weighQuantity = ''
  477 + row.category = ''
  478 + row.breedRelationshipId = ''
  479 + return
  480 + }
  481 + row.productId = item.value
  482 + row.productName = item.label
  483 + row.name = item.name || ''
  484 + row.weighQuantity = item.weighQuantity == null ? '' : item.weighQuantity
  485 + row.category = item.category || ''
  486 + row.breedRelationshipId = item.breedRelationshipId || ''
  487 + },
  488 + // 类别改选:category=code,breedRelationshipId=id
  489 + handleVarietyChange(idx, optIdx) {
  490 + const raw = (this.varietyOptions || [])[optIdx]
  491 + if (!raw) return
  492 + const row = this.detailList[idx]
  493 + row.category = raw.code || ''
  494 + row.breedRelationshipId = raw.id || ''
  495 + },
  496 + // 新增空行
  497 + addRow() {
  498 + this.detailList.push(this.createRow())
  499 + },
  500 + // 在当前行下方插入空行
  501 + insertRow(idx) {
  502 + this.detailList.splice(idx + 1, 0, this.createRow())
  503 + },
  504 + // 删除行(仅插入行可删除)
  505 + delRow(idx) {
  506 + this.detailList.splice(idx, 1)
  507 + },
  508 + // 构造空行
  509 + createRow() {
  510 + return {
  511 + rowId: genRowId(),
  512 + brought: false,
  513 + procurementPlanId: '',
  514 + planCode: '',
  515 + productId: '',
  516 + productName: '',
  517 + category: '',
  518 + breedRelationshipId: '',
  519 + name: '',
  520 + weighQuantity: '',
  521 + impurityRate: '',
  522 + foldWeight: '',
  523 + returnWeight: '',
  524 + netWeight: '',
  525 + remark: '',
  526 + productOptions: []
  527 + }
  528 + },
  529 + validate() {
  530 + if (!this.form.weighingTicketId) return this.tip('请选择码单编号')
  531 + if (!this.form.settleType) return this.tip('请选择类型')
  532 + return true
  533 + },
  534 + tip(msg) {
  535 + uni.showToast({ title: msg, icon: 'none' })
  536 + return false
  537 + },
  538 + buildSubmitData() {
  539 + const t = this.totalSummary
  540 + return {
  541 + weighingTicketId: this.form.weighingTicketId,
  542 + settleType: this.form.settleType,
  543 + totalWeighQuantity: String(t.totalWeighQuantity),
  544 + totalFoldWeight: String(t.totalFoldWeight),
  545 + totalReturnWeight: String(t.totalReturnWeight),
  546 + totalNetWeight: String(t.totalNetWeight),
  547 + remark: this.form.remark || '',
  548 + // 申请净重明细
  549 + applyLines: (this.applyList || []).map(item => ({
  550 + weighingTicketApplyLineId: item.weighingTicketApplyLineId || '',
  551 + category: item.category || '',
  552 + breedRelationshipId: item.breedRelationshipId || '',
  553 + quantity: item.quantity == null ? '' : String(item.quantity),
  554 + itemId: item.breedRelationshipId || ''
  555 + })),
  556 + // 详情明细
  557 + lines: (this.detailList || []).map(item => ({
  558 + procurementPlanId: item.procurementPlanId || '',
  559 + planCode: item.planCode || '',
  560 + productId: item.productId || '',
  561 + category: item.category || '',
  562 + name: item.name || '',
  563 + weighQuantity: item.weighQuantity == null ? '' : String(item.weighQuantity),
  564 + impurityRate: item.impurityRate == null ? '' : String(item.impurityRate),
  565 + foldWeight: item.foldWeight == null ? '' : String(item.foldWeight),
  566 + returnWeight: item.returnWeight == null ? '' : String(item.returnWeight),
  567 + netWeight: item.netWeight == null ? '' : String(item.netWeight),
  568 + remark: item.remark || '',
  569 + itemId: item.breedRelationshipId || ''
  570 + }))
  571 + }
  572 + },
  573 + async onSubmit() {
  574 + if (!this.validate()) return
  575 + const confirmRes = await new Promise(resolve => {
  576 + uni.showModal({ title: '提示', content: '确定保存原料结算详情单吗?', confirmText: '确定', cancelText: '取消', success: resolve })
  577 + })
  578 + if (!(confirmRes && confirmRes.confirm)) return
  579 + uni.showLoading({ title: '提交中...', mask: true })
  580 + materialSettleCreateApi(this.buildSubmitData())
  581 + .then(() => {
  582 + uni.hideLoading()
  583 + uni.showToast({ title: '保存成功', icon: 'none' })
  584 + try { uni.setStorageSync('MATERIAL_SETTLEMENT_LIST_NEED_REFRESH', '1') } catch (e) {}
  585 + setTimeout(() => { uni.navigateBack() }, 400)
  586 + })
  587 + .catch(e => {
  588 + uni.hideLoading()
  589 + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' })
  590 + })
  591 + }
  592 + }
  593 +}
  594 +
  595 +// 生成前端临时行 id
  596 +function genRowId() {
  597 + return 'row_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8)
  598 +}
  599 +</script>
  600 +
  601 +<style lang="scss" scoped>
  602 +.page {
  603 + display: flex;
  604 + flex-direction: column;
  605 + height: 100%;
  606 +}
  607 +
  608 +.scroll {
  609 + flex: 1;
  610 + padding: 12rpx 0 200rpx !important;
  611 +}
  612 +
  613 +.footer {
  614 + z-index: 2;
  615 + position: fixed;
  616 + left: 0;
  617 + right: 0;
  618 + bottom: 0;
  619 + padding: 32rpx;
  620 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  621 + background: #fff;
  622 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  623 +
  624 + .btn {
  625 + height: 80rpx;
  626 + line-height: 80rpx;
  627 + border-radius: 12rpx;
  628 + font-size: 32rpx;
  629 + }
  630 +
  631 + .submit {
  632 + background: $theme-primary;
  633 + color: #fff;
  634 + }
  635 +}
  636 +
  637 +::v-deep .uni-list {
  638 + .uni-easyinput {
  639 + display: flex;
  640 +
  641 + .uni-input-input {
  642 + color: rgba(0, 0, 0, 0.9);
  643 + }
  644 + }
  645 +
  646 + .uni-input-placeholder {
  647 + z-index: 1;
  648 + }
  649 +
  650 + .uni-input-input {
  651 + background-color: #ffffff;
  652 + }
  653 +
  654 + background: transparent;
  655 +
  656 + &-item {
  657 + &__extra-text {
  658 + font-size: 32rpx;
  659 + }
  660 +
  661 + &__content-title {
  662 + font-size: 32rpx;
  663 + color: rgba(0, 0, 0, 0.9);
  664 + }
  665 +
  666 + &__container {
  667 + padding: 32rpx;
  668 +
  669 + .uni-easyinput {
  670 + &__placeholder-class {
  671 + font-size: 32rpx;
  672 + color: rgba(0, 0, 0, 0.4);
  673 + }
  674 +
  675 + &__content {
  676 + border: none;
  677 + background-color: #ffffff !important;
  678 +
  679 + &-input {
  680 + padding-left: 0 !important;
  681 + height: 48rpx;
  682 + line-height: 48rpx;
  683 + font-size: 32rpx;
  684 + }
  685 +
  686 + .content-clear-icon {
  687 + font-size: 44rpx !important;
  688 + }
  689 + }
  690 + }
  691 +
  692 + .item-title,
  693 + .uni-list-item__content {
  694 + flex: none;
  695 + min-height: 48rpx;
  696 + line-height: 48rpx;
  697 + font-size: 32rpx;
  698 + position: relative;
  699 + width: 240rpx;
  700 + margin-right: 32rpx;
  701 + color: rgba(0, 0, 0, 0.9);
  702 +
  703 + .required {
  704 + color: red;
  705 + position: absolute;
  706 + top: 50%;
  707 + transform: translateY(-50%);
  708 + left: -16rpx;
  709 + }
  710 + }
  711 + }
  712 +
  713 + &.select-item {
  714 + &.is-empty {
  715 + .uni-list-item__extra-text {
  716 + color: rgba(0, 0, 0, 0.4) !important;
  717 + }
  718 + }
  719 +
  720 + &.is-filled {
  721 + .uni-list-item__extra-text {
  722 + color: rgba(0, 0, 0, 0.9) !important;
  723 + }
  724 + }
  725 + }
  726 + }
  727 +}
  728 +
  729 +.picker-value {
  730 + font-size: 32rpx;
  731 + color: rgba(0, 0, 0, 0.9);
  732 + line-height: 48rpx;
  733 + text-align: right;
  734 + min-height: 48rpx;
  735 +
  736 + &.placeholder {
  737 + color: rgba(0, 0, 0, 0.4);
  738 + }
  739 +}
  740 +
  741 +.sub-table,
  742 +.remark-section {
  743 + margin-top: 20rpx;
  744 + background: #fff;
  745 +}
  746 +
  747 +.header {
  748 + display: flex;
  749 + align-items: center;
  750 + padding: 24rpx 32rpx;
  751 + border-bottom: 1rpx solid #f0f0f0;
  752 +
  753 + .opCollapse {
  754 + width: 32rpx;
  755 + height: 28rpx;
  756 + margin-right: 16rpx;
  757 + margin-top: 8rpx;
  758 + }
  759 +
  760 + .title {
  761 + font-size: 32rpx;
  762 + color: rgba(0, 0, 0, 0.9);
  763 + font-weight: 600;
  764 + flex: 1;
  765 + }
  766 +
  767 + .ops {
  768 + display: flex;
  769 + align-items: center;
  770 +
  771 + .opAdd {
  772 + width: 40rpx;
  773 + height: 40rpx;
  774 + }
  775 + }
  776 +}
  777 +
  778 +.add-list {
  779 + padding: 0 0 16rpx;
  780 +
  781 + .empty-tip {
  782 + text-align: center;
  783 + padding: 60rpx 0;
  784 + color: rgba(0, 0, 0, 0.4);
  785 + font-size: 28rpx;
  786 + }
  787 +
  788 + .block {
  789 + border-bottom: 1rpx solid #f0f0f0;
  790 +
  791 + &:last-child {
  792 + border-bottom: none;
  793 + }
  794 +
  795 + .block-ops {
  796 + display: flex;
  797 + align-items: center;
  798 + justify-content: flex-end;
  799 + gap: 48rpx;
  800 + padding: 20rpx 32rpx;
  801 + background: #f8f8f8;
  802 +
  803 + .del,
  804 + .toggle {
  805 + display: flex;
  806 + align-items: center;
  807 + font-size: 28rpx;
  808 + color: rgba(0, 0, 0, 0.6);
  809 +
  810 + .icon {
  811 + width: 32rpx;
  812 + height: 32rpx;
  813 + margin-right: 8rpx;
  814 + }
  815 + }
  816 +
  817 + .del {
  818 + color: #d54941;
  819 + }
  820 + }
  821 + }
  822 +}
  823 +
  824 +.total-card {
  825 + margin-top: 20rpx;
  826 + background: #fff;
  827 + padding: 24rpx 32rpx;
  828 +
  829 + .total-title {
  830 + font-size: 32rpx;
  831 + font-weight: 600;
  832 + color: rgba(0, 0, 0, 0.9);
  833 + margin-bottom: 20rpx;
  834 + }
  835 +
  836 + .total-body {
  837 + display: flex;
  838 + flex-wrap: wrap;
  839 +
  840 + .total-item {
  841 + width: 50%;
  842 + display: flex;
  843 + align-items: center;
  844 + margin-bottom: 20rpx;
  845 +
  846 + &:nth-last-child(-n + 2) {
  847 + margin-bottom: 0;
  848 + }
  849 +
  850 + .total-label {
  851 + font-size: 28rpx;
  852 + color: rgba(0, 0, 0, 0.6);
  853 + margin-right: 16rpx;
  854 + }
  855 +
  856 + .total-value {
  857 + font-size: 28rpx;
  858 + color: rgba(0, 0, 0, 0.9);
  859 + font-weight: 500;
  860 + }
  861 + }
  862 + }
  863 +}
  864 +
  865 +.section-content {
  866 + padding: 32rpx;
  867 +}
  868 +
  869 +.remark-group {
  870 + margin-top: 8rpx;
  871 +
  872 + .remark-label {
  873 + display: flex;
  874 + align-items: center;
  875 + font-size: 32rpx;
  876 + color: rgba(0, 0, 0, 0.9);
  877 + margin-bottom: 16rpx;
  878 + }
  879 +}
  880 +</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(planCodeText) }}</text></view>
  10 + <view class="row"><text class="label">单位</text><text class="value">{{ safeText(form.supplierName) }}</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('apply')">
  20 + <image class="sub-toggle_icon" :src="collapse.apply ? '/static/images/down.png' : '/static/images/up.png'" />
  21 + <text class="sub-toggle_text">{{ collapse.apply ? '展开' : '收起' }}</text>
  22 + </view>
  23 + </view>
  24 + <view v-if="!collapse.apply" class="sub-body">
  25 + <view v-if="!applyList.length" class="empty-tip">暂无明细</view>
  26 + <view v-for="(item, idx) in applyList" :key="'a-' + (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">{{ formatNumber(item.quantity) }}</text></view>
  30 + </view>
  31 + </view>
  32 + </view>
  33 +
  34 + <!-- 详情明细 -->
  35 + <view class="sub-table">
  36 + <view class="sub-header">
  37 + <image class="sub-bar" src="/static/images/title.png" />
  38 + <text class="sub-title">详情明细</text>
  39 + <view class="sub-toggle" @click="toggle('detail')">
  40 + <image class="sub-toggle_icon" :src="collapse.detail ? '/static/images/down.png' : '/static/images/up.png'" />
  41 + <text class="sub-toggle_text">{{ collapse.detail ? '展开' : '收起' }}</text>
  42 + </view>
  43 + </view>
  44 + <view v-if="!collapse.detail" class="sub-body">
  45 + <view v-if="!detailList.length" class="empty-tip">暂无明细</view>
  46 + <view v-for="(item, idx) in detailList" :key="'d-' + (item.id || idx)" class="card">
  47 + <view class="card-index">第 {{ idx + 1 }} 行</view>
  48 + <view class="row"><text class="label">计划编号</text><text class="value">{{ safeText(item.planCode) }}</text></view>
  49 + <view class="row"><text class="label">品种</text><text class="value">{{ safeText(item.productName) }}</text></view>
  50 + <view class="row"><text class="label">类别</text><text class="value">{{ safeText(item.category) }}</text></view>
  51 + <view class="row"><text class="label">名称</text><text class="value">{{ safeText(item.name) }}</text></view>
  52 + <view class="row"><text class="label">过磅数</text><text class="value">{{ formatNumber(item.weighQuantity) }}</text></view>
  53 + <view class="row"><text class="label">杂率(%)</text><text class="value">{{ formatNumber(item.impurityRate) }}</text></view>
  54 + <view class="row"><text class="label">折斤</text><text class="value">{{ formatNumber(item.foldWeight) }}</text></view>
  55 + <view class="row"><text class="label">退料</text><text class="value">{{ formatNumber(item.returnWeight) }}</text></view>
  56 + <view class="row"><text class="label">入库净重</text><text class="value">{{ formatNumber(item.netWeight) }}</text></view>
  57 + <view class="row"><text class="label">备注</text><text class="value">{{ safeText(item.remark) }}</text></view>
  58 + </view>
  59 + </view>
  60 + </view>
  61 +
  62 + <!-- 其他信息 -->
  63 + <view class="title-header">
  64 + <image class="title-header_icon" src="/static/images/title.png" />
  65 + <span>其他信息</span>
  66 + </view>
  67 + <view class="total-card">
  68 + <view class="total-title">合计</view>
  69 + <view class="total-body">
  70 + <view class="total-item">
  71 + <text class="total-label">过磅数</text>
  72 + <text class="total-value">{{ formatNumber(form.totalWeighQuantity) }}</text>
  73 + </view>
  74 + <view class="total-item">
  75 + <text class="total-label">折斤</text>
  76 + <text class="total-value">{{ formatNumber(form.totalFoldWeight) }}</text>
  77 + </view>
  78 + <view class="total-item">
  79 + <text class="total-label">退料</text>
  80 + <text class="total-value">{{ formatNumber(form.totalReturnWeight) }}</text>
  81 + </view>
  82 + <view class="total-item">
  83 + <text class="total-label">入库净重</text>
  84 + <text class="total-value">{{ formatNumber(form.totalNetWeight) }}</text>
  85 + </view>
  86 + </view>
  87 + </view>
  88 + <view class="section">
  89 + <view class="row"><text class="label">类型</text><text class="value">{{ settleTypeName }}</text></view>
  90 + </view>
  91 + <view class="section">
  92 + <text class="remark-text">{{ safeText(form.remark) }}</text>
  93 + </view>
  94 + </view>
  95 + </scroll-view>
  96 + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  97 + </view>
  98 +</template>
  99 +
  100 +<script>
  101 +import DetailButtons from '@/components/detail-buttons/index.vue'
  102 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  103 +import {
  104 + materialSettleDetailApi,
  105 + materialSettleSubmitAuditApi,
  106 + materialSettleReturnDraftApi,
  107 + materialSettleCancelApi
  108 +} from '@/api/procure-manage/materialSettlement.js'
  109 +import { getInfo } from '@/api/login.js'
  110 +
  111 +export default {
  112 + name: 'MaterialSettlementDetail',
  113 + components: { DetailButtons },
  114 + data() {
  115 + return {
  116 + id: '',
  117 + // 是否作废单(作废单仅可查看,对齐 PC 端 createActions)
  118 + isDeleted: false,
  119 + form: {},
  120 + applyList: [],
  121 + detailList: [],
  122 + currentUserId: '',
  123 + collapse: { apply: false, detail: false },
  124 + dicOptions: {
  125 + SETTLE_TYPE: [],
  126 + AUDIT_STATUS: []
  127 + },
  128 + buttons: [
  129 + { text: '修改', visible: true, variant: 'outline', event: 'edit' },
  130 + { text: '提交审核', visible: true, variant: 'outline', event: 'submitAudit' },
  131 + { text: '审核', visible: true, variant: 'primary', event: 'audit' },
  132 + { text: '审核详情', visible: true, variant: 'outline', event: 'auditDetail' },
  133 + { text: '退回', visible: true, variant: 'outline', event: 'back' },
  134 + { text: '取消', visible: true, variant: 'outline', event: 'cancel' }
  135 + ]
  136 + }
  137 + },
  138 + computed: {
  139 + settleTypeName() {
  140 + const v = this.form.settleType == null ? '' : String(this.form.settleType)
  141 + if (!v) return '-'
  142 + return getDicName('SETTLE_TYPE', v, this.dicOptions.SETTLE_TYPE) || v
  143 + },
  144 + planCodeText() {
  145 + const codes = Array.from(new Set((this.detailList || []).map(it => it.planCode).filter(Boolean)))
  146 + return codes.join(',')
  147 + },
  148 + displayButtons() {
  149 + if (this.isDeleted) return []
  150 + const status = this.form.approvalStatus || ''
  151 + const isMine = this.form.createById === this.currentUserId
  152 + const isDraft = status === 'DRAFT'
  153 + const isAudit = status === 'AUDIT'
  154 + const isPass = status === 'PASS'
  155 + const isRefuse = status === 'REFUSE'
  156 + const showExamine = this.form.showExamine === true
  157 + const showExamineDetail = this.form.showExamineDetail === true
  158 + return [
  159 + {
  160 + ...this.buttons[0],
  161 + visible: (isDraft || isRefuse) && isMine && this.$auth.hasPermi('warehouse-manage:material-settlement:modify')
  162 + },
  163 + {
  164 + ...this.buttons[1],
  165 + visible: (isDraft || isRefuse) && isMine && this.$auth.hasPermi('warehouse-manage:material-settlement:submit')
  166 + },
  167 + {
  168 + ...this.buttons[2],
  169 + visible: isAudit && showExamine && this.$auth.hasPermi('warehouse-manage:material-settlement:approve')
  170 + },
  171 + {
  172 + ...this.buttons[3],
  173 + visible: showExamineDetail && this.$auth.hasPermi('warehouse-manage:material-settlement:review')
  174 + },
  175 + {
  176 + ...this.buttons[4],
  177 + visible: isPass && this.$auth.hasPermi('warehouse-manage:material-settlement:back')
  178 + },
  179 + {
  180 + ...this.buttons[5],
  181 + visible: (isRefuse || isDraft) && this.$auth.hasPermi('warehouse-manage:material-settlement:cancel')
  182 + }
  183 + ]
  184 + }
  185 + },
  186 + onLoad(query) {
  187 + this.id = (query && query.id) || ''
  188 + this.isDeleted = (query && query.deleted) === '1'
  189 + this.loadDicData()
  190 + this.loadDetail()
  191 + this.getUserInfo()
  192 + },
  193 + onShow() {
  194 + let needRefresh = ''
  195 + try { needRefresh = uni.getStorageSync('MATERIAL_SETTLEMENT_DETAIL_NEED_REFRESH') } catch (e) {}
  196 + if (!needRefresh) return
  197 + try { uni.removeStorageSync('MATERIAL_SETTLEMENT_DETAIL_NEED_REFRESH') } catch (e) {}
  198 + this.loadDetail()
  199 + },
  200 + methods: {
  201 + toggle(key) {
  202 + this.collapse = { ...this.collapse, [key]: !this.collapse[key] }
  203 + },
  204 + async loadDicData() {
  205 + try {
  206 + const results = await getDicByCodes(['SETTLE_TYPE', 'AUDIT_STATUS'])
  207 + this.dicOptions.SETTLE_TYPE = (results.SETTLE_TYPE && results.SETTLE_TYPE.data) || []
  208 + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || []
  209 + } catch (e) {
  210 + this.dicOptions = { SETTLE_TYPE: [], AUDIT_STATUS: [] }
  211 + }
  212 + },
  213 + async getUserInfo() {
  214 + try {
  215 + const res = await getInfo()
  216 + this.currentUserId = (res && (res.id || (res.data && res.data.id))) || ''
  217 + } catch (e) {
  218 + this.currentUserId = ''
  219 + }
  220 + },
  221 + loadDetail() {
  222 + if (!this.id) {
  223 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  224 + return
  225 + }
  226 + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true })
  227 + materialSettleDetailApi({ id: this.id })
  228 + .then(res => {
  229 + const data = res && res.data ? (res.data.data || res.data) : {}
  230 + this.form = Object.assign({}, data)
  231 + this.applyList = Array.isArray(data.applyLines) ? data.applyLines.map(x => ({ ...x })) : []
  232 + this.detailList = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : []
  233 + })
  234 + .catch(() => {
  235 + uni.showToast({ title: '详情加载失败', icon: 'none' })
  236 + })
  237 + .finally(() => {
  238 + uni.hideLoading && uni.hideLoading()
  239 + })
  240 + },
  241 + handleButtonClick(btn) {
  242 + if (!btn || btn.disabled || !btn.visible) return
  243 + const e = btn.event || ''
  244 + if (e === 'edit') return this.onEdit()
  245 + if (e === 'submitAudit') return this.onSubmitAudit()
  246 + if (e === 'audit') return this.onAudit()
  247 + if (e === 'auditDetail') return this.onAuditDetail()
  248 + if (e === 'back') return this.onBack()
  249 + if (e === 'cancel') return this.onCancel()
  250 + },
  251 + onEdit() {
  252 + uni.navigateTo({ url: '/pages/material-settlement/modify?id=' + this.id })
  253 + },
  254 + onAudit() {
  255 + const id = this.id || (this.form && this.form.id) || ''
  256 + if (!id) return
  257 + uni.setStorageSync('contractType', 'SETTLE_DETAIL')
  258 + uni.setStorageSync('sourceBusinessId', id)
  259 + uni.navigateTo({ url: '/pages/flow/audit' })
  260 + },
  261 + onAuditDetail() {
  262 + const id = this.id || (this.form && this.form.id) || ''
  263 + if (!id) return
  264 + uni.setStorageSync('contractType', 'SETTLE_DETAIL')
  265 + uni.setStorageSync('sourceBusinessId', id)
  266 + uni.navigateTo({ url: '/pages/flow/audit_detail' })
  267 + },
  268 + refreshListFlags() {
  269 + try {
  270 + uni.setStorageSync('MATERIAL_SETTLEMENT_LIST_NEED_REFRESH', '1')
  271 + uni.setStorageSync('MATERIAL_SETTLEMENT_DETAIL_NEED_REFRESH', '1')
  272 + } catch (e) {}
  273 + },
  274 + runWithConfirm(opts) {
  275 + const title = opts.title || '提示'
  276 + const content = opts.content || ''
  277 + const run = opts.run
  278 + const loading = opts.loading || '处理中'
  279 + const successText = opts.successText || '操作成功'
  280 + const failText = opts.failText || '操作失败'
  281 + if (!this.id) {
  282 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  283 + return
  284 + }
  285 + uni.showModal({
  286 + title,
  287 + content,
  288 + confirmText: '确定',
  289 + cancelText: '取消',
  290 + success: res => {
  291 + if (!res || !res.confirm) return
  292 + uni.showLoading({ title: loading, mask: true })
  293 + Promise.resolve(run(this.id))
  294 + .then(() => {
  295 + uni.hideLoading()
  296 + uni.showToast({ title: successText, icon: 'none' })
  297 + this.refreshListFlags()
  298 + this.loadDetail()
  299 + })
  300 + .catch(e => {
  301 + uni.hideLoading()
  302 + uni.showToast({ title: (e && (e.msg || e.message)) || failText, icon: 'none' })
  303 + })
  304 + }
  305 + })
  306 + },
  307 + onSubmitAudit() {
  308 + this.runWithConfirm({
  309 + title: '提交审核确认',
  310 + content: '确认提交审核吗?',
  311 + loading: '提交中',
  312 + successText: '提交审核成功',
  313 + failText: '提交审核失败',
  314 + run: id => materialSettleSubmitAuditApi(id)
  315 + })
  316 + },
  317 + onBack() {
  318 + this.runWithConfirm({
  319 + title: '退回确认',
  320 + content: '确认退回该结算单吗?',
  321 + loading: '处理中',
  322 + successText: '退回成功',
  323 + failText: '退回失败',
  324 + run: id => materialSettleReturnDraftApi(id)
  325 + })
  326 + },
  327 + onCancel() {
  328 + this.runWithConfirm({
  329 + title: '取消确认',
  330 + content: '确认取消该结算单吗?',
  331 + loading: '处理中',
  332 + successText: '取消成功',
  333 + failText: '取消失败',
  334 + run: id => materialSettleCancelApi(id)
  335 + })
  336 + },
  337 + safeText(v) {
  338 + const s = v == null ? '' : String(v)
  339 + return s.trim() ? s : '-'
  340 + },
  341 + formatNumber(v) {
  342 + if (v === null || v === undefined || v === '') return '-'
  343 + const n = Number(v)
  344 + if (isNaN(n)) return String(v)
  345 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  346 + }
  347 + }
  348 +}
  349 +</script>
  350 +
  351 +<style lang="scss" scoped>
  352 +.page {
  353 + display: flex;
  354 + flex-direction: column;
  355 + height: 100%;
  356 +}
  357 +.scroll {
  358 + flex: 1;
  359 + padding: 8rpx 0 144rpx;
  360 +}
  361 +.detail-page {
  362 + background: #f3f3f3;
  363 +}
  364 +.section {
  365 + padding: 32rpx;
  366 + background: #fff;
  367 + margin-bottom: 20rpx;
  368 +}
  369 +.title-header {
  370 + display: flex;
  371 + align-items: center;
  372 + padding: 24rpx 32rpx 12rpx;
  373 + background-color: #ffffff;
  374 + .title-header_icon { width: 36rpx; height: 36rpx; margin-right: 12rpx; }
  375 + span { font-size: 34rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); }
  376 +}
  377 +.row {
  378 + display: flex;
  379 + margin-bottom: 28rpx;
  380 + &:last-child { margin-bottom: 0; }
  381 + &.company {
  382 + font-size: 36rpx;
  383 + font-weight: 600;
  384 + color: rgba(0, 0, 0, 0.9);
  385 + padding-top: 8rpx;
  386 + line-height: 50rpx;
  387 + }
  388 + .label {
  389 + max-width: 420rpx;
  390 + margin-right: 20rpx;
  391 + line-height: 32rpx;
  392 + font-size: 28rpx;
  393 + color: rgba(0, 0, 0, 0.6);
  394 + }
  395 + .value {
  396 + flex: 1;
  397 + line-height: 32rpx;
  398 + font-size: 28rpx;
  399 + color: rgba(0, 0, 0, 0.9);
  400 + text-align: right;
  401 + word-break: break-all;
  402 + }
  403 +}
  404 +.remark-text {
  405 + font-size: 28rpx;
  406 + color: rgba(0, 0, 0, 0.9);
  407 + line-height: 1.6;
  408 + white-space: pre-wrap;
  409 +}
  410 +.total-card {
  411 + background: #fff;
  412 + margin-bottom: 20rpx;
  413 + padding: 24rpx 32rpx;
  414 + .total-title {
  415 + font-size: 32rpx;
  416 + font-weight: 600;
  417 + color: rgba(0, 0, 0, 0.9);
  418 + margin-bottom: 20rpx;
  419 + }
  420 + .total-body {
  421 + display: flex;
  422 + flex-wrap: wrap;
  423 + .total-item {
  424 + width: 50%;
  425 + display: flex;
  426 + align-items: center;
  427 + margin-bottom: 20rpx;
  428 + &:nth-last-child(-n + 2) { margin-bottom: 0; }
  429 + .total-label {
  430 + font-size: 28rpx;
  431 + color: rgba(0, 0, 0, 0.6);
  432 + margin-right: 16rpx;
  433 + }
  434 + .total-value {
  435 + font-size: 28rpx;
  436 + color: rgba(0, 0, 0, 0.9);
  437 + font-weight: 500;
  438 + }
  439 + }
  440 + }
  441 +}
  442 +.sub-table {
  443 + background: #fff;
  444 + margin-bottom: 20rpx;
  445 +}
  446 +.sub-header {
  447 + display: flex;
  448 + align-items: center;
  449 + padding: 16rpx 0 16rpx 32rpx;
  450 + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; }
  451 + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; }
  452 + .sub-toggle {
  453 + display: flex;
  454 + align-items: center;
  455 + padding: 0 12rpx;
  456 + height: 56rpx;
  457 + .sub-toggle_icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; }
  458 + .sub-toggle_text { font-size: 26rpx; color: rgba(0, 0, 0, 0.6); }
  459 + }
  460 +}
  461 +.sub-body {
  462 + padding: 0 32rpx 24rpx;
  463 + .empty-tip {
  464 + text-align: center;
  465 + padding: 60rpx 0;
  466 + color: rgba(0, 0, 0, 0.4);
  467 + font-size: 28rpx;
  468 + }
  469 + .card {
  470 + position: relative;
  471 + background: #fafafa;
  472 + border-radius: 12rpx;
  473 + padding: 32rpx 28rpx 20rpx;
  474 + margin-bottom: 24rpx;
  475 + .card-index {
  476 + position: absolute;
  477 + top: 0;
  478 + right: 0;
  479 + background: rgba(24, 144, 255, 0.08);
  480 + color: $theme-primary;
  481 + font-size: 22rpx;
  482 + line-height: 36rpx;
  483 + padding: 0 16rpx;
  484 + border-bottom-left-radius: 12rpx;
  485 + border-top-right-radius: 12rpx;
  486 + }
  487 + .row {
  488 + align-items: center;
  489 + justify-content: space-between;
  490 + padding: 14rpx 0;
  491 + margin-bottom: 0;
  492 + border-bottom: 1rpx dashed #f2f2f2;
  493 + &:last-child { border-bottom: none; }
  494 + .label {
  495 + flex-shrink: 0;
  496 + width: 220rpx;
  497 + max-width: none;
  498 + margin-right: 0;
  499 + font-size: 28rpx;
  500 + color: rgba(0, 0, 0, 0.6);
  501 + line-height: 40rpx;
  502 + }
  503 + .value {
  504 + flex: 1;
  505 + text-align: right;
  506 + font-size: 28rpx;
  507 + color: rgba(0, 0, 0, 0.9);
  508 + line-height: 40rpx;
  509 + overflow: hidden;
  510 + text-overflow: ellipsis;
  511 + white-space: nowrap;
  512 + }
  513 + }
  514 + }
  515 +}
  516 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <view class="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:material-settlement: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 +
  27 + <view class="tabs">
  28 + <view
  29 + v-for="(t, i) in tabs"
  30 + :key="i"
  31 + :class="['tab', { active: deleted === t.value }]"
  32 + @click="switchTab(t)"
  33 + >
  34 + {{ t.label }}
  35 + </view>
  36 + </view>
  37 + </view>
  38 +
  39 + <view class="list-box">
  40 + <card-list
  41 + ref="cardRef"
  42 + :fetch-fn="fetchList"
  43 + :query="query"
  44 + :extra="extraParams"
  45 + row-key="id"
  46 + :enable-refresh="true"
  47 + :enable-load-more="true"
  48 + @loaded="onCardLoaded"
  49 + @error="onCardError"
  50 + >
  51 + <template v-slot="{ item }">
  52 + <view class="card" @click="onCardClick(item)">
  53 + <view class="card-header">
  54 + <text class="title omit2">{{ item.supplierName || '-' }}</text>
  55 + <text :class="['status', `status_${item.approvalStatus}`]">{{ getAuditStatusText(item.approvalStatus) }}</text>
  56 + </view>
  57 + <view class="info-row">
  58 + <text>码单编号</text>
  59 + <text>{{ item.weighingTicketCode || '-' }}</text>
  60 + </view>
  61 + <view class="info-row">
  62 + <text>日期</text>
  63 + <text>{{ formatDateOnly(item.ticketDate) }}</text>
  64 + </view>
  65 + <view class="info-row">
  66 + <text>计划编号</text>
  67 + <text>{{ item.planCode.join(',') || '-' }}</text>
  68 + </view>
  69 + <view class="info-row">
  70 + <text>分厂</text>
  71 + <text>{{ item.workshopName || '-' }}</text>
  72 + </view>
  73 + <view class="info-row">
  74 + <text>流程节点</text>
  75 + <text>{{ getFlowNodeText(item.flowNode) }}</text>
  76 + </view>
  77 + <view class="info-row">
  78 + <text>创建时间</text>
  79 + <text>{{ item.createTime || '-' }}</text>
  80 + </view>
  81 + </view>
  82 + </template>
  83 + </card-list>
  84 + </view>
  85 +
  86 + <filter-modal
  87 + :visible.sync="filterVisible"
  88 + :value.sync="filterForm"
  89 + title="筛选"
  90 + @reset="onFilterReset"
  91 + @confirm="onFilterConfirm"
  92 + >
  93 + <template v-slot="{ model }">
  94 + <view class="filter-form">
  95 + <view class="form-item">
  96 + <view class="label">计划编号</view>
  97 + <input class="input" v-model="model.planCode" placeholder="请输入计划编号" />
  98 + </view>
  99 + <view class="form-item">
  100 + <view class="label">分厂</view>
  101 + <picker mode="selector" :range="workshopLabels" @change="onWorkshopChange">
  102 + <view class="fake-select">
  103 + <text v-if="workshopLabel" class="value">{{ workshopLabel }}</text>
  104 + <text v-else class="placeholder">请选择分厂</text>
  105 + </view>
  106 + </picker>
  107 + </view>
  108 + <view class="form-item">
  109 + <view class="label">流程节点</view>
  110 + <picker mode="selector" :range="flowNodeLabels" @change="onFlowNodeChange">
  111 + <view class="fake-select">
  112 + <text v-if="flowNodeLabel" class="value">{{ flowNodeLabel }}</text>
  113 + <text v-else class="placeholder">请选择流程节点</text>
  114 + </view>
  115 + </picker>
  116 + </view>
  117 + <view class="form-item">
  118 + <view class="label">审核状态</view>
  119 + <uni-data-checkbox
  120 + mode="tag"
  121 + :multiple="false"
  122 + :value-field="'value'"
  123 + :text-field="'text'"
  124 + v-model="model.approvalStatus"
  125 + :localdata="approvalStatusOptions"
  126 + />
  127 + </view>
  128 + <view class="form-item">
  129 + <view class="label">日期</view>
  130 + <uni-datetime-picker type="daterange" v-model="model.timeRange" start="2023-01-01" />
  131 + </view>
  132 + </view>
  133 + </template>
  134 + </filter-modal>
  135 + </view>
  136 +</template>
  137 +
  138 +<script>
  139 +import CardList from '@/components/card/index.vue'
  140 +import FilterModal from '@/components/filter/index.vue'
  141 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  142 +import { materialSettleQueryApi } from '@/api/procure-manage/materialSettlement.js'
  143 +import { workshopQueryApi } from '@/api/procure-manage/assayReport.js'
  144 +
  145 +export default {
  146 + name: 'MaterialSettlementList',
  147 + components: { CardList, FilterModal },
  148 + data() {
  149 + return {
  150 + searchKeyword: '',
  151 + searchKeywordDebounced: '',
  152 + searchDebounceTimer: null,
  153 + deleted: false,
  154 + tabs: [
  155 + { label: '有效', value: false },
  156 + { label: '作废', value: true }
  157 + ],
  158 + query: {
  159 + planCode: '',
  160 + workshopId: '',
  161 + flowNode: '',
  162 + approvalStatus: '',
  163 + timeRange: []
  164 + },
  165 + extraParams: {},
  166 + currentItems: [],
  167 + filterVisible: false,
  168 + filterForm: {
  169 + planCode: '',
  170 + workshopId: '',
  171 + flowNode: '',
  172 + approvalStatus: '',
  173 + timeRange: []
  174 + },
  175 + approvalStatusOptions: [
  176 + { value: '', text: '全部' },
  177 + { value: 'DRAFT', text: '草稿' },
  178 + { value: 'AUDIT', text: '审核中' },
  179 + { value: 'PASS', text: '审核通过' },
  180 + { value: 'REFUSE', text: '已驳回' },
  181 + { value: 'CANCEL', text: '已取消' }
  182 + ],
  183 + workshopOptions: [],
  184 + workshopLabel: '',
  185 + flowNodeLabel: '',
  186 + dicOptions: {
  187 + AUDIT_STATUS: [],
  188 + SETTLE_FLOW_NODE: []
  189 + }
  190 + }
  191 + },
  192 + computed: {
  193 + workshopLabels() {
  194 + return ['全部'].concat(this.workshopOptions.map(it => it.label))
  195 + },
  196 + flowNodeLabels() {
  197 + return ['全部'].concat((this.dicOptions.SETTLE_FLOW_NODE || []).map(it => it.name))
  198 + },
  199 + extraCombined() {
  200 + return {
  201 + keyword: this.searchKeywordDebounced || undefined,
  202 + deleted: this.deleted
  203 + }
  204 + }
  205 + },
  206 + watch: {
  207 + extraCombined: {
  208 + deep: true,
  209 + handler(v) {
  210 + this.extraParams = v
  211 + },
  212 + immediate: true
  213 + }
  214 + },
  215 + created() {
  216 + this.loadDicData()
  217 + this.loadWorkshopOptions()
  218 + },
  219 + onShow() {
  220 + let needRefresh = ''
  221 + try { needRefresh = uni.getStorageSync('MATERIAL_SETTLEMENT_LIST_NEED_REFRESH') } catch (e) {}
  222 + if (!needRefresh) return
  223 + try { uni.removeStorageSync('MATERIAL_SETTLEMENT_LIST_NEED_REFRESH') } catch (e) {}
  224 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.reload) {
  225 + this.$refs.cardRef.reload()
  226 + }
  227 + },
  228 + onReachBottom() {
  229 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.onLoadMore) {
  230 + this.$refs.cardRef.onLoadMore()
  231 + }
  232 + },
  233 + beforeDestroy() {
  234 + if (this.searchDebounceTimer) {
  235 + clearTimeout(this.searchDebounceTimer)
  236 + this.searchDebounceTimer = null
  237 + }
  238 + },
  239 + methods: {
  240 + async loadDicData() {
  241 + try {
  242 + const results = await getDicByCodes(['AUDIT_STATUS', 'SETTLE_FLOW_NODE'])
  243 + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || []
  244 + this.dicOptions.SETTLE_FLOW_NODE = (results.SETTLE_FLOW_NODE && results.SETTLE_FLOW_NODE.data) || []
  245 + } catch (e) {
  246 + this.dicOptions = { AUDIT_STATUS: [], SETTLE_FLOW_NODE: [] }
  247 + }
  248 + },
  249 + async loadWorkshopOptions() {
  250 + try {
  251 + const res = await workshopQueryApi({ pageIndex: 1, pageSize: 9999 })
  252 + const _data = (res && res.data) || {}
  253 + const datas = _data.datas || _data.list || _data.records || []
  254 + this.workshopOptions = datas.map(item => ({
  255 + label: item.name || '',
  256 + value: item.id || ''
  257 + })).filter(it => it.value)
  258 + } catch (e) {
  259 + this.workshopOptions = []
  260 + }
  261 + },
  262 + getAuditStatusText(status) {
  263 + const v = status == null ? '' : String(status)
  264 + if (!v) return '-'
  265 + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v
  266 + },
  267 + getFlowNodeText(flowNode) {
  268 + const v = flowNode == null ? '' : String(flowNode)
  269 + if (!v) return '-'
  270 + return getDicName('SETTLE_FLOW_NODE', v, this.dicOptions.SETTLE_FLOW_NODE) || v
  271 + },
  272 + formatDateOnly(v) {
  273 + const s = v == null ? '' : String(v).trim()
  274 + if (!s) return '-'
  275 + if (s.length >= 10) return s.slice(0, 10)
  276 + return s
  277 + },
  278 + onCardLoaded({ items }) {
  279 + this.currentItems = items
  280 + },
  281 + onCardError() {
  282 + uni.showToast({ title: '列表加载失败', icon: 'none' })
  283 + },
  284 + onAdd() {
  285 + uni.navigateTo({ url: '/pages/material-settlement/add' })
  286 + },
  287 + onSearchInput() {
  288 + if (this.searchDebounceTimer) clearTimeout(this.searchDebounceTimer)
  289 + this.searchDebounceTimer = setTimeout(() => {
  290 + this.searchKeywordDebounced = this.searchKeyword
  291 + this.searchDebounceTimer = null
  292 + }, 1200)
  293 + },
  294 + search(e) {
  295 + const val = e && e.value != null ? e.value : this.searchKeyword
  296 + this.searchKeyword = val
  297 + this.searchKeywordDebounced = val
  298 + },
  299 + switchTab(t) {
  300 + this.deleted = t.value
  301 + },
  302 + onWorkshopChange(e) {
  303 + const idx = Number(e.detail.value)
  304 + if (idx <= 0) {
  305 + this.filterForm.workshopId = ''
  306 + this.workshopLabel = ''
  307 + } else {
  308 + const opt = this.workshopOptions[idx - 1]
  309 + this.filterForm.workshopId = opt ? opt.value : ''
  310 + this.workshopLabel = opt ? opt.label : ''
  311 + }
  312 + },
  313 + onFlowNodeChange(e) {
  314 + const idx = Number(e.detail.value)
  315 + if (idx <= 0) {
  316 + this.filterForm.flowNode = ''
  317 + this.flowNodeLabel = ''
  318 + } else {
  319 + const opt = (this.dicOptions.SETTLE_FLOW_NODE || [])[idx - 1]
  320 + this.filterForm.flowNode = opt ? String(opt.code) : ''
  321 + this.flowNodeLabel = opt ? opt.name : ''
  322 + }
  323 + },
  324 + openFilter() {
  325 + this.filterForm = {
  326 + planCode: this.query.planCode || '',
  327 + workshopId: this.query.workshopId || '',
  328 + flowNode: this.query.flowNode || '',
  329 + approvalStatus: this.query.approvalStatus || '',
  330 + timeRange: Array.isArray(this.query.timeRange) ? this.query.timeRange.slice(0) : []
  331 + }
  332 + const workshop = this.workshopOptions.find(it => it.value === this.filterForm.workshopId)
  333 + this.workshopLabel = workshop ? workshop.label : ''
  334 + const flowNode = (this.dicOptions.SETTLE_FLOW_NODE || []).find(it => String(it.code) === String(this.filterForm.flowNode))
  335 + this.flowNodeLabel = flowNode ? flowNode.name : ''
  336 + this.filterVisible = true
  337 + },
  338 + onFilterReset(payload) {
  339 + this.filterForm = payload
  340 + this.workshopLabel = ''
  341 + this.flowNodeLabel = ''
  342 + },
  343 + onFilterConfirm(payload) {
  344 + this.query = {
  345 + planCode: payload.planCode || '',
  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 + deleted: e.deleted === true,
  361 + weighingTicketCode: keyword || '',
  362 + planCode: q.planCode || '',
  363 + workshopId: q.workshopId || '',
  364 + flowNode: q.flowNode || '',
  365 + approvalStatus: q.approvalStatus || '',
  366 + ticketDateStart: range && range.length === 2 ? range[0] : '',
  367 + ticketDateEnd: range && range.length === 2 ? range[1] : ''
  368 + }
  369 + return materialSettleQueryApi(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 + // 作废单仅可查看(对齐 PC 端 createActions)
  390 + uni.navigateTo({ url: '/pages/material-settlement/detail?id=' + id + '&deleted=' + (item.deleted === true ? '1' : '0') })
  391 + }
  392 + }
  393 +}
  394 +</script>
  395 +
  396 +<style lang="scss" scoped>
  397 +.page {
  398 + display: flex;
  399 + flex-direction: column;
  400 + height: 100vh;
  401 +}
  402 +.list-fixed {
  403 + position: fixed;
  404 + top: 96rpx;
  405 + left: 0;
  406 + right: 0;
  407 + z-index: 2;
  408 + background: #fff;
  409 + .search-row {
  410 + display: flex;
  411 + align-items: center;
  412 + padding: 16rpx 32rpx;
  413 + .uni-searchbar { padding: 0; flex: 1; }
  414 + .tool-icons {
  415 + display: flex;
  416 + .tool-icon { width: 48rpx; height: 48rpx; display: block; margin-left: 32rpx; }
  417 + }
  418 + }
  419 + .tabs {
  420 + display: flex;
  421 + align-items: center;
  422 + justify-content: space-between;
  423 + padding: 26rpx 34rpx;
  424 + border-bottom: solid 1px #e7e7e7;
  425 + .tab { width: 50%; text-align: center; color: rgba(0, 0, 0, 0.9); line-height: 44rpx; position: relative; font-weight: 600; }
  426 + .tab.active { color: $theme-primary; }
  427 + .tab.active::after {
  428 + content: '';
  429 + position: absolute;
  430 + left: 50%;
  431 + transform: translateX(-50%);
  432 + bottom: -13px;
  433 + width: 32rpx;
  434 + height: 6rpx;
  435 + border-radius: 4rpx;
  436 + background: $theme-primary;
  437 + }
  438 + }
  439 +}
  440 +::v-deep .uni-searchbar__box {
  441 + height: 80rpx !important;
  442 + justify-content: start;
  443 + .uni-searchbar__box-search-input { font-size: 32rpx !important; }
  444 +}
  445 +.list-box {
  446 + flex: 1;
  447 + padding-top: 236rpx;
  448 + .card { position: relative; }
  449 + .card-header {
  450 + margin-bottom: 28rpx;
  451 + position: relative;
  452 + .title { font-size: 36rpx; font-weight: 600; line-height: 50rpx; color: rgba(0, 0, 0, 0.9); width: 578rpx; }
  453 + .status {
  454 + position: absolute;
  455 + top: -32rpx;
  456 + right: -12rpx;
  457 + height: 48rpx;
  458 + line-height: 48rpx;
  459 + font-weight: 600;
  460 + color: #fff;
  461 + font-size: 24rpx;
  462 + padding: 0 14rpx;
  463 + border-radius: 6rpx;
  464 + box-sizing: content-box;
  465 +
  466 + &.status_AUDIT { background: $theme-primary; }
  467 + &.status_PASS { background: #2ba471; }
  468 + &.status_REFUSE { background: #d54941; }
  469 + &.status_DRAFT { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); }
  470 + &.status_CANCEL { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); }
  471 + }
  472 + }
  473 + .info-row {
  474 + display: flex;
  475 + align-items: center;
  476 + color: rgba(0, 0, 0, 0.6);
  477 + font-size: 28rpx;
  478 + margin-bottom: 24rpx;
  479 + height: 32rpx;
  480 + &:last-child { margin-bottom: 0; }
  481 + text {
  482 + width: 50%;
  483 + &:last-child {
  484 + color: rgba(0, 0, 0, 0.9);
  485 + width: 50%;
  486 + overflow: hidden;
  487 + text-overflow: ellipsis;
  488 + white-space: nowrap;
  489 + }
  490 + }
  491 + }
  492 +}
  493 +.filter-form {
  494 + .form-item { margin-bottom: 24rpx; }
  495 + .label { margin-bottom: 20rpx; color: rgba(0, 0, 0, 0.9); height: 44rpx; line-height: 44rpx; font-size: 30rpx; }
  496 + .input {
  497 + width: 100%;
  498 + height: 72rpx;
  499 + line-height: 72rpx;
  500 + padding: 0 24rpx;
  501 + border: 1rpx solid #e7e7e7;
  502 + border-radius: 8rpx;
  503 + font-size: 28rpx;
  504 + color: rgba(0, 0, 0, 0.9);
  505 + background: #fff;
  506 + box-sizing: border-box;
  507 + }
  508 + .fake-select {
  509 + height: 72rpx;
  510 + line-height: 72rpx;
  511 + padding: 0 24rpx;
  512 + border: 1rpx solid #e7e7e7;
  513 + border-radius: 8rpx;
  514 + font-size: 28rpx;
  515 + .placeholder { color: #999; }
  516 + .value { color: rgba(0, 0, 0, 0.9); }
  517 + }
  518 +}
  519 +</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(planCodeText) }}</text></view>
  9 + <view class="row"><text class="label">单位</text><text class="value">{{ safeText(form.supplierName) }}</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="!applyList.length" class="empty-tip">暂无明细</view>
  21 + <view v-for="(item, idx) in applyList" :key="'a-' + (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">{{ formatNumber(item.quantity) }}</text></view>
  25 + </view>
  26 + </view>
  27 + </view>
  28 +
  29 + <!-- 详情明细 -->
  30 + <view class="sub-table">
  31 + <view class="sub-header">
  32 + <image class="sub-bar" src="/static/images/title.png" />
  33 + <text class="sub-title">详情明细</text>
  34 + </view>
  35 + <view class="sub-body">
  36 + <view v-if="!detailList.length" class="empty-tip">暂无明细</view>
  37 + <view v-for="(item, idx) in detailList" :key="'d-' + (item.id || idx)" class="card">
  38 + <view class="card-index">第 {{ idx + 1 }} 行</view>
  39 + <view class="row"><text class="label">计划编号</text><text class="value">{{ safeText(item.planCode) }}</text></view>
  40 + <view class="row"><text class="label">品种</text><text class="value">{{ safeText(item.productName) }}</text></view>
  41 + <view class="row"><text class="label">类别</text><text class="value">{{ safeText(item.category) }}</text></view>
  42 + <view class="row"><text class="label">名称</text><text class="value">{{ safeText(item.name) }}</text></view>
  43 + <view class="row"><text class="label">过磅数</text><text class="value">{{ formatNumber(item.weighQuantity) }}</text></view>
  44 + <view class="row"><text class="label">杂率(%)</text><text class="value">{{ formatNumber(item.impurityRate) }}</text></view>
  45 + <view class="row"><text class="label">折斤</text><text class="value">{{ formatNumber(item.foldWeight) }}</text></view>
  46 + <view class="row"><text class="label">退料</text><text class="value">{{ formatNumber(item.returnWeight) }}</text></view>
  47 + <view class="row"><text class="label">入库净重</text><text class="value">{{ formatNumber(item.netWeight) }}</text></view>
  48 + <view class="row"><text class="label">备注</text><text class="value">{{ safeText(item.remark) }}</text></view>
  49 + </view>
  50 + </view>
  51 + </view>
  52 +
  53 + <!-- 其他信息 -->
  54 + <view class="title-header">
  55 + <image class="title-header_icon" src="/static/images/title.png" />
  56 + <span>其他信息</span>
  57 + </view>
  58 + <view class="total-card">
  59 + <view class="total-title">合计</view>
  60 + <view class="total-body">
  61 + <view class="total-item">
  62 + <text class="total-label">过磅数</text>
  63 + <text class="total-value">{{ formatNumber(form.totalWeighQuantity) }}</text>
  64 + </view>
  65 + <view class="total-item">
  66 + <text class="total-label">折斤</text>
  67 + <text class="total-value">{{ formatNumber(form.totalFoldWeight) }}</text>
  68 + </view>
  69 + <view class="total-item">
  70 + <text class="total-label">退料</text>
  71 + <text class="total-value">{{ formatNumber(form.totalReturnWeight) }}</text>
  72 + </view>
  73 + <view class="total-item">
  74 + <text class="total-label">入库净重</text>
  75 + <text class="total-value">{{ formatNumber(form.totalNetWeight) }}</text>
  76 + </view>
  77 + </view>
  78 + </view>
  79 + <view class="section">
  80 + <view class="row"><text class="label">类型</text><text class="value">{{ settleTypeName }}</text></view>
  81 + </view>
  82 + <view class="section">
  83 + <text class="remark-text">{{ safeText(form.remark) }}</text>
  84 + </view>
  85 + </scroll-view>
  86 + </view>
  87 +</template>
  88 +
  89 +<script>
  90 +import { materialSettleDetailApi } from '@/api/procure-manage/materialSettlement.js'
  91 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  92 +
  93 +export default {
  94 + name: 'MaterialSettlementViewer',
  95 + props: { id: { type: [String, Number], default: '' } },
  96 + data() {
  97 + return {
  98 + form: {},
  99 + applyList: [],
  100 + detailList: [],
  101 + dicOptions: {
  102 + SETTLE_TYPE: []
  103 + }
  104 + }
  105 + },
  106 + computed: {
  107 + settleTypeName() {
  108 + const v = this.form.settleType == null ? '' : String(this.form.settleType)
  109 + if (!v) return '-'
  110 + return getDicName('SETTLE_TYPE', v, this.dicOptions.SETTLE_TYPE) || v
  111 + },
  112 + planCodeText() {
  113 + const codes = Array.from(new Set((this.detailList || []).map(it => it.planCode).filter(Boolean)))
  114 + return codes.join(',')
  115 + }
  116 + },
  117 + created() {
  118 + this.loadDicData()
  119 + },
  120 + watch: {
  121 + id: {
  122 + immediate: true,
  123 + handler(val) {
  124 + const v = (val !== undefined && val !== null) ? String(val) : ''
  125 + if (v) this.loadDetail(v)
  126 + }
  127 + }
  128 + },
  129 + methods: {
  130 + async loadDicData() {
  131 + try {
  132 + const results = await getDicByCodes(['SETTLE_TYPE'])
  133 + this.dicOptions.SETTLE_TYPE = (results.SETTLE_TYPE && results.SETTLE_TYPE.data) || []
  134 + } catch (e) {
  135 + this.dicOptions = { SETTLE_TYPE: [] }
  136 + }
  137 + },
  138 + loadDetail(id) {
  139 + materialSettleDetailApi({ id })
  140 + .then(res => {
  141 + const data = res && res.data ? (res.data.data || res.data) : {}
  142 + this.form = Object.assign({}, data)
  143 + this.applyList = Array.isArray(data.applyLines) ? data.applyLines.map(x => ({ ...x })) : []
  144 + this.detailList = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : []
  145 + })
  146 + .catch(() => {
  147 + uni.showToast({ title: '详情加载失败', icon: 'none' })
  148 + })
  149 + },
  150 + // 供流程审核页获取业务表单数据(variables)
  151 + getFormValues() {
  152 + return this.form
  153 + },
  154 + safeText(v) {
  155 + const s = v == null ? '' : String(v)
  156 + return s.trim() ? s : '-'
  157 + },
  158 + formatNumber(v) {
  159 + if (v === null || v === undefined || v === '') return '-'
  160 + const n = Number(v)
  161 + if (isNaN(n)) return String(v)
  162 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  163 + }
  164 + }
  165 +}
  166 +</script>
  167 +
  168 +<style lang="scss" scoped>
  169 +.detail-page {
  170 + background: #f3f3f3;
  171 + min-height: 100%;
  172 +}
  173 +.scroll {
  174 + flex: 1;
  175 + padding: 8rpx 0;
  176 +}
  177 +.section {
  178 + padding: 32rpx;
  179 + background: #fff;
  180 + margin-bottom: 20rpx;
  181 +}
  182 +.title-header {
  183 + display: flex;
  184 + align-items: center;
  185 + padding: 24rpx 32rpx 12rpx;
  186 + background-color: #ffffff;
  187 + .title-header_icon { width: 36rpx; height: 36rpx; margin-right: 12rpx; }
  188 + span { font-size: 34rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); }
  189 +}
  190 +.row {
  191 + display: flex;
  192 + margin-bottom: 28rpx;
  193 + &:last-child { margin-bottom: 0; }
  194 + &.company {
  195 + font-size: 36rpx;
  196 + font-weight: 600;
  197 + color: rgba(0, 0, 0, 0.9);
  198 + padding-top: 8rpx;
  199 + line-height: 50rpx;
  200 + }
  201 + .label {
  202 + max-width: 420rpx;
  203 + margin-right: 20rpx;
  204 + line-height: 32rpx;
  205 + font-size: 28rpx;
  206 + color: rgba(0, 0, 0, 0.6);
  207 + }
  208 + .value {
  209 + flex: 1;
  210 + line-height: 32rpx;
  211 + font-size: 28rpx;
  212 + color: rgba(0, 0, 0, 0.9);
  213 + text-align: right;
  214 + word-break: break-all;
  215 + }
  216 +}
  217 +.remark-text {
  218 + font-size: 28rpx;
  219 + color: rgba(0, 0, 0, 0.9);
  220 + line-height: 1.6;
  221 + white-space: pre-wrap;
  222 +}
  223 +.total-card {
  224 + background: #fff;
  225 + margin-bottom: 20rpx;
  226 + padding: 24rpx 32rpx;
  227 + .total-title {
  228 + font-size: 32rpx;
  229 + font-weight: 600;
  230 + color: rgba(0, 0, 0, 0.9);
  231 + margin-bottom: 20rpx;
  232 + }
  233 + .total-body {
  234 + display: flex;
  235 + flex-wrap: wrap;
  236 + .total-item {
  237 + width: 50%;
  238 + display: flex;
  239 + align-items: center;
  240 + margin-bottom: 20rpx;
  241 + &:nth-last-child(-n + 2) { margin-bottom: 0; }
  242 + .total-label {
  243 + font-size: 28rpx;
  244 + color: rgba(0, 0, 0, 0.6);
  245 + margin-right: 16rpx;
  246 + }
  247 + .total-value {
  248 + font-size: 28rpx;
  249 + color: rgba(0, 0, 0, 0.9);
  250 + font-weight: 500;
  251 + }
  252 + }
  253 + }
  254 +}
  255 +.sub-table {
  256 + background: #fff;
  257 + margin-bottom: 20rpx;
  258 +}
  259 +.sub-header {
  260 + display: flex;
  261 + align-items: center;
  262 + padding: 16rpx 0 16rpx 32rpx;
  263 + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; }
  264 + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; }
  265 +}
  266 +.sub-body {
  267 + padding: 0 32rpx 24rpx;
  268 + .empty-tip {
  269 + text-align: center;
  270 + padding: 60rpx 0;
  271 + color: rgba(0, 0, 0, 0.4);
  272 + font-size: 28rpx;
  273 + }
  274 + .card {
  275 + position: relative;
  276 + background: #fafafa;
  277 + border-radius: 12rpx;
  278 + padding: 32rpx 28rpx 20rpx;
  279 + margin-bottom: 24rpx;
  280 + .card-index {
  281 + position: absolute;
  282 + top: 0;
  283 + right: 0;
  284 + background: rgba(24, 144, 255, 0.08);
  285 + color: $theme-primary;
  286 + font-size: 22rpx;
  287 + line-height: 36rpx;
  288 + padding: 0 16rpx;
  289 + border-bottom-left-radius: 12rpx;
  290 + border-top-right-radius: 12rpx;
  291 + }
  292 + .row {
  293 + align-items: center;
  294 + justify-content: space-between;
  295 + padding: 14rpx 0;
  296 + margin-bottom: 0;
  297 + border-bottom: 1rpx dashed #f2f2f2;
  298 + &:last-child { border-bottom: none; }
  299 + .label {
  300 + flex-shrink: 0;
  301 + width: 220rpx;
  302 + max-width: none;
  303 + margin-right: 0;
  304 + font-size: 28rpx;
  305 + color: rgba(0, 0, 0, 0.6);
  306 + line-height: 40rpx;
  307 + }
  308 + .value {
  309 + flex: 1;
  310 + text-align: right;
  311 + font-size: 28rpx;
  312 + color: rgba(0, 0, 0, 0.9);
  313 + line-height: 40rpx;
  314 + overflow: hidden;
  315 + text-overflow: ellipsis;
  316 + white-space: nowrap;
  317 + }
  318 + }
  319 + }
  320 +}
  321 +</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="planCodeText" :inputBorder="false" disabled />
  19 + </template>
  20 + </uni-list-item>
  21 + <uni-list-item title="单位">
  22 + <template v-slot:footer>
  23 + <uni-easyinput :value="form.supplierName" :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="!applyList.length" class="empty-tip">暂无明细</view>
  41 + <view v-for="(item, idx) in applyList" :key="'a-' + (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.quantity" :inputBorder="false" disabled />
  51 + </template>
  52 + </uni-list-item>
  53 + </uni-list>
  54 + </view>
  55 + </view>
  56 + </view>
  57 +
  58 + <!-- 详情明细(可编辑) -->
  59 + <view class="sub-table">
  60 + <view class="header">
  61 + <image class="opCollapse" src="/static/images/title.png" />
  62 + <text class="title">详情明细</text>
  63 + <view class="ops">
  64 + <image class="opAdd" @click="addRow" src="/static/images/plus.png" />
  65 + </view>
  66 + </view>
  67 + <view class="add-list">
  68 + <view v-if="!detailList.length" class="empty-tip">暂无明细,请添加</view>
  69 + <view v-for="(item, idx) in detailList" :key="'d-' + (item.rowId || idx)" class="block">
  70 + <uni-list>
  71 + <!-- 计划编号:插入行选择,原有行只读 -->
  72 + <uni-list-item v-if="!item.brought" class="select-item" :class="item.planCode ? 'is-filled' : 'is-empty'">
  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 + <picker mode="selector" :range="planCodeLabels"
  78 + @change="(e) => handlePlanChange(idx, Number(e.detail.value))">
  79 + <view class="picker-value" :class="{ placeholder: !item.planCode }">
  80 + {{ item.planCode || '请选择计划编号' }}
  81 + </view>
  82 + </picker>
  83 + </template>
  84 + </uni-list-item>
  85 + <uni-list-item v-else title="计划编号">
  86 + <template v-slot:footer>
  87 + <uni-easyinput :value="item.planCode" :inputBorder="false" disabled />
  88 + </template>
  89 + </uni-list-item>
  90 +
  91 + <!-- 品种:插入行选择计划后可选,原有行只读 -->
  92 + <uni-list-item v-if="!item.brought" class="select-item" :class="item.productId ? 'is-filled' : 'is-empty'">
  93 + <template v-slot:body>
  94 + <view class="item-title"><text>品种</text></view>
  95 + </template>
  96 + <template v-slot:footer>
  97 + <picker mode="selector" :range="getProductLabels(item)" :disabled="!item.procurementPlanId"
  98 + @change="(e) => handleProductChange(idx, Number(e.detail.value))">
  99 + <view class="picker-value" :class="{ placeholder: !item.productName }">
  100 + {{ item.productName || (item.procurementPlanId ? '请选择品种' : '请先选择计划编号') }}
  101 + </view>
  102 + </picker>
  103 + </template>
  104 + </uni-list-item>
  105 + <uni-list-item v-else title="品种">
  106 + <template v-slot:footer>
  107 + <uni-easyinput :value="item.productName" :inputBorder="false" disabled />
  108 + </template>
  109 + </uni-list-item>
  110 +
  111 + <!-- 类别:插入行未选品种时不可选,其余可选 -->
  112 + <uni-list-item class="select-item" :class="item.category ? 'is-filled' : 'is-empty'">
  113 + <template v-slot:body>
  114 + <view class="item-title"><text>类别</text></view>
  115 + </template>
  116 + <template v-slot:footer>
  117 + <picker v-if="item.brought || item.productId" mode="selector" :range="varietyLabels"
  118 + @change="(e) => handleVarietyChange(idx, Number(e.detail.value))">
  119 + <view class="picker-value" :class="{ placeholder: !item.category }">
  120 + {{ item.category || '请选择类别' }}
  121 + </view>
  122 + </picker>
  123 + <uni-easyinput v-else :value="item.category" :inputBorder="false" disabled placeholder="请先选择品种" />
  124 + </template>
  125 + </uni-list-item>
  126 +
  127 + <!-- 名称:原有行/已选品种只读 -->
  128 + <uni-list-item title="名称">
  129 + <template v-slot:footer>
  130 + <uni-easyinput v-if="!item.brought && !item.productId" v-model="item.name" :inputBorder="false" placeholder="请输入名称" />
  131 + <uni-easyinput v-else :value="item.name" :inputBorder="false" disabled />
  132 + </template>
  133 + </uni-list-item>
  134 +
  135 + <uni-list-item title="过磅数">
  136 + <template v-slot:footer>
  137 + <uni-easyinput :value="item.weighQuantity" :inputBorder="false" disabled />
  138 + </template>
  139 + </uni-list-item>
  140 + <uni-list-item title="杂率(%)">
  141 + <template v-slot:footer>
  142 + <uni-easyinput v-model="item.impurityRate" type="digit" :inputBorder="false" placeholder="请输入杂率" />
  143 + </template>
  144 + </uni-list-item>
  145 + <uni-list-item title="折斤">
  146 + <template v-slot:footer>
  147 + <uni-easyinput v-model="item.foldWeight" type="digit" :inputBorder="false" placeholder="请输入折斤" />
  148 + </template>
  149 + </uni-list-item>
  150 + <uni-list-item title="退料">
  151 + <template v-slot:footer>
  152 + <uni-easyinput v-model="item.returnWeight" type="digit" :inputBorder="false" placeholder="请输入退料" />
  153 + </template>
  154 + </uni-list-item>
  155 + <uni-list-item title="入库净重">
  156 + <template v-slot:footer>
  157 + <uni-easyinput v-model="item.netWeight" type="digit" :inputBorder="false" placeholder="请输入入库净重" />
  158 + </template>
  159 + </uni-list-item>
  160 + <uni-list-item title="备注">
  161 + <template v-slot:footer>
  162 + <uni-easyinput v-model="item.remark" :inputBorder="false" placeholder="请输入备注" />
  163 + </template>
  164 + </uni-list-item>
  165 + </uni-list>
  166 + <view class="block-ops">
  167 + <div class="toggle" @click="insertRow(idx)">
  168 + <image src="/static/images/plus.png" class="icon" />插入
  169 + </div>
  170 + <div v-if="!item.brought" class="del" @click="delRow(idx)">
  171 + <image src="/static/images/delete.png" class="icon" />删除
  172 + </div>
  173 + </view>
  174 + </view>
  175 + </view>
  176 + </view>
  177 +
  178 + <!-- 合计 -->
  179 + <view class="total-card">
  180 + <view class="total-title">合计</view>
  181 + <view class="total-body">
  182 + <view class="total-item">
  183 + <text class="total-label">过磅数</text>
  184 + <text class="total-value">{{ totalSummary.totalWeighQuantity || '-' }}</text>
  185 + </view>
  186 + <view class="total-item">
  187 + <text class="total-label">折斤</text>
  188 + <text class="total-value">{{ totalSummary.totalFoldWeight || '-' }}</text>
  189 + </view>
  190 + <view class="total-item">
  191 + <text class="total-label">退料</text>
  192 + <text class="total-value">{{ totalSummary.totalReturnWeight || '-' }}</text>
  193 + </view>
  194 + <view class="total-item">
  195 + <text class="total-label">入库净重</text>
  196 + <text class="total-value">{{ totalSummary.totalNetWeight || '-' }}</text>
  197 + </view>
  198 + </view>
  199 + </view>
  200 +
  201 + <!-- 其他信息 -->
  202 + <view class="remark-section">
  203 + <view class="header">
  204 + <image class="opCollapse" src="/static/images/title.png" />
  205 + <text class="title">其他信息</text>
  206 + </view>
  207 + <view class="section-content">
  208 + <uni-list>
  209 + <uni-list-item class="select-item" :class="form.settleType ? 'is-filled' : 'is-empty'">
  210 + <template v-slot:body>
  211 + <view class="item-title"><text class="required">*</text><text>类型</text></view>
  212 + </template>
  213 + <template v-slot:footer>
  214 + <picker mode="selector" :range="settleTypeLabels" @change="onSettleTypeChange">
  215 + <view class="picker-value" :class="{ placeholder: !form.settleType }">
  216 + {{ settleTypeName || '请选择类型' }}
  217 + </view>
  218 + </picker>
  219 + </template>
  220 + </uni-list-item>
  221 + </uni-list>
  222 + <view class="remark-group">
  223 + <view class="remark-label">备注</view>
  224 + <uni-easyinput v-model="form.remark" type="textarea" :inputBorder="false" placeholder="请输入备注" maxlength="2000" autoHeight />
  225 + </view>
  226 + </view>
  227 + </view>
  228 +
  229 + <view class="footer">
  230 + <button class="btn submit" type="primary" @click="onSubmit">保存</button>
  231 + </view>
  232 + </scroll-view>
  233 + </view>
  234 +</template>
  235 +
  236 +<script>
  237 +import {
  238 + materialSettleDetailApi,
  239 + materialSettlePlanOptionsApi,
  240 + materialSettlePlanLineOptionsApi,
  241 + materialSettleUpdateApi,
  242 + productVarietyQueryApi
  243 +} from '@/api/procure-manage/materialSettlement.js'
  244 +import { getDicByCodes } from '@/utils/dic.js'
  245 +
  246 +export default {
  247 + name: 'ModifyMaterialSettlement',
  248 + data() {
  249 + return {
  250 + id: '',
  251 + form: {
  252 + id: '',
  253 + weighingTicketId: '',
  254 + weighingTicketCode: '',
  255 + ticketDate: '',
  256 + supplierName: '',
  257 + workshopName: '',
  258 + settleType: '',
  259 + remark: ''
  260 + },
  261 + dicOptions: { SETTLE_TYPE: [] },
  262 + // 申请净重明细(只读)
  263 + applyList: [],
  264 + // 详情明细(原有行只读,新插入行可编辑)
  265 + detailList: [],
  266 + // 计划编号下拉选项(当前码单可选计划)
  267 + planOptions: [],
  268 + // 品种(类别)下拉选项
  269 + varietyOptions: []
  270 + }
  271 + },
  272 + computed: {
  273 + settleTypeLabels() {
  274 + return (this.dicOptions.SETTLE_TYPE || []).map(it => it.name)
  275 + },
  276 + settleTypeName() {
  277 + const found = (this.dicOptions.SETTLE_TYPE || []).find(it => String(it.code) === String(this.form.settleType))
  278 + return found ? found.name : ''
  279 + },
  280 + planCodeText() {
  281 + const codes = Array.from(new Set((this.detailList || []).map(it => it.planCode).filter(Boolean)))
  282 + return codes.join(',')
  283 + },
  284 + planCodeLabels() {
  285 + return this.planOptions.map(o => o.label)
  286 + },
  287 + varietyLabels() {
  288 + return (this.varietyOptions || []).map(item =>
  289 + [item.productName, item.code].filter(Boolean).join(' ')
  290 + )
  291 + },
  292 + // 详情明细各数值列合计(过磅数/折斤/入库净重保留两位小数,退料取整)
  293 + totalSummary() {
  294 + const list = this.detailList || []
  295 + const sum = (field, fixed) => Number(
  296 + list.reduce((acc, row) => acc + Number(row[field] || 0), 0).toFixed(fixed)
  297 + )
  298 + return {
  299 + totalWeighQuantity: sum('weighQuantity', 2),
  300 + totalFoldWeight: sum('foldWeight', 2),
  301 + totalReturnWeight: sum('returnWeight', 0),
  302 + totalNetWeight: sum('netWeight', 2)
  303 + }
  304 + }
  305 + },
  306 + onLoad(query) {
  307 + this.id = (query && query.id) || ''
  308 + this.loadDicData()
  309 + this.loadVarietyOptions()
  310 + this.loadDetail()
  311 + },
  312 + methods: {
  313 + async loadDicData() {
  314 + try {
  315 + const results = await getDicByCodes(['SETTLE_TYPE'])
  316 + this.dicOptions.SETTLE_TYPE = (results.SETTLE_TYPE && results.SETTLE_TYPE.data) || []
  317 + } catch (e) {
  318 + this.dicOptions = { SETTLE_TYPE: [] }
  319 + }
  320 + },
  321 + async loadVarietyOptions() {
  322 + try {
  323 + const res = await productVarietyQueryApi({ pageIndex: 1, pageSize: 9999 })
  324 + const _data = (res && res.data) || {}
  325 + this.varietyOptions = _data.datas || _data.list || _data.records || []
  326 + } catch (e) {
  327 + this.varietyOptions = []
  328 + }
  329 + },
  330 + onSettleTypeChange(e) {
  331 + const idx = Number(e.detail.value)
  332 + const opt = (this.dicOptions.SETTLE_TYPE || [])[idx]
  333 + this.form.settleType = opt && opt.code != null ? String(opt.code) : ''
  334 + },
  335 + loadDetail() {
  336 + if (!this.id) {
  337 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  338 + return
  339 + }
  340 + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true })
  341 + materialSettleDetailApi({ id: this.id })
  342 + .then(res => {
  343 + const data = res && res.data ? (res.data.data || res.data) : {}
  344 + this.form = {
  345 + id: data.id || this.id,
  346 + weighingTicketId: data.weighingTicketId || '',
  347 + weighingTicketCode: data.weighingTicketCode || '',
  348 + ticketDate: data.ticketDate || '',
  349 + supplierName: data.supplierName || '',
  350 + workshopName: data.workshopName || '',
  351 + settleType: data.settleType || '',
  352 + remark: data.remark || ''
  353 + }
  354 + // 申请净重明细回显(只读)
  355 + this.applyList = (data.applyLines || []).map(item => ({
  356 + rowId: genRowId(),
  357 + weighingTicketApplyLineId: item.weighingTicketApplyLineId || item.id || '',
  358 + category: item.category || '',
  359 + breedRelationshipId: item.breedRelationshipId || '',
  360 + quantity: item.quantity == null ? '' : item.quantity
  361 + }))
  362 + // 详情明细回显(原有行只读,不可删除)
  363 + this.detailList = (data.lines || []).map(item => ({
  364 + rowId: genRowId(),
  365 + brought: true,
  366 + procurementPlanId: item.procurementPlanId || '',
  367 + planCode: item.planCode || '',
  368 + productId: item.productId || '',
  369 + productName: item.productName || '',
  370 + category: item.category || '',
  371 + breedRelationshipId: item.breedRelationshipId || '',
  372 + name: item.name || '',
  373 + weighQuantity: item.weighQuantity == null ? '' : item.weighQuantity,
  374 + impurityRate: item.impurityRate == null ? '' : item.impurityRate,
  375 + foldWeight: item.foldWeight == null ? '' : item.foldWeight,
  376 + returnWeight: item.returnWeight == null ? '' : item.returnWeight,
  377 + netWeight: item.netWeight == null ? '' : item.netWeight,
  378 + remark: item.remark || ''
  379 + }))
  380 + // 加载当前码单可选计划下拉(供新插入行使用)
  381 + this.loadPlanOptions(this.form.weighingTicketId)
  382 + })
  383 + .catch(() => {
  384 + uni.showToast({ title: '详情加载失败', icon: 'none' })
  385 + })
  386 + .finally(() => {
  387 + uni.hideLoading && uni.hideLoading()
  388 + })
  389 + },
  390 + loadPlanOptions(ticketId) {
  391 + if (!ticketId) {
  392 + this.planOptions = []
  393 + return
  394 + }
  395 + materialSettlePlanOptionsApi({ ticketId })
  396 + .then(res => {
  397 + const list = (res && res.data) || []
  398 + this.planOptions = (list || []).map(item => ({
  399 + label: item.planCode || '',
  400 + value: item.planId || item.id || ''
  401 + }))
  402 + })
  403 + .catch(() => {
  404 + this.planOptions = []
  405 + })
  406 + },
  407 + // 计划编号改选:重置品种与类别带出并加载该计划下可选品种
  408 + handlePlanChange(idx, optIdx) {
  409 + const opt = this.planOptions[optIdx]
  410 + if (!opt) return
  411 + const row = this.detailList[idx]
  412 + row.procurementPlanId = opt.value
  413 + row.planCode = opt.label
  414 + row.productId = ''
  415 + row.productName = ''
  416 + row.name = ''
  417 + row.weighQuantity = ''
  418 + row.category = ''
  419 + row.breedRelationshipId = ''
  420 + row.productOptions = []
  421 + materialSettlePlanLineOptionsApi({ planId: opt.value })
  422 + .then(res => {
  423 + const list = (res && res.data) || []
  424 + row.productOptions = (list || []).map(line => ({
  425 + label: line.productName || '',
  426 + value: line.productId || '',
  427 + name: line.name || '',
  428 + weighQuantity: line.weighQuantity == null ? (line.quantity == null ? '' : line.quantity) : line.weighQuantity,
  429 + category: line.category || '',
  430 + breedRelationshipId: line.breedRelationshipId || ''
  431 + }))
  432 + })
  433 + .catch(() => {
  434 + row.productOptions = []
  435 + })
  436 + },
  437 + getProductLabels(item) {
  438 + return (item.productOptions || []).map(o => o.label)
  439 + },
  440 + // 品种改选:带出名称、过磅数与类别;清空时同步清空带出数据
  441 + handleProductChange(idx, optIdx) {
  442 + const row = this.detailList[idx]
  443 + const item = (row.productOptions || [])[optIdx]
  444 + if (!item) {
  445 + row.productName = ''
  446 + row.name = ''
  447 + row.weighQuantity = ''
  448 + row.category = ''
  449 + row.breedRelationshipId = ''
  450 + return
  451 + }
  452 + row.productId = item.value
  453 + row.productName = item.label
  454 + row.name = item.name || ''
  455 + row.weighQuantity = item.weighQuantity == null ? '' : item.weighQuantity
  456 + row.category = item.category || ''
  457 + row.breedRelationshipId = item.breedRelationshipId || ''
  458 + },
  459 + // 类别改选:category=code,breedRelationshipId=id
  460 + handleVarietyChange(idx, optIdx) {
  461 + const raw = (this.varietyOptions || [])[optIdx]
  462 + if (!raw) return
  463 + const row = this.detailList[idx]
  464 + row.category = raw.code || ''
  465 + row.breedRelationshipId = raw.id || ''
  466 + },
  467 + // 新增空行
  468 + addRow() {
  469 + this.detailList.push(this.createRow())
  470 + },
  471 + // 在当前行下方插入空行
  472 + insertRow(idx) {
  473 + this.detailList.splice(idx + 1, 0, this.createRow())
  474 + },
  475 + // 删除行(仅插入行可删除)
  476 + delRow(idx) {
  477 + this.detailList.splice(idx, 1)
  478 + },
  479 + // 构造空行
  480 + createRow() {
  481 + return {
  482 + rowId: genRowId(),
  483 + brought: false,
  484 + procurementPlanId: '',
  485 + planCode: '',
  486 + productId: '',
  487 + productName: '',
  488 + category: '',
  489 + breedRelationshipId: '',
  490 + name: '',
  491 + weighQuantity: '',
  492 + impurityRate: '',
  493 + foldWeight: '',
  494 + returnWeight: '',
  495 + netWeight: '',
  496 + remark: '',
  497 + productOptions: []
  498 + }
  499 + },
  500 + validate() {
  501 + if (!this.form.settleType) return this.tip('请选择类型')
  502 + return true
  503 + },
  504 + tip(msg) {
  505 + uni.showToast({ title: msg, icon: 'none' })
  506 + return false
  507 + },
  508 + buildSubmitData() {
  509 + const t = this.totalSummary
  510 + return {
  511 + id: this.form.id,
  512 + weighingTicketId: this.form.weighingTicketId,
  513 + settleType: this.form.settleType,
  514 + totalWeighQuantity: String(t.totalWeighQuantity),
  515 + totalFoldWeight: String(t.totalFoldWeight),
  516 + totalReturnWeight: String(t.totalReturnWeight),
  517 + totalNetWeight: String(t.totalNetWeight),
  518 + remark: this.form.remark || '',
  519 + // 申请净重明细
  520 + applyLines: (this.applyList || []).map(item => ({
  521 + weighingTicketApplyLineId: item.weighingTicketApplyLineId || '',
  522 + category: item.category || '',
  523 + breedRelationshipId: item.breedRelationshipId || '',
  524 + quantity: item.quantity == null ? '' : String(item.quantity),
  525 + itemId: item.breedRelationshipId || ''
  526 + })),
  527 + // 详情明细
  528 + lines: (this.detailList || []).map(item => ({
  529 + procurementPlanId: item.procurementPlanId || '',
  530 + planCode: item.planCode || '',
  531 + productId: item.productId || '',
  532 + category: item.category || '',
  533 + name: item.name || '',
  534 + weighQuantity: item.weighQuantity == null ? '' : String(item.weighQuantity),
  535 + impurityRate: item.impurityRate == null ? '' : String(item.impurityRate),
  536 + foldWeight: item.foldWeight == null ? '' : String(item.foldWeight),
  537 + returnWeight: item.returnWeight == null ? '' : String(item.returnWeight),
  538 + netWeight: item.netWeight == null ? '' : String(item.netWeight),
  539 + remark: item.remark || '',
  540 + itemId: item.breedRelationshipId || ''
  541 + }))
  542 + }
  543 + },
  544 + async onSubmit() {
  545 + if (!this.validate()) return
  546 + const confirmRes = await new Promise(resolve => {
  547 + uni.showModal({ title: '提示', content: '确定保存原料结算详情单吗?', confirmText: '确定', cancelText: '取消', success: resolve })
  548 + })
  549 + if (!(confirmRes && confirmRes.confirm)) return
  550 + uni.showLoading({ title: '提交中...', mask: true })
  551 + materialSettleUpdateApi(this.buildSubmitData())
  552 + .then(() => {
  553 + uni.hideLoading()
  554 + uni.showToast({ title: '保存成功', icon: 'none' })
  555 + try {
  556 + uni.setStorageSync('MATERIAL_SETTLEMENT_LIST_NEED_REFRESH', '1')
  557 + uni.setStorageSync('MATERIAL_SETTLEMENT_DETAIL_NEED_REFRESH', '1')
  558 + } catch (e) {}
  559 + setTimeout(() => { uni.navigateBack() }, 400)
  560 + })
  561 + .catch(e => {
  562 + uni.hideLoading()
  563 + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' })
  564 + })
  565 + }
  566 + }
  567 +}
  568 +
  569 +// 生成前端临时行 id
  570 +function genRowId() {
  571 + return 'row_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8)
  572 +}
  573 +</script>
  574 +
  575 +<style lang="scss" scoped>
  576 +.page {
  577 + display: flex;
  578 + flex-direction: column;
  579 + height: 100%;
  580 +}
  581 +
  582 +.scroll {
  583 + flex: 1;
  584 + padding: 12rpx 0 200rpx !important;
  585 +}
  586 +
  587 +.footer {
  588 + z-index: 2;
  589 + position: fixed;
  590 + left: 0;
  591 + right: 0;
  592 + bottom: 0;
  593 + padding: 32rpx;
  594 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  595 + background: #fff;
  596 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  597 +
  598 + .btn {
  599 + height: 80rpx;
  600 + line-height: 80rpx;
  601 + border-radius: 12rpx;
  602 + font-size: 32rpx;
  603 + }
  604 +
  605 + .submit {
  606 + background: $theme-primary;
  607 + color: #fff;
  608 + }
  609 +}
  610 +
  611 +::v-deep .uni-list {
  612 + .uni-easyinput {
  613 + display: flex;
  614 +
  615 + .uni-input-input {
  616 + color: rgba(0, 0, 0, 0.9);
  617 + }
  618 + }
  619 +
  620 + .uni-input-placeholder {
  621 + z-index: 1;
  622 + }
  623 +
  624 + .uni-input-input {
  625 + background-color: #ffffff;
  626 + }
  627 +
  628 + background: transparent;
  629 +
  630 + &-item {
  631 + &__extra-text {
  632 + font-size: 32rpx;
  633 + }
  634 +
  635 + &__content-title {
  636 + font-size: 32rpx;
  637 + color: rgba(0, 0, 0, 0.9);
  638 + }
  639 +
  640 + &__container {
  641 + padding: 32rpx;
  642 +
  643 + .uni-easyinput {
  644 + &__placeholder-class {
  645 + font-size: 32rpx;
  646 + color: rgba(0, 0, 0, 0.4);
  647 + }
  648 +
  649 + &__content {
  650 + border: none;
  651 + background-color: #ffffff !important;
  652 +
  653 + &-input {
  654 + padding-left: 0 !important;
  655 + height: 48rpx;
  656 + line-height: 48rpx;
  657 + font-size: 32rpx;
  658 + }
  659 +
  660 + .content-clear-icon {
  661 + font-size: 44rpx !important;
  662 + }
  663 + }
  664 + }
  665 +
  666 + .item-title,
  667 + .uni-list-item__content {
  668 + flex: none;
  669 + min-height: 48rpx;
  670 + line-height: 48rpx;
  671 + font-size: 32rpx;
  672 + position: relative;
  673 + width: 240rpx;
  674 + margin-right: 32rpx;
  675 + color: rgba(0, 0, 0, 0.9);
  676 +
  677 + .required {
  678 + color: red;
  679 + position: absolute;
  680 + top: 50%;
  681 + transform: translateY(-50%);
  682 + left: -16rpx;
  683 + }
  684 + }
  685 + }
  686 +
  687 + &.select-item {
  688 + &.is-empty {
  689 + .uni-list-item__extra-text {
  690 + color: rgba(0, 0, 0, 0.4) !important;
  691 + }
  692 + }
  693 +
  694 + &.is-filled {
  695 + .uni-list-item__extra-text {
  696 + color: rgba(0, 0, 0, 0.9) !important;
  697 + }
  698 + }
  699 + }
  700 + }
  701 +}
  702 +
  703 +.picker-value {
  704 + font-size: 32rpx;
  705 + color: rgba(0, 0, 0, 0.9);
  706 + line-height: 48rpx;
  707 + text-align: right;
  708 + min-height: 48rpx;
  709 +
  710 + &.placeholder {
  711 + color: rgba(0, 0, 0, 0.4);
  712 + }
  713 +}
  714 +
  715 +.sub-table,
  716 +.remark-section {
  717 + margin-top: 20rpx;
  718 + background: #fff;
  719 +}
  720 +
  721 +.header {
  722 + display: flex;
  723 + align-items: center;
  724 + padding: 24rpx 32rpx;
  725 + border-bottom: 1rpx solid #f0f0f0;
  726 +
  727 + .opCollapse {
  728 + width: 32rpx;
  729 + height: 28rpx;
  730 + margin-right: 16rpx;
  731 + margin-top: 8rpx;
  732 + }
  733 +
  734 + .title {
  735 + font-size: 32rpx;
  736 + color: rgba(0, 0, 0, 0.9);
  737 + font-weight: 600;
  738 + flex: 1;
  739 + }
  740 +
  741 + .ops {
  742 + display: flex;
  743 + align-items: center;
  744 +
  745 + .opAdd {
  746 + width: 40rpx;
  747 + height: 40rpx;
  748 + }
  749 + }
  750 +}
  751 +
  752 +.add-list {
  753 + padding: 0 0 16rpx;
  754 +
  755 + .empty-tip {
  756 + text-align: center;
  757 + padding: 60rpx 0;
  758 + color: rgba(0, 0, 0, 0.4);
  759 + font-size: 28rpx;
  760 + }
  761 +
  762 + .block {
  763 + border-bottom: 1rpx solid #f0f0f0;
  764 +
  765 + &:last-child {
  766 + border-bottom: none;
  767 + }
  768 +
  769 + .block-ops {
  770 + display: flex;
  771 + align-items: center;
  772 + justify-content: flex-end;
  773 + gap: 48rpx;
  774 + padding: 20rpx 32rpx;
  775 + background: #f8f8f8;
  776 +
  777 + .del,
  778 + .toggle {
  779 + display: flex;
  780 + align-items: center;
  781 + font-size: 28rpx;
  782 + color: rgba(0, 0, 0, 0.6);
  783 +
  784 + .icon {
  785 + width: 32rpx;
  786 + height: 32rpx;
  787 + margin-right: 8rpx;
  788 + }
  789 + }
  790 +
  791 + .del {
  792 + color: #d54941;
  793 + }
  794 + }
  795 + }
  796 +}
  797 +
  798 +.total-card {
  799 + margin-top: 20rpx;
  800 + background: #fff;
  801 + padding: 24rpx 32rpx;
  802 +
  803 + .total-title {
  804 + font-size: 32rpx;
  805 + font-weight: 600;
  806 + color: rgba(0, 0, 0, 0.9);
  807 + margin-bottom: 20rpx;
  808 + }
  809 +
  810 + .total-body {
  811 + display: flex;
  812 + flex-wrap: wrap;
  813 +
  814 + .total-item {
  815 + width: 50%;
  816 + display: flex;
  817 + align-items: center;
  818 + margin-bottom: 20rpx;
  819 +
  820 + &:nth-last-child(-n + 2) {
  821 + margin-bottom: 0;
  822 + }
  823 +
  824 + .total-label {
  825 + font-size: 28rpx;
  826 + color: rgba(0, 0, 0, 0.6);
  827 + margin-right: 16rpx;
  828 + }
  829 +
  830 + .total-value {
  831 + font-size: 28rpx;
  832 + color: rgba(0, 0, 0, 0.9);
  833 + font-weight: 500;
  834 + }
  835 + }
  836 + }
  837 +}
  838 +
  839 +.section-content {
  840 + padding: 32rpx;
  841 +}
  842 +
  843 +.remark-group {
  844 + margin-top: 8rpx;
  845 +
  846 + .remark-label {
  847 + display: flex;
  848 + align-items: center;
  849 + font-size: 32rpx;
  850 + color: rgba(0, 0, 0, 0.9);
  851 + margin-bottom: 16rpx;
  852 + }
  853 +}
  854 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <!-- 基础信息 -->
  5 + <uni-list>
  6 + <!-- 码单编号(弹窗选择) -->
  7 + <uni-list-item class="select-item" :class="form.weighingTicketCode ? 'is-filled' : 'is-empty'" clickable
  8 + @click="openTicketSheet" :rightText="form.weighingTicketCode || '请选择码单'" showArrow>
  9 + <template v-slot:body>
  10 + <view class="item-title"><text class="required">*</text><text>码单编号</text></view>
  11 + </template>
  12 + </uni-list-item>
  13 +
  14 + <!-- 日期(选择码单后带出) -->
  15 + <uni-list-item class="select-item" :class="form.reportDate ? 'is-filled' : 'is-empty'">
  16 + <template v-slot:body>
  17 + <view class="item-title"><text class="required">*</text><text>日期</text></view>
  18 + </template>
  19 + <template v-slot:footer>
  20 + <view class="picker-value" :class="{ placeholder: !form.reportDate }">
  21 + {{ form.reportDate || '选择码单后带出' }}
  22 + </view>
  23 + </template>
  24 + </uni-list-item>
  25 +
  26 + <!-- 客户名称(选择码单后带出) -->
  27 + <uni-list-item class="select-item" :class="form.supplierName ? 'is-filled' : 'is-empty'">
  28 + <template v-slot:body>
  29 + <view class="item-title"><text class="required">*</text><text>客户名称</text></view>
  30 + </template>
  31 + <template v-slot:footer>
  32 + <view class="picker-value" :class="{ placeholder: !form.supplierName }">
  33 + {{ form.supplierName || '选择码单后带出' }}
  34 + </view>
  35 + </template>
  36 + </uni-list-item>
  37 +
  38 + <!-- 计划编号 -->
  39 + <uni-list-item class="select-item" :class="form.procurementPlanId ? 'is-filled' : 'is-empty'">
  40 + <template v-slot:body>
  41 + <view class="item-title"><text class="required">*</text><text>计划编号</text></view>
  42 + </template>
  43 + <template v-slot:footer>
  44 + <picker mode="selector" :range="planLabels" @change="onPlanChange" :disabled="!planOptions.length">
  45 + <view class="picker-value" :class="{ placeholder: !form.procurementPlanId }">
  46 + {{ getPlanLabel() || '请选择计划编号' }}
  47 + </view>
  48 + </picker>
  49 + </template>
  50 + </uni-list-item>
  51 +
  52 + <!-- 过磅品种 -->
  53 + <uni-list-item class="select-item" :class="form.productId ? 'is-filled' : 'is-empty'">
  54 + <template v-slot:body>
  55 + <view class="item-title"><text class="required">*</text><text>过磅品种</text></view>
  56 + </template>
  57 + <template v-slot:footer>
  58 + <picker mode="selector" :range="productLabels" @change="onProductChange" :disabled="!productOptions.length">
  59 + <view class="picker-value" :class="{ placeholder: !form.productId }">
  60 + {{ getProductLabel() || '请选择过磅品种' }}
  61 + </view>
  62 + </picker>
  63 + </template>
  64 + </uni-list-item>
  65 + </uni-list>
  66 +
  67 + <!-- 化验明细:样品/数量/样号/送样编号 + 成份%(成分项按码单分厂区分) -->
  68 + <AssayDetailTable ref="detailTable" :options="applyDetailOptions" :workshop-code="ticketWorkshopCode" :workshop-name="ticketWorkshopName" />
  69 + </scroll-view>
  70 +
  71 + <view class="footer">
  72 + <button class="btn submit" type="primary" @click="onSubmit">保存</button>
  73 + </view>
  74 +
  75 + <RelateSelectSheet :visible.sync="ticketSheet.visible" title="选择码单" :multiple="false"
  76 + :fetchFn="ticketSheet.fetchFn" :display-fields="ticketSheet.displayFields"
  77 + row-key="id" :selectedKeys.sync="ticketSheet.selectedKeys" @confirm="onTicketConfirm" />
  78 + </view>
  79 +</template>
  80 +
  81 +<script>
  82 +import RelateSelectSheet from '@/components/relate-select/index.vue'
  83 +import AssayDetailTable from './assay-detail-table.vue'
  84 +import {
  85 + assayReportTicketPageApi,
  86 + assayReportPlanOptionsApi,
  87 + assayReportProductOptionsApi,
  88 + assayReportApplyOptionsApi,
  89 + assayReportCreateApi
  90 +} from '@/api/procure-manage/assayReport.js'
  91 +
  92 +export default {
  93 + name: 'AddMaterialTest',
  94 + components: { RelateSelectSheet, AssayDetailTable },
  95 + data() {
  96 + return {
  97 + form: {
  98 + weighingTicketId: '',
  99 + weighingTicketCode: '',
  100 + reportDate: '',
  101 + supplierName: '',
  102 + procurementPlanId: '',
  103 + productId: ''
  104 + },
  105 + // 选中的码单行对象,供回显与分厂成分联动使用
  106 + selectedTicketRow: null,
  107 + // 计划编号下拉选项(所选码单下的计划)
  108 + planOptions: [],
  109 + // 过磅品种下拉选项(所选计划下的品种)
  110 + productOptions: [],
  111 + // 化验明细数据源(applyOptions 返回),供明细子组件送样编号下拉与固定值使用
  112 + applyDetailOptions: [],
  113 + ticketSheet: {
  114 + visible: false,
  115 + fetchFn: null,
  116 + displayFields: [
  117 + { label: '码单编号', field: 'code' },
  118 + { label: '供应商', field: 'supplierName' },
  119 + { label: '分厂', field: 'workshopName' },
  120 + { label: '创建人', field: 'createBy' },
  121 + { label: '完成时间', field: 'completeTime' }
  122 + ],
  123 + selectedKeys: []
  124 + }
  125 + }
  126 + },
  127 + computed: {
  128 + // 码单分厂编码/名称,决定化验明细成份项集合
  129 + ticketWorkshopCode() {
  130 + return (this.selectedTicketRow && this.selectedTicketRow.workshopCode) || ''
  131 + },
  132 + ticketWorkshopName() {
  133 + return (this.selectedTicketRow && this.selectedTicketRow.workshopName) || ''
  134 + },
  135 + planLabels() {
  136 + return (this.planOptions || []).map(it => it.label)
  137 + },
  138 + productLabels() {
  139 + return (this.productOptions || []).map(it => it.label)
  140 + }
  141 + },
  142 + created() {
  143 + this.ticketSheet.fetchFn = this.fetchTickets.bind(this)
  144 + },
  145 + methods: {
  146 + // 码单选择弹窗数据源(可选过磅码单分页,合并筛选条件)
  147 + fetchTickets({ pageIndex, pageSize, extra }) {
  148 + const keyword = (extra && extra.keyword) || ''
  149 + const params = {
  150 + pageIndex,
  151 + pageSize,
  152 + code: keyword || undefined
  153 + }
  154 + return assayReportTicketPageApi(params).then(res => {
  155 + const _data = (res && res.data) || {}
  156 + const records = _data.datas || _data.list || _data.records || []
  157 + const totalCount = _data.totalCount || _data.count || 0
  158 + const hasNext = _data.hasNext || false
  159 + return { records, totalCount, hasNext }
  160 + }).catch(() => ({ records: [], totalCount: 0, hasNext: false }))
  161 + },
  162 + openTicketSheet() {
  163 + this.ticketSheet.selectedKeys = this.form.weighingTicketId ? [this.form.weighingTicketId] : []
  164 + this.ticketSheet.visible = true
  165 + },
  166 + // 码单选择回调:带出日期/客户名称,联动刷新计划编号下拉、按分厂刷新成分表格
  167 + onTicketConfirm({ items }) {
  168 + const row = (items || [])[0]
  169 + if (!row) {
  170 + this.selectedTicketRow = null
  171 + this.form.weighingTicketId = ''
  172 + this.form.weighingTicketCode = ''
  173 + this.form.reportDate = ''
  174 + this.form.supplierName = ''
  175 + this.resetDownStream()
  176 + return
  177 + }
  178 + this.selectedTicketRow = row
  179 + this.form.weighingTicketId = row.id || ''
  180 + this.form.weighingTicketCode = row.code || ''
  181 + // 选择码单后带出日期与客户名称
  182 + this.form.reportDate = String(row.completeTime || '').slice(0, 10)
  183 + this.form.supplierName = row.supplierName || ''
  184 + // 切换码单后重置计划编号、品种及化验明细(成分项随分厂名变化由明细子组件自动刷新)
  185 + this.resetDownStream()
  186 + this.loadPlanOptions(row.id)
  187 + },
  188 + resetDownStream() {
  189 + this.form.procurementPlanId = ''
  190 + this.form.productId = ''
  191 + this.planOptions = []
  192 + this.productOptions = []
  193 + this.applyDetailOptions = []
  194 + const detailTable = this.$refs.detailTable
  195 + detailTable && detailTable.setRows && detailTable.setRows([])
  196 + },
  197 + // 根据所选码单加载计划编号下拉选项
  198 + loadPlanOptions(ticketId) {
  199 + assayReportPlanOptionsApi(ticketId)
  200 + .then(res => {
  201 + const list = (res && res.data) || []
  202 + this.planOptions = (list || []).map(item => ({
  203 + label: item.planCode,
  204 + value: item.planId
  205 + }))
  206 + })
  207 + .catch(() => {
  208 + this.planOptions = []
  209 + })
  210 + },
  211 + getPlanLabel() {
  212 + const found = (this.planOptions || []).find(it => it.value === this.form.procurementPlanId)
  213 + return found ? found.label : ''
  214 + },
  215 + // 计划编号改选后:重置品种并按所选计划刷新过磅品种下拉
  216 + onPlanChange(e) {
  217 + const opt = (this.planOptions || [])[Number(e.detail.value)]
  218 + if (!opt) return
  219 + this.form.procurementPlanId = opt.value
  220 + this.form.productId = ''
  221 + this.productOptions = []
  222 + this.applyDetailOptions = []
  223 + const detailTable = this.$refs.detailTable
  224 + detailTable && detailTable.setRows && detailTable.setRows([])
  225 + assayReportProductOptionsApi({
  226 + ticketId: this.form.weighingTicketId || undefined,
  227 + planId: opt.value
  228 + })
  229 + .then(res => {
  230 + const list = (res && res.data) || []
  231 + this.productOptions = (list || []).map(item => ({
  232 + label: item.productName,
  233 + value: item.productId
  234 + }))
  235 + })
  236 + .catch(() => {
  237 + this.productOptions = []
  238 + })
  239 + },
  240 + getProductLabel() {
  241 + const found = (this.productOptions || []).find(it => it.value === this.form.productId)
  242 + return found ? found.label : ''
  243 + },
  244 + // 过磅品种改选后:按码单/计划/品种加载化验明细并填充表格
  245 + onProductChange(e) {
  246 + const opt = (this.productOptions || [])[Number(e.detail.value)]
  247 + if (!opt) return
  248 + this.form.productId = opt.value
  249 + this.applyDetailOptions = []
  250 + const detailTable = this.$refs.detailTable
  251 + detailTable && detailTable.setRows && detailTable.setRows([])
  252 + this.loadApplyDetail()
  253 + },
  254 + // 加载化验明细数据
  255 + loadApplyDetail() {
  256 + assayReportApplyOptionsApi({
  257 + ticketId: this.form.weighingTicketId || undefined,
  258 + planId: this.form.procurementPlanId || undefined,
  259 + productId: this.form.productId || undefined
  260 + })
  261 + .then(res => {
  262 + const list = (res && res.data) || []
  263 + this.applyDetailOptions = (list || []).map(item => ({
  264 + assayApplyId: item.assayApplyId || item.id || '',
  265 + assayApplyCode: item.assayApplyCode || '',
  266 + productName: item.productName || '',
  267 + category: item.category || '',
  268 + productId: item.productId || '',
  269 + quantity: item.quantity
  270 + }))
  271 + // 默认按化验明细填充表格,样号从1开始编号
  272 + const detailTable = this.$refs.detailTable
  273 + detailTable && detailTable.loadRows && detailTable.loadRows(this.applyDetailOptions)
  274 + })
  275 + .catch(() => {
  276 + this.applyDetailOptions = []
  277 + })
  278 + },
  279 + validate() {
  280 + const f = this.form
  281 + if (!f.weighingTicketId) return this.tip('请选择码单编号')
  282 + if (!f.reportDate) return this.tip('日期不能为空')
  283 + if (!f.procurementPlanId) return this.tip('请选择计划编号')
  284 + if (!f.productId) return this.tip('请选择过磅品种')
  285 + return true
  286 + },
  287 + tip(msg) {
  288 + uni.showToast({ title: msg, icon: 'none' })
  289 + return false
  290 + },
  291 + async onSubmit() {
  292 + if (!this.validate()) return
  293 + const confirmRes = await new Promise(resolve => {
  294 + uni.showModal({ title: '提示', content: '确定保存原料化验报告单吗?', confirmText: '确定', cancelText: '取消', success: resolve })
  295 + })
  296 + if (!(confirmRes && confirmRes.confirm)) return
  297 + const detailTable = this.$refs.detailTable
  298 + const lines = (detailTable && detailTable.getLines && detailTable.getLines()) || []
  299 + uni.showLoading({ title: '提交中...', mask: true })
  300 + assayReportCreateApi({
  301 + weighingTicketId: this.form.weighingTicketId,
  302 + reportDate: this.form.reportDate,
  303 + procurementPlanId: this.form.procurementPlanId,
  304 + productId: this.form.productId,
  305 + lines
  306 + })
  307 + .then(() => {
  308 + uni.hideLoading()
  309 + uni.showToast({ title: '保存成功', icon: 'none' })
  310 + try { uni.setStorageSync('MATERIAL_TEST_LIST_NEED_REFRESH', '1') } catch (e) {}
  311 + setTimeout(() => { uni.navigateBack() }, 400)
  312 + })
  313 + .catch(e => {
  314 + uni.hideLoading()
  315 + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' })
  316 + })
  317 + }
  318 + }
  319 +}
  320 +</script>
  321 +
  322 +<style lang="scss" scoped>
  323 +.page {
  324 + display: flex;
  325 + flex-direction: column;
  326 + height: 100%;
  327 +}
  328 +
  329 +.scroll {
  330 + flex: 1;
  331 + padding: 12rpx 0 200rpx !important;
  332 +}
  333 +
  334 +.footer {
  335 + z-index: 2;
  336 + position: fixed;
  337 + left: 0;
  338 + right: 0;
  339 + bottom: 0;
  340 + padding: 32rpx;
  341 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  342 + background: #fff;
  343 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  344 +
  345 + .btn {
  346 + height: 80rpx;
  347 + line-height: 80rpx;
  348 + border-radius: 12rpx;
  349 + font-size: 32rpx;
  350 + }
  351 +
  352 + .submit {
  353 + background: $theme-primary;
  354 + color: #fff;
  355 + }
  356 +}
  357 +
  358 +::v-deep .uni-list {
  359 + .uni-easyinput {
  360 + display: flex;
  361 +
  362 + .uni-input-input {
  363 + color: rgba(0, 0, 0, 0.9);
  364 + }
  365 + }
  366 +
  367 + .uni-input-placeholder {
  368 + z-index: 1;
  369 + }
  370 +
  371 + .uni-input-input {
  372 + background-color: #ffffff;
  373 + }
  374 +
  375 + background: transparent;
  376 +
  377 + &-item {
  378 + &__extra-text {
  379 + font-size: 32rpx;
  380 + }
  381 +
  382 + &__content-title {
  383 + font-size: 32rpx;
  384 + color: rgba(0, 0, 0, 0.9);
  385 + }
  386 +
  387 + &__container {
  388 + padding: 32rpx;
  389 +
  390 + .item-title,
  391 + .uni-list-item__content {
  392 + flex: none;
  393 + min-height: 48rpx;
  394 + line-height: 48rpx;
  395 + font-size: 32rpx;
  396 + position: relative;
  397 + width: 240rpx;
  398 + margin-right: 32rpx;
  399 + color: rgba(0, 0, 0, 0.9);
  400 +
  401 + .required {
  402 + color: red;
  403 + position: absolute;
  404 + top: 50%;
  405 + transform: translateY(-50%);
  406 + left: -16rpx;
  407 + }
  408 + }
  409 + }
  410 +
  411 + &.select-item {
  412 + &.is-empty {
  413 + .uni-list-item__extra-text {
  414 + color: rgba(0, 0, 0, 0.4) !important;
  415 + }
  416 + }
  417 +
  418 + &.is-filled {
  419 + .uni-list-item__extra-text {
  420 + color: rgba(0, 0, 0, 0.9) !important;
  421 + }
  422 + }
  423 + }
  424 + }
  425 +}
  426 +
  427 +.picker-value {
  428 + font-size: 32rpx;
  429 + color: rgba(0, 0, 0, 0.9);
  430 + line-height: 48rpx;
  431 + text-align: right;
  432 + min-height: 48rpx;
  433 +
  434 + &.placeholder {
  435 + color: rgba(0, 0, 0, 0.4);
  436 + }
  437 +}
  438 +</style>
... ...