Commit d6c420c9c4e276472b23afde588970e608b2f952

Authored by gesilong
1 parent 6c80b5d7

commit:买断入库

  1 +import request from '@/utils/request'
  2 +import { ContentTypeEnum } from '@/utils/httpEnum'
  3 +
  4 +// 买断入库核算单(对齐 PC 端 api/warehouse-manage/outright-purchase)
  5 +const baseUrl = '/procurement/buyout/account'
  6 +
  7 +/**
  8 + * 分页查询买断入库核算单列表
  9 + * params: pageIndex, pageSize, weighingTicketCode, planCodes, incomingUnit,
  10 + * workshopId, flowNode, approvalStatus, startTime, endTime, deleted(boolean)
  11 + */
  12 +export function outrightPurchaseQueryApi(params) {
  13 + return request({
  14 + url: baseUrl + '/query',
  15 + method: 'get',
  16 + params
  17 + })
  18 +}
  19 +
  20 +/**
  21 + * 可选原料结算详情单(新增买断入库核算单-码单编号选择弹窗)
  22 + * params: code(码单编号), supplierName(客户名称), workshopId(分厂ID)
  23 + */
  24 +export function outrightPurchaseSettleOptionsApi(params) {
  25 + return request({
  26 + url: baseUrl + '/settleOptions',
  27 + method: 'get',
  28 + params
  29 + })
  30 +}
  31 +
  32 +/**
  33 + * 按原料结算详情单ID带出买断入库核算单默认数据(主表信息+明细行默认值)
  34 + * params: settleDetailId-原料结算详情单ID
  35 + */
  36 +export function outrightPurchaseSettleDataApi(params) {
  37 + return request({
  38 + url: baseUrl + '/settleData',
  39 + method: 'get',
  40 + params
  41 + })
  42 +}
  43 +
  44 +/**
  45 + * 新增买断入库核算单
  46 + */
  47 +export function outrightPurchaseCreateApi(data) {
  48 + return request({
  49 + url: baseUrl,
  50 + method: 'post',
  51 + data,
  52 + contentType: ContentTypeEnum.JSON
  53 + })
  54 +}
  55 +
  56 +/**
  57 + * 修改买断入库核算单
  58 + */
  59 +export function outrightPurchaseUpdateApi(data) {
  60 + return request({
  61 + url: baseUrl,
  62 + method: 'put',
  63 + data,
  64 + contentType: ContentTypeEnum.JSON
  65 + })
  66 +}
  67 +
  68 +/**
  69 + * 提交审核
  70 + */
  71 +export function outrightPurchaseSubmitAuditApi(id) {
  72 + return request({
  73 + url: baseUrl + '/submit?id=' + id,
  74 + method: 'put'
  75 + })
  76 +}
  77 +
  78 +/**
  79 + * 取消核算单
  80 + */
  81 +export function outrightPurchaseCancelApi(id) {
  82 + return request({
  83 + url: baseUrl + '/cancel?id=' + id,
  84 + method: 'put'
  85 + })
  86 +}
  87 +
  88 +/**
  89 + * 查询买断入库核算单详情
  90 + * params: { id }
  91 + */
  92 +export function outrightPurchaseDetailApi(params) {
  93 + return request({
  94 + url: baseUrl,
  95 + method: 'get',
  96 + params
  97 + })
  98 +}
... ...
... ... @@ -156,6 +156,15 @@ export function procurementPlanStopApi(id) {
156 156 })
157 157 }
158 158
  159 +export function procurementPlanDiffQuantityExceededApi(data) {
  160 + return request({
  161 + url: '/procurement/plan/diffQuantityExceeded',
  162 + method: 'put',
  163 + data,
  164 + contentType: ContentTypeEnum.JSON
  165 + })
  166 +}
  167 +
159 168 export function procurementPlanChangeSubmitApi(id) {
160 169 return request({
161 170 url: '/procurement/plan/change/submit?id=' + id,
... ...
... ... @@ -725,6 +725,38 @@
725 725 }
726 726 },
727 727 {
  728 + "path": "pages/outright-purchase/index",
  729 + "style": {
  730 + "navigationBarTitleText": "买断入库核算单",
  731 + "navigationBarBackgroundColor": "#ffffff",
  732 + "navigationBarTextStyle": "black"
  733 + }
  734 + },
  735 + {
  736 + "path": "pages/outright-purchase/add",
  737 + "style": {
  738 + "navigationBarTitleText": "新增买断入库核算单",
  739 + "navigationBarBackgroundColor": "#ffffff",
  740 + "navigationBarTextStyle": "black"
  741 + }
  742 + },
  743 + {
  744 + "path": "pages/outright-purchase/detail",
  745 + "style": {
  746 + "navigationBarTitleText": "买断入库核算单详情",
  747 + "navigationBarBackgroundColor": "#ffffff",
  748 + "navigationBarTextStyle": "black"
  749 + }
  750 + },
  751 + {
  752 + "path": "pages/outright-purchase/modify",
  753 + "style": {
  754 + "navigationBarTitleText": "编辑买断入库核算单",
  755 + "navigationBarBackgroundColor": "#ffffff",
  756 + "navigationBarTextStyle": "black"
  757 + }
  758 + },
  759 + {
728 760 "path": "pages/order_list/index",
729 761 "style": {
730 762 "navigationBarTitleText": "订货单列表",
... ...
... ... @@ -83,7 +83,7 @@
83 83 <script>
84 84 import DetailButtons from '@/components/detail-buttons/index.vue'
85 85 import ProductRel from './productRel.vue'
86   -import { procurementPlanDetailApi, procurementPlanGenerateContractApi, procurementPlanSubmitAuditApi, procurementPlanSubmitApi, procurementPlanStopApi } from '@/api/procure-manage/procurementPlan.js'
  86 +import { procurementPlanDetailApi, procurementPlanGenerateContractApi, procurementPlanSubmitAuditApi, procurementPlanSubmitApi, procurementPlanStopApi, procurementPlanDiffQuantityExceededApi } from '@/api/procure-manage/procurementPlan.js'
87 87 import { buyoutApplyCreateApi, buyoutApplyAbolishApi, buyoutApplyDeleteByPlanIdApi } from '@/api/procure-manage/buyout.js'
88 88 import { getDicByCodes, getDicName } from '@/utils/dic.js'
89 89 import { getInfo } from '@/api/login.js'
... ... @@ -142,6 +142,7 @@ export default {
142 142 { text: '生成买断操作申请单', variant: 'outline', event: 'generate' },
143 143 { text: '废除买断操作申请单', variant: 'danger', event: 'cancel' },
144 144 { text: '查看买断操作申请单', variant: 'outline', event: 'look' },
  145 + { text: '更改差值状态', variant: 'outline', event: 'change' },
145 146 // { text: '上传附件', variant: 'primary', event: 'upload' }
146 147 ]
147 148 }
... ... @@ -188,6 +189,7 @@ export default {
188 189 var ps = String(f.processStatus != null ? f.processStatus : '')
189 190 var aStatus = String(f.approvalStatus != null ? f.approvalStatus : '')
190 191 var SC = this.PROCESS_STATUS_CODE
  192 + const diffQuantityExceeded = this.form?.diffQuantityExceeded;
191 193 var inStatus = function (codes) { return codes.indexOf(ps) >= 0 }
192 194 console.log(SC,inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED, SC.REFUSE]),'SC')
193 195 var perms = {
... ... @@ -203,6 +205,7 @@ export default {
203 205 generate: this.hasPerm('plan-manage:domestic-plan:generate'),
204 206 cancel: this.hasPerm('plan-manage:domestic-plan:cancel'),
205 207 look: this.hasPerm('plan-manage:domestic-plan:look'),
  208 + change: this.hasPerm('plan-manage:domestic-plan:change'),
206 209 // upload: this.hasPerm('plan-manage:domestic-plan:upload')
207 210 }
208 211 var visibleMap = {
... ... @@ -218,7 +221,8 @@ export default {
218 221 generate: !!f.showGenerateBuyoutApply && inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED]) && perms.generate,
219 222 cancel: !!f.showAbolishBuyoutApply && inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED]) && perms.cancel,
220 223 look: inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED, SC.REFUSE, SC.ABORTED]) && perms.look,
221   - // uploadAttachment: inStatus([SC.COMPLETED]) && !!this.planRoleFlags.isPlanner && perms.uploadAttachment
  224 + change: inStatus(diffQuantityExceeded) && perms.change,
  225 + // // uploadAttachment: inStatus([SC.COMPLETED]) && !!this.planRoleFlags.isPlanner && perms.uploadAttachment
