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