222 226 }
223 227 var out = []
224 228 for (var i = 0; i < this.buttonTemplates.length; i++) {
... ... @@ -434,6 +438,7 @@ export default {
434 438 if (e === 'cancel') return this.onAbolishBuyoutApply()
435 439 if (e === 'look') return this.onViewBuyoutApply()
436 440 if (e === 'uploadAttachment') return this.onUploadAttachment()
  441 + if (e === 'change') return this.onChangeDiffQuantityExceeded()
437 442 },
438 443
439 444 onView() {
... ... @@ -525,6 +530,16 @@ export default {
525 530 }
526 531 uni.navigateTo({ url: '/pages/domestic-plan/selectWorkshop?id=' + id })
527 532 },
  533 + onChangeDiffQuantityExceeded() {
  534 + this.runWithConfirm({
  535 + title: '更改差值状态',
  536 + content: '确定更改差值状态吗?',
  537 + loading: '处理中',
  538 + successText: '更改成功',
  539 + failText: '更改差值状态失败',
  540 + run: function (id) { return procurementPlanDiffQuantityExceededApi({ id: id, diffQuantityExceeded: false }) }
  541 + })
  542 + },
528 543 onSubmitSplit() {
529 544 this.runWithConfirm({
530 545 title: '提交',
... ...
... ... @@ -238,7 +238,7 @@ export default {
238 238 text: '买断入库核算单',
239 239 icon: '/static/images/index/draft_order.png',
240 240 link: '/pages/outright-purchase/index',
241   - name: 'OuthrightPurchase'
  241 + name: 'OutrightPurchase'
242 242 }
243 243 ]
244 244 },
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <!-- 基础信息 -->
  5 + <uni-list>
  6 + <uni-list-item class="select-item" :class="form.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.incomingUnit" :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.planCodes" :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.purchaseDepartmentName" :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.regionName" :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.buyoutCategory" :inputBorder="false" disabled />
  47 + </template>
  48 + </uni-list-item>
  49 + <uni-list-item title="买断数量">
  50 + <template v-slot:footer>
  51 + <uni-easyinput :value="item.buyoutQuantity" :inputBorder="false" disabled />
  52 + </template>
  53 + </uni-list-item>
  54 + <uni-list-item title="买断单价">
  55 + <template v-slot:footer>
  56 + <uni-easyinput :value="item.buyoutPrice" :inputBorder="false" disabled />
  57 + </template>
  58 + </uni-list-item>
  59 + <uni-list-item title="买断金额">
  60 + <template v-slot:footer>
  61 + <uni-easyinput :value="item.buyoutAmount" :inputBorder="false" disabled placeholder="买断单价×买断数量自动计算" />
  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.instockQuantity" type="digit" :inputBorder="false" placeholder="请输入入库数量" @input="recalcDiffAmount(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.instockPrice" 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.instockAmount" type="digit" :inputBorder="false" placeholder="请输入入库金额" />
  86 + </template>
  87 + </uni-list-item>
  88 + <uni-list-item title="预计吨损耗(元/吨)">
  89 + <template v-slot:footer>
  90 + <uni-easyinput :value="item.expectTonLoss" :inputBorder="false" disabled />
  91 + </template>
  92 + </uni-list-item>
  93 + <uni-list-item>
  94 + <template v-slot:body>
  95 + <view class="item-title"><text class="required">*</text><text>实际吨损耗(元/吨)</text></view>
  96 + </template>
  97 + <template v-slot:footer>
  98 + <uni-easyinput v-model="item.actualTonLoss" type="digit" :inputBorder="false" placeholder="请输入实际吨损耗" @input="recalcTonLossDiff(item)" />
  99 + </template>
  100 + </uni-list-item>
  101 + <uni-list-item title="吨损耗差异(元/吨)">
  102 + <template v-slot:footer>
  103 + <uni-easyinput :value="item.tonLossDiff" :inputBorder="false" disabled placeholder="预计-实际自动计算" />
  104 + </template>
  105 + </uni-list-item>
  106 + <uni-list-item title="差异金额(元)">
  107 + <template v-slot:footer>
  108 + <uni-easyinput :value="item.diffAmount" :inputBorder="false" disabled placeholder="入库数量×吨损耗差异/1000" />
  109 + </template>
  110 + </uni-list-item>
  111 + </uni-list>
  112 + </view>
  113 + </view>
  114 + </view>
  115 +
  116 + <!-- 合计 -->
  117 + <view class="total-card">
  118 + <view class="total-title">合计</view>
  119 + <view class="total-body">
  120 + <view class="total-item">
  121 + <text class="total-label">买断数量</text>
  122 + <text class="total-value">{{ totalSummary.totalBuyoutQuantity || '-' }}</text>
  123 + </view>
  124 + <view class="total-item">
  125 + <text class="total-label">买断金额</text>
  126 + <text class="total-value">{{ totalSummary.totalBuyoutAmount || '-' }}</text>
  127 + </view>
  128 + <view class="total-item">
  129 + <text class="total-label">入库数量</text>
  130 + <text class="total-value">{{ totalSummary.totalInstockQuantity || '-' }}</text>
  131 + </view>
  132 + <view class="total-item">
  133 + <text class="total-label">入库金额</text>
  134 + <text class="total-value">{{ totalSummary.totalInstockAmount || '-' }}</text>
  135 + </view>
  136 + <view class="total-item">
  137 + <text class="total-label">差异金额</text>
  138 + <text class="total-value">{{ totalSummary.totalDiffAmount || '-' }}</text>
  139 + </view>
  140 + </view>
  141 + </view>
  142 +
  143 + <!-- 其他信息 -->
  144 + <view class="remark-section">
  145 + <view class="header">
  146 + <image class="opCollapse" src="/static/images/title.png" />
  147 + <text class="title">其他信息</text>
  148 + </view>
  149 + <view class="section-content">
  150 + <uni-list>
  151 + <uni-list-item>
  152 + <template v-slot:body>
  153 + <view class="item-title"><text class="required">*</text><text>磅差情况</text></view>
  154 + </template>
  155 + <template v-slot:footer>
  156 + <uni-easyinput v-model="form.weighDiff" type="digit" :inputBorder="false" placeholder="请输入磅差情况" />
  157 + </template>
  158 + </uni-list-item>
  159 + </uni-list>
  160 + </view>
  161 + </view>
  162 +
  163 + <view class="footer">
  164 + <button class="btn submit" type="primary" @click="onSubmit">保存</button>
  165 + </view>
  166 + </scroll-view>
  167 +
  168 + <RelateSelectSheet :visible.sync="settleSheet.visible" title="选择结算详情单" :multiple="false"
  169 + :fetchFn="settleSheet.fetchFn" :display-fields="settleSheet.displayFields"
  170 + row-key="settleDetailId" :selectedKeys.sync="settleSheet.selectedKeys" @confirm="onSettleConfirm" />
  171 + </view>
  172 +</template>
  173 +
  174 +<script>
  175 +import RelateSelectSheet from '@/components/relate-select/index.vue'
  176 +import {
  177 + outrightPurchaseSettleOptionsApi,
  178 + outrightPurchaseSettleDataApi,
  179 + outrightPurchaseCreateApi
  180 +} from '@/api/procure-manage/outrightPurchase.js'
  181 +import { buyoutApplyDetailByPlanIdApi } from '@/api/procure-manage/buyout.js'
  182 +
  183 +export default {
  184 + name: 'AddOutrightPurchase',
  185 + components: { RelateSelectSheet },
  186 + data() {
  187 + return {
  188 + loading: false,
  189 + form: {
  190 + settleDetailId: '',
  191 + weighingTicketId: '',
  192 + weighingTicketCode: '',
  193 + incomingUnit: '',
  194 + planCodes: '',
  195 + purchaseDepartmentId: '',
  196 + purchaseDepartmentName: '',
  197 + regionId: '',
  198 + regionName: '',
  199 + weighDiff: ''
  200 + },
  201 + // 选中的结算详情单行,供回显使用
  202 + selectedSettleRow: null,
  203 + // 明细数据(选择码单编号后带出)
  204 + lineList: [],
  205 + // 计划ID集合(由结算详情单带出)
  206 + planIds: [],
  207 + settleSheet: {
  208 + visible: false,
  209 + fetchFn: null,
  210 + displayFields: [
  211 + { label: '码单编号', field: 'weighingTicketCode' },
  212 + { label: '来料单位', field: 'incomingUnit' },
  213 + { label: '计划编号', field: 'planCodes' },
  214 + { label: '分厂', field: 'workshopName' }
  215 + ],
  216 + selectedKeys: []
  217 + }
  218 + }
  219 + },
  220 + computed: {
  221 + // 明细各数值列合计(保留两位)
  222 + totalSummary() {
  223 + const list = this.lineList || []
  224 + return {
  225 + totalBuyoutQuantity: this.calcTotal(list, 'buyoutQuantity'),
  226 + totalBuyoutAmount: this.calcTotal(list, 'buyoutAmount'),
  227 + totalInstockQuantity: this.calcTotal(list, 'instockQuantity'),
  228 + totalInstockAmount: this.calcTotal(list, 'instockAmount'),
  229 + totalDiffAmount: this.calcTotal(list, 'diffAmount')
  230 + }
  231 + }
  232 + },
  233 + created() {
  234 + this.settleSheet.fetchFn = this.fetchSettleList.bind(this)
  235 + },
  236 + methods: {
  237 + // 结算详情单选择弹窗数据源(接口不分页,包装为组件所需格式)
  238 + fetchSettleList({ pageIndex, pageSize, extra }) {
  239 + const keyword = (extra && extra.keyword) || ''
  240 + const params = {
  241 + code: keyword || undefined
  242 + }
  243 + return outrightPurchaseSettleOptionsApi(params).then(res => {
  244 + const _data = (res && res.data) || []
  245 + const records = (Array.isArray(_data) ? _data : []).map(it => ({ ...it }))
  246 + return { records, totalCount: records.length, hasNext: false }
  247 + }).catch(() => ({ records: [], totalCount: 0, hasNext: false }))
  248 + },
  249 + openSettleSheet() {
  250 + this.settleSheet.selectedKeys = this.selectedSettleRow ? [this.selectedSettleRow.settleDetailId || this.selectedSettleRow.id] : []
  251 + this.settleSheet.visible = true
  252 + },
  253 + // 结算详情单选择回调:主表信息由选中行带出,选中后按结算详情单ID查询详情带出明细默认值
  254 + onSettleConfirm({ items }) {
  255 + const row = (items || [])[0]
  256 + // 清空选择:重置带出数据
  257 + if (!row) {
  258 + this.selectedSettleRow = null
  259 + this.form.settleDetailId = ''
  260 + this.form.weighingTicketId = ''
  261 + this.form.weighingTicketCode = ''
  262 + this.form.incomingUnit = ''
  263 + this.form.planCodes = ''
  264 + this.form.purchaseDepartmentId = ''
  265 + this.form.purchaseDepartmentName = ''
  266 + this.form.regionId = ''
  267 + this.form.regionName = ''
  268 + this.planIds = []
  269 + this.lineList = []
  270 + return
  271 + }
  272 + this.selectedSettleRow = row
  273 + this.form.settleDetailId = row.settleDetailId || row.id || ''
  274 + this.form.weighingTicketId = row.weighingTicketId || ''
  275 + this.form.weighingTicketCode = row.weighingTicketCode || ''
  276 + // 按结算详情单ID查询详情(带出主表信息与明细行默认值)
  277 + const settleDetailId = this.form.settleDetailId
  278 + if (!settleDetailId) return
  279 + this.loading = true
  280 + uni.showLoading({ title: '加载中...', mask: true })
  281 + outrightPurchaseSettleDataApi({ settleDetailId })
  282 + .then(res => {
  283 + const data = res && res.data ? (res.data.data || res.data) : {}
  284 + const lines = Array.isArray(data.lines) ? data.lines : []
  285 + // 来料单位/计划编号/采购处/区域:由结算详情单详情带出
  286 + this.form.incomingUnit = data.incomingUnit || row.materialSource || row.supplierName || ''
  287 + this.form.planCodes = data.planCodes || row.planCodes || ''
  288 + this.form.purchaseDepartmentId = data.purchaseDepartmentId || ''
  289 + this.form.purchaseDepartmentName = data.purchaseDepartmentName || ''
  290 + this.form.regionId = data.regionId || ''
  291 + this.form.regionName = data.regionName || ''
  292 + // 计划ID集合:优先取详情返回,否则由明细行计划ID去重
  293 + this.planIds = data.planIds || Array.from(new Set(lines.map(l => l.procurementPlanId).filter(Boolean)))
  294 + // 查询详情带出明细默认值(异步查询预计吨损耗后再构建)
  295 + return this.loadExpectLossMap(this.planIds).then(expectLossMap => {
  296 + this.lineList = lines.map(item => this.buildLine(item, expectLossMap))
  297 + })
  298 + })
  299 + .catch(() => {
  300 + this.planIds = []
  301 + this.lineList = []
  302 + })
  303 + .finally(() => {
  304 + this.loading = false
  305 + uni.hideLoading()
  306 + })
  307 + },
  308 + // 按计划ID集合查询买断操作申请表,构建 预计吨损耗映射:{ 计划ID: { 品种ID: 预计吨损耗 } }
  309 + async loadExpectLossMap(planIds) {
  310 + const map = {}
  311 + const ids = Array.from(new Set((planIds || []).filter(Boolean)))
  312 + const results = await Promise.all(
  313 + ids.map(id => buyoutApplyDetailByPlanIdApi(id).catch(() => null))
  314 + )
  315 + results.forEach((res, idx) => {
  316 + const data = res && res.data ? res.data : {}
  317 + const lineList = data.buyoutApplyLineList || data.procurementBuyoutApplyLineList || []
  318 + map[ids[idx]] = lineList.reduce((m, line) => {
  319 + if (line && line.productId) {
  320 + m[line.productId] = line.estimatedLoss == null ? '' : line.estimatedLoss
  321 + }
  322 + return m
  323 + }, {})
  324 + })
  325 + return map
  326 + },
  327 + // 由结算详情单明细构建核算单明细行(买断金额/入库数量默认值在此计算)
  328 + buildLine(item, expectLossMap) {
  329 + // 买断数量:结算详情单过磅数;买断单价:仓库收料单含税单价
  330 + const buyoutQuantity = item.buyoutQuantity != null ? item.buyoutQuantity : (item.weighQuantity != null ? item.weighQuantity : '')
  331 + const buyoutPrice = item.buyoutPrice != null ? item.buyoutPrice : (item.taxPrice != null ? item.taxPrice : '')
  332 + // 入库数量:申请净重-退料-折斤(有申请净重再计算,找不到为空)
  333 + const instockQuantity = item.instockQuantity != null ? item.instockQuantity : this.calcInstockQuantity(item)
  334 + // 预计吨损耗:按计划+品种匹配买断操作申请表的预计损耗
  335 + const expectTonLoss = ((expectLossMap || {})[item.procurementPlanId] || {})[item.productId]
  336 + return {
  337 + rowId: genRowId(),
  338 + itemId: item.settleLineId || item.id || '',
  339 + settleLineId: item.settleLineId || item.id || '',
  340 + procurementPlanId: item.procurementPlanId || '',
  341 + productId: item.productId || '',
  342 + buyoutCategory: item.buyoutCategory || item.category || '',
  343 + buyoutQuantity,
  344 + buyoutPrice,
  345 + buyoutAmount: this.calcBuyoutAmount(buyoutPrice, buyoutQuantity),
  346 + instockQuantity,
  347 + instockPrice: '',
  348 + instockAmount: '',
  349 + expectTonLoss: expectTonLoss == null ? '' : expectTonLoss,
  350 + actualTonLoss: '',
  351 + tonLossDiff: '',
  352 + diffAmount: ''
  353 + }
  354 + },
  355 + // 买断金额 = 买断单价 * 买断数量(单价或数量为空则金额为空)
  356 + calcBuyoutAmount(price, quantity) {
  357 + const hasPrice = price !== null && price !== undefined && price !== ''
  358 + const hasQty = quantity !== null && quantity !== undefined && quantity !== ''
  359 + if (hasPrice && hasQty) {
  360 + return Math.round(Number(price) * Number(quantity) * 100) / 100
  361 + }
  362 + return ''
  363 + },
  364 + // 入库数量 = 申请净重 - 退料 - 折斤(无申请净重则为空)
  365 + calcInstockQuantity(item) {
  366 + const netWeight = item.netWeight
  367 + if (netWeight === null || netWeight === undefined || netWeight === '') return ''
  368 + const returnWeight = Number(item.returnWeight || 0)
  369 + const foldWeight = Number(item.foldWeight || 0)
  370 + return Math.round((Number(netWeight) - returnWeight - foldWeight) * 100) / 100
  371 + },
  372 + // 吨损耗差异 = 预计吨损耗 - 实际吨损耗(预计或实际为空则差异为空),并联动差异金额
  373 + recalcTonLossDiff(row) {
  374 + const expect = row.expectTonLoss
  375 + const actual = row.actualTonLoss
  376 + const hasExpect = expect !== null && expect !== undefined && expect !== ''
  377 + const hasActual = actual !== null && actual !== undefined && actual !== ''
  378 + if (hasExpect && hasActual) {
  379 + row.tonLossDiff = Math.round((Number(expect) - Number(actual)) * 100) / 100
  380 + } else {
  381 + row.tonLossDiff = ''
  382 + }
  383 + this.recalcDiffAmount(row)
  384 + },
  385 + // 差异金额 = 入库数量 * 吨损耗差异 / 1000(入库数量或吨损耗差异为空则金额为空)
  386 + recalcDiffAmount(row) {
  387 + const qty = row.instockQuantity
  388 + const diff = row.tonLossDiff
  389 + const hasQty = qty !== null && qty !== undefined && qty !== ''
  390 + const hasDiff = diff !== null && diff !== undefined && diff !== ''
  391 + if (hasQty && hasDiff) {
  392 + row.diffAmount = Math.round(((Number(qty) * Number(diff)) / 1000) * 100) / 100
  393 + } else {
  394 + row.diffAmount = ''
  395 + }
  396 + },
  397 + // 计算合计(保留两位,空值按0处理,无数据返回 '-')
  398 + calcTotal(list, field) {
  399 + if (!list.length) return ''
  400 + const total = Number(list.reduce((sum, row) => sum + Number(row[field] || 0), 0).toFixed(2))
  401 + return String(total)
  402 + },
  403 + validate() {
  404 + if (!this.form.settleDetailId) return this.tip('请选择码单编号')
  405 + if (this.form.weighDiff === '' || this.form.weighDiff == null) return this.tip('请输入磅差情况')
  406 + return true
  407 + },
  408 + tip(msg) {
  409 + uni.showToast({ title: msg, icon: 'none' })
  410 + return false
  411 + },
  412 + toNum(v) {
  413 + if (v === null || v === undefined || v === '') return null
  414 + const n = Number(v)
  415 + return isNaN(n) ? null : n
  416 + },
  417 + buildSubmitData() {
  418 + return {
  419 + settleDetailId: this.form.settleDetailId,
  420 + totalBuyoutQuantity: this.toNum(this.totalSummary.totalBuyoutQuantity),
  421 + totalBuyoutAmount: this.toNum(this.totalSummary.totalBuyoutAmount),
  422 + totalInstockQuantity: this.toNum(this.totalSummary.totalInstockQuantity),
  423 + totalInstockAmount: this.toNum(this.totalSummary.totalInstockAmount),
  424 + totalDiffAmount: this.toNum(this.totalSummary.totalDiffAmount),
  425 + weighDiff: this.toNum(this.form.weighDiff),
  426 + // 核算单明细
  427 + lines: (this.lineList || []).map(item => ({
  428 + settleLineId: item.settleLineId || '',
  429 + procurementPlanId: item.procurementPlanId || '',
  430 + productId: item.productId || '',
  431 + buyoutCategory: item.buyoutCategory || '',
  432 + buyoutQuantity: this.toNum(item.buyoutQuantity),
  433 + buyoutPrice: this.toNum(item.buyoutPrice),
  434 + buyoutAmount: this.toNum(item.buyoutAmount),
  435 + instockQuantity: this.toNum(item.instockQuantity),
  436 + instockPrice: this.toNum(item.instockPrice),
  437 + instockAmount: this.toNum(item.instockAmount),
  438 + expectTonLoss: this.toNum(item.expectTonLoss),
  439 + actualTonLoss: this.toNum(item.actualTonLoss),
  440 + tonLossDiff: this.toNum(item.tonLossDiff),
  441 + diffAmount: this.toNum(item.diffAmount)
  442 + }))
  443 + }
  444 + },
  445 + async onSubmit() {
  446 + if (!this.validate()) return
  447 + const confirmRes = await new Promise(resolve => {
  448 + uni.showModal({ title: '提示', content: '确定保存买断入库核算单吗?', confirmText: '确定', cancelText: '取消', success: resolve })
  449 + })
  450 + if (!(confirmRes && confirmRes.confirm)) return
  451 + uni.showLoading({ title: '提交中...', mask: true })
  452 + outrightPurchaseCreateApi(this.buildSubmitData())
  453 + .then(() => {
  454 + uni.hideLoading()
  455 + uni.showToast({ title: '保存成功', icon: 'none' })
  456 + try { uni.setStorageSync('OUTRIGHT_PURCHASE_LIST_NEED_REFRESH', '1') } catch (e) {}
  457 + setTimeout(() => { uni.navigateBack() }, 400)
  458 + })
  459 + .catch(e => {
  460 + uni.hideLoading()
  461 + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' })
  462 + })
  463 + }
  464 + }
  465 +}
  466 +
  467 +// 生成前端临时行 id
  468 +function genRowId() {
  469 + return 'row_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8)
  470 +}
  471 +</script>
  472 +
  473 +<style lang="scss" scoped>
  474 +.page {
  475 + display: flex;
  476 + flex-direction: column;
  477 + height: 100%;
  478 +}
  479 +
  480 +.scroll {
  481 + flex: 1;
  482 + padding: 12rpx 0 200rpx !important;
  483 +}
  484 +
  485 +.footer {
  486 + z-index: 2;
  487 + position: fixed;
  488 + left: 0;
  489 + right: 0;
  490 + bottom: 0;
  491 + padding: 32rpx;
  492 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  493 + background: #fff;
  494 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  495 +
  496 + .btn {
  497 + height: 80rpx;
  498 + line-height: 80rpx;
  499 + border-radius: 12rpx;
  500 + font-size: 32rpx;
  501 + }
  502 +
  503 + .submit {
  504 + background: $theme-primary;
  505 + color: #fff;
  506 + }
  507 +}
  508 +
  509 +::v-deep .uni-list {
  510 + .uni-easyinput {
  511 + display: flex;
  512 +
  513 + .uni-input-input {
  514 + color: rgba(0, 0, 0, 0.9);
  515 + }
  516 + }
  517 +
  518 + .uni-input-placeholder {
  519 + z-index: 1;
  520 + }
  521 +
  522 + .uni-input-input {
  523 + background-color: #ffffff;
  524 + }
  525 +
  526 + background: transparent;
  527 +
  528 + &-item {
  529 + &__extra-text {
  530 + font-size: 32rpx;
  531 + }
  532 +
  533 + &__content-title {
  534 + font-size: 32rpx;
  535 + color: rgba(0, 0, 0, 0.9);
  536 + }
  537 +
  538 + &__container {
  539 + padding: 32rpx;
  540 +
  541 + .uni-easyinput {
  542 + &__placeholder-class {
  543 + font-size: 32rpx;
  544 + color: rgba(0, 0, 0, 0.4);
  545 + }
  546 +
  547 + &__content {
  548 + border: none;
  549 + background-color: #ffffff !important;
  550 +
  551 + &-input {
  552 + padding-left: 0 !important;
  553 + height: 48rpx;
  554 + line-height: 48rpx;
  555 + font-size: 32rpx;
  556 + }
  557 +
  558 + .content-clear-icon {
  559 + font-size: 44rpx !important;
  560 + }
  561 + }
  562 + }
  563 +
  564 + .item-title,
  565 + .uni-list-item__content {
  566 + flex: none;
  567 + min-height: 48rpx;
  568 + line-height: 48rpx;
  569 + font-size: 32rpx;
  570 + position: relative;
  571 + width: 240rpx;
  572 + margin-right: 32rpx;
  573 + color: rgba(0, 0, 0, 0.9);
  574 +
  575 + .required {
  576 + color: red;
  577 + position: absolute;
  578 + top: 50%;
  579 + transform: translateY(-50%);
  580 + left: -16rpx;
  581 + }
  582 + }
  583 + }
  584 +
  585 + &.select-item {
  586 + &.is-empty {
  587 + .uni-list-item__extra-text {
  588 + color: rgba(0, 0, 0, 0.4) !important;
  589 + }
  590 + }
  591 +
  592 + &.is-filled {
  593 + .uni-list-item__extra-text {
  594 + color: rgba(0, 0, 0, 0.9) !important;
  595 + }
  596 + }
  597 + }
  598 + }
  599 +}
  600 +
  601 +.sub-table,
  602 +.remark-section {
  603 + margin-top: 20rpx;
  604 + background: #fff;
  605 +}
  606 +
  607 +.header {
  608 + display: flex;
  609 + align-items: center;
  610 + padding: 24rpx 32rpx;
  611 + border-bottom: 1rpx solid #f0f0f0;
  612 +
  613 + .opCollapse {
  614 + width: 32rpx;
  615 + height: 28rpx;
  616 + margin-right: 16rpx;
  617 + margin-top: 8rpx;
  618 + }
  619 +
  620 + .title {
  621 + font-size: 32rpx;
  622 + color: rgba(0, 0, 0, 0.9);
  623 + font-weight: 600;
  624 + flex: 1;
  625 + }
  626 +}
  627 +
  628 +.add-list {
  629 + padding: 0 0 16rpx;
  630 +
  631 + .empty-tip {
  632 + text-align: center;
  633 + padding: 60rpx 0;
  634 + color: rgba(0, 0, 0, 0.4);
  635 + font-size: 28rpx;
  636 + }
  637 +
  638 + .block {
  639 + border-bottom: 1rpx solid #f0f0f0;
  640 +
  641 + &:last-child {
  642 + border-bottom: none;
  643 + }
  644 + }
  645 +}
  646 +
  647 +.total-card {
  648 + margin-top: 20rpx;
  649 + background: #fff;
  650 + padding: 24rpx 32rpx;
  651 +
  652 + .total-title {
  653 + font-size: 32rpx;
  654 + font-weight: 600;
  655 + color: rgba(0, 0, 0, 0.9);
  656 + margin-bottom: 20rpx;
  657 + }
  658 +
  659 + .total-body {
  660 + display: flex;
  661 + flex-wrap: wrap;
  662 +
  663 + .total-item {
  664 + width: 50%;
  665 + display: flex;
  666 + align-items: center;
  667 + margin-bottom: 20rpx;
  668 +
  669 + &:nth-last-child(-n + 2) {
  670 + margin-bottom: 0;
  671 + }
  672 +
  673 + .total-label {
  674 + font-size: 28rpx;
  675 + color: rgba(0, 0, 0, 0.6);
  676 + margin-right: 16rpx;
  677 + }
  678 +
  679 + .total-value {
  680 + font-size: 28rpx;
  681 + color: rgba(0, 0, 0, 0.9);
  682 + font-weight: 500;
  683 + }
  684 + }
  685 + }
  686 +}
  687 +
  688 +.section-content {
  689 + padding: 32rpx;
  690 +}
  691 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <view class="detail-page">
  5 + <!-- 基础信息 -->
  6 + <view class="section">
  7 + <text class="row company">{{ safeText(form.weighingTicketCode) }}</text>
  8 + <view class="row"><text class="label">来料单位</text><text class="value">{{ safeText(form.incomingUnit) }}</text></view>
  9 + <view class="row"><text class="label">计划单编号</text><text class="value">{{ safeText(form.planCodes) }}</text></view>
  10 + <view class="row"><text class="label">采购处</text><text class="value">{{ safeText(form.purchaseDepartmentName) }}</text></view>
  11 + <view class="row"><text class="label">区域</text><text class="value">{{ safeText(form.regionName) }}</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('lines')">
  20 + <image class="sub-toggle_icon" :src="collapse.lines ? '/static/images/down.png' : '/static/images/up.png'" />
  21 + <text class="sub-toggle_text">{{ collapse.lines ? '展开' : '收起' }}</text>
  22 + </view>
  23 + </view>
  24 + <view v-if="!collapse.lines" class="sub-body">
  25 + <view v-if="!lineList.length" class="empty-tip">暂无明细</view>
  26 + <view v-for="(item, idx) in lineList" :key="'l-' + (item.id || idx)" class="card">
  27 + <view class="card-index">第 {{ idx + 1 }} 行</view>
  28 + <view class="row"><text class="label">买断品种</text><text class="value">{{ safeText(item.buyoutCategory) }}</text></view>
  29 + <view class="row"><text class="label">买断数量</text><text class="value">{{ formatNumber(item.buyoutQuantity) }}</text></view>
  30 + <view class="row"><text class="label">买断单价</text><text class="value">{{ formatNumber(item.buyoutPrice) }}</text></view>
  31 + <view class="row"><text class="label">买断金额</text><text class="value">{{ formatNumber(item.buyoutAmount) }}</text></view>
  32 + <view class="row"><text class="label">入库数量</text><text class="value">{{ formatNumber(item.instockQuantity) }}</text></view>
  33 + <view class="row"><text class="label">入库单价</text><text class="value">{{ formatNumber(item.instockPrice) }}</text></view>
  34 + <view class="row"><text class="label">入库金额</text><text class="value">{{ formatNumber(item.instockAmount) }}</text></view>
  35 + <view class="row"><text class="label">预计吨损耗(元/吨)</text><text class="value">{{ formatNumber(item.expectTonLoss) }}</text></view>
  36 + <view class="row"><text class="label">实际吨损耗(元/吨)</text><text class="value">{{ formatNumber(item.actualTonLoss) }}</text></view>
  37 + <view class="row"><text class="label">吨损耗差异(元/吨)</text><text class="value">{{ formatNumber(item.tonLossDiff) }}</text></view>
  38 + <view class="row"><text class="label">差异金额(元)</text><text class="value">{{ formatNumber(item.diffAmount) }}</text></view>
  39 + </view>
  40 + </view>
  41 + </view>
  42 +
  43 + <!-- 合计 -->
  44 + <view class="title-header">
  45 + <image class="title-header_icon" src="/static/images/title.png" />
  46 + <span>合计</span>
  47 + </view>
  48 + <view class="section">
  49 + <view class="row"><text class="label">买断数量</text><text class="value">{{ formatNumber(form.totalBuyoutQuantity) }}</text></view>
  50 + <view class="row"><text class="label">买断金额</text><text class="value">{{ formatNumber(form.totalBuyoutAmount) }}</text></view>
  51 + <view class="row"><text class="label">入库数量</text><text class="value">{{ formatNumber(form.totalInstockQuantity) }}</text></view>
  52 + <view class="row"><text class="label">入库金额</text><text class="value">{{ formatNumber(form.totalInstockAmount) }}</text></view>
  53 + <view class="row"><text class="label">差异金额</text><text class="value">{{ formatNumber(form.totalDiffAmount) }}</text></view>
  54 + </view>
  55 +
  56 + <!-- 其他信息 -->
  57 + <view class="title-header">
  58 + <image class="title-header_icon" src="/static/images/title.png" />
  59 + <span>其他信息</span>
  60 + </view>
  61 + <view class="section">
  62 + <view class="row"><text class="label">磅差情况</text><text class="value">{{ formatNumber(form.weighDiff) }}</text></view>
  63 + </view>
  64 + </view>
  65 + </scroll-view>
  66 + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  67 + </view>
  68 +</template>
  69 +
  70 +<script>
  71 +import DetailButtons from '@/components/detail-buttons/index.vue'
  72 +import {
  73 + outrightPurchaseDetailApi,
  74 + outrightPurchaseSubmitAuditApi,
  75 + outrightPurchaseCancelApi
  76 +} from '@/api/procure-manage/outrightPurchase.js'
  77 +import { getInfo } from '@/api/login.js'
  78 +
  79 +export default {
  80 + name: 'OutrightPurchaseDetail',
  81 + components: { DetailButtons },
  82 + data() {
  83 + return {
  84 + id: '',
  85 + form: {},
  86 + lineList: [],
  87 + currentUserId: '',
  88 + collapse: { lines: false },
  89 + buttons: [
  90 + { text: '修改', visible: true, variant: 'outline', event: 'edit' },
  91 + { text: '提交审核', visible: true, variant: 'outline', event: 'submitAudit' },
  92 + { text: '审核', visible: true, variant: 'primary', event: 'audit' },
  93 + { text: '审核详情', visible: true, variant: 'outline', event: 'auditDetail' },
  94 + { text: '取消', visible: true, variant: 'outline', event: 'cancel' }
  95 + ]
  96 + }
  97 + },
  98 + computed: {
  99 + displayButtons() {
  100 + const status = this.form.approvalStatus || ''
  101 + const isMine = this.form.createById === this.currentUserId
  102 + const isAudit = status === 'AUDIT'
  103 + const isDraft = status === 'DRAFT'
  104 + const isRefuse = status === 'REFUSE'
  105 + const showExamine = this.form.showExamine === true
  106 + const showExamineDetail = this.form.showExamineDetail === true
  107 + return [
  108 + {
  109 + ...this.buttons[0],
  110 + visible: (isDraft || isRefuse) && isMine && this.$auth.hasPermi('warehouse-manage:outright-purchase:modify')
  111 + },
  112 + {
  113 + ...this.buttons[1],
  114 + visible: (isDraft || isRefuse) && isMine && this.$auth.hasPermi('warehouse-manage:outright-purchase:submit')
  115 + },
  116 + {
  117 + ...this.buttons[2],
  118 + visible: isAudit && showExamine && this.$auth.hasPermi('warehouse-manage:outright-purchase:approve')
  119 + },
  120 + {
  121 + ...this.buttons[3],
  122 + visible: showExamineDetail && this.$auth.hasPermi('warehouse-manage:outright-purchase:review')
  123 + },
  124 + {
  125 + ...this.buttons[4],
  126 + visible: (isDraft || isRefuse) && this.$auth.hasPermi('warehouse-manage:outright-purchase:cancel')
  127 + }
  128 + ]
  129 + }
  130 + },
  131 + onLoad(query) {
  132 + this.id = (query && query.id) || ''
  133 + this.loadDetail()
  134 + this.getUserInfo()
  135 + },
  136 + onShow() {
  137 + let needRefresh = ''
  138 + try { needRefresh = uni.getStorageSync('OUTRIGHT_PURCHASE_DETAIL_NEED_REFRESH') } catch (e) {}
  139 + if (!needRefresh) return
  140 + try { uni.removeStorageSync('OUTRIGHT_PURCHASE_DETAIL_NEED_REFRESH') } catch (e) {}
  141 + this.loadDetail()
  142 + },
  143 + methods: {
  144 + toggle(key) {
  145 + this.collapse = { ...this.collapse, [key]: !this.collapse[key] }
  146 + },
  147 + async getUserInfo() {
  148 + try {
  149 + const res = await getInfo()
  150 + this.currentUserId = (res && (res.id || (res.data && res.data.id))) || ''
  151 + } catch (e) {
  152 + this.currentUserId = ''
  153 + }
  154 + },
  155 + loadDetail() {
  156 + if (!this.id) {
  157 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  158 + return
  159 + }
  160 + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true })
  161 + outrightPurchaseDetailApi({ id: this.id })
  162 + .then(res => {
  163 + const data = res && res.data ? (res.data.data || res.data) : {}
  164 + this.form = Object.assign({}, data)
  165 + this.lineList = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : []
  166 + })
  167 + .catch(() => {
  168 + uni.showToast({ title: '详情加载失败', icon: 'none' })
  169 + })
  170 + .finally(() => {
  171 + uni.hideLoading && uni.hideLoading()
  172 + })
  173 + },
  174 + handleButtonClick(btn) {
  175 + if (!btn || btn.disabled || !btn.visible) return
  176 + const e = btn.event || ''
  177 + if (e === 'edit') return this.onEdit()
  178 + if (e === 'submitAudit') return this.onSubmitAudit()
  179 + if (e === 'audit') return this.onAudit()
  180 + if (e === 'auditDetail') return this.onAuditDetail()
  181 + if (e === 'cancel') return this.onCancel()
  182 + },
  183 + onEdit() {
  184 + uni.navigateTo({ url: '/pages/outright-purchase/modify?id=' + this.id })
  185 + },
  186 + onAudit() {
  187 + const id = this.id || (this.form && this.form.id) || ''
  188 + if (!id) return
  189 + // 写入业务 id 与流程模块 code 后跳转 BPM 审核页(审核页读取后打开审核弹框)
  190 + uni.setStorageSync('contractType', 'BUYOUT_ACCOUNT_ORDER')
  191 + uni.setStorageSync('sourceBusinessId', id)
  192 + uni.navigateTo({ url: '/pages/flow/audit' })
  193 + },
  194 + onAuditDetail() {
  195 + const id = this.id || (this.form && this.form.id) || ''
  196 + if (!id) return
  197 + // 写入业务 id 与流程模块 code 后跳转 BPM 审核详情页(以查看模式打开审批详情)
  198 + uni.setStorageSync('contractType', 'BUYOUT_ACCOUNT_ORDER')
  199 + uni.setStorageSync('sourceBusinessId', id)
  200 + uni.navigateTo({ url: '/pages/flow/audit_detail' })
  201 + },
  202 + refreshListFlags() {
  203 + try {
  204 + uni.setStorageSync('OUTRIGHT_PURCHASE_LIST_NEED_REFRESH', '1')
  205 + uni.setStorageSync('OUTRIGHT_PURCHASE_DETAIL_NEED_REFRESH', '1')
  206 + } catch (e) {}
  207 + },
  208 + runWithConfirm(opts) {
  209 + const title = opts.title || '提示'
  210 + const content = opts.content || ''
  211 + const run = opts.run
  212 + const loading = opts.loading || '处理中'
  213 + const successText = opts.successText || '操作成功'
  214 + const failText = opts.failText || '操作失败'
  215 + if (!this.id) {
  216 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  217 + return
  218 + }
  219 + uni.showModal({
  220 + title,
  221 + content,
  222 + confirmText: '确定',
  223 + cancelText: '取消',
  224 + success: res => {
  225 + if (!res || !res.confirm) return
  226 + uni.showLoading({ title: loading, mask: true })
  227 + Promise.resolve(run(this.id))
  228 + .then(() => {
  229 + uni.hideLoading()
  230 + uni.showToast({ title: successText, icon: 'none' })
  231 + this.refreshListFlags()
  232 + this.loadDetail()
  233 + })
  234 + .catch(e => {
  235 + uni.hideLoading()
  236 + uni.showToast({ title: (e && (e.msg || e.message)) || failText, icon: 'none' })
  237 + })
  238 + }
  239 + })
  240 + },
  241 + onSubmitAudit() {
  242 + this.runWithConfirm({
  243 + title: '提交审核确认',
  244 + content: '确认提交审核吗?',
  245 + loading: '提交中',
  246 + successText: '提交审核成功',
  247 + failText: '提交审核失败',
  248 + run: id => outrightPurchaseSubmitAuditApi(id)
  249 + })
  250 + },
  251 + onCancel() {
  252 + this.runWithConfirm({
  253 + title: '取消确认',
  254 + content: '确认取消该核算单吗?',
  255 + loading: '处理中',
  256 + successText: '取消成功',
  257 + failText: '取消失败',
  258 + run: id => outrightPurchaseCancelApi(id)
  259 + })
  260 + },
  261 + safeText(v) {
  262 + const s = v == null ? '' : String(v)
  263 + return s.trim() ? s : '-'
  264 + },
  265 + formatNumber(v) {
  266 + if (v === null || v === undefined || v === '') return '-'
  267 + const n = Number(v)
  268 + if (isNaN(n)) return String(v)
  269 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  270 + }
  271 + }
  272 +}
  273 +</script>
  274 +
  275 +<style lang="scss" scoped>
  276 +.page {
  277 + display: flex;
  278 + flex-direction: column;
  279 + height: 100%;
  280 +}
  281 +.scroll {
  282 + flex: 1;
  283 + padding: 8rpx 0 144rpx;
  284 +}
  285 +.detail-page {
  286 + background: #f3f3f3;
  287 +}
  288 +.section {
  289 + padding: 32rpx;
  290 + background: #fff;
  291 + margin-bottom: 20rpx;
  292 +}
  293 +.title-header {
  294 + display: flex;
  295 + align-items: center;
  296 + padding: 24rpx 32rpx 12rpx;
  297 + background-color: #ffffff;
  298 + .title-header_icon { width: 36rpx; height: 36rpx; margin-right: 12rpx; }
  299 + span { font-size: 34rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); }
  300 +}
  301 +.row {
  302 + display: flex;
  303 + margin-bottom: 28rpx;
  304 + &:last-child { margin-bottom: 0; }
  305 + &.company {
  306 + font-size: 36rpx;
  307 + font-weight: 600;
  308 + color: rgba(0, 0, 0, 0.9);
  309 + padding-top: 8rpx;
  310 + line-height: 50rpx;
  311 + }
  312 + .label {
  313 + max-width: 420rpx;
  314 + margin-right: 20rpx;
  315 + line-height: 32rpx;
  316 + font-size: 28rpx;
  317 + color: rgba(0, 0, 0, 0.6);
  318 + }
  319 + .value {
  320 + flex: 1;
  321 + line-height: 32rpx;
  322 + font-size: 28rpx;
  323 + color: rgba(0, 0, 0, 0.9);
  324 + text-align: right;
  325 + word-break: break-all;
  326 + }
  327 +}
  328 +.sub-table {
  329 + background: #fff;
  330 + margin-bottom: 20rpx;
  331 +}
  332 +.sub-header {
  333 + display: flex;
  334 + align-items: center;
  335 + padding: 16rpx 0 16rpx 32rpx;
  336 + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; }
  337 + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; }
  338 + .sub-toggle {
  339 + display: flex;
  340 + align-items: center;
  341 + padding: 0 12rpx;
  342 + height: 56rpx;
  343 + .sub-toggle_icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; }
  344 + .sub-toggle_text { font-size: 26rpx; color: rgba(0, 0, 0, 0.6); }
  345 + }
  346 +}
  347 +.sub-body {
  348 + padding: 0 32rpx 24rpx;
  349 + .empty-tip {
  350 + text-align: center;
  351 + padding: 60rpx 0;
  352 + color: rgba(0, 0, 0, 0.4);
  353 + font-size: 28rpx;
  354 + }
  355 + .card {
  356 + position: relative;
  357 + background: #fafafa;
  358 + border-radius: 12rpx;
  359 + padding: 32rpx 28rpx 20rpx;
  360 + margin-bottom: 24rpx;
  361 + .card-index {
  362 + position: absolute;
  363 + top: 0;
  364 + right: 0;
  365 + background: rgba(24, 144, 255, 0.08);
  366 + color: $theme-primary;
  367 + font-size: 22rpx;
  368 + line-height: 36rpx;
  369 + padding: 0 16rpx;
  370 + border-bottom-left-radius: 12rpx;
  371 + border-top-right-radius: 12rpx;
  372 + }
  373 + .row {
  374 + align-items: center;
  375 + justify-content: space-between;
  376 + padding: 14rpx 0;
  377 + margin-bottom: 0;
  378 + border-bottom: 1rpx dashed #f2f2f2;
  379 + &:last-child { border-bottom: none; }
  380 + .label {
  381 + flex-shrink: 0;
  382 + width: 220rpx;
  383 + max-width: none;
  384 + margin-right: 0;
  385 + font-size: 28rpx;
  386 + color: rgba(0, 0, 0, 0.6);
  387 + line-height: 40rpx;
  388 + }
  389 + .value {
  390 + flex: 1;
  391 + text-align: right;
  392 + font-size: 28rpx;
  393 + color: rgba(0, 0, 0, 0.9);
  394 + line-height: 40rpx;
  395 + overflow: hidden;
  396 + text-overflow: ellipsis;
  397 + white-space: nowrap;
  398 + }
  399 + }
  400 + }
  401 +}
  402 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <view class="ticket-list-fixed">
  4 + <view class="search-row">
  5 + <uni-search-bar
  6 + v-model="searchKeyword"
  7 + radius="6"
  8 + placeholder="请输入码单编号"
  9 + clearButton="auto"
  10 + cancelButton="none"
  11 + bgColor="#F3F3F3"
  12 + textColor="rgba(0,0,0,0.4)"
  13 + @confirm="search"
  14 + @input="onSearchInput"
  15 + />
  16 + <view class="tool-icons">
  17 + <image
  18 + v-if="$auth.hasPermi('warehouse-manage:outright-purchase: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.weighingTicketCode || '-' }}</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.planCodes.join(',') || '-' }}</text>
  60 + </view>
  61 + <view class="info-row">
  62 + <text>来料单位</text>
  63 + <text>{{ item.incomingUnit || '-' }}</text>
  64 + </view>
  65 + <view class="info-row">
  66 + <text>分厂</text>
  67 + <text>{{ item.workshopName || '-' }}</text>
  68 + </view>
  69 + <view class="info-row">
  70 + <text>流程节点</text>
  71 + <text>{{ getFlowNodeText(item.flowNode) }}</text>
  72 + </view>
  73 + <view class="info-row">
  74 + <text>时间</text>
  75 + <text>{{ formatDateOnly(item.createTime) }}</text>
  76 + </view>
  77 + </view>
  78 + </template>
  79 + </card-list>
  80 + </view>
  81 +
  82 + <filter-modal
  83 + :visible.sync="filterVisible"
  84 + :value.sync="filterForm"
  85 + title="筛选"
  86 + @reset="onFilterReset"
  87 + @confirm="onFilterConfirm"
  88 + >
  89 + <template v-slot="{ model }">
  90 + <view class="filter-form">
  91 + <view class="form-item">
  92 + <view class="label">码单编号</view>
  93 + <input class="input" v-model="model.weighingTicketCode" placeholder="请输入码单编号" />
  94 + </view>
  95 + <view class="form-item">
  96 + <view class="label">计划编号</view>
  97 + <input class="input" v-model="model.planCodes" placeholder="请输入计划编号" />
  98 + </view>
  99 + <view class="form-item">
  100 + <view class="label">来料单位</view>
  101 + <input class="input" v-model="model.incomingUnit" placeholder="请输入来料单位" />
  102 + </view>
  103 + <view class="form-item">
  104 + <view class="label">分厂</view>
  105 + <picker mode="selector" :range="workshopLabels" @change="onWorkshopChange">
  106 + <view class="fake-select">
  107 + <text v-if="workshopLabel" class="value">{{ workshopLabel }}</text>
  108 + <text v-else class="placeholder">请选择分厂</text>
  109 + </view>
  110 + </picker>
  111 + </view>
  112 + <view class="form-item">
  113 + <view class="label">流程节点</view>
  114 + <picker mode="selector" :range="flowNodeLabels" @change="onFlowNodeChange">
  115 + <view class="fake-select">
  116 + <text v-if="flowNodeLabel" class="value">{{ flowNodeLabel }}</text>
  117 + <text v-else class="placeholder">请选择流程节点</text>
  118 + </view>
  119 + </picker>
  120 + </view>
  121 + <view class="form-item">
  122 + <view class="label">审核状态</view>
  123 + <uni-data-checkbox
  124 + mode="tag"
  125 + :multiple="false"
  126 + :value-field="'value'"
  127 + :text-field="'text'"
  128 + v-model="model.approvalStatus"
  129 + :localdata="approvalStatusOptions"
  130 + />
  131 + </view>
  132 + <view class="form-item">
  133 + <view class="label">时间</view>
  134 + <uni-datetime-picker type="daterange" v-model="model.timeRange" start="2023-01-01" />
  135 + </view>
  136 + </view>
  137 + </template>
  138 + </filter-modal>
  139 + </view>
  140 +</template>
  141 +
  142 +<script>
  143 +import CardList from '@/components/card/index.vue'
  144 +import FilterModal from '@/components/filter/index.vue'
  145 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  146 +import { outrightPurchaseQueryApi } from '@/api/procure-manage/outrightPurchase.js'
  147 +import { workshopQueryApi } from '@/api/procure-manage/warehouseMaterial.js'
  148 +
  149 +export default {
  150 + name: 'OutrightPurchaseList',
  151 + components: { CardList, FilterModal },
  152 + data() {
  153 + return {
  154 + searchKeyword: '',
  155 + searchKeywordDebounced: '',
  156 + searchDebounceTimer: null,
  157 + deleted: false,
  158 + tabs: [
  159 + { label: '有效', value: false },
  160 + { label: '作废', value: true }
  161 + ],
  162 + query: {
  163 + weighingTicketCode: '',
  164 + planCodes: '',
  165 + incomingUnit: '',
  166 + workshopId: '',
  167 + flowNode: '',
  168 + approvalStatus: '',
  169 + timeRange: []
  170 + },
  171 + extraParams: {},
  172 + currentItems: [],
  173 + filterVisible: false,
  174 + filterForm: {
  175 + weighingTicketCode: '',
  176 + planCodes: '',
  177 + incomingUnit: '',
  178 + workshopId: '',
  179 + flowNode: '',
  180 + approvalStatus: '',
  181 + timeRange: []
  182 + },
  183 + approvalStatusOptions: [
  184 + { value: '', text: '全部' },
  185 + { value: 'DRAFT', text: '草稿' },
  186 + { value: 'AUDIT', text: '审核中' },
  187 + { value: 'PASS', text: '审核通过' },
  188 + { value: 'REFUSE', text: '已驳回' },
  189 + { value: 'CANCEL', text: '已取消' }
  190 + ],
  191 + workshopOptions: [],
  192 + workshopLabel: '',
  193 + flowNodeOptions: [],
  194 + flowNodeLabel: '',
  195 + dicOptions: {
  196 + AUDIT_STATUS: [],
  197 + BUYOUT_FLOW_NODE: []
  198 + }
  199 + }
  200 + },
  201 + computed: {
  202 + workshopLabels() {
  203 + return ['全部'].concat(this.workshopOptions.map(it => it.label))
  204 + },
  205 + flowNodeLabels() {
  206 + return ['全部'].concat(this.flowNodeOptions.map(it => it.name || ''))
  207 + },
  208 + extraCombined() {
  209 + return {
  210 + keyword: this.searchKeywordDebounced || undefined,
  211 + deleted: this.deleted
  212 + }
  213 + }
  214 + },
  215 + watch: {
  216 + extraCombined: {
  217 + deep: true,
  218 + handler(v) {
  219 + this.extraParams = v
  220 + },
  221 + immediate: true
  222 + }
  223 + },
  224 + created() {
  225 + this.loadDicData()
  226 + this.loadWorkshopOptions()
  227 + },
  228 + onShow() {
  229 + let needRefresh = ''
  230 + try { needRefresh = uni.getStorageSync('OUTRIGHT_PURCHASE_LIST_NEED_REFRESH') } catch (e) {}
  231 + if (!needRefresh) return
  232 + try { uni.removeStorageSync('OUTRIGHT_PURCHASE_LIST_NEED_REFRESH') } catch (e) {}
  233 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.reload) {
  234 + this.$refs.cardRef.reload()
  235 + }
  236 + },
  237 + onReachBottom() {
  238 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.onLoadMore) {
  239 + this.$refs.cardRef.onLoadMore()
  240 + }
  241 + },
  242 + beforeDestroy() {
  243 + if (this.searchDebounceTimer) {
  244 + clearTimeout(this.searchDebounceTimer)
  245 + this.searchDebounceTimer = null
  246 + }
  247 + },
  248 + methods: {
  249 + async loadDicData() {
  250 + try {
  251 + const results = await getDicByCodes(['AUDIT_STATUS', 'BUYOUT_FLOW_NODE'])
  252 + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || []
  253 + this.dicOptions.BUYOUT_FLOW_NODE = (results.BUYOUT_FLOW_NODE && results.BUYOUT_FLOW_NODE.data) || []
  254 + this.flowNodeOptions = this.dicOptions.BUYOUT_FLOW_NODE
  255 + } catch (e) {
  256 + this.dicOptions = { AUDIT_STATUS: [], BUYOUT_FLOW_NODE: [] }
  257 + this.flowNodeOptions = []
  258 + }
  259 + },
  260 + async loadWorkshopOptions() {
  261 + try {
  262 + const res = await workshopQueryApi({ pageIndex: 1, pageSize: 9999 })
  263 + const _data = (res && res.data) || {}
  264 + const datas = _data.datas || _data.list || _data.records || []
  265 + this.workshopOptions = datas.map(item => ({
  266 + label: item.name || '',
  267 + value: item.id || ''
  268 + })).filter(it => it.value)
  269 + } catch (e) {
  270 + this.workshopOptions = []
  271 + }
  272 + },
  273 + getAuditStatusText(status) {
  274 + const v = status == null ? '' : String(status)
  275 + if (!v) return '-'
  276 + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v
  277 + },
  278 + getFlowNodeText(node) {
  279 + const v = node == null ? '' : String(node)
  280 + if (!v) return '-'
  281 + return getDicName('BUYOUT_FLOW_NODE', v, this.dicOptions.BUYOUT_FLOW_NODE) || v
  282 + },
  283 + formatDateOnly(v) {
  284 + const s = v == null ? '' : String(v).trim()
  285 + if (!s) return '-'
  286 + if (s.length >= 10) return s.slice(0, 10)
  287 + return s
  288 + },
  289 + onCardLoaded({ items }) {
  290 + this.currentItems = items
  291 + },
  292 + onCardError() {
  293 + uni.showToast({ title: '列表加载失败', icon: 'none' })
  294 + },
  295 + onAdd() {
  296 + uni.navigateTo({ url: '/pages/outright-purchase/add' })
  297 + },
  298 + onSearchInput() {
  299 + if (this.searchDebounceTimer) clearTimeout(this.searchDebounceTimer)
  300 + this.searchDebounceTimer = setTimeout(() => {
  301 + this.searchKeywordDebounced = this.searchKeyword
  302 + this.searchDebounceTimer = null
  303 + }, 1200)
  304 + },
  305 + search(e) {
  306 + const val = e && e.value != null ? e.value : this.searchKeyword
  307 + this.searchKeyword = val
  308 + this.searchKeywordDebounced = val
  309 + },
  310 + switchTab(t) {
  311 + this.deleted = t.value
  312 + },
  313 + onWorkshopChange(e) {
  314 + const idx = Number(e.detail.value)
  315 + if (idx <= 0) {
  316 + this.filterForm.workshopId = ''
  317 + this.workshopLabel = ''
  318 + } else {
  319 + const opt = this.workshopOptions[idx - 1]
  320 + this.filterForm.workshopId = opt ? opt.value : ''
  321 + this.workshopLabel = opt ? opt.label : ''
  322 + }
  323 + },
  324 + onFlowNodeChange(e) {
  325 + const idx = Number(e.detail.value)
  326 + if (idx <= 0) {
  327 + this.filterForm.flowNode = ''
  328 + this.flowNodeLabel = ''
  329 + } else {
  330 + const opt = this.flowNodeOptions[idx - 1]
  331 + this.filterForm.flowNode = opt ? (opt.code == null ? '' : String(opt.code)) : ''
  332 + this.flowNodeLabel = opt ? (opt.name || '') : ''
  333 + }
  334 + },
  335 + openFilter() {
  336 + this.filterForm = {
  337 + weighingTicketCode: this.query.weighingTicketCode || '',
  338 + planCodes: this.query.planCodes || '',
  339 + incomingUnit: this.query.incomingUnit || '',
  340 + workshopId: this.query.workshopId || '',
  341 + flowNode: this.query.flowNode || '',
  342 + approvalStatus: this.query.approvalStatus || '',
  343 + timeRange: Array.isArray(this.query.timeRange) ? this.query.timeRange.slice(0) : []
  344 + }
  345 + const foundWorkshop = this.workshopOptions.find(it => it.value === this.filterForm.workshopId)
  346 + this.workshopLabel = foundWorkshop ? foundWorkshop.label : ''
  347 + const foundNode = this.flowNodeOptions.find(it => String(it.code) === String(this.filterForm.flowNode))
  348 + this.flowNodeLabel = foundNode ? (foundNode.name || '') : ''
  349 + this.filterVisible = true
  350 + },
  351 + onFilterReset(payload) {
  352 + this.filterForm = payload
  353 + this.workshopLabel = ''
  354 + this.flowNodeLabel = ''
  355 + },
  356 + onFilterConfirm(payload) {
  357 + this.query = {
  358 + weighingTicketCode: payload.weighingTicketCode || '',
  359 + planCodes: payload.planCodes || '',
  360 + incomingUnit: payload.incomingUnit || '',
  361 + workshopId: payload.workshopId || '',
  362 + flowNode: payload.flowNode || '',
  363 + approvalStatus: payload.approvalStatus || '',
  364 + timeRange: Array.isArray(payload.timeRange) ? payload.timeRange : []
  365 + }
  366 + },
  367 + fetchList({ pageIndex, pageSize, query, extra }) {
  368 + const q = query || {}
  369 + const e = extra || {}
  370 + const range = Array.isArray(q.timeRange) ? q.timeRange : []
  371 + const keyword = e.keyword || ''
  372 + const params = {
  373 + pageIndex,
  374 + pageSize,
  375 + deleted: e.deleted === true,
  376 + weighingTicketCode: q.weighingTicketCode || keyword || '',
  377 + planCodes: q.planCodes || '',
  378 + incomingUnit: q.incomingUnit || '',
  379 + workshopId: q.workshopId || '',
  380 + flowNode: q.flowNode || '',
  381 + approvalStatus: q.approvalStatus || '',
  382 + startTime: range && range.length === 2 ? range[0] : '',
  383 + endTime: range && range.length === 2 ? range[1] : ''
  384 + }
  385 + return outrightPurchaseQueryApi(params)
  386 + .then(res => {
  387 + const _data = (res && res.data) || {}
  388 + let records = _data.datas || _data.list || _data.records || []
  389 + const totalCount = _data.totalCount || _data.count || 0
  390 + const hasNext = _data.hasNext || false
  391 + records = records.map(it => ({ ...it }))
  392 + return { records, totalCount, hasNext }
  393 + })
  394 + .catch(() => {
  395 + this.onCardError()
  396 + return { records: [], totalCount: 0, hasNext: false }
  397 + })
  398 + },
  399 + onCardClick(item) {
  400 + const id = item && item.id
  401 + if (!id) {
  402 + uni.showToast({ title: '缺少ID', icon: 'none' })
  403 + return
  404 + }
  405 + uni.navigateTo({ url: '/pages/outright-purchase/detail?id=' + id })
  406 + }
  407 + }
  408 +}
  409 +</script>
  410 +
  411 +<style lang="scss" scoped>
  412 +.page {
  413 + display: flex;
  414 + flex-direction: column;
  415 + height: 100vh;
  416 +}
  417 +.ticket-list-fixed {
  418 + position: fixed;
  419 + top: 96rpx;
  420 + left: 0;
  421 + right: 0;
  422 + z-index: 2;
  423 + background: #fff;
  424 + .search-row {
  425 + display: flex;
  426 + align-items: center;
  427 + padding: 16rpx 32rpx;
  428 + .uni-searchbar { padding: 0; flex: 1; }
  429 + .tool-icons {
  430 + display: flex;
  431 + .tool-icon { width: 48rpx; height: 48rpx; display: block; margin-left: 32rpx; }
  432 + }
  433 + }
  434 + .tabs {
  435 + display: flex;
  436 + align-items: center;
  437 + justify-content: space-between;
  438 + padding: 26rpx 34rpx;
  439 + border-bottom: solid 1px #e7e7e7;
  440 + .tab { width: 50%; text-align: center; color: rgba(0, 0, 0, 0.9); line-height: 44rpx; position: relative; font-weight: 600; }
  441 + .tab.active { color: $theme-primary; }
  442 + .tab.active::after {
  443 + content: '';
  444 + position: absolute;
  445 + left: 50%;
  446 + transform: translateX(-50%);
  447 + bottom: -13px;
  448 + width: 32rpx;
  449 + height: 6rpx;
  450 + border-radius: 4rpx;
  451 + background: $theme-primary;
  452 + }
  453 + }
  454 +}
  455 +::v-deep .uni-searchbar__box {
  456 + height: 80rpx !important;
  457 + justify-content: start;
  458 + .uni-searchbar__box-search-input { font-size: 32rpx !important; }
  459 +}
  460 +.list-box {
  461 + flex: 1;
  462 + padding-top: 236rpx;
  463 + .card { position: relative; }
  464 + .card-header {
  465 + margin-bottom: 28rpx;
  466 + position: relative;
  467 + .title { font-size: 36rpx; font-weight: 600; line-height: 50rpx; color: rgba(0, 0, 0, 0.9); width: 578rpx; }
  468 + .status {
  469 + position: absolute;
  470 + top: -32rpx;
  471 + right: -12rpx;
  472 + height: 48rpx;
  473 + line-height: 48rpx;
  474 + font-weight: 600;
  475 + color: #fff;
  476 + font-size: 24rpx;
  477 + padding: 0 14rpx;
  478 + border-radius: 6rpx;
  479 + box-sizing: content-box;
  480 +
  481 + &.status_AUDIT { background: $theme-primary; }
  482 + &.status_PASS { background: #2ba471; }
  483 + &.status_REFUSE { background: #d54941; }
  484 + &.status_DRAFT { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); }
  485 + &.status_CANCEL { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); }
  486 + }
  487 + }
  488 + .info-row {
  489 + display: flex;
  490 + align-items: center;
  491 + color: rgba(0, 0, 0, 0.6);
  492 + font-size: 28rpx;
  493 + margin-bottom: 24rpx;
  494 + height: 32rpx;
  495 + &:last-child { margin-bottom: 0; }
  496 + text {
  497 + width: 50%;
  498 + &:last-child {
  499 + color: rgba(0, 0, 0, 0.9);
  500 + width: 50%;
  501 + overflow: hidden;
  502 + text-overflow: ellipsis;
  503 + white-space: nowrap;
  504 + }
  505 + }
  506 + }
  507 +}
  508 +.filter-form {
  509 + .form-item { margin-bottom: 24rpx; }
  510 + .label { margin-bottom: 20rpx; color: rgba(0, 0, 0, 0.9); height: 44rpx; line-height: 44rpx; font-size: 30rpx; }
  511 + .input {
  512 + width: 100%;
  513 + height: 72rpx;
  514 + line-height: 72rpx;
  515 + padding: 0 24rpx;
  516 + border: 1rpx solid #e7e7e7;
  517 + border-radius: 8rpx;
  518 + font-size: 28rpx;
  519 + color: rgba(0, 0, 0, 0.9);
  520 + background: #fff;
  521 + box-sizing: border-box;
  522 + }
  523 + .fake-select {
  524 + height: 72rpx;
  525 + line-height: 72rpx;
  526 + padding: 0 24rpx;
  527 + border: 1rpx solid #e7e7e7;
  528 + border-radius: 8rpx;
  529 + font-size: 28rpx;
  530 + .placeholder { color: #999; }
  531 + .value { color: rgba(0, 0, 0, 0.9); }
  532 + }
  533 +}
  534 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <!-- 基础信息(详情回显,只读) -->
  5 + <uni-list>
  6 + <uni-list-item title="码单编号">
  7 + <template v-slot:footer>
  8 + <text class="readonly-text">{{ form.weighingTicketCode || '-' }}</text>
  9 + </template>
  10 + </uni-list-item>
  11 + <uni-list-item title="来料单位">
  12 + <template v-slot:footer>
  13 + <uni-easyinput :value="form.incomingUnit" :inputBorder="false" disabled />
  14 + </template>
  15 + </uni-list-item>
  16 + <uni-list-item title="计划单编号">
  17 + <template v-slot:footer>
  18 + <uni-easyinput :value="form.planCodes" :inputBorder="false" disabled />
  19 + </template>
  20 + </uni-list-item>
  21 + <uni-list-item title="采购处">
  22 + <template v-slot:footer>
  23 + <uni-easyinput :value="form.purchaseDepartmentName" :inputBorder="false" disabled />
  24 + </template>
  25 + </uni-list-item>
  26 + <uni-list-item title="区域">
  27 + <template v-slot:footer>
  28 + <uni-easyinput :value="form.regionName" :inputBorder="false" disabled />
  29 + </template>
  30 + </uni-list-item>
  31 + </uni-list>
  32 +
  33 + <!-- 明细数据(详情回显,入库数量/入库单价/入库金额/实际吨损耗可编辑) -->
  34 + <view class="sub-table">
  35 + <view class="header">
  36 + <image class="opCollapse" src="/static/images/title.png" />
  37 + <text class="title">明细数据</text>
  38 + </view>
  39 + <view class="add-list">
  40 + <view v-if="!lineList.length" class="empty-tip">暂无明细</view>
  41 + <view v-for="(item, idx) in lineList" :key="'l-' + (item.rowId || item.id || idx)" class="block">
  42 + <uni-list>
  43 + <uni-list-item title="买断品种">
  44 + <template v-slot:footer>
  45 + <uni-easyinput :value="item.buyoutCategory" :inputBorder="false" disabled />
  46 + </template>
  47 + </uni-list-item>
  48 + <uni-list-item title="买断数量">
  49 + <template v-slot:footer>
  50 + <uni-easyinput :value="item.buyoutQuantity" :inputBorder="false" disabled />
  51 + </template>
  52 + </uni-list-item>
  53 + <uni-list-item title="买断单价">
  54 + <template v-slot:footer>
  55 + <uni-easyinput :value="item.buyoutPrice" :inputBorder="false" disabled />
  56 + </template>
  57 + </uni-list-item>
  58 + <uni-list-item title="买断金额">
  59 + <template v-slot:footer>
  60 + <uni-easyinput :value="item.buyoutAmount" :inputBorder="false" disabled />
  61 + </template>
  62 + </uni-list-item>
  63 + <uni-list-item>
  64 + <template v-slot:body>
  65 + <view class="item-title"><text class="required">*</text><text>入库数量</text></view>
  66 + </template>
  67 + <template v-slot:footer>
  68 + <uni-easyinput v-model="item.instockQuantity" type="digit" :inputBorder="false" placeholder="请输入入库数量" @input="recalcDiffAmount(item)" />
  69 + </template>
  70 + </uni-list-item>
  71 + <uni-list-item>
  72 + <template v-slot:body>
  73 + <view class="item-title"><text class="required">*</text><text>入库单价</text></view>
  74 + </template>
  75 + <template v-slot:footer>
  76 + <uni-easyinput v-model="item.instockPrice" type="digit" :inputBorder="false" placeholder="请输入入库单价" />
  77 + </template>
  78 + </uni-list-item>
  79 + <uni-list-item>
  80 + <template v-slot:body>
  81 + <view class="item-title"><text class="required">*</text><text>入库金额</text></view>
  82 + </template>
  83 + <template v-slot:footer>
  84 + <uni-easyinput v-model="item.instockAmount" type="digit" :inputBorder="false" placeholder="请输入入库金额" />
  85 + </template>
  86 + </uni-list-item>
  87 + <uni-list-item title="预计吨损耗(元/吨)">
  88 + <template v-slot:footer>
  89 + <uni-easyinput :value="item.expectTonLoss" :inputBorder="false" disabled />
  90 + </template>
  91 + </uni-list-item>
  92 + <uni-list-item>
  93 + <template v-slot:body>
  94 + <view class="item-title"><text class="required">*</text><text>实际吨损耗(元/吨)</text></view>
  95 + </template>
  96 + <template v-slot:footer>
  97 + <uni-easyinput v-model="item.actualTonLoss" type="digit" :inputBorder="false" placeholder="请输入实际吨损耗" @input="recalcTonLossDiff(item)" />
  98 + </template>
  99 + </uni-list-item>
  100 + <uni-list-item title="吨损耗差异(元/吨)">
  101 + <template v-slot:footer>
  102 + <uni-easyinput :value="item.tonLossDiff" :inputBorder="false" disabled placeholder="预计-实际自动计算" />
  103 + </template>
  104 + </uni-list-item>
  105 + <uni-list-item title="差异金额(元)">
  106 + <template v-slot:footer>
  107 + <uni-easyinput :value="item.diffAmount" :inputBorder="false" disabled placeholder="入库数量×吨损耗差异/1000" />
  108 + </template>
  109 + </uni-list-item>
  110 + </uni-list>
  111 + </view>
  112 + </view>
  113 + </view>
  114 +
  115 + <!-- 合计 -->
  116 + <view class="total-card">
  117 + <view class="total-title">合计</view>
  118 + <view class="total-body">
  119 + <view class="total-item">
  120 + <text class="total-label">买断数量</text>
  121 + <text class="total-value">{{ totalSummary.totalBuyoutQuantity || '-' }}</text>
  122 + </view>
  123 + <view class="total-item">
  124 + <text class="total-label">买断金额</text>
  125 + <text class="total-value">{{ totalSummary.totalBuyoutAmount || '-' }}</text>
  126 + </view>
  127 + <view class="total-item">
  128 + <text class="total-label">入库数量</text>
  129 + <text class="total-value">{{ totalSummary.totalInstockQuantity || '-' }}</text>
  130 + </view>
  131 + <view class="total-item">
  132 + <text class="total-label">入库金额</text>
  133 + <text class="total-value">{{ totalSummary.totalInstockAmount || '-' }}</text>
  134 + </view>
  135 + <view class="total-item">
  136 + <text class="total-label">差异金额</text>
  137 + <text class="total-value">{{ totalSummary.totalDiffAmount || '-' }}</text>
  138 + </view>
  139 + </view>
  140 + </view>
  141 +
  142 + <!-- 其他信息 -->
  143 + <view class="remark-section">
  144 + <view class="header">
  145 + <image class="opCollapse" src="/static/images/title.png" />
  146 + <text class="title">其他信息</text>
  147 + </view>
  148 + <view class="section-content">
  149 + <uni-list>
  150 + <uni-list-item>
  151 + <template v-slot:body>
  152 + <view class="item-title"><text class="required">*</text><text>磅差情况</text></view>
  153 + </template>
  154 + <template v-slot:footer>
  155 + <uni-easyinput v-model="form.weighDiff" type="digit" :inputBorder="false" placeholder="请输入磅差情况" />
  156 + </template>
  157 + </uni-list-item>
  158 + </uni-list>
  159 + </view>
  160 + </view>
  161 +
  162 + <view class="footer">
  163 + <button class="btn submit" type="primary" @click="onSubmit">保存</button>
  164 + </view>
  165 + </scroll-view>
  166 + </view>
  167 +</template>
  168 +
  169 +<script>
  170 +import {
  171 + outrightPurchaseDetailApi,
  172 + outrightPurchaseUpdateApi
  173 +} from '@/api/procure-manage/outrightPurchase.js'
  174 +
  175 +export default {
  176 + name: 'ModifyOutrightPurchase',
  177 + data() {
  178 + return {
  179 + id: '',
  180 + form: {
  181 + id: '',
  182 + settleDetailId: '',
  183 + weighingTicketCode: '',
  184 + incomingUnit: '',
  185 + planCodes: '',
  186 + purchaseDepartmentName: '',
  187 + regionName: '',
  188 + weighDiff: ''
  189 + },
  190 + // 明细数据(详情回显,保留行主键 id,提交时随行携带)
  191 + lineList: []
  192 + }
  193 + },
  194 + computed: {
  195 + // 明细各数值列合计(保留两位)
  196 + totalSummary() {
  197 + const list = this.lineList || []
  198 + return {
  199 + totalBuyoutQuantity: this.calcTotal(list, 'buyoutQuantity'),
  200 + totalBuyoutAmount: this.calcTotal(list, 'buyoutAmount'),
  201 + totalInstockQuantity: this.calcTotal(list, 'instockQuantity'),
  202 + totalInstockAmount: this.calcTotal(list, 'instockAmount'),
  203 + totalDiffAmount: this.calcTotal(list, 'diffAmount')
  204 + }
  205 + }
  206 + },
  207 + onLoad(query) {
  208 + this.id = (query && query.id) || ''
  209 + this.loadDetail()
  210 + },
  211 + methods: {
  212 + loadDetail() {
  213 + if (!this.id) {
  214 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  215 + return
  216 + }
  217 + uni.showLoading({ title: '加载中...', mask: true })
  218 + outrightPurchaseDetailApi({ id: this.id })
  219 + .then(res => {
  220 + const data = res && res.data ? (res.data.data || res.data) : {}
  221 + this.form = {
  222 + id: data.id || this.id,
  223 + settleDetailId: data.settleDetailId || '',
  224 + weighingTicketCode: data.weighingTicketCode || '',
  225 + incomingUnit: data.incomingUnit || '',
  226 + planCodes: data.planCodes || '',
  227 + purchaseDepartmentName: data.purchaseDepartmentName || '',
  228 + regionName: data.regionName || '',
  229 + weighDiff: data.weighDiff == null ? '' : data.weighDiff
  230 + }
  231 + // 明细回显(保留行主键 id,提交时随行携带)
  232 + this.lineList = (Array.isArray(data.lines) ? data.lines : []).map(item => ({
  233 + rowId: genRowId(),
  234 + id: item.id || '',
  235 + itemId: item.id || item.settleLineId || '',
  236 + settleLineId: item.settleLineId || '',
  237 + procurementPlanId: item.procurementPlanId || '',
  238 + productId: item.productId || '',
  239 + buyoutCategory: item.buyoutCategory || '',
  240 + buyoutQuantity: item.buyoutQuantity == null ? '' : item.buyoutQuantity,
  241 + buyoutPrice: item.buyoutPrice == null ? '' : item.buyoutPrice,
  242 + buyoutAmount: item.buyoutAmount == null ? '' : item.buyoutAmount,
  243 + instockQuantity: item.instockQuantity == null ? '' : item.instockQuantity,
  244 + instockPrice: item.instockPrice == null ? '' : item.instockPrice,
  245 + instockAmount: item.instockAmount == null ? '' : item.instockAmount,
  246 + expectTonLoss: item.expectTonLoss == null ? '' : item.expectTonLoss,
  247 + actualTonLoss: item.actualTonLoss == null ? '' : item.actualTonLoss,
  248 + tonLossDiff: item.tonLossDiff == null ? '' : item.tonLossDiff,
  249 + diffAmount: item.diffAmount == null ? '' : item.diffAmount
  250 + }))
  251 + })
  252 + .catch(() => {
  253 + uni.showToast({ title: '详情加载失败', icon: 'none' })
  254 + })
  255 + .finally(() => {
  256 + uni.hideLoading()
  257 + })
  258 + },
  259 + // 吨损耗差异 = 预计吨损耗 - 实际吨损耗(预计或实际为空则差异为空),并联动差异金额
  260 + recalcTonLossDiff(row) {
  261 + const expect = row.expectTonLoss
  262 + const actual = row.actualTonLoss
  263 + const hasExpect = expect !== null && expect !== undefined && expect !== ''
  264 + const hasActual = actual !== null && actual !== undefined && actual !== ''
  265 + if (hasExpect && hasActual) {
  266 + row.tonLossDiff = Math.round((Number(expect) - Number(actual)) * 100) / 100
  267 + } else {
  268 + row.tonLossDiff = ''
  269 + }
  270 + this.recalcDiffAmount(row)
  271 + },
  272 + // 差异金额 = 入库数量 * 吨损耗差异 / 1000(入库数量或吨损耗差异为空则金额为空)
  273 + recalcDiffAmount(row) {
  274 + const qty = row.instockQuantity
  275 + const diff = row.tonLossDiff
  276 + const hasQty = qty !== null && qty !== undefined && qty !== ''
  277 + const hasDiff = diff !== null && diff !== undefined && diff !== ''
  278 + if (hasQty && hasDiff) {
  279 + row.diffAmount = Math.round(((Number(qty) * Number(diff)) / 1000) * 100) / 100
  280 + } else {
  281 + row.diffAmount = ''
  282 + }
  283 + },
  284 + // 计算合计(保留两位,空值按0处理,无数据返回 '-')
  285 + calcTotal(list, field) {
  286 + if (!list.length) return ''
  287 + const total = Number(list.reduce((sum, row) => sum + Number(row[field] || 0), 0).toFixed(2))
  288 + return String(total)
  289 + },
  290 + validate() {
  291 + if (this.form.weighDiff === '' || this.form.weighDiff == null) return this.tip('请输入磅差情况')
  292 + return true
  293 + },
  294 + tip(msg) {
  295 + uni.showToast({ title: msg, icon: 'none' })
  296 + return false
  297 + },
  298 + toNum(v) {
  299 + if (v === null || v === undefined || v === '') return null
  300 + const n = Number(v)
  301 + return isNaN(n) ? null : n
  302 + },
  303 + buildSubmitData() {
  304 + return {
  305 + id: this.form.id,
  306 + settleDetailId: this.form.settleDetailId,
  307 + totalBuyoutQuantity: this.toNum(this.totalSummary.totalBuyoutQuantity),
  308 + totalBuyoutAmount: this.toNum(this.totalSummary.totalBuyoutAmount),
  309 + totalInstockQuantity: this.toNum(this.totalSummary.totalInstockQuantity),
  310 + totalInstockAmount: this.toNum(this.totalSummary.totalInstockAmount),
  311 + totalDiffAmount: this.toNum(this.totalSummary.totalDiffAmount),
  312 + weighDiff: this.toNum(this.form.weighDiff),
  313 + // 核算单明细(携带行主键 id)
  314 + lines: (this.lineList || []).map(item => ({
  315 + id: item.id || '',
  316 + settleLineId: item.settleLineId || '',
  317 + procurementPlanId: item.procurementPlanId || '',
  318 + productId: item.productId || '',
  319 + buyoutCategory: item.buyoutCategory || '',
  320 + buyoutQuantity: this.toNum(item.buyoutQuantity),
  321 + buyoutPrice: this.toNum(item.buyoutPrice),
  322 + buyoutAmount: this.toNum(item.buyoutAmount),
  323 + instockQuantity: this.toNum(item.instockQuantity),
  324 + instockPrice: this.toNum(item.instockPrice),
  325 + instockAmount: this.toNum(item.instockAmount),
  326 + expectTonLoss: this.toNum(item.expectTonLoss),
  327 + actualTonLoss: this.toNum(item.actualTonLoss),
  328 + tonLossDiff: this.toNum(item.tonLossDiff),
  329 + diffAmount: this.toNum(item.diffAmount)
  330 + }))
  331 + }
  332 + },
  333 + async onSubmit() {
  334 + if (!this.validate()) return
  335 + const confirmRes = await new Promise(resolve => {
  336 + uni.showModal({ title: '提示', content: '确定保存买断入库核算单吗?', confirmText: '确定', cancelText: '取消', success: resolve })
  337 + })
  338 + if (!(confirmRes && confirmRes.confirm)) return
  339 + uni.showLoading({ title: '提交中...', mask: true })
  340 + outrightPurchaseUpdateApi(this.buildSubmitData())
  341 + .then(() => {
  342 + uni.hideLoading()
  343 + uni.showToast({ title: '保存成功', icon: 'none' })
  344 + this.refreshFlags()
  345 + setTimeout(() => { uni.navigateBack() }, 400)
  346 + })
  347 + .catch(e => {
  348 + uni.hideLoading()
  349 + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' })
  350 + })
  351 + },
  352 + refreshFlags() {
  353 + try {
  354 + uni.setStorageSync('OUTRIGHT_PURCHASE_LIST_NEED_REFRESH', '1')
  355 + uni.setStorageSync('OUTRIGHT_PURCHASE_DETAIL_NEED_REFRESH', '1')
  356 + } catch (e) {}
  357 + }
  358 + }
  359 +}
  360 +
  361 +// 生成前端临时行 id
  362 +function genRowId() {
  363 + return 'row_' + Date.now().toString(36) + '_' + Math.random().toString(36).slice(2, 8)
  364 +}
  365 +</script>
  366 +
  367 +<style lang="scss" scoped>
  368 +.page {
  369 + display: flex;
  370 + flex-direction: column;
  371 + height: 100%;
  372 +}
  373 +
  374 +.scroll {
  375 + flex: 1;
  376 + padding: 12rpx 0 200rpx !important;
  377 +}
  378 +
  379 +.footer {
  380 + z-index: 2;
  381 + position: fixed;
  382 + left: 0;
  383 + right: 0;
  384 + bottom: 0;
  385 + padding: 32rpx;
  386 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  387 + background: #fff;
  388 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  389 +
  390 + .btn {
  391 + height: 80rpx;
  392 + line-height: 80rpx;
  393 + border-radius: 12rpx;
  394 + font-size: 32rpx;
  395 + }
  396 +
  397 + .submit {
  398 + background: $theme-primary;
  399 + color: #fff;
  400 + }
  401 +}
  402 +
  403 +::v-deep .uni-list {
  404 + .uni-easyinput {
  405 + display: flex;
  406 +
  407 + .uni-input-input {
  408 + color: rgba(0, 0, 0, 0.9);
  409 + }
  410 + }
  411 +
  412 + .uni-input-placeholder {
  413 + z-index: 1;
  414 + }
  415 +
  416 + .uni-input-input {
  417 + background-color: #ffffff;
  418 + }
  419 +
  420 + background: transparent;
  421 +
  422 + &-item {
  423 + &__extra-text {
  424 + font-size: 32rpx;
  425 + }
  426 +
  427 + &__content-title {
  428 + font-size: 32rpx;
  429 + color: rgba(0, 0, 0, 0.9);
  430 + }
  431 +
  432 + &__container {
  433 + padding: 32rpx;
  434 +
  435 + .uni-easyinput {
  436 + &__placeholder-class {
  437 + font-size: 32rpx;
  438 + color: rgba(0, 0, 0, 0.4);
  439 + }
  440 +
  441 + &__content {
  442 + border: none;
  443 + background-color: #ffffff !important;
  444 +
  445 + &-input {
  446 + padding-left: 0 !important;
  447 + height: 48rpx;
  448 + line-height: 48rpx;
  449 + font-size: 32rpx;
  450 + }
  451 +
  452 + .content-clear-icon {
  453 + font-size: 44rpx !important;
  454 + }
  455 + }
  456 + }
  457 +
  458 + .item-title,
  459 + .uni-list-item__content {
  460 + flex: none;
  461 + min-height: 48rpx;
  462 + line-height: 48rpx;
  463 + font-size: 32rpx;
  464 + position: relative;
  465 + width: 240rpx;
  466 + margin-right: 32rpx;
  467 + color: rgba(0, 0, 0, 0.9);
  468 +
  469 + .required {
  470 + color: red;
  471 + position: absolute;
  472 + top: 50%;
  473 + transform: translateY(-50%);
  474 + left: -16rpx;
  475 + }
  476 + }
  477 + }
  478 + }
  479 +}
  480 +
  481 +.readonly-text {
  482 + color: rgba(0, 0, 0, 0.9);
  483 + font-size: 32rpx;
  484 + line-height: 48rpx;
  485 + text-align: right;
  486 + white-space: pre-wrap;
  487 + word-break: break-all;
  488 +}
  489 +
  490 +.sub-table,
  491 +.remark-section {
  492 + margin-top: 20rpx;
  493 + background: #fff;
  494 +}
  495 +
  496 +.header {
  497 + display: flex;
  498 + align-items: center;
  499 + padding: 24rpx 32rpx;
  500 + border-bottom: 1rpx solid #f0f0f0;
  501 +
  502 + .opCollapse {
  503 + width: 32rpx;
  504 + height: 28rpx;
  505 + margin-right: 16rpx;
  506 + margin-top: 8rpx;
  507 + }
  508 +
  509 + .title {
  510 + font-size: 32rpx;
  511 + color: rgba(0, 0, 0, 0.9);
  512 + font-weight: 600;
  513 + flex: 1;
  514 + }
  515 +}
  516 +
  517 +.add-list {
  518 + padding: 0 0 16rpx;
  519 +
  520 + .empty-tip {
  521 + text-align: center;
  522 + padding: 60rpx 0;
  523 + color: rgba(0, 0, 0, 0.4);
  524 + font-size: 28rpx;
  525 + }
  526 +
  527 + .block {
  528 + border-bottom: 1rpx solid #f0f0f0;
  529 +
  530 + &:last-child {
  531 + border-bottom: none;
  532 + }
  533 + }
  534 +}
  535 +
  536 +.total-card {
  537 + margin-top: 20rpx;
  538 + background: #fff;
  539 + padding: 24rpx 32rpx;
  540 +
  541 + .total-title {
  542 + font-size: 32rpx;
  543 + font-weight: 600;
  544 + color: rgba(0, 0, 0, 0.9);
  545 + margin-bottom: 20rpx;
  546 + }
  547 +
  548 + .total-body {
  549 + display: flex;
  550 + flex-wrap: wrap;
  551 +
  552 + .total-item {
  553 + width: 50%;
  554 + display: flex;
  555 + align-items: center;
  556 + margin-bottom: 20rpx;
  557 +
  558 + &:nth-last-child(-n + 2) {
  559 + margin-bottom: 0;
  560 + }
  561 +
  562 + .total-label {
  563 + font-size: 28rpx;
  564 + color: rgba(0, 0, 0, 0.6);
  565 + margin-right: 16rpx;
  566 + }
  567 +
  568 + .total-value {
  569 + font-size: 28rpx;
  570 + color: rgba(0, 0, 0, 0.9);
  571 + font-weight: 500;
  572 + }
  573 + }
  574 + }
  575 +}
  576 +
  577 +.section-content {
  578 + padding: 32rpx;
  579 +}
  580 +</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.incomingUnit) }}</text></view>
  8 + <view class="row"><text class="label">计划单编号</text><text class="value">{{ safeText(form.planCodes) }}</text></view>
  9 + <view class="row"><text class="label">采购处</text><text class="value">{{ safeText(form.purchaseDepartmentName) }}</text></view>
  10 + <view class="row"><text class="label">区域</text><text class="value">{{ safeText(form.regionName) }}</text></view>
  11 + </view>
  12 +
  13 + <!-- 明细数据 -->
  14 + <view class="sub-table">
  15 + <view class="sub-header">
  16 + <image class="sub-bar" src="/static/images/title.png" />
  17 + <text class="sub-title">明细数据</text>
  18 + </view>
  19 + <view class="sub-body">
  20 + <view v-if="!lineList.length" class="empty-tip">暂无明细</view>
  21 + <view v-for="(item, idx) in lineList" :key="'l-' + (item.id || idx)" class="card">
  22 + <view class="card-index">第 {{ idx + 1 }} 行</view>
  23 + <view class="row"><text class="label">买断品种</text><text class="value">{{ safeText(item.buyoutCategory) }}</text></view>
  24 + <view class="row"><text class="label">买断数量</text><text class="value">{{ formatNumber(item.buyoutQuantity) }}</text></view>
  25 + <view class="row"><text class="label">买断单价</text><text class="value">{{ formatNumber(item.buyoutPrice) }}</text></view>
  26 + <view class="row"><text class="label">买断金额</text><text class="value">{{ formatNumber(item.buyoutAmount) }}</text></view>
  27 + <view class="row"><text class="label">入库数量</text><text class="value">{{ formatNumber(item.instockQuantity) }}</text></view>
  28 + <view class="row"><text class="label">入库单价</text><text class="value">{{ formatNumber(item.instockPrice) }}</text></view>
  29 + <view class="row"><text class="label">入库金额</text><text class="value">{{ formatNumber(item.instockAmount) }}</text></view>
  30 + <view class="row"><text class="label">预计吨损耗(元/吨)</text><text class="value">{{ formatNumber(item.expectTonLoss) }}</text></view>
  31 + <view class="row"><text class="label">实际吨损耗(元/吨)</text><text class="value">{{ formatNumber(item.actualTonLoss) }}</text></view>
  32 + <view class="row"><text class="label">吨损耗差异(元/吨)</text><text class="value">{{ formatNumber(item.tonLossDiff) }}</text></view>
  33 + <view class="row"><text class="label">差异金额(元)</text><text class="value">{{ formatNumber(item.diffAmount) }}</text></view>
  34 + </view>
  35 + </view>
  36 + </view>
  37 +
  38 + <!-- 其他信息 -->
  39 + <view class="title-header">
  40 + <image class="title-header_icon" src="/static/images/title.png" />
  41 + <span>其他信息</span>
  42 + </view>
  43 + <view class="total-card">
  44 + <view class="total-title">合计</view>
  45 + <view class="total-body">
  46 + <view class="total-item">
  47 + <text class="total-label">买断数量</text>
  48 + <text class="total-value">{{ formatNumber(form.totalBuyoutQuantity) }}</text>
  49 + </view>
  50 + <view class="total-item">
  51 + <text class="total-label">买断金额</text>
  52 + <text class="total-value">{{ formatNumber(form.totalBuyoutAmount) }}</text>
  53 + </view>
  54 + <view class="total-item">
  55 + <text class="total-label">入库数量</text>
  56 + <text class="total-value">{{ formatNumber(form.totalInstockQuantity) }}</text>
  57 + </view>
  58 + <view class="total-item">
  59 + <text class="total-label">入库金额</text>
  60 + <text class="total-value">{{ formatNumber(form.totalInstockAmount) }}</text>
  61 + </view>
  62 + <view class="total-item">
  63 + <text class="total-label">差异金额</text>
  64 + <text class="total-value">{{ formatNumber(form.totalDiffAmount) }}</text>
  65 + </view>
  66 + </view>
  67 + </view>
  68 + <view class="section">
  69 + <view class="row"><text class="label">磅差情况</text><text class="value">{{ formatNumber(form.weighDiff) }}</text></view>
  70 + </view>
  71 + </scroll-view>
  72 + </view>
  73 +</template>
  74 +
  75 +<script>
  76 +import { outrightPurchaseDetailApi } from '@/api/procure-manage/outrightPurchase.js'
  77 +
  78 +export default {
  79 + name: 'OutrightPurchaseViewer',
  80 + props: {
  81 + id: { type: [String, Number], default: '' },
  82 + // 当前审核节点编码(审核页透传,备用)
  83 + nodeCode: { type: String, default: '' }
  84 + },
  85 + data() {
  86 + return {
  87 + // 业务数据全量(详情接口返回,getFormValues 提交 variables 用)
  88 + bizData: {},
  89 + form: {},
  90 + lineList: []
  91 + }
  92 + },
  93 + watch: {
  94 + id: {
  95 + immediate: true,
  96 + handler(val) {
  97 + const v = (val !== undefined && val !== null) ? String(val) : ''
  98 + if (v) this.loadDetail(v)
  99 + }
  100 + }
  101 + },
  102 + methods: {
  103 + loadDetail(id) {
  104 + outrightPurchaseDetailApi({ id })
  105 + .then(res => {
  106 + const data = res && res.data ? (res.data.data || res.data) : {}
  107 + // 保留业务数据全量(getFormValues 提交 variables 用)
  108 + this.bizData = Object.assign({}, data)
  109 + this.form = {
  110 + weighingTicketCode: data.weighingTicketCode || '',
  111 + incomingUnit: data.incomingUnit || '',
  112 + planCodes: data.planCodes || '',
  113 + purchaseDepartmentName: data.purchaseDepartmentName || '',
  114 + regionName: data.regionName || '',
  115 + totalBuyoutQuantity: data.totalBuyoutQuantity == null ? '' : data.totalBuyoutQuantity,
  116 + totalBuyoutAmount: data.totalBuyoutAmount == null ? '' : data.totalBuyoutAmount,
  117 + totalInstockQuantity: data.totalInstockQuantity == null ? '' : data.totalInstockQuantity,
  118 + totalInstockAmount: data.totalInstockAmount == null ? '' : data.totalInstockAmount,
  119 + totalDiffAmount: data.totalDiffAmount == null ? '' : data.totalDiffAmount,
  120 + weighDiff: data.weighDiff == null ? '' : data.weighDiff
  121 + }
  122 + this.lineList = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : []
  123 + })
  124 + .catch(() => {
  125 + uni.showToast({ title: '详情加载失败', icon: 'none' })
  126 + })
  127 + },
  128 + // 供流程审核页获取业务表单数据(variables)
  129 + getFormValues() {
  130 + return { ...this.bizData, lines: this.lineList }
  131 + },
  132 + // 供流程审核页审批通过前校验(审批表单只读,无需校验)
  133 + checkForm() {
  134 + return true
  135 + },
  136 + safeText(v) {
  137 + const s = v == null ? '' : String(v)
  138 + return s.trim() ? s : '-'
  139 + },
  140 + formatNumber(v) {
  141 + if (v === null || v === undefined || v === '') return '-'
  142 + const n = Number(v)
  143 + if (isNaN(n)) return String(v)
  144 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  145 + }
  146 + }
  147 +}
  148 +</script>
  149 +
  150 +<style lang="scss" scoped>
  151 +.detail-page {
  152 + background: #f3f3f3;
  153 + min-height: 100%;
  154 +}
  155 +.scroll {
  156 + flex: 1;
  157 + padding: 8rpx 0;
  158 +}
  159 +.section {
  160 + padding: 32rpx;
  161 + background: #fff;
  162 + margin-bottom: 20rpx;
  163 +}
  164 +.title-header {
  165 + display: flex;
  166 + align-items: center;
  167 + padding: 24rpx 32rpx 12rpx;
  168 + background-color: #ffffff;
  169 + .title-header_icon { width: 36rpx; height: 36rpx; margin-right: 12rpx; }
  170 + span { font-size: 34rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); }
  171 +}
  172 +.row {
  173 + display: flex;
  174 + margin-bottom: 28rpx;
  175 + &:last-child { margin-bottom: 0; }
  176 + &.company {
  177 + font-size: 36rpx;
  178 + font-weight: 600;
  179 + color: rgba(0, 0, 0, 0.9);
  180 + padding-top: 8rpx;
  181 + line-height: 50rpx;
  182 + }
  183 + .label {
  184 + max-width: 420rpx;
  185 + margin-right: 20rpx;
  186 + line-height: 32rpx;
  187 + font-size: 28rpx;
  188 + color: rgba(0, 0, 0, 0.6);
  189 + }
  190 + .value {
  191 + flex: 1;
  192 + line-height: 32rpx;
  193 + font-size: 28rpx;
  194 + color: rgba(0, 0, 0, 0.9);
  195 + text-align: right;
  196 + word-break: break-all;
  197 + }
  198 +}
  199 +.total-card {
  200 + background: #fff;
  201 + margin-bottom: 20rpx;
  202 + padding: 24rpx 32rpx;
  203 + .total-title {
  204 + font-size: 32rpx;
  205 + font-weight: 600;
  206 + color: rgba(0, 0, 0, 0.9);
  207 + margin-bottom: 20rpx;
  208 + }
  209 + .total-body {
  210 + display: flex;
  211 + flex-wrap: wrap;
  212 + .total-item {
  213 + width: 50%;
  214 + display: flex;
  215 + align-items: center;
  216 + margin-bottom: 20rpx;
  217 + &:nth-last-child(-n + 2) { margin-bottom: 0; }
  218 + .total-label {
  219 + font-size: 28rpx;
  220 + color: rgba(0, 0, 0, 0.6);
  221 + margin-right: 16rpx;
  222 + }
  223 + .total-value {
  224 + font-size: 28rpx;
  225 + color: rgba(0, 0, 0, 0.9);
  226 + font-weight: 500;
  227 + word-break: break-all;
  228 + }
  229 + }
  230 + }
  231 +}
  232 +.sub-table {
  233 + background: #fff;
  234 + margin-bottom: 20rpx;
  235 +}
  236 +.sub-header {
  237 + display: flex;
  238 + align-items: center;
  239 + padding: 16rpx 0 16rpx 32rpx;
  240 + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; }
  241 + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; }
  242 +}
  243 +.sub-body {
  244 + padding: 0 32rpx 24rpx;
  245 + .empty-tip {
  246 + text-align: center;
  247 + padding: 60rpx 0;
  248 + color: rgba(0, 0, 0, 0.4);
  249 + font-size: 28rpx;
  250 + }
  251 + .card {
  252 + position: relative;
  253 + background: #fafafa;
  254 + border-radius: 12rpx;
  255 + padding: 32rpx 28rpx 20rpx;
  256 + margin-bottom: 24rpx;
  257 + .card-index {
  258 + position: absolute;
  259 + top: 0;
  260 + right: 0;
  261 + background: rgba(24, 144, 255, 0.08);
  262 + color: $theme-primary;
  263 + font-size: 22rpx;
  264 + line-height: 36rpx;
  265 + padding: 0 16rpx;
  266 + border-bottom-left-radius: 12rpx;
  267 + border-top-right-radius: 12rpx;
  268 + }
  269 + .row {
  270 + align-items: center;
  271 + justify-content: space-between;
  272 + padding: 14rpx 0;
  273 + margin-bottom: 0;
  274 + border-bottom: 1rpx dashed #f2f2f2;
  275 + &:last-child { border-bottom: none; }
  276 + .label {
  277 + flex-shrink: 0;
  278 + width: 220rpx;
  279 + max-width: none;
  280 + margin-right: 0;
  281 + font-size: 28rpx;
  282 + color: rgba(0, 0, 0, 0.6);
  283 + line-height: 40rpx;
  284 + }
  285 + .value {
  286 + flex: 1;
  287 + text-align: right;
  288 + font-size: 28rpx;
  289 + color: rgba(0, 0, 0, 0.9);
  290 + line-height: 40rpx;
  291 + overflow: hidden;
  292 + text-overflow: ellipsis;
  293 + white-space: nowrap;
  294 + }
  295 + }
  296 + }
  297 +}
  298 +</style>
... ...
... ... @@ -34,6 +34,7 @@ import SampleSubmissionViewer from '@/pages/sample-submission/sampleSubmissionVi
34 34 import MaterialTestViewer from '@/pages/material-test/materialTestViewer.vue'
35 35 import MaterialSettlementViewer from '@/pages/material-settlement/materialSettlementViewer.vue'
36 36 import WarehouseMaterialViewer from '@/pages/warehouse-material/warehouseMaterialViewer.vue'
  37 +import OutrightPurchaseViewer from '@/pages/outright-purchase/outrightPurchaseViewer.vue'
37 38
38 39 export default function registerComponents(Vue) {
39 40 Vue.component('CustomerDevelopViewer', CustomerDevelopViewer)
... ... @@ -72,4 +73,5 @@ export default function registerComponents(Vue) {
72 73 Vue.component('MaterialTestViewer', MaterialTestViewer)
73 74 Vue.component('MaterialSettlementViewer', MaterialSettlementViewer)
74 75 Vue.component('WarehouseMaterialViewer', WarehouseMaterialViewer)
  76 + Vue.component('OutrightPurchaseViewer', OutrightPurchaseViewer)
75 77 }
... ...
... ... @@ -183,6 +183,12 @@ export const getSysFlowComponentPath = (bizFlag) => {
183 183 case 'RECEIVE_ORDER_EDIT': // 仓库收料单
184 184 componentPath = 'WarehouseMaterialViewer'; // 仓库收料单-审批
185 185 break;
  186 + case 'BUYOUT_ACCOUNT_ORDER': // 买断入库核算单
  187 + componentPath = 'OutrightPurchaseViewer'; // 买断入库核算单-审批详情
  188 + break;
  189 + case 'BUYOUT_ACCOUNT_ORDER_EDIT': // 买断入库核算单
  190 + componentPath = 'OutrightPurchaseViewer'; // 买断入库核算单-审批
  191 + break;
186 192 }
187 193 return componentPath;
188 194 };
... ...