Commit 0bc993b675b6d4d06175863ac391e5fd0b3b8c5a

Authored by gesilong
2 parents 86d0a87b e15b5ae9

Merge branch 'cjerp-2.0-plan' into test_cjerp

... ... @@ -120,4 +120,40 @@ export function workshopQueryApi(params) {
120 120 method: 'get',
121 121 params
122 122 })
  123 +}
  124 +
  125 +// 价格表 查询
  126 +export function priceTableQueryApi(params) {
  127 + return request({
  128 + url: `/baseData/price/query`,
  129 + method: 'get',
  130 + params
  131 + })
  132 +}
  133 +
  134 +// 品种关系 查询
  135 +export function breedRelationshipQueryApi(params) {
  136 + return request({
  137 + url: `/baseData/breedRelationship/query`,
  138 + method: 'get',
  139 + params
  140 + })
  141 +}
  142 +
  143 +// 公司简称 查询
  144 +export function companyShortQueryApi(params) {
  145 + return request({
  146 + url: `/basedata/company/short/query`,
  147 + method: 'get',
  148 + params
  149 + })
  150 +}
  151 +
  152 +// 价格表 详情
  153 +export function priceTableDetailApi(params) {
  154 + return request({
  155 + url: `/baseData/price`,
  156 + method: 'get',
  157 + params
  158 + })
123 159 }
\ No newline at end of file
... ...
  1 +import request from '@/utils/request'
  2 +
  3 +export function buyoutApplyDetailByPlanIdApi(planId) {
  4 + return request({
  5 + url: '/procurement/buyout/apply/detailByPlanId',
  6 + method: 'get',
  7 + params: { planId: planId }
  8 + })
  9 +}
  10 +
  11 +export function buyoutApplyCreateApi(data) {
  12 + return request({
  13 + url: '/procurement/buyout/apply/create',
  14 + method: 'post',
  15 + data: data,
  16 + contentType: 'application/json'
  17 + })
  18 +}
  19 +
  20 +export function buyoutApplyAbolishApi(planId) {
  21 + return request({
  22 + url: '/procurement/buyout/apply/abolish',
  23 + method: 'post',
  24 + params: { planId: planId }
  25 + })
  26 +}
... ...
  1 +import request from '@/utils/request'
  2 +import { ContentTypeEnum } from '@/utils/httpEnum'
  3 +
  4 +export function procurementPlanQueryApi(params) {
  5 + return request({
  6 + url: '/procurement/plan/query',
  7 + method: 'get',
  8 + params
  9 + })
  10 +}
  11 +
  12 +export function procurementPlanChangeQueryApi(params) {
  13 + return request({
  14 + url: '/procurement/plan/change/query',
  15 + method: 'get',
  16 + params
  17 + })
  18 +}
  19 +
  20 +export function procurementReplenishQueryApi(params) {
  21 + return request({
  22 + url: '/procurement/plan/replenish/query',
  23 + method: 'get',
  24 + params
  25 + })
  26 +}
  27 +
  28 +export function procurementPlanCanChangeOrReplenishmentApi(params) {
  29 + return request({
  30 + url: '/procurement/plan/queryCanChangeOrReplenishment',
  31 + method: 'get',
  32 + params
  33 + })
  34 +}
  35 +
  36 +
  37 +export function procurementPlanChangeCreateApi(data) {
  38 + return request({
  39 + url: '/procurement/plan/change/create',
  40 + method: 'post',
  41 + data,
  42 + contentType: ContentTypeEnum.JSON
  43 + })
  44 +}
  45 +
  46 +export function procurementPlanReplenplenishApi(data) {
  47 + return request({
  48 + url: '/procurement/plan/replenish',
  49 + method: 'post',
  50 + data,
  51 + contentType: ContentTypeEnum.JSON
  52 + })
  53 +}
  54 +
  55 +export function procurementPlanChangeFindByIdApi(params) {
  56 + return request({
  57 + url: '/procurement/plan/change/findById',
  58 + method: 'get',
  59 + params
  60 + })
  61 +}
  62 +
  63 +// export function procurementPlanReplenishFindByIdApi(params) {
  64 +// return request({
  65 +// url: '/procurement/plan/replenish',
  66 +// method: 'get',
  67 +// params
  68 +// })
  69 +// }
  70 +
  71 +export function procurementPlanReplenishFindByIdApi(params) {
  72 + return request({
  73 + url: '/procurement/plan/replenish',
  74 + method: 'get',
  75 + params
  76 + })
  77 +}
  78 +
  79 +export function procurementPlanChangeUpdateApi(data) {
  80 + return request({
  81 + url: '/procurement/plan/change/update',
  82 + method: 'post',
  83 + data,
  84 + contentType: ContentTypeEnum.JSON
  85 + })
  86 +}
  87 +
  88 +export function procurementPlanReplenishUpdateApi(data) {
  89 + return request({
  90 + url: '/procurement/plan/replenish',
  91 + method: 'put',
  92 + data,
  93 + contentType: ContentTypeEnum.JSON
  94 + })
  95 +}
  96 +
  97 +export function procurementPlanSaveApi(data) {
  98 + return request({
  99 + url: '/procurement/plan',
  100 + method: 'post',
  101 + data,
  102 + contentType: ContentTypeEnum.JSON
  103 + })
  104 +}
  105 +
  106 +export function procurementPlanDetailApi(params) {
  107 + return request({
  108 + url: '/procurement/plan',
  109 + method: 'get',
  110 + params
  111 + })
  112 +}
  113 +
  114 +export function procurementPlanUpdateApi(data) {
  115 + return request({
  116 + url: '/procurement/plan',
  117 + method: 'put',
  118 + data,
  119 + contentType: ContentTypeEnum.JSON
  120 + })
  121 +}
  122 +
  123 +export function procurementPlanGetApi(id) {
  124 + return request({
  125 + url: '/procurement/plan/get',
  126 + method: 'get',
  127 + params: { id }
  128 + })
  129 +}
  130 +
  131 +export function procurementPlanGenerateContractApi(id) {
  132 + return request({
  133 + url: '/procurement/plan/generateContract',
  134 + method: 'post',
  135 + params: { id: id }
  136 + })
  137 +}
  138 +
  139 +export function procurementPlanSubmitAuditApi(id) {
  140 + return request({
  141 + url: '/procurement/plan/submitAudit',
  142 + method: 'post',
  143 + params: { id: id }
  144 + })
  145 +}
  146 +
  147 +export function procurementPlanSubmitApi(id) {
  148 + return request({
  149 + url: '/procurement/plan/submit',
  150 + method: 'post',
  151 + params: { id: id }
  152 + })
  153 +}
  154 +
  155 +export function procurementPlanStopApi(id) {
  156 + return request({
  157 + url: '/procurement/plan/stop',
  158 + method: 'post',
  159 + params: { id: id }
  160 + })
  161 +}
  162 +
  163 +export function procurementPlanChangeSubmitApi(id) {
  164 + return request({
  165 + url: '/procurement/plan/change/submit',
  166 + method: 'post',
  167 + params: { id: id }
  168 + })
  169 +}
  170 +
  171 +export function procurementPlanReplenishSubmitApi(id) {
  172 + return request({
  173 + url: '/procurement/plan/replenish/submit',
  174 + method: 'post',
  175 + params: { id: id }
  176 + })
  177 +}
  178 +
  179 +export function procurementPlanChangeCancelApi(id) {
  180 + return request({
  181 + url: '/procurement/plan/change/cancel',
  182 + method: 'post',
  183 + params: { id: id }
  184 + })
  185 +}
  186 +
  187 +
  188 +export function procurementPlanReplenishCancelApi(id) {
  189 + return request({
  190 + url: '/procurement/plan/replenish/cancel',
  191 + method: 'post',
  192 + params: { id: id }
  193 + })
  194 +}
\ No newline at end of file
... ...
... ... @@ -413,6 +413,110 @@
413 413 }
414 414 },
415 415 {
  416 + "path": "pages/domestic-plan/index",
  417 + "style": {
  418 + "navigationBarTitleText": "内贸计划单",
  419 + "navigationBarBackgroundColor": "#ffffff",
  420 + "navigationBarTextStyle": "black"
  421 + }
  422 + },
  423 + {
  424 + "path": "pages/domestic-plan/detail",
  425 + "style": {
  426 + "navigationBarTitleText": "内贸计划单详情",
  427 + "navigationBarBackgroundColor": "#ffffff",
  428 + "navigationBarTextStyle": "black"
  429 + }
  430 + },
  431 + {
  432 + "path": "pages/domestic-plan/supplement",
  433 + "style": {
  434 + "navigationBarTitleText": "内贸计划单补充",
  435 + "navigationBarBackgroundColor": "#ffffff",
  436 + "navigationBarTextStyle": "black"
  437 + }
  438 + },
  439 + {
  440 + "path": "pages/domestic-plan/selectWorkshop",
  441 + "style": {
  442 + "navigationBarTitleText": "选择分厂",
  443 + "navigationBarBackgroundColor": "#ffffff",
  444 + "navigationBarTextStyle": "black"
  445 + }
  446 + },
  447 + {
  448 + "path": "pages/domestic-plan/viewBuyoutApply",
  449 + "style": {
  450 + "navigationBarTitleText": "查看买断操作申请单",
  451 + "navigationBarBackgroundColor": "#ffffff",
  452 + "navigationBarTextStyle": "black"
  453 + }
  454 + },
  455 + {
  456 + "path": "pages/schedule-plan/index",
  457 + "style": {
  458 + "navigationBarTitleText": "计划变更单",
  459 + "navigationBarBackgroundColor": "#ffffff",
  460 + "navigationBarTextStyle": "black"
  461 + }
  462 + },
  463 + {
  464 + "path": "pages/schedule-plan/add",
  465 + "style": {
  466 + "navigationBarTitleText": "新增计划变更单",
  467 + "navigationBarBackgroundColor": "#ffffff",
  468 + "navigationBarTextStyle": "black"
  469 + }
  470 + },
  471 + {
  472 + "path": "pages/schedule-plan/detail",
  473 + "style": {
  474 + "navigationBarTitleText": "计划变更单详情",
  475 + "navigationBarBackgroundColor": "#ffffff",
  476 + "navigationBarTextStyle": "black"
  477 + }
  478 + },
  479 + {
  480 + "path": "pages/schedule-plan/modify",
  481 + "style": {
  482 + "navigationBarTitleText": "编辑计划变更单",
  483 + "navigationBarBackgroundColor": "#ffffff",
  484 + "navigationBarTextStyle": "black"
  485 + }
  486 + },
  487 + {
  488 + "path": "pages/supple-plan/index",
  489 + "style": {
  490 + "navigationBarTitleText": "计划补录单",
  491 + "navigationBarBackgroundColor": "#ffffff",
  492 + "navigationBarTextStyle": "black"
  493 + }
  494 + },
  495 + {
  496 + "path": "pages/supple-plan/add",
  497 + "style": {
  498 + "navigationBarTitleText": "新增计划补录单",
  499 + "navigationBarBackgroundColor": "#ffffff",
  500 + "navigationBarTextStyle": "black"
  501 + }
  502 + },
  503 + {
  504 + "path": "pages/supple-plan/modify",
  505 + "style": {
  506 + "navigationBarTitleText": "修改计划补录单",
  507 + "navigationBarBackgroundColor": "#ffffff",
  508 + "navigationBarTextStyle": "black"
  509 + }
  510 + },
  511 + {
  512 + "path": "pages/supple-plan/detail",
  513 + "style": {
  514 + "navigationBarTitleText": "计划补录单详情",
  515 + "navigationBarBackgroundColor": "#ffffff",
  516 + "navigationBarTextStyle": "black"
  517 + }
  518 + },
  519 + {
416 520 "path": "pages/order_list/index",
417 521 "style": {
418 522 "navigationBarTitleText": "订货单列表",
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <view class="detail-page">
  5 + <view class="section">
  6 + <text class="row company">{{ safeText(form.code) }}</text>
  7 + <view class="row"><text class="label">公司简称</text><text class="value">{{ safeText(form.companyShortName || form.companyName) }}</text></view>
  8 + <view class="row"><text class="label">供应商名称</text><text class="value">{{ safeText(form.supplierName) }}</text></view>
  9 + <view class="row"><text class="label">采购处</text><text class="value">{{ safeText(form.purchaseDepartmentName || form.purchaseDepartment) }}</text></view>
  10 + <view class="row"><text class="label">区域</text><text class="value">{{ safeText(form.regionName || form.region) }}</text></view>
  11 + <view class="row"><text class="label">日期</text><text class="value">{{ formatDateOnly(form.date) }}</text></view>
  12 + <view class="row"><text class="label">报价时效</text><text class="value">{{ safeText(form.validityPeriod) }}</text></view>
  13 + <view class="row"><text class="label">报价人</text><text class="value">{{ safeText(form.quoterName) }}</text></view>
  14 + <view class="row"><text class="label">是否长单操作</text><text class="value">{{ boolText(form.longTermOperation) }}</text></view>
  15 + <view class="row"><text class="label">是否终端客户</text><text class="value">{{ boolText(form.terminalCustomer) }}</text></view>
  16 + <view class="row"><text class="label">是否未点价</text><text class="value">{{ boolText(form.priced) }}</text></view>
  17 + <view v-if="form.priced === true" class="row"><text class="label">点价截止日期</text><text class="value">{{ formatDateOnly(form.pricingDeadline) }}</text></view>
  18 + <view v-if="form.priced === true" class="row"><text class="label">是否暂定价</text><text class="value">{{ boolText(form.temporaryPrice) }}</text></view>
  19 + <view class="row"><text class="label">其他费用凭票到厂另行结算</text><text class="value">{{ boolText(form.otherExpenseSettlement) }}</text></view>
  20 + <view class="row"><text class="label">交提货方式</text><text class="value">{{ getDeliveryMethodLabel() }}</text></view>
  21 + <view class="row"><text class="label">是否通货买断</text><text class="value">{{ boolText(form.commodityBuyout) }}</text></view>
  22 + <view class="row"><text class="label">是否质量买断</text><text class="value">{{ boolText(form.qualityBuyout) }}</text></view>
  23 + <view class="row"><text class="label">是否数量买断</text><text class="value">{{ boolText(form.quantityBuyout) }}</text></view>
  24 + <view class="row"><text class="label">是否送货上门</text><text class="value">{{ boolText(form.doorDelivery) }}</text></view>
  25 + <view class="row"><text class="label">另付运费</text><text class="value">{{ formatNumber(form.shippingCost) }}</text></view>
  26 + <view class="row"><text class="label">装车费</text><text class="value">{{ formatNumber(form.loadingFee) }}</text></view>
  27 + <view class="row"><text class="label">开票品名</text><text class="value">{{ safeText(form.invoiceProductName) }}</text></view>
  28 + <view class="row"><text class="label">交货日期</text><text class="value">{{ formatDateOnly(form.deliveryDate) }}</text></view>
  29 + <view class="row"><text class="label">结算方式</text><text class="value">{{ safeText(form.settlementMethod) }}</text></view>
  30 + <view class="row"><text class="label">结算比例(%)</text><text class="value">{{ formatNumber(form.settlementRatio) }}</text></view>
  31 + <view class="row"><text class="label">价格表编号</text><text class="value">{{ getPriceTableLabel() }}</text></view>
  32 + <view class="row"><text class="label">协调事由</text><text class="value">{{ safeText(form.coordinationReason) }}</text></view>
  33 + <view class="row"><text class="label">票类状况</text><text class="value">{{ safeText(form.invoiceTypeStatus) }}</text></view>
  34 + <view class="row" v-if="attachmentList.length">
  35 + <text class="label">附件</text>
  36 + <view class="attach-list">
  37 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  38 + <text class="attach-name">{{ at.name }}</text>
  39 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  40 + </view>
  41 + </view>
  42 + </view>
  43 + </view>
  44 +
  45 + <ProductRel
  46 + mode="view"
  47 + :list="lineListWithName"
  48 + :product-options="productOptions"
  49 + :workshop-options="workshopOptions"
  50 + />
  51 +
  52 + <view class="title-header">
  53 + <image class="title-header_icon" src="/static/images/title.png" />
  54 + <span>料质状况</span>
  55 + </view>
  56 + <view class="section">
  57 + <view class="row"><text class="label">是否启用料质状况</text><text class="value">{{ boolText(form.materialConditionEnabled) }}</text></view>
  58 + <template v-if="form.materialConditionEnabled">
  59 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  60 + <text class="material-label">{{ mc.label }}</text>
  61 + <view class="tag-list">
  62 + <view v-for="opt in getDictOptions(mc.dictCode)" :key="opt.code" class="tag-btn" :class="{ active: isTagSelected(mc.field, opt.code) }">{{ opt.name }}</view>
  63 + </view>
  64 + </view>
  65 + </template>
  66 + </view>
  67 +
  68 + <view class="title-header">
  69 + <image class="title-header_icon" src="/static/images/title.png" />
  70 + <span>备注</span>
  71 + </view>
  72 + <view class="section">
  73 + <text class="remark-text">{{ safeText(form.remark) }}</text>
  74 + </view>
  75 + </view>
  76 + </scroll-view>
  77 + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  78 + </view>
  79 +</template>
  80 +
  81 +<script>
  82 +import DetailButtons from '@/components/detail-buttons/index.vue'
  83 +import ProductRel from './productRel.vue'
  84 +import { procurementPlanDetailApi, procurementPlanGenerateContractApi, procurementPlanSubmitAuditApi, procurementPlanSubmitApi, procurementPlanStopApi } from '@/api/procure-manage/procurementPlan.js'
  85 +import { buyoutApplyCreateApi, buyoutApplyAbolishApi } from '@/api/procure-manage/buyout.js'
  86 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  87 +import { getInfo } from '@/api/login.js'
  88 +import { priceTableQueryApi, breedRelationshipQueryApi, workshopQueryApi } from '@/api/devManage.js'
  89 +
  90 +export default {
  91 + name: 'DomesticPlanDetail',
  92 + components: { DetailButtons, ProductRel },
  93 + data() {
  94 + return {
  95 + id: '',
  96 + form: {},
  97 + lineList: [],
  98 + attachmentList: [],
  99 + materialConditionConfigs: [
  100 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  101 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  102 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  103 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  104 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  105 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  106 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  107 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  108 + ],
  109 + dicOptions: {
  110 + AUDIT_STATUS: [],
  111 + PROCESS_STATUS: [],
  112 + DELIVERY_METHOD: []
  113 + },
  114 + dictData: {},
  115 + currentUserId: '',
  116 + priceTableList: [],
  117 + productOptions: [],
  118 + workshopOptions: [],
  119 + planRoleFlags: {
  120 + isPlanner: false
  121 + },
  122 + PROCESS_STATUS_CODE: {
  123 + TO_SUPPLEMENT: 'TO_SUPPLEMENT',
  124 + TO_SPLIT: 'TO_SPLIT',
  125 + TO_SUBMIT_REVIEW: 'TO_SUBMIT_REVIEW',
  126 + AUDIT: 'AUDIT',
  127 + REFUSE: 'REFUSE',
  128 + COMPLETED: 'COMPLETED',
  129 + ABORTED: 'ABORTED'
  130 + },
  131 + buttonTemplates: [
  132 + { text: '补充', variant: 'primary', event: 'supplement' },
  133 + { text: '生成合同', variant: 'primary', event: 'generateContract' },
  134 + { text: '选择分厂', variant: 'primary', event: 'selectWorkshop' },
  135 + { text: '提交', variant: 'primary', event: 'submitSplit' },
  136 + { text: '提交审核', variant: 'primary', event: 'submitReview' },
  137 + { text: '终止', variant: 'danger', event: 'abort' },
  138 + { text: '审核', variant: 'primary', event: 'approve' },
  139 + { text: '审核详情', variant: 'outline', event: 'approveDetail' },
  140 + { text: '生成买断操作申请单', variant: 'outline', event: 'generate' },
  141 + { text: '废除买断操作申请单', variant: 'danger', event: 'cancel' },
  142 + { text: '查看买断操作申请单', variant: 'outline', event: 'look' },
  143 + // { text: '上传附件', variant: 'primary', event: 'upload' }
  144 + ]
  145 + }
  146 + },
  147 + computed: {
  148 + productMap() {
  149 + var list = Array.isArray(this.productOptions) ? this.productOptions : []
  150 + var m = {}
  151 + list.forEach(function (o) {
  152 + var key = String(o.productId || o.id || o.value || '')
  153 + if (key) m[key] = o
  154 + })
  155 + return m
  156 + },
  157 + workshopMap() {
  158 + var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  159 + var m = {}
  160 + list.forEach(function (o) {
  161 + var key = String(o.workshopId || o.id || o.value || '')
  162 + if (key) m[key] = o
  163 + })
  164 + return m
  165 + },
  166 + lineListWithName() {
  167 + var self = this
  168 + var list = Array.isArray(this.lineList) ? this.lineList : []
  169 + return list.map(function (row) {
  170 + var pid = String(row.productId || '')
  171 + var wid = String(row.workshopId || '')
  172 + var p = pid ? self.productMap[pid] : null
  173 + var w = wid ? self.workshopMap[wid] : null
  174 + return Object.assign({}, row, {
  175 + productName: row.productName || (p ? (p.productName || p.name || p.label || '') : ''),
  176 + workshopName: row.workshopName || (w ? (w.workshopName || w.name || w.label || '') : '')
  177 + })
  178 + })
  179 + },
  180 + displayButtons() {
  181 + var self = this
  182 + var f = this.form || {}
  183 + var ps = String(f.processStatus != null ? f.processStatus : '')
  184 + var aStatus = String(f.approvalStatus != null ? f.approvalStatus : '')
  185 + var SC = this.PROCESS_STATUS_CODE
  186 + var inStatus = function (codes) { return codes.indexOf(ps) >= 0 }
  187 + var perms = {
  188 + supplement: this.hasPerm('plan-manage:domestic-plan:supple'),
  189 + generateContract: this.hasPerm('plan-manage:domestic-plan:do'),
  190 + selectWorkshop: this.hasPerm('plan-manage:domestic-plan:split'),
  191 + submitSplit: this.hasPerm('plan-manage:domestic-plan:submit'),
  192 + submitReview: this.hasPerm('plan-manage:domestic-plan:goapprove'),
  193 + abort: this.hasPerm('plan-manage:domestic-plan:stop'),
  194 + approve: this.hasPerm('plan-manage:domestic-plan:approve'),
  195 + approveDetail: this.hasPerm('plan-manage:domestic-plan:view'),
  196 + print: this.hasPerm('plan-manage:domestic-plan:print'),
  197 + generate: this.hasPerm('plan-manage:domestic-plan:generate'),
  198 + cancel: this.hasPerm('plan-manage:domestic-plan:cancel'),
  199 + look: this.hasPerm('plan-manage:domestic-plan:look'),
  200 + // upload: this.hasPerm('plan-manage:domestic-plan:upload')
  201 + }
  202 + var visibleMap = {
  203 + supplement: inStatus([SC.TO_SUPPLEMENT]) && perms.supplement,
  204 + generateContract: inStatus([SC.TO_SUPPLEMENT]) && perms.generateContract,
  205 + selectWorkshop: inStatus([SC.TO_SPLIT]) && perms.selectWorkshop,
  206 + submitSplit: inStatus([SC.TO_SPLIT]) && perms.submitSplit,
  207 + submitReview: inStatus([SC.TO_SUBMIT_REVIEW]) && perms.submitReview,
  208 + abort: inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.REFUSE]) && perms.abort,
  209 + approve: (inStatus([SC.AUDIT, SC.REFUSE]) && aStatus === 'AUDIT' && !!f.showExamine) && perms.approve,
  210 + approveDetail: !!f.showExamineDetail && (inStatus([SC.AUDIT, SC.COMPLETED, SC.REFUSE])) && perms.approveDetail,
  211 + print: inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED, SC.ABORTED, SC.REFUSE]) && perms.print,
  212 + generate: !!f.showGenerateBuyoutApply && inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED]) && perms.generateBuyoutApply,
  213 + cancel: !!f.showAbolishBuyoutApply && inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED]) && perms.abolishBuyoutApply,
  214 + look: inStatus([SC.TO_SUBMIT_REVIEW, SC.AUDIT, SC.COMPLETED, SC.REFUSE]) && perms.viewBuyoutApply,
  215 + // uploadAttachment: inStatus([SC.COMPLETED]) && !!this.planRoleFlags.isPlanner && perms.uploadAttachment
  216 + }
  217 + var out = []
  218 + for (var i = 0; i < this.buttonTemplates.length; i++) {
  219 + var tpl = this.buttonTemplates[i]
  220 + var visible = !!visibleMap[tpl.event]
  221 + if (visible) {
  222 + out.push(Object.assign({}, tpl))
  223 + }
  224 + }
  225 + return out
  226 + }
  227 + },
  228 + onLoad(query) {
  229 + this.id = (query && query.id) || ''
  230 + this.loadDictData()
  231 + this.loadRefData()
  232 + this.getUserInfo()
  233 + this.loadDetail()
  234 + },
  235 + methods: {
  236 + hasPerm(code) {
  237 + try {
  238 + return !!(this.$auth && this.$auth.hasPermi && this.$auth.hasPermi(code))
  239 + } catch (e) {
  240 + return true
  241 + }
  242 + },
  243 + async getUserInfo() {
  244 + try {
  245 + var res = await getInfo()
  246 + this.currentUserId = (res && res.id) ? res.id : ''
  247 + } catch (e) {
  248 + this.currentUserId = ''
  249 + }
  250 + },
  251 + async loadDictData() {
  252 + var codes = [].concat(
  253 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  254 + ['DELIVERY_METHOD', 'AUDIT_STATUS', 'PROCESS_STATUS']
  255 + )
  256 + try {
  257 + var results = await getDicByCodes(codes)
  258 + var d = results || {}
  259 + this.dictData = d
  260 + this.dicOptions.AUDIT_STATUS = (d.AUDIT_STATUS && d.AUDIT_STATUS.data) || []
  261 + this.dicOptions.PROCESS_STATUS = (d.PROCESS_STATUS && d.PROCESS_STATUS.data) || []
  262 + this.dicOptions.DELIVERY_METHOD = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  263 + } catch (e) {
  264 + this.dictData = {}
  265 + }
  266 + },
  267 + getDictOptions(dictCode) {
  268 + var data = this.dictData[dictCode]
  269 + return (data && data.data) ? data.data : []
  270 + },
  271 + isTagSelected(field, code) {
  272 + var selected = this.form ? this.form[field] : undefined
  273 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  274 + if (typeof selected === 'string' && selected) {
  275 + return selected.split(',').indexOf(code) >= 0
  276 + }
  277 + return false
  278 + },
  279 + getAuditStatusText(status) {
  280 + var v = status == null ? '' : String(status)
  281 + if (!v) return '-'
  282 + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v
  283 + },
  284 + getProcessStatusText(status) {
  285 + var v = status == null ? '' : String(status)
  286 + if (!v) return '-'
  287 + return getDicName('PROCESS_STATUS', v, this.dicOptions.PROCESS_STATUS) || v
  288 + },
  289 + getDeliveryMethodLabel() {
  290 + var opts = this.getDictOptions('DELIVERY_METHOD') || []
  291 + var v = String(this.form.deliveryMode != null ? this.form.deliveryMode : '')
  292 + if (!v) return '-'
  293 + for (var i = 0; i < opts.length; i++) {
  294 + var o = opts[i]
  295 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  296 + if (code === v) return o.name || o.label || '-'
  297 + }
  298 + return v
  299 + },
  300 + getPriceTableLabel() {
  301 + var code = this.form.priceTableCode != null ? this.form.priceTableCode : (this.form.priceId != null ? this.form.priceId : '')
  302 + if (code == null || String(code).trim() === '') return '-'
  303 + var sc = String(code)
  304 + var list = Array.isArray(this.priceTableList) ? this.priceTableList : []
  305 + for (var i = 0; i < list.length; i++) {
  306 + var o = list[i]
  307 + var id = String(o.id || o.priceId || o.value || '')
  308 + var c = String(o.priceTableCode || o.code || o.priceCode || '')
  309 + if (id === sc || c === sc) {
  310 + var name = o.priceTableName || o.tableName || o.name || o.label || ''
  311 + var cd = o.priceTableCode || o.code || c
  312 + return (name ? name + ' ' : '') + (cd ? cd : '') || '-'
  313 + }
  314 + }
  315 + return sc
  316 + },
  317 + async loadRefData() {
  318 + var self = this
  319 + try {
  320 + var results = await Promise.all([
  321 + this.pCall(priceTableQueryApi, { pageIndex: 1, pageSize: 1000 }),
  322 + this.pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  323 + this.pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  324 + ])
  325 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  326 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  327 + var r3 = (results[2] && results[2].data) ? results[2].data : {}
  328 + self.priceTableList = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  329 + self.productOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  330 + self.workshopOptions = (r3.datas && Array.isArray(r3.datas)) ? r3.datas : ((r3.list && Array.isArray(r3.list)) ? r3.list : ((r3.records && Array.isArray(r3.records)) ? r3.records : []))
  331 + } catch (e) {
  332 + self.priceTableList = []
  333 + self.productOptions = []
  334 + self.workshopOptions = []
  335 + }
  336 + },
  337 + pCall(fn, params) {
  338 + try {
  339 + return Promise.resolve(fn(params))
  340 + } catch (e) {
  341 + return Promise.reject(e)
  342 + }
  343 + },
  344 + boolText(v) {
  345 + if (typeof v !== 'boolean') return '-'
  346 + return v ? '是' : '否'
  347 + },
  348 + formatDateOnly(v) {
  349 + var s = v == null ? '' : String(v).trim()
  350 + if (!s) return '-'
  351 + if (s.length >= 10) return s.slice(0, 10)
  352 + return s
  353 + },
  354 + safeText(v) {
  355 + var s = v == null ? '' : String(v)
  356 + return s.trim() ? s : '-'
  357 + },
  358 + formatNumber(v) {
  359 + if (v == null || v === '') return '-'
  360 + var n = Number(v)
  361 + if (isNaN(n)) return String(v)
  362 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  363 + },
  364 + buildAttachmentList() {
  365 + var ids = this.form.attachmentFileIds
  366 + var names = this.form.attachmentFileNames
  367 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  368 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  369 + var len = Math.max(idArr.length, nameArr.length)
  370 + var list = []
  371 + for (var i = 0; i < len; i++) {
  372 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  373 + }
  374 + this.attachmentList = list
  375 + },
  376 + async loadDetail() {
  377 + if (!this.id) return
  378 + try {
  379 + var res = await procurementPlanDetailApi({ id: this.id })
  380 + var d = (res && res.data) ? res.data : {}
  381 + var self = this
  382 + this.materialConditionConfigs.forEach(function (mc) {
  383 + var v = d[mc.field]
  384 + if (typeof v === 'string' && v) {
  385 + d[mc.field] = v.split(',').filter(Boolean)
  386 + } else if (!Array.isArray(v)) {
  387 + d[mc.field] = []
  388 + }
  389 + })
  390 + this.form = d
  391 + this.lineList = Array.isArray(d.procurementPlanLineList) ? d.procurementPlanLineList : []
  392 + this.buildAttachmentList()
  393 + } catch (e) {
  394 + uni.showToast({ title: '加载详情失败', icon: 'none' })
  395 + }
  396 + },
  397 + onPreviewAttachment(at) {
  398 + if (!at || !at.id) {
  399 + uni.showToast({ title: '无法查看', icon: 'none' })
  400 + return
  401 + }
  402 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  403 + },
  404 + handleButtonClick(btn) {
  405 + if (!btn || btn.disabled) return
  406 + var e = btn.event || ''
  407 + if (e === 'view') return this.onView()
  408 + if (e === 'supplement') return this.onSupplement()
  409 + if (e === 'generateContract') return this.onGenerateContract()
  410 + if (e === 'selectWorkshop') return this.onSelectWorkshop()
  411 + if (e === 'submitSplit') return this.onSubmitSplit()
  412 + if (e === 'submitReview') return this.onSubmitReview()
  413 + if (e === 'abort') return this.onAbort()
  414 + if (e === 'approve') return this.onApprove()
  415 + if (e === 'approveDetail') return this.onApproveDetail()
  416 + if (e === 'print') return this.onPrint()
  417 + if (e === 'generateBuyoutApply') return this.onGenerateBuyoutApply()
  418 + if (e === 'abolishBuyoutApply') return this.onAbolishBuyoutApply()
  419 + if (e === 'look') return this.onViewBuyoutApply()
  420 + if (e === 'uploadAttachment') return this.onUploadAttachment()
  421 + },
  422 + onView() {
  423 + uni.showToast({ title: '查看', icon: 'none' })
  424 + },
  425 + onSupplement() {
  426 + uni.navigateTo({ url: '/pages/domestic-plan/supplement?id=' + this.id })
  427 + },
  428 + onGenerateContract() {
  429 + var self = this
  430 + var id = this.id || (this.form && this.form.id) || ''
  431 + if (!id) {
  432 + uni.showToast({ title: '缺少单据id', icon: 'none' })
  433 + return
  434 + }
  435 + uni.showModal({
  436 + title: '生成合同',
  437 + content: '合同生成之后无法再编辑,确定生成吗?',
  438 + confirmText: '确定',
  439 + cancelText: '取消',
  440 + success: function (res) {
  441 + if (!res || !res.confirm) return
  442 + uni.showLoading({ title: '生成中', mask: true })
  443 + procurementPlanGenerateContractApi(id).then(function () {
  444 + uni.hideLoading()
  445 + uni.showToast({ title: '生成成功', icon: 'none' })
  446 + try {
  447 + uni.setStorageSync('DOMESTIC_PLAN_LIST_NEED_REFRESH', '1')
  448 + uni.setStorageSync('SUPPLE_PLAN_LIST_NEED_REFRESH', '1')
  449 + } catch (e) {}
  450 + self.loadDetail()
  451 + }).catch(function (e) {
  452 + uni.hideLoading()
  453 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : '生成合同失败', icon: 'none' })
  454 + })
  455 + }
  456 + })
  457 + },
  458 + refreshListFlags() {
  459 + try {
  460 + uni.setStorageSync('DOMESTIC_PLAN_LIST_NEED_REFRESH', '1')
  461 + uni.setStorageSync('SUPPLE_PLAN_LIST_NEED_REFRESH', '1')
  462 + } catch (e) {}
  463 + },
  464 + runWithConfirm(opts) {
  465 + var self = this
  466 + var title = opts.title || '提示'
  467 + var content = opts.content || ''
  468 + var run = opts.run
  469 + var loading = opts.loading || '处理中'
  470 + var successText = opts.successText || '操作成功'
  471 + var failText = opts.failText || '操作失败'
  472 + if (!this.id) {
  473 + uni.showToast({ title: '缺少单据id', icon: 'none' })
  474 + return
  475 + }
  476 + var apiFn = function () {
  477 + uni.showLoading({ title: loading, mask: true })
  478 + Promise.resolve(run(self.id)).then(function () {
  479 + uni.hideLoading()
  480 + uni.showToast({ title: successText, icon: 'none' })
  481 + self.refreshListFlags()
  482 + self.loadDetail()
  483 + }).catch(function (e) {
  484 + uni.hideLoading()
  485 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : failText, icon: 'none' })
  486 + })
  487 + }
  488 + if (opts.skipConfirm) {
  489 + apiFn()
  490 + return
  491 + }
  492 + uni.showModal({
  493 + title: title,
  494 + content: content,
  495 + confirmText: '确定',
  496 + cancelText: '取消',
  497 + success: function (res) {
  498 + if (!res || !res.confirm) return
  499 + apiFn()
  500 + }
  501 + })
  502 + },
  503 + onSelectWorkshop() {
  504 + var id = this.id || (this.form && this.form.id) || ''
  505 + if (!id) {
  506 + uni.showToast({ title: '缺少单据id', icon: 'none' })
  507 + return
  508 + }
  509 + uni.navigateTo({ url: '/pages/domestic-plan/selectWorkshop?id=' + id })
  510 + },
  511 + onSubmitSplit() {
  512 + this.runWithConfirm({
  513 + title: '提交',
  514 + content: '提交之后无法再选择分厂,确定提交吗?',
  515 + loading: '提交中',
  516 + successText: '提交成功',
  517 + failText: '提交失败',
  518 + run: function (id) { return procurementPlanSubmitApi(id) }
  519 + })
  520 + },
  521 + onSubmitReview() {
  522 + this.runWithConfirm({
  523 + title: '提交审核',
  524 + content: '确认提交审核吗?',
  525 + loading: '提交中',
  526 + successText: '提交成功',
  527 + failText: '提交审核失败',
  528 + run: function (id) { return procurementPlanSubmitAuditApi(id) }
  529 + })
  530 + },
  531 + onAbort() {
  532 + this.runWithConfirm({
  533 + title: '中止',
  534 + content: '若有关联计划,则关联计划会受到影响,是否确认中止?',
  535 + loading: '中止中',
  536 + successText: '中止成功',
  537 + failText: '中止失败',
  538 + run: function (id) { return procurementPlanStopApi(id) }
  539 + })
  540 + },
  541 + onPrint() {
  542 + uni.showToast({ title: '打印(待对接)', icon: 'none' })
  543 + },
  544 + onGenerateBuyoutApply() {
  545 + var self = this
  546 + var id = this.id || (this.form && this.form.id) || ''
  547 + this.runWithConfirm({
  548 + title: '生成买断操作申请单',
  549 + content: '确定生成买断操作申请单吗?',
  550 + loading: '生成中',
  551 + successText: '生成成功',
  552 + failText: '生成买断操作申请单失败',
  553 + run: function () { return buyoutApplyCreateApi({ procurementPlanId: id }) }
  554 + })
  555 + },
  556 + onAbolishBuyoutApply() {
  557 + var self = this
  558 + var id = this.id || (this.form && this.form.id) || ''
  559 + this.runWithConfirm({
  560 + title: '废除买断操作申请单',
  561 + content: '确定废除买断操作申请单吗?',
  562 + loading: '废除中',
  563 + successText: '废除成功',
  564 + failText: '废除买断操作申请单失败',
  565 + run: function () { return buyoutApplyAbolishApi(id) }
  566 + })
  567 + },
  568 + onViewBuyoutApply() {
  569 + var id = this.id || (this.form && this.form.id) || ''
  570 + if (!id) {
  571 + uni.showToast({ title: '缺少单据id', icon: 'none' })
  572 + return
  573 + }
  574 + uni.navigateTo({ url: '/pages/domestic-plan/viewBuyoutApply?planId=' + id })
  575 + },
  576 + onUploadAttachment() {
  577 + uni.showToast({ title: '上传附件(待对接)', icon: 'none' })
  578 + },
  579 + onApprove() {
  580 + var id = this.id || (this.form && this.form.id) || ''
  581 + if (!id) return
  582 + try {
  583 + uni.setStorageSync('contractType', 'PROCUREMENT_PLAN')
  584 + uni.setStorageSync('sourceBusinessId', id)
  585 + } catch (e) {}
  586 + uni.navigateTo({ url: '/pages/flow/audit' })
  587 + },
  588 + onApproveDetail() {
  589 + var id = this.id || (this.form && this.form.id) || ''
  590 + if (!id) return
  591 + try {
  592 + uni.setStorageSync('contractType', 'PROCUREMENT_PLAN')
  593 + uni.setStorageSync('sourceBusinessId', id)
  594 + } catch (e) {}
  595 + uni.navigateTo({ url: '/pages/flow/audit_detail' })
  596 + }
  597 + }
  598 +}
  599 +</script>
  600 +
  601 +<style lang="scss" scoped>
  602 +.page {
  603 + display: flex;
  604 + flex-direction: column;
  605 + height: 100%;
  606 +}
  607 +.scroll {
  608 + flex: 1;
  609 + padding: 8rpx 0 144rpx;
  610 +}
  611 +.detail-page {
  612 + background: #f3f3f3;
  613 +}
  614 +.title-header {
  615 + display: flex;
  616 + align-items: center;
  617 + padding: 24rpx 32rpx 12rpx;
  618 + background-color: #ffffff;
  619 + .title-header_icon {
  620 + width: 36rpx;
  621 + height: 36rpx;
  622 + margin-right: 12rpx;
  623 + }
  624 + span {
  625 + font-size: 34rpx;
  626 + font-weight: 600;
  627 + color: rgba(0, 0, 0, 0.9);
  628 + }
  629 +}
  630 +.section {
  631 + padding: 32rpx;
  632 + background: #fff;
  633 + margin-bottom: 20rpx;
  634 +}
  635 +.row {
  636 + display: flex;
  637 + margin-bottom: 28rpx;
  638 + &:last-child { margin-bottom: 0; }
  639 + &.company {
  640 + font-size: 36rpx;
  641 + font-weight: 600;
  642 + color: rgba(0, 0, 0, 0.9);
  643 + padding-top: 8rpx;
  644 + line-height: 50rpx;
  645 + }
  646 + .label {
  647 + max-width: 420rpx;
  648 + margin-right: 20rpx;
  649 + line-height: 32rpx;
  650 + font-size: 28rpx;
  651 + color: rgba(0, 0, 0, 0.6);
  652 + }
  653 + .value {
  654 + flex: 1;
  655 + line-height: 32rpx;
  656 + font-size: 28rpx;
  657 + color: rgba(0, 0, 0, 0.9);
  658 + text-align: right;
  659 + word-break: break-all;
  660 + }
  661 +}
  662 +.attach-list {
  663 + flex: 1;
  664 + display: flex;
  665 + flex-direction: column;
  666 + align-items: flex-end;
  667 + gap: 8rpx;
  668 +}
  669 +.attach-item {
  670 + display: flex;
  671 + align-items: center;
  672 + gap: 16rpx;
  673 + .attach-name {
  674 + font-size: 26rpx;
  675 + color: rgba(0, 0, 0, 0.9);
  676 + }
  677 + .attach-view {
  678 + font-size: 26rpx;
  679 + color: $theme-primary;
  680 + }
  681 +}
  682 +.material-group {
  683 + margin-top: 32rpx;
  684 + &:first-child { margin-top: 0; }
  685 +}
  686 +.material-label {
  687 + display: block;
  688 + font-size: 28rpx;
  689 + color: rgba(0, 0, 0, 0.6);
  690 + margin-bottom: 20rpx;
  691 +}
  692 +.tag-list {
  693 + display: flex;
  694 + flex-wrap: wrap;
  695 + gap: 16rpx;
  696 +}
  697 +.tag-btn {
  698 + padding: 12rpx 24rpx;
  699 + border: 1rpx solid #ddd;
  700 + border-radius: 8rpx;
  701 + font-size: 28rpx;
  702 + color: #999;
  703 + background: #f5f5f5;
  704 +}
  705 +.tag-btn.active {
  706 + background: $theme-primary;
  707 + border-color: $theme-primary;
  708 + color: #fff;
  709 +}
  710 +.remark-text {
  711 + font-size: 28rpx;
  712 + color: rgba(0, 0, 0, 0.9);
  713 + line-height: 1.6;
  714 + white-space: pre-wrap;
  715 +}
  716 +.empty-tip {
  717 + text-align: center;
  718 + font-size: 28rpx;
  719 + color: rgba(0, 0, 0, 0.4);
  720 + padding: 24rpx 0;
  721 +}
  722 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <view class="plan-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 class="tool-icon" src="/static/images/dev_manage/filter_icon.png" @click="openFilter" />
  18 + </view>
  19 + </view>
  20 +
  21 + <view class="tabs">
  22 + <view
  23 + v-for="(t, i) in tabs"
  24 + :key="i"
  25 + :class="['tab', { active: frozen === t.value }]"
  26 + @click="switchTab(t)"
  27 + >
  28 + {{ t.label }}
  29 + </view>
  30 + </view>
  31 + </view>
  32 +
  33 + <view class="list-box">
  34 + <card-list
  35 + ref="cardRef"
  36 + :fetch-fn="fetchList"
  37 + :query="query"
  38 + :extra="extraParams"
  39 + row-key="id"
  40 + :enable-refresh="true"
  41 + :enable-load-more="true"
  42 + @loaded="onCardLoaded"
  43 + @error="onCardError"
  44 + >
  45 + <template v-slot="{ item }">
  46 + <view class="card" @click="onCardClick(item)">
  47 + <view class="card-header">
  48 + <text class="title omit2">{{ item.code || '-' }}</text>
  49 + <text :class="['status', `status_${item.approvalStatus}`]">{{ getAuditStatusText(item.approvalStatus) }}</text>
  50 + </view>
  51 + <view class="info-row">
  52 + <text>公司名称</text>
  53 + <text>{{item.companyShortName || '-' }}</text>
  54 + </view>
  55 + <view class="info-row">
  56 + <text>供应商名称</text>
  57 + <text>{{ item.supplierName || '-' }}</text>
  58 + </view>
  59 + <view class="info-row">
  60 + <text>数量</text>
  61 + <text>{{ formatQuantity(item.totalQuantity || 0) }}</text>
  62 + </view>
  63 + <view class="info-row">
  64 + <text>采购处</text>
  65 + <text>{{ item.purchaseDepartmentName || '-' }}</text>
  66 + </view>
  67 + </view>
  68 + </template>
  69 + </card-list>
  70 + </view>
  71 +
  72 + <filter-modal
  73 + :visible.sync="filterVisible"
  74 + :value.sync="filterForm"
  75 + title="筛选"
  76 + @reset="onFilterReset"
  77 + @confirm="onFilterConfirm"
  78 + >
  79 + <template v-slot="{ model }">
  80 + <view class="filter-form">
  81 + <view class="form-item">
  82 + <view class="label">编号</view>
  83 + <input class="input" v-model="model.code" placeholder="请输入编号" />
  84 + </view>
  85 + <view class="form-item">
  86 + <view class="label">供应商名称</view>
  87 + <input class="input" v-model="model.supplierName" placeholder="请输入供应商名称" />
  88 + </view>
  89 + <view class="form-item">
  90 + <view class="label">日期</view>
  91 + <uni-datetime-picker type="daterange" v-model="model.dateRange" start="2023-01-01" />
  92 + </view>
  93 + </view>
  94 + </template>
  95 + </filter-modal>
  96 + </view>
  97 +</template>
  98 +
  99 +<script>
  100 +import CardList from '@/components/card/index.vue'
  101 +import FilterModal from '@/components/filter/index.vue'
  102 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  103 +import { procurementPlanQueryApi } from '@/api/procure-manage/procurementPlan.js'
  104 +
  105 +export default {
  106 + name: 'DomesticPlan',
  107 + components: { CardList, FilterModal },
  108 + data() {
  109 + return {
  110 + searchKeyword: '',
  111 + searchKeywordDebounced: '',
  112 + searchDebounceTimer: null,
  113 + frozen: false,
  114 + tabs: [
  115 + { label: '未冻结', value: false },
  116 + { label: '已冻结', value: true }
  117 + ],
  118 + query: {
  119 + code: '',
  120 + supplierName: '',
  121 + dateRange: []
  122 + },
  123 + extraParams: {},
  124 + currentItems: [],
  125 + filterVisible: false,
  126 + filterForm: {
  127 + code: '',
  128 + supplierName: '',
  129 + dateRange: []
  130 + },
  131 + dicOptions: {
  132 + AUDIT_STATUS: []
  133 + }
  134 + }
  135 + },
  136 + computed: {
  137 + extraCombined() {
  138 + const keyword = this.searchKeywordDebounced || ''
  139 + return {
  140 + keyword: keyword || undefined,
  141 + frozen: this.frozen
  142 + }
  143 + }
  144 + },
  145 + watch: {
  146 + extraCombined: {
  147 + deep: true,
  148 + handler(v) {
  149 + this.extraParams = v
  150 + },
  151 + immediate: true
  152 + }
  153 + },
  154 + created() {
  155 + this.loadDicData()
  156 + },
  157 + onShow() {
  158 + let needRefresh = ''
  159 + try { needRefresh = uni.getStorageSync('DOMESTIC_PLAN_LIST_NEED_REFRESH') } catch (e) {}
  160 + if (!needRefresh) return
  161 + try { uni.removeStorageSync('DOMESTIC_PLAN_LIST_NEED_REFRESH') } catch (e) {}
  162 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.reload) {
  163 + this.$refs.cardRef.reload()
  164 + }
  165 + },
  166 + onReachBottom() {
  167 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.onLoadMore) {
  168 + this.$refs.cardRef.onLoadMore()
  169 + }
  170 + },
  171 + beforeDestroy() {
  172 + if (this.searchDebounceTimer) {
  173 + clearTimeout(this.searchDebounceTimer)
  174 + this.searchDebounceTimer = null
  175 + }
  176 + },
  177 + methods: {
  178 + async loadDicData() {
  179 + try {
  180 + const results = await getDicByCodes(['AUDIT_STATUS'])
  181 + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || []
  182 + } catch (e) {
  183 + this.dicOptions.AUDIT_STATUS = []
  184 + }
  185 + },
  186 + getAuditStatusText(status) {
  187 + const v = status == null ? '' : String(status)
  188 + if (!v) return '-'
  189 + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v
  190 + },
  191 + getTotalQuantity(item) {
  192 + const lines = item && item.procurementPlanLineList && Array.isArray(item.procurementPlanLineList)
  193 + ? item.procurementPlanLineList
  194 + : []
  195 + let total = 0
  196 + lines.forEach(line => {
  197 + const q = line && line.quantity != null ? Number(line.quantity) : 0
  198 + if (!isNaN(q)) total += q
  199 + })
  200 + return total
  201 + },
  202 + formatQuantity(val) {
  203 + if (val == null) return '-'
  204 + try {
  205 + const num = Number(val)
  206 + if (isNaN(num)) return '-'
  207 + return num.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  208 + } catch (e) {
  209 + return String(val)
  210 + }
  211 + },
  212 + onCardLoaded(_ref) {
  213 + var items = _ref.items
  214 + this.currentItems = items
  215 + },
  216 + onCardError() {
  217 + uni.showToast({ title: '列表加载失败', icon: 'none' })
  218 + },
  219 + onSearchInput() {
  220 + var _this = this
  221 + if (this.searchDebounceTimer) clearTimeout(this.searchDebounceTimer)
  222 + this.searchDebounceTimer = setTimeout(function () {
  223 + _this.searchKeywordDebounced = _this.searchKeyword
  224 + _this.searchDebounceTimer = null
  225 + }, 1200)
  226 + },
  227 + search(e) {
  228 + const val = e && e.value != null ? e.value : this.searchKeyword
  229 + this.searchKeyword = val
  230 + this.searchKeywordDebounced = val
  231 + },
  232 + switchTab(t) {
  233 + this.frozen = t.value
  234 + },
  235 + openFilter() {
  236 + this.filterForm = {
  237 + code: this.query.code || '',
  238 + supplierName: this.query.supplierName || '',
  239 + dateRange: Array.isArray(this.query.dateRange) ? this.query.dateRange.slice(0) : []
  240 + }
  241 + this.filterVisible = true
  242 + },
  243 + onFilterReset(payload) {
  244 + this.filterForm = payload
  245 + },
  246 + onFilterConfirm(payload) {
  247 + this.query = {
  248 + code: payload.code || '',
  249 + supplierName: payload.supplierName || '',
  250 + dateRange: Array.isArray(payload.dateRange) ? payload.dateRange : []
  251 + }
  252 + },
  253 + fetchList(_ref2) {
  254 + var _this2 = this
  255 + var pageIndex = _ref2.pageIndex
  256 + var pageSize = _ref2.pageSize
  257 + var query = _ref2.query
  258 + var extra = _ref2.extra
  259 + const q = query || {}
  260 + const e = extra || {}
  261 + const range = Array.isArray(q.dateRange) ? q.dateRange : []
  262 + const keyword = e.keyword || ''
  263 + const params = {
  264 + pageIndex: pageIndex,
  265 + pageSize: pageSize,
  266 + frozen: e.frozen != null ? e.frozen : false,
  267 + code: q.code || '',
  268 + supplierName: q.supplierName || '',
  269 + startDate: range && range.length === 2 ? range[0] : '',
  270 + endDate: range && range.length === 2 ? range[1] : ''
  271 + }
  272 + if (keyword) {
  273 + if (!params.code) params.code = keyword
  274 + if (!params.supplierName) params.supplierName = keyword
  275 + }
  276 + return procurementPlanQueryApi(params).then(function (res) {
  277 + const _data = res && res.data ? res.data : {}
  278 + let records = _data.datas || _data.list || _data.records || []
  279 + const totalCount = _data.totalCount || _data.count || 0
  280 + const hasNext = _data.hasNext || false
  281 + records = records.map(function (it) { return Object.assign({}, it) })
  282 + return { records: records, totalCount: totalCount, hasNext: hasNext }
  283 + }).catch(function () {
  284 + _this2.onCardError()
  285 + return { records: [], totalCount: 0, hasNext: false }
  286 + })
  287 + },
  288 + onCardClick(item) {
  289 + uni.navigateTo({ url: '/pages/domestic-plan/detail?id=' + item.id })
  290 + }
  291 + }
  292 +}
  293 +</script>
  294 +
  295 +<style lang="scss" scoped>
  296 +.page {
  297 + display: flex;
  298 + flex-direction: column;
  299 + height: 100vh;
  300 +}
  301 +.plan-list-fixed {
  302 + position: fixed;
  303 + top: 96rpx;
  304 + left: 0;
  305 + right: 0;
  306 + z-index: 2;
  307 + background: #fff;
  308 + .search-row {
  309 + display: flex;
  310 + align-items: center;
  311 + padding: 16rpx 32rpx;
  312 + .uni-searchbar { padding: 0; flex: 1; }
  313 + .tool-icons {
  314 + display: flex;
  315 + .tool-icon { width: 48rpx; height: 48rpx; display: block; margin-left: 32rpx; }
  316 + }
  317 + }
  318 + .tabs {
  319 + display: flex;
  320 + align-items: center;
  321 + justify-content: space-between;
  322 + padding: 26rpx 34rpx;
  323 + border-bottom: solid 1px #E7E7E7;
  324 + .tab { width: 50%; text-align: center; color: rgba(0,0,0,0.9); line-height: 44rpx; position: relative; font-weight: 600; }
  325 + .tab.active { color: $theme-primary; }
  326 + .tab.active::after {
  327 + content: '';
  328 + position: absolute;
  329 + left: 50%;
  330 + transform: translateX(-50%);
  331 + bottom: -13px;
  332 + width: 32rpx;
  333 + height: 6rpx;
  334 + border-radius: 4rpx;
  335 + background: $theme-primary;
  336 + }
  337 + }
  338 +}
  339 +::v-deep .uni-searchbar__box { height: 80rpx !important; justify-content: start; .uni-searchbar__box-search-input { font-size: 32rpx !important; } }
  340 +.list-box {
  341 + flex: 1;
  342 + padding-top: 236rpx;
  343 + .card { position: relative; }
  344 + .card-header {
  345 + margin-bottom: 28rpx;
  346 + position: relative;
  347 + .title { font-size: 36rpx; font-weight: 600; line-height: 50rpx; color: rgba(0,0,0,0.9); width: 578rpx; }
  348 + .status {
  349 + position: absolute;
  350 + top: -32rpx;
  351 + right: -12rpx;
  352 + height: 48rpx;
  353 + line-height: 48rpx;
  354 + font-weight: 600;
  355 + color: #fff;
  356 + font-size: 24rpx;
  357 + padding: 0 14rpx;
  358 + border-radius: 6rpx;
  359 + box-sizing: content-box;
  360 +
  361 + &.status_AUDIT {
  362 + background: $theme-primary;
  363 + }
  364 +
  365 + &.status_PASS {
  366 + background: #2BA471;
  367 + }
  368 +
  369 + &.status_REFUSE {
  370 + background: #D54941;
  371 + }
  372 +
  373 + &.status_CANCEL {
  374 + background: #E7E7E7;
  375 + color: rgba(0, 0, 0, 0.9);
  376 + }
  377 + }
  378 + }
  379 + .info-row {
  380 + display: flex;
  381 + align-items: center;
  382 + color: rgba(0,0,0,0.6);
  383 + font-size: 28rpx;
  384 + margin-bottom: 24rpx;
  385 + height: 32rpx;
  386 + &:last-child { margin-bottom: 0; }
  387 + text {
  388 + width: 50%;
  389 + &:last-child { color: rgba(0,0,0,0.9); width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  390 + }
  391 + }
  392 +}
  393 +.filter-form {
  394 + .form-item { margin-bottom: 24rpx; }
  395 + .label { margin-bottom: 20rpx; color: rgba(0,0,0,0.9); height: 44rpx; line-height: 44rpx; font-size: 30rpx; }
  396 + .input {
  397 + width: 100%;
  398 + height: 72rpx;
  399 + line-height: 72rpx;
  400 + padding: 0 24rpx;
  401 + border: 1rpx solid #E7E7E7;
  402 + border-radius: 8rpx;
  403 + font-size: 28rpx;
  404 + color: rgba(0,0,0,0.9);
  405 + background: #fff;
  406 + box-sizing: border-box;
  407 + }
  408 +}
  409 +</style>
... ...
  1 +<template>
  2 + <view class="product-rel">
  3 + <view class="header">
  4 + <image class="opCollapse" src="/static/images/title.png" />
  5 + <text class="title">明细信息</text>
  6 + <view class="ops">
  7 + <image v-if="(mode === 'add' || mode === 'edit') && !isSupplement && !isSelectWorkshop" class="opAdd" @click="onAdd" src="/static/images/plus.png" />
  8 + <view v-if="mode === 'view'" class="op1" @click="toggleViewCollapse">
  9 + <image class="opAdd" :src="collapsedView ? '/static/images/down.png' : '/static/images/up.png'" />
  10 + <text class="op">{{ collapsedView ? '展开' : '收起' }}</text>
  11 + </view>
  12 + </view>
  13 + </view>
  14 +
  15 + <view v-if="mode === 'add' || mode === 'edit'" class="add-list">
  16 + <view v-for="(item, idx) in items" :key="item._key || idx" class="block">
  17 + <uni-list v-show="!item.collapsed">
  18 + <uni-list-item
  19 + class="select-item"
  20 + :class="item.productName ? 'is-filled' : 'is-empty'"
  21 + :clickable="!isSelectWorkshop && !isSupplement"
  22 + @click="!isSelectWorkshop && !isSupplement ? openSelectSheet('product', idx) : undefined"
  23 + :rightText="item.productName || (isSelectWorkshop || isSupplement ? '-' : '请选择品种')"
  24 + :showArrow="!isSelectWorkshop && !isSupplement"
  25 + >
  26 + <template v-slot:body>
  27 + <view class="item-title" :class="{ 'no-required': isSelectWorkshop || isSupplement }">
  28 + <text v-if="!isSelectWorkshop && !isSupplement" class="required">*</text><text>品种</text>
  29 + </view>
  30 + </template>
  31 + </uni-list-item>
  32 + <uni-list-item title="料型">
  33 + <template v-slot:footer>
  34 + <uni-easyinput v-if="!isSelectWorkshop && !isSupplement" v-model="item.materialType" :inputBorder="false" placeholder="请输入料型" />
  35 + <text v-else class="lock-value">{{ safeText(item.materialType) }}</text>
  36 + </template>
  37 + </uni-list-item>
  38 + <uni-list-item title="数量(吨)">
  39 + <template v-slot:footer>
  40 + <template v-if="!isSelectWorkshop && !isSupplement">
  41 + <uni-easyinput
  42 + v-model="item.quantity"
  43 + type="digit"
  44 + :inputBorder="false"
  45 + placeholder="请输入数量"
  46 + @input="onNonNegativeInput(idx, 'quantity')"
  47 + @blur="onNonNegativeBlur(idx, 'quantity', 4)"
  48 + />
  49 + </template>
  50 + <text v-else class="lock-value">{{ formatTextNumber(item.quantity) }}</text>
  51 + </template>
  52 + </uni-list-item>
  53 + <uni-list-item title="实际采购价">
  54 + <template v-slot:footer>
  55 + <template v-if="!isSelectWorkshop && !isSupplement">
  56 + <uni-easyinput
  57 + v-model="item.actualPurchasePrice"
  58 + type="digit"
  59 + :inputBorder="false"
  60 + placeholder="请输入实际采购价"
  61 + @input="onNonNegativeInput(idx, 'actualPurchasePrice')"
  62 + @blur="onNonNegativeBlur(idx, 'actualPurchasePrice', 2)"
  63 + />
  64 + </template>
  65 + <text v-else class="lock-value">{{ formatTextNumber(item.actualPurchasePrice) }}</text>
  66 + </template>
  67 + </uni-list-item>
  68 + <uni-list-item title="含运到厂价">
  69 + <template v-slot:footer>
  70 + <!-- <template v-if="isSupplement">
  71 + <uni-easyinput
  72 + v-model="item.includingShippingPrice"
  73 + type="digit"
  74 + :inputBorder="false"
  75 + placeholder="请输入含运到厂价"
  76 + @input="onNonNegativeInput(idx, 'includingShippingPrice')"
  77 + @blur="onNonNegativeBlur(idx, 'includingShippingPrice', 2)"
  78 + />
  79 + </template> -->
  80 + <template v-if="!isSelectWorkshop || isSupplement">
  81 + <uni-easyinput
  82 + v-model="item.includingShippingPrice"
  83 + type="digit"
  84 + :inputBorder="false"
  85 + placeholder="请输入含运到厂价"
  86 + @input="onNonNegativeInput(idx, 'includingShippingPrice')"
  87 + @blur="onNonNegativeBlur(idx, 'includingShippingPrice', 2)"
  88 + />
  89 + </template>
  90 + <text v-else class="lock-value">{{ formatTextNumber(item.includingShippingPrice) }}</text>
  91 + </template>
  92 + </uni-list-item>
  93 + <uni-list-item title="价格表价格">
  94 + <template v-slot:footer>
  95 + <uni-easyinput
  96 + v-if="!isSelectWorkshop"
  97 + v-model="item.priceListPrices"
  98 + type="digit"
  99 + :inputBorder="false"
  100 + placeholder="请输入价格表价格"
  101 + @input="onNonNegativeInput(idx, 'priceListPrices')"
  102 + @blur="onNonNegativeBlur(idx, 'priceListPrices', 2)"
  103 + />
  104 + <text v-else class="lock-value">{{ formatTextNumber(item.priceListPrices) }}</text>
  105 + </template>
  106 + </uni-list-item>
  107 + <uni-list-item title="协调幅度">
  108 + <template v-slot:footer>
  109 + <template v-if="isSupplement">
  110 + <uni-easyinput
  111 + v-model="item.coordinationRange"
  112 + type="digit"
  113 + :inputBorder="false"
  114 + placeholder="请输入协调幅度"
  115 + @input="onSignedInput(idx, 'coordinationRange')"
  116 + @blur="onNonNegativeBlur(idx, 'coordinationRange', 2)"
  117 + />
  118 + </template>
  119 + <template v-else-if="!isSelectWorkshop">
  120 + <uni-easyinput
  121 + v-model="item.coordinationRange"
  122 + type="digit"
  123 + :inputBorder="false"
  124 + placeholder="请输入协调幅度"
  125 + @input="onSignedInput(idx, 'coordinationRange')"
  126 + @blur="onNonNegativeBlur(idx, 'coordinationRange', 2)"
  127 + />
  128 + </template>
  129 + <text v-else class="lock-value">{{ formatTextNumber(item.coordinationRange) }}</text>
  130 + </template>
  131 + </uni-list-item>
  132 + <uni-list-item title="买断料预计损耗">
  133 + <template v-slot:footer>
  134 + <template v-if="!isSelectWorkshop && !isSupplement">
  135 + <uni-easyinput
  136 + v-model="item.estimatedLoss"
  137 + type="digit"
  138 + :inputBorder="false"
  139 + placeholder="请输入预计损耗"
  140 + @input="onNonNegativeInput(idx, 'estimatedLoss')"
  141 + @blur="onNonNegativeBlur(idx, 'estimatedLoss', 2)"
  142 + />
  143 + </template>
  144 + <text v-else class="lock-value">{{ formatTextNumber(item.estimatedLoss) }}</text>
  145 + </template>
  146 + </uni-list-item>
  147 + <uni-list-item title="申请损耗(%)">
  148 + <template v-slot:footer>
  149 + <template v-if="!isSelectWorkshop && !isSupplement">
  150 + <uni-easyinput
  151 + v-model="item.applicationAttrition"
  152 + type="digit"
  153 + :inputBorder="false"
  154 + placeholder="请输入申请损耗"
  155 + @input="onNonNegativeInput(idx, 'applicationAttrition')"
  156 + @blur="onNonNegativeBlur(idx, 'applicationAttrition', 2)"
  157 + />
  158 + </template>
  159 + <text v-else class="lock-value">{{ formatTextNumber(item.applicationAttrition) }}</text>
  160 + </template>
  161 + </uni-list-item>
  162 + <uni-list-item
  163 + class="select-item"
  164 + :class="item.workshopName ? 'is-filled' : 'is-empty'"
  165 + :clickable="!isSupplement"
  166 + @click="!isSupplement ? openSelectSheet('workshop', idx) : undefined"
  167 + :rightText="item.workshopName || (isSupplement ? '-' : '请选择分厂')"
  168 + :showArrow="!isSupplement"
  169 + >
  170 + <template v-slot:body>
  171 + <view class="item-title" :class="{ 'no-required': isSupplement }">
  172 + <text v-if="!isSupplement" class="required">*</text><text>选择分厂</text>
  173 + </view>
  174 + </template>
  175 + </uni-list-item>
  176 + </uni-list>
  177 + <uni-list v-show="item.collapsed">
  178 + <uni-list-item
  179 + class="select-item"
  180 + :class="item.productName ? 'is-filled' : 'is-empty'"
  181 + :clickable="!isSelectWorkshop && !isSupplement"
  182 + @click="!isSelectWorkshop && !isSupplement ? openSelectSheet('product', idx) : undefined"
  183 + :rightText="item.productName || (isSelectWorkshop || isSupplement ? '-' : '请选择品种')"
  184 + :showArrow="!isSelectWorkshop && !isSupplement"
  185 + >
  186 + <template v-slot:body>
  187 + <view class="item-title" :class="{ 'no-required': isSelectWorkshop || isSupplement }">
  188 + <text v-if="!isSelectWorkshop && !isSupplement" class="required">*</text><text>品种</text>
  189 + </view>
  190 + </template>
  191 + </uni-list-item>
  192 + </uni-list>
  193 + <view class="block-ops" :class="{ 'readonly-ops': isSelectWorkshop || isSupplement }">
  194 + <div v-if="!isSelectWorkshop && !isSupplement" class="del" @click="onRemove(idx)">
  195 + <image src="/static/images/delete.png" class="icon" />
  196 + 删除
  197 + </div>
  198 + <div class="toggle" @click="toggleItem(idx)">
  199 + <image :src="item.collapsed ? '/static/images/up.png' : '/static/images/down.png'" class="icon" />
  200 + {{ item.collapsed ? '展开' : '收起' }}
  201 + </div>
  202 + </view>
  203 + </view>
  204 + </view>
  205 +
  206 + <view v-else class="view-list" v-show="!collapsedView">
  207 + <view v-if="!items.length" class="empty-tip">暂无明细</view>
  208 + <view v-for="(item, idx) in items" :key="'v-' + (item._key || item.itemId || idx)" class="card">
  209 + <view class="row"><text class="label">品种</text><text class="value">{{ safeText(item.productName || item.productId) }}</text></view>
  210 + <view class="row"><text class="label">料型</text><text class="value">{{ safeText(item.materialType) }}</text></view>
  211 + <view class="row"><text class="label">数量(吨)</text><text class="value">{{ formatNumber(item.quantity) }}</text></view>
  212 + <view class="row"><text class="label">实际采购价</text><text class="value">{{ formatNumber(item.actualPurchasePrice) }}</text></view>
  213 + <view class="row"><text class="label">含运到厂价</text><text class="value">{{ formatNumber(item.includingShippingPrice) }}</text></view>
  214 + <view class="row"><text class="label">价格表价格</text><text class="value">{{ formatNumber(item.priceListPrices) }}</text></view>
  215 + <view class="row"><text class="label">协调幅度</text><text class="value">{{ formatNumber(item.coordinationRange) }}</text></view>
  216 + <view class="row"><text class="label">买断料预计损耗</text><text class="value">{{ formatNumber(item.estimatedLoss) }}</text></view>
  217 + <view class="row"><text class="label">申请损耗(%)</text><text class="value">{{ formatNumber(item.applicationAttrition) }}</text></view>
  218 + <view class="row"><text class="label">分厂</text><text class="value">{{ safeText(item.workshopName || item.workshopId) }}</text></view>
  219 + </view>
  220 + </view>
  221 +
  222 + <SingleSelectSheet
  223 + :visible.sync="sheet.visible"
  224 + :title="sheet.title"
  225 + :options="sheet.options"
  226 + v-model="sheet.value"
  227 + @confirm="onSheetConfirm"
  228 + />
  229 + </view>
  230 +</template>
  231 +
  232 +<script>
  233 +import SingleSelectSheet from '@/components/single-select/index.vue'
  234 +
  235 +export default {
  236 + name: 'DomesticPlanProductRel',
  237 + props: {
  238 + mode: { type: String, default: 'view' },
  239 + scene: { type: String, default: '' },
  240 + list: { type: Array, default: function () { return [] } },
  241 + max: { type: Number, default: 50 },
  242 + productOptions: { type: Array, default: function () { return [] } },
  243 + workshopOptions: { type: Array, default: function () { return [] } }
  244 + },
  245 + components: { SingleSelectSheet },
  246 + data() {
  247 + return {
  248 + items: [],
  249 + collapsedView: false,
  250 + sheet: { visible: false, title: '请选择', options: [], value: '', idx: -1, type: '' },
  251 + _initialized: false
  252 + }
  253 + },
  254 + computed: {
  255 + isSupplement() { return this.scene === 'supplement' },
  256 + isSelectWorkshop() { return this.scene === 'selectWorkshop' },
  257 + productOptsComputed() {
  258 + var list = Array.isArray(this.productOptions) ? this.productOptions : []
  259 + return list.map(function (o) {
  260 + return {
  261 + label: o.label != null ? o.label : (o.name != null ? o.name : (o.productName || '')),
  262 + value: o.value != null ? o.value : (o.id != null ? o.id : o.productId)
  263 + }
  264 + })
  265 + },
  266 + workshopOptsComputed() {
  267 + var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  268 + return list.map(function (o) {
  269 + return {
  270 + label: o.label != null ? o.label : (o.name != null ? o.name : (o.workshopName || '')),
  271 + value: o.value != null ? o.value : (o.id != null ? o.id : o.workshopId)
  272 + }
  273 + })
  274 + }
  275 + },
  276 + watch: {
  277 + items: {
  278 + handler() { this.emitChange() },
  279 + deep: true
  280 + },
  281 + list: {
  282 + handler(v) {
  283 + this._initialized = false
  284 + this.initItems()
  285 + var self = this
  286 + this.$nextTick(function () { self._initialized = true })
  287 + },
  288 + immediate: false
  289 + }
  290 + },
  291 + created() {
  292 + this.initItems()
  293 + var self = this
  294 + this.$nextTick(function () { self._initialized = true })
  295 + },
  296 + methods: {
  297 + initItems() {
  298 + var src = Array.isArray(this.list) && this.list.length > 0 ? this.list : []
  299 + if (!src.length) {
  300 + if (this.mode === 'add' || this.mode === 'edit') {
  301 + this.items = [Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false })]
  302 + } else {
  303 + this.items = []
  304 + }
  305 + return
  306 + }
  307 + var existing = this.items || []
  308 + var existingMap = {}
  309 + existing.forEach(function (it) {
  310 + if (it.itemId) existingMap[it.itemId] = it
  311 + })
  312 + var self = this
  313 + this.items = src.map(function (x, i) {
  314 + var key = x && x.itemId ? x.itemId : (x && x._key ? x._key : self.newKey())
  315 + var old = existingMap[key]
  316 + return Object.assign({}, self.defaultItem(), x, {
  317 + _key: key,
  318 + itemId: x && x.itemId ? x.itemId : key,
  319 + collapsed: old ? old.collapsed : true
  320 + })
  321 + })
  322 + },
  323 + newKey() {
  324 + return Date.now() + '-' + Math.random().toString(16).slice(2)
  325 + },
  326 + defaultItem() {
  327 + return {
  328 + productId: '',
  329 + productName: '',
  330 + materialType: '',
  331 + quantity: '',
  332 + actualPurchasePrice: '',
  333 + includingShippingPrice: '',
  334 + priceListPrices: '',
  335 + coordinationRange: '',
  336 + estimatedLoss: '',
  337 + applicationAttrition: '',
  338 + workshopId: '',
  339 + workshopName: ''
  340 + }
  341 + },
  342 + onNonNegativeInput(idx, field) {
  343 + var it = this.items[idx]
  344 + if (!it) return
  345 + var v = String(it[field] != null ? it[field] : '')
  346 + v = v.replace(/[^0-9.]/g, '')
  347 + v = v.replace(/(\..*)\./g, '$1')
  348 + it[field] = v
  349 + this.$set(this.items, idx, it)
  350 + },
  351 + onSignedInput(idx, field) {
  352 + var it = this.items[idx]
  353 + if (!it) return
  354 + var v = String(it[field] != null ? it[field] : '')
  355 + var sign = ''
  356 + if (v.charAt(0) === '-') { sign = '-'; v = v.slice(1) }
  357 + v = v.replace(/[^0-9.]/g, '')
  358 + v = v.replace(/(\..*)\./g, '$1')
  359 + it[field] = sign + v
  360 + this.$set(this.items, idx, it)
  361 + },
  362 + onNonNegativeBlur(idx, field, digits) {
  363 + var it = this.items[idx]
  364 + if (!it) return
  365 + var raw = it[field]
  366 + if (raw === '' || raw === null || raw === undefined) {
  367 + this.$set(this.items, idx, it)
  368 + return
  369 + }
  370 + var val = parseFloat(raw)
  371 + if (isNaN(val)) val = 0
  372 + var m = Math.pow(10, digits)
  373 + var rounded = Math.round(val * m) / m
  374 + it[field] = rounded
  375 + this.$set(this.items, idx, it)
  376 + },
  377 + onAdd() {
  378 + if (this.items.length >= this.max) {
  379 + uni.showToast({ title: '最多' + this.max + '条明细', icon: 'none' })
  380 + return
  381 + }
  382 + this.items.push(Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false }))
  383 + },
  384 + onRemove(idx) {
  385 + this.items.splice(idx, 1)
  386 + if ((this.mode === 'add' || this.mode === 'edit') && this.items.length === 0) {
  387 + this.items.push(Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false }))
  388 + }
  389 + },
  390 + toggleItem(idx) {
  391 + var it = this.items[idx]
  392 + if (!it) return
  393 + this.$set(it, 'collapsed', !it.collapsed)
  394 + },
  395 + toggleViewCollapse() {
  396 + this.collapsedView = !this.collapsedView
  397 + },
  398 + openSelectSheet(type, idx) {
  399 + if (type === 'product') {
  400 + var pOpts = this.productOptsComputed
  401 + var curP = this.items[idx] && this.items[idx].productId
  402 + var mP = pOpts.find(function (o) { return String(o.value) === String(curP) })
  403 + this.sheet = { visible: true, title: '请选择品种', options: pOpts, value: mP ? mP.value : '', idx: idx, type: type }
  404 + } else if (type === 'workshop') {
  405 + var wOpts = this.workshopOptsComputed
  406 + var curW = this.items[idx] && this.items[idx].workshopId
  407 + var mW = wOpts.find(function (o) { return String(o.value) === String(curW) })
  408 + this.sheet = { visible: true, title: '请选择分厂', options: wOpts, value: mW ? mW.value : '', idx: idx, type: type }
  409 + }
  410 + },
  411 + onSheetConfirm(_ref) {
  412 + var value = _ref.value
  413 + var label = _ref.label
  414 + var idx = this.sheet.idx
  415 + var type = this.sheet.type
  416 + if (idx < 0 || !this.items[idx]) return
  417 + var it = this.items[idx]
  418 + if (type === 'product') {
  419 + this.$set(it, 'productId', value)
  420 + this.$set(it, 'productName', label)
  421 + } else if (type === 'workshop') {
  422 + this.$set(it, 'workshopId', value)
  423 + this.$set(it, 'workshopName', label)
  424 + }
  425 + },
  426 + emitChange() {
  427 + if (!this._initialized) return
  428 + var list = (this.items || []).map(function (it) {
  429 + var c = Object.assign({}, it)
  430 + var key = c._key
  431 + delete c._key
  432 + delete c.collapsed
  433 + delete c._selected
  434 + if (!c.itemId) c.itemId = key
  435 + return c
  436 + })
  437 + this.$emit('change', list)
  438 + },
  439 + safeText(v) {
  440 + var s = v == null ? '' : String(v)
  441 + return s.trim() ? s : '-'
  442 + },
  443 + formatNumber(v) {
  444 + if (v == null || v === '') return '-'
  445 + var n = Number(v)
  446 + if (isNaN(n)) return String(v)
  447 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  448 + },
  449 + formatTextNumber(v) {
  450 + if (v == null || v === '') return '-'
  451 + var n = Number(v)
  452 + if (isNaN(n)) return String(v)
  453 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  454 + },
  455 + validate() {
  456 + var list = this.items || []
  457 + for (var i = 0; i < list.length; i++) {
  458 + var it = list[i]
  459 + if (!this.isSupplement && !this.isSelectWorkshop && !it.productId) {
  460 + uni.showToast({ title: '第' + (i + 1) + '条明细:请选择品种', icon: 'none' })
  461 + return false
  462 + }
  463 + if (!this.isSupplement && !it.workshopId) {
  464 + uni.showToast({ title: '第' + (i + 1) + '条明细:请选择分厂', icon: 'none' })
  465 + return false
  466 + }
  467 + }
  468 + return true
  469 + }
  470 + }
  471 +}
  472 +</script>
  473 +
  474 +<style lang="scss" scoped>
  475 +.product-rel {
  476 + margin-top: 20rpx;
  477 + background: #fff;
  478 +}
  479 +.header {
  480 + display: flex;
  481 + align-items: center;
  482 + padding: 24rpx 32rpx;
  483 + border-bottom: 1rpx solid #f0f0f0;
  484 +}
  485 +.title {
  486 + font-size: 32rpx;
  487 + color: rgba(0, 0, 0, 0.9);
  488 + font-weight: 600;
  489 +}
  490 +.ops {
  491 + margin-left: auto;
  492 +}
  493 +.op {
  494 + color: $theme-primary;
  495 + font-size: 28rpx;
  496 + margin-left: 8rpx;
  497 +}
  498 +.op1 {
  499 + display: flex;
  500 + align-items: center;
  501 +}
  502 +.opAdd {
  503 + color: rgba(0, 0, 0, 0.6);
  504 + width: 40rpx;
  505 + height: 40rpx;
  506 +}
  507 +.opCollapse {
  508 + color: rgba(0, 0, 0, 0.6);
  509 + width: 32rpx;
  510 + height: 28rpx;
  511 + margin-right: 16rpx;
  512 + margin-top: 8rpx;
  513 +}
  514 +.block {
  515 + background: #fff;
  516 + margin-bottom: 20rpx;
  517 +}
  518 +::v-deep .uni-list-item__content {
  519 + display: flex;
  520 + justify-content: center;
  521 +}
  522 +::v-deep .uni-list {
  523 + .uni-easyinput {
  524 + display: flex;
  525 + .uni-input-input {
  526 + color: rgba(0, 0, 0, 0.9);
  527 + }
  528 + }
  529 + .uni-input-placeholder { z-index: 1; }
  530 + .uni-input-input { background-color: #ffffff; }
  531 + background: transparent;
  532 + &-item {
  533 + &__container { padding: 32rpx; }
  534 + &__content-title {
  535 + font-size: 28rpx;
  536 + color: rgba(0, 0, 0, 0.9);
  537 + }
  538 + &__extra-text { font-size: 32rpx; }
  539 + .uni-easyinput {
  540 + width: 100%;
  541 + &__placeholder-class {
  542 + font-size: 32rpx;
  543 + color: rgba(0, 0, 0, 0.4);
  544 + }
  545 + &__content {
  546 + border: none;
  547 + background-color: #ffffff !important;
  548 + display: flex;
  549 + &-input {
  550 + padding-left: 0 !important;
  551 + height: 48rpx;
  552 + line-height: 48rpx;
  553 + font-size: 32rpx;
  554 + }
  555 + }
  556 + }
  557 + &.select-item {
  558 + &.is-empty {
  559 + .uni-list-item__extra-text { color: rgba(0, 0, 0, 0.4) !important; }
  560 + }
  561 + &.is-filled {
  562 + .uni-list-item__extra-text { color: rgba(0, 0, 0, 0.9) !important; }
  563 + }
  564 + }
  565 + }
  566 +}
  567 +
  568 +::v-deep .uni-easyinput {
  569 + width: 100%;
  570 + &__content {
  571 + background: #f8f8f8 !important;
  572 + border-radius: 8rpx;
  573 + &-input { font-size: 30rpx; }
  574 + }
  575 +}
  576 +.block-ops {
  577 + display: flex;
  578 + padding: 20rpx 32rpx 20rpx;
  579 + justify-content: space-around;
  580 + &.readonly-ops {
  581 + justify-content: flex-end;
  582 + }
  583 +}
  584 +.del {
  585 + color: #D54941;
  586 + font-size: 28rpx;
  587 + display: flex;
  588 + align-items: center;
  589 + image { width: 40rpx; height: 40rpx; }
  590 +}
  591 +.toggle {
  592 + color: $theme-primary;
  593 + font-size: 28rpx;
  594 + display: flex;
  595 + align-items: center;
  596 + image { width: 40rpx; height: 40rpx; }
  597 +}
  598 +.view-list {
  599 + padding: 24rpx 32rpx;
  600 + background: #ffffff;
  601 +}
  602 +.empty-tip {
  603 + text-align: center;
  604 + font-size: 28rpx;
  605 + color: rgba(0, 0, 0, 0.4);
  606 + padding: 24rpx 0;
  607 +}
  608 +.card {
  609 + background: #f3f3f3;
  610 + border-radius: 16rpx;
  611 + padding: 24rpx;
  612 + margin-bottom: 20rpx;
  613 +}
  614 +.row {
  615 + display: flex;
  616 + margin-bottom: 20rpx;
  617 +}
  618 +.row:last-child { margin-bottom: 0; }
  619 +.label {
  620 + width: 260rpx;
  621 + color: rgba(0, 0, 0, 0.6);
  622 + font-size: 28rpx;
  623 +}
  624 +.value {
  625 + flex: 1;
  626 + color: rgba(0, 0, 0, 0.9);
  627 + font-size: 28rpx;
  628 + word-break: break-all;
  629 +}
  630 +.item-title {
  631 + position: relative;
  632 + width: 210rpx;
  633 + margin-right: 32rpx;
  634 + color: rgba(0, 0, 0, 0.9);
  635 + font-size: 32rpx;
  636 + min-height: 48rpx;
  637 + line-height: 48rpx;
  638 + .required {
  639 + color: red;
  640 + position: absolute;
  641 + top: 50%;
  642 + transform: translateY(-50%);
  643 + left: -16rpx;
  644 + }
  645 +}
  646 +.lock-value {
  647 + flex: 1;
  648 + text-align: right;
  649 + font-size: 32rpx;
  650 + color: rgba(0, 0, 0, 0.85);
  651 + padding: 8rpx 0;
  652 +}
  653 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view scroll-y class="scroll">
  4 + <uni-list>
  5 + <uni-list-item class="select-item" :class="detail.code ? 'is-filled' : 'is-empty'">
  6 + <template v-slot:body>
  7 + <view class="item-title"><text>编号</text></view>
  8 + </template>
  9 + <template v-slot:footer>
  10 + <view class="serial-number-row">
  11 + <text class="readonly-text value-code">{{ safeText(detail.code) }}</text>
  12 + </view>
  13 + </template>
  14 + </uni-list-item>
  15 +
  16 + <uni-list-item title="公司名称">
  17 + <template v-slot:footer>
  18 + <uni-easyinput v-model="companyNameDisplay" :inputBorder="false" disabled placeholder="-" />
  19 + </template>
  20 + </uni-list-item>
  21 +
  22 + <uni-list-item title="供应商名称">
  23 + <template v-slot:footer>
  24 + <uni-easyinput v-model="detail.supplierName" :inputBorder="false" disabled placeholder="-" />
  25 + </template>
  26 + </uni-list-item>
  27 +
  28 + <uni-list-item title="采购处">
  29 + <template v-slot:footer>
  30 + <uni-easyinput v-model="purchaseDepartmentDisplay" :inputBorder="false" disabled placeholder="-" />
  31 + </template>
  32 + </uni-list-item>
  33 +
  34 + <uni-list-item title="区域">
  35 + <template v-slot:footer>
  36 + <uni-easyinput v-model="regionDisplay" :inputBorder="false" disabled placeholder="-" />
  37 + </template>
  38 + </uni-list-item>
  39 +
  40 + <uni-list-item title="日期">
  41 + <template v-slot:footer>
  42 + <uni-easyinput v-model="dateDisplay" :inputBorder="false" disabled placeholder="-" />
  43 + </template>
  44 + </uni-list-item>
  45 +
  46 + <uni-list-item title="报价时效">
  47 + <template v-slot:footer>
  48 + <uni-easyinput v-model="detail.validityPeriod" :inputBorder="false" disabled placeholder="-" />
  49 + </template>
  50 + </uni-list-item>
  51 +
  52 + <uni-list-item title="报价人">
  53 + <template v-slot:footer>
  54 + <uni-easyinput v-model="detail.quoterName" :inputBorder="false" disabled placeholder="-" />
  55 + </template>
  56 + </uni-list-item>
  57 +
  58 + <uni-list-item class="select-item" :class="typeof detail.longTermOperation === 'boolean' ? 'is-filled' : 'is-empty'">
  59 + <template v-slot:body>
  60 + <view class="item-title"><text>是否长单操作</text></view>
  61 + </template>
  62 + <template v-slot:footer>
  63 + <text class="readonly-text">{{ boolText(detail.longTermOperation) }}</text>
  64 + </template>
  65 + </uni-list-item>
  66 +
  67 + <uni-list-item class="select-item" :class="typeof detail.terminalCustomer === 'boolean' ? 'is-filled' : 'is-empty'">
  68 + <template v-slot:body>
  69 + <view class="item-title"><text>是否终端客户</text></view>
  70 + </template>
  71 + <template v-slot:footer>
  72 + <text class="readonly-text">{{ boolText(detail.terminalCustomer) }}</text>
  73 + </template>
  74 + </uni-list-item>
  75 +
  76 + <uni-list-item class="select-item" :class="typeof detail.priced === 'boolean' ? 'is-filled' : 'is-empty'">
  77 + <template v-slot:body>
  78 + <view class="item-title"><text>是否未点价</text></view>
  79 + </template>
  80 + <template v-slot:footer>
  81 + <text class="readonly-text">{{ boolText(detail.priced) }}</text>
  82 + </template>
  83 + </uni-list-item>
  84 +
  85 + <uni-list-item v-if="detail.priced === true" title="点价截止日期">
  86 + <template v-slot:footer>
  87 + <uni-easyinput v-model="pricingDeadlineDisplay" :inputBorder="false" disabled placeholder="-" />
  88 + </template>
  89 + </uni-list-item>
  90 +
  91 + <uni-list-item v-if="detail.priced === true" class="select-item" :class="typeof detail.temporaryPrice === 'boolean' ? 'is-filled' : 'is-empty'">
  92 + <template v-slot:body>
  93 + <view class="item-title"><text>是否暂定价</text></view>
  94 + </template>
  95 + <template v-slot:footer>
  96 + <text class="readonly-text">{{ boolText(detail.temporaryPrice) }}</text>
  97 + </template>
  98 + </uni-list-item>
  99 +
  100 + <uni-list-item class="select-item" :class="typeof detail.otherExpenseSettlement === 'boolean' ? 'is-filled' : 'is-empty'">
  101 + <template v-slot:body>
  102 + <view class="item-title"><text>其他费用凭票到厂另行结算</text></view>
  103 + </template>
  104 + <template v-slot:footer>
  105 + <text class="readonly-text">{{ boolText(detail.otherExpenseSettlement) }}</text>
  106 + </template>
  107 + </uni-list-item>
  108 +
  109 + <uni-list-item class="select-item" :class="detail.deliveryMode ? 'is-filled' : 'is-empty'">
  110 + <template v-slot:body>
  111 + <view class="item-title"><text>交提货方式</text></view>
  112 + </template>
  113 + <template v-slot:footer>
  114 + <text class="readonly-text">{{ getDeliveryMethodLabel() }}</text>
  115 + </template>
  116 + </uni-list-item>
  117 +
  118 + <uni-list-item class="select-item" :class="typeof detail.commodityBuyout === 'boolean' ? 'is-filled' : 'is-empty'">
  119 + <template v-slot:body>
  120 + <view class="item-title"><text>是否通货买断</text></view>
  121 + </template>
  122 + <template v-slot:footer>
  123 + <text class="readonly-text">{{ boolText(detail.commodityBuyout) }}</text>
  124 + </template>
  125 + </uni-list-item>
  126 +
  127 + <uni-list-item class="select-item" :class="typeof detail.qualityBuyout === 'boolean' ? 'is-filled' : 'is-empty'">
  128 + <template v-slot:body>
  129 + <view class="item-title"><text>是否质量买断</text></view>
  130 + </template>
  131 + <template v-slot:footer>
  132 + <text class="readonly-text">{{ boolText(detail.qualityBuyout) }}</text>
  133 + </template>
  134 + </uni-list-item>
  135 +
  136 + <uni-list-item class="select-item" :class="typeof detail.quantityBuyout === 'boolean' ? 'is-filled' : 'is-empty'">
  137 + <template v-slot:body>
  138 + <view class="item-title"><text>是否数量买断</text></view>
  139 + </template>
  140 + <template v-slot:footer>
  141 + <text class="readonly-text">{{ boolText(detail.quantityBuyout) }}</text>
  142 + </template>
  143 + </uni-list-item>
  144 +
  145 + <uni-list-item class="select-item" :class="typeof detail.doorDelivery === 'boolean' ? 'is-filled' : 'is-empty'">
  146 + <template v-slot:body>
  147 + <view class="item-title"><text>是否送货上门</text></view>
  148 + </template>
  149 + <template v-slot:footer>
  150 + <text class="readonly-text">{{ boolText(detail.doorDelivery) }}</text>
  151 + </template>
  152 + </uni-list-item>
  153 +
  154 + <uni-list-item title="另付运费">
  155 + <template v-slot:footer>
  156 + <uni-easyinput v-model="shippingCostDisplay" :inputBorder="false" disabled placeholder="-" />
  157 + </template>
  158 + </uni-list-item>
  159 +
  160 + <uni-list-item title="装车费">
  161 + <template v-slot:footer>
  162 + <uni-easyinput v-model="loadingFeeDisplay" :inputBorder="false" disabled placeholder="-" />
  163 + </template>
  164 + </uni-list-item>
  165 +
  166 + <uni-list-item title="开票品名">
  167 + <template v-slot:footer>
  168 + <uni-easyinput v-model="detail.invoiceProductName" :inputBorder="false" disabled placeholder="-" />
  169 + </template>
  170 + </uni-list-item>
  171 +
  172 + <uni-list-item title="交货日期">
  173 + <template v-slot:footer>
  174 + <uni-easyinput v-model="deliveryDateDisplay" :inputBorder="false" disabled placeholder="-" />
  175 + </template>
  176 + </uni-list-item>
  177 +
  178 + <uni-list-item title="结算方式">
  179 + <template v-slot:footer>
  180 + <uni-easyinput v-model="detail.settlementMethod" :inputBorder="false" disabled placeholder="-" />
  181 + </template>
  182 + </uni-list-item>
  183 +
  184 + <uni-list-item title="结算比例(%)">
  185 + <template v-slot:footer>
  186 + <uni-easyinput v-model="settlementRatioDisplay" :inputBorder="false" disabled placeholder="-" />
  187 + </template>
  188 + </uni-list-item>
  189 +
  190 + <uni-list-item title="价格表编号">
  191 + <template v-slot:footer>
  192 + <uni-easyinput v-model="priceTableDisplay" :inputBorder="false" disabled placeholder="-" />
  193 + </template>
  194 + </uni-list-item>
  195 +
  196 + <uni-list-item title="协调事由">
  197 + <template v-slot:footer>
  198 + <uni-easyinput v-model="detail.coordinationReason" :inputBorder="false" disabled placeholder="-" />
  199 + </template>
  200 + </uni-list-item>
  201 +
  202 + <uni-list-item title="票类状况">
  203 + <template v-slot:footer>
  204 + <uni-easyinput v-model="detail.invoiceTypeStatus" :inputBorder="false" disabled placeholder="-" />
  205 + </template>
  206 + </uni-list-item>
  207 +
  208 + <uni-list-item v-if="attachmentList.length" title="附件">
  209 + <template v-slot:footer>
  210 + <view class="attach-list">
  211 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  212 + <text class="attach-name">{{ at.name }}</text>
  213 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  214 + </view>
  215 + </view>
  216 + </template>
  217 + </uni-list-item>
  218 +
  219 + <ProductRel
  220 + ref="productRel"
  221 + mode="edit"
  222 + :scene="workshopScene"
  223 + :list="lineList"
  224 + :product-options="productOptions"
  225 + :workshop-options="workshopOptions"
  226 + @change="onLineChange"
  227 + />
  228 + </uni-list>
  229 +
  230 + <view class="material-condition-section">
  231 + <view class="section-header">
  232 + <image class="opCollapse" src="/static/images/title.png" />
  233 + <text class="section-title">料质状况</text>
  234 + </view>
  235 + <view class="section-content">
  236 + <view class="form-row">
  237 + <text class="form-label">是否启用料质状况</text>
  238 + <text class="form-value">{{ boolText(detail.materialConditionEnabled) }}</text>
  239 + </view>
  240 + <template v-if="detail.materialConditionEnabled">
  241 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  242 + <text class="material-label">{{ mc.label }}</text>
  243 + <view class="tag-list">
  244 + <view
  245 + v-for="opt in getDictOptions(mc.dictCode)"
  246 + :key="opt.code"
  247 + class="tag-btn"
  248 + :class="{ active: isTagSelected(mc.field, opt.code) }"
  249 + >
  250 + {{ opt.name }}
  251 + </view>
  252 + </view>
  253 + </view>
  254 + </template>
  255 + </view>
  256 + </view>
  257 +
  258 + <view class="remark-section">
  259 + <view class="section-header">
  260 + <image class="opCollapse" src="/static/images/title.png" />
  261 + <text class="section-title">备注</text>
  262 + </view>
  263 + <view class="section-content">
  264 + <text class="remark-text">{{ safeText(detail.remark) }}</text>
  265 + </view>
  266 + </view>
  267 +
  268 + <view class="footer-tip">提示:仅「选择分厂」字段可编辑,其余字段自动带出且不可编辑</view>
  269 + </scroll-view>
  270 +
  271 + <view class="bottom-bar">
  272 + <button class="btn btn-outline" @click="onBack">取消</button>
  273 + <button class="btn btn-primary" @click="onSubmit">保存</button>
  274 + </view>
  275 + </view>
  276 +</template>
  277 +
  278 +<script>
  279 +import ProductRel from './productRel.vue'
  280 +import { procurementPlanDetailApi, procurementPlanUpdateApi } from '@/api/procure-manage/procurementPlan.js'
  281 +import { breedRelationshipQueryApi, workshopQueryApi, priceTableQueryApi, priceTableDetailApi } from '@/api/devManage.js'
  282 +import { getDicByCodes } from '@/utils/dic.js'
  283 +
  284 +export default {
  285 + name: 'DomesticPlanSelectWorkshop',
  286 + components: { ProductRel },
  287 + data() {
  288 + return {
  289 + workshopScene: 'selectWorkshop',
  290 + id: '',
  291 + detail: {},
  292 + attachmentList: [],
  293 + materialConditionConfigs: [
  294 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  295 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  296 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  297 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  298 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  299 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  300 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  301 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  302 + ],
  303 + dictData: {},
  304 + lineList: [],
  305 + productOptions: [],
  306 + workshopOptions: []
  307 + }
  308 + },
  309 + computed: {
  310 + companyNameDisplay() {
  311 + var d = this.detail || {}
  312 + return d.companyShortName != null ? d.companyShortName : (d.companyName != null ? d.companyName : '')
  313 + },
  314 + purchaseDepartmentDisplay() {
  315 + var d = this.detail || {}
  316 + return d.purchaseDepartmentName != null ? d.purchaseDepartmentName : (d.purchaseDepartment != null ? d.purchaseDepartment : '')
  317 + },
  318 + regionDisplay() {
  319 + var d = this.detail || {}
  320 + return d.regionName != null ? d.regionName : (d.region != null ? d.region : '')
  321 + },
  322 + dateDisplay() {
  323 + var d = this.detail || {}
  324 + var s = d.date == null ? '' : String(d.date).trim()
  325 + if (!s) return ''
  326 + return s.length >= 10 ? s.slice(0, 10) : s
  327 + },
  328 + pricingDeadlineDisplay() {
  329 + var d = this.detail || {}
  330 + var s = d.pricingDeadline == null ? '' : String(d.pricingDeadline).trim()
  331 + if (!s) return ''
  332 + return s.length >= 10 ? s.slice(0, 10) : s
  333 + },
  334 + deliveryDateDisplay() {
  335 + var d = this.detail || {}
  336 + var s = d.deliveryDate == null ? '' : String(d.deliveryDate).trim()
  337 + if (!s) return ''
  338 + return s.length >= 10 ? s.slice(0, 10) : s
  339 + },
  340 + loadingFeeDisplay() {
  341 + var v = (this.detail || {}).loadingFee
  342 + if (v == null || v === '') return ''
  343 + var n = Number(v)
  344 + if (isNaN(n)) return String(v)
  345 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  346 + },
  347 + shippingCostDisplay() {
  348 + var v = (this.detail || {}).shippingCost
  349 + if (v == null || v === '') return ''
  350 + var n = Number(v)
  351 + if (isNaN(n)) return String(v)
  352 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 2 })
  353 + },
  354 + settlementRatioDisplay() {
  355 + var v = (this.detail || {}).settlementRatio
  356 + if (v == null || v === '') return ''
  357 + var n = Number(v)
  358 + if (isNaN(n)) return String(v)
  359 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  360 + },
  361 + priceTableDisplay() {
  362 + var d = this.detail || {}
  363 + var c = d.priceTableCode != null ? d.priceTableCode : (d.priceTableId != null ? d.priceTableId : '')
  364 + var n = d.priceTableName != null ? d.priceTableName : ''
  365 + if (!c && !n) return ''
  366 + return n ? (n + (c ? ' (' + c + ')' : '')) : c
  367 + }
  368 + },
  369 + onLoad(query) {
  370 + this.id = (query && query.id) ? query.id : ''
  371 + this.loadDictData()
  372 + this.loadRefData()
  373 + if (this.id) {
  374 + this.loadSourceDetail()
  375 + }
  376 + },
  377 + methods: {
  378 + toNumber(v) {
  379 + if (v == null || v === '') return 0
  380 + var n = Number(v)
  381 + return isNaN(n) ? 0 : n
  382 + },
  383 + toFixed(v, n) {
  384 + var num = Number(v)
  385 + if (isNaN(num)) return ''
  386 + return num.toFixed(n)
  387 + },
  388 + safeText(v) {
  389 + var s = v == null ? '' : String(v)
  390 + return s.trim() ? s : '-'
  391 + },
  392 + boolText(v) {
  393 + if (typeof v !== 'boolean') return '-'
  394 + return v ? '是' : '否'
  395 + },
  396 + async loadDictData() {
  397 + var codes = this.materialConditionConfigs.map(function (mc) { return mc.dictCode }).concat(['DELIVERY_METHOD'])
  398 + try {
  399 + var results = await getDicByCodes(codes)
  400 + this.dictData = results || {}
  401 + } catch (e) {
  402 + this.dictData = {}
  403 + }
  404 + },
  405 + getDictOptions(dictCode) {
  406 + var data = this.dictData[dictCode]
  407 + return (data && data.data) ? data.data : []
  408 + },
  409 + isTagSelected(field, code) {
  410 + var selected = this.detail ? this.detail[field] : undefined
  411 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  412 + if (typeof selected === 'string' && selected) {
  413 + return selected.split(',').indexOf(code) >= 0
  414 + }
  415 + return false
  416 + },
  417 + getDeliveryMethodLabel() {
  418 + var opts = this.getDictOptions('DELIVERY_METHOD') || []
  419 + var v = String(this.detail.deliveryMode != null ? this.detail.deliveryMode : '')
  420 + if (!v) return '-'
  421 + for (var i = 0; i < opts.length; i++) {
  422 + var o = opts[i]
  423 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  424 + if (code === v) return o.name || o.label || '-'
  425 + }
  426 + return v
  427 + },
  428 + buildAttachmentList() {
  429 + var ids = this.detail.attachmentFileIds
  430 + var names = this.detail.attachmentFileNames
  431 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  432 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  433 + var len = Math.max(idArr.length, nameArr.length)
  434 + var list = []
  435 + for (var i = 0; i < len; i++) {
  436 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  437 + }
  438 + this.attachmentList = list
  439 + },
  440 + onPreviewAttachment(at) {
  441 + if (!at || !at.id) {
  442 + uni.showToast({ title: '无法查看', icon: 'none' })
  443 + return
  444 + }
  445 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  446 + },
  447 + async loadSourceDetail() {
  448 + if (!this.id) return
  449 + try {
  450 + var res = await procurementPlanDetailApi({ id: this.id })
  451 + var d = (res && res.data) ? res.data : {}
  452 + var self = this
  453 + this.materialConditionConfigs.forEach(function (mc) {
  454 + var v = d[mc.field]
  455 + if (typeof v === 'string' && v) {
  456 + d[mc.field] = v.split(',').filter(Boolean)
  457 + } else if (!Array.isArray(v)) {
  458 + d[mc.field] = []
  459 + }
  460 + })
  461 + this.detail = d
  462 + this.lineList = Array.isArray(d.procurementPlanLineList) ? d.procurementPlanLineList.slice() : []
  463 + this.buildAttachmentList()
  464 + this.fillLineNames()
  465 + await this.fillPriceByDetailPriceId()
  466 + } catch (e) {
  467 + uni.showToast({ title: '加载详情失败', icon: 'none' })
  468 + }
  469 + },
  470 + async loadRefData() {
  471 + try {
  472 + var results = await Promise.all([
  473 + this.$pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  474 + this.$pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  475 + ])
  476 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  477 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  478 + this.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  479 + this.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  480 + this.fillLineNames()
  481 + } catch (e) {
  482 + this.productOptions = []
  483 + this.workshopOptions = []
  484 + }
  485 + },
  486 + $pCall(fn, params) {
  487 + try { return Promise.resolve(fn(params)) } catch (e) { return Promise.reject(e) }
  488 + },
  489 + onLineChange(list) {
  490 + this.lineList = Array.isArray(list) ? list.slice() : []
  491 + this.fillLineNames()
  492 + },
  493 + fillLineNames() {
  494 + if (!Array.isArray(this.lineList) || !this.lineList.length) return
  495 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  496 + var wOpts = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  497 + var self = this
  498 + this.lineList = this.lineList.map(function (row) {
  499 + var r = Object.assign({}, row)
  500 + var pid = r.productId != null ? String(r.productId) : ''
  501 + var wid = r.workshopId != null ? String(r.workshopId) : ''
  502 + if ((r.productName == null || String(r.productName).trim() === '') && pid) {
  503 + var p = pOpts.find(function (o) {
  504 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  505 + return id === pid
  506 + })
  507 + if (p) {
  508 + r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
  509 + }
  510 + }
  511 + if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) {
  512 + var w = wOpts.find(function (o) {
  513 + var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
  514 + return id === wid
  515 + })
  516 + if (w) {
  517 + r.workshopName = w.name != null ? w.name : (w.workshopName != null ? w.workshopName : (w.label != null ? w.label : ''))
  518 + }
  519 + }
  520 + return r
  521 + })
  522 + this.notifyLineChange()
  523 + },
  524 + notifyLineChange() {
  525 + try {
  526 + var pr = this.$refs.productRel
  527 + if (pr) {
  528 + if (typeof pr.initItems === 'function') {
  529 + pr._initialized = false
  530 + pr.initItems()
  531 + var self = this
  532 + this.$nextTick(function () {
  533 + pr._initialized = true
  534 + })
  535 + }
  536 + }
  537 + } catch (e) {
  538 + console.warn('notifyLineChange error:', e)
  539 + }
  540 + },
  541 + async fillPriceByDetailPriceId() {
  542 + var d = this.detail || {}
  543 + var priceId = d.priceId != null ? d.priceId : (d.priceTableId != null ? d.priceTableId : '')
  544 + if (!priceId) return
  545 + await this.fetchPriceDetailAndApply(priceId)
  546 + },
  547 + async fetchPriceDetailAndApply(priceId) {
  548 + if (!priceId) return
  549 + var self = this
  550 + try {
  551 + var res = await priceTableDetailApi({ id: priceId })
  552 + var d = (res && res.data) ? res.data : {}
  553 + var priceLines = self.extractPriceLines(d)
  554 + self.applyPriceLinesToLines(priceLines)
  555 + } catch (e) {
  556 + return
  557 + }
  558 + },
  559 + extractPriceLines(priceDetail) {
  560 + if (!priceDetail || typeof priceDetail !== 'object') return []
  561 + var candidates = [
  562 + priceDetail.procurementPriceLineList,
  563 + priceDetail.priceLineList,
  564 + priceDetail.priceList,
  565 + priceDetail.lineList,
  566 + priceDetail.datas,
  567 + priceDetail.records,
  568 + priceDetail.list
  569 + ]
  570 + for (var i = 0; i < candidates.length; i++) {
  571 + if (Array.isArray(candidates[i]) && candidates[i].length) return candidates[i]
  572 + }
  573 + for (var k in priceDetail) {
  574 + if (!Object.prototype.hasOwnProperty.call(priceDetail, k)) continue
  575 + if (Array.isArray(priceDetail[k])) {
  576 + var arr = priceDetail[k]
  577 + if (arr.length && arr[0] && typeof arr[0] === 'object' && (arr[0].price != null || arr[0].productId != null || arr[0].breedId != null || arr[0].varietyId != null)) {
  578 + return arr
  579 + }
  580 + }
  581 + }
  582 + return []
  583 + },
  584 + buildPriceMap(priceLines) {
  585 + var m = {}
  586 + if (!Array.isArray(priceLines)) return m
  587 + for (var i = 0; i < priceLines.length; i++) {
  588 + var line = priceLines[i] || {}
  589 + if (line.price == null) continue
  590 + var key = String(line.productId || line.breedId || line.varietyId || line.id || ('__idx_' + i))
  591 + m[key] = { price: Number(line.price), meta: line }
  592 + }
  593 + return m
  594 + },
  595 + applyPriceLinesToLines(priceLines) {
  596 + if (!Array.isArray(this.lineList)) return
  597 + var priceMap = this.buildPriceMap(priceLines)
  598 + var self = this
  599 + this.lineList = this.lineList.map(function (row) {
  600 + var pid = String(row.productId || row.breedId || row.varietyId || '')
  601 + var price = null
  602 + if (pid && priceMap[pid] != null) {
  603 + price = priceMap[pid].price
  604 + } else {
  605 + var pname = (row.productName || '').trim()
  606 + if (pname) {
  607 + for (var k in priceMap) {
  608 + if (!Object.prototype.hasOwnProperty.call(priceMap, k)) continue
  609 + var meta = priceMap[k] && priceMap[k].meta ? priceMap[k].meta : null
  610 + if (meta && ((meta.productName && meta.productName === pname) || (meta.breedName && meta.breedName === pname) || (meta.varietyName && meta.varietyName === pname))) {
  611 + price = priceMap[k].price
  612 + break
  613 + }
  614 + }
  615 + }
  616 + }
  617 + if (price != null) {
  618 + row.priceListPrices = self.toFixed(price, 2)
  619 + } else {
  620 + row.priceListPrices = ''
  621 + }
  622 + return row
  623 + })
  624 + this.fillLineNames()
  625 + },
  626 + joinStr(arr) {
  627 + if (Array.isArray(arr)) return arr.filter(Boolean).join(',')
  628 + if (typeof arr === 'string') return arr
  629 + return ''
  630 + },
  631 + toBool(v, fallback) {
  632 + if (typeof v === 'boolean') return v
  633 + if (v === 'true' || v === '1' || v === 1) return true
  634 + if (v === 'false' || v === '0' || v === 0) return false
  635 + return typeof fallback === 'boolean' ? fallback : false
  636 + },
  637 + pickId(v) {
  638 + if (v == null || v === '') return ''
  639 + if (typeof v === 'string' || typeof v === 'number') return String(v)
  640 + if (typeof v === 'object') {
  641 + return String(v.id != null ? v.id : (v.value != null ? v.value : (v.code != null ? v.code : '')))
  642 + }
  643 + return String(v)
  644 + },
  645 + buildPayload() {
  646 + var self = this
  647 + var d = this.detail || {}
  648 + var lines = Array.isArray(this.lineList) ? this.lineList.slice() : []
  649 + var lineList = lines.map(function (row, i) {
  650 + var r = row || {}
  651 + var itemId = r.itemId || (r._key != null ? r._key : (r.id ? String(r.id) : ('line-' + Date.now() + '-' + i)))
  652 + return {
  653 + id: r.id != null ? r.id : '',
  654 + itemId: itemId,
  655 + procurementPlanId: (r.procurementPlanId != null ? r.procurementPlanId : (self.id || d.id || '')),
  656 + productId: self.pickId(r.productId),
  657 + materialType: r.materialType != null ? String(r.materialType) : '',
  658 + quantity: self.toNumber(r.quantity),
  659 + actualPurchasePrice: self.toNumber(r.actualPurchasePrice),
  660 + includingShippingPrice: self.toNumber(r.includingShippingPrice),
  661 + priceListPrices: self.toNumber(r.priceListPrices),
  662 + coordinationRange: self.toNumber(r.coordinationRange),
  663 + estimatedLoss: self.toNumber(r.estimatedLoss),
  664 + applicationAttrition: self.toNumber(r.applicationAttrition),
  665 + workshopId: self.pickId(r.workshopId)
  666 + }
  667 + })
  668 + var mcFields = this.materialConditionConfigs.map(function (mc) { return mc.field })
  669 + var materialPayload = {}
  670 + mcFields.forEach(function (f) {
  671 + materialPayload[f] = self.joinStr(d[f])
  672 + })
  673 + var body = {
  674 + id: this.id || d.id || '',
  675 + code: d.code != null ? String(d.code) : '',
  676 + companyShortId: this.pickId(d.companyShortId || d.companyId),
  677 + supplierId: this.pickId(d.supplierId),
  678 + purchaseDepartment: this.pickId(d.purchaseDepartmentId || d.purchaseDepartment),
  679 + region: this.pickId(d.regionId || d.region),
  680 + date: d.date != null ? String(d.date) : '',
  681 + validityPeriod: d.validityPeriod != null ? String(d.validityPeriod) : '',
  682 + quoterId: this.pickId(d.quoterId),
  683 + quoterName: d.quoterName != null ? String(d.quoterName) : '',
  684 + longTermOperation: this.toBool(d.longTermOperation, false),
  685 + terminalCustomer: this.toBool(d.terminalCustomer, false),
  686 + priced: this.toBool(d.priced, false),
  687 + pricingDeadline: d.pricingDeadline != null ? String(d.pricingDeadline) : '',
  688 + temporaryPrice: this.toBool(d.temporaryPrice, false),
  689 + otherExpenseSettlement: this.toBool(d.otherExpenseSettlement, false),
  690 + deliveryMode: d.deliveryMode != null ? String(d.deliveryMode) : '',
  691 + commodityBuyout: this.toBool(d.commodityBuyout, false),
  692 + qualityBuyout: this.toBool(d.qualityBuyout, false),
  693 + quantityBuyout: this.toBool(d.quantityBuyout, false),
  694 + doorDelivery: this.toBool(d.doorDelivery, false),
  695 + shippingCost: this.toNumber(d.shippingCost),
  696 + loadingFee: this.toNumber(d.loadingFee),
  697 + invoiceProductName: d.invoiceProductName != null ? String(d.invoiceProductName) : '',
  698 + deliveryDate: d.deliveryDate != null ? String(d.deliveryDate) : '',
  699 + settlementMethod: d.settlementMethod != null ? String(d.settlementMethod) : '',
  700 + settlementRatio: this.toNumber(d.settlementRatio),
  701 + priceId: this.pickId(d.priceId || d.priceTableId),
  702 + coordinationReason: d.coordinationReason != null ? String(d.coordinationReason) : '',
  703 + invoiceTypeStatus: d.invoiceTypeStatus != null ? String(d.invoiceTypeStatus) : '',
  704 + remark: d.remark != null ? String(d.remark) : '',
  705 + materialConditionEnabled: this.toBool(d.materialConditionEnabled, false),
  706 + approvalStatus: d.approvalStatus != null ? String(d.approvalStatus) : '',
  707 + processStatus: d.processStatus != null ? String(d.processStatus) : '',
  708 + processNode: d.processNode != null ? String(d.processNode) : '',
  709 + procurementPlanLineList: lineList
  710 + }
  711 + Object.keys(materialPayload).forEach(function (k) {
  712 + body[k] = materialPayload[k]
  713 + })
  714 + return body
  715 + },
  716 + onBack() {
  717 + uni.navigateBack({ delta: 1 })
  718 + },
  719 + validateForm() {
  720 + var pr = this.$refs.productRel
  721 + if (pr && typeof pr.validate === 'function') {
  722 + var ok = pr.validate()
  723 + if (!ok) return false
  724 + }
  725 + return true
  726 + },
  727 + async onSubmit() {
  728 + if (!this.validateForm()) return
  729 + var payload = this.buildPayload()
  730 + try {
  731 + await procurementPlanUpdateApi(payload)
  732 + uni.showToast({ title: '保存成功', icon: 'none' })
  733 + try {
  734 + uni.setStorageSync('DOMESTIC_PLAN_LIST_NEED_REFRESH', '1')
  735 + uni.setStorageSync('SUPPLE_PLAN_LIST_NEED_REFRESH', '1')
  736 + } catch (e) {}
  737 + var self = this
  738 + setTimeout(function () {
  739 + uni.navigateBack({ delta: 1 })
  740 + }, 400)
  741 + } catch (e) {
  742 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : '保存失败', icon: 'none' })
  743 + }
  744 + }
  745 + }
  746 +}
  747 +</script>
  748 +
  749 +<style lang="scss" scoped>
  750 +.page {
  751 + display: flex;
  752 + flex-direction: column;
  753 + height: 100%;
  754 +}
  755 +.scroll {
  756 + flex: 1;
  757 + padding: 12rpx 0 392rpx !important;
  758 +}
  759 +.bottom-bar {
  760 + z-index: 2;
  761 + position: fixed;
  762 + left: 0;
  763 + right: 0;
  764 + bottom: 0;
  765 + padding: 32rpx;
  766 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  767 + background: #fff;
  768 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  769 + display: flex;
  770 + gap: 24rpx;
  771 + .btn {
  772 + flex: 1;
  773 + height: 80rpx;
  774 + line-height: 80rpx;
  775 + border-radius: 12rpx;
  776 + font-size: 32rpx;
  777 + }
  778 + .btn-outline {
  779 + background: #fff;
  780 + color: $theme-primary;
  781 + border: 2rpx solid $theme-primary;
  782 + }
  783 + .btn-primary {
  784 + background: $theme-primary;
  785 + color: #fff;
  786 + border: 2rpx solid $theme-primary;
  787 + }
  788 +}
  789 +
  790 +::v-deep .uni-list {
  791 + .uni-easyinput {
  792 + display: flex;
  793 + .uni-input-input {
  794 + color: rgba(0, 0, 0, 0.9);
  795 + }
  796 + }
  797 + .uni-input-placeholder { z-index: 1; }
  798 + .uni-input-input { background-color: #ffffff; }
  799 + background: transparent;
  800 + &-item {
  801 + &__extra-text { font-size: 32rpx; }
  802 + &__content-title {
  803 + font-size: 32rpx;
  804 + color: rgba(0, 0, 0, 0.9);
  805 + }
  806 + &__container {
  807 + padding: 32rpx;
  808 + .uni-easyinput {
  809 + &__placeholder-class {
  810 + font-size: 32rpx;
  811 + color: rgba(0, 0, 0, 0.4);
  812 + }
  813 + &__content {
  814 + border: none;
  815 + background-color: #ffffff !important;
  816 + &-input {
  817 + padding-left: 0 !important;
  818 + height: 48rpx;
  819 + line-height: 48rpx;
  820 + font-size: 32rpx;
  821 + }
  822 + .content-clear-icon {
  823 + font-size: 44rpx !important;
  824 + }
  825 + }
  826 + }
  827 + .item-title,
  828 + .uni-list-item__content {
  829 + flex: none;
  830 + min-height: 48rpx;
  831 + line-height: 48rpx;
  832 + font-size: 32rpx;
  833 + position: relative;
  834 + width: 240rpx;
  835 + margin-right: 32rpx;
  836 + color: rgba(0, 0, 0, 0.9);
  837 + .required {
  838 + color: red;
  839 + position: absolute;
  840 + top: 50%;
  841 + transform: translateY(-50%);
  842 + left: -16rpx;
  843 + }
  844 + }
  845 + }
  846 + &.select-item {
  847 + &.is-empty {
  848 + .uni-list-item__extra-text {
  849 + color: rgba(0, 0, 0, 0.4) !important;
  850 + }
  851 + }
  852 + &.is-filled {
  853 + .uni-list-item__extra-text {
  854 + color: rgba(0, 0, 0, 0.9) !important;
  855 + }
  856 + }
  857 + .serial-number-row {
  858 + display: flex;
  859 + align-items: center;
  860 + }
  861 + }
  862 + }
  863 +}
  864 +
  865 +.readonly-text {
  866 + color: rgba(0, 0, 0, 0.9);
  867 + font-size: 32rpx;
  868 + line-height: 48rpx;
  869 + text-align: right;
  870 + white-space: pre-wrap;
  871 + word-break: break-all;
  872 +}
  873 +.value-code {
  874 + width: 260rpx;
  875 + text-align: left;
  876 +}
  877 +
  878 +.attach-list {
  879 + flex: 1;
  880 + display: flex;
  881 + flex-direction: column;
  882 + align-items: flex-end;
  883 + gap: 8rpx;
  884 +}
  885 +.attach-item {
  886 + display: flex;
  887 + align-items: center;
  888 + gap: 16rpx;
  889 + .attach-name { font-size: 26rpx; color: rgba(0,0,0,0.9); }
  890 + .attach-view { font-size: 26rpx; color: $theme-primary; }
  891 +}
  892 +
  893 +.material-condition-section,
  894 +.remark-section {
  895 + margin-top: 20rpx;
  896 + background: #fff;
  897 +}
  898 +.section-header {
  899 + display: flex;
  900 + align-items: center;
  901 + padding: 24rpx 32rpx;
  902 + border-bottom: 1rpx solid #f0f0f0;
  903 +}
  904 +.section-title {
  905 + font-size: 32rpx;
  906 + color: rgba(0, 0, 0, 0.9);
  907 + font-weight: 600;
  908 +}
  909 +.opCollapse {
  910 + width: 32rpx;
  911 + height: 28rpx;
  912 + margin-right: 16rpx;
  913 + margin-top: 8rpx;
  914 +}
  915 +.section-content {
  916 + padding: 32rpx;
  917 +}
  918 +.form-row {
  919 + display: flex;
  920 + align-items: center;
  921 + justify-content: space-between;
  922 + margin-bottom: 24rpx;
  923 +}
  924 +.form-row:last-child { margin-bottom: 0; }
  925 +.form-label {
  926 + font-size: 32rpx;
  927 + color: rgba(0, 0, 0, 0.9);
  928 +}
  929 +.form-value {
  930 + font-size: 32rpx;
  931 + color: rgba(0, 0, 0, 0.9);
  932 +}
  933 +.material-group {
  934 + margin-top: 32rpx;
  935 +}
  936 +.material-label {
  937 + display: block;
  938 + font-size: 30rpx;
  939 + color: rgba(0, 0, 0, 0.9);
  940 + margin-bottom: 20rpx;
  941 +}
  942 +.tag-list {
  943 + display: flex;
  944 + flex-wrap: wrap;
  945 + gap: 16rpx;
  946 +}
  947 +.tag-btn {
  948 + padding: 12rpx 24rpx;
  949 + border: 1rpx solid #ddd;
  950 + border-radius: 8rpx;
  951 + font-size: 28rpx;
  952 + color: #666;
  953 + background: #fff;
  954 +}
  955 +.tag-btn.active {
  956 + background: $theme-primary;
  957 + border-color: $theme-primary;
  958 + color: #fff;
  959 +}
  960 +.remark-text {
  961 + font-size: 30rpx;
  962 + color: rgba(0,0,0,0.9);
  963 + line-height: 1.6;
  964 + white-space: pre-wrap;
  965 +}
  966 +.footer-tip {
  967 + padding: 24rpx 32rpx;
  968 + color: rgba(0,0,0,0.45);
  969 + font-size: 24rpx;
  970 +}
  971 +
  972 +::v-deep .uni-easyinput {
  973 + width: 100%;
  974 + &__content {
  975 + background: #f8f8f8 !important;
  976 + border-radius: 8rpx;
  977 + &-input { font-size: 30rpx; }
  978 + }
  979 +}
  980 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view scroll-y class="scroll">
  4 + <uni-list>
  5 + <uni-list-item class="select-item" :class="detail.code ? 'is-filled' : 'is-empty'">
  6 + <template v-slot:body>
  7 + <view class="item-title"><text>编号</text></view>
  8 + </template>
  9 + <template v-slot:footer>
  10 + <view class="serial-number-row">
  11 + <text class="readonly-text value-code">{{ safeText(detail.code) }}</text>
  12 + </view>
  13 + </template>
  14 + </uni-list-item>
  15 +
  16 + <uni-list-item class="select-item" :class="form.companyId ? 'is-filled' : 'is-empty'" clickable
  17 + @click="openCompanySheet" :rightText="form.companyName || '请选择公司名称'" showArrow>
  18 + <template v-slot:body>
  19 + <view class="item-title"><text class="required">*</text><text>公司名称</text></view>
  20 + </template>
  21 + </uni-list-item>
  22 +
  23 + <uni-list-item title="供应商名称">
  24 + <template v-slot:footer>
  25 + <uni-easyinput v-model="detail.supplierName" :inputBorder="false" disabled placeholder="-" />
  26 + </template>
  27 + </uni-list-item>
  28 +
  29 + <uni-list-item title="采购处">
  30 + <template v-slot:footer>
  31 + <uni-easyinput v-model="purchaseDepartmentDisplay" :inputBorder="false" disabled placeholder="-" />
  32 + </template>
  33 + </uni-list-item>
  34 +
  35 + <uni-list-item title="区域">
  36 + <template v-slot:footer>
  37 + <uni-easyinput v-model="regionDisplay" :inputBorder="false" disabled placeholder="-" />
  38 + </template>
  39 + </uni-list-item>
  40 +
  41 + <uni-list-item>
  42 + <template v-slot:body>
  43 + <view class="item-title"><text class="required">*</text><text>日期</text></view>
  44 + </template>
  45 + <template v-slot:footer>
  46 + <uni-datetime-picker type="date" v-model="form.date" return-type="string" />
  47 + </template>
  48 + </uni-list-item>
  49 +
  50 + <uni-list-item title="报价时效">
  51 + <template v-slot:footer>
  52 + <uni-easyinput v-model="detail.validityPeriod" :inputBorder="false" disabled placeholder="-" />
  53 + </template>
  54 + </uni-list-item>
  55 +
  56 + <uni-list-item title="报价人">
  57 + <template v-slot:footer>
  58 + <uni-easyinput v-model="detail.quoterName" :inputBorder="false" disabled placeholder="-" />
  59 + </template>
  60 + </uni-list-item>
  61 +
  62 + <uni-list-item class="select-item" :class="typeof detail.longTermOperation === 'boolean' ? 'is-filled' : 'is-empty'">
  63 + <template v-slot:body>
  64 + <view class="item-title"><text>是否长单操作</text></view>
  65 + </template>
  66 + <template v-slot:footer>
  67 + <text class="readonly-text">{{ boolText(detail.longTermOperation) }}</text>
  68 + </template>
  69 + </uni-list-item>
  70 +
  71 + <uni-list-item class="select-item" :class="typeof detail.terminalCustomer === 'boolean' ? 'is-filled' : 'is-empty'">
  72 + <template v-slot:body>
  73 + <view class="item-title"><text>是否终端客户</text></view>
  74 + </template>
  75 + <template v-slot:footer>
  76 + <text class="readonly-text">{{ boolText(detail.terminalCustomer) }}</text>
  77 + </template>
  78 + </uni-list-item>
  79 +
  80 + <uni-list-item class="select-item" :class="typeof detail.priced === 'boolean' ? 'is-filled' : 'is-empty'">
  81 + <template v-slot:body>
  82 + <view class="item-title"><text>是否未点价</text></view>
  83 + </template>
  84 + <template v-slot:footer>
  85 + <text class="readonly-text">{{ boolText(detail.priced) }}</text>
  86 + </template>
  87 + </uni-list-item>
  88 +
  89 + <uni-list-item v-if="detail.priced === true" title="点价截止日期">
  90 + <template v-slot:footer>
  91 + <uni-easyinput v-model="pricingDeadlineDisplay" :inputBorder="false" disabled placeholder="-" />
  92 + </template>
  93 + </uni-list-item>
  94 +
  95 + <uni-list-item v-if="detail.priced === true" class="select-item" :class="typeof detail.temporaryPrice === 'boolean' ? 'is-filled' : 'is-empty'">
  96 + <template v-slot:body>
  97 + <view class="item-title"><text>是否暂定价</text></view>
  98 + </template>
  99 + <template v-slot:footer>
  100 + <text class="readonly-text">{{ boolText(detail.temporaryPrice) }}</text>
  101 + </template>
  102 + </uni-list-item>
  103 +
  104 + <uni-list-item class="select-item" :class="typeof detail.otherExpenseSettlement === 'boolean' ? 'is-filled' : 'is-empty'">
  105 + <template v-slot:body>
  106 + <view class="item-title"><text>其他费用凭票到厂另行结算</text></view>
  107 + </template>
  108 + <template v-slot:footer>
  109 + <text class="readonly-text">{{ boolText(detail.otherExpenseSettlement) }}</text>
  110 + </template>
  111 + </uni-list-item>
  112 +
  113 + <uni-list-item class="select-item" :class="detail.deliveryMode ? 'is-filled' : 'is-empty'">
  114 + <template v-slot:body>
  115 + <view class="item-title"><text>交提货方式</text></view>
  116 + </template>
  117 + <template v-slot:footer>
  118 + <text class="readonly-text">{{ getDeliveryMethodLabel() }}</text>
  119 + </template>
  120 + </uni-list-item>
  121 +
  122 + <uni-list-item class="select-item" :class="typeof detail.commodityBuyout === 'boolean' ? 'is-filled' : 'is-empty'">
  123 + <template v-slot:body>
  124 + <view class="item-title"><text>是否通货买断</text></view>
  125 + </template>
  126 + <template v-slot:footer>
  127 + <text class="readonly-text">{{ boolText(detail.commodityBuyout) }}</text>
  128 + </template>
  129 + </uni-list-item>
  130 +
  131 + <uni-list-item class="select-item" :class="typeof detail.qualityBuyout === 'boolean' ? 'is-filled' : 'is-empty'">
  132 + <template v-slot:body>
  133 + <view class="item-title"><text>是否质量买断</text></view>
  134 + </template>
  135 + <template v-slot:footer>
  136 + <text class="readonly-text">{{ boolText(detail.qualityBuyout) }}</text>
  137 + </template>
  138 + </uni-list-item>
  139 +
  140 + <uni-list-item class="select-item" :class="typeof detail.quantityBuyout === 'boolean' ? 'is-filled' : 'is-empty'">
  141 + <template v-slot:body>
  142 + <view class="item-title"><text>是否数量买断</text></view>
  143 + </template>
  144 + <template v-slot:footer>
  145 + <text class="readonly-text">{{ boolText(detail.quantityBuyout) }}</text>
  146 + </template>
  147 + </uni-list-item>
  148 +
  149 + <uni-list-item class="select-item" :class="typeof detail.doorDelivery === 'boolean' ? 'is-filled' : 'is-empty'">
  150 + <template v-slot:body>
  151 + <view class="item-title"><text>是否送货上门</text></view>
  152 + </template>
  153 + <template v-slot:footer>
  154 + <text class="readonly-text">{{ boolText(detail.doorDelivery) }}</text>
  155 + </template>
  156 + </uni-list-item>
  157 +
  158 + <uni-list-item title="另付运费">
  159 + <template v-slot:footer>
  160 + <uni-easyinput
  161 + v-model="form.shippingCost"
  162 + type="digit"
  163 + :inputBorder="false"
  164 + placeholder="请输入另付运费"
  165 + @input="onShippingCostInput"
  166 + @blur="onShippingCostBlur"
  167 + />
  168 + </template>
  169 + </uni-list-item>
  170 +
  171 + <uni-list-item title="装车费">
  172 + <template v-slot:footer>
  173 + <uni-easyinput v-model="loadingFeeDisplay" :inputBorder="false" disabled placeholder="-" />
  174 + </template>
  175 + </uni-list-item>
  176 +
  177 + <uni-list-item title="开票品名">
  178 + <template v-slot:footer>
  179 + <uni-easyinput v-model="detail.invoiceProductName" :inputBorder="false" disabled placeholder="-" />
  180 + </template>
  181 + </uni-list-item>
  182 +
  183 + <uni-list-item title="交货日期">
  184 + <template v-slot:footer>
  185 + <uni-easyinput v-model="deliveryDateDisplay" :inputBorder="false" disabled placeholder="-" />
  186 + </template>
  187 + </uni-list-item>
  188 +
  189 + <uni-list-item title="结算方式">
  190 + <template v-slot:footer>
  191 + <uni-easyinput v-model="detail.settlementMethod" :inputBorder="false" disabled placeholder="-" />
  192 + </template>
  193 + </uni-list-item>
  194 +
  195 + <uni-list-item title="结算比例(%)">
  196 + <template v-slot:footer>
  197 + <uni-easyinput v-model="settlementRatioDisplay" :inputBorder="false" disabled placeholder="-" />
  198 + </template>
  199 + </uni-list-item>
  200 +
  201 + <uni-list-item class="select-item" :class="form.priceTableId || form.priceTableCode ? 'is-filled' : 'is-empty'" clickable
  202 + @click="openPriceTableSheet" :rightText="form.priceTableCodeLabel || '请选择价格表编号'" showArrow>
  203 + <template v-slot:body>
  204 + <view class="item-title"><text class="required">*</text><text>价格表编号</text></view>
  205 + </template>
  206 + </uni-list-item>
  207 +
  208 + <uni-list-item title="协调事由">
  209 + <template v-slot:footer>
  210 + <uni-easyinput v-model="detail.coordinationReason" :inputBorder="false" disabled placeholder="-" />
  211 + </template>
  212 + </uni-list-item>
  213 +
  214 + <uni-list-item title="票类状况">
  215 + <template v-slot:footer>
  216 + <uni-easyinput v-model="detail.invoiceTypeStatus" :inputBorder="false" disabled placeholder="-" />
  217 + </template>
  218 + </uni-list-item>
  219 +
  220 + <uni-list-item v-if="attachmentList.length" title="附件">
  221 + <template v-slot:footer>
  222 + <view class="attach-list">
  223 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  224 + <text class="attach-name">{{ at.name }}</text>
  225 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  226 + </view>
  227 + </view>
  228 + </template>
  229 + </uni-list-item>
  230 +
  231 + <ProductRel
  232 + ref="productRel"
  233 + mode="edit"
  234 + :scene="supplementScene"
  235 + :list="lineList"
  236 + :product-options="productOptions"
  237 + :workshop-options="workshopOptions"
  238 + @change="onLineChange"
  239 + />
  240 + </uni-list>
  241 +
  242 + <view class="material-condition-section">
  243 + <view class="section-header">
  244 + <image class="opCollapse" src="/static/images/title.png" />
  245 + <text class="section-title">料质状况</text>
  246 + </view>
  247 + <view class="section-content">
  248 + <view class="form-row">
  249 + <text class="form-label">是否启用料质状况</text>
  250 + <text class="form-value">{{ boolText(detail.materialConditionEnabled) }}</text>
  251 + </view>
  252 + <template v-if="detail.materialConditionEnabled">
  253 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  254 + <text class="material-label">{{ mc.label }}</text>
  255 + <view class="tag-list">
  256 + <view
  257 + v-for="opt in getDictOptions(mc.dictCode)"
  258 + :key="opt.code"
  259 + class="tag-btn"
  260 + :class="{ active: isTagSelected(mc.field, opt.code) }"
  261 + >
  262 + {{ opt.name }}
  263 + </view>
  264 + </view>
  265 + </view>
  266 + </template>
  267 + </view>
  268 + </view>
  269 +
  270 + <view class="remark-section">
  271 + <view class="section-header">
  272 + <image class="opCollapse" src="/static/images/title.png" />
  273 + <text class="section-title">备注</text>
  274 + </view>
  275 + <view class="section-content">
  276 + <text class="remark-text">{{ safeText(detail.remark) }}</text>
  277 + </view>
  278 + </view>
  279 +
  280 + <view class="footer-tip">提示:含运到厂价 = 实际采购价 + 另付运费;协调幅度 = 含运到厂价 + 买断料预计损耗 - 价格表价格</view>
  281 + </scroll-view>
  282 +
  283 + <view class="bottom-bar">
  284 + <button class="btn btn-outline" @click="onBack">取消</button>
  285 + <button class="btn btn-primary" @click="onSubmit">保存</button>
  286 + </view>
  287 +
  288 + <RelateSelectSheet
  289 + v-if="companySheetVisible"
  290 + :visible.sync="companySheetVisible"
  291 + title="选择公司"
  292 + :fetch-fn="fetchCompanyList"
  293 + :display-fields="companyDisplayFields"
  294 + :page-size="20"
  295 + :multiple="false"
  296 + row-key="id"
  297 + @confirm="onCompanyConfirm"
  298 + />
  299 + <RelateSelectSheet
  300 + v-if="priceSheetVisible"
  301 + :visible.sync="priceSheetVisible"
  302 + title="选择价格表"
  303 + :fetch-fn="fetchPriceTableList"
  304 + :display-fields="priceTableDisplayFields"
  305 + :page-size="20"
  306 + :multiple="false"
  307 + row-key="id"
  308 + @confirm="onPriceTableConfirm"
  309 + />
  310 + </view>
  311 +</template>
  312 +
  313 +<script>
  314 +import ProductRel from './productRel.vue'
  315 +import RelateSelectSheet from '@/components/relate-select/index.vue'
  316 +import { procurementPlanDetailApi, procurementPlanUpdateApi } from '@/api/procure-manage/procurementPlan.js'
  317 +import {
  318 + companyShortQueryApi,
  319 + priceTableQueryApi,
  320 + priceTableDetailApi,
  321 + breedRelationshipQueryApi,
  322 + workshopQueryApi
  323 +} from '@/api/devManage.js'
  324 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  325 +
  326 +export default {
  327 + name: 'DomesticPlanSupplement',
  328 + components: { ProductRel, RelateSelectSheet },
  329 + data() {
  330 + return {
  331 + supplementScene: 'supplement',
  332 + id: '',
  333 + detail: {},
  334 + attachmentList: [],
  335 + materialConditionConfigs: [
  336 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  337 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  338 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  339 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  340 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  341 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  342 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  343 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  344 + ],
  345 + dicOptions: {
  346 + AUDIT_STATUS: [],
  347 + PROCESS_STATUS: [],
  348 + DELIVERY_METHOD: []
  349 + },
  350 + dictData: {},
  351 + form: {
  352 + id: '',
  353 + companyId: '',
  354 + companyName: '',
  355 + date: '',
  356 + shippingCost: '',
  357 + priceTableId: '',
  358 + priceTableCode: '',
  359 + priceTableCodeLabel: ''
  360 + },
  361 + lineList: [],
  362 + productOptions: [],
  363 + workshopOptions: [],
  364 + priceTableList: [],
  365 + companySheetVisible: false,
  366 + priceSheetVisible: false,
  367 + companyDisplayFields: [
  368 + { label: '公司简称', field: 'shortName' },
  369 + { label: '公司名称', field: 'companyName' },
  370 + { label: '办事处', field: 'deptName' }
  371 + ],
  372 + priceTableDisplayFields: [
  373 + { label: '价格表编号', field: 'code' },
  374 + { label: '创建人', field: 'createBy' },
  375 + ]
  376 + }
  377 + },
  378 + computed: {
  379 + shippingCostNumber() {
  380 + var v = this.form.shippingCost
  381 + if (v == null || v === '') return 0
  382 + var n = Number(v)
  383 + return isNaN(n) ? 0 : n
  384 + },
  385 + purchaseDepartmentDisplay() {
  386 + var d = this.detail || {}
  387 + return d.purchaseDepartmentName != null ? d.purchaseDepartmentName : (d.purchaseDepartment != null ? d.purchaseDepartment : '')
  388 + },
  389 + regionDisplay() {
  390 + var d = this.detail || {}
  391 + return d.regionName != null ? d.regionName : (d.region != null ? d.region : '')
  392 + },
  393 + pricingDeadlineDisplay() {
  394 + var d = this.detail || {}
  395 + var s = d.pricingDeadline == null ? '' : String(d.pricingDeadline).trim()
  396 + if (!s) return ''
  397 + if (s.length >= 10) return s.slice(0, 10)
  398 + return s
  399 + },
  400 + deliveryDateDisplay() {
  401 + var d = this.detail || {}
  402 + var s = d.deliveryDate == null ? '' : String(d.deliveryDate).trim()
  403 + if (!s) return ''
  404 + if (s.length >= 10) return s.slice(0, 10)
  405 + return s
  406 + },
  407 + loadingFeeDisplay() {
  408 + var v = (this.detail || {}).loadingFee
  409 + if (v == null || v === '') return ''
  410 + var n = Number(v)
  411 + if (isNaN(n)) return String(v)
  412 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  413 + },
  414 + settlementRatioDisplay() {
  415 + var v = (this.detail || {}).settlementRatio
  416 + if (v == null || v === '') return ''
  417 + var n = Number(v)
  418 + if (isNaN(n)) return String(v)
  419 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  420 + }
  421 + },
  422 + onLoad(query) {
  423 + this.id = (query && query.id) ? query.id : ''
  424 + this.loadDictData()
  425 + this.loadRefData()
  426 + if (this.id) {
  427 + this.loadSourceDetail()
  428 + }
  429 + },
  430 + methods: {
  431 + toNumber(v) {
  432 + if (v == null || v === '') return 0
  433 + var n = Number(v)
  434 + return isNaN(n) ? 0 : n
  435 + },
  436 + toFixed(v, n) {
  437 + var num = Number(v)
  438 + if (isNaN(num)) return ''
  439 + return num.toFixed(n)
  440 + },
  441 + safeText(v) {
  442 + var s = v == null ? '' : String(v)
  443 + return s.trim() ? s : '-'
  444 + },
  445 + boolText(v) {
  446 + if (typeof v !== 'boolean') return '-'
  447 + return v ? '是' : '否'
  448 + },
  449 + async loadDictData() {
  450 + var codes = [].concat(
  451 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  452 + ['DELIVERY_METHOD', 'AUDIT_STATUS', 'PROCESS_STATUS']
  453 + )
  454 + try {
  455 + var results = await getDicByCodes(codes)
  456 + var d = results || {}
  457 + this.dictData = d
  458 + this.dicOptions.AUDIT_STATUS = (d.AUDIT_STATUS && d.AUDIT_STATUS.data) || []
  459 + this.dicOptions.PROCESS_STATUS = (d.PROCESS_STATUS && d.PROCESS_STATUS.data) || []
  460 + this.dicOptions.DELIVERY_METHOD = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  461 + } catch (e) {
  462 + this.dictData = {}
  463 + }
  464 + },
  465 + getDictOptions(dictCode) {
  466 + var data = this.dictData[dictCode]
  467 + return (data && data.data) ? data.data : []
  468 + },
  469 + isTagSelected(field, code) {
  470 + var selected = this.detail ? this.detail[field] : undefined
  471 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  472 + if (typeof selected === 'string' && selected) {
  473 + return selected.split(',').indexOf(code) >= 0
  474 + }
  475 + return false
  476 + },
  477 + getDeliveryMethodLabel() {
  478 + var opts = this.getDictOptions('DELIVERY_METHOD') || []
  479 + var v = String(this.detail.deliveryMode != null ? this.detail.deliveryMode : '')
  480 + if (!v) return '-'
  481 + for (var i = 0; i < opts.length; i++) {
  482 + var o = opts[i]
  483 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  484 + if (code === v) return o.name || o.label || '-'
  485 + }
  486 + return v
  487 + },
  488 + buildAttachmentList() {
  489 + var ids = this.detail.attachmentFileIds
  490 + var names = this.detail.attachmentFileNames
  491 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  492 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  493 + var len = Math.max(idArr.length, nameArr.length)
  494 + var list = []
  495 + for (var i = 0; i < len; i++) {
  496 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  497 + }
  498 + this.attachmentList = list
  499 + },
  500 + onPreviewAttachment(at) {
  501 + if (!at || !at.id) {
  502 + uni.showToast({ title: '无法查看', icon: 'none' })
  503 + return
  504 + }
  505 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  506 + },
  507 + async loadSourceDetail() {
  508 + if (!this.id) return
  509 + try {
  510 + var res = await procurementPlanDetailApi({ id: this.id })
  511 + var d = (res && res.data) ? res.data : {}
  512 + var self = this
  513 + this.materialConditionConfigs.forEach(function (mc) {
  514 + var v = d[mc.field]
  515 + if (typeof v === 'string' && v) {
  516 + d[mc.field] = v.split(',').filter(Boolean)
  517 + } else if (!Array.isArray(v)) {
  518 + d[mc.field] = []
  519 + }
  520 + })
  521 + this.detail = d
  522 + var date = ''
  523 + if (d.date) {
  524 + var s = String(d.date)
  525 + date = s.length >= 10 ? s.slice(0, 10) : s
  526 + }
  527 + this.form.id = d.id || ''
  528 + this.form.companyId = d.companyId || ''
  529 + this.form.companyName = d.companyShortName || d.companyName || ''
  530 + this.form.date = date
  531 + var sc = d.shippingCost
  532 + if (sc != null && sc !== '') {
  533 + this.form.shippingCost = this.toFixed(sc, 2)
  534 + }
  535 + this.lineList = Array.isArray(d.procurementPlanLineList) ? d.procurementPlanLineList.slice() : []
  536 + this.buildAttachmentList()
  537 + this.fillLineNames()
  538 + this.refreshLinesFromShipping()
  539 + this.loadLatestPriceTableAndApply()
  540 + } catch (e) {
  541 + uni.showToast({ title: '加载报价单失败', icon: 'none' })
  542 + }
  543 + },
  544 + async loadRefData() {
  545 + try {
  546 + var results = await Promise.all([
  547 + this.$pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  548 + this.$pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  549 + ])
  550 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  551 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  552 + this.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  553 + this.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  554 + this.fillLineNames()
  555 + } catch (e) {
  556 + this.productOptions = []
  557 + this.workshopOptions = []
  558 + }
  559 + },
  560 + $pCall(fn, params) {
  561 + try { return Promise.resolve(fn(params)) } catch (e) { return Promise.reject(e) }
  562 + },
  563 + fetchCompanyList(args) {
  564 + var extra = (args && args.extra) ? args.extra : {}
  565 + var keyword = extra.keyword || extra.name || ''
  566 + var params = { pageIndex: args.pageIndex || 1, pageSize: args.pageSize || 20 }
  567 + if (keyword) params.name = keyword
  568 + var self = this
  569 + return companyShortQueryApi(params).then(function (res) {
  570 + var d = (res && res.data) ? res.data : {}
  571 + var records = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.records && Array.isArray(d.records)) ? d.records : ((d.list && Array.isArray(d.list)) ? d.list : []))
  572 + var total = d.totalCount || d.count || (records ? records.length : 0)
  573 + var hasNext = !!d.hasNext
  574 + return { records: records, totalCount: total, hasNext: hasNext }
  575 + }).catch(function () {
  576 + return { records: [], totalCount: 0, hasNext: false }
  577 + })
  578 + },
  579 + fetchPriceTableList(args) {
  580 + var extra = (args && args.extra) ? args.extra : {}
  581 + var keyword = extra.keyword || extra.name || ''
  582 + var params = { pageIndex: args.pageIndex || 1, pageSize: args.pageSize || 20 }
  583 + if (keyword) params.name = keyword
  584 + var self = this
  585 + return priceTableQueryApi(params).then(function (res) {
  586 + var d = (res && res.data) ? res.data : {}
  587 + var records = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.records && Array.isArray(d.records)) ? d.records : ((d.list && Array.isArray(d.list)) ? d.list : []))
  588 + var total = d.totalCount || d.count || (records ? records.length : 0)
  589 + var hasNext = !!d.hasNext
  590 + return { records: records, totalCount: total, hasNext: hasNext }
  591 + }).catch(function () {
  592 + return { records: [], totalCount: 0, hasNext: false }
  593 + })
  594 + },
  595 + openCompanySheet() {
  596 + this.companySheetVisible = true
  597 + },
  598 + openPriceTableSheet() {
  599 + this.priceSheetVisible = true
  600 + },
  601 + onCompanyConfirm(e) {
  602 + var items = (e && e.items) ? e.items : []
  603 + if (!items.length) return
  604 + var row = items[0] || {}
  605 + this.form.companyId = row.id || ''
  606 + this.form.companyName = row.companyShortName || row.companyName || row.name || ''
  607 + },
  608 + onPriceTableConfirm(e) {
  609 + var items = (e && e.items) ? e.items : []
  610 + if (!items.length) return
  611 + var row = items[0] || {}
  612 + this.selectPriceTableRow(row)
  613 + },
  614 + selectPriceTableRow(row) {
  615 + this.form.priceTableId = row.id || ''
  616 + this.form.priceTableCode = row.priceTableCode || row.code || ''
  617 + var code = row.priceTableCode || row.code || ''
  618 + var name = row.priceTableName || row.name || ''
  619 + this.form.priceTableCodeLabel = name ? (name + (code ? ' (' + code + ')' : '')) : code
  620 + if (this.form.priceTableId) {
  621 + this.fetchPriceDetailAndApply(this.form.priceTableId)
  622 + }
  623 + },
  624 + async loadLatestPriceTableAndApply() {
  625 + var self = this
  626 + try {
  627 + var res = await priceTableQueryApi({ pageIndex: 1, pageSize: 1, orderByColumn: 'createTime desc,id desc' })
  628 + var d = (res && res.data) ? res.data : {}
  629 + var list = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.records && Array.isArray(d.records)) ? d.records : ((d.list && Array.isArray(d.list)) ? d.list : []))
  630 + if (!list || !list.length) return
  631 + var row = list[0]
  632 + self.selectPriceTableRow(row)
  633 + } catch (e) {
  634 + return
  635 + }
  636 + },
  637 + async fetchPriceDetailAndApply(priceId) {
  638 + if (!priceId) return
  639 + var self = this
  640 + try {
  641 + var res = await priceTableDetailApi({ id: priceId })
  642 + var d = (res && res.data) ? res.data : {}
  643 + var priceLines = self.extractPriceLines(d)
  644 + console.log(priceLines,d,'6666')
  645 + self.applyPriceLinesToLines(priceLines)
  646 + } catch (e) {
  647 + return
  648 + }
  649 + },
  650 + extractPriceLines(priceDetail) {
  651 + if (!priceDetail || typeof priceDetail !== 'object') return []
  652 + var candidates = [
  653 + priceDetail.procurementPriceLineList,
  654 + priceDetail.priceLineList,
  655 + priceDetail.priceList,
  656 + priceDetail.lineList,
  657 + priceDetail.datas,
  658 + priceDetail.records,
  659 + priceDetail.list
  660 + ]
  661 + for (var i = 0; i < candidates.length; i++) {
  662 + if (Array.isArray(candidates[i]) && candidates[i].length) return candidates[i]
  663 + }
  664 + for (var k in priceDetail) {
  665 + if (!Object.prototype.hasOwnProperty.call(priceDetail, k)) continue
  666 + if (Array.isArray(priceDetail[k])) {
  667 + var arr = priceDetail[k]
  668 + if (arr.length && arr[0] && typeof arr[0] === 'object' && (arr[0].price != null || arr[0].productId != null || arr[0].breedId != null || arr[0].varietyId != null)) {
  669 + return arr
  670 + }
  671 + }
  672 + }
  673 + return []
  674 + },
  675 + applyPriceLinesToLines(priceLines) {
  676 + if (!Array.isArray(this.lineList)) return
  677 + var priceMap = this.buildPriceMap(priceLines)
  678 + var self = this
  679 + this.lineList = this.lineList.map(function (row) {
  680 + var pid = String(row.productId || row.breedId || row.varietyId || '')
  681 + var price = null
  682 + if (pid && priceMap[pid] != null) {
  683 + price = priceMap[pid].price
  684 + } else {
  685 + var pname = (row.productName || '').trim()
  686 + if (pname) {
  687 + for (var k in priceMap) {
  688 + if (!Object.prototype.hasOwnProperty.call(priceMap, k)) continue
  689 + var meta = priceMap[k] && priceMap[k].meta ? priceMap[k].meta : null
  690 + if (meta && ((meta.productName && meta.productName === pname) || (meta.breedName && meta.breedName === pname) || (meta.varietyName && meta.varietyName === pname))) {
  691 + price = priceMap[k].price
  692 + break
  693 + }
  694 + }
  695 + }
  696 + }
  697 + if (price != null) {
  698 + row.priceListPrices = self.toFixed(price, 2)
  699 + } else {
  700 + row.priceListPrices = ''
  701 + }
  702 + return row
  703 + })
  704 + this.refreshLinesFromShipping()
  705 + this.notifyLineChange()
  706 + },
  707 + buildPriceMap(priceLines) {
  708 + var m = {}
  709 + if (!Array.isArray(priceLines)) return m
  710 + for (var i = 0; i < priceLines.length; i++) {
  711 + var line = priceLines[i] || {}
  712 + if (line.price == null) continue
  713 + var key = String(line.productId || line.breedId || line.varietyId || line.id || ('__idx_' + i))
  714 + m[key] = { price: Number(line.price), meta: line }
  715 + }
  716 + return m
  717 + },
  718 + onShippingCostInput(val) {
  719 + var s = val == null ? '' : String(val)
  720 + s = s.replace(/[^\d.]/g, '')
  721 + var parts = s.split('.')
  722 + if (parts.length > 2) s = parts[0] + '.' + parts.slice(1).join('')
  723 + this.form.shippingCost = s
  724 + this.refreshLinesFromShipping()
  725 + },
  726 + onShippingCostBlur() {
  727 + if (this.form.shippingCost == null || this.form.shippingCost === '') {
  728 + this.refreshLinesFromShipping()
  729 + return
  730 + }
  731 + var n = Number(this.form.shippingCost)
  732 + if (isNaN(n)) {
  733 + this.form.shippingCost = ''
  734 + } else {
  735 + if (n < 0) n = 0
  736 + this.form.shippingCost = this.toFixed(n, 2)
  737 + }
  738 + this.refreshLinesFromShipping()
  739 + },
  740 + refreshLinesFromShipping() {
  741 + var self = this
  742 + var sc = self.shippingCostNumber
  743 + if (!Array.isArray(self.lineList)) return
  744 + self.lineList = self.lineList.map(function (row) {
  745 + var actual = self.toNumber(row.actualPurchasePrice)
  746 + var including = actual + sc
  747 + row.includingShippingPrice = self.toFixed(including, 2)
  748 + var priceList = self.toNumber(row.priceListPrices)
  749 + var loss = self.toNumber(row.estimatedLoss)
  750 + var coord = including + loss - priceList
  751 + row.coordinationRange = self.toFixed(coord, 2)
  752 + return row
  753 + })
  754 + self.notifyLineChange()
  755 + },
  756 + onLineChange(list) {
  757 + this.lineList = Array.isArray(list) ? list.slice() : []
  758 + this.fillLineNames()
  759 + this.refreshLinesFromShipping()
  760 + },
  761 + fillLineNames() {
  762 + if (!Array.isArray(this.lineList) || !this.lineList.length) return
  763 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  764 + var wOpts = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  765 + var self = this
  766 + this.lineList = this.lineList.map(function (row) {
  767 + var r = Object.assign({}, row)
  768 + var pid = r.productId != null ? String(r.productId) : ''
  769 + var wid = r.workshopId != null ? String(r.workshopId) : ''
  770 + if ((r.productName == null || String(r.productName).trim() === '') && pid) {
  771 + var p = pOpts.find(function (o) {
  772 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  773 + return id === pid
  774 + })
  775 + if (p) {
  776 + r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
  777 + }
  778 + }
  779 + if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) {
  780 + var w = wOpts.find(function (o) {
  781 + var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
  782 + return id === wid
  783 + })
  784 + if (w) {
  785 + r.workshopName = w.name != null ? w.name : (w.workshopName != null ? w.workshopName : (w.label != null ? w.label : ''))
  786 + }
  787 + }
  788 + return r
  789 + })
  790 + },
  791 + notifyLineChange() {
  792 + try {
  793 + var pr = this.$refs.productRel
  794 + if (pr) {
  795 + if (typeof pr.initItems === 'function') {
  796 + pr._initialized = false
  797 + pr.initItems()
  798 + var self = this
  799 + this.$nextTick(function () {
  800 + pr._initialized = true
  801 + })
  802 + }
  803 + }
  804 + } catch (e) {
  805 + console.warn('notifyLineChange error:', e)
  806 + }
  807 + },
  808 + validateForm() {
  809 + if (!this.form.companyName || !this.form.companyId) {
  810 + uni.showToast({ title: '请选择公司名称', icon: 'none' })
  811 + return false
  812 + }
  813 + if (!this.form.date) {
  814 + uni.showToast({ title: '请选择日期', icon: 'none' })
  815 + return false
  816 + }
  817 + if (!this.form.priceTableId && !this.form.priceTableCode) {
  818 + uni.showToast({ title: '请选择价格表', icon: 'none' })
  819 + return false
  820 + }
  821 + var pr = this.$refs.productRel
  822 + if (pr && typeof pr.validate === 'function') {
  823 + var ok = pr.validate()
  824 + if (!ok) return false
  825 + }
  826 + return true
  827 + },
  828 + joinStr(arr) {
  829 + if (Array.isArray(arr)) return arr.filter(Boolean).join(',')
  830 + if (typeof arr === 'string') return arr
  831 + return ''
  832 + },
  833 + toBool(v, fallback) {
  834 + if (typeof v === 'boolean') return v
  835 + if (v === 'true' || v === '1' || v === 1) return true
  836 + if (v === 'false' || v === '0' || v === 0) return false
  837 + return typeof fallback === 'boolean' ? fallback : false
  838 + },
  839 + pickId(v) {
  840 + if (v == null || v === '') return ''
  841 + if (typeof v === 'string' || typeof v === 'number') return String(v)
  842 + if (typeof v === 'object') {
  843 + return String(v.id != null ? v.id : (v.value != null ? v.value : (v.code != null ? v.code : '')))
  844 + }
  845 + return String(v)
  846 + },
  847 + buildPayload() {
  848 + var self = this
  849 + var d = this.detail || {}
  850 + var lines = Array.isArray(this.lineList) ? this.lineList.slice() : []
  851 + var lineList = lines.map(function (row, i) {
  852 + var r = row || {}
  853 + var itemId = r.itemId || (r._key != null ? r._key : (r.id ? String(r.id) : ('line-' + Date.now() + '-' + i)))
  854 + return {
  855 + id: r.id != null ? r.id : '',
  856 + itemId: itemId,
  857 + procurementPlanId: (r.procurementPlanId != null ? r.procurementPlanId : (self.form.id || d.id || '')),
  858 + productId: self.pickId(r.productId),
  859 + materialType: r.materialType != null ? String(r.materialType) : '',
  860 + quantity: self.toNumber(r.quantity),
  861 + actualPurchasePrice: self.toNumber(r.actualPurchasePrice),
  862 + includingShippingPrice: self.toNumber(r.includingShippingPrice),
  863 + priceListPrices: self.toNumber(r.priceListPrices),
  864 + coordinationRange: self.toNumber(r.coordinationRange),
  865 + estimatedLoss: self.toNumber(r.estimatedLoss),
  866 + applicationAttrition: self.toNumber(r.applicationAttrition),
  867 + workshopId: self.pickId(r.workshopId)
  868 + }
  869 + })
  870 + var mcFields = this.materialConditionConfigs.map(function (mc) { return mc.field })
  871 + var materialPayload = {}
  872 + mcFields.forEach(function (f) {
  873 + materialPayload[f] = self.joinStr(d[f])
  874 + })
  875 + var body = {
  876 + id: this.form.id || d.id || '',
  877 + code: d.code != null ? String(d.code) : '',
  878 + companyShortId: this.pickId(this.form.companyId || d.companyShortId || d.companyId),
  879 + supplierId: this.pickId(d.supplierId),
  880 + purchaseDepartment: this.pickId(d.purchaseDepartmentId || d.purchaseDepartment),
  881 + region: this.pickId(d.regionId || d.region),
  882 + date: this.form.date || '',
  883 + validityPeriod: d.validityPeriod != null ? String(d.validityPeriod) : '',
  884 + quoterId: this.pickId(d.quoterId),
  885 + quoterName: d.quoterName != null ? String(d.quoterName) : '',
  886 + longTermOperation: this.toBool(d.longTermOperation, false),
  887 + terminalCustomer: this.toBool(d.terminalCustomer, false),
  888 + priced: this.toBool(d.priced, false),
  889 + pricingDeadline: d.pricingDeadline != null ? String(d.pricingDeadline) : '',
  890 + temporaryPrice: this.toBool(d.temporaryPrice, false),
  891 + otherExpenseSettlement: this.toBool(d.otherExpenseSettlement, false),
  892 + deliveryMode: d.deliveryMode != null ? String(d.deliveryMode) : '',
  893 + commodityBuyout: this.toBool(d.commodityBuyout, false),
  894 + qualityBuyout: this.toBool(d.qualityBuyout, false),
  895 + quantityBuyout: this.toBool(d.quantityBuyout, false),
  896 + doorDelivery: this.toBool(d.doorDelivery, false),
  897 + shippingCost: this.toNumber(this.form.shippingCost),
  898 + loadingFee: this.toNumber(d.loadingFee),
  899 + invoiceProductName: d.invoiceProductName != null ? String(d.invoiceProductName) : '',
  900 + deliveryDate: d.deliveryDate != null ? String(d.deliveryDate) : '',
  901 + settlementMethod: d.settlementMethod != null ? String(d.settlementMethod) : '',
  902 + settlementRatio: this.toNumber(d.settlementRatio),
  903 + priceId: this.pickId(this.form.priceTableId || d.priceId || d.priceTableId),
  904 + coordinationReason: d.coordinationReason != null ? String(d.coordinationReason) : '',
  905 + invoiceTypeStatus: d.invoiceTypeStatus != null ? String(d.invoiceTypeStatus) : '',
  906 + remark: d.remark != null ? String(d.remark) : '',
  907 + materialConditionEnabled: this.toBool(d.materialConditionEnabled, false),
  908 + approvalStatus: d.approvalStatus != null ? String(d.approvalStatus) : '',
  909 + processStatus: d.processStatus != null ? String(d.processStatus) : '',
  910 + processNode: d.processNode != null ? String(d.processNode) : '',
  911 + procurementPlanLineList: lineList
  912 + }
  913 + Object.keys(materialPayload).forEach(function (k) {
  914 + body[k] = materialPayload[k]
  915 + })
  916 + return body
  917 + },
  918 + onBack() {
  919 + uni.navigateBack({ delta: 1 })
  920 + },
  921 + async onSubmit() {
  922 + if (!this.validateForm()) return
  923 + var payload = this.buildPayload()
  924 + try {
  925 + await procurementPlanUpdateApi(payload)
  926 + uni.showToast({ title: '保存成功', icon: 'none' })
  927 + try {
  928 + uni.setStorageSync('DOMESTIC_PLAN_LIST_NEED_REFRESH', '1')
  929 + uni.setStorageSync('SUPPLE_PLAN_LIST_NEED_REFRESH', '1')
  930 + } catch (e) {}
  931 + var self = this
  932 + setTimeout(function () {
  933 + uni.navigateBack({ delta: 1 })
  934 + }, 400)
  935 + } catch (e) {
  936 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : '保存失败', icon: 'none' })
  937 + }
  938 + }
  939 + }
  940 +}
  941 +</script>
  942 +
  943 +<style lang="scss" scoped>
  944 +.page {
  945 + display: flex;
  946 + flex-direction: column;
  947 + height: 100%;
  948 +}
  949 +.scroll {
  950 + flex: 1;
  951 + padding: 12rpx 0 392rpx !important;
  952 +}
  953 +.bottom-bar {
  954 + z-index: 2;
  955 + position: fixed;
  956 + left: 0;
  957 + right: 0;
  958 + bottom: 0;
  959 + padding: 32rpx;
  960 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  961 + background: #fff;
  962 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  963 + display: flex;
  964 + gap: 24rpx;
  965 + .btn {
  966 + flex: 1;
  967 + height: 80rpx;
  968 + line-height: 80rpx;
  969 + border-radius: 12rpx;
  970 + font-size: 32rpx;
  971 + }
  972 + .btn-outline {
  973 + background: #fff;
  974 + color: $theme-primary;
  975 + border: 2rpx solid $theme-primary;
  976 + }
  977 + .btn-primary {
  978 + background: $theme-primary;
  979 + color: #fff;
  980 + border: 2rpx solid $theme-primary;
  981 + }
  982 +}
  983 +
  984 +::v-deep .uni-list {
  985 + .uni-easyinput {
  986 + display: flex;
  987 + .uni-input-input {
  988 + color: rgba(0, 0, 0, 0.9);
  989 + }
  990 + }
  991 + .uni-input-placeholder { z-index: 1; }
  992 + .uni-input-input { background-color: #ffffff; }
  993 + background: transparent;
  994 + &-item {
  995 + &__extra-text { font-size: 32rpx; }
  996 + &__content-title {
  997 + font-size: 32rpx;
  998 + color: rgba(0, 0, 0, 0.9);
  999 + }
  1000 + &__container {
  1001 + padding: 32rpx;
  1002 + .uni-easyinput {
  1003 + &__placeholder-class {
  1004 + font-size: 32rpx;
  1005 + color: rgba(0, 0, 0, 0.4);
  1006 + }
  1007 + &__content {
  1008 + border: none;
  1009 + background-color: #ffffff !important;
  1010 + &-input {
  1011 + padding-left: 0 !important;
  1012 + height: 48rpx;
  1013 + line-height: 48rpx;
  1014 + font-size: 32rpx;
  1015 + }
  1016 + .content-clear-icon {
  1017 + font-size: 44rpx !important;
  1018 + }
  1019 + }
  1020 + }
  1021 + .item-title,
  1022 + .uni-list-item__content {
  1023 + flex: none;
  1024 + min-height: 48rpx;
  1025 + line-height: 48rpx;
  1026 + font-size: 32rpx;
  1027 + position: relative;
  1028 + width: 240rpx;
  1029 + margin-right: 32rpx;
  1030 + color: rgba(0, 0, 0, 0.9);
  1031 + .required {
  1032 + color: red;
  1033 + position: absolute;
  1034 + top: 50%;
  1035 + transform: translateY(-50%);
  1036 + left: -16rpx;
  1037 + }
  1038 + }
  1039 + }
  1040 + &.select-item {
  1041 + &.is-empty {
  1042 + .uni-list-item__extra-text {
  1043 + color: rgba(0, 0, 0, 0.4) !important;
  1044 + }
  1045 + }
  1046 + &.is-filled {
  1047 + .uni-list-item__extra-text {
  1048 + color: rgba(0, 0, 0, 0.9) !important;
  1049 + }
  1050 + }
  1051 + .serial-number-row {
  1052 + display: flex;
  1053 + align-items: center;
  1054 + }
  1055 + }
  1056 + }
  1057 +}
  1058 +
  1059 +.readonly-text {
  1060 + color: rgba(0, 0, 0, 0.9);
  1061 + font-size: 32rpx;
  1062 + line-height: 48rpx;
  1063 + text-align: right;
  1064 + white-space: pre-wrap;
  1065 + word-break: break-all;
  1066 +}
  1067 +.value-code {
  1068 + width: 260rpx;
  1069 + text-align: left;
  1070 +}
  1071 +
  1072 +.attach-list {
  1073 + flex: 1;
  1074 + display: flex;
  1075 + flex-direction: column;
  1076 + align-items: flex-end;
  1077 + gap: 8rpx;
  1078 +}
  1079 +.attach-item {
  1080 + display: flex;
  1081 + align-items: center;
  1082 + gap: 16rpx;
  1083 + .attach-name { font-size: 26rpx; color: rgba(0,0,0,0.9); }
  1084 + .attach-view { font-size: 26rpx; color: $theme-primary; }
  1085 +}
  1086 +
  1087 +.material-condition-section,
  1088 +.remark-section {
  1089 + margin-top: 20rpx;
  1090 + background: #fff;
  1091 +}
  1092 +.section-header {
  1093 + display: flex;
  1094 + align-items: center;
  1095 + padding: 24rpx 32rpx;
  1096 + border-bottom: 1rpx solid #f0f0f0;
  1097 +}
  1098 +.section-title {
  1099 + font-size: 32rpx;
  1100 + color: rgba(0, 0, 0, 0.9);
  1101 + font-weight: 600;
  1102 +}
  1103 +.opCollapse {
  1104 + width: 32rpx;
  1105 + height: 28rpx;
  1106 + margin-right: 16rpx;
  1107 + margin-top: 8rpx;
  1108 +}
  1109 +.section-content {
  1110 + padding: 32rpx;
  1111 +}
  1112 +.form-row {
  1113 + display: flex;
  1114 + align-items: center;
  1115 + justify-content: space-between;
  1116 + margin-bottom: 24rpx;
  1117 +}
  1118 +.form-row:last-child { margin-bottom: 0; }
  1119 +.form-label {
  1120 + font-size: 32rpx;
  1121 + color: rgba(0, 0, 0, 0.9);
  1122 +}
  1123 +.form-value {
  1124 + font-size: 32rpx;
  1125 + color: rgba(0, 0, 0, 0.9);
  1126 +}
  1127 +.material-group {
  1128 + margin-top: 32rpx;
  1129 +}
  1130 +.material-label {
  1131 + display: block;
  1132 + font-size: 30rpx;
  1133 + color: rgba(0, 0, 0, 0.9);
  1134 + margin-bottom: 20rpx;
  1135 +}
  1136 +.tag-list {
  1137 + display: flex;
  1138 + flex-wrap: wrap;
  1139 + gap: 16rpx;
  1140 +}
  1141 +.tag-btn {
  1142 + padding: 12rpx 24rpx;
  1143 + border: 1rpx solid #ddd;
  1144 + border-radius: 8rpx;
  1145 + font-size: 28rpx;
  1146 + color: #666;
  1147 + background: #fff;
  1148 +}
  1149 +.tag-btn.active {
  1150 + background: $theme-primary;
  1151 + border-color: $theme-primary;
  1152 + color: #fff;
  1153 +}
  1154 +.remark-text {
  1155 + font-size: 30rpx;
  1156 + color: rgba(0,0,0,0.9);
  1157 + line-height: 1.6;
  1158 + white-space: pre-wrap;
  1159 +}
  1160 +.footer-tip {
  1161 + padding: 24rpx 32rpx;
  1162 + color: rgba(0,0,0,0.45);
  1163 + font-size: 24rpx;
  1164 +}
  1165 +
  1166 +::v-deep .uni-easyinput {
  1167 + width: 100%;
  1168 + &__content {
  1169 + background: #f8f8f8 !important;
  1170 + border-radius: 8rpx;
  1171 + &-input { font-size: 30rpx; }
  1172 + }
  1173 +}
  1174 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view scroll-y class="scroll">
  4 + <uni-list>
  5 + <uni-list-item class="select-item is-filled">
  6 + <template v-slot:body>
  7 + <view class="item-title"><text>编号</text></view>
  8 + </template>
  9 + <template v-slot:footer>
  10 + <view class="serial-number-row">
  11 + <text class="readonly-text value-code">{{ safeText(main.code) }}</text>
  12 + </view>
  13 + </template>
  14 + </uni-list-item>
  15 +
  16 + <uni-list-item title="供应商名称">
  17 + <template v-slot:footer>
  18 + <uni-easyinput v-model="main.supplierName" :inputBorder="false" disabled placeholder="-" />
  19 + </template>
  20 + </uni-list-item>
  21 +
  22 + <uni-list-item title="采购处">
  23 + <template v-slot:footer>
  24 + <uni-easyinput v-model="purchaseDepartmentDisplay" :inputBorder="false" disabled placeholder="-" />
  25 + </template>
  26 + </uni-list-item>
  27 +
  28 + <uni-list-item title="区域">
  29 + <template v-slot:footer>
  30 + <uni-easyinput v-model="regionDisplay" :inputBorder="false" disabled placeholder="-" />
  31 + </template>
  32 + </uni-list-item>
  33 +
  34 + <uni-list-item title="日期">
  35 + <template v-slot:footer>
  36 + <uni-easyinput v-model="dateDisplay" :inputBorder="false" disabled placeholder="-" />
  37 + </template>
  38 + </uni-list-item>
  39 +
  40 + <uni-list-item title="运费(另付运费)">
  41 + <template v-slot:footer>
  42 + <uni-easyinput v-model="shippingCostDisplay" :inputBorder="false" disabled placeholder="-" />
  43 + </template>
  44 + </uni-list-item>
  45 +
  46 + <uni-list-item title="外观描述">
  47 + <template v-slot:footer>
  48 + <uni-easyinput v-model="main.appearanceDesc" :inputBorder="false" disabled placeholder="-" />
  49 + </template>
  50 + </uni-list-item>
  51 +
  52 + <uni-list-item title="料质状况">
  53 + <template v-slot:footer>
  54 + <uni-easyinput v-model="main.materialQualityDesc" :inputBorder="false" disabled placeholder="-" />
  55 + </template>
  56 + </uni-list-item>
  57 +
  58 + <uni-list-item title="废杂物情况">
  59 + <template v-slot:footer>
  60 + <uni-easyinput v-model="main.impurityDesc" :inputBorder="false" disabled placeholder="-" />
  61 + </template>
  62 + </uni-list-item>
  63 +
  64 + <uni-list-item title="油水杂情况">
  65 + <template v-slot:footer>
  66 + <uni-easyinput v-model="main.oilWaterDesc" :inputBorder="false" disabled placeholder="-" />
  67 + </template>
  68 + </uni-list-item>
  69 +
  70 + <uni-list-item title="装车费情况">
  71 + <template v-slot:footer>
  72 + <uni-easyinput v-model="loadingFeeDisplay" :inputBorder="false" disabled placeholder="-" />
  73 + </template>
  74 + </uni-list-item>
  75 +
  76 + <uni-list-item title="买断原因">
  77 + <template v-slot:footer>
  78 + <uni-easyinput v-model="main.buyoutReason" :inputBorder="false" disabled placeholder="-" />
  79 + </template>
  80 + </uni-list-item>
  81 +
  82 + <uni-list-item title="漆损率(%)">
  83 + <template v-slot:footer>
  84 + <uni-easyinput v-model="paintLossRatioDisplay" :inputBorder="false" disabled placeholder="-" />
  85 + </template>
  86 + </uni-list-item>
  87 +
  88 + <uni-list-item title="带漆说明">
  89 + <template v-slot:footer>
  90 + <text class="readonly-text small">{{ paintSummaryText || '-' }}</text>
  91 + </template>
  92 + </uni-list-item>
  93 + </uni-list>
  94 +
  95 + <view class="line-section">
  96 + <view class="section-header">
  97 + <image class="opCollapse" src="/static/images/title.png" />
  98 + <text class="section-title">买断明细</text>
  99 + </view>
  100 + <view v-if="!lineList.length" class="empty-tip">暂无明细</view>
  101 + <view v-else class="line-list">
  102 + <view v-for="(item, idx) in lineList" :key="item._key || ('line-' + idx)" class="line-card">
  103 + <view class="line-title">第 {{ idx + 1 }} 条明细</view>
  104 + <uni-list>
  105 + <uni-list-item title="买断品种">
  106 + <template v-slot:footer>
  107 + <text class="readonly-text">{{ safeText(item.productName) }}</text>
  108 + </template>
  109 + </uni-list-item>
  110 + <uni-list-item title="料型">
  111 + <template v-slot:footer>
  112 + <text class="readonly-text">{{ safeText(item.materialType) }}</text>
  113 + </template>
  114 + </uni-list-item>
  115 + <uni-list-item title="买断数量(吨)">
  116 + <template v-slot:footer>
  117 + <text class="readonly-text">{{ formatNumberText(item.quantity, 4) }}</text>
  118 + </template>
  119 + </uni-list-item>
  120 + <uni-list-item title="买断价格">
  121 + <template v-slot:footer>
  122 + <text class="readonly-text">{{ formatNumberText(item.buyoutPrice, 2) }}</text>
  123 + </template>
  124 + </uni-list-item>
  125 + <uni-list-item title="预计吨损耗">
  126 + <template v-slot:footer>
  127 + <text class="readonly-text">{{ formatNumberText(item.estimatedLoss, 2) }}</text>
  128 + </template>
  129 + </uni-list-item>
  130 + <uni-list-item title="漆损率(%)">
  131 + <template v-slot:footer>
  132 + <text class="readonly-text">{{ formatNumberText(item.paintLossRatio, 4) }}</text>
  133 + </template>
  134 + </uni-list-item>
  135 + <uni-list-item title="是否带漆">
  136 + <template v-slot:footer>
  137 + <text class="readonly-text">{{ item.withPaint ? '是(按漆损率计算)' : '否' }}</text>
  138 + </template>
  139 + </uni-list-item>
  140 + <uni-list-item title="除损耗后纯铜价格">
  141 + <template v-slot:footer>
  142 + <text class="readonly-text value-code price-code">{{ formatNumberText(item.pureCopperPrice, 2) }}</text>
  143 + </template>
  144 + </uni-list-item>
  145 + </uni-list>
  146 + </view>
  147 + </view>
  148 + </view>
  149 + </scroll-view>
  150 + </view>
  151 +</template>
  152 +
  153 +<script>
  154 +import { buyoutApplyDetailByPlanIdApi } from '@/api/procure-manage/buyout.js'
  155 +import { procurementPlanDetailApi } from '@/api/procure-manage/procurementPlan.js'
  156 +import { breedRelationshipQueryApi } from '@/api/devManage.js'
  157 +
  158 +export default {
  159 + name: 'DomesticPlanViewBuyoutApply',
  160 + data() {
  161 + return {
  162 + planId: '',
  163 + planData: {},
  164 + buyoutData: null,
  165 + breedOptions: [],
  166 + main: {
  167 + code: '',
  168 + supplierName: '',
  169 + purchaseDepartment: '',
  170 + purchaseDepartmentId: '',
  171 + region: '',
  172 + regionId: '',
  173 + date: '',
  174 + shippingCost: '',
  175 + appearanceDesc: '',
  176 + materialQualityDesc: '',
  177 + impurityDesc: '',
  178 + oilWaterDesc: '',
  179 + loadingFee: '',
  180 + buyoutReason: '',
  181 + paintLossRatio: ''
  182 + },
  183 + lineList: []
  184 + }
  185 + },
  186 + computed: {
  187 + purchaseDepartmentDisplay() {
  188 + var m = this.main || {}
  189 + var p = this.planData || {}
  190 + var v1 = m.purchaseDepartment != null ? String(m.purchaseDepartment) : ''
  191 + var v2 = p.purchaseDepartmentName != null ? String(p.purchaseDepartmentName) : (p.purchaseDepartment != null ? String(p.purchaseDepartment) : '')
  192 + return v1 ? v1 : v2
  193 + },
  194 + regionDisplay() {
  195 + var m = this.main || {}
  196 + var p = this.planData || {}
  197 + var v1 = m.region != null ? String(m.region) : ''
  198 + var v2 = p.regionName != null ? String(p.regionName) : (p.region != null ? String(p.region) : '')
  199 + return v1 ? v1 : v2
  200 + },
  201 + dateDisplay() {
  202 + var s = String(this.main.date || (this.planData.date || '')).trim()
  203 + if (!s) return ''
  204 + return s.length >= 10 ? s.slice(0, 10) : s
  205 + },
  206 + shippingCostDisplay() {
  207 + var v = this.toNumber(this.main.shippingCost != null ? this.main.shippingCost : this.planData.shippingCost)
  208 + return v === 0 ? '0.00' : v.toFixed(2)
  209 + },
  210 + loadingFeeDisplay() {
  211 + var v = this.toNumber(this.main.loadingFee != null ? this.main.loadingFee : this.planData.loadingFee)
  212 + return v === 0 ? '0.00' : v.toFixed(2)
  213 + },
  214 + paintLossRatioDisplay() {
  215 + var v = this.toNumber(this.main.paintLossRatio)
  216 + if (v === 0) return '0.0000'
  217 + return v ? v.toFixed(4) : ''
  218 + },
  219 + paintSummaryText() {
  220 + var list = Array.isArray(this.lineList) ? this.lineList : []
  221 + var withPaintList = list.filter(function (r) { return r.withPaint })
  222 + if (!withPaintList.length) return '本单明细未发现带漆的买断品种'
  223 + var totalQty = 0
  224 + var totalPureQty = 0
  225 + for (var i = 0; i < withPaintList.length; i++) {
  226 + var r = withPaintList[i]
  227 + var qty = this.toNumber(r.quantity)
  228 + var ratio = this.toNumber(r.paintLossRatio) / 100
  229 + if (ratio < 0) ratio = 0
  230 + if (ratio >= 1) ratio = 0.9999
  231 + totalQty += qty
  232 + totalPureQty += qty * (1 - ratio)
  233 + }
  234 + var avg = totalQty > 0 ? (totalPureQty / totalQty * 100) : 0
  235 + return '带漆品种数量合计 ' + this.formatNumber(totalQty, 4) + ' 吨,按品种漆损率计算的纯料折合比例约 ' + this.formatNumber(avg, 2) + '%(=∑ 数量*(1-漆损率) / 带漆总数量)'
  236 + }
  237 + },
  238 + onLoad(query) {
  239 + this.planId = (query && (query.planId || query.id)) ? (query.planId || query.id) : ''
  240 + this.loadAll()
  241 + },
  242 + methods: {
  243 + toNumber(v) {
  244 + if (v == null || v === '') return 0
  245 + var n = Number(v)
  246 + return isNaN(n) ? 0 : n
  247 + },
  248 + formatNumber(v, fraction) {
  249 + var n = this.toNumber(v)
  250 + if (fraction != null) return n.toFixed(fraction)
  251 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  252 + },
  253 + formatNumberText(v, fraction) {
  254 + if (v == null || v === '') return '-'
  255 + var n = Number(v)
  256 + if (isNaN(n)) return String(v)
  257 + return fraction != null ? n.toFixed(fraction) : n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  258 + },
  259 + safeText(v) {
  260 + var s = v == null ? '' : String(v)
  261 + return s.trim() ? s : '-'
  262 + },
  263 + async loadAll() {
  264 + var self = this
  265 + try {
  266 + await this.loadBreedOptions()
  267 + await this.loadPlanAndApply()
  268 + } catch (e) {
  269 + uni.showToast({ title: '加载失败', icon: 'none' })
  270 + }
  271 + },
  272 + async loadBreedOptions() {
  273 + try {
  274 + var res = await breedRelationshipQueryApi({ pageIndex: 1, pageSize: 2000 })
  275 + var d = (res && res.data) ? res.data : {}
  276 + this.breedOptions = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.list && Array.isArray(d.list)) ? d.list : ((d.records && Array.isArray(d.records)) ? d.records : []))
  277 + } catch (e) {
  278 + this.breedOptions = []
  279 + }
  280 + },
  281 + findBreedOption(productId) {
  282 + if (!productId) return null
  283 + var pid = String(productId)
  284 + var list = Array.isArray(this.breedOptions) ? this.breedOptions : []
  285 + for (var i = 0; i < list.length; i++) {
  286 + var o = list[i] || {}
  287 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.breedId != null ? String(o.breedId) : (o.value != null ? String(o.value) : '')))
  288 + if (id === pid) return o
  289 + }
  290 + return null
  291 + },
  292 + getPaintLossRatioFromBreed(productId, fallbackRatio) {
  293 + var opt = this.findBreedOption(productId)
  294 + if (opt) {
  295 + var keys = ['paintLossRatio', 'paintLossRate', 'lossRatio', 'lacquerLossRatio']
  296 + for (var i = 0; i < keys.length; i++) {
  297 + if (opt[keys[i]] != null && opt[keys[i]] !== '') {
  298 + var n = Number(opt[keys[i]])
  299 + if (!isNaN(n)) return n
  300 + }
  301 + }
  302 + }
  303 + if (fallbackRatio != null && fallbackRatio !== '') {
  304 + var f = Number(fallbackRatio)
  305 + if (!isNaN(f)) return f
  306 + }
  307 + return 0
  308 + },
  309 + isWithPaintByBreed(productId, productName, breedPaintLossRatio) {
  310 + if (breedPaintLossRatio > 0) return true
  311 + var name = String(productName || '')
  312 + var tags = ['带漆', '漆', '漆包', '油漆', '喷漆', '覆漆']
  313 + for (var i = 0; i < tags.length; i++) {
  314 + if (name.indexOf(tags[i]) >= 0) return true
  315 + }
  316 + return false
  317 + },
  318 + async loadPlanAndApply() {
  319 + var self = this
  320 + var planRes = null
  321 + var plan = {}
  322 + if (this.planId) {
  323 + try { planRes = await procurementPlanDetailApi({ id: this.planId }) } catch (e) { planRes = null }
  324 + plan = (planRes && planRes.data) ? planRes.data : {}
  325 + this.planData = plan || {}
  326 + }
  327 + var buyout = null
  328 + if (this.planId) {
  329 + try {
  330 + var bRes = await buyoutApplyDetailByPlanIdApi(this.planId)
  331 + if (bRes && (bRes.data != null || (bRes.code && bRes.code === 200))) {
  332 + buyout = bRes.data ? bRes.data : {}
  333 + if (buyout && (buyout.id || buyout.code || (Array.isArray(buyout.procurementBuyoutApplyLineList) && buyout.procurementBuyoutApplyLineList.length))) {
  334 + this.buyoutData = buyout
  335 + }
  336 + }
  337 + } catch (e) {
  338 + buyout = null
  339 + }
  340 + }
  341 + this.buildMain(plan, buyout)
  342 + this.buildLineList(plan, buyout)
  343 + },
  344 + buildMain(plan, buyout) {
  345 + var b = buyout || {}
  346 + var p = plan || {}
  347 + var code = b.code || p.code || ''
  348 + var supplierName = b.supplierName != null ? b.supplierName : (p.supplierName != null ? p.supplierName : '')
  349 + var pd = b.purchaseDepartment != null ? b.purchaseDepartment : (p.purchaseDepartmentName != null ? p.purchaseDepartmentName : p.purchaseDepartment)
  350 + var pdId = b.purchaseDepartmentId != null ? b.purchaseDepartmentId : (p.purchaseDepartmentId != null ? p.purchaseDepartmentId : p.purchaseDepartment)
  351 + var region = b.region != null ? b.region : (p.regionName != null ? p.regionName : p.region)
  352 + var regionId = b.regionId != null ? b.regionId : (p.regionId != null ? p.regionId : p.region)
  353 + var date = b.date != null ? b.date : p.date
  354 + var shippingCost = b.shippingCost != null ? b.shippingCost : (p.shippingCost != null ? p.shippingCost : '')
  355 + var appearanceDesc = b.appearanceDesc != null ? b.appearanceDesc : '厂家生产过程中报废的一手料'
  356 + var materialQualityDesc = b.materialQualityDesc != null ? b.materialQualityDesc : '料质清爽'
  357 + var impurityDesc = b.impurityDesc != null ? b.impurityDesc : '含少量杂质'
  358 + var oilWaterDesc = b.oilWaterDesc != null ? b.oilWaterDesc : ''
  359 + var loadingFee = b.loadingFee != null ? b.loadingFee : (p.loadingFee != null ? p.loadingFee : '')
  360 + var buyoutReason = b.buyoutReason != null ? b.buyoutReason : ''
  361 + var paintLossRatio = b.paintLossRatio != null ? b.paintLossRatio : (p.paintLossRatio != null ? p.paintLossRatio : '')
  362 + this.main = {
  363 + code: code,
  364 + supplierName: supplierName,
  365 + purchaseDepartment: pd,
  366 + purchaseDepartmentId: pdId,
  367 + region: region,
  368 + regionId: regionId,
  369 + date: date,
  370 + shippingCost: shippingCost,
  371 + appearanceDesc: appearanceDesc,
  372 + materialQualityDesc: materialQualityDesc,
  373 + impurityDesc: impurityDesc,
  374 + oilWaterDesc: oilWaterDesc,
  375 + loadingFee: loadingFee,
  376 + buyoutReason: buyoutReason,
  377 + paintLossRatio: paintLossRatio
  378 + }
  379 + },
  380 + buildLineList(plan, buyout) {
  381 + var self = this
  382 + var lines = []
  383 + var bLines = (buyout && buyout.procurementBuyoutApplyLineList && Array.isArray(buyout.procurementBuyoutApplyLineList)) ? buyout.procurementBuyoutApplyLineList : null
  384 + var pLines = (plan && plan.procurementPlanLineList && Array.isArray(plan.procurementPlanLineList)) ? plan.procurementPlanLineList.slice() : []
  385 + if (bLines && bLines.length) {
  386 + lines = bLines
  387 + } else {
  388 + lines = pLines
  389 + }
  390 + var shippingCost = this.toNumber(this.main.shippingCost != null ? this.main.shippingCost : this.planData.shippingCost)
  391 + var loadingFee = this.toNumber(this.main.loadingFee != null ? this.main.loadingFee : this.planData.loadingFee)
  392 + var defaultPaintLossRatio = this.toNumber(this.main.paintLossRatio != null ? this.main.paintLossRatio : this.planData.paintLossRatio)
  393 + this.lineList = lines.map(function (r, i) {
  394 + var row = r || {}
  395 + var productId = row.productId
  396 + var breedPaintLossRatio = self.getPaintLossRatioFromBreed(productId, defaultPaintLossRatio)
  397 + var withPaint = self.isWithPaintByBreed(productId, row.productName, breedPaintLossRatio)
  398 + var ratio = withPaint ? breedPaintLossRatio : 0
  399 + var ratioFrac = ratio / 100
  400 + if (ratioFrac < 0) ratioFrac = 0
  401 + if (ratioFrac >= 1) ratioFrac = 0.9999
  402 + var actualPurchase = row.actualPurchasePrice != null ? row.actualPurchasePrice : (row.buyoutPrice != null ? row.buyoutPrice : 0)
  403 + var buyoutPrice = row.buyoutPrice != null ? row.buyoutPrice : actualPurchase
  404 + var estimatedLoss = row.estimatedLoss != null ? row.estimatedLoss : 0
  405 + var divisor = 1 - ratioFrac
  406 + var base = divisor > 0 ? (self.toNumber(actualPurchase) / divisor) : self.toNumber(actualPurchase)
  407 + var pureCopperPrice = base + shippingCost + self.toNumber(estimatedLoss) + loadingFee
  408 + return {
  409 + _key: row._key || row.id || ('row-' + i + '-' + Date.now()),
  410 + productId: productId,
  411 + productName: row.productName || '',
  412 + materialType: row.materialType || '',
  413 + quantity: row.quantity != null ? row.quantity : 0,
  414 + buyoutPrice: buyoutPrice,
  415 + estimatedLoss: estimatedLoss,
  416 + paintLossRatio: ratio,
  417 + withPaint: !!withPaint,
  418 + pureCopperPrice: pureCopperPrice
  419 + }
  420 + })
  421 + if (!this.main.paintLossRatio && defaultPaintLossRatio > 0) {
  422 + this.main.paintLossRatio = defaultPaintLossRatio
  423 + }
  424 + }
  425 + }
  426 +}
  427 +</script>
  428 +
  429 +<style lang="scss" scoped>
  430 +.page { display: flex; flex-direction: column; height: 100%; background: #f7f7f7; }
  431 +.scroll { flex: 1; padding: 12rpx 0 40rpx; }
  432 +
  433 +.line-section { margin-top: 20rpx; background: #fff; }
  434 +.section-header { display: flex; align-items: center; padding: 24rpx 32rpx; border-bottom: 1rpx solid #f0f0f0; }
  435 +.section-title { font-size: 32rpx; color: rgba(0,0,0,0.9); font-weight: 600; }
  436 +.opCollapse { width: 32rpx; height: 28rpx; margin-right: 16rpx; margin-top: 8rpx; }
  437 +.empty-tip { padding: 80rpx 32rpx; text-align: center; color: rgba(0,0,0,0.4); font-size: 28rpx; }
  438 +.line-list { padding: 0 0 20rpx; }
  439 +.line-card { margin: 24rpx 24rpx 0; background: #fff; border-radius: 16rpx; box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.05); overflow: hidden; }
  440 +.line-title { padding: 20rpx 32rpx; font-size: 30rpx; color: rgba(0,0,0,0.9); border-bottom: 1rpx solid #f2f2f2; font-weight: 600; }
  441 +.value-code.price-code { font-weight: 700; color: $theme-primary; font-size: 32rpx; }
  442 +
  443 +::v-deep .uni-list {
  444 + .uni-easyinput {
  445 + display: flex;
  446 + .uni-input-input { color: rgba(0,0,0,0.9); }
  447 + }
  448 + .uni-input-placeholder { z-index: 1; }
  449 + .uni-input-input { background-color: #ffffff; }
  450 + background: transparent;
  451 + &-item {
  452 + &__container {
  453 + padding: 32rpx;
  454 + .uni-easyinput {
  455 + &__content {
  456 + border: none;
  457 + background-color: #ffffff !important;
  458 + &-input {
  459 + padding-left: 0 !important;
  460 + height: 48rpx;
  461 + line-height: 48rpx;
  462 + font-size: 32rpx;
  463 + }
  464 + }
  465 + }
  466 + .item-title,
  467 + .uni-list-item__content {
  468 + flex: none;
  469 + min-height: 48rpx;
  470 + line-height: 48rpx;
  471 + font-size: 32rpx;
  472 + width: 280rpx;
  473 + margin-right: 32rpx;
  474 + color: rgba(0,0,0,0.9);
  475 + }
  476 + }
  477 + &.select-item {
  478 + &.is-empty .uni-list-item__extra-text { color: rgba(0,0,0,0.4) !important; }
  479 + &.is-filled .uni-list-item__extra-text { color: rgba(0,0,0,0.9) !important; }
  480 + }
  481 + }
  482 +}
  483 +.readonly-text {
  484 + color: rgba(0,0,0,0.9);
  485 + font-size: 32rpx;
  486 + line-height: 48rpx;
  487 + text-align: right;
  488 + white-space: pre-wrap;
  489 + word-break: break-all;
  490 + &.small { font-size: 26rpx; line-height: 1.6; text-align: right; }
  491 +}
  492 +.value-code { width: 260rpx; text-align: left; }
  493 +.serial-number-row { display: flex; align-items: center; }
  494 +
  495 +::v-deep .uni-easyinput {
  496 + width: 100%;
  497 + &__content {
  498 + background: #f8f8f8 !important;
  499 + border-radius: 8rpx;
  500 + &-input { font-size: 30rpx; }
  501 + }
  502 +}
  503 +</style>
... ...
... ... @@ -179,6 +179,24 @@ export default {
179 179 icon: '/static/images/index/delay_invoice.png',
180 180 link: '/pages/quote-manage/index',
181 181 name: 'QuoteManage'
  182 + },
  183 + {
  184 + text: '内贸计划单',
  185 + icon: '/static/images/index/follow_up_form.png',
  186 + link: '/pages/domestic-plan/index',
  187 + name: 'DomesticPlan'
  188 + },
  189 + {
  190 + text: '计划变更单',
  191 + icon: '/static/images/index/draft_order.png',
  192 + link: '/pages/schedule-plan/index',
  193 + name: 'SchedulePlan'
  194 + },
  195 + {
  196 + text: '计划补录单',
  197 + icon: '/static/images/index/revoke_list.png',
  198 + link: '/pages/supple-plan/index',
  199 + name: 'SupplePlan'
182 200 }
183 201 ]
184 202 },
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view scroll-y class="scroll">
  4 + <uni-list>
  5 + <uni-list-item class="select-item" :class="form.code ? 'is-filled' : 'is-empty'" clickable
  6 + @click="openPlanSheet" :rightText="form.code || '请选择计划编号'" showArrow>
  7 + <template v-slot:body>
  8 + <view class="item-title"><text class="required">*</text><text>计划数据</text></view>
  9 + </template>
  10 + </uni-list-item>
  11 +
  12 + <uni-list-item title="公司名称">
  13 + <template v-slot:footer>
  14 + <uni-easyinput v-model="companyNameDisplay" :inputBorder="false" disabled placeholder="-" />
  15 + </template>
  16 + </uni-list-item>
  17 +
  18 + <uni-list-item>
  19 + <template v-slot:body>
  20 + <view class="item-title"><text class="required">*</text><text>供应商名称</text></view>
  21 + </template>
  22 + <template v-slot:footer>
  23 + <uni-easyinput v-model="detail.supplierName" :inputBorder="false" placeholder="请输入供应商名称" />
  24 + </template>
  25 + </uni-list-item>
  26 +
  27 + <uni-list-item title="采购处">
  28 + <template v-slot:footer>
  29 + <uni-easyinput v-model="purchaseDepartmentDisplay" :inputBorder="false" disabled placeholder="-" />
  30 + </template>
  31 + </uni-list-item>
  32 +
  33 + <uni-list-item title="区域">
  34 + <template v-slot:footer>
  35 + <uni-easyinput v-model="regionDisplay" :inputBorder="false" disabled placeholder="-" />
  36 + </template>
  37 + </uni-list-item>
  38 +
  39 + <uni-list-item title="日期">
  40 + <template v-slot:footer>
  41 + <uni-easyinput v-model="dateDisplay" :inputBorder="false" disabled placeholder="-" />
  42 + </template>
  43 + </uni-list-item>
  44 +
  45 + <uni-list-item>
  46 + <template v-slot:body>
  47 + <view class="item-title"><text class="required">*</text><text>报价时效</text></view>
  48 + </template>
  49 + <template v-slot:footer>
  50 + <uni-easyinput v-model="detail.validityPeriod" :inputBorder="false" placeholder="请输入报价时效" />
  51 + </template>
  52 + </uni-list-item>
  53 +
  54 + <uni-list-item>
  55 + <template v-slot:body>
  56 + <view class="item-title"><text class="required">*</text><text>报价人</text></view>
  57 + </template>
  58 + <template v-slot:footer>
  59 + <uni-easyinput v-model="detail.quoterName" :inputBorder="false" placeholder="请输入报价人" />
  60 + </template>
  61 + </uni-list-item>
  62 +
  63 + <uni-list-item class="select-item" :class="typeof detail.longTermOperation === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  64 + @click="toggleBool('longTermOperation')" :rightText="boolText(detail.longTermOperation) || '请选择'" showArrow>
  65 + <template v-slot:body>
  66 + <view class="item-title"><text class="required">*</text><text>是否长单操作</text></view>
  67 + </template>
  68 + </uni-list-item>
  69 +
  70 + <uni-list-item class="select-item" :class="typeof detail.terminalCustomer === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  71 + @click="toggleBool('terminalCustomer')" :rightText="boolText(detail.terminalCustomer) || '请选择'" showArrow>
  72 + <template v-slot:body>
  73 + <view class="item-title"><text class="required">*</text><text>是否终端客户</text></view>
  74 + </template>
  75 + </uni-list-item>
  76 +
  77 + <uni-list-item class="select-item" :class="typeof detail.priced === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  78 + @click="toggleBool('priced')" :rightText="boolText(detail.priced) || '请选择'" showArrow>
  79 + <template v-slot:body>
  80 + <view class="item-title"><text class="required">*</text><text>是否未点价</text></view>
  81 + </template>
  82 + </uni-list-item>
  83 +
  84 + <uni-list-item v-if="detail.priced === true">
  85 + <template v-slot:body>
  86 + <view class="item-title"><text class="required">*</text><text>点价截止日期</text></view>
  87 + </template>
  88 + <template v-slot:footer>
  89 + <uni-datetime-picker type="date" v-model="detail.pricingDeadline" return-type="string" />
  90 + </template>
  91 + </uni-list-item>
  92 +
  93 + <uni-list-item v-if="detail.priced === true" class="select-item" :class="typeof detail.temporaryPrice === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  94 + @click="toggleBool('temporaryPrice')" :rightText="boolText(detail.temporaryPrice) || '请选择'" showArrow>
  95 + <template v-slot:body>
  96 + <view class="item-title"><text class="required">*</text><text>是否暂定价</text></view>
  97 + </template>
  98 + </uni-list-item>
  99 +
  100 + <uni-list-item class="select-item" :class="typeof detail.otherExpenseSettlement === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  101 + @click="toggleBool('otherExpenseSettlement')" :rightText="boolText(detail.otherExpenseSettlement) || '请选择'" showArrow>
  102 + <template v-slot:body>
  103 + <view class="item-title"><text class="required">*</text><text>其他费用凭票到厂另行结算</text></view>
  104 + </template>
  105 + </uni-list-item>
  106 +
  107 + <uni-list-item class="select-item" :class="detail.deliveryMode ? 'is-filled' : 'is-empty'" clickable
  108 + @click="openDeliverySheet" :rightText="getDeliveryMethodLabel()" showArrow>
  109 + <template v-slot:body>
  110 + <view class="item-title"><text class="required">*</text><text>交提货方式</text></view>
  111 + </template>
  112 + </uni-list-item>
  113 +
  114 + <uni-list-item class="select-item" :class="typeof detail.commodityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  115 + @click="toggleBool('commodityBuyout')" :rightText="boolText(detail.commodityBuyout) || '请选择'" showArrow>
  116 + <template v-slot:body>
  117 + <view class="item-title"><text>是否通货买断</text></view>
  118 + </template>
  119 + </uni-list-item>
  120 +
  121 + <uni-list-item class="select-item" :class="typeof detail.qualityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  122 + @click="toggleBool('qualityBuyout')" :rightText="boolText(detail.qualityBuyout) || '请选择'" showArrow>
  123 + <template v-slot:body>
  124 + <view class="item-title"><text class="required">*</text><text>是否质量买断</text></view>
  125 + </template>
  126 + </uni-list-item>
  127 +
  128 + <uni-list-item class="select-item" :class="typeof detail.quantityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  129 + @click="toggleBool('quantityBuyout')" :rightText="boolText(detail.quantityBuyout) || '请选择'" showArrow>
  130 + <template v-slot:body>
  131 + <view class="item-title"><text>是否数量买断</text></view>
  132 + </template>
  133 + </uni-list-item>
  134 +
  135 + <uni-list-item class="select-item" :class="typeof detail.doorDelivery === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  136 + @click="toggleBool('doorDelivery')" :rightText="boolText(detail.doorDelivery) || '请选择'" showArrow>
  137 + <template v-slot:body>
  138 + <view class="item-title"><text class="required">*</text><text>是否送货上门</text></view>
  139 + </template>
  140 + </uni-list-item>
  141 +
  142 + <uni-list-item title="另付运费">
  143 + <template v-slot:footer>
  144 + <uni-easyinput v-model="shippingCostDisplay" :inputBorder="false" disabled placeholder="-" />
  145 + </template>
  146 + </uni-list-item>
  147 +
  148 + <uni-list-item>
  149 + <template v-slot:body>
  150 + <view class="item-title"><text class="required">*</text><text>装车费</text></view>
  151 + </template>
  152 + <template v-slot:footer>
  153 + <uni-easyinput
  154 + v-model="detail.loadingFee"
  155 + type="digit"
  156 + :inputBorder="false"
  157 + placeholder="请输入装车费"
  158 + @input="onNonNegativeInput('loadingFee')"
  159 + @blur="onNonNegativeBlur('loadingFee', 2)"
  160 + />
  161 + </template>
  162 + </uni-list-item>
  163 +
  164 + <uni-list-item title="开票品名">
  165 + <template v-slot:footer>
  166 + <uni-easyinput v-model="detail.invoiceProductName" :inputBorder="false" placeholder="请输入开票品名" />
  167 + </template>
  168 + </uni-list-item>
  169 +
  170 + <uni-list-item>
  171 + <template v-slot:body>
  172 + <view class="item-title"><text class="required">*</text><text>交货日期</text></view>
  173 + </template>
  174 + <template v-slot:footer>
  175 + <uni-datetime-picker type="date" v-model="detail.deliveryDate" return-type="string" />
  176 + </template>
  177 + </uni-list-item>
  178 + <uni-list-item>
  179 + <template v-slot:body>
  180 + <view class="item-title"><text class="required">*</text><text>结算方式</text></view>
  181 + </template>
  182 + <template v-slot:footer>
  183 + <uni-easyinput v-model="detail.settlementMethod" :inputBorder="false" placeholder="请输入结算方式" />
  184 + </template>
  185 + </uni-list-item>
  186 +
  187 + <uni-list-item>
  188 + <template v-slot:body>
  189 + <view class="item-title"><text class="required">*</text><text>结算比例(%)</text></view>
  190 + </template>
  191 + <template v-slot:footer>
  192 + <uni-easyinput
  193 + v-model="detail.settlementRatio"
  194 + type="digit"
  195 + :inputBorder="false"
  196 + placeholder="请输入结算比例"
  197 + @input="onNonNegativeInput('settlementRatio')"
  198 + @blur="onNonNegativeBlur('settlementRatio', 4)"
  199 + />
  200 + </template>
  201 + </uni-list-item>
  202 +
  203 + <uni-list-item title="价格表编号">
  204 + <template v-slot:footer>
  205 + <uni-easyinput v-model="priceTableDisplay" :inputBorder="false" disabled placeholder="-" />
  206 + </template>
  207 + </uni-list-item>
  208 +
  209 + <uni-list-item>
  210 + <template v-slot:body>
  211 + <view class="item-title"><text class="required">*</text><text>协调事由</text></view>
  212 + </template>
  213 + <template v-slot:footer>
  214 + <uni-easyinput v-model="detail.coordinationReason" :inputBorder="false" placeholder="请输入协调事由" />
  215 + </template>
  216 + </uni-list-item>
  217 +
  218 + <uni-list-item>
  219 + <template v-slot:body>
  220 + <view class="item-title"><text class="required">*</text><text>票类状况</text></view>
  221 + </template>
  222 + <template v-slot:footer>
  223 + <uni-easyinput v-model="detail.invoiceTypeStatus" :inputBorder="false" placeholder="请输入票类状况" />
  224 + </template>
  225 + </uni-list-item>
  226 +
  227 + <uni-list-item v-if="attachmentList.length" title="附件">
  228 + <template v-slot:footer>
  229 + <view class="attach-list">
  230 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  231 + <text class="attach-name">{{ at.name }}</text>
  232 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  233 + </view>
  234 + </view>
  235 + </template>
  236 + </uni-list-item>
  237 +
  238 + <ProductRel
  239 + ref="productRel"
  240 + mode="edit"
  241 + :list="lineList"
  242 + :product-options="productOptions"
  243 + :workshop-options="workshopOptions"
  244 + @change="onLineChange"
  245 + />
  246 + </uni-list>
  247 +
  248 + <view class="material-condition-section">
  249 + <view class="section-header">
  250 + <image class="opCollapse" src="/static/images/title.png" />
  251 + <text class="section-title">料质状况</text>
  252 + </view>
  253 + <view class="section-content">
  254 + <view class="form-row">
  255 + <text class="form-label">是否启用料质状况</text>
  256 + <text class="form-value toggle-link" @click="toggleBool('materialConditionEnabled')">{{ boolText(detail.materialConditionEnabled) || '请选择' }}</text>
  257 + </view>
  258 + <template v-if="detail.materialConditionEnabled">
  259 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  260 + <text class="material-label">{{ mc.label }}</text>
  261 + <view class="tag-list">
  262 + <view
  263 + v-for="opt in getDictOptions(mc.dictCode)"
  264 + :key="opt.code"
  265 + class="tag-btn"
  266 + :class="{ active: isTagSelected(mc.field, opt.code) }"
  267 + @click="toggleTag(mc.field, opt.code)"
  268 + >
  269 + {{ opt.name }}
  270 + </view>
  271 + </view>
  272 + </view>
  273 + </template>
  274 + </view>
  275 + </view>
  276 +
  277 + <view class="remark-section">
  278 + <view class="section-header">
  279 + <image class="opCollapse" src="/static/images/title.png" />
  280 + <text class="section-title">备注</text>
  281 + </view>
  282 + <view class="section-content">
  283 + <uni-easyinput type="textarea" v-model="detail.remark" :inputBorder="false" placeholder="请输入备注" />
  284 + </view>
  285 + </view>
  286 + <view class="remark-section">
  287 + <view class="section-header">
  288 + <image class="opCollapse" src="/static/images/title.png" />
  289 + <text class="section-title"><text class="required">*</text>变更事由</text>
  290 + </view>
  291 + <view class="section-content">
  292 + <uni-easyinput type="textarea" v-model="detail.changeReason" :inputBorder="false" placeholder="请输入变更事由" />
  293 + </view>
  294 + </view>
  295 + </scroll-view>
  296 +
  297 + <view class="bottom-bar">
  298 + <button class="btn btn-outline" @click="onBack">取消</button>
  299 + <button class="btn btn-primary" @click="onSubmit">保存</button>
  300 + </view>
  301 +
  302 + <RelateSelectSheet
  303 + v-if="planSheetVisible"
  304 + :visible.sync="planSheetVisible"
  305 + title="选择计划"
  306 + :fetch-fn="fetchChangePlanList"
  307 + :display-fields="planDisplayFields"
  308 + :page-size="20"
  309 + :multiple="false"
  310 + row-key="id"
  311 + @confirm="onPlanConfirm"
  312 + />
  313 + <SingleSelectSheet
  314 + :visible.sync="deliverySheetVisible"
  315 + title="交提货方式"
  316 + :options="deliveryOptions"
  317 + v-model="deliverySheetValue"
  318 + @confirm="onDeliveryConfirm"
  319 + />
  320 + </view>
  321 +</template>
  322 +
  323 +<script>
  324 +import ProductRel from './productRel.vue'
  325 +import RelateSelectSheet from '@/components/relate-select/index.vue'
  326 +import SingleSelectSheet from '@/components/single-select/index.vue'
  327 +import { procurementPlanDetailApi, procurementPlanCanChangeOrReplenishmentApi, procurementPlanChangeCreateApi } from '@/api/procure-manage/procurementPlan.js'
  328 +import {
  329 + breedRelationshipQueryApi,
  330 + priceTableDetailApi,
  331 + workshopQueryApi
  332 +} from '@/api/devManage.js'
  333 +import { getDicByCodes } from '@/utils/dic.js'
  334 +
  335 +export default {
  336 + name: 'SchedulePlanAdd',
  337 + components: { ProductRel, RelateSelectSheet, SingleSelectSheet },
  338 + data() {
  339 + return {
  340 + form: {
  341 + planId: '',
  342 + code: ''
  343 + },
  344 + detail: {},
  345 + attachmentList: [],
  346 + materialConditionConfigs: [
  347 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  348 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  349 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  350 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  351 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  352 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  353 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  354 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  355 + ],
  356 + dicOptions: {
  357 + DELIVERY_METHOD: []
  358 + },
  359 + dictData: {},
  360 + lineList: [],
  361 + productOptions: [],
  362 + workshopOptions: [],
  363 + planSheetVisible: false,
  364 + planDisplayFields: [
  365 + { label: '计划编号', field: 'code' },
  366 + { label: '公司简称', field: 'companyShortName' },
  367 + { label: '供应商名称', field: 'supplierName' },
  368 + { label: '数量', field: 'totalQuantity' },
  369 + { label: '采购处', field: 'purchaseDepartmentName' }
  370 + ],
  371 + deliverySheetVisible: false,
  372 + deliverySheetValue: '',
  373 + deliveryOptions: []
  374 + }
  375 + },
  376 + computed: {
  377 + companyNameDisplay() {
  378 + var d = this.detail || {}
  379 + return d.companyShortName != null ? d.companyShortName : (d.companyName != null ? d.companyName : '')
  380 + },
  381 + purchaseDepartmentDisplay() {
  382 + var d = this.detail || {}
  383 + return d.purchaseDepartmentName != null ? d.purchaseDepartmentName : (d.purchaseDepartment != null ? d.purchaseDepartment : '')
  384 + },
  385 + regionDisplay() {
  386 + var d = this.detail || {}
  387 + return d.regionName != null ? d.regionName : (d.region != null ? d.region : '')
  388 + },
  389 + dateDisplay() {
  390 + var d = this.detail || {}
  391 + var s = d.date == null ? '' : String(d.date).trim()
  392 + return s.length >= 10 ? s.slice(0, 10) : s
  393 + },
  394 + shippingCostDisplay() {
  395 + var v = (this.detail || {}).shippingCost
  396 + if (v == null || v === '') return ''
  397 + var n = Number(v)
  398 + if (isNaN(n)) return String(v)
  399 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  400 + },
  401 + priceTableDisplay() {
  402 + var d = this.detail || {}
  403 + var code = d.priceTableCode != null ? String(d.priceTableCode).trim() : ''
  404 + if (!code) return ''
  405 + var name = d.priceTableName || ''
  406 + return name ? (name + ' (' + code + ')') : code
  407 + }
  408 + },
  409 + onLoad() {
  410 + this.loadDictData()
  411 + this.loadRefData()
  412 + },
  413 + methods: {
  414 + safeText(v) {
  415 + var s = v == null ? '' : String(v)
  416 + return s.trim() ? s : '-'
  417 + },
  418 + boolText(v) {
  419 + if (typeof v !== 'boolean') return ''
  420 + return v ? '是' : '否'
  421 + },
  422 + toNumber(v) {
  423 + if (v == null || v === '') return 0
  424 + var n = Number(v)
  425 + return isNaN(n) ? 0 : n
  426 + },
  427 + toFixed(v, n) {
  428 + var num = Number(v)
  429 + if (isNaN(num)) return ''
  430 + return num.toFixed(n)
  431 + },
  432 + async loadDictData() {
  433 + var codes = [].concat(
  434 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  435 + ['DELIVERY_METHOD']
  436 + )
  437 + try {
  438 + var results = await getDicByCodes(codes)
  439 + var d = results || {}
  440 + this.dictData = d
  441 + this.dicOptions.DELIVERY_METHOD = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  442 + this.deliveryOptions = this.dicOptions.DELIVERY_METHOD.map(function (o) {
  443 + return { label: o.name || o.label || '', value: o.code != null ? o.code : o.value }
  444 + })
  445 + } catch (e) {
  446 + this.dictData = {}
  447 + }
  448 + },
  449 + async loadRefData() {
  450 + try {
  451 + var results = await Promise.all([
  452 + this.$pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  453 + this.$pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  454 + ])
  455 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  456 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  457 + this.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  458 + this.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  459 + this.fillLineNames()
  460 + } catch (e) {
  461 + this.productOptions = []
  462 + this.workshopOptions = []
  463 + }
  464 + },
  465 + $pCall(fn, params) {
  466 + try { return Promise.resolve(fn(params)) } catch (e) { return Promise.reject(e) }
  467 + },
  468 + getDictOptions(dictCode) {
  469 + var data = this.dictData[dictCode]
  470 + return (data && data.data) ? data.data : []
  471 + },
  472 + getDeliveryMethodLabel() {
  473 + var opts = this.dicOptions.DELIVERY_METHOD || []
  474 + var v = String(this.detail.deliveryMode != null ? this.detail.deliveryMode : '')
  475 + if (!v) return '请选择'
  476 + for (var i = 0; i < opts.length; i++) {
  477 + var o = opts[i]
  478 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  479 + if (code === v) return o.name || o.label || v
  480 + }
  481 + return v
  482 + },
  483 + openPlanSheet() {
  484 + this.planSheetVisible = true
  485 + },
  486 + fetchChangePlanList(args) {
  487 + var extra = (args && args.extra) ? args.extra : {}
  488 + var keyword = extra.keyword || extra.name || ''
  489 + var params = { pageIndex: args.pageIndex || 1, pageSize: args.pageSize || 20, queryType: 'CHANGE' }
  490 + if (keyword) params.keyword = keyword
  491 + return procurementPlanCanChangeOrReplenishmentApi(params).then(function (res) {
  492 + var d = (res && res.data) ? res.data : {}
  493 + var records = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.records && Array.isArray(d.records)) ? d.records : ((d.list && Array.isArray(d.list)) ? d.list : []))
  494 + var total = d.totalCount || d.count || (records ? records.length : 0)
  495 + var hasNext = !!d.hasNext
  496 + return { records: records, totalCount: total, hasNext: hasNext }
  497 + }).catch(function () {
  498 + return { records: [], totalCount: 0, hasNext: false }
  499 + })
  500 + },
  501 + onPlanConfirm(e) {
  502 + var items = (e && e.items) ? e.items : []
  503 + if (!items.length) return
  504 + var row = items[0] || {}
  505 + var id = row.id != null ? row.id : (row.planId != null ? row.planId : (row.procurementPlanId != null ? row.procurementPlanId : ''))
  506 + this.form.planId = id
  507 + this.form.code = row.code || ''
  508 + if (id) {
  509 + this.loadSourceDetail(id)
  510 + }
  511 + },
  512 + async loadSourceDetail(id) {
  513 + if (!id) return
  514 + try {
  515 + var res = await procurementPlanDetailApi({ id: id })
  516 + var d = (res && res.data) ? res.data : {}
  517 + var boolFields = ['longTermOperation', 'terminalCustomer', 'priced', 'temporaryPrice', 'otherExpenseSettlement', 'commodityBuyout', 'qualityBuyout', 'quantityBuyout', 'doorDelivery', 'materialConditionEnabled']
  518 + boolFields.forEach(function (f) {
  519 + var v = d[f]
  520 + if (typeof v === 'string') {
  521 + d[f] = v === 'true' || v === '1'
  522 + } else if (typeof v === 'number') {
  523 + d[f] = v === 1
  524 + } else {
  525 + d[f] = !!v
  526 + }
  527 + })
  528 + this.materialConditionConfigs.forEach(function (mc) {
  529 + var v = d[mc.field]
  530 + if (typeof v === 'string' && v) {
  531 + d[mc.field] = v.split(',').filter(Boolean)
  532 + } else if (!Array.isArray(v)) {
  533 + d[mc.field] = []
  534 + }
  535 + })
  536 + d.pricingDeadline = this.trimDate(d.pricingDeadline)
  537 + d.deliveryDate = this.trimDate(d.deliveryDate)
  538 + this.detail = d
  539 + if (!this.form.code) {
  540 + this.form.code = d.code || ''
  541 + }
  542 + this.lineList = Array.isArray(d.procurementPlanLineList) ? d.procurementPlanLineList.slice() : []
  543 + this.buildAttachmentList()
  544 + this.fillLineNames()
  545 + this.fetchPriceDetailAndApply(d.priceId)
  546 + } catch (e) {
  547 + uni.showToast({ title: '加载计划失败', icon: 'none' })
  548 + }
  549 + },
  550 + trimDate(v) {
  551 + if (v == null || v === '') return ''
  552 + var s = String(v).trim()
  553 + return s.length >= 10 ? s.slice(0, 10) : s
  554 + },
  555 + buildAttachmentList() {
  556 + var ids = this.detail.attachmentFileIds
  557 + var names = this.detail.attachmentFileNames
  558 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  559 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  560 + var len = Math.max(idArr.length, nameArr.length)
  561 + var list = []
  562 + for (var i = 0; i < len; i++) {
  563 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  564 + }
  565 + this.attachmentList = list
  566 + },
  567 + onPreviewAttachment(at) {
  568 + if (!at || !at.id) {
  569 + uni.showToast({ title: '无法查看', icon: 'none' })
  570 + return
  571 + }
  572 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  573 + },
  574 + fillLineNames() {
  575 + var list = Array.isArray(this.lineList) ? this.lineList : []
  576 + if (!list.length) return
  577 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  578 + var wOpts = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  579 + this.lineList = list.map(function (row) {
  580 + var r = Object.assign({}, row)
  581 + var pid = r.productId != null ? String(r.productId) : ''
  582 + var wid = r.workshopId != null ? String(r.workshopId) : ''
  583 + if ((r.productName == null || String(r.productName).trim() === '') && pid) {
  584 + var p = pOpts.find(function (o) {
  585 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  586 + return id === pid
  587 + })
  588 + if (p) {
  589 + r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
  590 + }
  591 + }
  592 + if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) {
  593 + var w = wOpts.find(function (o) {
  594 + var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
  595 + return id === wid
  596 + })
  597 + if (w) {
  598 + r.workshopName = w.name != null ? w.name : (w.workshopName != null ? w.workshopName : (w.label != null ? w.label : ''))
  599 + }
  600 + }
  601 + return r
  602 + })
  603 + },
  604 + async fetchPriceDetailAndApply(priceId) {
  605 + if (!priceId) return
  606 + var self = this
  607 + try {
  608 + var res = await priceTableDetailApi({ id: priceId })
  609 + var d = (res && res.data) ? res.data : {}
  610 + if (d.code != null && this.detail) {
  611 + this.$set(this.detail, 'priceTableCode', String(d.code))
  612 + }
  613 + if (d.priceTableName != null && this.detail) {
  614 + this.$set(this.detail, 'priceTableName', d.priceTableName)
  615 + }
  616 + var priceLines = self.extractPriceLines(d)
  617 + self.applyPriceLinesToLines(priceLines)
  618 + } catch (e) {
  619 + return
  620 + }
  621 + },
  622 + extractPriceLines(priceDetail) {
  623 + if (!priceDetail || typeof priceDetail !== 'object') return []
  624 + var candidates = [
  625 + priceDetail.procurementPriceLineList,
  626 + priceDetail.priceSubTableList,
  627 + priceDetail.priceLineList,
  628 + priceDetail.priceList,
  629 + priceDetail.lineList,
  630 + priceDetail.datas,
  631 + priceDetail.records,
  632 + priceDetail.list
  633 + ]
  634 + for (var i = 0; i < candidates.length; i++) {
  635 + if (Array.isArray(candidates[i]) && candidates[i].length) return candidates[i]
  636 + }
  637 + for (var k in priceDetail) {
  638 + if (!Object.prototype.hasOwnProperty.call(priceDetail, k)) continue
  639 + if (Array.isArray(priceDetail[k])) {
  640 + var arr = priceDetail[k]
  641 + if (arr.length && arr[0] && typeof arr[0] === 'object' && (arr[0].price != null || arr[0].productId != null || arr[0].breedId != null || arr[0].varietyId != null)) {
  642 + return arr
  643 + }
  644 + }
  645 + }
  646 + return []
  647 + },
  648 + buildPriceMap(priceLines) {
  649 + var m = {}
  650 + if (!Array.isArray(priceLines)) return m
  651 + for (var i = 0; i < priceLines.length; i++) {
  652 + var line = priceLines[i] || {}
  653 + if (line.price == null) continue
  654 + var key = String(line.productId || line.breedId || line.varietyId || line.id || ('__idx_' + i))
  655 + m[key] = { price: Number(line.price), meta: line }
  656 + }
  657 + return m
  658 + },
  659 + applyPriceLinesToLines(priceLines) {
  660 + if (!Array.isArray(this.lineList)) return
  661 + var priceMap = this.buildPriceMap(priceLines)
  662 + var self = this
  663 + this.lineList = this.lineList.map(function (row) {
  664 + var pid = String(row.productId || row.breedId || row.varietyId || '')
  665 + var price = null
  666 + if (pid && priceMap[pid] != null) {
  667 + price = priceMap[pid].price
  668 + } else {
  669 + var pname = (row.productName || '').trim()
  670 + if (pname) {
  671 + for (var k in priceMap) {
  672 + if (!Object.prototype.hasOwnProperty.call(priceMap, k)) continue
  673 + var meta = priceMap[k] && priceMap[k].meta ? priceMap[k].meta : null
  674 + if (meta && ((meta.productName && meta.productName === pname) || (meta.breedName && meta.breedName === pname) || (meta.varietyName && meta.varietyName === pname))) {
  675 + price = priceMap[k].price
  676 + break
  677 + }
  678 + }
  679 + }
  680 + }
  681 + if (price != null) {
  682 + row.priceListPrices = self.toFixed(price, 2)
  683 + } else {
  684 + row.priceListPrices = ''
  685 + }
  686 + return row
  687 + })
  688 + },
  689 + onLineChange(list) {
  690 + this.lineList = Array.isArray(list) ? list.slice() : []
  691 + },
  692 + toggleBool(field) {
  693 + var cur = this.detail[field]
  694 + this.$set(this.detail, field, cur !== true)
  695 + },
  696 + onNonNegativeInput(field) {
  697 + var v = String(this.detail[field] != null ? this.detail[field] : '')
  698 + v = v.replace(/[^0-9.]/g, '')
  699 + v = v.replace(/(\..*)\./g, '$1')
  700 + this.$set(this.detail, field, v)
  701 + },
  702 + onNonNegativeBlur(field, digits) {
  703 + var raw = this.detail[field]
  704 + if (raw === '' || raw === null || raw === undefined) {
  705 + this.$set(this.detail, field, '')
  706 + return
  707 + }
  708 + var val = parseFloat(raw)
  709 + if (isNaN(val)) val = 0
  710 + var m = Math.pow(10, digits)
  711 + var rounded = Math.round(val * m) / m
  712 + this.$set(this.detail, field, rounded)
  713 + },
  714 + openDeliverySheet() {
  715 + var cur = this.detail.deliveryMode != null ? this.detail.deliveryMode : ''
  716 + var match = this.deliveryOptions.find(function (o) { return String(o.value) === String(cur) })
  717 + this.deliverySheetValue = match ? match.value : ''
  718 + this.deliverySheetVisible = true
  719 + },
  720 + onDeliveryConfirm(e) {
  721 + this.$set(this.detail, 'deliveryMode', e.value != null ? e.value : '')
  722 + },
  723 + isTagSelected(field, code) {
  724 + var selected = this.detail ? this.detail[field] : undefined
  725 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  726 + if (typeof selected === 'string' && selected) {
  727 + return selected.split(',').indexOf(code) >= 0
  728 + }
  729 + return false
  730 + },
  731 + toggleTag(field, code) {
  732 + var selected = this.detail[field]
  733 + var arr = Array.isArray(selected) ? selected.slice() : []
  734 + var idx = arr.indexOf(code)
  735 + if (idx >= 0) {
  736 + arr.splice(idx, 1)
  737 + } else {
  738 + arr.push(code)
  739 + }
  740 + this.$set(this.detail, field, arr)
  741 + },
  742 + validateForm() {
  743 + if (!this.form.planId) {
  744 + uni.showToast({ title: '请选择计划', icon: 'none' })
  745 + return false
  746 + }
  747 + var d = this.detail || {}
  748 + var textChecks = [
  749 + { key: 'supplierName', title: '供应商名称' },
  750 + { key: 'validityPeriod', title: '报价时效' },
  751 + { key: 'quoterName', title: '报价人' },
  752 + { key: 'deliveryMode', title: '交提货方式' },
  753 + { key: 'loadingFee', title: '装车费' },
  754 + { key: 'invoiceProductName', title: '开票品名' },
  755 + { key: 'deliveryDate', title: '交货日期' },
  756 + { key: 'settlementMethod', title: '结算方式' },
  757 + { key: 'settlementRatio', title: '结算比例' },
  758 + { key: 'coordinationReason', title: '协调事由' },
  759 + { key: 'invoiceTypeStatus', title: '票类状况' },
  760 + { key: 'changeReason', title: '变更事由' }
  761 + ]
  762 + for (var i = 0; i < textChecks.length; i++) {
  763 + var tc = textChecks[i]
  764 + var tv = d[tc.key]
  765 + if (tv === '' || tv === null || tv === undefined) {
  766 + uni.showToast({ title: '请填写' + tc.title, icon: 'none' })
  767 + return false
  768 + }
  769 + }
  770 + var boolChecks = [
  771 + { key: 'longTermOperation', title: '是否长单操作' },
  772 + { key: 'terminalCustomer', title: '是否终端客户' },
  773 + { key: 'priced', title: '是否未点价' },
  774 + { key: 'otherExpenseSettlement', title: '其他费用凭票到厂另行结算' },
  775 + { key: 'commodityBuyout', title: '是否通货买断' },
  776 + { key: 'qualityBuyout', title: '是否质量买断' },
  777 + { key: 'quantityBuyout', title: '是否数量买断' },
  778 + { key: 'doorDelivery', title: '是否送货上门' }
  779 + ]
  780 + if (d.priced === true) {
  781 + boolChecks.push({ key: 'temporaryPrice', title: '是否暂定价' })
  782 + var pd = d.pricingDeadline
  783 + if (pd === '' || pd === null || pd === undefined) {
  784 + uni.showToast({ title: '请选择点价截止日期', icon: 'none' })
  785 + return false
  786 + }
  787 + }
  788 + for (var j = 0; j < boolChecks.length; j++) {
  789 + var bc = boolChecks[j]
  790 + if (typeof d[bc.key] !== 'boolean') {
  791 + uni.showToast({ title: '请选择' + bc.title, icon: 'none' })
  792 + return false
  793 + }
  794 + }
  795 + var pr = this.$refs.productRel
  796 + if (pr && typeof pr.validate === 'function') {
  797 + if (!pr.validate()) return false
  798 + }
  799 + return true
  800 + },
  801 + onBack() {
  802 + uni.navigateBack({ delta: 1 })
  803 + },
  804 + joinStr(arr) {
  805 + if (Array.isArray(arr)) return arr.filter(Boolean).join(',')
  806 + if (typeof arr === 'string') return arr
  807 + return ''
  808 + },
  809 + pickId(v) {
  810 + if (v == null || v === '') return ''
  811 + if (typeof v === 'string' || typeof v === 'number') return String(v)
  812 + if (typeof v === 'object') {
  813 + return String(v.id != null ? v.id : (v.value != null ? v.value : (v.code != null ? v.code : '')))
  814 + }
  815 + return String(v)
  816 + },
  817 + boolToStr(v) {
  818 + return v === true ? 'true' : 'false'
  819 + },
  820 + buildPayload() {
  821 + var self = this
  822 + var d = this.detail || {}
  823 + var lines = Array.isArray(this.lineList) ? this.lineList.slice() : []
  824 + var workshopId = d.workshopId != null ? d.workshopId : ''
  825 + var lineList = lines.map(function (row, i) {
  826 + var r = row || {}
  827 + var itemId = r.itemId != null ? r.itemId : (r.id != null ? String(r.id) : (r._key != null ? r._key : ('line-' + Date.now() + '-' + i)))
  828 + if (!workshopId && r.workshopId != null) workshopId = r.workshopId
  829 + return {
  830 + productId: self.pickId(r.productId),
  831 + materialType: r.materialType != null ? String(r.materialType) : '',
  832 + quantity: r.quantity != null ? String(r.quantity) : '',
  833 + actualPurchasePrice: r.actualPurchasePrice != null ? String(r.actualPurchasePrice) : '',
  834 + includingShippingPrice: r.includingShippingPrice != null ? String(r.includingShippingPrice) : '',
  835 + priceListPrices: r.priceListPrices != null ? String(r.priceListPrices) : '',
  836 + coordinationRange: r.coordinationRange != null ? String(r.coordinationRange) : '',
  837 + estimatedLoss: r.estimatedLoss != null ? String(r.estimatedLoss) : '',
  838 + applicationAttrition: r.applicationAttrition != null ? String(r.applicationAttrition) : '',
  839 + paintDamageRatio: r.paintDamageRatio != null ? String(r.paintDamageRatio) : '',
  840 + workshopId: self.pickId(r.workshopId),
  841 + itemId: itemId
  842 + }
  843 + })
  844 + var body = {
  845 + procurementPlanId: this.form.planId || d.id || '',
  846 + changeReason: d.changeReason != null ? String(d.changeReason) : '',
  847 + code: d.code != null ? String(d.code) : '',
  848 + companyShortId: this.pickId(d.companyShortId || d.companyId),
  849 + supplierId: this.pickId(d.supplierId),
  850 + purchaseDepartment: this.pickId(d.purchaseDepartment),
  851 + region: this.pickId(d.region),
  852 + date: d.date != null ? String(d.date).slice(0, 10) : '',
  853 + validityPeriod: d.validityPeriod != null ? String(d.validityPeriod) : '',
  854 + quoterId: this.pickId(d.quoterId),
  855 + workshopId: this.pickId(workshopId),
  856 + quoterName: d.quoterName != null ? String(d.quoterName) : '',
  857 + longTermOperation: this.boolToStr(d.longTermOperation),
  858 + terminalCustomer: this.boolToStr(d.terminalCustomer),
  859 + priced: this.boolToStr(d.priced),
  860 + pricingDeadline: d.pricingDeadline != null ? String(d.pricingDeadline) : '',
  861 + temporaryPrice: this.boolToStr(d.temporaryPrice),
  862 + otherExpenseSettlement: this.boolToStr(d.otherExpenseSettlement),
  863 + deliveryMode: d.deliveryMode != null ? String(d.deliveryMode) : '',
  864 + commodityBuyout: this.boolToStr(d.commodityBuyout),
  865 + qualityBuyout: this.boolToStr(d.qualityBuyout),
  866 + quantityBuyout: this.boolToStr(d.quantityBuyout),
  867 + doorDelivery: this.boolToStr(d.doorDelivery),
  868 + shippingCost: d.shippingCost != null ? String(d.shippingCost) : '',
  869 + loadingFee: d.loadingFee != null ? String(d.loadingFee) : '',
  870 + invoiceProductName: d.invoiceProductName != null ? String(d.invoiceProductName) : '',
  871 + deliveryDate: d.deliveryDate != null ? String(d.deliveryDate) : '',
  872 + settlementMethod: d.settlementMethod != null ? String(d.settlementMethod) : '',
  873 + settlementRatio: d.settlementRatio != null ? String(d.settlementRatio) : '',
  874 + priceId: this.pickId(d.priceId),
  875 + coordinationReason: d.coordinationReason != null ? String(d.coordinationReason) : '',
  876 + invoiceTypeStatus: d.invoiceTypeStatus != null ? String(d.invoiceTypeStatus) : '',
  877 + totalQuantity: d.totalQuantity != null ? String(d.totalQuantity) : '',
  878 + remark: d.remark != null ? String(d.remark) : '',
  879 + materialConditionEnabled: this.boolToStr(d.materialConditionEnabled),
  880 + lines: lineList
  881 + }
  882 + this.materialConditionConfigs.forEach(function (mc) {
  883 + body[mc.field] = self.joinStr(d[mc.field])
  884 + })
  885 + return body
  886 + },
  887 + async onSubmit() {
  888 + if (!this.validateForm()) return
  889 + var payload = this.buildPayload()
  890 + try {
  891 + await procurementPlanChangeCreateApi(payload)
  892 + uni.showToast({ title: '保存成功', icon: 'none' })
  893 + try {
  894 + uni.setStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH', '1')
  895 + } catch (e) {}
  896 + var self = this
  897 + setTimeout(function () {
  898 + uni.navigateTo({ url: '/pages/schedule-plan/index' })
  899 + }, 400)
  900 + } catch (e) {
  901 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : '保存失败', icon: 'none' })
  902 + }
  903 + }
  904 + }
  905 +}
  906 +</script>
  907 +
  908 +<style lang="scss" scoped>
  909 +.page {
  910 + display: flex;
  911 + flex-direction: column;
  912 + height: 100%;
  913 +}
  914 +.scroll {
  915 + flex: 1;
  916 + padding: 12rpx 0 392rpx !important;
  917 +}
  918 +.bottom-bar {
  919 + z-index: 2;
  920 + position: fixed;
  921 + left: 0;
  922 + right: 0;
  923 + bottom: 0;
  924 + padding: 32rpx;
  925 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  926 + background: #fff;
  927 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  928 + display: flex;
  929 + gap: 24rpx;
  930 + .btn {
  931 + flex: 1;
  932 + height: 80rpx;
  933 + line-height: 80rpx;
  934 + border-radius: 12rpx;
  935 + font-size: 32rpx;
  936 + }
  937 + .btn-outline {
  938 + background: #fff;
  939 + color: $theme-primary;
  940 + border: 2rpx solid $theme-primary;
  941 + }
  942 + .btn-primary {
  943 + background: $theme-primary;
  944 + color: #fff;
  945 + border: 2rpx solid $theme-primary;
  946 + }
  947 +}
  948 +
  949 +::v-deep .uni-list {
  950 + .uni-easyinput {
  951 + display: flex;
  952 + .uni-input-input {
  953 + color: rgba(0, 0, 0, 0.9);
  954 + }
  955 + }
  956 + .uni-input-placeholder { z-index: 1; }
  957 + .uni-input-input { background-color: #ffffff; }
  958 + background: transparent;
  959 + &-item {
  960 + &__extra-text { font-size: 32rpx; }
  961 + &__content-title {
  962 + font-size: 32rpx;
  963 + color: rgba(0, 0, 0, 0.9);
  964 + }
  965 + &__container {
  966 + padding: 32rpx;
  967 + .uni-easyinput {
  968 + &__placeholder-class {
  969 + font-size: 32rpx;
  970 + color: rgba(0, 0, 0, 0.4);
  971 + }
  972 + &__content {
  973 + border: none;
  974 + background-color: #ffffff !important;
  975 + &-input {
  976 + padding-left: 0 !important;
  977 + height: 48rpx;
  978 + line-height: 48rpx;
  979 + font-size: 32rpx;
  980 + }
  981 + .content-clear-icon {
  982 + font-size: 44rpx !important;
  983 + }
  984 + }
  985 + }
  986 + .item-title,
  987 + .uni-list-item__content {
  988 + flex: none;
  989 + min-height: 48rpx;
  990 + line-height: 48rpx;
  991 + font-size: 32rpx;
  992 + position: relative;
  993 + width: 240rpx;
  994 + margin-right: 32rpx;
  995 + color: rgba(0, 0, 0, 0.9);
  996 + .required {
  997 + color: red;
  998 + position: absolute;
  999 + top: 50%;
  1000 + transform: translateY(-50%);
  1001 + left: -16rpx;
  1002 + }
  1003 + }
  1004 + }
  1005 + &.select-item {
  1006 + &.is-empty {
  1007 + .uni-list-item__extra-text {
  1008 + color: rgba(0, 0, 0, 0.4) !important;
  1009 + }
  1010 + }
  1011 + &.is-filled {
  1012 + .uni-list-item__extra-text {
  1013 + color: rgba(0, 0, 0, 0.9) !important;
  1014 + }
  1015 + }
  1016 + .serial-number-row {
  1017 + display: flex;
  1018 + align-items: center;
  1019 + }
  1020 + }
  1021 + }
  1022 +}
  1023 +
  1024 +.readonly-text {
  1025 + color: rgba(0, 0, 0, 0.9);
  1026 + font-size: 32rpx;
  1027 + line-height: 48rpx;
  1028 + text-align: right;
  1029 + white-space: pre-wrap;
  1030 + word-break: break-all;
  1031 +}
  1032 +.value-code {
  1033 + width: 260rpx;
  1034 + text-align: left;
  1035 +}
  1036 +
  1037 +.attach-list {
  1038 + flex: 1;
  1039 + display: flex;
  1040 + flex-direction: column;
  1041 + align-items: flex-end;
  1042 + gap: 8rpx;
  1043 +}
  1044 +.attach-item {
  1045 + display: flex;
  1046 + align-items: center;
  1047 + gap: 16rpx;
  1048 + .attach-name { font-size: 26rpx; color: rgba(0,0,0,0.9); }
  1049 + .attach-view { font-size: 26rpx; color: $theme-primary; }
  1050 +}
  1051 +
  1052 +.material-condition-section,
  1053 +.remark-section {
  1054 + margin-top: 20rpx;
  1055 + background: #fff;
  1056 +}
  1057 +.section-header {
  1058 + display: flex;
  1059 + align-items: center;
  1060 + padding: 24rpx 32rpx;
  1061 + border-bottom: 1rpx solid #f0f0f0;
  1062 +}
  1063 +.section-title {
  1064 + position: relative;
  1065 + font-size: 32rpx;
  1066 + color: rgba(0, 0, 0, 0.9);
  1067 + font-weight: 600;
  1068 + .required {
  1069 + color: red;
  1070 + position: absolute;
  1071 + top: 50%;
  1072 + transform: translateY(-50%);
  1073 + left: -16rpx;
  1074 + }
  1075 +}
  1076 +.opCollapse {
  1077 + width: 32rpx;
  1078 + height: 28rpx;
  1079 + margin-right: 16rpx;
  1080 + margin-top: 8rpx;
  1081 +}
  1082 +.section-content {
  1083 + padding: 32rpx;
  1084 +}
  1085 +.form-row {
  1086 + display: flex;
  1087 + align-items: center;
  1088 + justify-content: space-between;
  1089 + margin-bottom: 24rpx;
  1090 +}
  1091 +.form-row:last-child { margin-bottom: 0; }
  1092 +.form-label {
  1093 + font-size: 32rpx;
  1094 + color: rgba(0, 0, 0, 0.9);
  1095 +}
  1096 +.form-value {
  1097 + font-size: 32rpx;
  1098 + color: rgba(0, 0, 0, 0.9);
  1099 +}
  1100 +.toggle-link {
  1101 + color: $theme-primary;
  1102 +}
  1103 +.material-group {
  1104 + margin-top: 32rpx;
  1105 +}
  1106 +.material-label {
  1107 + display: block;
  1108 + font-size: 30rpx;
  1109 + color: rgba(0, 0, 0, 0.9);
  1110 + margin-bottom: 20rpx;
  1111 +}
  1112 +.tag-list {
  1113 + display: flex;
  1114 + flex-wrap: wrap;
  1115 + gap: 16rpx;
  1116 +}
  1117 +.tag-btn {
  1118 + padding: 12rpx 24rpx;
  1119 + border: 1rpx solid #ddd;
  1120 + border-radius: 8rpx;
  1121 + font-size: 28rpx;
  1122 + color: #666;
  1123 + background: #fff;
  1124 +}
  1125 +.tag-btn.active {
  1126 + background: $theme-primary;
  1127 + border-color: $theme-primary;
  1128 + color: #fff;
  1129 +}
  1130 +
  1131 +::v-deep .uni-easyinput {
  1132 + width: 100%;
  1133 + &__content {
  1134 + background: #f8f8f8 !important;
  1135 + border-radius: 8rpx;
  1136 + &-input { font-size: 30rpx; }
  1137 + }
  1138 +}
  1139 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <view class="detail-page">
  5 + <view class="section">
  6 + <text class="row company">{{ safeText(form.code) }}</text>
  7 + <view class="row"><text class="label">公司简称</text><text class="value">{{ safeText(form.companyShortName || form.companyName) }}</text></view>
  8 + <view class="row"><text class="label">供应商名称</text><text class="value">{{ safeText(form.supplierName) }}</text></view>
  9 + <view class="row"><text class="label">采购处</text><text class="value">{{ safeText(form.purchaseDepartmentName || form.purchaseDepartment) }}</text></view>
  10 + <view class="row"><text class="label">区域</text><text class="value">{{ safeText(form.regionName || form.region) }}</text></view>
  11 + <view class="row"><text class="label">日期</text><text class="value">{{ formatDateOnly(form.date) }}</text></view>
  12 + <view class="row"><text class="label">报价时效</text><text class="value">{{ safeText(form.validityPeriod) }}</text></view>
  13 + <view class="row"><text class="label">报价人</text><text class="value">{{ safeText(form.quoterName) }}</text></view>
  14 + <view class="row"><text class="label">是否长单操作</text><text class="value">{{ boolText(form.longTermOperation) }}</text></view>
  15 + <view class="row"><text class="label">是否终端客户</text><text class="value">{{ boolText(form.terminalCustomer) }}</text></view>
  16 + <view class="row"><text class="label">是否未点价</text><text class="value">{{ boolText(form.priced) }}</text></view>
  17 + <view v-if="form.priced === true" class="row"><text class="label">点价截止日期</text><text class="value">{{ formatDateOnly(form.pricingDeadline) }}</text></view>
  18 + <view v-if="form.priced === true" class="row"><text class="label">是否暂定价</text><text class="value">{{ boolText(form.temporaryPrice) }}</text></view>
  19 + <view class="row"><text class="label">其他费用凭票到厂另行结算</text><text class="value">{{ boolText(form.otherExpenseSettlement) }}</text></view>
  20 + <view class="row"><text class="label">交提货方式</text><text class="value">{{ getDeliveryMethodLabel() }}</text></view>
  21 + <view class="row"><text class="label">是否通货买断</text><text class="value">{{ boolText(form.commodityBuyout) }}</text></view>
  22 + <view class="row"><text class="label">是否质量买断</text><text class="value">{{ boolText(form.qualityBuyout) }}</text></view>
  23 + <view class="row"><text class="label">是否数量买断</text><text class="value">{{ boolText(form.quantityBuyout) }}</text></view>
  24 + <view class="row"><text class="label">是否送货上门</text><text class="value">{{ boolText(form.doorDelivery) }}</text></view>
  25 + <view class="row"><text class="label">另付运费</text><text class="value">{{ formatNumber(form.shippingCost) }}</text></view>
  26 + <view class="row"><text class="label">装车费</text><text class="value">{{ formatNumber(form.loadingFee) }}</text></view>
  27 + <view class="row"><text class="label">开票品名</text><text class="value">{{ safeText(form.invoiceProductName) }}</text></view>
  28 + <view class="row"><text class="label">交货日期</text><text class="value">{{ formatDateOnly(form.deliveryDate) }}</text></view>
  29 + <view class="row"><text class="label">结算方式</text><text class="value">{{ safeText(form.settlementMethod) }}</text></view>
  30 + <view class="row"><text class="label">结算比例(%)</text><text class="value">{{ formatNumber(form.settlementRatio) }}</text></view>
  31 + <view class="row"><text class="label">价格表编号</text><text class="value">{{ priceTableDisplay }}</text></view>
  32 + <view class="row"><text class="label">协调事由</text><text class="value">{{ safeText(form.coordinationReason) }}</text></view>
  33 + <view class="row"><text class="label">票类状况</text><text class="value">{{ safeText(form.invoiceTypeStatus) }}</text></view>
  34 + <view class="row"><text class="label">数量合计</text><text class="value">{{ formatNumber(form.totalQuantity) }}</text></view>
  35 + <view class="row" v-if="attachmentList.length">
  36 + <text class="label">附件</text>
  37 + <view class="attach-list">
  38 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  39 + <text class="attach-name">{{ at.name }}</text>
  40 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  41 + </view>
  42 + </view>
  43 + </view>
  44 + </view>
  45 +
  46 + <view class="title-header">
  47 + <image class="title-header_icon" src="/static/images/title.png" />
  48 + <span>明细信息</span>
  49 + </view>
  50 + <view v-if="lineListWithName.length" class="section">
  51 + <view v-for="(line, idx) in lineListWithName" :key="line.itemId || idx" class="line-block">
  52 + <view class="line-title">明细{{ idx + 1 }}</view>
  53 + <view class="row"><text class="label">品种</text><text class="value">{{ safeText(line.productName) }}</text></view>
  54 + <view class="row"><text class="label">料型</text><text class="value">{{ safeText(line.materialType) }}</text></view>
  55 + <view class="row"><text class="label">数量(吨)</text><text class="value">{{ formatNumber(line.quantity) }}</text></view>
  56 + <view class="row"><text class="label">实际采购价</text><text class="value">{{ formatNumber(line.actualPurchasePrice) }}</text></view>
  57 + <view class="row"><text class="label">含运到厂价</text><text class="value">{{ formatNumber(line.includingShippingPrice) }}</text></view>
  58 + <view class="row"><text class="label">价格表价格</text><text class="value">{{ formatNumber(line.priceListPrices) }}</text></view>
  59 + <view class="row"><text class="label">协调幅度</text><text class="value">{{ formatNumber(line.coordinationRange) }}</text></view>
  60 + <view class="row"><text class="label">买断料预计损耗</text><text class="value">{{ formatNumber(line.estimatedLoss) }}</text></view>
  61 + <view class="row"><text class="label">申请损耗(%)</text><text class="value">{{ formatNumber(line.applicationAttrition) }}</text></view>
  62 + <view class="row"><text class="label">选择分厂</text><text class="value">{{ safeText(line.workshopName) }}</text></view>
  63 + </view>
  64 + </view>
  65 + <view v-else class="section empty-tip">暂无明细</view>
  66 +
  67 + <view class="title-header">
  68 + <image class="title-header_icon" src="/static/images/title.png" />
  69 + <span>料质状况</span>
  70 + </view>
  71 + <view class="section">
  72 + <view class="row"><text class="label">是否启用料质状况</text><text class="value">{{ boolText(form.materialConditionEnabled) }}</text></view>
  73 + <template v-if="form.materialConditionEnabled">
  74 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  75 + <text class="material-label">{{ mc.label }}</text>
  76 + <view class="tag-list">
  77 + <view v-for="opt in getDictOptions(mc.dictCode)" :key="opt.code" class="tag-btn" :class="{ active: isTagSelected(mc.field, opt.code) }">{{ opt.name }}</view>
  78 + </view>
  79 + </view>
  80 + </template>
  81 + </view>
  82 +
  83 + <view class="title-header">
  84 + <image class="title-header_icon" src="/static/images/title.png" />
  85 + <span>备注</span>
  86 + </view>
  87 + <view class="section">
  88 + <text class="remark-text">{{ safeText(form.remark) }}</text>
  89 + </view>
  90 +
  91 + <view class="title-header">
  92 + <image class="title-header_icon" src="/static/images/title.png" />
  93 + <span>变更事由</span>
  94 + </view>
  95 + <view class="section">
  96 + <text class="remark-text">{{ safeText(form.changeReason) }}</text>
  97 + </view>
  98 + </view>
  99 + </scroll-view>
  100 + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  101 + </view>
  102 +</template>
  103 +
  104 +<script>
  105 +import { procurementPlanChangeFindByIdApi, procurementPlanChangeSubmitApi, procurementPlanChangeCancelApi } from '@/api/procure-manage/procurementPlan.js'
  106 +import { breedRelationshipQueryApi, priceTableDetailApi, workshopQueryApi } from '@/api/devManage.js'
  107 +import { getDicByCodes } from '@/utils/dic.js'
  108 +import DetailButtons from '@/components/detail-buttons/index.vue'
  109 +export default {
  110 + name: 'SchedulePlanDetail',
  111 + components: { DetailButtons },
  112 + data() {
  113 + return {
  114 + id: '',
  115 + form: {},
  116 + lineList: [],
  117 + attachmentList: [],
  118 + materialConditionConfigs: [
  119 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  120 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  121 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  122 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  123 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  124 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  125 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  126 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  127 + ],
  128 + dictData: {},
  129 + productOptions: [],
  130 + workshopOptions: [],
  131 + buttons: [
  132 + { text: '编辑', visible: true, variant: 'outline', event: 'edit' },
  133 + { text: '发起变更审核', visible: true, variant: 'primary', event: 'initiate' },
  134 + { text: '取消', visible: true, variant: 'outline', event: 'cancel' },
  135 + { text: '审核', visible: true, variant: 'primary', event: 'approve' },
  136 + { text: '审核详情', visible: true, event: 'approveDetail' },
  137 + ],
  138 + }
  139 + },
  140 + computed: {
  141 + productMap() {
  142 + var list = Array.isArray(this.productOptions) ? this.productOptions : []
  143 + var m = {}
  144 + list.forEach(function (o) {
  145 + var key = String(o.productId || o.id || o.value || '')
  146 + if (key) m[key] = o
  147 + })
  148 + return m
  149 + },
  150 + workshopMap() {
  151 + var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  152 + var m = {}
  153 + list.forEach(function (o) {
  154 + var key = String(o.workshopId || o.id || o.value || '')
  155 + if (key) m[key] = o
  156 + })
  157 + return m
  158 + },
  159 + lineListWithName() {
  160 + var self = this
  161 + var list = Array.isArray(this.lineList) ? this.lineList : []
  162 + return list.map(function (row) {
  163 + var pid = String(row.productId || '')
  164 + var wid = String(row.workshopId || '')
  165 + var p = pid ? self.productMap[pid] : null
  166 + var w = wid ? self.workshopMap[wid] : null
  167 + return Object.assign({}, row, {
  168 + productName: row.productName || (p ? (p.productName || p.name || p.label || '') : ''),
  169 + workshopName: row.workshopName || (w ? (w.workshopName || w.name || w.label || '') : '')
  170 + })
  171 + })
  172 + },
  173 + priceTableDisplay() {
  174 + var d = this.form || {}
  175 + var code = d.priceTableCode != null ? String(d.priceTableCode).trim() : ''
  176 + var name = d.priceTableName || ''
  177 + if (name || code) {
  178 + return (name ? name + (code ? ' (' + code + ')' : '') : String(code))
  179 + }
  180 + return '-'
  181 + },
  182 + displayButtons() {
  183 + const status = this.form ? this.form.approvalStatus : '';
  184 + const isDraft = status === 'DRAFT';
  185 + const isAudit = status === 'AUDIT';
  186 + const isPass = status === 'PASS';
  187 + const isRefuse = status === 'REFUSE';
  188 + const canExamine = isAudit && this.form && this.form.showExamine === true;
  189 + return [
  190 + { ...this.buttons[0], visible: ((isDraft || isRefuse) && this.$auth.hasPermi('plan-manage:schedule-plan:modify')) },
  191 + { ...this.buttons[1], visible: ((isDraft || isRefuse) && this.$auth.hasPermi('plan-manage:schedule-plan:initiate')) },
  192 + { ...this.buttons[2], visible: (isRefuse && this.$auth.hasPermi('plan-manage:schedule-plan:cancel')) },
  193 + { ...this.buttons[3], visible: (canExamine && this.$auth.hasPermi('plan-manage:schedule-plan:approve')) },
  194 + { ...this.buttons[4], visible: ((isAudit || isPass) && this.form.showExamine && this.$auth.hasPermi('plan-manage:schedule-plan:view')) },
  195 + ]
  196 + }
  197 + },
  198 + onLoad(query) {
  199 + this.id = (query && query.id) || ''
  200 + this.loadDictData()
  201 + this.loadRefData()
  202 + this.loadDetail()
  203 + },
  204 + methods: {
  205 + handleButtonClick(btn) {
  206 + if (!btn || btn.disabled) return
  207 + const e = btn.event || ''
  208 + if (e === 'edit') return this.onEdit()
  209 + if (e === 'initiate') return this.onInitiate()
  210 + if (e === 'approve') return this.onApprove()
  211 + if (e === 'approveDetail') return this.onApproveDetail()
  212 + if (e === 'cancel') return this.onCancel()
  213 + },
  214 + refreshListFlags() {
  215 + try {
  216 + uni.setStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH', '1')
  217 + } catch (e) {}
  218 + },
  219 + runWithConfirm(opts) {
  220 + var self = this
  221 + var title = opts.title || '提示'
  222 + var content = opts.content || ''
  223 + var run = opts.run
  224 + var loading = opts.loading || '处理中'
  225 + var successText = opts.successText || '操作成功'
  226 + var failText = opts.failText || '操作失败'
  227 + if (!this.id) {
  228 + uni.showToast({ title: '缺少单据id', icon: 'none' })
  229 + return
  230 + }
  231 + var apiFn = function () {
  232 + uni.showLoading({ title: loading, mask: true })
  233 + Promise.resolve(run(self.id)).then(function () {
  234 + uni.hideLoading()
  235 + uni.showToast({ title: successText, icon: 'none' })
  236 + self.refreshListFlags()
  237 + self.loadDetail()
  238 + }).catch(function (e) {
  239 + uni.hideLoading()
  240 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : failText, icon: 'none' })
  241 + })
  242 + }
  243 + if (opts.skipConfirm) {
  244 + apiFn()
  245 + return
  246 + }
  247 + uni.showModal({
  248 + title: title,
  249 + content: content,
  250 + confirmText: '确定',
  251 + cancelText: '取消',
  252 + success: function (res) {
  253 + if (!res || !res.confirm) return
  254 + apiFn()
  255 + }
  256 + })
  257 + },
  258 + onInitiate() {
  259 + this.runWithConfirm({
  260 + title: '发起变更审核',
  261 + content: '确认发起变更审核吗',
  262 + loading: '提交中',
  263 + successText: '发起成功',
  264 + failText: '发起变更审核失败',
  265 + run: function (id) { return procurementPlanChangeSubmitApi(id) }
  266 + })
  267 + },
  268 + onEdit() {
  269 + if (!this.id) {
  270 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  271 + return
  272 + }
  273 + uni.navigateTo({ url: '/pages/schedule-plan/modify?id=' + this.id })
  274 + },
  275 + async loadDictData() {
  276 + var codes = [].concat(
  277 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  278 + ['DELIVERY_METHOD']
  279 + )
  280 + try {
  281 + var results = await getDicByCodes(codes)
  282 + var d = results || {}
  283 + this.dictData = d
  284 + this.deliveryOptions = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  285 + } catch (e) {
  286 + this.dictData = {}
  287 + this.deliveryOptions = []
  288 + }
  289 + },
  290 + async loadRefData() {
  291 + var self = this
  292 + try {
  293 + var results = await Promise.all([
  294 + this.pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  295 + this.pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  296 + ])
  297 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  298 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  299 + self.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  300 + self.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  301 + } catch (e) {
  302 + self.productOptions = []
  303 + self.workshopOptions = []
  304 + }
  305 + },
  306 + pCall(fn, params) {
  307 + try {
  308 + return Promise.resolve(fn(params))
  309 + } catch (e) {
  310 + return Promise.reject(e)
  311 + }
  312 + },
  313 + async loadDetail() {
  314 + if (!this.id) return
  315 + try {
  316 + var res = await procurementPlanChangeFindByIdApi({ id: this.id })
  317 + var d = (res && res.data) ? res.data : {}
  318 + var boolFields = ['longTermOperation', 'terminalCustomer', 'priced', 'temporaryPrice', 'otherExpenseSettlement', 'commodityBuyout', 'qualityBuyout', 'quantityBuyout', 'doorDelivery', 'materialConditionEnabled']
  319 + boolFields.forEach(function (f) {
  320 + var v = d[f]
  321 + if (typeof v === 'string') {
  322 + d[f] = v === 'true' || v === '1'
  323 + } else if (typeof v === 'number') {
  324 + d[f] = v === 1
  325 + } else {
  326 + d[f] = !!v
  327 + }
  328 + })
  329 + this.materialConditionConfigs.forEach(function (mc) {
  330 + var v = d[mc.field]
  331 + if (typeof v === 'string' && v) {
  332 + d[mc.field] = v.split(',').filter(Boolean)
  333 + } else if (!Array.isArray(v)) {
  334 + d[mc.field] = []
  335 + }
  336 + })
  337 + this.form = d
  338 + var lines = d.lines || d.procurementPlanLineList || d.lineList || []
  339 + this.lineList = Array.isArray(lines) ? lines : []
  340 + this.buildAttachmentList()
  341 + this.fetchPriceDetailAndApply(d.priceId)
  342 + } catch (e) {
  343 + uni.showToast({ title: '加载详情失败', icon: 'none' })
  344 + }
  345 + },
  346 + buildAttachmentList() {
  347 + var d = this.form || {}
  348 + var ids = d.attachmentFileIds
  349 + var names = d.attachmentFileNames
  350 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  351 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  352 + var len = Math.max(idArr.length, nameArr.length)
  353 + var list = []
  354 + for (var i = 0; i < len; i++) {
  355 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  356 + }
  357 + this.attachmentList = list
  358 + },
  359 + async fetchPriceDetailAndApply(priceId) {
  360 + if (!priceId) return
  361 + var self = this
  362 + try {
  363 + var res = await priceTableDetailApi({ id: priceId })
  364 + var d = (res && res.data) ? res.data : {}
  365 + if (d.code != null && this.form) {
  366 + this.$set(this.form, 'priceTableCode', String(d.code))
  367 + }
  368 + if (d.priceTableName != null && this.form) {
  369 + this.$set(this.form, 'priceTableName', d.priceTableName)
  370 + }
  371 + var priceLines = self.extractPriceLines(d)
  372 + self.applyPriceLinesToLines(priceLines)
  373 + } catch (e) {
  374 + return
  375 + }
  376 + },
  377 + extractPriceLines(priceDetail) {
  378 + if (!priceDetail || typeof priceDetail !== 'object') return []
  379 + var candidates = [
  380 + priceDetail.procurementPriceLineList,
  381 + priceDetail.priceSubTableList,
  382 + priceDetail.priceLineList,
  383 + priceDetail.priceList,
  384 + priceDetail.lineList,
  385 + priceDetail.datas,
  386 + priceDetail.records,
  387 + priceDetail.list
  388 + ]
  389 + for (var i = 0; i < candidates.length; i++) {
  390 + if (Array.isArray(candidates[i]) && candidates[i].length) return candidates[i]
  391 + }
  392 + for (var k in priceDetail) {
  393 + if (!Object.prototype.hasOwnProperty.call(priceDetail, k)) continue
  394 + if (Array.isArray(priceDetail[k])) {
  395 + var arr = priceDetail[k]
  396 + if (arr.length && arr[0] && typeof arr[0] === 'object' && (arr[0].price != null || arr[0].productId != null || arr[0].breedId != null || arr[0].varietyId != null)) {
  397 + return arr
  398 + }
  399 + }
  400 + }
  401 + return []
  402 + },
  403 + buildPriceMap(priceLines) {
  404 + var m = {}
  405 + if (!Array.isArray(priceLines)) return m
  406 + for (var i = 0; i < priceLines.length; i++) {
  407 + var line = priceLines[i] || {}
  408 + if (line.price == null) continue
  409 + var key = String(line.productId || line.breedId || line.varietyId || line.id || ('__idx_' + i))
  410 + m[key] = { price: Number(line.price), meta: line }
  411 + }
  412 + return m
  413 + },
  414 + applyPriceLinesToLines(priceLines) {
  415 + if (!Array.isArray(this.lineList)) return
  416 + var priceMap = this.buildPriceMap(priceLines)
  417 + var self = this
  418 + this.lineList = this.lineList.map(function (row) {
  419 + var pid = String(row.productId || row.breedId || row.varietyId || '')
  420 + var price = null
  421 + if (pid && priceMap[pid] != null) {
  422 + price = priceMap[pid].price
  423 + } else {
  424 + var pname = (row.productName || '').trim()
  425 + if (pname) {
  426 + for (var k in priceMap) {
  427 + if (!Object.prototype.hasOwnProperty.call(priceMap, k)) continue
  428 + var meta = priceMap[k] && priceMap[k].meta ? priceMap[k].meta : null
  429 + if (meta && ((meta.productName && meta.productName === pname) || (meta.breedName && meta.breedName === pname) || (meta.varietyName && meta.varietyName === pname))) {
  430 + price = priceMap[k].price
  431 + break
  432 + }
  433 + }
  434 + }
  435 + }
  436 + if (price != null) {
  437 + row.priceListPrices = Number(price).toFixed(2)
  438 + }
  439 + return row
  440 + })
  441 + },
  442 + getDictOptions(dictCode) {
  443 + var data = this.dictData[dictCode]
  444 + return (data && data.data) ? data.data : []
  445 + },
  446 + isTagSelected(field, code) {
  447 + var selected = this.form ? this.form[field] : undefined
  448 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  449 + if (typeof selected === 'string' && selected) {
  450 + return selected.split(',').indexOf(code) >= 0
  451 + }
  452 + return false
  453 + },
  454 + getDeliveryMethodLabel() {
  455 + var opts = this.deliveryOptions || []
  456 + var v = String(this.form.deliveryMode != null ? this.form.deliveryMode : '')
  457 + if (!v) return '-'
  458 + for (var i = 0; i < opts.length; i++) {
  459 + var o = opts[i]
  460 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  461 + if (code === v) return o.name || o.label || '-'
  462 + }
  463 + return v
  464 + },
  465 + boolText(v) {
  466 + if (typeof v === 'boolean') return v ? '是' : '否'
  467 + if (v === 'true' || v === '1' || v === 1) return '是'
  468 + if (v === 'false' || v === '0' || v === 0) return '否'
  469 + return '-'
  470 + },
  471 + formatDateOnly(v) {
  472 + var s = v == null ? '' : String(v).trim()
  473 + if (!s) return '-'
  474 + if (s.length >= 10) return s.slice(0, 10)
  475 + return s
  476 + },
  477 + safeText(v) {
  478 + var s = v == null ? '' : String(v)
  479 + return s.trim() ? s : '-'
  480 + },
  481 + formatNumber(v) {
  482 + if (v == null || v === '') return '-'
  483 + var n = Number(v)
  484 + if (isNaN(n)) return String(v)
  485 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  486 + },
  487 + onCancel() {
  488 + this.runWithConfirm({
  489 + title: '取消',
  490 + content: '确认取消该变更单吗?',
  491 + loading: '提交中',
  492 + successText: '取消成功',
  493 + failText: '取消失败',
  494 + run: function (id) { return procurementPlanChangeCancelApi(id) }
  495 + })
  496 + },
  497 + onApprove() {
  498 + const id = this.id || (this.form && this.form.id) || ''
  499 + if (!id) return
  500 + const CACHE_KEY = 'sourceBusinessId'
  501 + const TYPE = 'contractType'
  502 + uni.setStorageSync(TYPE, 'PLAN_CHANGE')
  503 + uni.setStorageSync(CACHE_KEY, id)
  504 + uni.navigateTo({ url: '/pages/flow/audit' })
  505 + },
  506 + onApproveDetail() {
  507 + const id = this.id || (this.form && this.form.id) || ''
  508 + if (!id) return
  509 + const CACHE_KEY = 'sourceBusinessId'
  510 + const TYPE = 'contractType'
  511 + uni.setStorageSync(TYPE, 'PLAN_CHANGE')
  512 + uni.setStorageSync(CACHE_KEY, id)
  513 + uni.navigateTo({ url: '/pages/flow/audit_detail' })
  514 + },
  515 + onPreviewAttachment(at) {
  516 + if (!at || !at.id) {
  517 + uni.showToast({ title: '无法查看', icon: 'none' })
  518 + return
  519 + }
  520 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  521 + }
  522 + }
  523 +}
  524 +</script>
  525 +
  526 +<style lang="scss" scoped>
  527 +.page {
  528 + display: flex;
  529 + flex-direction: column;
  530 + height: 100%;
  531 +}
  532 +.scroll {
  533 + flex: 1;
  534 + padding: 8rpx 0 144rpx;
  535 +}
  536 +.detail-page {
  537 + background: #f3f3f3;
  538 +}
  539 +.title-header {
  540 + display: flex;
  541 + align-items: center;
  542 + padding: 24rpx 32rpx 12rpx;
  543 + background-color: #ffffff;
  544 + .title-header_icon {
  545 + width: 36rpx;
  546 + height: 36rpx;
  547 + margin-right: 12rpx;
  548 + }
  549 + span {
  550 + font-size: 34rpx;
  551 + font-weight: 600;
  552 + color: rgba(0, 0, 0, 0.9);
  553 + }
  554 +}
  555 +.section {
  556 + padding: 32rpx;
  557 + background: #fff;
  558 + margin-bottom: 20rpx;
  559 +}
  560 +.row {
  561 + display: flex;
  562 + margin-bottom: 28rpx;
  563 + &:last-child { margin-bottom: 0; }
  564 + &.company {
  565 + font-size: 36rpx;
  566 + font-weight: 600;
  567 + color: rgba(0, 0, 0, 0.9);
  568 + padding-top: 8rpx;
  569 + line-height: 50rpx;
  570 + }
  571 + .label {
  572 + max-width: 420rpx;
  573 + margin-right: 20rpx;
  574 + line-height: 32rpx;
  575 + font-size: 28rpx;
  576 + color: rgba(0, 0, 0, 0.6);
  577 + }
  578 + .value {
  579 + flex: 1;
  580 + line-height: 32rpx;
  581 + font-size: 28rpx;
  582 + color: rgba(0, 0, 0, 0.9);
  583 + text-align: right;
  584 + word-break: break-all;
  585 + }
  586 +}
  587 +.line-block {
  588 + padding-bottom: 24rpx;
  589 + margin-bottom: 24rpx;
  590 + border-bottom: 1rpx solid #f0f0f0;
  591 + &:last-child {
  592 + padding-bottom: 0;
  593 + margin-bottom: 0;
  594 + border-bottom: none;
  595 + }
  596 +}
  597 +.line-title {
  598 + font-size: 30rpx;
  599 + font-weight: 600;
  600 + color: rgba(0, 0, 0, 0.9);
  601 + margin-bottom: 20rpx;
  602 +}
  603 +.attach-list {
  604 + flex: 1;
  605 + display: flex;
  606 + flex-direction: column;
  607 + align-items: flex-end;
  608 + gap: 8rpx;
  609 +}
  610 +.attach-item {
  611 + display: flex;
  612 + align-items: center;
  613 + gap: 16rpx;
  614 + .attach-name {
  615 + font-size: 26rpx;
  616 + color: rgba(0, 0, 0, 0.9);
  617 + }
  618 + .attach-view {
  619 + font-size: 26rpx;
  620 + color: $theme-primary;
  621 + }
  622 +}
  623 +.material-group {
  624 + margin-top: 32rpx;
  625 + &:first-child { margin-top: 0; }
  626 +}
  627 +.material-label {
  628 + display: block;
  629 + font-size: 28rpx;
  630 + color: rgba(0, 0, 0, 0.6);
  631 + margin-bottom: 20rpx;
  632 +}
  633 +.tag-list {
  634 + display: flex;
  635 + flex-wrap: wrap;
  636 + gap: 16rpx;
  637 +}
  638 +.tag-btn {
  639 + padding: 12rpx 24rpx;
  640 + border: 1rpx solid #ddd;
  641 + border-radius: 8rpx;
  642 + font-size: 28rpx;
  643 + color: #999;
  644 + background: #f5f5f5;
  645 +}
  646 +.tag-btn.active {
  647 + background: $theme-primary;
  648 + border-color: $theme-primary;
  649 + color: #fff;
  650 +}
  651 +.remark-text {
  652 + font-size: 28rpx;
  653 + color: rgba(0, 0, 0, 0.9);
  654 + line-height: 1.6;
  655 + white-space: pre-wrap;
  656 +}
  657 +.empty-tip {
  658 + text-align: center;
  659 + font-size: 28rpx;
  660 + color: rgba(0, 0, 0, 0.4);
  661 + padding: 24rpx 0;
  662 +}
  663 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <view class="plan-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 class="tool-icon" src="/static/images/dev_manage/filter_icon.png" @click="openFilter" />
  18 + <image v-if="$auth.hasPermi('plan-manage:schedule-plan:add')" class="tool-icon" src="/static/images/dev_manage/add_icon.png" @click="onAdd" />
  19 + </view>
  20 + </view>
  21 + </view>
  22 +
  23 + <view class="list-box">
  24 + <card-list
  25 + ref="cardRef"
  26 + :fetch-fn="fetchList"
  27 + :query="query"
  28 + :extra="extraParams"
  29 + row-key="id"
  30 + :enable-refresh="true"
  31 + :enable-load-more="true"
  32 + @loaded="onCardLoaded"
  33 + @error="onCardError"
  34 + >
  35 + <template v-slot="{ item }">
  36 + <view class="card" @click="onCardClick(item)">
  37 + <view class="card-header">
  38 + <text class="title omit2">{{ item.code || '-' }}</text>
  39 + <text :class="['status', `status_${item.approvalStatus}`]">{{ getAuditStatusText(item.approvalStatus) }}</text>
  40 + </view>
  41 + <view class="info-row">
  42 + <text>公司名称</text>
  43 + <text>{{item.companyShortName || '-' }}</text>
  44 + </view>
  45 + <view class="info-row">
  46 + <text>供应商名称</text>
  47 + <text>{{ item.supplierName || '-' }}</text>
  48 + </view>
  49 + <view class="info-row">
  50 + <text>数量</text>
  51 + <text>{{ formatQuantity(item.totalQuantity || 0) }}</text>
  52 + </view>
  53 + <view class="info-row">
  54 + <text>采购处</text>
  55 + <text>{{ item.purchaseDepartmentName || '-' }}</text>
  56 + </view>
  57 + </view>
  58 + </template>
  59 + </card-list>
  60 + </view>
  61 +
  62 + <filter-modal
  63 + :visible.sync="filterVisible"
  64 + :value.sync="filterForm"
  65 + title="筛选"
  66 + @reset="onFilterReset"
  67 + @confirm="onFilterConfirm"
  68 + >
  69 + <template v-slot="{ model }">
  70 + <view class="filter-form">
  71 + <view class="form-item">
  72 + <view class="label">编号</view>
  73 + <input class="input" v-model="model.code" placeholder="请输入编号" />
  74 + </view>
  75 + <view class="form-item">
  76 + <view class="label">供应商名称</view>
  77 + <input class="input" v-model="model.supplierName" placeholder="请输入供应商名称" />
  78 + </view>
  79 + <view class="form-item">
  80 + <view class="label">日期</view>
  81 + <uni-datetime-picker type="daterange" v-model="model.dateRange" start="2023-01-01" />
  82 + </view>
  83 + </view>
  84 + </template>
  85 + </filter-modal>
  86 + </view>
  87 +</template>
  88 +
  89 +<script>
  90 +import CardList from '@/components/card/index.vue'
  91 +import FilterModal from '@/components/filter/index.vue'
  92 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  93 +import { procurementPlanChangeQueryApi } from '@/api/procure-manage/procurementPlan.js'
  94 +
  95 +export default {
  96 + name: 'SchedulePlan',
  97 + components: { CardList, FilterModal },
  98 + data() {
  99 + return {
  100 + searchKeyword: '',
  101 + searchKeywordDebounced: '',
  102 + searchDebounceTimer: null,
  103 + query: {
  104 + code: '',
  105 + supplierName: '',
  106 + dateRange: []
  107 + },
  108 + extraParams: {},
  109 + currentItems: [],
  110 + filterVisible: false,
  111 + filterForm: {
  112 + code: '',
  113 + supplierName: '',
  114 + dateRange: []
  115 + },
  116 + dicOptions: {
  117 + AUDIT_STATUS: []
  118 + }
  119 + }
  120 + },
  121 + computed: {
  122 + extraCombined() {
  123 + const keyword = this.searchKeywordDebounced || ''
  124 + return {
  125 + keyword: keyword || undefined
  126 + }
  127 + }
  128 + },
  129 + watch: {
  130 + extraCombined: {
  131 + deep: true,
  132 + handler(v) {
  133 + this.extraParams = v
  134 + },
  135 + immediate: true
  136 + }
  137 + },
  138 + created() {
  139 + this.loadDicData()
  140 + },
  141 + onShow() {
  142 + let needRefresh = ''
  143 + try { needRefresh = uni.getStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH') } catch (e) {}
  144 + if (!needRefresh) return
  145 + try { uni.removeStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH') } catch (e) {}
  146 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.reload) {
  147 + this.$refs.cardRef.reload()
  148 + }
  149 + },
  150 + onReachBottom() {
  151 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.onLoadMore) {
  152 + this.$refs.cardRef.onLoadMore()
  153 + }
  154 + },
  155 + beforeDestroy() {
  156 + if (this.searchDebounceTimer) {
  157 + clearTimeout(this.searchDebounceTimer)
  158 + this.searchDebounceTimer = null
  159 + }
  160 + },
  161 + methods: {
  162 + onAdd() {
  163 + uni.navigateTo({ url: '/pages/schedule-plan/add' })
  164 + },
  165 + async loadDicData() {
  166 + try {
  167 + const results = await getDicByCodes(['AUDIT_STATUS'])
  168 + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || []
  169 + } catch (e) {
  170 + this.dicOptions.AUDIT_STATUS = []
  171 + }
  172 + },
  173 + getAuditStatusText(status) {
  174 + const v = status == null ? '' : String(status)
  175 + if (!v) return '-'
  176 + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v
  177 + },
  178 + getTotalQuantity(item) {
  179 + const lines = item && item.procurementPlanLineList && Array.isArray(item.procurementPlanLineList)
  180 + ? item.procurementPlanLineList
  181 + : []
  182 + let total = 0
  183 + lines.forEach(line => {
  184 + const q = line && line.quantity != null ? Number(line.quantity) : 0
  185 + if (!isNaN(q)) total += q
  186 + })
  187 + return total
  188 + },
  189 + formatQuantity(val) {
  190 + if (val == null) return '-'
  191 + try {
  192 + const num = Number(val)
  193 + if (isNaN(num)) return '-'
  194 + return num.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  195 + } catch (e) {
  196 + return String(val)
  197 + }
  198 + },
  199 + onCardLoaded(_ref) {
  200 + var items = _ref.items
  201 + this.currentItems = items
  202 + },
  203 + onCardError() {
  204 + uni.showToast({ title: '列表加载失败', icon: 'none' })
  205 + },
  206 + onSearchInput() {
  207 + var _this = this
  208 + if (this.searchDebounceTimer) clearTimeout(this.searchDebounceTimer)
  209 + this.searchDebounceTimer = setTimeout(function () {
  210 + _this.searchKeywordDebounced = _this.searchKeyword
  211 + _this.searchDebounceTimer = null
  212 + }, 1200)
  213 + },
  214 + search(e) {
  215 + const val = e && e.value != null ? e.value : this.searchKeyword
  216 + this.searchKeyword = val
  217 + this.searchKeywordDebounced = val
  218 + },
  219 + openFilter() {
  220 + this.filterForm = {
  221 + code: this.query.code || '',
  222 + supplierName: this.query.supplierName || '',
  223 + dateRange: Array.isArray(this.query.dateRange) ? this.query.dateRange.slice(0) : []
  224 + }
  225 + this.filterVisible = true
  226 + },
  227 + onFilterReset(payload) {
  228 + this.filterForm = payload
  229 + },
  230 + onFilterConfirm(payload) {
  231 + this.query = {
  232 + code: payload.code || '',
  233 + supplierName: payload.supplierName || '',
  234 + dateRange: Array.isArray(payload.dateRange) ? payload.dateRange : []
  235 + }
  236 + },
  237 + fetchList(_ref2) {
  238 + var _this2 = this
  239 + var pageIndex = _ref2.pageIndex
  240 + var pageSize = _ref2.pageSize
  241 + var query = _ref2.query
  242 + var extra = _ref2.extra
  243 + const q = query || {}
  244 + const e = extra || {}
  245 + const range = Array.isArray(q.dateRange) ? q.dateRange : []
  246 + const keyword = e.keyword || ''
  247 + const params = {
  248 + pageIndex: pageIndex,
  249 + pageSize: pageSize,
  250 + code: q.code || '',
  251 + supplierName: q.supplierName || '',
  252 + startDate: range && range.length === 2 ? range[0] : '',
  253 + endDate: range && range.length === 2 ? range[1] : ''
  254 + }
  255 + if (keyword) {
  256 + if (!params.code) params.code = keyword
  257 + if (!params.supplierName) params.supplierName = keyword
  258 + }
  259 + return procurementPlanChangeQueryApi(params).then(function (res) {
  260 + const _data = res && res.data ? res.data : {}
  261 + let records = _data.datas || _data.list || _data.records || []
  262 + const totalCount = _data.totalCount || _data.count || 0
  263 + const hasNext = _data.hasNext || false
  264 + records = records.map(function (it) { return Object.assign({}, it) })
  265 + return { records: records, totalCount: totalCount, hasNext: hasNext }
  266 + }).catch(function () {
  267 + _this2.onCardError()
  268 + return { records: [], totalCount: 0, hasNext: false }
  269 + })
  270 + },
  271 + onCardClick(item) {
  272 + uni.navigateTo({ url: '/pages/schedule-plan/detail?id=' + item.id })
  273 + }
  274 + }
  275 +}
  276 +</script>
  277 +
  278 +<style lang="scss" scoped>
  279 +.page {
  280 + display: flex;
  281 + flex-direction: column;
  282 + height: 100vh;
  283 +}
  284 +.plan-list-fixed {
  285 + position: fixed;
  286 + top: 96rpx;
  287 + left: 0;
  288 + right: 0;
  289 + z-index: 2;
  290 + background: #fff;
  291 + .search-row {
  292 + display: flex;
  293 + align-items: center;
  294 + padding: 16rpx 32rpx;
  295 + .uni-searchbar { padding: 0; flex: 1; }
  296 + .tool-icons {
  297 + display: flex;
  298 + .tool-icon { width: 48rpx; height: 48rpx; display: block; margin-left: 32rpx; }
  299 + }
  300 + }
  301 +}
  302 +::v-deep .uni-searchbar__box { height: 80rpx !important; justify-content: start; .uni-searchbar__box-search-input { font-size: 32rpx !important; } }
  303 +.list-box {
  304 + flex: 1;
  305 + padding-top: 140rpx;
  306 + .card { position: relative; }
  307 + .card-header {
  308 + margin-bottom: 28rpx;
  309 + position: relative;
  310 + .title { font-size: 36rpx; font-weight: 600; line-height: 50rpx; color: rgba(0,0,0,0.9); width: 578rpx; }
  311 + .status {
  312 + position: absolute;
  313 + top: -32rpx;
  314 + right: -12rpx;
  315 + height: 48rpx;
  316 + line-height: 48rpx;
  317 + font-weight: 600;
  318 + color: #fff;
  319 + font-size: 24rpx;
  320 + padding: 0 14rpx;
  321 + border-radius: 6rpx;
  322 + box-sizing: content-box;
  323 +
  324 + &.status_AUDIT {
  325 + background: $theme-primary;
  326 + }
  327 +
  328 + &.status_PASS {
  329 + background: #2BA471;
  330 + }
  331 +
  332 + &.status_REFUSE {
  333 + background: #D54941;
  334 + }
  335 +
  336 + &.status_CANCEL {
  337 + background: #E7E7E7;
  338 + color: rgba(0, 0, 0, 0.9);
  339 + }
  340 + }
  341 + }
  342 + .info-row {
  343 + display: flex;
  344 + align-items: center;
  345 + color: rgba(0,0,0,0.6);
  346 + font-size: 28rpx;
  347 + margin-bottom: 24rpx;
  348 + height: 32rpx;
  349 + &:last-child { margin-bottom: 0; }
  350 + text {
  351 + width: 50%;
  352 + &:last-child { color: rgba(0,0,0,0.9); width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  353 + }
  354 + }
  355 +}
  356 +.filter-form {
  357 + .form-item { margin-bottom: 24rpx; }
  358 + .label { margin-bottom: 20rpx; color: rgba(0,0,0,0.9); height: 44rpx; line-height: 44rpx; font-size: 30rpx; }
  359 + .input {
  360 + width: 100%;
  361 + height: 72rpx;
  362 + line-height: 72rpx;
  363 + padding: 0 24rpx;
  364 + border: 1rpx solid #E7E7E7;
  365 + border-radius: 8rpx;
  366 + font-size: 28rpx;
  367 + color: rgba(0,0,0,0.9);
  368 + background: #fff;
  369 + box-sizing: border-box;
  370 + }
  371 +}
  372 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view scroll-y class="scroll">
  4 + <uni-list>
  5 + <uni-list-item class="select-item" :class="form.planCode ? 'is-filled' : 'is-empty'">
  6 + <template v-slot:body>
  7 + <view class="item-title"><text class="required">*</text><text>计划数据</text></view>
  8 + </template>
  9 + <template v-slot:footer>
  10 + <text class="readonly-text">{{ form.planCode || '-' }}</text>
  11 + </template>
  12 + </uni-list-item>
  13 +
  14 + <uni-list-item title="公司名称">
  15 + <template v-slot:footer>
  16 + <uni-easyinput v-model="companyNameDisplay" :inputBorder="false" disabled placeholder="-" />
  17 + </template>
  18 + </uni-list-item>
  19 +
  20 + <uni-list-item>
  21 + <template v-slot:body>
  22 + <view class="item-title"><text class="required">*</text><text>供应商名称</text></view>
  23 + </template>
  24 + <template v-slot:footer>
  25 + <uni-easyinput v-model="detail.supplierName" :inputBorder="false" placeholder="请输入供应商名称" />
  26 + </template>
  27 + </uni-list-item>
  28 +
  29 + <uni-list-item title="采购处">
  30 + <template v-slot:footer>
  31 + <uni-easyinput v-model="purchaseDepartmentDisplay" :inputBorder="false" disabled placeholder="-" />
  32 + </template>
  33 + </uni-list-item>
  34 +
  35 + <uni-list-item title="区域">
  36 + <template v-slot:footer>
  37 + <uni-easyinput v-model="regionDisplay" :inputBorder="false" disabled placeholder="-" />
  38 + </template>
  39 + </uni-list-item>
  40 +
  41 + <uni-list-item title="日期">
  42 + <template v-slot:footer>
  43 + <uni-easyinput v-model="dateDisplay" :inputBorder="false" disabled placeholder="-" />
  44 + </template>
  45 + </uni-list-item>
  46 +
  47 + <uni-list-item>
  48 + <template v-slot:body>
  49 + <view class="item-title"><text class="required">*</text><text>报价时效</text></view>
  50 + </template>
  51 + <template v-slot:footer>
  52 + <uni-easyinput v-model="detail.validityPeriod" :inputBorder="false" placeholder="请输入报价时效" />
  53 + </template>
  54 + </uni-list-item>
  55 +
  56 + <uni-list-item>
  57 + <template v-slot:body>
  58 + <view class="item-title"><text class="required">*</text><text>报价人</text></view>
  59 + </template>
  60 + <template v-slot:footer>
  61 + <uni-easyinput v-model="detail.quoterName" :inputBorder="false" placeholder="请输入报价人" />
  62 + </template>
  63 + </uni-list-item>
  64 +
  65 + <uni-list-item class="select-item" :class="typeof detail.longTermOperation === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  66 + @click="toggleBool('longTermOperation')" :rightText="boolText(detail.longTermOperation) || '请选择'" showArrow>
  67 + <template v-slot:body>
  68 + <view class="item-title"><text class="required">*</text><text>是否长单操作</text></view>
  69 + </template>
  70 + </uni-list-item>
  71 +
  72 + <uni-list-item class="select-item" :class="typeof detail.terminalCustomer === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  73 + @click="toggleBool('terminalCustomer')" :rightText="boolText(detail.terminalCustomer) || '请选择'" showArrow>
  74 + <template v-slot:body>
  75 + <view class="item-title"><text class="required">*</text><text>是否终端客户</text></view>
  76 + </template>
  77 + </uni-list-item>
  78 +
  79 + <uni-list-item class="select-item" :class="typeof detail.priced === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  80 + @click="toggleBool('priced')" :rightText="boolText(detail.priced) || '请选择'" showArrow>
  81 + <template v-slot:body>
  82 + <view class="item-title"><text class="required">*</text><text>是否未点价</text></view>
  83 + </template>
  84 + </uni-list-item>
  85 +
  86 + <uni-list-item v-if="detail.priced === true">
  87 + <template v-slot:body>
  88 + <view class="item-title"><text class="required">*</text><text>点价截止日期</text></view>
  89 + </template>
  90 + <template v-slot:footer>
  91 + <uni-datetime-picker type="date" v-model="detail.pricingDeadline" return-type="string" />
  92 + </template>
  93 + </uni-list-item>
  94 +
  95 + <uni-list-item v-if="detail.priced === true" class="select-item" :class="typeof detail.temporaryPrice === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  96 + @click="toggleBool('temporaryPrice')" :rightText="boolText(detail.temporaryPrice) || '请选择'" showArrow>
  97 + <template v-slot:body>
  98 + <view class="item-title"><text class="required">*</text><text>是否暂定价</text></view>
  99 + </template>
  100 + </uni-list-item>
  101 +
  102 + <uni-list-item class="select-item" :class="typeof detail.otherExpenseSettlement === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  103 + @click="toggleBool('otherExpenseSettlement')" :rightText="boolText(detail.otherExpenseSettlement) || '请选择'" showArrow>
  104 + <template v-slot:body>
  105 + <view class="item-title"><text class="required">*</text><text>其他费用凭票到厂另行结算</text></view>
  106 + </template>
  107 + </uni-list-item>
  108 +
  109 + <uni-list-item class="select-item" :class="detail.deliveryMode ? 'is-filled' : 'is-empty'" clickable
  110 + @click="openDeliverySheet" :rightText="getDeliveryMethodLabel()" showArrow>
  111 + <template v-slot:body>
  112 + <view class="item-title"><text class="required">*</text><text>交提货方式</text></view>
  113 + </template>
  114 + </uni-list-item>
  115 +
  116 + <uni-list-item class="select-item" :class="typeof detail.commodityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  117 + @click="toggleBool('commodityBuyout')" :rightText="boolText(detail.commodityBuyout) || '请选择'" showArrow>
  118 + <template v-slot:body>
  119 + <view class="item-title"><text class="required">*</text><text>是否通货买断</text></view>
  120 + </template>
  121 + </uni-list-item>
  122 +
  123 + <uni-list-item class="select-item" :class="typeof detail.qualityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  124 + @click="toggleBool('qualityBuyout')" :rightText="boolText(detail.qualityBuyout) || '请选择'" showArrow>
  125 + <template v-slot:body>
  126 + <view class="item-title"><text class="required">*</text><text>是否质量买断</text></view>
  127 + </template>
  128 + </uni-list-item>
  129 +
  130 + <uni-list-item class="select-item" :class="typeof detail.quantityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  131 + @click="toggleBool('quantityBuyout')" :rightText="boolText(detail.quantityBuyout) || '请选择'" showArrow>
  132 + <template v-slot:body>
  133 + <view class="item-title"><text class="required">*</text><text>是否数量买断</text></view>
  134 + </template>
  135 + </uni-list-item>
  136 +
  137 + <uni-list-item class="select-item" :class="typeof detail.doorDelivery === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  138 + @click="toggleBool('doorDelivery')" :rightText="boolText(detail.doorDelivery) || '请选择'" showArrow>
  139 + <template v-slot:body>
  140 + <view class="item-title"><text class="required">*</text><text>是否送货上门</text></view>
  141 + </template>
  142 + </uni-list-item>
  143 +
  144 + <uni-list-item title="另付运费">
  145 + <template v-slot:footer>
  146 + <uni-easyinput v-model="shippingCostDisplay" :inputBorder="false" disabled placeholder="-" />
  147 + </template>
  148 + </uni-list-item>
  149 +
  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
  156 + v-model="detail.loadingFee"
  157 + type="digit"
  158 + :inputBorder="false"
  159 + placeholder="请输入装车费"
  160 + @input="onNonNegativeInput('loadingFee')"
  161 + @blur="onNonNegativeBlur('loadingFee', 2)"
  162 + />
  163 + </template>
  164 + </uni-list-item>
  165 +
  166 + <uni-list-item>
  167 + <template v-slot:body>
  168 + <view class="item-title"><text class="required">*</text><text>开票品名</text></view>
  169 + </template>
  170 + <template v-slot:footer>
  171 + <uni-easyinput v-model="detail.invoiceProductName" :inputBorder="false" placeholder="请输入开票品名" />
  172 + </template>
  173 + </uni-list-item>
  174 +
  175 + <uni-list-item>
  176 + <template v-slot:body>
  177 + <view class="item-title"><text class="required">*</text><text>交货日期</text></view>
  178 + </template>
  179 + <template v-slot:footer>
  180 + <uni-datetime-picker type="date" v-model="detail.deliveryDate" return-type="string" />
  181 + </template>
  182 + </uni-list-item>
  183 +
  184 + <uni-list-item>
  185 + <template v-slot:body>
  186 + <view class="item-title"><text class="required">*</text><text>结算方式</text></view>
  187 + </template>
  188 + <template v-slot:footer>
  189 + <uni-easyinput v-model="detail.settlementMethod" :inputBorder="false" placeholder="请输入结算方式" />
  190 + </template>
  191 + </uni-list-item>
  192 +
  193 + <uni-list-item>
  194 + <template v-slot:body>
  195 + <view class="item-title"><text class="required">*</text><text>结算比例(%)</text></view>
  196 + </template>
  197 + <template v-slot:footer>
  198 + <uni-easyinput
  199 + v-model="detail.settlementRatio"
  200 + type="digit"
  201 + :inputBorder="false"
  202 + placeholder="请输入结算比例"
  203 + @input="onNonNegativeInput('settlementRatio')"
  204 + @blur="onNonNegativeBlur('settlementRatio', 4)"
  205 + />
  206 + </template>
  207 + </uni-list-item>
  208 +
  209 + <uni-list-item title="价格表编号">
  210 + <template v-slot:footer>
  211 + <uni-easyinput v-model="priceTableDisplay" :inputBorder="false" disabled placeholder="-" />
  212 + </template>
  213 + </uni-list-item>
  214 +
  215 + <uni-list-item>
  216 + <template v-slot:body>
  217 + <view class="item-title"><text class="required">*</text><text>协调事由</text></view>
  218 + </template>
  219 + <template v-slot:footer>
  220 + <uni-easyinput v-model="detail.coordinationReason" :inputBorder="false" placeholder="请输入协调事由" />
  221 + </template>
  222 + </uni-list-item>
  223 +
  224 + <uni-list-item>
  225 + <template v-slot:body>
  226 + <view class="item-title"><text class="required">*</text><text>票类状况</text></view>
  227 + </template>
  228 + <template v-slot:footer>
  229 + <uni-easyinput v-model="detail.invoiceTypeStatus" :inputBorder="false" placeholder="请输入票类状况" />
  230 + </template>
  231 + </uni-list-item>
  232 +
  233 + <uni-list-item v-if="attachmentList.length" title="附件">
  234 + <template v-slot:footer>
  235 + <view class="attach-list">
  236 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  237 + <text class="attach-name">{{ at.name }}</text>
  238 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  239 + </view>
  240 + </view>
  241 + </template>
  242 + </uni-list-item>
  243 +
  244 + <ProductRel
  245 + ref="productRel"
  246 + mode="edit"
  247 + :list="lineList"
  248 + :product-options="productOptions"
  249 + :workshop-options="workshopOptions"
  250 + @change="onLineChange"
  251 + />
  252 + </uni-list>
  253 +
  254 + <view class="material-condition-section">
  255 + <view class="section-header">
  256 + <image class="opCollapse" src="/static/images/title.png" />
  257 + <text class="section-title">料质状况</text>
  258 + </view>
  259 + <view class="section-content">
  260 + <view class="form-row">
  261 + <text class="form-label">是否启用料质状况</text>
  262 + <text class="form-value toggle-link" @click="toggleBool('materialConditionEnabled')">{{ boolText(detail.materialConditionEnabled) || '请选择' }}</text>
  263 + </view>
  264 + <template v-if="detail.materialConditionEnabled">
  265 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  266 + <text class="material-label">{{ mc.label }}</text>
  267 + <view class="tag-list">
  268 + <view
  269 + v-for="opt in getDictOptions(mc.dictCode)"
  270 + :key="opt.code"
  271 + class="tag-btn"
  272 + :class="{ active: isTagSelected(mc.field, opt.code) }"
  273 + @click="toggleTag(mc.field, opt.code)"
  274 + >
  275 + {{ opt.name }}
  276 + </view>
  277 + </view>
  278 + </view>
  279 + </template>
  280 + </view>
  281 + </view>
  282 +
  283 + <view class="remark-section">
  284 + <view class="section-header">
  285 + <image class="opCollapse" src="/static/images/title.png" />
  286 + <text class="section-title">备注</text>
  287 + </view>
  288 + <view class="section-content">
  289 + <uni-easyinput type="textarea" v-model="detail.remark" :inputBorder="false" placeholder="请输入备注" />
  290 + </view>
  291 + </view>
  292 +
  293 + <view class="remark-section">
  294 + <view class="section-header">
  295 + <image class="opCollapse" src="/static/images/title.png" />
  296 + <text class="section-title"><text class="required">*</text>变更事由</text>
  297 + </view>
  298 + <view class="section-content">
  299 + <uni-easyinput type="textarea" v-model="detail.changeReason" :inputBorder="false" placeholder="请输入变更事由" />
  300 + </view>
  301 + </view>
  302 + </scroll-view>
  303 +
  304 + <view class="bottom-bar">
  305 + <button class="btn btn-outline" @click="onBack">取消</button>
  306 + <button class="btn btn-primary" @click="onSubmit">保存</button>
  307 + </view>
  308 +
  309 + <SingleSelectSheet
  310 + :visible.sync="deliverySheetVisible"
  311 + title="交提货方式"
  312 + :options="deliveryOptions"
  313 + v-model="deliverySheetValue"
  314 + @confirm="onDeliveryConfirm"
  315 + />
  316 + </view>
  317 +</template>
  318 +
  319 +<script>
  320 +import ProductRel from './productRel.vue'
  321 +import SingleSelectSheet from '@/components/single-select/index.vue'
  322 +import { procurementPlanChangeFindByIdApi, procurementPlanChangeUpdateApi } from '@/api/procure-manage/procurementPlan.js'
  323 +import {
  324 + breedRelationshipQueryApi,
  325 + priceTableDetailApi,
  326 + workshopQueryApi
  327 +} from '@/api/devManage.js'
  328 +import { getDicByCodes } from '@/utils/dic.js'
  329 +
  330 +export default {
  331 + name: 'SchedulePlanModify',
  332 + components: { ProductRel, SingleSelectSheet },
  333 + data() {
  334 + return {
  335 + id: '',
  336 + form: {
  337 + planId: '',
  338 + planCode: ''
  339 + },
  340 + detail: {},
  341 + attachmentList: [],
  342 + materialConditionConfigs: [
  343 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  344 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  345 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  346 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  347 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  348 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  349 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  350 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  351 + ],
  352 + dicOptions: {
  353 + DELIVERY_METHOD: []
  354 + },
  355 + dictData: {},
  356 + lineList: [],
  357 + productOptions: [],
  358 + workshopOptions: [],
  359 + deliverySheetVisible: false,
  360 + deliverySheetValue: '',
  361 + deliveryOptions: []
  362 + }
  363 + },
  364 + computed: {
  365 + companyNameDisplay() {
  366 + var d = this.detail || {}
  367 + return d.companyShortName != null ? d.companyShortName : (d.companyName != null ? d.companyName : '')
  368 + },
  369 + purchaseDepartmentDisplay() {
  370 + var d = this.detail || {}
  371 + return d.purchaseDepartmentName != null ? d.purchaseDepartmentName : (d.purchaseDepartment != null ? d.purchaseDepartment : '')
  372 + },
  373 + regionDisplay() {
  374 + var d = this.detail || {}
  375 + return d.regionName != null ? d.regionName : (d.region != null ? d.region : '')
  376 + },
  377 + dateDisplay() {
  378 + var d = this.detail || {}
  379 + var s = d.date == null ? '' : String(d.date).trim()
  380 + return s.length >= 10 ? s.slice(0, 10) : s
  381 + },
  382 + shippingCostDisplay() {
  383 + var v = (this.detail || {}).shippingCost
  384 + if (v == null || v === '') return ''
  385 + var n = Number(v)
  386 + if (isNaN(n)) return String(v)
  387 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  388 + },
  389 + priceTableDisplay() {
  390 + var d = this.detail || {}
  391 + var code = d.priceTableCode != null ? String(d.priceTableCode).trim() : ''
  392 + if (!code) return ''
  393 + var name = d.priceTableName || ''
  394 + return name ? (name + ' (' + code + ')') : code
  395 + }
  396 + },
  397 + onLoad(query) {
  398 + this.id = (query && query.id) || ''
  399 + this.loadDictData()
  400 + this.loadRefData()
  401 + if (this.id) {
  402 + this.loadDetailById(this.id)
  403 + }
  404 + },
  405 + methods: {
  406 + safeText(v) {
  407 + var s = v == null ? '' : String(v)
  408 + return s.trim() ? s : '-'
  409 + },
  410 + boolText(v) {
  411 + if (typeof v !== 'boolean') return ''
  412 + return v ? '是' : '否'
  413 + },
  414 + toNumber(v) {
  415 + if (v == null || v === '') return 0
  416 + var n = Number(v)
  417 + return isNaN(n) ? 0 : n
  418 + },
  419 + toFixed(v, n) {
  420 + var num = Number(v)
  421 + if (isNaN(num)) return ''
  422 + return num.toFixed(n)
  423 + },
  424 + async loadDictData() {
  425 + var codes = [].concat(
  426 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  427 + ['DELIVERY_METHOD']
  428 + )
  429 + try {
  430 + var results = await getDicByCodes(codes)
  431 + var d = results || {}
  432 + this.dictData = d
  433 + this.dicOptions.DELIVERY_METHOD = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  434 + this.deliveryOptions = this.dicOptions.DELIVERY_METHOD.map(function (o) {
  435 + return { label: o.name || o.label || '', value: o.code != null ? o.code : o.value }
  436 + })
  437 + } catch (e) {
  438 + this.dictData = {}
  439 + }
  440 + },
  441 + async loadRefData() {
  442 + try {
  443 + var results = await Promise.all([
  444 + this.$pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  445 + this.$pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  446 + ])
  447 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  448 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  449 + this.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  450 + this.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  451 + this.fillLineNames()
  452 + } catch (e) {
  453 + this.productOptions = []
  454 + this.workshopOptions = []
  455 + }
  456 + },
  457 + $pCall(fn, params) {
  458 + try { return Promise.resolve(fn(params)) } catch (e) { return Promise.reject(e) }
  459 + },
  460 + getDictOptions(dictCode) {
  461 + var data = this.dictData[dictCode]
  462 + return (data && data.data) ? data.data : []
  463 + },
  464 + getDeliveryMethodLabel() {
  465 + var opts = this.dicOptions.DELIVERY_METHOD || []
  466 + var v = String(this.detail.deliveryMode != null ? this.detail.deliveryMode : '')
  467 + if (!v) return '请选择'
  468 + for (var i = 0; i < opts.length; i++) {
  469 + var o = opts[i]
  470 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  471 + if (code === v) return o.name || o.label || v
  472 + }
  473 + return v
  474 + },
  475 + async loadDetailById(id) {
  476 + if (!id) return
  477 + try {
  478 + var res = await procurementPlanChangeFindByIdApi({ id: id })
  479 + var d = (res && res.data) ? res.data : {}
  480 + var boolFields = ['longTermOperation', 'terminalCustomer', 'priced', 'temporaryPrice', 'otherExpenseSettlement', 'commodityBuyout', 'qualityBuyout', 'quantityBuyout', 'doorDelivery', 'materialConditionEnabled']
  481 + boolFields.forEach(function (f) {
  482 + var v = d[f]
  483 + if (typeof v === 'string') {
  484 + d[f] = v === 'true' || v === '1'
  485 + } else if (typeof v === 'number') {
  486 + d[f] = v === 1
  487 + } else {
  488 + d[f] = !!v
  489 + }
  490 + })
  491 + this.materialConditionConfigs.forEach(function (mc) {
  492 + var v = d[mc.field]
  493 + if (typeof v === 'string' && v) {
  494 + d[mc.field] = v.split(',').filter(Boolean)
  495 + } else if (!Array.isArray(v)) {
  496 + d[mc.field] = []
  497 + }
  498 + })
  499 + d.pricingDeadline = this.trimDate(d.pricingDeadline)
  500 + d.deliveryDate = this.trimDate(d.deliveryDate)
  501 + this.detail = d
  502 + this.form.planId = d.procurementPlanId != null ? d.procurementPlanId : (d.planId != null ? d.planId : (d.id || ''))
  503 + this.form.planCode = d.procurementPlanCode != null ? d.procurementPlanCode : (d.planCode != null ? d.planCode : d.code)
  504 + var lines = d.lines || d.procurementPlanLineList || d.lineList || []
  505 + this.lineList = Array.isArray(lines) ? lines.slice() : []
  506 + this.buildAttachmentList()
  507 + this.fillLineNames()
  508 + this.fetchPriceDetailAndApply(d.priceId)
  509 + } catch (e) {
  510 + uni.showToast({ title: '加载详情失败', icon: 'none' })
  511 + }
  512 + },
  513 + trimDate(v) {
  514 + if (v == null || v === '') return ''
  515 + var s = String(v).trim()
  516 + return s.length >= 10 ? s.slice(0, 10) : s
  517 + },
  518 + buildAttachmentList() {
  519 + var ids = this.detail.attachmentFileIds
  520 + var names = this.detail.attachmentFileNames
  521 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  522 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  523 + var len = Math.max(idArr.length, nameArr.length)
  524 + var list = []
  525 + for (var i = 0; i < len; i++) {
  526 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  527 + }
  528 + this.attachmentList = list
  529 + },
  530 + onPreviewAttachment(at) {
  531 + if (!at || !at.id) {
  532 + uni.showToast({ title: '无法查看', icon: 'none' })
  533 + return
  534 + }
  535 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  536 + },
  537 + fillLineNames() {
  538 + var list = Array.isArray(this.lineList) ? this.lineList : []
  539 + if (!list.length) return
  540 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  541 + var wOpts = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  542 + this.lineList = list.map(function (row) {
  543 + var r = Object.assign({}, row)
  544 + var pid = r.productId != null ? String(r.productId) : ''
  545 + var wid = r.workshopId != null ? String(r.workshopId) : ''
  546 + if ((r.productName == null || String(r.productName).trim() === '') && pid) {
  547 + var p = pOpts.find(function (o) {
  548 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  549 + return id === pid
  550 + })
  551 + if (p) {
  552 + r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
  553 + }
  554 + }
  555 + if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) {
  556 + var w = wOpts.find(function (o) {
  557 + var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
  558 + return id === wid
  559 + })
  560 + if (w) {
  561 + r.workshopName = w.name != null ? w.name : (w.workshopName != null ? w.workshopName : (w.label != null ? w.label : ''))
  562 + }
  563 + }
  564 + return r
  565 + })
  566 + },
  567 + async fetchPriceDetailAndApply(priceId) {
  568 + if (!priceId) return
  569 + var self = this
  570 + try {
  571 + var res = await priceTableDetailApi({ id: priceId })
  572 + var d = (res && res.data) ? res.data : {}
  573 + if (d.code != null && this.detail) {
  574 + this.$set(this.detail, 'priceTableCode', String(d.code))
  575 + }
  576 + if (d.priceTableName != null && this.detail) {
  577 + this.$set(this.detail, 'priceTableName', d.priceTableName)
  578 + }
  579 + var priceLines = self.extractPriceLines(d)
  580 + self.applyPriceLinesToLines(priceLines)
  581 + } catch (e) {
  582 + return
  583 + }
  584 + },
  585 + extractPriceLines(priceDetail) {
  586 + if (!priceDetail || typeof priceDetail !== 'object') return []
  587 + var candidates = [
  588 + priceDetail.procurementPriceLineList,
  589 + priceDetail.priceSubTableList,
  590 + priceDetail.priceLineList,
  591 + priceDetail.priceList,
  592 + priceDetail.lineList,
  593 + priceDetail.datas,
  594 + priceDetail.records,
  595 + priceDetail.list
  596 + ]
  597 + for (var i = 0; i < candidates.length; i++) {
  598 + if (Array.isArray(candidates[i]) && candidates[i].length) return candidates[i]
  599 + }
  600 + for (var k in priceDetail) {
  601 + if (!Object.prototype.hasOwnProperty.call(priceDetail, k)) continue
  602 + if (Array.isArray(priceDetail[k])) {
  603 + var arr = priceDetail[k]
  604 + if (arr.length && arr[0] && typeof arr[0] === 'object' && (arr[0].price != null || arr[0].productId != null || arr[0].breedId != null || arr[0].varietyId != null)) {
  605 + return arr
  606 + }
  607 + }
  608 + }
  609 + return []
  610 + },
  611 + buildPriceMap(priceLines) {
  612 + var m = {}
  613 + if (!Array.isArray(priceLines)) return m
  614 + for (var i = 0; i < priceLines.length; i++) {
  615 + var line = priceLines[i] || {}
  616 + if (line.price == null) continue
  617 + var key = String(line.productId || line.breedId || line.varietyId || line.id || ('__idx_' + i))
  618 + m[key] = { price: Number(line.price), meta: line }
  619 + }
  620 + return m
  621 + },
  622 + applyPriceLinesToLines(priceLines) {
  623 + if (!Array.isArray(this.lineList)) return
  624 + var priceMap = this.buildPriceMap(priceLines)
  625 + var self = this
  626 + this.lineList = this.lineList.map(function (row) {
  627 + var pid = String(row.productId || row.breedId || row.varietyId || '')
  628 + var price = null
  629 + if (pid && priceMap[pid] != null) {
  630 + price = priceMap[pid].price
  631 + } else {
  632 + var pname = (row.productName || '').trim()
  633 + if (pname) {
  634 + for (var k in priceMap) {
  635 + if (!Object.prototype.hasOwnProperty.call(priceMap, k)) continue
  636 + var meta = priceMap[k] && priceMap[k].meta ? priceMap[k].meta : null
  637 + if (meta && ((meta.productName && meta.productName === pname) || (meta.breedName && meta.breedName === pname) || (meta.varietyName && meta.varietyName === pname))) {
  638 + price = priceMap[k].price
  639 + break
  640 + }
  641 + }
  642 + }
  643 + }
  644 + if (price != null) {
  645 + row.priceListPrices = self.toFixed(price, 2)
  646 + } else {
  647 + row.priceListPrices = ''
  648 + }
  649 + return row
  650 + })
  651 + },
  652 + onLineChange(list) {
  653 + this.lineList = Array.isArray(list) ? list.slice() : []
  654 + },
  655 + toggleBool(field) {
  656 + var cur = this.detail[field]
  657 + this.$set(this.detail, field, cur !== true)
  658 + },
  659 + onNonNegativeInput(field) {
  660 + var v = String(this.detail[field] != null ? this.detail[field] : '')
  661 + v = v.replace(/[^0-9.]/g, '')
  662 + v = v.replace(/(\..*)\./g, '$1')
  663 + this.$set(this.detail, field, v)
  664 + },
  665 + onNonNegativeBlur(field, digits) {
  666 + var raw = this.detail[field]
  667 + if (raw === '' || raw === null || raw === undefined) {
  668 + this.$set(this.detail, field, '')
  669 + return
  670 + }
  671 + var val = parseFloat(raw)
  672 + if (isNaN(val)) val = 0
  673 + var m = Math.pow(10, digits)
  674 + var rounded = Math.round(val * m) / m
  675 + this.$set(this.detail, field, rounded)
  676 + },
  677 + openDeliverySheet() {
  678 + var cur = this.detail.deliveryMode != null ? this.detail.deliveryMode : ''
  679 + var match = this.deliveryOptions.find(function (o) { return String(o.value) === String(cur) })
  680 + this.deliverySheetValue = match ? match.value : ''
  681 + this.deliverySheetVisible = true
  682 + },
  683 + onDeliveryConfirm(e) {
  684 + this.$set(this.detail, 'deliveryMode', e.value != null ? e.value : '')
  685 + },
  686 + isTagSelected(field, code) {
  687 + var selected = this.detail ? this.detail[field] : undefined
  688 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  689 + if (typeof selected === 'string' && selected) {
  690 + return selected.split(',').indexOf(code) >= 0
  691 + }
  692 + return false
  693 + },
  694 + toggleTag(field, code) {
  695 + var selected = this.detail[field]
  696 + var arr = Array.isArray(selected) ? selected.slice() : []
  697 + var idx = arr.indexOf(code)
  698 + if (idx >= 0) {
  699 + arr.splice(idx, 1)
  700 + } else {
  701 + arr.push(code)
  702 + }
  703 + this.$set(this.detail, field, arr)
  704 + },
  705 + validateForm() {
  706 + if (!this.form.planId) {
  707 + uni.showToast({ title: '请选择计划', icon: 'none' })
  708 + return false
  709 + }
  710 + var d = this.detail || {}
  711 + var textChecks = [
  712 + { key: 'supplierName', title: '供应商名称' },
  713 + { key: 'validityPeriod', title: '报价时效' },
  714 + { key: 'quoterName', title: '报价人' },
  715 + { key: 'deliveryMode', title: '交提货方式' },
  716 + { key: 'loadingFee', title: '装车费' },
  717 + { key: 'invoiceProductName', title: '开票品名' },
  718 + { key: 'deliveryDate', title: '交货日期' },
  719 + { key: 'settlementMethod', title: '结算方式' },
  720 + { key: 'settlementRatio', title: '结算比例' },
  721 + { key: 'coordinationReason', title: '协调事由' },
  722 + { key: 'invoiceTypeStatus', title: '票类状况' },
  723 + { key: 'changeReason', title: '变更事由' }
  724 + ]
  725 + for (var i = 0; i < textChecks.length; i++) {
  726 + var tc = textChecks[i]
  727 + var tv = d[tc.key]
  728 + if (tv === '' || tv === null || tv === undefined) {
  729 + uni.showToast({ title: '请填写' + tc.title, icon: 'none' })
  730 + return false
  731 + }
  732 + }
  733 + var boolChecks = [
  734 + { key: 'longTermOperation', title: '是否长单操作' },
  735 + { key: 'terminalCustomer', title: '是否终端客户' },
  736 + { key: 'priced', title: '是否未点价' },
  737 + { key: 'otherExpenseSettlement', title: '其他费用凭票到厂另行结算' },
  738 + { key: 'commodityBuyout', title: '是否通货买断' },
  739 + { key: 'qualityBuyout', title: '是否质量买断' },
  740 + { key: 'quantityBuyout', title: '是否数量买断' },
  741 + { key: 'doorDelivery', title: '是否送货上门' }
  742 + ]
  743 + if (d.priced === true) {
  744 + boolChecks.push({ key: 'temporaryPrice', title: '是否暂定价' })
  745 + var pd = d.pricingDeadline
  746 + if (pd === '' || pd === null || pd === undefined) {
  747 + uni.showToast({ title: '请选择点价截止日期', icon: 'none' })
  748 + return false
  749 + }
  750 + }
  751 + for (var j = 0; j < boolChecks.length; j++) {
  752 + var bc = boolChecks[j]
  753 + if (typeof d[bc.key] !== 'boolean') {
  754 + uni.showToast({ title: '请选择' + bc.title, icon: 'none' })
  755 + return false
  756 + }
  757 + }
  758 + var pr = this.$refs.productRel
  759 + if (pr && typeof pr.validate === 'function') {
  760 + if (!pr.validate()) return false
  761 + }
  762 + return true
  763 + },
  764 + onBack() {
  765 + uni.navigateBack({ delta: 1 })
  766 + },
  767 + joinStr(arr) {
  768 + if (Array.isArray(arr)) return arr.filter(Boolean).join(',')
  769 + if (typeof arr === 'string') return arr
  770 + return ''
  771 + },
  772 + pickId(v) {
  773 + if (v == null || v === '') return ''
  774 + if (typeof v === 'string' || typeof v === 'number') return String(v)
  775 + if (typeof v === 'object') {
  776 + return String(v.id != null ? v.id : (v.value != null ? v.value : (v.code != null ? v.code : '')))
  777 + }
  778 + return String(v)
  779 + },
  780 + boolToStr(v) {
  781 + return v === true ? 'true' : 'false'
  782 + },
  783 + buildPayload() {
  784 + var self = this
  785 + var d = this.detail || {}
  786 + var lines = Array.isArray(this.lineList) ? this.lineList.slice() : []
  787 + var workshopId = d.workshopId != null ? d.workshopId : ''
  788 + var lineList = lines.map(function (row, i) {
  789 + var r = row || {}
  790 + var itemId = r.itemId != null ? r.itemId : (r.id != null ? String(r.id) : (r._key != null ? r._key : ('line-' + Date.now() + '-' + i)))
  791 + if (!workshopId && r.workshopId != null) workshopId = r.workshopId
  792 + return {
  793 + productId: self.pickId(r.productId),
  794 + materialType: r.materialType != null ? String(r.materialType) : '',
  795 + quantity: r.quantity != null ? String(r.quantity) : '',
  796 + actualPurchasePrice: r.actualPurchasePrice != null ? String(r.actualPurchasePrice) : '',
  797 + includingShippingPrice: r.includingShippingPrice != null ? String(r.includingShippingPrice) : '',
  798 + priceListPrices: r.priceListPrices != null ? String(r.priceListPrices) : '',
  799 + coordinationRange: r.coordinationRange != null ? String(r.coordinationRange) : '',
  800 + estimatedLoss: r.estimatedLoss != null ? String(r.estimatedLoss) : '',
  801 + applicationAttrition: r.applicationAttrition != null ? String(r.applicationAttrition) : '',
  802 + paintDamageRatio: r.paintDamageRatio != null ? String(r.paintDamageRatio) : '',
  803 + workshopId: self.pickId(r.workshopId),
  804 + itemId: itemId
  805 + }
  806 + })
  807 + var body = {
  808 + id: this.id || d.id || '',
  809 + procurementPlanId: this.form.planId || d.id || '',
  810 + changeReason: d.changeReason != null ? String(d.changeReason) : '',
  811 + code: d.code != null ? String(d.code) : '',
  812 + companyShortId: this.pickId(d.companyShortId || d.companyId),
  813 + supplierId: this.pickId(d.supplierId),
  814 + purchaseDepartment: this.pickId(d.purchaseDepartment),
  815 + region: this.pickId(d.region),
  816 + date: d.date != null ? String(d.date).slice(0, 10) : '',
  817 + validityPeriod: d.validityPeriod != null ? String(d.validityPeriod) : '',
  818 + quoterId: this.pickId(d.quoterId),
  819 + workshopId: this.pickId(workshopId),
  820 + quoterName: d.quoterName != null ? String(d.quoterName) : '',
  821 + longTermOperation: this.boolToStr(d.longTermOperation),
  822 + terminalCustomer: this.boolToStr(d.terminalCustomer),
  823 + priced: this.boolToStr(d.priced),
  824 + pricingDeadline: d.pricingDeadline != null ? String(d.pricingDeadline) : '',
  825 + temporaryPrice: this.boolToStr(d.temporaryPrice),
  826 + otherExpenseSettlement: this.boolToStr(d.otherExpenseSettlement),
  827 + deliveryMode: d.deliveryMode != null ? String(d.deliveryMode) : '',
  828 + commodityBuyout: this.boolToStr(d.commodityBuyout),
  829 + qualityBuyout: this.boolToStr(d.qualityBuyout),
  830 + quantityBuyout: this.boolToStr(d.quantityBuyout),
  831 + doorDelivery: this.boolToStr(d.doorDelivery),
  832 + shippingCost: d.shippingCost != null ? String(d.shippingCost) : '',
  833 + loadingFee: d.loadingFee != null ? String(d.loadingFee) : '',
  834 + invoiceProductName: d.invoiceProductName != null ? String(d.invoiceProductName) : '',
  835 + deliveryDate: d.deliveryDate != null ? String(d.deliveryDate) : '',
  836 + settlementMethod: d.settlementMethod != null ? String(d.settlementMethod) : '',
  837 + settlementRatio: d.settlementRatio != null ? String(d.settlementRatio) : '',
  838 + priceId: this.pickId(d.priceId),
  839 + coordinationReason: d.coordinationReason != null ? String(d.coordinationReason) : '',
  840 + invoiceTypeStatus: d.invoiceTypeStatus != null ? String(d.invoiceTypeStatus) : '',
  841 + totalQuantity: d.totalQuantity != null ? String(d.totalQuantity) : '',
  842 + remark: d.remark != null ? String(d.remark) : '',
  843 + materialConditionEnabled: this.boolToStr(d.materialConditionEnabled),
  844 + lines: lineList
  845 + }
  846 + this.materialConditionConfigs.forEach(function (mc) {
  847 + body[mc.field] = self.joinStr(d[mc.field])
  848 + })
  849 + return body
  850 + },
  851 + async onSubmit() {
  852 + if (!this.validateForm()) return
  853 + var payload = this.buildPayload()
  854 + try {
  855 + await procurementPlanChangeUpdateApi(payload)
  856 + uni.showToast({ title: '保存成功', icon: 'none' })
  857 + try {
  858 + uni.setStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH', '1')
  859 + } catch (e) {}
  860 + var self = this
  861 + setTimeout(function () {
  862 + uni.navigateTo({ url: '/pages/schedule-plan/index' })
  863 + }, 400)
  864 + } catch (e) {
  865 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : '保存失败', icon: 'none' })
  866 + }
  867 + }
  868 + }
  869 +}
  870 +</script>
  871 +
  872 +<style lang="scss" scoped>
  873 +.page {
  874 + display: flex;
  875 + flex-direction: column;
  876 + height: 100%;
  877 +}
  878 +.scroll {
  879 + flex: 1;
  880 + padding: 12rpx 0 392rpx !important;
  881 +}
  882 +.bottom-bar {
  883 + z-index: 2;
  884 + position: fixed;
  885 + left: 0;
  886 + right: 0;
  887 + bottom: 0;
  888 + padding: 32rpx;
  889 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  890 + background: #fff;
  891 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  892 + display: flex;
  893 + gap: 24rpx;
  894 + .btn {
  895 + flex: 1;
  896 + height: 80rpx;
  897 + line-height: 80rpx;
  898 + border-radius: 12rpx;
  899 + font-size: 32rpx;
  900 + }
  901 + .btn-outline {
  902 + background: #fff;
  903 + color: $theme-primary;
  904 + border: 2rpx solid $theme-primary;
  905 + }
  906 + .btn-primary {
  907 + background: $theme-primary;
  908 + color: #fff;
  909 + border: 2rpx solid $theme-primary;
  910 + }
  911 +}
  912 +
  913 +::v-deep .uni-list {
  914 + .uni-easyinput {
  915 + display: flex;
  916 + .uni-input-input {
  917 + color: rgba(0, 0, 0, 0.9);
  918 + }
  919 + }
  920 + .uni-input-placeholder { z-index: 1; }
  921 + .uni-input-input { background-color: #ffffff; }
  922 + background: transparent;
  923 + &-item {
  924 + &__extra-text { font-size: 32rpx; }
  925 + &__content-title {
  926 + font-size: 32rpx;
  927 + color: rgba(0, 0, 0, 0.9);
  928 + }
  929 + &__container {
  930 + padding: 32rpx;
  931 + .uni-easyinput {
  932 + &__placeholder-class {
  933 + font-size: 32rpx;
  934 + color: rgba(0, 0, 0, 0.4);
  935 + }
  936 + &__content {
  937 + border: none;
  938 + background-color: #ffffff !important;
  939 + &-input {
  940 + padding-left: 0 !important;
  941 + height: 48rpx;
  942 + line-height: 48rpx;
  943 + font-size: 32rpx;
  944 + }
  945 + .content-clear-icon {
  946 + font-size: 44rpx !important;
  947 + }
  948 + }
  949 + }
  950 + .item-title,
  951 + .uni-list-item__content {
  952 + flex: none;
  953 + min-height: 48rpx;
  954 + line-height: 48rpx;
  955 + font-size: 32rpx;
  956 + position: relative;
  957 + width: 240rpx;
  958 + margin-right: 32rpx;
  959 + color: rgba(0, 0, 0, 0.9);
  960 + .required {
  961 + color: red;
  962 + position: absolute;
  963 + top: 50%;
  964 + transform: translateY(-50%);
  965 + left: -16rpx;
  966 + }
  967 + }
  968 + }
  969 + &.select-item {
  970 + &.is-empty {
  971 + .uni-list-item__extra-text {
  972 + color: rgba(0, 0, 0, 0.4) !important;
  973 + }
  974 + }
  975 + &.is-filled {
  976 + .uni-list-item__extra-text {
  977 + color: rgba(0, 0, 0, 0.9) !important;
  978 + }
  979 + }
  980 + .serial-number-row {
  981 + display: flex;
  982 + align-items: center;
  983 + }
  984 + }
  985 + }
  986 +}
  987 +
  988 +.readonly-text {
  989 + color: rgba(0, 0, 0, 0.9);
  990 + font-size: 32rpx;
  991 + line-height: 48rpx;
  992 + text-align: right;
  993 + white-space: pre-wrap;
  994 + word-break: break-all;
  995 +}
  996 +.value-code {
  997 + width: 260rpx;
  998 + text-align: left;
  999 +}
  1000 +
  1001 +.attach-list {
  1002 + flex: 1;
  1003 + display: flex;
  1004 + flex-direction: column;
  1005 + align-items: flex-end;
  1006 + gap: 8rpx;
  1007 +}
  1008 +.attach-item {
  1009 + display: flex;
  1010 + align-items: center;
  1011 + gap: 16rpx;
  1012 + .attach-name { font-size: 26rpx; color: rgba(0,0,0,0.9); }
  1013 + .attach-view { font-size: 26rpx; color: $theme-primary; }
  1014 +}
  1015 +
  1016 +.material-condition-section,
  1017 +.remark-section {
  1018 + margin-top: 20rpx;
  1019 + background: #fff;
  1020 +}
  1021 +.section-header {
  1022 + display: flex;
  1023 + align-items: center;
  1024 + padding: 24rpx 32rpx;
  1025 + border-bottom: 1rpx solid #f0f0f0;
  1026 +}
  1027 +.section-title {
  1028 + position: relative;
  1029 + font-size: 32rpx;
  1030 + color: rgba(0, 0, 0, 0.9);
  1031 + font-weight: 600;
  1032 + .required {
  1033 + color: red;
  1034 + position: absolute;
  1035 + top: 50%;
  1036 + transform: translateY(-50%);
  1037 + left: -16rpx;
  1038 + }
  1039 +}
  1040 +.opCollapse {
  1041 + width: 32rpx;
  1042 + height: 28rpx;
  1043 + margin-right: 16rpx;
  1044 + margin-top: 8rpx;
  1045 +}
  1046 +.section-content {
  1047 + padding: 32rpx;
  1048 +}
  1049 +.form-row {
  1050 + display: flex;
  1051 + align-items: center;
  1052 + justify-content: space-between;
  1053 + margin-bottom: 24rpx;
  1054 +}
  1055 +.form-row:last-child { margin-bottom: 0; }
  1056 +.form-label {
  1057 + font-size: 32rpx;
  1058 + color: rgba(0, 0, 0, 0.9);
  1059 +}
  1060 +.form-value {
  1061 + font-size: 32rpx;
  1062 + color: rgba(0, 0, 0, 0.9);
  1063 +}
  1064 +.toggle-link {
  1065 + color: $theme-primary;
  1066 +}
  1067 +.material-group {
  1068 + margin-top: 32rpx;
  1069 +}
  1070 +.material-label {
  1071 + display: block;
  1072 + font-size: 30rpx;
  1073 + color: rgba(0, 0, 0, 0.9);
  1074 + margin-bottom: 20rpx;
  1075 +}
  1076 +.tag-list {
  1077 + display: flex;
  1078 + flex-wrap: wrap;
  1079 + gap: 16rpx;
  1080 +}
  1081 +.tag-btn {
  1082 + padding: 12rpx 24rpx;
  1083 + border: 1rpx solid #ddd;
  1084 + border-radius: 8rpx;
  1085 + font-size: 28rpx;
  1086 + color: #666;
  1087 + background: #fff;
  1088 +}
  1089 +.tag-btn.active {
  1090 + background: $theme-primary;
  1091 + border-color: $theme-primary;
  1092 + color: #fff;
  1093 +}
  1094 +
  1095 +::v-deep .uni-easyinput {
  1096 + width: 100%;
  1097 + &__content {
  1098 + background: #f8f8f8 !important;
  1099 + border-radius: 8rpx;
  1100 + &-input { font-size: 30rpx; }
  1101 + }
  1102 +}
  1103 +</style>
... ...
  1 +<template>
  2 + <view class="product-rel">
  3 + <view class="header">
  4 + <image class="opCollapse" src="/static/images/title.png" />
  5 + <text class="title">明细信息</text>
  6 + <view class="ops">
  7 + <image class="opAdd" @click="onAdd" src="/static/images/plus.png" />
  8 + </view>
  9 + </view>
  10 +
  11 + <view class="add-list">
  12 + <view v-for="(item, idx) in items" :key="item._key || idx" class="block">
  13 + <uni-list v-show="!item.collapsed">
  14 + <uni-list-item
  15 + class="select-item"
  16 + :class="item.productName ? 'is-filled' : 'is-empty'"
  17 + clickable
  18 + @click="openSelectSheet('product', idx)"
  19 + :rightText="item.productName || '请选择品种'"
  20 + showArrow
  21 + >
  22 + <template v-slot:body>
  23 + <view class="item-title">
  24 + <text class="required">*</text><text>品种</text>
  25 + </view>
  26 + </template>
  27 + </uni-list-item>
  28 + <uni-list-item>
  29 + <template v-slot:body>
  30 + <view class="item-title">
  31 + <text class="required">*</text><text>料型</text>
  32 + </view>
  33 + </template>
  34 + <template v-slot:footer>
  35 + <uni-easyinput v-model="item.materialType" :inputBorder="false" placeholder="请输入料型" />
  36 + </template>
  37 + </uni-list-item>
  38 + <uni-list-item>
  39 + <template v-slot:body>
  40 + <view class="item-title">
  41 + <text class="required">*</text><text>数量(吨)</text>
  42 + </view>
  43 + </template>
  44 + <template v-slot:footer>
  45 + <uni-easyinput
  46 + v-model="item.quantity"
  47 + type="digit"
  48 + :inputBorder="false"
  49 + placeholder="请输入数量"
  50 + @input="onNonNegativeInput(idx, 'quantity')"
  51 + @blur="onNonNegativeBlur(idx, 'quantity', 4)"
  52 + />
  53 + </template>
  54 + </uni-list-item>
  55 + <uni-list-item>
  56 + <template v-slot:body>
  57 + <view class="item-title">
  58 + <text class="required">*</text><text>实际采购价</text>
  59 + </view>
  60 + </template>
  61 + <template v-slot:footer>
  62 + <uni-easyinput
  63 + v-model="item.actualPurchasePrice"
  64 + type="digit"
  65 + :inputBorder="false"
  66 + placeholder="请输入实际采购价"
  67 + @input="onNonNegativeInput(idx, 'actualPurchasePrice')"
  68 + @blur="onNonNegativeBlur(idx, 'actualPurchasePrice', 2)"
  69 + />
  70 + </template>
  71 + </uni-list-item>
  72 + <uni-list-item title="含运到厂价">
  73 + <template v-slot:footer>
  74 + <text class="lock-value">{{ formatTextNumber(item.includingShippingPrice) }}</text>
  75 + </template>
  76 + </uni-list-item>
  77 + <uni-list-item title="价格表价格">
  78 + <template v-slot:footer>
  79 + <text class="lock-value">{{ formatTextNumber(item.priceListPrices) }}</text>
  80 + </template>
  81 + </uni-list-item>
  82 + <uni-list-item title="协调幅度">
  83 + <template v-slot:footer>
  84 + <text class="lock-value">{{ formatTextNumber(item.coordinationRange) }}</text>
  85 + </template>
  86 + </uni-list-item>
  87 + <uni-list-item>
  88 + <template v-slot:body>
  89 + <view class="item-title">
  90 + <text class="required">*</text><text>买断料预计损耗</text>
  91 + </view>
  92 + </template>
  93 + <template v-slot:footer>
  94 + <uni-easyinput
  95 + v-model="item.estimatedLoss"
  96 + type="digit"
  97 + :inputBorder="false"
  98 + placeholder="请输入预计损耗"
  99 + @input="onNonNegativeInput(idx, 'estimatedLoss')"
  100 + @blur="onNonNegativeBlur(idx, 'estimatedLoss', 2)"
  101 + />
  102 + </template>
  103 + </uni-list-item>
  104 + <uni-list-item>
  105 + <template v-slot:body>
  106 + <view class="item-title">
  107 + <text class="required">*</text><text>申请损耗(%)</text>
  108 + </view>
  109 + </template>
  110 + <template v-slot:footer>
  111 + <uni-easyinput
  112 + v-model="item.applicationAttrition"
  113 + type="digit"
  114 + :inputBorder="false"
  115 + placeholder="请输入申请损耗"
  116 + @input="onNonNegativeInput(idx, 'applicationAttrition')"
  117 + @blur="onNonNegativeBlur(idx, 'applicationAttrition', 2)"
  118 + />
  119 + </template>
  120 + </uni-list-item>
  121 + <uni-list-item title="选择分厂">
  122 + <template v-slot:footer>
  123 + <text class="lock-value">{{ safeText(item.workshopName) }}</text>
  124 + </template>
  125 + </uni-list-item>
  126 + </uni-list>
  127 + <uni-list v-show="item.collapsed">
  128 + <uni-list-item
  129 + class="select-item"
  130 + :class="item.productName ? 'is-filled' : 'is-empty'"
  131 + clickable
  132 + @click="openSelectSheet('product', idx)"
  133 + :rightText="item.productName || '请选择品种'"
  134 + showArrow
  135 + >
  136 + <template v-slot:body>
  137 + <view class="item-title">
  138 + <text class="required">*</text><text>品种</text>
  139 + </view>
  140 + </template>
  141 + </uni-list-item>
  142 + </uni-list>
  143 + <view class="block-ops">
  144 + <div class="del" @click="onRemove(idx)">
  145 + <image src="/static/images/delete.png" class="icon" />
  146 + 删除
  147 + </div>
  148 + <div class="toggle" @click="toggleItem(idx)">
  149 + <image :src="item.collapsed ? '/static/images/up.png' : '/static/images/down.png'" class="icon" />
  150 + {{ item.collapsed ? '展开' : '收起' }}
  151 + </div>
  152 + </view>
  153 + </view>
  154 + </view>
  155 +
  156 + <SingleSelectSheet
  157 + :visible.sync="sheet.visible"
  158 + :title="sheet.title"
  159 + :options="sheet.options"
  160 + v-model="sheet.value"
  161 + @confirm="onSheetConfirm"
  162 + />
  163 + </view>
  164 +</template>
  165 +
  166 +<script>
  167 +import SingleSelectSheet from '@/components/single-select/index.vue'
  168 +
  169 +export default {
  170 + name: 'SchedulePlanProductRel',
  171 + components: { SingleSelectSheet },
  172 + props: {
  173 + mode: { type: String, default: 'edit' },
  174 + list: { type: Array, default: function () { return [] } },
  175 + max: { type: Number, default: 50 },
  176 + productOptions: { type: Array, default: function () { return [] } },
  177 + workshopOptions: { type: Array, default: function () { return [] } }
  178 + },
  179 + data() {
  180 + return {
  181 + items: [],
  182 + sheet: { visible: false, title: '请选择', options: [], value: '', idx: -1, type: '' },
  183 + _initialized: false
  184 + }
  185 + },
  186 + computed: {
  187 + productOptsComputed() {
  188 + var list = Array.isArray(this.productOptions) ? this.productOptions : []
  189 + return list.map(function (o) {
  190 + return {
  191 + label: o.label != null ? o.label : (o.name != null ? o.name : (o.productName || '')),
  192 + value: o.value != null ? o.value : (o.id != null ? o.id : o.productId)
  193 + }
  194 + })
  195 + },
  196 + workshopOptsComputed() {
  197 + var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  198 + return list.map(function (o) {
  199 + return {
  200 + label: o.label != null ? o.label : (o.name != null ? o.name : (o.workshopName || '')),
  201 + value: o.value != null ? o.value : (o.id != null ? o.id : o.workshopId)
  202 + }
  203 + })
  204 + }
  205 + },
  206 + watch: {
  207 + items: {
  208 + handler() {
  209 + this.emitChange() },
  210 + deep: true
  211 + },
  212 + list: {
  213 + handler() {
  214 + this._initialized = false
  215 + this.initItems()
  216 + var self = this
  217 + this.$nextTick(function () { self._initialized = true })
  218 + },
  219 + immediate: false
  220 + }
  221 + },
  222 + created() {
  223 + this.initItems()
  224 + var self = this
  225 + this.$nextTick(function () { self._initialized = true })
  226 + },
  227 + methods: {
  228 + initItems() {
  229 + var src = Array.isArray(this.list) && this.list.length > 0 ? this.list : []
  230 + if (!src.length) {
  231 + if (this.mode === 'add' || this.mode === 'edit') {
  232 + this.items = [Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false })]
  233 + } else {
  234 + this.items = []
  235 + }
  236 + return
  237 + }
  238 + var existing = this.items || []
  239 + var existingMap = {}
  240 + existing.forEach(function (it) {
  241 + if (it.itemId) existingMap[it.itemId] = it
  242 + })
  243 + var self = this
  244 + this.items = src.map(function (x, i) {
  245 + var key = x && x.itemId ? x.itemId : (x && x._key ? x._key : self.newKey())
  246 + var old = existingMap[key]
  247 + var collapsed = old ? old.collapsed : (typeof x.collapsed === 'boolean' ? x.collapsed : false)
  248 + return Object.assign({}, self.defaultItem(), x, {
  249 + _key: key,
  250 + itemId: x && x.itemId ? x.itemId : key,
  251 + collapsed: collapsed
  252 + })
  253 + })
  254 + },
  255 + newKey() {
  256 + return Date.now() + '-' + Math.random().toString(16).slice(2)
  257 + },
  258 + defaultItem() {
  259 + return {
  260 + productId: '',
  261 + productName: '',
  262 + materialType: '',
  263 + quantity: '',
  264 + actualPurchasePrice: '',
  265 + includingShippingPrice: '',
  266 + priceListPrices: '',
  267 + coordinationRange: '',
  268 + estimatedLoss: '',
  269 + applicationAttrition: '',
  270 + workshopId: '',
  271 + workshopName: ''
  272 + }
  273 + },
  274 + onNonNegativeInput(idx, field) {
  275 + var it = this.items[idx]
  276 + if (!it) return
  277 + var v = String(it[field] != null ? it[field] : '')
  278 + v = v.replace(/[^0-9.]/g, '')
  279 + v = v.replace(/(\..*)\./g, '$1')
  280 + it[field] = v
  281 + this.$set(this.items, idx, it)
  282 + },
  283 + onNonNegativeBlur(idx, field, digits) {
  284 + var it = this.items[idx]
  285 + if (!it) return
  286 + var raw = it[field]
  287 + if (raw === '' || raw === null || raw === undefined) {
  288 + this.$set(this.items, idx, it)
  289 + return
  290 + }
  291 + var val = parseFloat(raw)
  292 + if (isNaN(val)) val = 0
  293 + var m = Math.pow(10, digits)
  294 + var rounded = Math.round(val * m) / m
  295 + it[field] = rounded
  296 + this.$set(this.items, idx, it)
  297 + },
  298 + onAdd() {
  299 + if (this.items.length >= this.max) {
  300 + uni.showToast({ title: '最多' + this.max + '条明细', icon: 'none' })
  301 + return
  302 + }
  303 + this.items.push(Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false }))
  304 + },
  305 + onRemove(idx) {
  306 + this.items.splice(idx, 1)
  307 + if ((this.mode === 'add' || this.mode === 'edit') && this.items.length === 0) {
  308 + this.items.push(Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false }))
  309 + }
  310 + },
  311 + toggleItem(idx) {
  312 + var it = this.items[idx]
  313 + if (!it) return
  314 + this.$set(it, 'collapsed', !it.collapsed)
  315 + },
  316 + openSelectSheet(type, idx) {
  317 + if (type === 'product') {
  318 + var pOpts = this.productOptsComputed
  319 + var curP = this.items[idx] && this.items[idx].productId
  320 + var mP = pOpts.find(function (o) { return String(o.value) === String(curP) })
  321 + this.sheet = { visible: true, title: '请选择品种', options: pOpts, value: mP ? mP.value : '', idx: idx, type: type }
  322 + }
  323 + },
  324 + onSheetConfirm(_ref) {
  325 + var value = _ref.value
  326 + var label = _ref.label
  327 + var idx = this.sheet.idx
  328 + var type = this.sheet.type
  329 + if (idx < 0 || !this.items[idx]) return
  330 + var it = this.items[idx]
  331 + if (type === 'product') {
  332 + this.$set(it, 'productId', value)
  333 + this.$set(it, 'productName', label)
  334 + }
  335 + },
  336 + fillLineNames() {
  337 + if (!Array.isArray(this.items) || !this.items.length) return
  338 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  339 + var wOpts = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  340 + var self = this
  341 + this.items = this.items.map(function (row) {
  342 + var r = Object.assign({}, row)
  343 + var pid = r.productId != null ? String(r.productId) : ''
  344 + var wid = r.workshopId != null ? String(r.workshopId) : ''
  345 + if ((r.productName == null || String(r.productName).trim() === '') && pid) {
  346 + var p = pOpts.find(function (o) {
  347 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  348 + return id === pid
  349 + })
  350 + if (p) {
  351 + r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
  352 + }
  353 + }
  354 + if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) {
  355 + var w = wOpts.find(function (o) {
  356 + var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
  357 + return id === wid
  358 + })
  359 + if (w) {
  360 + r.workshopName = w.name != null ? w.name : (w.workshopName != null ? w.workshopName : (w.label != null ? w.label : ''))
  361 + }
  362 + }
  363 + return r
  364 + })
  365 + this.$nextTick(function () { self.emitChange() })
  366 + },
  367 + emitChange() {
  368 + if (!this._initialized) return
  369 + var list = (this.items || []).map(function (it) {
  370 + var c = Object.assign({}, it)
  371 + var key = c._key
  372 + delete c._key
  373 + delete c.collapsed
  374 + delete c._selected
  375 + if (!c.itemId) c.itemId = key
  376 + return c
  377 + })
  378 + this.$emit('change', list)
  379 + },
  380 + safeText(v) {
  381 + var s = v == null ? '' : String(v)
  382 + return s.trim() ? s : '-'
  383 + },
  384 + formatTextNumber(v) {
  385 + if (v == null || v === '') return '-'
  386 + var n = Number(v)
  387 + if (isNaN(n)) return String(v)
  388 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  389 + },
  390 + validate() {
  391 + var items = this.items || []
  392 + if (!items.length) {
  393 + uni.showToast({ title: '请添加明细', icon: 'none' })
  394 + return false
  395 + }
  396 + var fields = [
  397 + { key: 'productName', title: '品种' },
  398 + { key: 'materialType', title: '料型' },
  399 + { key: 'quantity', title: '数量' },
  400 + { key: 'actualPurchasePrice', title: '实际采购价' },
  401 + { key: 'estimatedLoss', title: '买断料预计损耗' },
  402 + { key: 'applicationAttrition', title: '申请损耗' }
  403 + ]
  404 + for (var i = 0; i < items.length; i++) {
  405 + var it = items[i]
  406 + for (var j = 0; j < fields.length; j++) {
  407 + var f = fields[j]
  408 + var v = it[f.key]
  409 + if (v === '' || v === null || v === undefined) {
  410 + uni.showToast({ title: '请填写第' + (i + 1) + '条明细的' + f.title, icon: 'none' })
  411 + return false
  412 + }
  413 + }
  414 + }
  415 + return true
  416 + }
  417 + }
  418 +}
  419 +</script>
  420 +
  421 +<style lang="scss" scoped>
  422 +.product-rel {
  423 + margin-top: 20rpx;
  424 + background: #fff;
  425 +}
  426 +.header {
  427 + display: flex;
  428 + align-items: center;
  429 + padding: 24rpx 32rpx;
  430 + border-bottom: 1rpx solid #f0f0f0;
  431 +}
  432 +.title {
  433 + font-size: 32rpx;
  434 + color: rgba(0, 0, 0, 0.9);
  435 + font-weight: 600;
  436 +}
  437 +.ops {
  438 + margin-left: auto;
  439 +}
  440 +.opAdd {
  441 + color: rgba(0, 0, 0, 0.6);
  442 + width: 40rpx;
  443 + height: 40rpx;
  444 +}
  445 +.opCollapse {
  446 + color: rgba(0, 0, 0, 0.6);
  447 + width: 32rpx;
  448 + height: 28rpx;
  449 + margin-right: 16rpx;
  450 + margin-top: 8rpx;
  451 +}
  452 +.block {
  453 + background: #fff;
  454 + margin-bottom: 20rpx;
  455 +}
  456 +::v-deep .uni-list-item__content {
  457 + display: flex;
  458 + justify-content: center;
  459 +}
  460 +::v-deep .uni-list {
  461 + .uni-easyinput {
  462 + display: flex;
  463 + .uni-input-input {
  464 + color: rgba(0, 0, 0, 0.9);
  465 + }
  466 + }
  467 + .uni-input-placeholder { z-index: 1; }
  468 + .uni-input-input { background-color: #ffffff; }
  469 + background: transparent;
  470 + &-item {
  471 + &__container { padding: 32rpx; }
  472 + &__content-title {
  473 + font-size: 28rpx;
  474 + color: rgba(0, 0, 0, 0.9);
  475 + }
  476 + &__extra-text { font-size: 32rpx; }
  477 + .uni-easyinput {
  478 + width: 100%;
  479 + &__placeholder-class {
  480 + font-size: 32rpx;
  481 + color: rgba(0, 0, 0, 0.4);
  482 + }
  483 + &__content {
  484 + border: none;
  485 + background-color: #ffffff !important;
  486 + display: flex;
  487 + &-input {
  488 + padding-left: 0 !important;
  489 + height: 48rpx;
  490 + line-height: 48rpx;
  491 + font-size: 32rpx;
  492 + }
  493 + }
  494 + }
  495 + &.select-item {
  496 + &.is-empty {
  497 + .uni-list-item__extra-text { color: rgba(0, 0, 0, 0.4) !important; }
  498 + }
  499 + &.is-filled {
  500 + .uni-list-item__extra-text { color: rgba(0, 0, 0, 0.9) !important; }
  501 + }
  502 + }
  503 + }
  504 +}
  505 +
  506 +::v-deep .uni-easyinput {
  507 + width: 100%;
  508 + &__content {
  509 + background: #f8f8f8 !important;
  510 + border-radius: 8rpx;
  511 + &-input { font-size: 30rpx; }
  512 + }
  513 +}
  514 +.block-ops {
  515 + display: flex;
  516 + padding: 20rpx 32rpx 20rpx;
  517 + justify-content: space-around;
  518 +}
  519 +.del {
  520 + color: #D54941;
  521 + font-size: 28rpx;
  522 + display: flex;
  523 + align-items: center;
  524 + image { width: 40rpx; height: 40rpx; }
  525 +}
  526 +.toggle {
  527 + color: $theme-primary;
  528 + font-size: 28rpx;
  529 + display: flex;
  530 + align-items: center;
  531 + image { width: 40rpx; height: 40rpx; }
  532 +}
  533 +.item-title {
  534 + position: relative;
  535 + width: 210rpx;
  536 + margin-right: 32rpx;
  537 + color: rgba(0, 0, 0, 0.9);
  538 + font-size: 32rpx;
  539 + min-height: 48rpx;
  540 + line-height: 48rpx;
  541 + .required {
  542 + color: red;
  543 + position: absolute;
  544 + top: 50%;
  545 + transform: translateY(-50%);
  546 + left: -16rpx;
  547 + }
  548 +}
  549 +.lock-value {
  550 + flex: 1;
  551 + text-align: right;
  552 + font-size: 32rpx;
  553 + color: rgba(0, 0, 0, 0.85);
  554 + padding: 8rpx 0;
  555 +}
  556 +</style>
... ...
  1 +<template>
  2 + <view class="detail-page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <view class="section">
  5 + <text class="row company">{{ safeText(form.code) }}</text>
  6 + <view v-if="canEdit" class="row">
  7 + <text class="label required">公司名称</text>
  8 + <view class="value select-value" @click="openCompanySheet">
  9 + <text :class="form.companyShortName || form.companyName ? '' : 'placeholder'">{{ form.companyShortName || form.companyName || '请选择公司名称' }}</text>
  10 + <text class="arrow">›</text>
  11 + </view>
  12 + </view>
  13 + <view v-else class="row"><text class="label">公司简称</text><text class="value">{{ safeText(form.companyShortName || form.companyName) }}</text></view>
  14 + <view class="row"><text class="label">供应商名称</text><text class="value">{{ safeText(form.supplierName) }}</text></view>
  15 + <view class="row"><text class="label">采购处</text><text class="value">{{ safeText(form.purchaseDepartmentName || form.purchaseDepartment) }}</text></view>
  16 + <view class="row"><text class="label">区域</text><text class="value">{{ safeText(form.regionName || form.region) }}</text></view>
  17 + <view v-if="canEdit" class="row">
  18 + <text class="label required">日期</text>
  19 + <view class="value date-value">
  20 + <uni-datetime-picker type="date" v-model="form.date" return-type="string" />
  21 + </view>
  22 + </view>
  23 + <view v-else class="row"><text class="label">日期</text><text class="value">{{ formatDateOnly(form.date) }}</text></view>
  24 + <view class="row"><text class="label">报价时效</text><text class="value">{{ safeText(form.validityPeriod) }}</text></view>
  25 + <view class="row"><text class="label">报价人</text><text class="value">{{ safeText(form.quoterName) }}</text></view>
  26 + <view class="row"><text class="label">是否长单操作</text><text class="value">{{ boolText(form.longTermOperation) }}</text></view>
  27 + <view class="row"><text class="label">是否终端客户</text><text class="value">{{ boolText(form.terminalCustomer) }}</text></view>
  28 + <view class="row"><text class="label">是否未点价</text><text class="value">{{ boolText(form.priced) }}</text></view>
  29 + <view v-if="form.priced === true" class="row"><text class="label">点价截止日期</text><text class="value">{{ formatDateOnly(form.pricingDeadline) }}</text></view>
  30 + <view v-if="form.priced === true" class="row"><text class="label">是否暂定价</text><text class="value">{{ boolText(form.temporaryPrice) }}</text></view>
  31 + <view class="row"><text class="label">其他费用凭票到厂另行结算</text><text class="value">{{ boolText(form.otherExpenseSettlement) }}</text></view>
  32 + <view class="row"><text class="label">交提货方式</text><text class="value">{{ getDeliveryMethodLabel() }}</text></view>
  33 + <view class="row"><text class="label">是否通货买断</text><text class="value">{{ boolText(form.commodityBuyout) }}</text></view>
  34 + <view class="row"><text class="label">是否质量买断</text><text class="value">{{ boolText(form.qualityBuyout) }}</text></view>
  35 + <view class="row"><text class="label">是否数量买断</text><text class="value">{{ boolText(form.quantityBuyout) }}</text></view>
  36 + <view class="row"><text class="label">是否送货上门</text><text class="value">{{ boolText(form.doorDelivery) }}</text></view>
  37 + <view class="row">
  38 + <text class="label">另付运费</text>
  39 + <input v-if="canEdit" class="value line-input" v-model="form.shippingCost" type="digit" placeholder="请输入" @input="onShippingCostInput" @blur="onShippingCostBlur" />
  40 + <text v-else class="value">{{ formatNumber(form.shippingCost) }}</text>
  41 + </view>
  42 + <view class="row"><text class="label">装车费</text><text class="value">{{ formatNumber(form.loadingFee) }}</text></view>
  43 + <view class="row"><text class="label">开票品名</text><text class="value">{{ safeText(form.invoiceProductName) }}</text></view>
  44 + <view class="row"><text class="label">交货日期</text><text class="value">{{ formatDateOnly(form.deliveryDate) }}</text></view>
  45 + <view class="row"><text class="label">结算方式</text><text class="value">{{ safeText(form.settlementMethod) }}</text></view>
  46 + <view class="row"><text class="label">结算比例(%)</text><text class="value">{{ formatNumber(form.settlementRatio) }}</text></view>
  47 + <view class="row">
  48 + <text class="label" :class="{ required: canEdit }">价格表编号</text>
  49 + <view v-if="canEdit" class="value select-value" @click="openPriceTableSheet">
  50 + <text :class="priceTableCodeLabel ? '' : 'placeholder'">{{ priceTableCodeLabel || '请选择价格表编号' }}</text>
  51 + <text class="arrow">›</text>
  52 + </view>
  53 + <text v-else class="value">{{ priceTableDisplay }}</text>
  54 + </view>
  55 + <view class="row"><text class="label">协调事由</text><text class="value">{{ safeText(form.coordinationReason) }}</text></view>
  56 + <view class="row"><text class="label">票类状况</text><text class="value">{{ safeText(form.invoiceTypeStatus) }}</text></view>
  57 + <view class="row"><text class="label">数量合计</text><text class="value">{{ formatNumber(form.totalQuantity) }}</text></view>
  58 + <view class="row" v-if="attachmentList.length">
  59 + <text class="label">附件</text>
  60 + <view class="attach-list">
  61 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  62 + <text class="attach-name">{{ at.name }}</text>
  63 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  64 + </view>
  65 + </view>
  66 + </view>
  67 + </view>
  68 +
  69 + <view class="title-header">
  70 + <image class="title-header_icon" src="/static/images/title.png" />
  71 + <span>明细信息</span>
  72 + </view>
  73 + <view v-if="lineListWithName.length" class="section">
  74 + <view v-for="(line, idx) in lineListWithName" :key="line.itemId || idx" class="line-block">
  75 + <view class="line-title">明细{{ idx + 1 }}</view>
  76 + <view class="row"><text class="label">品种</text><text class="value">{{ safeText(line.productName) }}</text></view>
  77 + <view class="row"><text class="label">料型</text><text class="value">{{ safeText(line.materialType) }}</text></view>
  78 + <view class="row"><text class="label">数量(吨)</text><text class="value">{{ formatNumber(line.quantity) }}</text></view>
  79 + <view class="row"><text class="label">实际采购价</text><text class="value">{{ formatNumber(line.actualPurchasePrice) }}</text></view>
  80 + <view class="row"><text class="label">含运到厂价</text><text class="value">{{ formatNumber(line.includingShippingPrice) }}</text></view>
  81 + <view class="row">
  82 + <text class="label">价格表价格</text>
  83 + <input v-if="canEdit" class="value line-input" v-model="line.priceListPrices" type="digit" placeholder="请输入" @input="onLinePriceInput(idx, $event)" @blur="onLinePriceBlur(idx)" />
  84 + <text v-else class="value">{{ formatNumber(line.priceListPrices) }}</text>
  85 + </view>
  86 + <view class="row"><text class="label">协调幅度</text><text class="value">{{ formatNumber(line.coordinationRange) }}</text></view>
  87 + <view class="row"><text class="label">买断料预计损耗</text><text class="value">{{ formatNumber(line.estimatedLoss) }}</text></view>
  88 + <view class="row"><text class="label">申请损耗(%)</text><text class="value">{{ formatNumber(line.applicationAttrition) }}</text></view>
  89 + <view class="row">
  90 + <text class="label" :class="{ required: canEditWorkshop }">选择分厂</text>
  91 + <view v-if="canEditWorkshop" class="value select-value" @click="openWorkshopSheet(idx)">
  92 + <text :class="line.workshopName ? '' : 'placeholder'">{{ line.workshopName || '请选择分厂' }}</text>
  93 + <text class="arrow">›</text>
  94 + </view>
  95 + <text v-else class="value">{{ safeText(line.workshopName) }}</text>
  96 + </view>
  97 + </view>
  98 + </view>
  99 + <view v-else class="section empty-tip">暂无明细</view>
  100 +
  101 + <view class="title-header">
  102 + <image class="title-header_icon" src="/static/images/title.png" />
  103 + <span>料质状况</span>
  104 + </view>
  105 + <view class="section">
  106 + <view class="row"><text class="label">是否启用料质状况</text><text class="value">{{ boolText(form.materialConditionEnabled) }}</text></view>
  107 + <template v-if="form.materialConditionEnabled">
  108 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  109 + <text class="material-label">{{ mc.label }}</text>
  110 + <view class="tag-list">
  111 + <view v-for="opt in getDictOptions(mc.dictCode)" :key="opt.code" class="tag-btn" :class="{ active: isTagSelected(mc.field, opt.code) }">{{ opt.name }}</view>
  112 + </view>
  113 + </view>
  114 + </template>
  115 + </view>
  116 +
  117 + <view class="title-header">
  118 + <image class="title-header_icon" src="/static/images/title.png" />
  119 + <span>备注</span>
  120 + </view>
  121 + <view class="section">
  122 + <text class="remark-text">{{ safeText(form.remark) }}</text>
  123 + </view>
  124 +
  125 + <view class="title-header">
  126 + <image class="title-header_icon" src="/static/images/title.png" />
  127 + <span>变更事由</span>
  128 + </view>
  129 + <view class="section">
  130 + <text class="remark-text">{{ safeText(form.changeReason) }}</text>
  131 + </view>
  132 + </scroll-view>
  133 +
  134 + <RelateSelectSheet
  135 + v-if="companySheetVisible"
  136 + :visible.sync="companySheetVisible"
  137 + title="选择公司"
  138 + :fetch-fn="fetchCompanyList"
  139 + :display-fields="companyDisplayFields"
  140 + :page-size="20"
  141 + :multiple="false"
  142 + row-key="id"
  143 + @confirm="onCompanyConfirm"
  144 + />
  145 + <RelateSelectSheet
  146 + v-if="priceSheetVisible"
  147 + :visible.sync="priceSheetVisible"
  148 + title="选择价格表"
  149 + :fetch-fn="fetchPriceTableList"
  150 + :display-fields="priceTableDisplayFields"
  151 + :page-size="20"
  152 + :multiple="false"
  153 + row-key="id"
  154 + @confirm="onPriceTableConfirm"
  155 + />
  156 + <SingleSelectSheet
  157 + :visible.sync="workshopSheet.visible"
  158 + title="请选择分厂"
  159 + :options="workshopSheet.options"
  160 + v-model="workshopSheet.value"
  161 + @confirm="onWorkshopConfirm"
  162 + />
  163 + </view>
  164 +</template>
  165 +<script>
  166 +import { procurementPlanChangeFindByIdApi } from '@/api/procure-manage/procurementPlan.js'
  167 +import { breedRelationshipQueryApi, workshopQueryApi, companyShortQueryApi, priceTableQueryApi, priceTableDetailApi } from '@/api/devManage.js'
  168 +import { getDicByCodes } from '@/utils/dic.js'
  169 +import { getInfo } from '@/api/login.js'
  170 +import RelateSelectSheet from '@/components/relate-select/index.vue'
  171 +import SingleSelectSheet from '@/components/single-select/index.vue'
  172 +export default {
  173 + name: 'SchedulePlanChangeViewer',
  174 + components: { RelateSelectSheet, SingleSelectSheet },
  175 + props: { id: { type: [String, Number], default: '' } },
  176 + data() {
  177 + return {
  178 + form: {},
  179 + lineList: [],
  180 + attachmentList: [],
  181 + materialConditionConfigs: [
  182 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  183 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  184 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  185 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  186 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  187 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  188 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  189 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  190 + ],
  191 + dictData: {},
  192 + productOptions: [],
  193 + workshopOptions: [],
  194 + deliveryOptions: [],
  195 + isGyglkzg: false,
  196 + isGyglkzlglg: false,
  197 + companySheetVisible: false,
  198 + priceSheetVisible: false,
  199 + workshopSheet: { visible: false, title: '请选择分厂', options: [], value: '', idx: -1 },
  200 + companyDisplayFields: [
  201 + { label: '公司简称', field: 'companyShortName' },
  202 + { label: '公司名称', field: 'companyName' },
  203 + { label: '编码', field: 'code' }
  204 + ],
  205 + priceTableDisplayFields: [
  206 + { label: '价格表编号', field: 'priceTableCode' },
  207 + { label: '名称', field: 'priceTableName' },
  208 + { label: '日期', field: 'effectiveDate' }
  209 + ]
  210 + }
  211 + },
  212 + computed: {
  213 + isAuditPage() {
  214 + try {
  215 + var pages = getCurrentPages()
  216 + var cur = pages[pages.length - 1]
  217 + var route = cur && cur.route ? String(cur.route) : ''
  218 + return route === 'pages/flow/audit'
  219 + } catch (e) {
  220 + return false
  221 + }
  222 + },
  223 + canEdit() {
  224 + return !!this.isGyglkzg && this.isAuditPage
  225 + },
  226 + canEditWorkshop() {
  227 + return !!this.isGyglkzlglg && this.isAuditPage
  228 + },
  229 + workshopOptsComputed() {
  230 + var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  231 + return list.map(function (o) {
  232 + return {
  233 + label: o.label != null ? o.label : (o.name != null ? o.name : (o.workshopName || '')),
  234 + value: o.value != null ? o.value : (o.id != null ? o.id : o.workshopId)
  235 + }
  236 + })
  237 + },
  238 + shippingCostNumber() {
  239 + var v = this.form.shippingCost
  240 + if (v == null || v === '') return 0
  241 + var n = Number(v)
  242 + return isNaN(n) ? 0 : n
  243 + },
  244 + priceTableCodeLabel() {
  245 + var d = this.form || {}
  246 + var code = d.priceTableCode != null ? d.priceTableCode : ''
  247 + var name = d.priceTableName || ''
  248 + if (name || code) {
  249 + return (name ? name + (code ? ' (' + code + ')' : '') : String(code))
  250 + }
  251 + return ''
  252 + },
  253 + productMap() {
  254 + var list = Array.isArray(this.productOptions) ? this.productOptions : []
  255 + var m = {}
  256 + list.forEach(function (o) {
  257 + var key = String(o.productId || o.id || o.value || '')
  258 + if (key) m[key] = o
  259 + })
  260 + return m
  261 + },
  262 + workshopMap() {
  263 + var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  264 + var m = {}
  265 + list.forEach(function (o) {
  266 + var key = String(o.workshopId || o.id || o.value || '')
  267 + if (key) m[key] = o
  268 + })
  269 + return m
  270 + },
  271 + lineListWithName() {
  272 + var self = this
  273 + var list = Array.isArray(this.lineList) ? this.lineList : []
  274 + return list.map(function (row) {
  275 + if (!row.productName) {
  276 + var pid = String(row.productId || '')
  277 + var p = pid ? self.productMap[pid] : null
  278 + if (p) row.productName = p.productName || p.name || p.label || ''
  279 + }
  280 + if (!row.workshopName) {
  281 + var wid = String(row.workshopId || '')
  282 + var w = wid ? self.workshopMap[wid] : null
  283 + if (w) row.workshopName = w.workshopName || w.name || w.label || ''
  284 + }
  285 + return row
  286 + })
  287 + },
  288 + priceTableDisplay() {
  289 + var d = this.form || {}
  290 + var code = d.priceTableCode != null ? String(d.priceTableCode).trim() : ''
  291 + var name = d.priceTableName || ''
  292 + if (name || code) {
  293 + return (name ? name + (code ? ' (' + code + ')' : '') : String(code))
  294 + }
  295 + return '-'
  296 + }
  297 + },
  298 + created() {
  299 + this.loadDictData()
  300 + this.loadRefData()
  301 + this.getUserInfo()
  302 + },
  303 + watch: {
  304 + id: {
  305 + immediate: true,
  306 + handler(val) {
  307 + const v = (val !== undefined && val !== null) ? String(val) : ''
  308 + if (v) this.loadDetail(v)
  309 + }
  310 + }
  311 + },
  312 + methods: {
  313 + getUserInfo() {
  314 + getInfo()
  315 + .then((res) => {
  316 + this.isGyglkzg = !!(res?.roleCodes?.includes('gyglkzg') && res?.roleCodes?.includes('001'));
  317 + this.isGyglkzlglg = !!(res?.roleCodes?.includes('gyglkzlglg') && res?.roleCodes?.includes('001'));
  318 + })
  319 + .catch((err) => {
  320 + console.error('获取用户信息失败:', err);
  321 + });
  322 + },
  323 + toNumber(v) {
  324 + if (v == null || v === '') return 0
  325 + var n = Number(v)
  326 + return isNaN(n) ? 0 : n
  327 + },
  328 + toFixed(v, n) {
  329 + var num = Number(v)
  330 + if (isNaN(num)) return ''
  331 + return num.toFixed(n)
  332 + },
  333 + getInputValue(e) {
  334 + if (e && e.detail && e.detail.value !== undefined) return e.detail.value
  335 + return e
  336 + },
  337 + async loadDictData() {
  338 + var codes = [].concat(
  339 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  340 + ['DELIVERY_METHOD']
  341 + )
  342 + try {
  343 + var results = await getDicByCodes(codes)
  344 + var d = results || {}
  345 + this.dictData = d
  346 + this.deliveryOptions = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  347 + } catch (e) {
  348 + this.dictData = {}
  349 + this.deliveryOptions = []
  350 + }
  351 + },
  352 + async loadRefData() {
  353 + var self = this
  354 + try {
  355 + var results = await Promise.all([
  356 + this.pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  357 + this.pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  358 + ])
  359 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  360 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  361 + self.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  362 + self.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  363 + } catch (e) {
  364 + self.productOptions = []
  365 + self.workshopOptions = []
  366 + }
  367 + },
  368 + pCall(fn, params) {
  369 + try {
  370 + return Promise.resolve(fn(params))
  371 + } catch (e) {
  372 + return Promise.reject(e)
  373 + }
  374 + },
  375 + async loadDetail(id) {
  376 + try {
  377 + var res = await procurementPlanChangeFindByIdApi({ id: id })
  378 + var d = (res && res.data) ? res.data : {}
  379 + var boolFields = ['longTermOperation', 'terminalCustomer', 'priced', 'temporaryPrice', 'otherExpenseSettlement', 'commodityBuyout', 'qualityBuyout', 'quantityBuyout', 'doorDelivery', 'materialConditionEnabled']
  380 + boolFields.forEach(function (f) {
  381 + var v = d[f]
  382 + if (typeof v === 'string') {
  383 + d[f] = v === 'true' || v === '1'
  384 + } else if (typeof v === 'number') {
  385 + d[f] = v === 1
  386 + } else {
  387 + d[f] = !!v
  388 + }
  389 + })
  390 + this.materialConditionConfigs.forEach(function (mc) {
  391 + var v = d[mc.field]
  392 + if (typeof v === 'string' && v) {
  393 + d[mc.field] = v.split(',').filter(Boolean)
  394 + } else if (!Array.isArray(v)) {
  395 + d[mc.field] = []
  396 + }
  397 + })
  398 + this.form = d
  399 + var lines = d.lines || d.procurementPlanLineList || d.lineList || []
  400 + this.lineList = Array.isArray(lines) ? lines.slice() : []
  401 + // 初始化可编辑字段
  402 + this.form.companyId = d.companyId || ''
  403 + this.form.companyShortName = d.companyShortName || d.companyName || ''
  404 + var date = d.date ? String(d.date).trim() : ''
  405 + this.form.date = date.length >= 10 ? date.slice(0, 10) : date
  406 + var sc = d.shippingCost
  407 + this.form.shippingCost = (sc != null && sc !== '') ? this.toFixed(sc, 2) : ''
  408 + this.buildAttachmentList()
  409 + this.refreshLinesFromShipping()
  410 + if (this.canEdit) {
  411 + this.loadLatestPriceTableAndApply()
  412 + } else {
  413 + this.fetchPriceDetailAndApply(d.priceId)
  414 + }
  415 + } catch (e) {
  416 + this.form = {}
  417 + this.lineList = []
  418 + this.attachmentList = []
  419 + }
  420 + },
  421 + buildAttachmentList() {
  422 + var d = this.form || {}
  423 + var ids = d.attachmentFileIds
  424 + var names = d.attachmentFileNames
  425 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  426 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  427 + var len = Math.max(idArr.length, nameArr.length)
  428 + var list = []
  429 + for (var i = 0; i < len; i++) {
  430 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  431 + }
  432 + this.attachmentList = list
  433 + },
  434 + getDictOptions(dictCode) {
  435 + var data = this.dictData[dictCode]
  436 + return (data && data.data) ? data.data : []
  437 + },
  438 + isTagSelected(field, code) {
  439 + var selected = this.form ? this.form[field] : undefined
  440 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  441 + if (typeof selected === 'string' && selected) {
  442 + return selected.split(',').indexOf(code) >= 0
  443 + }
  444 + return false
  445 + },
  446 + getDeliveryMethodLabel() {
  447 + var opts = this.deliveryOptions || []
  448 + var v = String(this.form.deliveryMode != null ? this.form.deliveryMode : '')
  449 + if (!v) return '-'
  450 + for (var i = 0; i < opts.length; i++) {
  451 + var o = opts[i]
  452 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  453 + if (code === v) return o.name || o.label || '-'
  454 + }
  455 + return v
  456 + },
  457 + boolText(v) {
  458 + if (typeof v === 'boolean') return v ? '是' : '否'
  459 + if (v === 'true' || v === '1' || v === 1) return '是'
  460 + if (v === 'false' || v === '0' || v === 0) return '否'
  461 + return '-'
  462 + },
  463 + formatDateOnly(v) {
  464 + var s = v == null ? '' : String(v).trim()
  465 + if (!s) return '-'
  466 + if (s.length >= 10) return s.slice(0, 10)
  467 + return s
  468 + },
  469 + safeText(v) {
  470 + var s = v == null ? '' : String(v)
  471 + return s.trim() ? s : '-'
  472 + },
  473 + formatNumber(v) {
  474 + if (v == null || v === '') return '-'
  475 + var n = Number(v)
  476 + if (isNaN(n)) return String(v)
  477 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  478 + },
  479 + onPreviewAttachment(at) {
  480 + if (!at || !at.id) {
  481 + uni.showToast({ title: '无法查看', icon: 'none' })
  482 + return
  483 + }
  484 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  485 + },
  486 + // ==================== 公司下拉 ====================
  487 + fetchCompanyList(args) {
  488 + var extra = (args && args.extra) ? args.extra : {}
  489 + var keyword = extra.keyword || extra.name || ''
  490 + var params = { pageIndex: args.pageIndex || 1, pageSize: args.pageSize || 20 }
  491 + if (keyword) params.name = keyword
  492 + return companyShortQueryApi(params).then(function (res) {
  493 + var d = (res && res.data) ? res.data : {}
  494 + var records = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.records && Array.isArray(d.records)) ? d.records : ((d.list && Array.isArray(d.list)) ? d.list : []))
  495 + var total = d.totalCount || d.count || (records ? records.length : 0)
  496 + var hasNext = !!d.hasNext
  497 + return { records: records, totalCount: total, hasNext: hasNext }
  498 + }).catch(function () {
  499 + return { records: [], totalCount: 0, hasNext: false }
  500 + })
  501 + },
  502 + openCompanySheet() {
  503 + this.companySheetVisible = true
  504 + },
  505 + onCompanyConfirm(e) {
  506 + var items = (e && e.items) ? e.items : []
  507 + if (!items.length) return
  508 + var row = items[0] || {}
  509 + this.form.companyId = row.id || ''
  510 + this.form.companyShortName = row.companyShortName || row.companyName || row.name || ''
  511 + },
  512 + // ==================== 价格表下拉 ====================
  513 + fetchPriceTableList(args) {
  514 + var extra = (args && args.extra) ? args.extra : {}
  515 + var keyword = extra.keyword || extra.name || ''
  516 + var params = { pageIndex: args.pageIndex || 1, pageSize: args.pageSize || 20 }
  517 + if (keyword) params.name = keyword
  518 + return priceTableQueryApi(params).then(function (res) {
  519 + var d = (res && res.data) ? res.data : {}
  520 + var records = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.records && Array.isArray(d.records)) ? d.records : ((d.list && Array.isArray(d.list)) ? d.list : []))
  521 + var total = d.totalCount || d.count || (records ? records.length : 0)
  522 + var hasNext = !!d.hasNext
  523 + return { records: records, totalCount: total, hasNext: hasNext }
  524 + }).catch(function () {
  525 + return { records: [], totalCount: 0, hasNext: false }
  526 + })
  527 + },
  528 + openPriceTableSheet() {
  529 + this.priceSheetVisible = true
  530 + },
  531 + onPriceTableConfirm(e) {
  532 + var items = (e && e.items) ? e.items : []
  533 + if (!items.length) return
  534 + this.selectPriceTableRow(items[0] || {})
  535 + },
  536 + selectPriceTableRow(row) {
  537 + this.form.priceTableId = row.id || ''
  538 + this.form.priceTableCode = row.priceTableCode || row.code || ''
  539 + this.form.priceTableName = row.priceTableName || row.name || ''
  540 + if (this.form.priceTableId) {
  541 + this.fetchPriceDetailAndApply(this.form.priceTableId)
  542 + }
  543 + },
  544 + async loadLatestPriceTableAndApply() {
  545 + var self = this
  546 + try {
  547 + var res = await priceTableQueryApi({ pageIndex: 1, pageSize: 1, orderByColumn: 'createTime desc,id desc' })
  548 + var d = (res && res.data) ? res.data : {}
  549 + var list = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.records && Array.isArray(d.records)) ? d.records : ((d.list && Array.isArray(d.list)) ? d.list : []))
  550 + if (!list || !list.length) return
  551 + self.selectPriceTableRow(list[0])
  552 + } catch (e) {
  553 + return
  554 + }
  555 + },
  556 + async fetchPriceDetailAndApply(priceId) {
  557 + if (!priceId) return
  558 + var self = this
  559 + try {
  560 + var res = await priceTableDetailApi({ id: priceId })
  561 + var d = (res && res.data) ? res.data : {}
  562 + if (d.code != null && this.form) {
  563 + this.$set(this.form, 'priceTableCode', String(d.code))
  564 + }
  565 + if (d.priceTableName != null && this.form) {
  566 + this.$set(this.form, 'priceTableName', d.priceTableName)
  567 + }
  568 + var priceLines = self.extractPriceLines(d)
  569 + self.applyPriceLinesToLines(priceLines)
  570 + } catch (e) {
  571 + return
  572 + }
  573 + },
  574 + extractPriceLines(priceDetail) {
  575 + if (!priceDetail || typeof priceDetail !== 'object') return []
  576 + var candidates = [
  577 + priceDetail.procurementPriceLineList,
  578 + priceDetail.priceLineList,
  579 + priceDetail.priceList,
  580 + priceDetail.lineList,
  581 + priceDetail.datas,
  582 + priceDetail.records,
  583 + priceDetail.list
  584 + ]
  585 + for (var i = 0; i < candidates.length; i++) {
  586 + if (Array.isArray(candidates[i]) && candidates[i].length) return candidates[i]
  587 + }
  588 + for (var k in priceDetail) {
  589 + if (!Object.prototype.hasOwnProperty.call(priceDetail, k)) continue
  590 + if (Array.isArray(priceDetail[k])) {
  591 + var arr = priceDetail[k]
  592 + if (arr.length && arr[0] && typeof arr[0] === 'object' && (arr[0].price != null || arr[0].productId != null || arr[0].breedId != null || arr[0].varietyId != null)) {
  593 + return arr
  594 + }
  595 + }
  596 + }
  597 + return []
  598 + },
  599 + applyPriceLinesToLines(priceLines) {
  600 + if (!Array.isArray(this.lineList)) return
  601 + var priceMap = this.buildPriceMap(priceLines)
  602 + var self = this
  603 + this.lineList = this.lineList.map(function (row) {
  604 + var pid = String(row.productId || row.breedId || row.varietyId || '')
  605 + var price = null
  606 + if (pid && priceMap[pid] != null) {
  607 + price = priceMap[pid].price
  608 + } else {
  609 + var pname = (row.productName || '').trim()
  610 + if (pname) {
  611 + for (var k in priceMap) {
  612 + if (!Object.prototype.hasOwnProperty.call(priceMap, k)) continue
  613 + var meta = priceMap[k] && priceMap[k].meta ? priceMap[k].meta : null
  614 + if (meta && ((meta.productName && meta.productName === pname) || (meta.breedName && meta.breedName === pname) || (meta.varietyName && meta.varietyName === pname))) {
  615 + price = priceMap[k].price
  616 + break
  617 + }
  618 + }
  619 + }
  620 + }
  621 + if (price != null) {
  622 + row.priceListPrices = self.toFixed(price, 2)
  623 + } else {
  624 + row.priceListPrices = ''
  625 + }
  626 + return row
  627 + })
  628 + this.refreshLinesFromShipping()
  629 + },
  630 + buildPriceMap(priceLines) {
  631 + var m = {}
  632 + if (!Array.isArray(priceLines)) return m
  633 + for (var i = 0; i < priceLines.length; i++) {
  634 + var line = priceLines[i] || {}
  635 + if (line.price == null) continue
  636 + var key = String(line.productId || line.breedId || line.varietyId || line.id || ('__idx_' + i))
  637 + m[key] = { price: Number(line.price), meta: line }
  638 + }
  639 + return m
  640 + },
  641 + // ==================== 分厂选择 ====================
  642 + openWorkshopSheet(idx) {
  643 + var wOpts = this.workshopOptsComputed
  644 + var curW = this.lineList[idx] && this.lineList[idx].workshopId
  645 + var mW = wOpts.find(function (o) { return String(o.value) === String(curW) })
  646 + this.workshopSheet = { visible: true, title: '请选择分厂', options: wOpts, value: mW ? mW.value : '', idx: idx }
  647 + },
  648 + onWorkshopConfirm(_ref) {
  649 + var value = _ref.value
  650 + var label = _ref.label
  651 + var idx = this.workshopSheet.idx
  652 + if (idx < 0 || !this.lineList[idx]) return
  653 + var row = this.lineList[idx]
  654 + this.$set(row, 'workshopId', value)
  655 + this.$set(row, 'workshopName', label)
  656 + },
  657 + // ==================== 联动计算 ====================
  658 + onShippingCostInput(e) {
  659 + var s = this.getInputValue(e)
  660 + s = s == null ? '' : String(s)
  661 + s = s.replace(/[^\d.]/g, '')
  662 + var parts = s.split('.')
  663 + if (parts.length > 2) s = parts[0] + '.' + parts.slice(1).join('')
  664 + this.form.shippingCost = s
  665 + this.refreshLinesFromShipping()
  666 + },
  667 + onShippingCostBlur() {
  668 + if (this.form.shippingCost == null || this.form.shippingCost === '') {
  669 + this.refreshLinesFromShipping()
  670 + return
  671 + }
  672 + var n = Number(this.form.shippingCost)
  673 + if (isNaN(n) || n < 0) {
  674 + this.form.shippingCost = ''
  675 + } else {
  676 + this.form.shippingCost = this.toFixed(n, 2)
  677 + }
  678 + this.refreshLinesFromShipping()
  679 + },
  680 + onLinePriceInput(idx, e) {
  681 + var s = this.getInputValue(e)
  682 + s = s == null ? '' : String(s)
  683 + s = s.replace(/[^\d.]/g, '')
  684 + var parts = s.split('.')
  685 + if (parts.length > 2) s = parts[0] + '.' + parts.slice(1).join('')
  686 + var row = this.lineList[idx]
  687 + if (row) {
  688 + this.$set(row, 'priceListPrices', s)
  689 + this.recalcLine(idx)
  690 + }
  691 + },
  692 + onLinePriceBlur(idx) {
  693 + var row = this.lineList[idx]
  694 + if (!row) return
  695 + if (row.priceListPrices == null || row.priceListPrices === '') {
  696 + this.recalcLine(idx)
  697 + return
  698 + }
  699 + var n = Number(row.priceListPrices)
  700 + if (isNaN(n) || n < 0) {
  701 + this.$set(row, 'priceListPrices', '')
  702 + } else {
  703 + this.$set(row, 'priceListPrices', this.toFixed(n, 2))
  704 + }
  705 + this.recalcLine(idx)
  706 + },
  707 + refreshLinesFromShipping() {
  708 + var self = this
  709 + var sc = self.shippingCostNumber
  710 + if (!Array.isArray(self.lineList)) return
  711 + self.lineList = self.lineList.map(function (row) {
  712 + var actual = self.toNumber(row.actualPurchasePrice)
  713 + var including = actual + sc
  714 + row.includingShippingPrice = self.toFixed(including, 2)
  715 + var priceList = self.toNumber(row.priceListPrices)
  716 + var loss = self.toNumber(row.estimatedLoss)
  717 + var coord = including + loss - priceList
  718 + row.coordinationRange = self.toFixed(coord, 2)
  719 + return row
  720 + })
  721 + },
  722 + recalcLine(idx) {
  723 + var row = this.lineList[idx]
  724 + if (!row) return
  725 + var actual = this.toNumber(row.actualPurchasePrice)
  726 + var including = actual + this.shippingCostNumber
  727 + this.$set(row, 'includingShippingPrice', this.toFixed(including, 2))
  728 + var priceList = this.toNumber(row.priceListPrices)
  729 + var loss = this.toNumber(row.estimatedLoss)
  730 + var coord = including + loss - priceList
  731 + this.$set(row, 'coordinationRange', this.toFixed(coord, 2))
  732 + },
  733 + // ==================== 审核提交 ====================
  734 + checkForm() {
  735 + if (!this.canEdit) return true
  736 + if (!this.form.companyId) {
  737 + uni.showToast({ title: '请选择公司名称', icon: 'none' })
  738 + return false
  739 + }
  740 + if (!this.form.date) {
  741 + uni.showToast({ title: '请选择日期', icon: 'none' })
  742 + return false
  743 + }
  744 + if (!this.form.priceTableId) {
  745 + uni.showToast({ title: '请选择价格表编号', icon: 'none' })
  746 + return false
  747 + }
  748 + if (this.canEditWorkshop) {
  749 + var list = Array.isArray(this.lineList) ? this.lineList : []
  750 + for (var i = 0; i < list.length; i++) {
  751 + if (!list[i].workshopId) {
  752 + uni.showToast({ title: '请选择明细' + (i + 1) + '的分厂', icon: 'none' })
  753 + return false
  754 + }
  755 + }
  756 + }
  757 + return true
  758 + },
  759 + getFormValues() {
  760 + var self = this
  761 + var lines = Array.isArray(this.lineList) ? this.lineList : []
  762 + return {
  763 + companyId: this.form.companyId || '',
  764 + companyShortName: this.form.companyShortName || this.form.companyName || '',
  765 + date: this.form.date || '',
  766 + shippingCost: this.form.shippingCost != null && this.form.shippingCost !== '' ? this.toNumber(this.form.shippingCost) : null,
  767 + priceTableId: this.form.priceTableId || '',
  768 + priceTableCode: this.form.priceTableCode || '',
  769 + lineList: lines.map(function (r) {
  770 + return {
  771 + itemId: r.itemId || r.id || '',
  772 + workshopId: r.workshopId || '',
  773 + workshopName: r.workshopName || '',
  774 + priceListPrices: self.toNumber(r.priceListPrices),
  775 + includingShippingPrice: self.toNumber(r.includingShippingPrice),
  776 + coordinationRange: self.toNumber(r.coordinationRange)
  777 + }
  778 + })
  779 + }
  780 + }
  781 + }
  782 +}
  783 +</script>
  784 +<style lang="scss" scoped>
  785 +.detail-page {
  786 + background: #f3f3f3;
  787 +}
  788 +.scroll {
  789 + flex: 1;
  790 + padding: 8rpx 0 48rpx;
  791 +}
  792 +.title-header {
  793 + display: flex;
  794 + align-items: center;
  795 + padding: 24rpx 32rpx 12rpx;
  796 + background-color: #ffffff;
  797 + .title-header_icon {
  798 + width: 36rpx;
  799 + height: 36rpx;
  800 + margin-right: 12rpx;
  801 + }
  802 + span {
  803 + font-size: 34rpx;
  804 + font-weight: 600;
  805 + color: rgba(0, 0, 0, 0.9);
  806 + }
  807 +}
  808 +.section {
  809 + padding: 32rpx;
  810 + background: #fff;
  811 + margin-bottom: 20rpx;
  812 +}
  813 +.row {
  814 + display: flex;
  815 + margin-bottom: 28rpx;
  816 + align-items: center;
  817 + &:last-child { margin-bottom: 0; }
  818 + &.company {
  819 + font-size: 36rpx;
  820 + font-weight: 600;
  821 + color: rgba(0, 0, 0, 0.9);
  822 + padding-top: 8rpx;
  823 + line-height: 50rpx;
  824 + }
  825 + .label {
  826 + max-width: 420rpx;
  827 + margin-right: 20rpx;
  828 + line-height: 32rpx;
  829 + font-size: 28rpx;
  830 + color: rgba(0, 0, 0, 0.6);
  831 + &.required {
  832 + position: relative;
  833 + &::before {
  834 + content: '*';
  835 + color: #D54941;
  836 + margin-right: 6rpx;
  837 + }
  838 + }
  839 + }
  840 + .value {
  841 + flex: 1;
  842 + line-height: 32rpx;
  843 + font-size: 28rpx;
  844 + color: rgba(0, 0, 0, 0.9);
  845 + text-align: right;
  846 + word-break: break-all;
  847 + &.placeholder {
  848 + color: rgba(0, 0, 0, 0.4);
  849 + }
  850 + }
  851 +}
  852 +.select-value {
  853 + display: flex;
  854 + align-items: center;
  855 + justify-content: flex-end;
  856 + .arrow {
  857 + margin-left: 8rpx;
  858 + color: rgba(0, 0, 0, 0.4);
  859 + font-size: 30rpx;
  860 + }
  861 +}
  862 +.date-value {
  863 + ::v-deep .uni-datetime-picker {
  864 + display: inline-flex;
  865 + justify-content: flex-end;
  866 + .uni-datetime-picker__btn {
  867 + padding: 0;
  868 + border: none;
  869 + background: transparent;
  870 + font-size: 28rpx;
  871 + color: rgba(0, 0, 0, 0.9);
  872 + }
  873 + }
  874 +}
  875 +.line-input {
  876 + border-bottom: 1rpx solid #ddd;
  877 + padding: 4rpx 0;
  878 + text-align: right;
  879 + height: 40rpx;
  880 + min-height: 40rpx;
  881 + font-size: 28rpx;
  882 +}
  883 +.line-block {
  884 + padding-bottom: 24rpx;
  885 + margin-bottom: 24rpx;
  886 + border-bottom: 1rpx solid #f0f0f0;
  887 + &:last-child {
  888 + padding-bottom: 0;
  889 + margin-bottom: 0;
  890 + border-bottom: none;
  891 + }
  892 +}
  893 +.line-title {
  894 + font-size: 30rpx;
  895 + font-weight: 600;
  896 + color: rgba(0, 0, 0, 0.9);
  897 + margin-bottom: 20rpx;
  898 +}
  899 +.attach-list {
  900 + flex: 1;
  901 + display: flex;
  902 + flex-direction: column;
  903 + align-items: flex-end;
  904 + gap: 8rpx;
  905 +}
  906 +.attach-item {
  907 + display: flex;
  908 + align-items: center;
  909 + gap: 16rpx;
  910 + .attach-name {
  911 + font-size: 26rpx;
  912 + color: rgba(0, 0, 0, 0.9);
  913 + }
  914 + .attach-view {
  915 + font-size: 26rpx;
  916 + color: $theme-primary;
  917 + }
  918 +}
  919 +.material-group {
  920 + margin-top: 32rpx;
  921 + &:first-child { margin-top: 0; }
  922 +}
  923 +.material-label {
  924 + display: block;
  925 + font-size: 28rpx;
  926 + color: rgba(0, 0, 0, 0.6);
  927 + margin-bottom: 20rpx;
  928 +}
  929 +.tag-list {
  930 + display: flex;
  931 + flex-wrap: wrap;
  932 + gap: 16rpx;
  933 +}
  934 +.tag-btn {
  935 + padding: 12rpx 24rpx;
  936 + border: 1rpx solid #ddd;
  937 + border-radius: 8rpx;
  938 + font-size: 28rpx;
  939 + color: #999;
  940 + background: #f5f5f5;
  941 +}
  942 +.tag-btn.active {
  943 + background: $theme-primary;
  944 + border-color: $theme-primary;
  945 + color: #fff;
  946 +}
  947 +.remark-text {
  948 + font-size: 28rpx;
  949 + color: rgba(0, 0, 0, 0.9);
  950 + line-height: 1.6;
  951 + white-space: pre-wrap;
  952 +}
  953 +.empty-tip {
  954 + text-align: center;
  955 + font-size: 28rpx;
  956 + color: rgba(0, 0, 0, 0.4);
  957 + padding: 24rpx 0;
  958 +}
  959 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view scroll-y class="scroll">
  4 + <uni-list>
  5 + <uni-list-item class="select-item" :class="form.code ? 'is-filled' : 'is-empty'" clickable
  6 + @click="openPlanSheet" :rightText="form.code || '请选择计划编号'" showArrow>
  7 + <template v-slot:body>
  8 + <view class="item-title"><text class="required">*</text><text>计划数据</text></view>
  9 + </template>
  10 + </uni-list-item>
  11 +
  12 + <uni-list-item title="公司名称">
  13 + <template v-slot:footer>
  14 + <uni-easyinput v-model="companyNameDisplay" :inputBorder="false" disabled placeholder="-" />
  15 + </template>
  16 + </uni-list-item>
  17 +
  18 + <uni-list-item>
  19 + <template v-slot:body>
  20 + <view class="item-title"><text class="required">*</text><text>供应商名称</text></view>
  21 + </template>
  22 + <template v-slot:footer>
  23 + <uni-easyinput v-model="detail.supplierName" :inputBorder="false" placeholder="请输入供应商名称" />
  24 + </template>
  25 + </uni-list-item>
  26 +
  27 + <uni-list-item title="采购处">
  28 + <template v-slot:footer>
  29 + <uni-easyinput v-model="purchaseDepartmentDisplay" :inputBorder="false" disabled placeholder="-" />
  30 + </template>
  31 + </uni-list-item>
  32 +
  33 + <uni-list-item title="区域">
  34 + <template v-slot:footer>
  35 + <uni-easyinput v-model="regionDisplay" :inputBorder="false" disabled placeholder="-" />
  36 + </template>
  37 + </uni-list-item>
  38 +
  39 + <uni-list-item title="日期">
  40 + <template v-slot:footer>
  41 + <uni-easyinput v-model="dateDisplay" :inputBorder="false" disabled placeholder="-" />
  42 + </template>
  43 + </uni-list-item>
  44 +
  45 + <uni-list-item>
  46 + <template v-slot:body>
  47 + <view class="item-title"><text class="required">*</text><text>报价时效</text></view>
  48 + </template>
  49 + <template v-slot:footer>
  50 + <uni-easyinput v-model="detail.validityPeriod" :inputBorder="false" placeholder="请输入报价时效" />
  51 + </template>
  52 + </uni-list-item>
  53 +
  54 + <uni-list-item>
  55 + <template v-slot:body>
  56 + <view class="item-title"><text class="required">*</text><text>报价人</text></view>
  57 + </template>
  58 + <template v-slot:footer>
  59 + <uni-easyinput v-model="detail.quoterName" :inputBorder="false" placeholder="请输入报价人" />
  60 + </template>
  61 + </uni-list-item>
  62 +
  63 + <uni-list-item class="select-item" :class="typeof detail.longTermOperation === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  64 + @click="toggleBool('longTermOperation')" :rightText="boolText(detail.longTermOperation) || '请选择'" showArrow>
  65 + <template v-slot:body>
  66 + <view class="item-title"><text class="required">*</text><text>是否长单操作</text></view>
  67 + </template>
  68 + </uni-list-item>
  69 +
  70 + <uni-list-item class="select-item" :class="typeof detail.terminalCustomer === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  71 + @click="toggleBool('terminalCustomer')" :rightText="boolText(detail.terminalCustomer) || '请选择'" showArrow>
  72 + <template v-slot:body>
  73 + <view class="item-title"><text class="required">*</text><text>是否终端客户</text></view>
  74 + </template>
  75 + </uni-list-item>
  76 +
  77 + <uni-list-item class="select-item" :class="typeof detail.priced === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  78 + @click="toggleBool('priced')" :rightText="boolText(detail.priced) || '请选择'" showArrow>
  79 + <template v-slot:body>
  80 + <view class="item-title"><text class="required">*</text><text>是否未点价</text></view>
  81 + </template>
  82 + </uni-list-item>
  83 +
  84 + <uni-list-item v-if="detail.priced === true">
  85 + <template v-slot:body>
  86 + <view class="item-title"><text class="required">*</text><text>点价截止日期</text></view>
  87 + </template>
  88 + <template v-slot:footer>
  89 + <uni-datetime-picker type="date" v-model="detail.pricingDeadline" return-type="string" />
  90 + </template>
  91 + </uni-list-item>
  92 +
  93 + <uni-list-item v-if="detail.priced === true" class="select-item" :class="typeof detail.temporaryPrice === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  94 + @click="toggleBool('temporaryPrice')" :rightText="boolText(detail.temporaryPrice) || '请选择'" showArrow>
  95 + <template v-slot:body>
  96 + <view class="item-title"><text class="required">*</text><text>是否暂定价</text></view>
  97 + </template>
  98 + </uni-list-item>
  99 +
  100 + <uni-list-item class="select-item" :class="typeof detail.otherExpenseSettlement === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  101 + @click="toggleBool('otherExpenseSettlement')" :rightText="boolText(detail.otherExpenseSettlement) || '请选择'" showArrow>
  102 + <template v-slot:body>
  103 + <view class="item-title"><text class="required">*</text><text>其他费用凭票到厂另行结算</text></view>
  104 + </template>
  105 + </uni-list-item>
  106 +
  107 + <uni-list-item class="select-item" :class="detail.deliveryMode ? 'is-filled' : 'is-empty'" clickable
  108 + @click="openDeliverySheet" :rightText="getDeliveryMethodLabel()" showArrow>
  109 + <template v-slot:body>
  110 + <view class="item-title"><text class="required">*</text><text>交提货方式</text></view>
  111 + </template>
  112 + </uni-list-item>
  113 +
  114 + <uni-list-item class="select-item" :class="typeof detail.commodityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  115 + @click="toggleBool('commodityBuyout')" :rightText="boolText(detail.commodityBuyout) || '请选择'" showArrow>
  116 + <template v-slot:body>
  117 + <view class="item-title"><text>是否通货买断</text></view>
  118 + </template>
  119 + </uni-list-item>
  120 +
  121 + <uni-list-item class="select-item" :class="typeof detail.qualityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  122 + @click="toggleBool('qualityBuyout')" :rightText="boolText(detail.qualityBuyout) || '请选择'" showArrow>
  123 + <template v-slot:body>
  124 + <view class="item-title"><text class="required">*</text><text>是否质量买断</text></view>
  125 + </template>
  126 + </uni-list-item>
  127 +
  128 + <uni-list-item class="select-item" :class="typeof detail.quantityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  129 + @click="toggleBool('quantityBuyout')" :rightText="boolText(detail.quantityBuyout) || '请选择'" showArrow>
  130 + <template v-slot:body>
  131 + <view class="item-title"><text>是否数量买断</text></view>
  132 + </template>
  133 + </uni-list-item>
  134 +
  135 + <uni-list-item class="select-item" :class="typeof detail.doorDelivery === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  136 + @click="toggleBool('doorDelivery')" :rightText="boolText(detail.doorDelivery) || '请选择'" showArrow>
  137 + <template v-slot:body>
  138 + <view class="item-title"><text class="required">*</text><text>是否送货上门</text></view>
  139 + </template>
  140 + </uni-list-item>
  141 +
  142 + <uni-list-item title="另付运费">
  143 + <template v-slot:footer>
  144 + <uni-easyinput v-model="shippingCostDisplay" :inputBorder="false" disabled placeholder="-" />
  145 + </template>
  146 + </uni-list-item>
  147 +
  148 + <uni-list-item>
  149 + <template v-slot:body>
  150 + <view class="item-title"><text class="required">*</text><text>装车费</text></view>
  151 + </template>
  152 + <template v-slot:footer>
  153 + <uni-easyinput
  154 + v-model="detail.loadingFee"
  155 + type="digit"
  156 + :inputBorder="false"
  157 + placeholder="请输入装车费"
  158 + @input="onNonNegativeInput('loadingFee')"
  159 + @blur="onNonNegativeBlur('loadingFee', 2)"
  160 + />
  161 + </template>
  162 + </uni-list-item>
  163 +
  164 + <uni-list-item title="开票品名">
  165 + <template v-slot:footer>
  166 + <uni-easyinput v-model="detail.invoiceProductName" :inputBorder="false" placeholder="请输入开票品名" />
  167 + </template>
  168 + </uni-list-item>
  169 +
  170 + <uni-list-item>
  171 + <template v-slot:body>
  172 + <view class="item-title"><text class="required">*</text><text>交货日期</text></view>
  173 + </template>
  174 + <template v-slot:footer>
  175 + <uni-datetime-picker type="date" v-model="detail.deliveryDate" return-type="string" />
  176 + </template>
  177 + </uni-list-item>
  178 + <uni-list-item>
  179 + <template v-slot:body>
  180 + <view class="item-title"><text class="required">*</text><text>结算方式</text></view>
  181 + </template>
  182 + <template v-slot:footer>
  183 + <uni-easyinput v-model="detail.settlementMethod" :inputBorder="false" placeholder="请输入结算方式" />
  184 + </template>
  185 + </uni-list-item>
  186 +
  187 + <uni-list-item>
  188 + <template v-slot:body>
  189 + <view class="item-title"><text class="required">*</text><text>结算比例(%)</text></view>
  190 + </template>
  191 + <template v-slot:footer>
  192 + <uni-easyinput
  193 + v-model="detail.settlementRatio"
  194 + type="digit"
  195 + :inputBorder="false"
  196 + placeholder="请输入结算比例"
  197 + @input="onNonNegativeInput('settlementRatio')"
  198 + @blur="onNonNegativeBlur('settlementRatio', 4)"
  199 + />
  200 + </template>
  201 + </uni-list-item>
  202 +
  203 + <uni-list-item title="价格表编号">
  204 + <template v-slot:footer>
  205 + <uni-easyinput v-model="priceTableDisplay" :inputBorder="false" disabled placeholder="-" />
  206 + </template>
  207 + </uni-list-item>
  208 +
  209 + <uni-list-item>
  210 + <template v-slot:body>
  211 + <view class="item-title"><text class="required">*</text><text>协调事由</text></view>
  212 + </template>
  213 + <template v-slot:footer>
  214 + <uni-easyinput v-model="detail.coordinationReason" :inputBorder="false" placeholder="请输入协调事由" />
  215 + </template>
  216 + </uni-list-item>
  217 +
  218 + <uni-list-item>
  219 + <template v-slot:body>
  220 + <view class="item-title"><text class="required">*</text><text>票类状况</text></view>
  221 + </template>
  222 + <template v-slot:footer>
  223 + <uni-easyinput v-model="detail.invoiceTypeStatus" :inputBorder="false" placeholder="请输入票类状况" />
  224 + </template>
  225 + </uni-list-item>
  226 +
  227 + <uni-list-item v-if="attachmentList.length" title="附件">
  228 + <template v-slot:footer>
  229 + <view class="attach-list">
  230 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  231 + <text class="attach-name">{{ at.name }}</text>
  232 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  233 + </view>
  234 + </view>
  235 + </template>
  236 + </uni-list-item>
  237 +
  238 + <ProductRel
  239 + ref="productRel"
  240 + mode="edit"
  241 + :list="lineList"
  242 + :product-options="productOptions"
  243 + :workshop-options="workshopOptions"
  244 + :shipping-cost="detail.shippingCost"
  245 + :price-map="priceMap"
  246 + @change="onLineChange"
  247 + />
  248 + </uni-list>
  249 +
  250 + <view class="material-condition-section">
  251 + <view class="section-header">
  252 + <image class="opCollapse" src="/static/images/title.png" />
  253 + <text class="section-title">料质状况</text>
  254 + </view>
  255 + <view class="section-content">
  256 + <view class="form-row">
  257 + <text class="form-label">是否启用料质状况</text>
  258 + <text class="form-value toggle-link" @click="toggleBool('materialConditionEnabled')">{{ boolText(detail.materialConditionEnabled) || '请选择' }}</text>
  259 + </view>
  260 + <template v-if="detail.materialConditionEnabled">
  261 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  262 + <text class="material-label">{{ mc.label }}</text>
  263 + <view class="tag-list">
  264 + <view
  265 + v-for="opt in getDictOptions(mc.dictCode)"
  266 + :key="opt.code"
  267 + class="tag-btn"
  268 + :class="{ active: isTagSelected(mc.field, opt.code) }"
  269 + @click="toggleTag(mc.field, opt.code)"
  270 + >
  271 + {{ opt.name }}
  272 + </view>
  273 + </view>
  274 + </view>
  275 + </template>
  276 + </view>
  277 + </view>
  278 +
  279 + <view class="remark-section">
  280 + <view class="section-header">
  281 + <image class="opCollapse" src="/static/images/title.png" />
  282 + <text class="section-title">备注</text>
  283 + </view>
  284 + <view class="section-content">
  285 + <uni-easyinput type="textarea" v-model="detail.remark" :inputBorder="false" placeholder="请输入备注" />
  286 + </view>
  287 + </view>
  288 + <view class="remark-section">
  289 + <view class="section-header">
  290 + <image class="opCollapse" src="/static/images/title.png" />
  291 + <text class="section-title"><text class="required">*</text>变更事由</text>
  292 + </view>
  293 + <view class="section-content">
  294 + <uni-easyinput type="textarea" v-model="detail.changeReason" :inputBorder="false" placeholder="请输入变更事由" />
  295 + </view>
  296 + </view>
  297 + </scroll-view>
  298 +
  299 + <view class="bottom-bar">
  300 + <button class="btn btn-outline" @click="onBack">取消</button>
  301 + <button class="btn btn-primary" @click="onSubmit">保存</button>
  302 + </view>
  303 +
  304 + <RelateSelectSheet
  305 + v-if="planSheetVisible"
  306 + :visible.sync="planSheetVisible"
  307 + title="选择计划"
  308 + :fetch-fn="fetchChangePlanList"
  309 + :display-fields="planDisplayFields"
  310 + :page-size="20"
  311 + :multiple="false"
  312 + row-key="id"
  313 + @confirm="onPlanConfirm"
  314 + />
  315 + <SingleSelectSheet
  316 + :visible.sync="deliverySheetVisible"
  317 + title="交提货方式"
  318 + :options="deliveryOptions"
  319 + v-model="deliverySheetValue"
  320 + @confirm="onDeliveryConfirm"
  321 + />
  322 + </view>
  323 +</template>
  324 +
  325 +<script>
  326 +import ProductRel from './productRel.vue'
  327 +import RelateSelectSheet from '@/components/relate-select/index.vue'
  328 +import SingleSelectSheet from '@/components/single-select/index.vue'
  329 +import { procurementPlanDetailApi, procurementPlanCanChangeOrReplenishmentApi, procurementPlanReplenplenishApi } from '@/api/procure-manage/procurementPlan.js'
  330 +import {
  331 + breedRelationshipQueryApi,
  332 + priceTableDetailApi,
  333 + workshopQueryApi
  334 +} from '@/api/devManage.js'
  335 +import { getDicByCodes } from '@/utils/dic.js'
  336 +
  337 +export default {
  338 + name: 'SchedulePlanAdd',
  339 + components: { ProductRel, RelateSelectSheet, SingleSelectSheet },
  340 + data() {
  341 + return {
  342 + form: {
  343 + planId: '',
  344 + code: ''
  345 + },
  346 + detail: {},
  347 + attachmentList: [],
  348 + materialConditionConfigs: [
  349 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  350 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  351 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  352 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  353 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  354 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  355 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  356 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  357 + ],
  358 + dicOptions: {
  359 + DELIVERY_METHOD: []
  360 + },
  361 + dictData: {},
  362 + lineList: [],
  363 + productOptions: [],
  364 + workshopOptions: [],
  365 + priceMap: {},
  366 + planSheetVisible: false,
  367 + planDisplayFields: [
  368 + { label: '计划编号', field: 'code' },
  369 + { label: '公司简称', field: 'companyShortName' },
  370 + { label: '供应商名称', field: 'supplierName' },
  371 + { label: '数量', field: 'totalQuantity' },
  372 + { label: '采购处', field: 'purchaseDepartmentName' }
  373 + ],
  374 + deliverySheetVisible: false,
  375 + deliverySheetValue: '',
  376 + deliveryOptions: []
  377 + }
  378 + },
  379 + computed: {
  380 + companyNameDisplay() {
  381 + var d = this.detail || {}
  382 + return d.companyShortName != null ? d.companyShortName : (d.companyName != null ? d.companyName : '')
  383 + },
  384 + purchaseDepartmentDisplay() {
  385 + var d = this.detail || {}
  386 + return d.purchaseDepartmentName != null ? d.purchaseDepartmentName : (d.purchaseDepartment != null ? d.purchaseDepartment : '')
  387 + },
  388 + regionDisplay() {
  389 + var d = this.detail || {}
  390 + return d.regionName != null ? d.regionName : (d.region != null ? d.region : '')
  391 + },
  392 + dateDisplay() {
  393 + var d = this.detail || {}
  394 + var s = d.date == null ? '' : String(d.date).trim()
  395 + return s.length >= 10 ? s.slice(0, 10) : s
  396 + },
  397 + shippingCostDisplay() {
  398 + var v = (this.detail || {}).shippingCost
  399 + if (v == null || v === '') return ''
  400 + var n = Number(v)
  401 + if (isNaN(n)) return String(v)
  402 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  403 + },
  404 + priceTableDisplay() {
  405 + var d = this.detail || {}
  406 + var code = d.priceTableCode != null ? String(d.priceTableCode).trim() : ''
  407 + if (!code) return ''
  408 + var name = d.priceTableName || ''
  409 + return name ? (name + ' (' + code + ')') : code
  410 + }
  411 + },
  412 + onLoad() {
  413 + this.loadDictData()
  414 + this.loadRefData()
  415 + },
  416 + methods: {
  417 + safeText(v) {
  418 + var s = v == null ? '' : String(v)
  419 + return s.trim() ? s : '-'
  420 + },
  421 + boolText(v) {
  422 + if (typeof v !== 'boolean') return ''
  423 + return v ? '是' : '否'
  424 + },
  425 + toNumber(v) {
  426 + if (v == null || v === '') return 0
  427 + var n = Number(v)
  428 + return isNaN(n) ? 0 : n
  429 + },
  430 + toFixed(v, n) {
  431 + var num = Number(v)
  432 + if (isNaN(num)) return ''
  433 + return num.toFixed(n)
  434 + },
  435 + async loadDictData() {
  436 + var codes = [].concat(
  437 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  438 + ['DELIVERY_METHOD']
  439 + )
  440 + try {
  441 + var results = await getDicByCodes(codes)
  442 + var d = results || {}
  443 + this.dictData = d
  444 + this.dicOptions.DELIVERY_METHOD = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  445 + this.deliveryOptions = this.dicOptions.DELIVERY_METHOD.map(function (o) {
  446 + return { label: o.name || o.label || '', value: o.code != null ? o.code : o.value }
  447 + })
  448 + } catch (e) {
  449 + this.dictData = {}
  450 + }
  451 + },
  452 + async loadRefData() {
  453 + try {
  454 + var results = await Promise.all([
  455 + this.$pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  456 + this.$pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  457 + ])
  458 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  459 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  460 + this.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  461 + this.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  462 + this.fillLineNames()
  463 + } catch (e) {
  464 + this.productOptions = []
  465 + this.workshopOptions = []
  466 + }
  467 + },
  468 + $pCall(fn, params) {
  469 + try { return Promise.resolve(fn(params)) } catch (e) { return Promise.reject(e) }
  470 + },
  471 + getDictOptions(dictCode) {
  472 + var data = this.dictData[dictCode]
  473 + return (data && data.data) ? data.data : []
  474 + },
  475 + getDeliveryMethodLabel() {
  476 + var opts = this.dicOptions.DELIVERY_METHOD || []
  477 + var v = String(this.detail.deliveryMode != null ? this.detail.deliveryMode : '')
  478 + if (!v) return '请选择'
  479 + for (var i = 0; i < opts.length; i++) {
  480 + var o = opts[i]
  481 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  482 + if (code === v) return o.name || o.label || v
  483 + }
  484 + return v
  485 + },
  486 + openPlanSheet() {
  487 + this.planSheetVisible = true
  488 + },
  489 + fetchChangePlanList(args) {
  490 + var extra = (args && args.extra) ? args.extra : {}
  491 + var keyword = extra.keyword || extra.name || ''
  492 + var params = { pageIndex: args.pageIndex || 1, pageSize: args.pageSize || 20, queryType: 'REPLENISHMENT' }
  493 + if (keyword) params.keyword = keyword
  494 + return procurementPlanCanChangeOrReplenishmentApi(params).then(function (res) {
  495 + var d = (res && res.data) ? res.data : {}
  496 + var records = (d.datas && Array.isArray(d.datas)) ? d.datas : ((d.records && Array.isArray(d.records)) ? d.records : ((d.list && Array.isArray(d.list)) ? d.list : []))
  497 + var total = d.totalCount || d.count || (records ? records.length : 0)
  498 + var hasNext = !!d.hasNext
  499 + return { records: records, totalCount: total, hasNext: hasNext }
  500 + }).catch(function () {
  501 + return { records: [], totalCount: 0, hasNext: false }
  502 + })
  503 + },
  504 + onPlanConfirm(e) {
  505 + var items = (e && e.items) ? e.items : []
  506 + if (!items.length) return
  507 + var row = items[0] || {}
  508 + var id = row.id != null ? row.id : (row.planId != null ? row.planId : (row.procurementPlanId != null ? row.procurementPlanId : ''))
  509 + this.form.planId = id
  510 + this.form.code = row.code || ''
  511 + this.lineList = []
  512 + var pr = this.$refs.productRel
  513 + if (pr && typeof pr.clearItems === 'function') {
  514 + pr.clearItems()
  515 + }
  516 + if (id) {
  517 + this.loadSourceDetail(id)
  518 + }
  519 + },
  520 + async loadSourceDetail(id) {
  521 + if (!id) return
  522 + try {
  523 + var res = await procurementPlanDetailApi({ id: id })
  524 + var d = (res && res.data) ? res.data : {}
  525 + var boolFields = ['longTermOperation', 'terminalCustomer', 'priced', 'temporaryPrice', 'otherExpenseSettlement', 'commodityBuyout', 'qualityBuyout', 'quantityBuyout', 'doorDelivery', 'materialConditionEnabled']
  526 + boolFields.forEach(function (f) {
  527 + var v = d[f]
  528 + if (typeof v === 'string') {
  529 + d[f] = v === 'true' || v === '1'
  530 + } else if (typeof v === 'number') {
  531 + d[f] = v === 1
  532 + } else {
  533 + d[f] = !!v
  534 + }
  535 + })
  536 + this.materialConditionConfigs.forEach(function (mc) {
  537 + var v = d[mc.field]
  538 + if (typeof v === 'string' && v) {
  539 + d[mc.field] = v.split(',').filter(Boolean)
  540 + } else if (!Array.isArray(v)) {
  541 + d[mc.field] = []
  542 + }
  543 + })
  544 + d.pricingDeadline = this.trimDate(d.pricingDeadline)
  545 + d.deliveryDate = this.trimDate(d.deliveryDate)
  546 + this.detail = d
  547 + if (!this.form.code) {
  548 + this.form.code = d.code || ''
  549 + }
  550 + this.lineList = []
  551 + var pr = this.$refs.productRel
  552 + if (pr && typeof pr.clearItems === 'function') {
  553 + pr.clearItems()
  554 + }
  555 + this.buildAttachmentList()
  556 + this.fillLineNames()
  557 + this.fetchPriceDetailAndApply(d.priceId)
  558 + } catch (e) {
  559 + uni.showToast({ title: '加载计划失败', icon: 'none' })
  560 + }
  561 + },
  562 + trimDate(v) {
  563 + if (v == null || v === '') return ''
  564 + var s = String(v).trim()
  565 + return s.length >= 10 ? s.slice(0, 10) : s
  566 + },
  567 + buildAttachmentList() {
  568 + var ids = this.detail.attachmentFileIds
  569 + var names = this.detail.attachmentFileNames
  570 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  571 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  572 + var len = Math.max(idArr.length, nameArr.length)
  573 + var list = []
  574 + for (var i = 0; i < len; i++) {
  575 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  576 + }
  577 + this.attachmentList = list
  578 + },
  579 + onPreviewAttachment(at) {
  580 + if (!at || !at.id) {
  581 + uni.showToast({ title: '无法查看', icon: 'none' })
  582 + return
  583 + }
  584 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  585 + },
  586 + fillLineNames() {
  587 + var list = Array.isArray(this.lineList) ? this.lineList : []
  588 + if (!list.length) return
  589 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  590 + var wOpts = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  591 + this.lineList = list.map(function (row) {
  592 + var r = Object.assign({}, row)
  593 + var pid = r.productId != null ? String(r.productId) : ''
  594 + var wid = r.workshopId != null ? String(r.workshopId) : ''
  595 + if ((r.productName == null || String(r.productName).trim() === '') && pid) {
  596 + var p = pOpts.find(function (o) {
  597 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  598 + return id === pid
  599 + })
  600 + if (p) {
  601 + r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
  602 + }
  603 + }
  604 + if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) {
  605 + var w = wOpts.find(function (o) {
  606 + var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
  607 + return id === wid
  608 + })
  609 + if (w) {
  610 + r.workshopName = w.name != null ? w.name : (w.workshopName != null ? w.workshopName : (w.label != null ? w.label : ''))
  611 + }
  612 + }
  613 + return r
  614 + })
  615 + },
  616 + async fetchPriceDetailAndApply(priceId) {
  617 + if (!priceId) return
  618 + var self = this
  619 + try {
  620 + var res = await priceTableDetailApi({ id: priceId })
  621 + var d = (res && res.data) ? res.data : {}
  622 + if (d.code != null && this.detail) {
  623 + this.$set(this.detail, 'priceTableCode', String(d.code))
  624 + }
  625 + if (d.priceTableName != null && this.detail) {
  626 + this.$set(this.detail, 'priceTableName', d.priceTableName)
  627 + }
  628 + var priceLines = self.extractPriceLines(d)
  629 + self.applyPriceLinesToLines(priceLines)
  630 + } catch (e) {
  631 + return
  632 + }
  633 + },
  634 + extractPriceLines(priceDetail) {
  635 + if (!priceDetail || typeof priceDetail !== 'object') return []
  636 + var candidates = [
  637 + priceDetail.procurementPriceLineList,
  638 + priceDetail.priceSubTableList,
  639 + priceDetail.priceLineList,
  640 + priceDetail.priceList,
  641 + priceDetail.lineList,
  642 + priceDetail.datas,
  643 + priceDetail.records,
  644 + priceDetail.list
  645 + ]
  646 + for (var i = 0; i < candidates.length; i++) {
  647 + if (Array.isArray(candidates[i]) && candidates[i].length) return candidates[i]
  648 + }
  649 + for (var k in priceDetail) {
  650 + if (!Object.prototype.hasOwnProperty.call(priceDetail, k)) continue
  651 + if (Array.isArray(priceDetail[k])) {
  652 + var arr = priceDetail[k]
  653 + if (arr.length && arr[0] && typeof arr[0] === 'object' && (arr[0].price != null || arr[0].productId != null || arr[0].breedId != null || arr[0].varietyId != null)) {
  654 + return arr
  655 + }
  656 + }
  657 + }
  658 + return []
  659 + },
  660 + buildPriceMap(priceLines) {
  661 + var m = {}
  662 + if (!Array.isArray(priceLines)) return m
  663 + for (var i = 0; i < priceLines.length; i++) {
  664 + var line = priceLines[i] || {}
  665 + if (line.price == null) continue
  666 + var key = String(line.productId || line.breedId || line.varietyId || line.id || ('__idx_' + i))
  667 + m[key] = { price: Number(line.price), meta: line }
  668 + }
  669 + return m
  670 + },
  671 + applyPriceLinesToLines(priceLines) {
  672 + var priceMap = this.buildPriceMap(priceLines)
  673 + this.priceMap = priceMap || {}
  674 + if (!Array.isArray(this.lineList) || !this.lineList.length) {
  675 + var pr = this.$refs.productRel
  676 + if (pr && typeof pr.recalcAllItems === 'function') {
  677 + pr.recalcAllItems()
  678 + }
  679 + return
  680 + }
  681 + var self = this
  682 + this.lineList = this.lineList.map(function (row) {
  683 + var pid = String(row.productId || row.breedId || row.varietyId || '')
  684 + var price = null
  685 + if (pid && priceMap[pid] != null) {
  686 + price = priceMap[pid].price
  687 + } else {
  688 + var pname = (row.productName || '').trim()
  689 + if (pname) {
  690 + for (var k in priceMap) {
  691 + if (!Object.prototype.hasOwnProperty.call(priceMap, k)) continue
  692 + var meta = priceMap[k] && priceMap[k].meta ? priceMap[k].meta : null
  693 + if (meta && ((meta.productName && meta.productName === pname) || (meta.breedName && meta.breedName === pname) || (meta.varietyName && meta.varietyName === pname))) {
  694 + price = priceMap[k].price
  695 + break
  696 + }
  697 + }
  698 + }
  699 + }
  700 + if (price != null) {
  701 + row.priceListPrices = self.toFixed(price, 2)
  702 + } else {
  703 + row.priceListPrices = ''
  704 + }
  705 + return row
  706 + })
  707 + var pr = this.$refs.productRel
  708 + if (pr && typeof pr.recalcAllItems === 'function') {
  709 + pr.recalcAllItems()
  710 + }
  711 + },
  712 + onLineChange(list) {
  713 + var newList = Array.isArray(list) ? list.slice() : []
  714 + var oldList = Array.isArray(this.lineList) ? this.lineList : []
  715 + if (newList.length !== oldList.length) {
  716 + this.lineList = newList
  717 + return
  718 + }
  719 + var i = 0
  720 + for (i = 0; i < newList.length; i++) {
  721 + var n = newList[i] || {}
  722 + var o = oldList[i] || {}
  723 + if (n.productId !== o.productId || n.productName !== o.productName ||
  724 + n.materialType !== o.materialType || n.quantity !== o.quantity ||
  725 + n.actualPurchasePrice !== o.actualPurchasePrice || n.includingShippingPrice !== o.includingShippingPrice ||
  726 + n.priceListPrices !== o.priceListPrices || n.coordinationRange !== o.coordinationRange ||
  727 + n.estimatedLoss !== o.estimatedLoss || n.applicationAttrition !== o.applicationAttrition ||
  728 + n.paintDamageRatio !== o.paintDamageRatio || n.workshopId !== o.workshopId ||
  729 + n.workshopName !== o.workshopName || (n.itemId || '') !== (o.itemId || '')) {
  730 + this.lineList = newList
  731 + return
  732 + }
  733 + }
  734 + },
  735 + toggleBool(field) {
  736 + var cur = this.detail[field]
  737 + this.$set(this.detail, field, cur !== true)
  738 + },
  739 + onNonNegativeInput(field) {
  740 + var v = String(this.detail[field] != null ? this.detail[field] : '')
  741 + v = v.replace(/[^0-9.]/g, '')
  742 + v = v.replace(/(\..*)\./g, '$1')
  743 + this.$set(this.detail, field, v)
  744 + },
  745 + onNonNegativeBlur(field, digits) {
  746 + var raw = this.detail[field]
  747 + if (raw === '' || raw === null || raw === undefined) {
  748 + this.$set(this.detail, field, '')
  749 + return
  750 + }
  751 + var val = parseFloat(raw)
  752 + if (isNaN(val)) val = 0
  753 + var m = Math.pow(10, digits)
  754 + var rounded = Math.round(val * m) / m
  755 + this.$set(this.detail, field, rounded)
  756 + },
  757 + openDeliverySheet() {
  758 + var cur = this.detail.deliveryMode != null ? this.detail.deliveryMode : ''
  759 + var match = this.deliveryOptions.find(function (o) { return String(o.value) === String(cur) })
  760 + this.deliverySheetValue = match ? match.value : ''
  761 + this.deliverySheetVisible = true
  762 + },
  763 + onDeliveryConfirm(e) {
  764 + this.$set(this.detail, 'deliveryMode', e.value != null ? e.value : '')
  765 + },
  766 + isTagSelected(field, code) {
  767 + var selected = this.detail ? this.detail[field] : undefined
  768 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  769 + if (typeof selected === 'string' && selected) {
  770 + return selected.split(',').indexOf(code) >= 0
  771 + }
  772 + return false
  773 + },
  774 + toggleTag(field, code) {
  775 + var selected = this.detail[field]
  776 + var arr = Array.isArray(selected) ? selected.slice() : []
  777 + var idx = arr.indexOf(code)
  778 + if (idx >= 0) {
  779 + arr.splice(idx, 1)
  780 + } else {
  781 + arr.push(code)
  782 + }
  783 + this.$set(this.detail, field, arr)
  784 + },
  785 + validateForm() {
  786 + if (!this.form.planId) {
  787 + uni.showToast({ title: '请选择计划', icon: 'none' })
  788 + return false
  789 + }
  790 + var d = this.detail || {}
  791 + var textChecks = [
  792 + { key: 'supplierName', title: '供应商名称' },
  793 + { key: 'validityPeriod', title: '报价时效' },
  794 + { key: 'quoterName', title: '报价人' },
  795 + { key: 'deliveryMode', title: '交提货方式' },
  796 + { key: 'loadingFee', title: '装车费' },
  797 + { key: 'invoiceProductName', title: '开票品名' },
  798 + { key: 'deliveryDate', title: '交货日期' },
  799 + { key: 'settlementMethod', title: '结算方式' },
  800 + { key: 'settlementRatio', title: '结算比例' },
  801 + { key: 'coordinationReason', title: '协调事由' },
  802 + { key: 'invoiceTypeStatus', title: '票类状况' },
  803 + { key: 'changeReason', title: '变更事由' }
  804 + ]
  805 + for (var i = 0; i < textChecks.length; i++) {
  806 + var tc = textChecks[i]
  807 + var tv = d[tc.key]
  808 + if (tv === '' || tv === null || tv === undefined) {
  809 + uni.showToast({ title: '请填写' + tc.title, icon: 'none' })
  810 + return false
  811 + }
  812 + }
  813 + var boolChecks = [
  814 + { key: 'longTermOperation', title: '是否长单操作' },
  815 + { key: 'terminalCustomer', title: '是否终端客户' },
  816 + { key: 'priced', title: '是否未点价' },
  817 + { key: 'otherExpenseSettlement', title: '其他费用凭票到厂另行结算' },
  818 + { key: 'commodityBuyout', title: '是否通货买断' },
  819 + { key: 'qualityBuyout', title: '是否质量买断' },
  820 + { key: 'quantityBuyout', title: '是否数量买断' },
  821 + { key: 'doorDelivery', title: '是否送货上门' }
  822 + ]
  823 + if (d.priced === true) {
  824 + boolChecks.push({ key: 'temporaryPrice', title: '是否暂定价' })
  825 + var pd = d.pricingDeadline
  826 + if (pd === '' || pd === null || pd === undefined) {
  827 + uni.showToast({ title: '请选择点价截止日期', icon: 'none' })
  828 + return false
  829 + }
  830 + }
  831 + for (var j = 0; j < boolChecks.length; j++) {
  832 + var bc = boolChecks[j]
  833 + if (typeof d[bc.key] !== 'boolean') {
  834 + uni.showToast({ title: '请选择' + bc.title, icon: 'none' })
  835 + return false
  836 + }
  837 + }
  838 + var pr = this.$refs.productRel
  839 + if (pr && typeof pr.validate === 'function') {
  840 + if (!pr.validate()) return false
  841 + }
  842 + return true
  843 + },
  844 + onBack() {
  845 + uni.navigateBack({ delta: 1 })
  846 + },
  847 + joinStr(arr) {
  848 + if (Array.isArray(arr)) return arr.filter(Boolean).join(',')
  849 + if (typeof arr === 'string') return arr
  850 + return ''
  851 + },
  852 + pickId(v) {
  853 + if (v == null || v === '') return ''
  854 + if (typeof v === 'string' || typeof v === 'number') return String(v)
  855 + if (typeof v === 'object') {
  856 + return String(v.id != null ? v.id : (v.value != null ? v.value : (v.code != null ? v.code : '')))
  857 + }
  858 + return String(v)
  859 + },
  860 + boolToStr(v) {
  861 + return v === true ? 'true' : 'false'
  862 + },
  863 + buildPayload() {
  864 + var self = this
  865 + var d = this.detail || {}
  866 + var lines = Array.isArray(this.lineList) ? this.lineList.slice() : []
  867 + var workshopId = d.workshopId != null ? d.workshopId : ''
  868 + var lineList = lines.map(function (row, i) {
  869 + var r = row || {}
  870 + var itemId = r.itemId != null ? r.itemId : (r.id != null ? String(r.id) : (r._key != null ? r._key : ('line-' + Date.now() + '-' + i)))
  871 + if (!workshopId && r.workshopId != null) workshopId = r.workshopId
  872 + return {
  873 + productId: self.pickId(r.productId),
  874 + materialType: r.materialType != null ? String(r.materialType) : '',
  875 + quantity: r.quantity != null ? String(r.quantity) : '',
  876 + actualPurchasePrice: r.actualPurchasePrice != null ? String(r.actualPurchasePrice) : '',
  877 + includingShippingPrice: r.includingShippingPrice != null ? String(r.includingShippingPrice) : '',
  878 + priceListPrices: r.priceListPrices != null ? String(r.priceListPrices) : '',
  879 + coordinationRange: r.coordinationRange != null ? String(r.coordinationRange) : '',
  880 + estimatedLoss: r.estimatedLoss != null ? String(r.estimatedLoss) : '',
  881 + applicationAttrition: r.applicationAttrition != null ? String(r.applicationAttrition) : '',
  882 + paintDamageRatio: r.paintDamageRatio != null ? String(r.paintDamageRatio) : '',
  883 + workshopId: self.pickId(r.workshopId),
  884 + itemId: itemId
  885 + }
  886 + })
  887 + var body = {
  888 + procurementPlanId: this.form.planId || d.id || '',
  889 + changeReason: d.changeReason != null ? String(d.changeReason) : '',
  890 + code: d.code != null ? String(d.code) : '',
  891 + companyShortId: this.pickId(d.companyShortId || d.companyId),
  892 + supplierId: this.pickId(d.supplierId),
  893 + purchaseDepartment: this.pickId(d.purchaseDepartment),
  894 + region: this.pickId(d.region),
  895 + date: d.date != null ? String(d.date).slice(0, 10) : '',
  896 + validityPeriod: d.validityPeriod != null ? String(d.validityPeriod) : '',
  897 + quoterId: this.pickId(d.quoterId),
  898 + workshopId: this.pickId(workshopId),
  899 + quoterName: d.quoterName != null ? String(d.quoterName) : '',
  900 + longTermOperation: this.boolToStr(d.longTermOperation),
  901 + terminalCustomer: this.boolToStr(d.terminalCustomer),
  902 + priced: this.boolToStr(d.priced),
  903 + pricingDeadline: d.pricingDeadline != null ? String(d.pricingDeadline) : '',
  904 + temporaryPrice: this.boolToStr(d.temporaryPrice),
  905 + otherExpenseSettlement: this.boolToStr(d.otherExpenseSettlement),
  906 + deliveryMode: d.deliveryMode != null ? String(d.deliveryMode) : '',
  907 + commodityBuyout: this.boolToStr(d.commodityBuyout),
  908 + qualityBuyout: this.boolToStr(d.qualityBuyout),
  909 + quantityBuyout: this.boolToStr(d.quantityBuyout),
  910 + doorDelivery: this.boolToStr(d.doorDelivery),
  911 + shippingCost: d.shippingCost != null ? String(d.shippingCost) : '',
  912 + loadingFee: d.loadingFee != null ? String(d.loadingFee) : '',
  913 + invoiceProductName: d.invoiceProductName != null ? String(d.invoiceProductName) : '',
  914 + deliveryDate: d.deliveryDate != null ? String(d.deliveryDate) : '',
  915 + settlementMethod: d.settlementMethod != null ? String(d.settlementMethod) : '',
  916 + settlementRatio: d.settlementRatio != null ? String(d.settlementRatio) : '',
  917 + priceId: this.pickId(d.priceId),
  918 + coordinationReason: d.coordinationReason != null ? String(d.coordinationReason) : '',
  919 + invoiceTypeStatus: d.invoiceTypeStatus != null ? String(d.invoiceTypeStatus) : '',
  920 + totalQuantity: d.totalQuantity != null ? String(d.totalQuantity) : '',
  921 + remark: d.remark != null ? String(d.remark) : '',
  922 + materialConditionEnabled: this.boolToStr(d.materialConditionEnabled),
  923 + lines: lineList
  924 + }
  925 + this.materialConditionConfigs.forEach(function (mc) {
  926 + body[mc.field] = self.joinStr(d[mc.field])
  927 + })
  928 + return body
  929 + },
  930 + async onSubmit() {
  931 + if (!this.validateForm()) return
  932 + var payload = this.buildPayload()
  933 + try {
  934 + await procurementPlanReplenplenishApi(payload)
  935 + uni.showToast({ title: '保存成功', icon: 'none' })
  936 + try {
  937 + uni.setStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH', '1')
  938 + } catch (e) {}
  939 + var self = this
  940 + setTimeout(function () {
  941 + uni.navigateTo({ url: '/pages/schedule-plan/index' })
  942 + }, 400)
  943 + } catch (e) {
  944 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : '保存失败', icon: 'none' })
  945 + }
  946 + }
  947 + }
  948 +}
  949 +</script>
  950 +
  951 +<style lang="scss" scoped>
  952 +.page {
  953 + display: flex;
  954 + flex-direction: column;
  955 + height: 100%;
  956 +}
  957 +.scroll {
  958 + flex: 1;
  959 + padding: 12rpx 0 392rpx !important;
  960 +}
  961 +.bottom-bar {
  962 + z-index: 2;
  963 + position: fixed;
  964 + left: 0;
  965 + right: 0;
  966 + bottom: 0;
  967 + padding: 32rpx;
  968 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  969 + background: #fff;
  970 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  971 + display: flex;
  972 + gap: 24rpx;
  973 + .btn {
  974 + flex: 1;
  975 + height: 80rpx;
  976 + line-height: 80rpx;
  977 + border-radius: 12rpx;
  978 + font-size: 32rpx;
  979 + }
  980 + .btn-outline {
  981 + background: #fff;
  982 + color: $theme-primary;
  983 + border: 2rpx solid $theme-primary;
  984 + }
  985 + .btn-primary {
  986 + background: $theme-primary;
  987 + color: #fff;
  988 + border: 2rpx solid $theme-primary;
  989 + }
  990 +}
  991 +
  992 +::v-deep .uni-list {
  993 + .uni-easyinput {
  994 + display: flex;
  995 + .uni-input-input {
  996 + color: rgba(0, 0, 0, 0.9);
  997 + }
  998 + }
  999 + .uni-input-placeholder { z-index: 1; }
  1000 + .uni-input-input { background-color: #ffffff; }
  1001 + background: transparent;
  1002 + &-item {
  1003 + &__extra-text { font-size: 32rpx; }
  1004 + &__content-title {
  1005 + font-size: 32rpx;
  1006 + color: rgba(0, 0, 0, 0.9);
  1007 + }
  1008 + &__container {
  1009 + padding: 32rpx;
  1010 + .uni-easyinput {
  1011 + &__placeholder-class {
  1012 + font-size: 32rpx;
  1013 + color: rgba(0, 0, 0, 0.4);
  1014 + }
  1015 + &__content {
  1016 + border: none;
  1017 + background-color: #ffffff !important;
  1018 + &-input {
  1019 + padding-left: 0 !important;
  1020 + height: 48rpx;
  1021 + line-height: 48rpx;
  1022 + font-size: 32rpx;
  1023 + }
  1024 + .content-clear-icon {
  1025 + font-size: 44rpx !important;
  1026 + }
  1027 + }
  1028 + }
  1029 + .item-title,
  1030 + .uni-list-item__content {
  1031 + flex: none;
  1032 + min-height: 48rpx;
  1033 + line-height: 48rpx;
  1034 + font-size: 32rpx;
  1035 + position: relative;
  1036 + width: 240rpx;
  1037 + margin-right: 32rpx;
  1038 + color: rgba(0, 0, 0, 0.9);
  1039 + .required {
  1040 + color: red;
  1041 + position: absolute;
  1042 + top: 50%;
  1043 + transform: translateY(-50%);
  1044 + left: -16rpx;
  1045 + }
  1046 + }
  1047 + }
  1048 + &.select-item {
  1049 + &.is-empty {
  1050 + .uni-list-item__extra-text {
  1051 + color: rgba(0, 0, 0, 0.4) !important;
  1052 + }
  1053 + }
  1054 + &.is-filled {
  1055 + .uni-list-item__extra-text {
  1056 + color: rgba(0, 0, 0, 0.9) !important;
  1057 + }
  1058 + }
  1059 + .serial-number-row {
  1060 + display: flex;
  1061 + align-items: center;
  1062 + }
  1063 + }
  1064 + }
  1065 +}
  1066 +
  1067 +.readonly-text {
  1068 + color: rgba(0, 0, 0, 0.9);
  1069 + font-size: 32rpx;
  1070 + line-height: 48rpx;
  1071 + text-align: right;
  1072 + white-space: pre-wrap;
  1073 + word-break: break-all;
  1074 +}
  1075 +.value-code {
  1076 + width: 260rpx;
  1077 + text-align: left;
  1078 +}
  1079 +
  1080 +.attach-list {
  1081 + flex: 1;
  1082 + display: flex;
  1083 + flex-direction: column;
  1084 + align-items: flex-end;
  1085 + gap: 8rpx;
  1086 +}
  1087 +.attach-item {
  1088 + display: flex;
  1089 + align-items: center;
  1090 + gap: 16rpx;
  1091 + .attach-name { font-size: 26rpx; color: rgba(0,0,0,0.9); }
  1092 + .attach-view { font-size: 26rpx; color: $theme-primary; }
  1093 +}
  1094 +
  1095 +.material-condition-section,
  1096 +.remark-section {
  1097 + margin-top: 20rpx;
  1098 + background: #fff;
  1099 +}
  1100 +.section-header {
  1101 + display: flex;
  1102 + align-items: center;
  1103 + padding: 24rpx 32rpx;
  1104 + border-bottom: 1rpx solid #f0f0f0;
  1105 +}
  1106 +.section-title {
  1107 + position: relative;
  1108 + font-size: 32rpx;
  1109 + color: rgba(0, 0, 0, 0.9);
  1110 + font-weight: 600;
  1111 + .required {
  1112 + color: red;
  1113 + position: absolute;
  1114 + top: 50%;
  1115 + transform: translateY(-50%);
  1116 + left: -16rpx;
  1117 + }
  1118 +}
  1119 +.opCollapse {
  1120 + width: 32rpx;
  1121 + height: 28rpx;
  1122 + margin-right: 16rpx;
  1123 + margin-top: 8rpx;
  1124 +}
  1125 +.section-content {
  1126 + padding: 32rpx;
  1127 +}
  1128 +.form-row {
  1129 + display: flex;
  1130 + align-items: center;
  1131 + justify-content: space-between;
  1132 + margin-bottom: 24rpx;
  1133 +}
  1134 +.form-row:last-child { margin-bottom: 0; }
  1135 +.form-label {
  1136 + font-size: 32rpx;
  1137 + color: rgba(0, 0, 0, 0.9);
  1138 +}
  1139 +.form-value {
  1140 + font-size: 32rpx;
  1141 + color: rgba(0, 0, 0, 0.9);
  1142 +}
  1143 +.toggle-link {
  1144 + color: $theme-primary;
  1145 +}
  1146 +.material-group {
  1147 + margin-top: 32rpx;
  1148 +}
  1149 +.material-label {
  1150 + display: block;
  1151 + font-size: 30rpx;
  1152 + color: rgba(0, 0, 0, 0.9);
  1153 + margin-bottom: 20rpx;
  1154 +}
  1155 +.tag-list {
  1156 + display: flex;
  1157 + flex-wrap: wrap;
  1158 + gap: 16rpx;
  1159 +}
  1160 +.tag-btn {
  1161 + padding: 12rpx 24rpx;
  1162 + border: 1rpx solid #ddd;
  1163 + border-radius: 8rpx;
  1164 + font-size: 28rpx;
  1165 + color: #666;
  1166 + background: #fff;
  1167 +}
  1168 +.tag-btn.active {
  1169 + background: $theme-primary;
  1170 + border-color: $theme-primary;
  1171 + color: #fff;
  1172 +}
  1173 +
  1174 +::v-deep .uni-easyinput {
  1175 + width: 100%;
  1176 + &__content {
  1177 + background: #f8f8f8 !important;
  1178 + border-radius: 8rpx;
  1179 + &-input { font-size: 30rpx; }
  1180 + }
  1181 +}
  1182 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view class="scroll" scroll-y>
  4 + <view class="detail-page">
  5 + <view class="section">
  6 + <text class="row company">{{ safeText(form.code) }}</text>
  7 + <view class="row"><text class="label">公司简称</text><text class="value">{{ safeText(form.companyShortName || form.companyName) }}</text></view>
  8 + <view class="row"><text class="label">供应商名称</text><text class="value">{{ safeText(form.supplierName) }}</text></view>
  9 + <view class="row"><text class="label">采购处</text><text class="value">{{ safeText(form.purchaseDepartmentName || form.purchaseDepartment) }}</text></view>
  10 + <view class="row"><text class="label">区域</text><text class="value">{{ safeText(form.regionName || form.region) }}</text></view>
  11 + <view class="row"><text class="label">日期</text><text class="value">{{ formatDateOnly(form.date) }}</text></view>
  12 + <view class="row"><text class="label">报价时效</text><text class="value">{{ safeText(form.validityPeriod) }}</text></view>
  13 + <view class="row"><text class="label">报价人</text><text class="value">{{ safeText(form.quoterName) }}</text></view>
  14 + <view class="row"><text class="label">是否长单操作</text><text class="value">{{ boolText(form.longTermOperation) }}</text></view>
  15 + <view class="row"><text class="label">是否终端客户</text><text class="value">{{ boolText(form.terminalCustomer) }}</text></view>
  16 + <view class="row"><text class="label">是否未点价</text><text class="value">{{ boolText(form.priced) }}</text></view>
  17 + <view v-if="form.priced === true" class="row"><text class="label">点价截止日期</text><text class="value">{{ formatDateOnly(form.pricingDeadline) }}</text></view>
  18 + <view v-if="form.priced === true" class="row"><text class="label">是否暂定价</text><text class="value">{{ boolText(form.temporaryPrice) }}</text></view>
  19 + <view class="row"><text class="label">其他费用凭票到厂另行结算</text><text class="value">{{ boolText(form.otherExpenseSettlement) }}</text></view>
  20 + <view class="row"><text class="label">交提货方式</text><text class="value">{{ getDeliveryMethodLabel() }}</text></view>
  21 + <view class="row"><text class="label">是否通货买断</text><text class="value">{{ boolText(form.commodityBuyout) }}</text></view>
  22 + <view class="row"><text class="label">是否质量买断</text><text class="value">{{ boolText(form.qualityBuyout) }}</text></view>
  23 + <view class="row"><text class="label">是否数量买断</text><text class="value">{{ boolText(form.quantityBuyout) }}</text></view>
  24 + <view class="row"><text class="label">是否送货上门</text><text class="value">{{ boolText(form.doorDelivery) }}</text></view>
  25 + <view class="row"><text class="label">另付运费</text><text class="value">{{ formatNumber(form.shippingCost) }}</text></view>
  26 + <view class="row"><text class="label">装车费</text><text class="value">{{ formatNumber(form.loadingFee) }}</text></view>
  27 + <view class="row"><text class="label">开票品名</text><text class="value">{{ safeText(form.invoiceProductName) }}</text></view>
  28 + <view class="row"><text class="label">交货日期</text><text class="value">{{ formatDateOnly(form.deliveryDate) }}</text></view>
  29 + <view class="row"><text class="label">结算方式</text><text class="value">{{ safeText(form.settlementMethod) }}</text></view>
  30 + <view class="row"><text class="label">结算比例(%)</text><text class="value">{{ formatNumber(form.settlementRatio) }}</text></view>
  31 + <view class="row"><text class="label">价格表编号</text><text class="value">{{ priceTableDisplay }}</text></view>
  32 + <view class="row"><text class="label">协调事由</text><text class="value">{{ safeText(form.coordinationReason) }}</text></view>
  33 + <view class="row"><text class="label">票类状况</text><text class="value">{{ safeText(form.invoiceTypeStatus) }}</text></view>
  34 + <view class="row"><text class="label">数量合计</text><text class="value">{{ formatNumber(form.totalQuantity) }}</text></view>
  35 + <view class="row" v-if="attachmentList.length">
  36 + <text class="label">附件</text>
  37 + <view class="attach-list">
  38 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  39 + <text class="attach-name">{{ at.name }}</text>
  40 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  41 + </view>
  42 + </view>
  43 + </view>
  44 + </view>
  45 +
  46 + <view class="title-header">
  47 + <image class="title-header_icon" src="/static/images/title.png" />
  48 + <span>明细信息</span>
  49 + </view>
  50 + <view v-if="lineListWithName.length" class="section">
  51 + <view v-for="(line, idx) in lineListWithName" :key="line.itemId || idx" class="line-block">
  52 + <view class="line-title">明细{{ idx + 1 }}</view>
  53 + <view class="row"><text class="label">品种</text><text class="value">{{ safeText(line.productName) }}</text></view>
  54 + <view class="row"><text class="label">料型</text><text class="value">{{ safeText(line.materialType) }}</text></view>
  55 + <view class="row"><text class="label">数量(吨)</text><text class="value">{{ formatNumber(line.quantity) }}</text></view>
  56 + <view class="row"><text class="label">实际采购价</text><text class="value">{{ formatNumber(line.actualPurchasePrice) }}</text></view>
  57 + <view class="row"><text class="label">含运到厂价</text><text class="value">{{ formatNumber(line.includingShippingPrice) }}</text></view>
  58 + <view class="row"><text class="label">价格表价格</text><text class="value">{{ formatNumber(line.priceListPrices) }}</text></view>
  59 + <view class="row"><text class="label">协调幅度</text><text class="value">{{ formatNumber(line.coordinationRange) }}</text></view>
  60 + <view class="row"><text class="label">买断料预计损耗</text><text class="value">{{ formatNumber(line.estimatedLoss) }}</text></view>
  61 + <view class="row"><text class="label">申请损耗(%)</text><text class="value">{{ formatNumber(line.applicationAttrition) }}</text></view>
  62 + <view class="row"><text class="label">选择分厂</text><text class="value">{{ safeText(line.workshopName) }}</text></view>
  63 + </view>
  64 + </view>
  65 + <view v-else class="section empty-tip">暂无明细</view>
  66 +
  67 + <view class="title-header">
  68 + <image class="title-header_icon" src="/static/images/title.png" />
  69 + <span>料质状况</span>
  70 + </view>
  71 + <view class="section">
  72 + <view class="row"><text class="label">是否启用料质状况</text><text class="value">{{ boolText(form.materialConditionEnabled) }}</text></view>
  73 + <template v-if="form.materialConditionEnabled">
  74 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  75 + <text class="material-label">{{ mc.label }}</text>
  76 + <view class="tag-list">
  77 + <view v-for="opt in getDictOptions(mc.dictCode)" :key="opt.code" class="tag-btn" :class="{ active: isTagSelected(mc.field, opt.code) }">{{ opt.name }}</view>
  78 + </view>
  79 + </view>
  80 + </template>
  81 + </view>
  82 +
  83 + <view class="title-header">
  84 + <image class="title-header_icon" src="/static/images/title.png" />
  85 + <span>备注</span>
  86 + </view>
  87 + <view class="section">
  88 + <text class="remark-text">{{ safeText(form.remark) }}</text>
  89 + </view>
  90 +
  91 + <view class="title-header">
  92 + <image class="title-header_icon" src="/static/images/title.png" />
  93 + <span>变更事由</span>
  94 + </view>
  95 + <view class="section">
  96 + <text class="remark-text">{{ safeText(form.changeReason) }}</text>
  97 + </view>
  98 + </view>
  99 + </scroll-view>
  100 + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" />
  101 + </view>
  102 +</template>
  103 +
  104 +<script>
  105 +import { procurementPlanReplenishFindByIdApi, procurementPlanReplenishSubmitApi, procurementPlanReplenishCancelApi } from '@/api/procure-manage/procurementPlan.js'
  106 +import { breedRelationshipQueryApi, workshopQueryApi } from '@/api/devManage.js'
  107 +import { getDicByCodes } from '@/utils/dic.js'
  108 +import DetailButtons from '@/components/detail-buttons/index.vue'
  109 +export default {
  110 + name: 'SupplePlanDetail',
  111 + components: { DetailButtons },
  112 + data() {
  113 + return {
  114 + id: '',
  115 + form: {},
  116 + lineList: [],
  117 + attachmentList: [],
  118 + materialConditionConfigs: [
  119 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  120 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  121 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  122 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  123 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  124 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  125 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  126 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  127 + ],
  128 + dictData: {},
  129 + productOptions: [],
  130 + workshopOptions: [],
  131 + buttons: [
  132 + { text: '编辑', visible: true, variant: 'outline', event: 'edit' },
  133 + { text: '发起变更审核', visible: true, variant: 'primary', event: 'initiate' },
  134 + { text: '取消', visible: true, variant: 'outline', event: 'cancel' },
  135 + { text: '审核', visible: true, variant: 'primary', event: 'approve' },
  136 + { text: '审核详情', visible: true, event: 'approveDetail' },
  137 + ],
  138 + }
  139 + },
  140 + computed: {
  141 + productMap() {
  142 + var list = Array.isArray(this.productOptions) ? this.productOptions : []
  143 + var m = {}
  144 + list.forEach(function (o) {
  145 + var key = String(o.productId || o.id || o.value || '')
  146 + if (key) m[key] = o
  147 + })
  148 + return m
  149 + },
  150 + workshopMap() {
  151 + var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  152 + var m = {}
  153 + list.forEach(function (o) {
  154 + var key = String(o.workshopId || o.id || o.value || '')
  155 + if (key) m[key] = o
  156 + })
  157 + return m
  158 + },
  159 + lineListWithName() {
  160 + var self = this
  161 + var list = Array.isArray(this.lineList) ? this.lineList : []
  162 + return list.map(function (row) {
  163 + var pid = String(row.productId || '')
  164 + var wid = String(row.workshopId || '')
  165 + var p = pid ? self.productMap[pid] : null
  166 + var w = wid ? self.workshopMap[wid] : null
  167 + return Object.assign({}, row, {
  168 + productName: row.productName || (p ? (p.productName || p.name || p.label || '') : ''),
  169 + workshopName: row.workshopName || (w ? (w.workshopName || w.name || w.label || '') : '')
  170 + })
  171 + })
  172 + },
  173 + priceTableDisplay() {
  174 + var d = this.form || {}
  175 + var code = d.priceTableCode != null ? d.priceTableCode : (d.priceId != null ? d.priceId : '')
  176 + var name = d.priceTableName || ''
  177 + if (name || code) {
  178 + return (name ? name + (code ? ' (' + code + ')' : '') : String(code))
  179 + }
  180 + return '-'
  181 + },
  182 + displayButtons() {
  183 + const status = this.form ? this.form.approvalStatus : '';
  184 + const isDraft = status === 'DRAFT';
  185 + const isAudit = status === 'AUDIT';
  186 + const isPass = status === 'PASS';
  187 + const isRefuse = status === 'REFUSE';
  188 + const canExamine = isAudit && this.form && this.form.showExamine === true;
  189 + return [
  190 + { ...this.buttons[0], visible: ((isDraft || isRefuse) && this.$auth.hasPermi('plan-manage:supple-plan:modify')) },
  191 + { ...this.buttons[1], visible: ((isDraft || isRefuse) && this.$auth.hasPermi('plan-manage:supple-plan:initiate')) },
  192 + { ...this.buttons[2], visible: (isRefuse && this.$auth.hasPermi('plan-manage:supple-plan:cancel')) },
  193 + { ...this.buttons[3], visible: (canExamine && this.$auth.hasPermi('plan-manage:supple-plan:approve')) },
  194 + { ...this.buttons[4], visible: ((isAudit || isPass) && this.form.showExamine && this.$auth.hasPermi('plan-manage:supple-plan:view')) },
  195 + ]
  196 + }
  197 + },
  198 + onLoad(query) {
  199 + this.id = (query && query.id) || ''
  200 + this.loadDictData()
  201 + this.loadRefData()
  202 + this.loadDetail()
  203 + },
  204 + methods: {
  205 + handleButtonClick(btn) {
  206 + if (!btn || btn.disabled) return
  207 + const e = btn.event || ''
  208 + if (e === 'edit') return this.onEdit()
  209 + if (e === 'initiate') return this.onInitiate()
  210 + if (e === 'approve') return this.onApprove()
  211 + if (e === 'approveDetail') return this.onApproveDetail()
  212 + if (e === 'cancel') return this.onCancel()
  213 + },
  214 + refreshListFlags() {
  215 + try {
  216 + uni.setStorageSync('SUPPLE_PLAN_LIST_NEED_REFRESH', '1')
  217 + } catch (e) {}
  218 + },
  219 + runWithConfirm(opts) {
  220 + var self = this
  221 + var title = opts.title || '提示'
  222 + var content = opts.content || ''
  223 + var run = opts.run
  224 + var loading = opts.loading || '处理中'
  225 + var successText = opts.successText || '操作成功'
  226 + var failText = opts.failText || '操作失败'
  227 + if (!this.id) {
  228 + uni.showToast({ title: '缺少单据id', icon: 'none' })
  229 + return
  230 + }
  231 + var apiFn = function () {
  232 + uni.showLoading({ title: loading, mask: true })
  233 + Promise.resolve(run(self.id)).then(function () {
  234 + uni.hideLoading()
  235 + uni.showToast({ title: successText, icon: 'none' })
  236 + self.refreshListFlags()
  237 + self.loadDetail()
  238 + }).catch(function (e) {
  239 + uni.hideLoading()
  240 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : failText, icon: 'none' })
  241 + })
  242 + }
  243 + if (opts.skipConfirm) {
  244 + apiFn()
  245 + return
  246 + }
  247 + uni.showModal({
  248 + title: title,
  249 + content: content,
  250 + confirmText: '确定',
  251 + cancelText: '取消',
  252 + success: function (res) {
  253 + if (!res || !res.confirm) return
  254 + apiFn()
  255 + }
  256 + })
  257 + },
  258 + onInitiate() {
  259 + this.runWithConfirm({
  260 + title: '发起补货审核',
  261 + content: '确认发起补货审核吗',
  262 + loading: '提交中',
  263 + successText: '发起成功',
  264 + failText: '发起补货审核失败',
  265 + run: function (id) { return procurementPlanReplenishSubmitApi(id) }
  266 + })
  267 + },
  268 + onEdit() {
  269 + if (!this.id) {
  270 + uni.showToast({ title: '缺少单据ID', icon: 'none' })
  271 + return
  272 + }
  273 + uni.navigateTo({ url: '/pages/supple-plan/modify?id=' + this.id })
  274 + },
  275 + async loadDictData() {
  276 + var codes = [].concat(
  277 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  278 + ['DELIVERY_METHOD']
  279 + )
  280 + try {
  281 + var results = await getDicByCodes(codes)
  282 + var d = results || {}
  283 + this.dictData = d
  284 + this.deliveryOptions = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  285 + } catch (e) {
  286 + this.dictData = {}
  287 + this.deliveryOptions = []
  288 + }
  289 + },
  290 + async loadRefData() {
  291 + var self = this
  292 + try {
  293 + var results = await Promise.all([
  294 + this.pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  295 + this.pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  296 + ])
  297 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  298 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  299 + self.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  300 + self.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  301 + } catch (e) {
  302 + self.productOptions = []
  303 + self.workshopOptions = []
  304 + }
  305 + },
  306 + pCall(fn, params) {
  307 + try {
  308 + return Promise.resolve(fn(params))
  309 + } catch (e) {
  310 + return Promise.reject(e)
  311 + }
  312 + },
  313 + async loadDetail() {
  314 + if (!this.id) return
  315 + try {
  316 + var res = await procurementPlanReplenishFindByIdApi({ id: this.id })
  317 + var d = (res && res.data) ? res.data : {}
  318 + var boolFields = ['longTermOperation', 'terminalCustomer', 'priced', 'temporaryPrice', 'otherExpenseSettlement', 'commodityBuyout', 'qualityBuyout', 'quantityBuyout', 'doorDelivery', 'materialConditionEnabled']
  319 + boolFields.forEach(function (f) {
  320 + var v = d[f]
  321 + if (typeof v === 'string') {
  322 + d[f] = v === 'true' || v === '1'
  323 + } else if (typeof v === 'number') {
  324 + d[f] = v === 1
  325 + } else {
  326 + d[f] = !!v
  327 + }
  328 + })
  329 + this.materialConditionConfigs.forEach(function (mc) {
  330 + var v = d[mc.field]
  331 + if (typeof v === 'string' && v) {
  332 + d[mc.field] = v.split(',').filter(Boolean)
  333 + } else if (!Array.isArray(v)) {
  334 + d[mc.field] = []
  335 + }
  336 + })
  337 + this.form = d
  338 + var lines = d.lines || d.procurementPlanLineList || d.lineList || []
  339 + this.lineList = Array.isArray(lines) ? lines : []
  340 + this.buildAttachmentList()
  341 + } catch (e) {
  342 + uni.showToast({ title: '加载详情失败', icon: 'none' })
  343 + }
  344 + },
  345 + buildAttachmentList() {
  346 + var d = this.form || {}
  347 + var ids = d.attachmentFileIds
  348 + var names = d.attachmentFileNames
  349 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  350 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  351 + var len = Math.max(idArr.length, nameArr.length)
  352 + var list = []
  353 + for (var i = 0; i < len; i++) {
  354 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  355 + }
  356 + this.attachmentList = list
  357 + },
  358 + getDictOptions(dictCode) {
  359 + var data = this.dictData[dictCode]
  360 + return (data && data.data) ? data.data : []
  361 + },
  362 + isTagSelected(field, code) {
  363 + var selected = this.form ? this.form[field] : undefined
  364 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  365 + if (typeof selected === 'string' && selected) {
  366 + return selected.split(',').indexOf(code) >= 0
  367 + }
  368 + return false
  369 + },
  370 + getDeliveryMethodLabel() {
  371 + var opts = this.deliveryOptions || []
  372 + var v = String(this.form.deliveryMode != null ? this.form.deliveryMode : '')
  373 + if (!v) return '-'
  374 + for (var i = 0; i < opts.length; i++) {
  375 + var o = opts[i]
  376 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  377 + if (code === v) return o.name || o.label || '-'
  378 + }
  379 + return v
  380 + },
  381 + boolText(v) {
  382 + if (typeof v === 'boolean') return v ? '是' : '否'
  383 + if (v === 'true' || v === '1' || v === 1) return '是'
  384 + if (v === 'false' || v === '0' || v === 0) return '否'
  385 + return '-'
  386 + },
  387 + formatDateOnly(v) {
  388 + var s = v == null ? '' : String(v).trim()
  389 + if (!s) return '-'
  390 + if (s.length >= 10) return s.slice(0, 10)
  391 + return s
  392 + },
  393 + safeText(v) {
  394 + var s = v == null ? '' : String(v)
  395 + return s.trim() ? s : '-'
  396 + },
  397 + formatNumber(v) {
  398 + if (v == null || v === '') return '-'
  399 + var n = Number(v)
  400 + if (isNaN(n)) return String(v)
  401 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  402 + },
  403 + onCancel() {
  404 + this.runWithConfirm({
  405 + title: '取消',
  406 + content: '确认取消该补货单吗?',
  407 + loading: '提交中',
  408 + successText: '取消成功',
  409 + failText: '取消失败',
  410 + run: function (id) { return procurementPlanReplenishCancelApi(id) }
  411 + })
  412 + },
  413 + onApprove() {
  414 + const id = this.id || (this.form && this.form.id) || ''
  415 + if (!id) return
  416 + const CACHE_KEY = 'sourceBusinessId'
  417 + const TYPE = 'contractType'
  418 + uni.setStorageSync(TYPE, 'PLAN_CHANGE')
  419 + uni.setStorageSync(CACHE_KEY, id)
  420 + uni.navigateTo({ url: '/pages/flow/audit' })
  421 + },
  422 + onApproveDetail() {
  423 + const id = this.id || (this.form && this.form.id) || ''
  424 + if (!id) return
  425 + const CACHE_KEY = 'sourceBusinessId'
  426 + const TYPE = 'contractType'
  427 + uni.setStorageSync(TYPE, 'PLAN_CHANGE')
  428 + uni.setStorageSync(CACHE_KEY, id)
  429 + uni.navigateTo({ url: '/pages/flow/audit_detail' })
  430 + },
  431 + onPreviewAttachment(at) {
  432 + if (!at || !at.id) {
  433 + uni.showToast({ title: '无法查看', icon: 'none' })
  434 + return
  435 + }
  436 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  437 + }
  438 + }
  439 +}
  440 +</script>
  441 +
  442 +<style lang="scss" scoped>
  443 +.page {
  444 + display: flex;
  445 + flex-direction: column;
  446 + height: 100%;
  447 +}
  448 +.scroll {
  449 + flex: 1;
  450 + padding: 8rpx 0 144rpx;
  451 +}
  452 +.detail-page {
  453 + background: #f3f3f3;
  454 +}
  455 +.title-header {
  456 + display: flex;
  457 + align-items: center;
  458 + padding: 24rpx 32rpx 12rpx;
  459 + background-color: #ffffff;
  460 + .title-header_icon {
  461 + width: 36rpx;
  462 + height: 36rpx;
  463 + margin-right: 12rpx;
  464 + }
  465 + span {
  466 + font-size: 34rpx;
  467 + font-weight: 600;
  468 + color: rgba(0, 0, 0, 0.9);
  469 + }
  470 +}
  471 +.section {
  472 + padding: 32rpx;
  473 + background: #fff;
  474 + margin-bottom: 20rpx;
  475 +}
  476 +.row {
  477 + display: flex;
  478 + margin-bottom: 28rpx;
  479 + &:last-child { margin-bottom: 0; }
  480 + &.company {
  481 + font-size: 36rpx;
  482 + font-weight: 600;
  483 + color: rgba(0, 0, 0, 0.9);
  484 + padding-top: 8rpx;
  485 + line-height: 50rpx;
  486 + }
  487 + .label {
  488 + max-width: 420rpx;
  489 + margin-right: 20rpx;
  490 + line-height: 32rpx;
  491 + font-size: 28rpx;
  492 + color: rgba(0, 0, 0, 0.6);
  493 + }
  494 + .value {
  495 + flex: 1;
  496 + line-height: 32rpx;
  497 + font-size: 28rpx;
  498 + color: rgba(0, 0, 0, 0.9);
  499 + text-align: right;
  500 + word-break: break-all;
  501 + }
  502 +}
  503 +.line-block {
  504 + padding-bottom: 24rpx;
  505 + margin-bottom: 24rpx;
  506 + border-bottom: 1rpx solid #f0f0f0;
  507 + &:last-child {
  508 + padding-bottom: 0;
  509 + margin-bottom: 0;
  510 + border-bottom: none;
  511 + }
  512 +}
  513 +.line-title {
  514 + font-size: 30rpx;
  515 + font-weight: 600;
  516 + color: rgba(0, 0, 0, 0.9);
  517 + margin-bottom: 20rpx;
  518 +}
  519 +.attach-list {
  520 + flex: 1;
  521 + display: flex;
  522 + flex-direction: column;
  523 + align-items: flex-end;
  524 + gap: 8rpx;
  525 +}
  526 +.attach-item {
  527 + display: flex;
  528 + align-items: center;
  529 + gap: 16rpx;
  530 + .attach-name {
  531 + font-size: 26rpx;
  532 + color: rgba(0, 0, 0, 0.9);
  533 + }
  534 + .attach-view {
  535 + font-size: 26rpx;
  536 + color: $theme-primary;
  537 + }
  538 +}
  539 +.material-group {
  540 + margin-top: 32rpx;
  541 + &:first-child { margin-top: 0; }
  542 +}
  543 +.material-label {
  544 + display: block;
  545 + font-size: 28rpx;
  546 + color: rgba(0, 0, 0, 0.6);
  547 + margin-bottom: 20rpx;
  548 +}
  549 +.tag-list {
  550 + display: flex;
  551 + flex-wrap: wrap;
  552 + gap: 16rpx;
  553 +}
  554 +.tag-btn {
  555 + padding: 12rpx 24rpx;
  556 + border: 1rpx solid #ddd;
  557 + border-radius: 8rpx;
  558 + font-size: 28rpx;
  559 + color: #999;
  560 + background: #f5f5f5;
  561 +}
  562 +.tag-btn.active {
  563 + background: $theme-primary;
  564 + border-color: $theme-primary;
  565 + color: #fff;
  566 +}
  567 +.remark-text {
  568 + font-size: 28rpx;
  569 + color: rgba(0, 0, 0, 0.9);
  570 + line-height: 1.6;
  571 + white-space: pre-wrap;
  572 +}
  573 +.empty-tip {
  574 + text-align: center;
  575 + font-size: 28rpx;
  576 + color: rgba(0, 0, 0, 0.4);
  577 + padding: 24rpx 0;
  578 +}
  579 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <view class="plan-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 class="tool-icon" src="/static/images/dev_manage/filter_icon.png" @click="openFilter" />
  18 + <image v-if="$auth.hasPermi('plan-manage:schedule-plan:add')" class="tool-icon" src="/static/images/dev_manage/add_icon.png" @click="onAdd" />
  19 + </view>
  20 + </view>
  21 + </view>
  22 +
  23 + <view class="list-box">
  24 + <card-list
  25 + ref="cardRef"
  26 + :fetch-fn="fetchList"
  27 + :query="query"
  28 + :extra="extraParams"
  29 + row-key="id"
  30 + :enable-refresh="true"
  31 + :enable-load-more="true"
  32 + @loaded="onCardLoaded"
  33 + @error="onCardError"
  34 + >
  35 + <template v-slot="{ item }">
  36 + <view class="card" @click="onCardClick(item)">
  37 + <view class="card-header">
  38 + <text class="title omit2">{{ item.code || '-' }}</text>
  39 + <text :class="['status', `status_${item.approvalStatus}`]">{{ getAuditStatusText(item.approvalStatus) }}</text>
  40 + </view>
  41 + <view class="info-row">
  42 + <text>公司名称</text>
  43 + <text>{{item.companyShortName || '-' }}</text>
  44 + </view>
  45 + <view class="info-row">
  46 + <text>供应商名称</text>
  47 + <text>{{ item.supplierName || '-' }}</text>
  48 + </view>
  49 + <view class="info-row">
  50 + <text>数量</text>
  51 + <text>{{ formatQuantity(item.totalQuantity || 0) }}</text>
  52 + </view>
  53 + <view class="info-row">
  54 + <text>采购处</text>
  55 + <text>{{ item.purchaseDepartmentName || '-' }}</text>
  56 + </view>
  57 + </view>
  58 + </template>
  59 + </card-list>
  60 + </view>
  61 +
  62 + <filter-modal
  63 + :visible.sync="filterVisible"
  64 + :value.sync="filterForm"
  65 + title="筛选"
  66 + @reset="onFilterReset"
  67 + @confirm="onFilterConfirm"
  68 + >
  69 + <template v-slot="{ model }">
  70 + <view class="filter-form">
  71 + <view class="form-item">
  72 + <view class="label">编号</view>
  73 + <input class="input" v-model="model.code" placeholder="请输入编号" />
  74 + </view>
  75 + <view class="form-item">
  76 + <view class="label">供应商名称</view>
  77 + <input class="input" v-model="model.supplierName" placeholder="请输入供应商名称" />
  78 + </view>
  79 + <view class="form-item">
  80 + <view class="label">日期</view>
  81 + <uni-datetime-picker type="daterange" v-model="model.dateRange" start="2023-01-01" />
  82 + </view>
  83 + </view>
  84 + </template>
  85 + </filter-modal>
  86 + </view>
  87 +</template>
  88 +
  89 +<script>
  90 +import CardList from '@/components/card/index.vue'
  91 +import FilterModal from '@/components/filter/index.vue'
  92 +import { getDicByCodes, getDicName } from '@/utils/dic.js'
  93 +import { procurementReplenishQueryApi } from '@/api/procure-manage/procurementPlan.js'
  94 +
  95 +export default {
  96 + name: 'SupplyPlan',
  97 + components: { CardList, FilterModal },
  98 + data() {
  99 + return {
  100 + searchKeyword: '',
  101 + searchKeywordDebounced: '',
  102 + searchDebounceTimer: null,
  103 + query: {
  104 + code: '',
  105 + supplierName: '',
  106 + dateRange: []
  107 + },
  108 + extraParams: {},
  109 + currentItems: [],
  110 + filterVisible: false,
  111 + filterForm: {
  112 + code: '',
  113 + supplierName: '',
  114 + dateRange: []
  115 + },
  116 + dicOptions: {
  117 + AUDIT_STATUS: []
  118 + }
  119 + }
  120 + },
  121 + computed: {
  122 + extraCombined() {
  123 + const keyword = this.searchKeywordDebounced || ''
  124 + return {
  125 + keyword: keyword || undefined
  126 + }
  127 + }
  128 + },
  129 + watch: {
  130 + extraCombined: {
  131 + deep: true,
  132 + handler(v) {
  133 + this.extraParams = v
  134 + },
  135 + immediate: true
  136 + }
  137 + },
  138 + created() {
  139 + this.loadDicData()
  140 + },
  141 + onShow() {
  142 + let needRefresh = ''
  143 + try { needRefresh = uni.getStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH') } catch (e) {}
  144 + if (!needRefresh) return
  145 + try { uni.removeStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH') } catch (e) {}
  146 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.reload) {
  147 + this.$refs.cardRef.reload()
  148 + }
  149 + },
  150 + onReachBottom() {
  151 + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.onLoadMore) {
  152 + this.$refs.cardRef.onLoadMore()
  153 + }
  154 + },
  155 + beforeDestroy() {
  156 + if (this.searchDebounceTimer) {
  157 + clearTimeout(this.searchDebounceTimer)
  158 + this.searchDebounceTimer = null
  159 + }
  160 + },
  161 + methods: {
  162 + onAdd() {
  163 + uni.navigateTo({ url: '/pages/supple-plan/add' })
  164 + },
  165 + async loadDicData() {
  166 + try {
  167 + const results = await getDicByCodes(['AUDIT_STATUS'])
  168 + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || []
  169 + } catch (e) {
  170 + this.dicOptions.AUDIT_STATUS = []
  171 + }
  172 + },
  173 + getAuditStatusText(status) {
  174 + const v = status == null ? '' : String(status)
  175 + if (!v) return '-'
  176 + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v
  177 + },
  178 + getTotalQuantity(item) {
  179 + const lines = item && item.procurementPlanLineList && Array.isArray(item.procurementPlanLineList)
  180 + ? item.procurementPlanLineList
  181 + : []
  182 + let total = 0
  183 + lines.forEach(line => {
  184 + const q = line && line.quantity != null ? Number(line.quantity) : 0
  185 + if (!isNaN(q)) total += q
  186 + })
  187 + return total
  188 + },
  189 + formatQuantity(val) {
  190 + if (val == null) return '-'
  191 + try {
  192 + const num = Number(val)
  193 + if (isNaN(num)) return '-'
  194 + return num.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  195 + } catch (e) {
  196 + return String(val)
  197 + }
  198 + },
  199 + onCardLoaded(_ref) {
  200 + var items = _ref.items
  201 + this.currentItems = items
  202 + },
  203 + onCardError() {
  204 + uni.showToast({ title: '列表加载失败', icon: 'none' })
  205 + },
  206 + onSearchInput() {
  207 + var _this = this
  208 + if (this.searchDebounceTimer) clearTimeout(this.searchDebounceTimer)
  209 + this.searchDebounceTimer = setTimeout(function () {
  210 + _this.searchKeywordDebounced = _this.searchKeyword
  211 + _this.searchDebounceTimer = null
  212 + }, 1200)
  213 + },
  214 + search(e) {
  215 + const val = e && e.value != null ? e.value : this.searchKeyword
  216 + this.searchKeyword = val
  217 + this.searchKeywordDebounced = val
  218 + },
  219 + openFilter() {
  220 + this.filterForm = {
  221 + code: this.query.code || '',
  222 + supplierName: this.query.supplierName || '',
  223 + dateRange: Array.isArray(this.query.dateRange) ? this.query.dateRange.slice(0) : []
  224 + }
  225 + this.filterVisible = true
  226 + },
  227 + onFilterReset(payload) {
  228 + this.filterForm = payload
  229 + },
  230 + onFilterConfirm(payload) {
  231 + this.query = {
  232 + code: payload.code || '',
  233 + supplierName: payload.supplierName || '',
  234 + dateRange: Array.isArray(payload.dateRange) ? payload.dateRange : []
  235 + }
  236 + },
  237 + fetchList(_ref2) {
  238 + var _this2 = this
  239 + var pageIndex = _ref2.pageIndex
  240 + var pageSize = _ref2.pageSize
  241 + var query = _ref2.query
  242 + var extra = _ref2.extra
  243 + const q = query || {}
  244 + const e = extra || {}
  245 + const range = Array.isArray(q.dateRange) ? q.dateRange : []
  246 + const keyword = e.keyword || ''
  247 + const params = {
  248 + pageIndex: pageIndex,
  249 + pageSize: pageSize,
  250 + code: q.code || '',
  251 + supplierName: q.supplierName || '',
  252 + startDate: range && range.length === 2 ? range[0] : '',
  253 + endDate: range && range.length === 2 ? range[1] : ''
  254 + }
  255 + if (keyword) {
  256 + if (!params.code) params.code = keyword
  257 + if (!params.supplierName) params.supplierName = keyword
  258 + }
  259 + return procurementReplenishQueryApi(params).then(function (res) {
  260 + const _data = res && res.data ? res.data : {}
  261 + let records = _data.datas || _data.list || _data.records || []
  262 + const totalCount = _data.totalCount || _data.count || 0
  263 + const hasNext = _data.hasNext || false
  264 + records = records.map(function (it) { return Object.assign({}, it) })
  265 + return { records: records, totalCount: totalCount, hasNext: hasNext }
  266 + }).catch(function () {
  267 + _this2.onCardError()
  268 + return { records: [], totalCount: 0, hasNext: false }
  269 + })
  270 + },
  271 + onCardClick(item) {
  272 + uni.navigateTo({ url: '/pages/supple-plan/detail?id=' + item.id })
  273 + }
  274 + }
  275 +}
  276 +</script>
  277 +
  278 +<style lang="scss" scoped>
  279 +.page {
  280 + display: flex;
  281 + flex-direction: column;
  282 + height: 100vh;
  283 +}
  284 +.plan-list-fixed {
  285 + position: fixed;
  286 + top: 96rpx;
  287 + left: 0;
  288 + right: 0;
  289 + z-index: 2;
  290 + background: #fff;
  291 + .search-row {
  292 + display: flex;
  293 + align-items: center;
  294 + padding: 16rpx 32rpx;
  295 + .uni-searchbar { padding: 0; flex: 1; }
  296 + .tool-icons {
  297 + display: flex;
  298 + .tool-icon { width: 48rpx; height: 48rpx; display: block; margin-left: 32rpx; }
  299 + }
  300 + }
  301 +}
  302 +::v-deep .uni-searchbar__box { height: 80rpx !important; justify-content: start; .uni-searchbar__box-search-input { font-size: 32rpx !important; } }
  303 +.list-box {
  304 + flex: 1;
  305 + padding-top: 140rpx;
  306 + .card { position: relative; }
  307 + .card-header {
  308 + margin-bottom: 28rpx;
  309 + position: relative;
  310 + .title { font-size: 36rpx; font-weight: 600; line-height: 50rpx; color: rgba(0,0,0,0.9); width: 578rpx; }
  311 + .status {
  312 + position: absolute;
  313 + top: -32rpx;
  314 + right: -12rpx;
  315 + height: 48rpx;
  316 + line-height: 48rpx;
  317 + font-weight: 600;
  318 + color: #fff;
  319 + font-size: 24rpx;
  320 + padding: 0 14rpx;
  321 + border-radius: 6rpx;
  322 + box-sizing: content-box;
  323 +
  324 + &.status_AUDIT {
  325 + background: $theme-primary;
  326 + }
  327 +
  328 + &.status_PASS {
  329 + background: #2BA471;
  330 + }
  331 +
  332 + &.status_REFUSE {
  333 + background: #D54941;
  334 + }
  335 +
  336 + &.status_CANCEL {
  337 + background: #E7E7E7;
  338 + color: rgba(0, 0, 0, 0.9);
  339 + }
  340 + }
  341 + }
  342 + .info-row {
  343 + display: flex;
  344 + align-items: center;
  345 + color: rgba(0,0,0,0.6);
  346 + font-size: 28rpx;
  347 + margin-bottom: 24rpx;
  348 + height: 32rpx;
  349 + &:last-child { margin-bottom: 0; }
  350 + text {
  351 + width: 50%;
  352 + &:last-child { color: rgba(0,0,0,0.9); width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  353 + }
  354 + }
  355 +}
  356 +.filter-form {
  357 + .form-item { margin-bottom: 24rpx; }
  358 + .label { margin-bottom: 20rpx; color: rgba(0,0,0,0.9); height: 44rpx; line-height: 44rpx; font-size: 30rpx; }
  359 + .input {
  360 + width: 100%;
  361 + height: 72rpx;
  362 + line-height: 72rpx;
  363 + padding: 0 24rpx;
  364 + border: 1rpx solid #E7E7E7;
  365 + border-radius: 8rpx;
  366 + font-size: 28rpx;
  367 + color: rgba(0,0,0,0.9);
  368 + background: #fff;
  369 + box-sizing: border-box;
  370 + }
  371 +}
  372 +</style>
... ...
  1 +<template>
  2 + <view class="page">
  3 + <scroll-view scroll-y class="scroll">
  4 + <uni-list>
  5 + <uni-list-item class="select-item" :class="form.planCode ? 'is-filled' : 'is-empty'">
  6 + <template v-slot:body>
  7 + <view class="item-title"><text class="required">*</text><text>计划数据</text></view>
  8 + </template>
  9 + <template v-slot:footer>
  10 + <text class="readonly-text">{{ form.planCode || '-' }}</text>
  11 + </template>
  12 + </uni-list-item>
  13 +
  14 + <uni-list-item title="公司名称">
  15 + <template v-slot:footer>
  16 + <uni-easyinput v-model="companyNameDisplay" :inputBorder="false" disabled placeholder="-" />
  17 + </template>
  18 + </uni-list-item>
  19 +
  20 + <uni-list-item>
  21 + <template v-slot:body>
  22 + <view class="item-title"><text class="required">*</text><text>供应商名称</text></view>
  23 + </template>
  24 + <template v-slot:footer>
  25 + <uni-easyinput v-model="detail.supplierName" :inputBorder="false" placeholder="请输入供应商名称" />
  26 + </template>
  27 + </uni-list-item>
  28 +
  29 + <uni-list-item title="采购处">
  30 + <template v-slot:footer>
  31 + <uni-easyinput v-model="purchaseDepartmentDisplay" :inputBorder="false" disabled placeholder="-" />
  32 + </template>
  33 + </uni-list-item>
  34 +
  35 + <uni-list-item title="区域">
  36 + <template v-slot:footer>
  37 + <uni-easyinput v-model="regionDisplay" :inputBorder="false" disabled placeholder="-" />
  38 + </template>
  39 + </uni-list-item>
  40 +
  41 + <uni-list-item title="日期">
  42 + <template v-slot:footer>
  43 + <uni-easyinput v-model="dateDisplay" :inputBorder="false" disabled placeholder="-" />
  44 + </template>
  45 + </uni-list-item>
  46 +
  47 + <uni-list-item>
  48 + <template v-slot:body>
  49 + <view class="item-title"><text class="required">*</text><text>报价时效</text></view>
  50 + </template>
  51 + <template v-slot:footer>
  52 + <uni-easyinput v-model="detail.validityPeriod" :inputBorder="false" placeholder="请输入报价时效" />
  53 + </template>
  54 + </uni-list-item>
  55 +
  56 + <uni-list-item>
  57 + <template v-slot:body>
  58 + <view class="item-title"><text class="required">*</text><text>报价人</text></view>
  59 + </template>
  60 + <template v-slot:footer>
  61 + <uni-easyinput v-model="detail.quoterName" :inputBorder="false" placeholder="请输入报价人" />
  62 + </template>
  63 + </uni-list-item>
  64 +
  65 + <uni-list-item class="select-item" :class="typeof detail.longTermOperation === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  66 + @click="toggleBool('longTermOperation')" :rightText="boolText(detail.longTermOperation) || '请选择'" showArrow>
  67 + <template v-slot:body>
  68 + <view class="item-title"><text class="required">*</text><text>是否长单操作</text></view>
  69 + </template>
  70 + </uni-list-item>
  71 +
  72 + <uni-list-item class="select-item" :class="typeof detail.terminalCustomer === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  73 + @click="toggleBool('terminalCustomer')" :rightText="boolText(detail.terminalCustomer) || '请选择'" showArrow>
  74 + <template v-slot:body>
  75 + <view class="item-title"><text class="required">*</text><text>是否终端客户</text></view>
  76 + </template>
  77 + </uni-list-item>
  78 +
  79 + <uni-list-item class="select-item" :class="typeof detail.priced === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  80 + @click="toggleBool('priced')" :rightText="boolText(detail.priced) || '请选择'" showArrow>
  81 + <template v-slot:body>
  82 + <view class="item-title"><text class="required">*</text><text>是否未点价</text></view>
  83 + </template>
  84 + </uni-list-item>
  85 +
  86 + <uni-list-item v-if="detail.priced === true">
  87 + <template v-slot:body>
  88 + <view class="item-title"><text class="required">*</text><text>点价截止日期</text></view>
  89 + </template>
  90 + <template v-slot:footer>
  91 + <uni-datetime-picker type="date" v-model="detail.pricingDeadline" return-type="string" />
  92 + </template>
  93 + </uni-list-item>
  94 +
  95 + <uni-list-item v-if="detail.priced === true" class="select-item" :class="typeof detail.temporaryPrice === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  96 + @click="toggleBool('temporaryPrice')" :rightText="boolText(detail.temporaryPrice) || '请选择'" showArrow>
  97 + <template v-slot:body>
  98 + <view class="item-title"><text class="required">*</text><text>是否暂定价</text></view>
  99 + </template>
  100 + </uni-list-item>
  101 +
  102 + <uni-list-item class="select-item" :class="typeof detail.otherExpenseSettlement === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  103 + @click="toggleBool('otherExpenseSettlement')" :rightText="boolText(detail.otherExpenseSettlement) || '请选择'" showArrow>
  104 + <template v-slot:body>
  105 + <view class="item-title"><text class="required">*</text><text>其他费用凭票到厂另行结算</text></view>
  106 + </template>
  107 + </uni-list-item>
  108 +
  109 + <uni-list-item class="select-item" :class="detail.deliveryMode ? 'is-filled' : 'is-empty'" clickable
  110 + @click="openDeliverySheet" :rightText="getDeliveryMethodLabel()" showArrow>
  111 + <template v-slot:body>
  112 + <view class="item-title"><text class="required">*</text><text>交提货方式</text></view>
  113 + </template>
  114 + </uni-list-item>
  115 +
  116 + <uni-list-item class="select-item" :class="typeof detail.commodityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  117 + @click="toggleBool('commodityBuyout')" :rightText="boolText(detail.commodityBuyout) || '请选择'" showArrow>
  118 + <template v-slot:body>
  119 + <view class="item-title"><text class="required">*</text><text>是否通货买断</text></view>
  120 + </template>
  121 + </uni-list-item>
  122 +
  123 + <uni-list-item class="select-item" :class="typeof detail.qualityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  124 + @click="toggleBool('qualityBuyout')" :rightText="boolText(detail.qualityBuyout) || '请选择'" showArrow>
  125 + <template v-slot:body>
  126 + <view class="item-title"><text class="required">*</text><text>是否质量买断</text></view>
  127 + </template>
  128 + </uni-list-item>
  129 +
  130 + <uni-list-item class="select-item" :class="typeof detail.quantityBuyout === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  131 + @click="toggleBool('quantityBuyout')" :rightText="boolText(detail.quantityBuyout) || '请选择'" showArrow>
  132 + <template v-slot:body>
  133 + <view class="item-title"><text class="required">*</text><text>是否数量买断</text></view>
  134 + </template>
  135 + </uni-list-item>
  136 +
  137 + <uni-list-item class="select-item" :class="typeof detail.doorDelivery === 'boolean' ? 'is-filled' : 'is-empty'" clickable
  138 + @click="toggleBool('doorDelivery')" :rightText="boolText(detail.doorDelivery) || '请选择'" showArrow>
  139 + <template v-slot:body>
  140 + <view class="item-title"><text class="required">*</text><text>是否送货上门</text></view>
  141 + </template>
  142 + </uni-list-item>
  143 +
  144 + <uni-list-item title="另付运费">
  145 + <template v-slot:footer>
  146 + <uni-easyinput v-model="shippingCostDisplay" :inputBorder="false" disabled placeholder="-" />
  147 + </template>
  148 + </uni-list-item>
  149 +
  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
  156 + v-model="detail.loadingFee"
  157 + type="digit"
  158 + :inputBorder="false"
  159 + placeholder="请输入装车费"
  160 + @input="onNonNegativeInput('loadingFee')"
  161 + @blur="onNonNegativeBlur('loadingFee', 2)"
  162 + />
  163 + </template>
  164 + </uni-list-item>
  165 +
  166 + <uni-list-item>
  167 + <template v-slot:body>
  168 + <view class="item-title"><text class="required">*</text><text>开票品名</text></view>
  169 + </template>
  170 + <template v-slot:footer>
  171 + <uni-easyinput v-model="detail.invoiceProductName" :inputBorder="false" placeholder="请输入开票品名" />
  172 + </template>
  173 + </uni-list-item>
  174 +
  175 + <uni-list-item>
  176 + <template v-slot:body>
  177 + <view class="item-title"><text class="required">*</text><text>交货日期</text></view>
  178 + </template>
  179 + <template v-slot:footer>
  180 + <uni-datetime-picker type="date" v-model="detail.deliveryDate" return-type="string" />
  181 + </template>
  182 + </uni-list-item>
  183 +
  184 + <uni-list-item>
  185 + <template v-slot:body>
  186 + <view class="item-title"><text class="required">*</text><text>结算方式</text></view>
  187 + </template>
  188 + <template v-slot:footer>
  189 + <uni-easyinput v-model="detail.settlementMethod" :inputBorder="false" placeholder="请输入结算方式" />
  190 + </template>
  191 + </uni-list-item>
  192 +
  193 + <uni-list-item>
  194 + <template v-slot:body>
  195 + <view class="item-title"><text class="required">*</text><text>结算比例(%)</text></view>
  196 + </template>
  197 + <template v-slot:footer>
  198 + <uni-easyinput
  199 + v-model="detail.settlementRatio"
  200 + type="digit"
  201 + :inputBorder="false"
  202 + placeholder="请输入结算比例"
  203 + @input="onNonNegativeInput('settlementRatio')"
  204 + @blur="onNonNegativeBlur('settlementRatio', 4)"
  205 + />
  206 + </template>
  207 + </uni-list-item>
  208 +
  209 + <uni-list-item title="价格表编号">
  210 + <template v-slot:footer>
  211 + <uni-easyinput v-model="priceTableDisplay" :inputBorder="false" disabled placeholder="-" />
  212 + </template>
  213 + </uni-list-item>
  214 +
  215 + <uni-list-item>
  216 + <template v-slot:body>
  217 + <view class="item-title"><text class="required">*</text><text>协调事由</text></view>
  218 + </template>
  219 + <template v-slot:footer>
  220 + <uni-easyinput v-model="detail.coordinationReason" :inputBorder="false" placeholder="请输入协调事由" />
  221 + </template>
  222 + </uni-list-item>
  223 +
  224 + <uni-list-item>
  225 + <template v-slot:body>
  226 + <view class="item-title"><text class="required">*</text><text>票类状况</text></view>
  227 + </template>
  228 + <template v-slot:footer>
  229 + <uni-easyinput v-model="detail.invoiceTypeStatus" :inputBorder="false" placeholder="请输入票类状况" />
  230 + </template>
  231 + </uni-list-item>
  232 +
  233 + <uni-list-item v-if="attachmentList.length" title="附件">
  234 + <template v-slot:footer>
  235 + <view class="attach-list">
  236 + <view v-for="(at, idx) in attachmentList" :key="idx" class="attach-item">
  237 + <text class="attach-name">{{ at.name }}</text>
  238 + <text class="attach-view" @click.stop="onPreviewAttachment(at)">查看</text>
  239 + </view>
  240 + </view>
  241 + </template>
  242 + </uni-list-item>
  243 +
  244 + <ProductRel
  245 + ref="productRel"
  246 + mode="edit"
  247 + :list="lineList"
  248 + :product-options="productOptions"
  249 + :workshop-options="workshopOptions"
  250 + :shipping-cost="detail.shippingCost"
  251 + :price-map="priceMap"
  252 + @change="onLineChange"
  253 + />
  254 + </uni-list>
  255 +
  256 + <view class="material-condition-section">
  257 + <view class="section-header">
  258 + <image class="opCollapse" src="/static/images/title.png" />
  259 + <text class="section-title">料质状况</text>
  260 + </view>
  261 + <view class="section-content">
  262 + <view class="form-row">
  263 + <text class="form-label">是否启用料质状况</text>
  264 + <text class="form-value toggle-link" @click="toggleBool('materialConditionEnabled')">{{ boolText(detail.materialConditionEnabled) || '请选择' }}</text>
  265 + </view>
  266 + <template v-if="detail.materialConditionEnabled">
  267 + <view v-for="mc in materialConditionConfigs" :key="mc.field" class="material-group">
  268 + <text class="material-label">{{ mc.label }}</text>
  269 + <view class="tag-list">
  270 + <view
  271 + v-for="opt in getDictOptions(mc.dictCode)"
  272 + :key="opt.code"
  273 + class="tag-btn"
  274 + :class="{ active: isTagSelected(mc.field, opt.code) }"
  275 + @click="toggleTag(mc.field, opt.code)"
  276 + >
  277 + {{ opt.name }}
  278 + </view>
  279 + </view>
  280 + </view>
  281 + </template>
  282 + </view>
  283 + </view>
  284 +
  285 + <view class="remark-section">
  286 + <view class="section-header">
  287 + <image class="opCollapse" src="/static/images/title.png" />
  288 + <text class="section-title">备注</text>
  289 + </view>
  290 + <view class="section-content">
  291 + <uni-easyinput type="textarea" v-model="detail.remark" :inputBorder="false" placeholder="请输入备注" />
  292 + </view>
  293 + </view>
  294 +
  295 + <view class="remark-section">
  296 + <view class="section-header">
  297 + <image class="opCollapse" src="/static/images/title.png" />
  298 + <text class="section-title"><text class="required">*</text>变更事由</text>
  299 + </view>
  300 + <view class="section-content">
  301 + <uni-easyinput type="textarea" v-model="detail.changeReason" :inputBorder="false" placeholder="请输入变更事由" />
  302 + </view>
  303 + </view>
  304 + </scroll-view>
  305 +
  306 + <view class="bottom-bar">
  307 + <button class="btn btn-outline" @click="onBack">取消</button>
  308 + <button class="btn btn-primary" @click="onSubmit">保存</button>
  309 + </view>
  310 +
  311 + <SingleSelectSheet
  312 + :visible.sync="deliverySheetVisible"
  313 + title="交提货方式"
  314 + :options="deliveryOptions"
  315 + v-model="deliverySheetValue"
  316 + @confirm="onDeliveryConfirm"
  317 + />
  318 + </view>
  319 +</template>
  320 +
  321 +<script>
  322 +import ProductRel from './productRel.vue'
  323 +import SingleSelectSheet from '@/components/single-select/index.vue'
  324 +import { procurementPlanReplenishFindByIdApi, procurementPlanReplenishUpdateApi } from '@/api/procure-manage/procurementPlan.js'
  325 +import {
  326 + breedRelationshipQueryApi,
  327 + priceTableDetailApi,
  328 + workshopQueryApi
  329 +} from '@/api/devManage.js'
  330 +import { getDicByCodes } from '@/utils/dic.js'
  331 +
  332 +export default {
  333 + name: 'SchedulePlanModify',
  334 + components: { ProductRel, SingleSelectSheet },
  335 + data() {
  336 + return {
  337 + id: '',
  338 + form: {
  339 + planId: '',
  340 + planCode: ''
  341 + },
  342 + detail: {},
  343 + attachmentList: [],
  344 + materialConditionConfigs: [
  345 + { field: 'materialConditionCopperRice', label: '铜米', dictCode: 'COPPER_RICE' },
  346 + { field: 'materialConditionBrightCopper', label: '光亮铜', dictCode: 'BRIGHT_COPPER' },
  347 + { field: 'materialConditionFirstClass', label: '一特', dictCode: 'FIRST_CLASS' },
  348 + { field: 'materialConditionSecondClass', label: '二特', dictCode: 'SECOND_CLASS' },
  349 + { field: 'materialConditionTinCoated', label: '镀锡紫', dictCode: 'TIN_COATED' },
  350 + { field: 'materialConditionScrap', label: '角料', dictCode: 'SCRAP' },
  351 + { field: 'materialConditionWhiteYellow', label: '镀白黄', dictCode: 'WHITE_YELLOW' },
  352 + { field: 'materialConditionPhosphorCopper', label: '磷铜', dictCode: 'PHOSPHOR_COPPER' }
  353 + ],
  354 + dicOptions: {
  355 + DELIVERY_METHOD: []
  356 + },
  357 + dictData: {},
  358 + lineList: [],
  359 + productOptions: [],
  360 + workshopOptions: [],
  361 + priceMap: {},
  362 + deliverySheetVisible: false,
  363 + deliverySheetValue: '',
  364 + deliveryOptions: []
  365 + }
  366 + },
  367 + computed: {
  368 + companyNameDisplay() {
  369 + var d = this.detail || {}
  370 + return d.companyShortName != null ? d.companyShortName : (d.companyName != null ? d.companyName : '')
  371 + },
  372 + purchaseDepartmentDisplay() {
  373 + var d = this.detail || {}
  374 + return d.purchaseDepartmentName != null ? d.purchaseDepartmentName : (d.purchaseDepartment != null ? d.purchaseDepartment : '')
  375 + },
  376 + regionDisplay() {
  377 + var d = this.detail || {}
  378 + return d.regionName != null ? d.regionName : (d.region != null ? d.region : '')
  379 + },
  380 + dateDisplay() {
  381 + var d = this.detail || {}
  382 + var s = d.date == null ? '' : String(d.date).trim()
  383 + return s.length >= 10 ? s.slice(0, 10) : s
  384 + },
  385 + shippingCostDisplay() {
  386 + var v = (this.detail || {}).shippingCost
  387 + if (v == null || v === '') return ''
  388 + var n = Number(v)
  389 + if (isNaN(n)) return String(v)
  390 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  391 + },
  392 + priceTableDisplay() {
  393 + var d = this.detail || {}
  394 + var code = d.priceTableCode != null ? String(d.priceTableCode).trim() : ''
  395 + if (!code) return ''
  396 + var name = d.priceTableName || ''
  397 + return name ? (name + ' (' + code + ')') : code
  398 + }
  399 + },
  400 + onLoad(query) {
  401 + this.id = (query && query.id) || ''
  402 + this.loadDictData()
  403 + this.loadRefData()
  404 + if (this.id) {
  405 + this.loadDetailById(this.id)
  406 + }
  407 + },
  408 + methods: {
  409 + safeText(v) {
  410 + var s = v == null ? '' : String(v)
  411 + return s.trim() ? s : '-'
  412 + },
  413 + boolText(v) {
  414 + if (typeof v !== 'boolean') return ''
  415 + return v ? '是' : '否'
  416 + },
  417 + toNumber(v) {
  418 + if (v == null || v === '') return 0
  419 + var n = Number(v)
  420 + return isNaN(n) ? 0 : n
  421 + },
  422 + toFixed(v, n) {
  423 + var num = Number(v)
  424 + if (isNaN(num)) return ''
  425 + return num.toFixed(n)
  426 + },
  427 + async loadDictData() {
  428 + var codes = [].concat(
  429 + this.materialConditionConfigs.map(function (mc) { return mc.dictCode }),
  430 + ['DELIVERY_METHOD']
  431 + )
  432 + try {
  433 + var results = await getDicByCodes(codes)
  434 + var d = results || {}
  435 + this.dictData = d
  436 + this.dicOptions.DELIVERY_METHOD = (d.DELIVERY_METHOD && d.DELIVERY_METHOD.data) || []
  437 + this.deliveryOptions = this.dicOptions.DELIVERY_METHOD.map(function (o) {
  438 + return { label: o.name || o.label || '', value: o.code != null ? o.code : o.value }
  439 + })
  440 + } catch (e) {
  441 + this.dictData = {}
  442 + }
  443 + },
  444 + async loadRefData() {
  445 + try {
  446 + var results = await Promise.all([
  447 + this.$pCall(breedRelationshipQueryApi, { pageIndex: 1, pageSize: 1000 }),
  448 + this.$pCall(workshopQueryApi, { pageIndex: 1, pageSize: 1000 })
  449 + ])
  450 + var r1 = (results[0] && results[0].data) ? results[0].data : {}
  451 + var r2 = (results[1] && results[1].data) ? results[1].data : {}
  452 + this.productOptions = (r1.datas && Array.isArray(r1.datas)) ? r1.datas : ((r1.list && Array.isArray(r1.list)) ? r1.list : ((r1.records && Array.isArray(r1.records)) ? r1.records : []))
  453 + this.workshopOptions = (r2.datas && Array.isArray(r2.datas)) ? r2.datas : ((r2.list && Array.isArray(r2.list)) ? r2.list : ((r2.records && Array.isArray(r2.records)) ? r2.records : []))
  454 + this.fillLineNames()
  455 + } catch (e) {
  456 + this.productOptions = []
  457 + this.workshopOptions = []
  458 + }
  459 + },
  460 + $pCall(fn, params) {
  461 + try { return Promise.resolve(fn(params)) } catch (e) { return Promise.reject(e) }
  462 + },
  463 + getDictOptions(dictCode) {
  464 + var data = this.dictData[dictCode]
  465 + return (data && data.data) ? data.data : []
  466 + },
  467 + getDeliveryMethodLabel() {
  468 + var opts = this.dicOptions.DELIVERY_METHOD || []
  469 + var v = String(this.detail.deliveryMode != null ? this.detail.deliveryMode : '')
  470 + if (!v) return '请选择'
  471 + for (var i = 0; i < opts.length; i++) {
  472 + var o = opts[i]
  473 + var code = o.code != null ? String(o.code) : (o.value != null ? String(o.value) : '')
  474 + if (code === v) return o.name || o.label || v
  475 + }
  476 + return v
  477 + },
  478 + async loadDetailById(id) {
  479 + if (!id) return
  480 + try {
  481 + var res = await procurementPlanReplenishFindByIdApi({ id: id })
  482 + var d = (res && res.data) ? res.data : {}
  483 + var boolFields = ['longTermOperation', 'terminalCustomer', 'priced', 'temporaryPrice', 'otherExpenseSettlement', 'commodityBuyout', 'qualityBuyout', 'quantityBuyout', 'doorDelivery', 'materialConditionEnabled']
  484 + boolFields.forEach(function (f) {
  485 + var v = d[f]
  486 + if (typeof v === 'string') {
  487 + d[f] = v === 'true' || v === '1'
  488 + } else if (typeof v === 'number') {
  489 + d[f] = v === 1
  490 + } else {
  491 + d[f] = !!v
  492 + }
  493 + })
  494 + this.materialConditionConfigs.forEach(function (mc) {
  495 + var v = d[mc.field]
  496 + if (typeof v === 'string' && v) {
  497 + d[mc.field] = v.split(',').filter(Boolean)
  498 + } else if (!Array.isArray(v)) {
  499 + d[mc.field] = []
  500 + }
  501 + })
  502 + d.pricingDeadline = this.trimDate(d.pricingDeadline)
  503 + d.deliveryDate = this.trimDate(d.deliveryDate)
  504 + this.detail = d
  505 + this.form.planId = d.procurementPlanId != null ? d.procurementPlanId : (d.planId != null ? d.planId : (d.id || ''))
  506 + this.form.planCode = d.procurementPlanCode != null ? d.procurementPlanCode : (d.planCode != null ? d.planCode : d.code)
  507 + var lines = d.lines || d.procurementPlanLineList || d.lineList || []
  508 + this.lineList = Array.isArray(lines) ? lines.slice() : []
  509 + this.buildAttachmentList()
  510 + this.fillLineNames()
  511 + this.fetchPriceDetailAndApply(d.priceId)
  512 + } catch (e) {
  513 + uni.showToast({ title: '加载详情失败', icon: 'none' })
  514 + }
  515 + },
  516 + trimDate(v) {
  517 + if (v == null || v === '') return ''
  518 + var s = String(v).trim()
  519 + return s.length >= 10 ? s.slice(0, 10) : s
  520 + },
  521 + buildAttachmentList() {
  522 + var ids = this.detail.attachmentFileIds
  523 + var names = this.detail.attachmentFileNames
  524 + var idArr = (typeof ids === 'string' && ids) ? ids.split(',').filter(Boolean) : (Array.isArray(ids) ? ids : [])
  525 + var nameArr = (typeof names === 'string' && names) ? names.split(',').filter(Boolean) : (Array.isArray(names) ? names : [])
  526 + var len = Math.max(idArr.length, nameArr.length)
  527 + var list = []
  528 + for (var i = 0; i < len; i++) {
  529 + list.push({ id: idArr[i] || '', name: nameArr[i] || ('附件' + (i + 1)) })
  530 + }
  531 + this.attachmentList = list
  532 + },
  533 + onPreviewAttachment(at) {
  534 + if (!at || !at.id) {
  535 + uni.showToast({ title: '无法查看', icon: 'none' })
  536 + return
  537 + }
  538 + uni.showToast({ title: '查看附件 ' + at.name, icon: 'none' })
  539 + },
  540 + fillLineNames() {
  541 + var list = Array.isArray(this.lineList) ? this.lineList : []
  542 + if (!list.length) return
  543 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  544 + var wOpts = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  545 + this.lineList = list.map(function (row) {
  546 + var r = Object.assign({}, row)
  547 + var pid = r.productId != null ? String(r.productId) : ''
  548 + var wid = r.workshopId != null ? String(r.workshopId) : ''
  549 + if ((r.productName == null || String(r.productName).trim() === '') && pid) {
  550 + var p = pOpts.find(function (o) {
  551 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  552 + return id === pid
  553 + })
  554 + if (p) {
  555 + r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
  556 + }
  557 + }
  558 + if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) {
  559 + var w = wOpts.find(function (o) {
  560 + var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
  561 + return id === wid
  562 + })
  563 + if (w) {
  564 + r.workshopName = w.name != null ? w.name : (w.workshopName != null ? w.workshopName : (w.label != null ? w.label : ''))
  565 + }
  566 + }
  567 + return r
  568 + })
  569 + },
  570 + async fetchPriceDetailAndApply(priceId) {
  571 + if (!priceId) return
  572 + var self = this
  573 + try {
  574 + var res = await priceTableDetailApi({ id: priceId })
  575 + var d = (res && res.data) ? res.data : {}
  576 + if (d.code != null && this.detail) {
  577 + this.$set(this.detail, 'priceTableCode', String(d.code))
  578 + }
  579 + if (d.priceTableName != null && this.detail) {
  580 + this.$set(this.detail, 'priceTableName', d.priceTableName)
  581 + }
  582 + var priceLines = self.extractPriceLines(d)
  583 + self.applyPriceLinesToLines(priceLines)
  584 + } catch (e) {
  585 + return
  586 + }
  587 + },
  588 + extractPriceLines(priceDetail) {
  589 + if (!priceDetail || typeof priceDetail !== 'object') return []
  590 + var candidates = [
  591 + priceDetail.procurementPriceLineList,
  592 + priceDetail.priceSubTableList,
  593 + priceDetail.priceLineList,
  594 + priceDetail.priceList,
  595 + priceDetail.lineList,
  596 + priceDetail.datas,
  597 + priceDetail.records,
  598 + priceDetail.list
  599 + ]
  600 + for (var i = 0; i < candidates.length; i++) {
  601 + if (Array.isArray(candidates[i]) && candidates[i].length) return candidates[i]
  602 + }
  603 + for (var k in priceDetail) {
  604 + if (!Object.prototype.hasOwnProperty.call(priceDetail, k)) continue
  605 + if (Array.isArray(priceDetail[k])) {
  606 + var arr = priceDetail[k]
  607 + if (arr.length && arr[0] && typeof arr[0] === 'object' && (arr[0].price != null || arr[0].productId != null || arr[0].breedId != null || arr[0].varietyId != null)) {
  608 + return arr
  609 + }
  610 + }
  611 + }
  612 + return []
  613 + },
  614 + buildPriceMap(priceLines) {
  615 + var m = {}
  616 + if (!Array.isArray(priceLines)) return m
  617 + for (var i = 0; i < priceLines.length; i++) {
  618 + var line = priceLines[i] || {}
  619 + if (line.price == null) continue
  620 + var key = String(line.productId || line.breedId || line.varietyId || line.id || ('__idx_' + i))
  621 + m[key] = { price: Number(line.price), meta: line }
  622 + }
  623 + return m
  624 + },
  625 + applyPriceLinesToLines(priceLines) {
  626 + var priceMap = this.buildPriceMap(priceLines)
  627 + this.priceMap = priceMap || {}
  628 + if (!Array.isArray(this.lineList)) return
  629 + var self = this
  630 + this.lineList = this.lineList.map(function (row) {
  631 + var pid = String(row.productId || row.breedId || row.varietyId || '')
  632 + var price = null
  633 + if (pid && priceMap[pid] != null) {
  634 + price = priceMap[pid].price
  635 + } else {
  636 + var pname = (row.productName || '').trim()
  637 + if (pname) {
  638 + for (var k in priceMap) {
  639 + if (!Object.prototype.hasOwnProperty.call(priceMap, k)) continue
  640 + var meta = priceMap[k] && priceMap[k].meta ? priceMap[k].meta : null
  641 + if (meta && ((meta.productName && meta.productName === pname) || (meta.breedName && meta.breedName === pname) || (meta.varietyName && meta.varietyName === pname))) {
  642 + price = priceMap[k].price
  643 + break
  644 + }
  645 + }
  646 + }
  647 + }
  648 + if (price != null) {
  649 + row.priceListPrices = self.toFixed(price, 2)
  650 + } else {
  651 + row.priceListPrices = ''
  652 + }
  653 + return row
  654 + })
  655 + var pr = this.$refs.productRel
  656 + if (pr && typeof pr.recalcAllItems === 'function') {
  657 + pr.recalcAllItems()
  658 + }
  659 + },
  660 + onLineChange(list) {
  661 + var newList = Array.isArray(list) ? list.slice() : []
  662 + var oldList = Array.isArray(this.lineList) ? this.lineList : []
  663 + if (newList.length !== oldList.length) {
  664 + this.lineList = newList
  665 + return
  666 + }
  667 + var i = 0
  668 + for (i = 0; i < newList.length; i++) {
  669 + var n = newList[i] || {}
  670 + var o = oldList[i] || {}
  671 + if (n.productId !== o.productId || n.productName !== o.productName ||
  672 + n.materialType !== o.materialType || n.quantity !== o.quantity ||
  673 + n.actualPurchasePrice !== o.actualPurchasePrice || n.includingShippingPrice !== o.includingShippingPrice ||
  674 + n.priceListPrices !== o.priceListPrices || n.coordinationRange !== o.coordinationRange ||
  675 + n.estimatedLoss !== o.estimatedLoss || n.applicationAttrition !== o.applicationAttrition ||
  676 + n.paintDamageRatio !== o.paintDamageRatio || n.workshopId !== o.workshopId ||
  677 + n.workshopName !== o.workshopName || (n.itemId || '') !== (o.itemId || '')) {
  678 + this.lineList = newList
  679 + return
  680 + }
  681 + }
  682 + },
  683 + toggleBool(field) {
  684 + var cur = this.detail[field]
  685 + this.$set(this.detail, field, cur !== true)
  686 + },
  687 + onNonNegativeInput(field) {
  688 + var v = String(this.detail[field] != null ? this.detail[field] : '')
  689 + v = v.replace(/[^0-9.]/g, '')
  690 + v = v.replace(/(\..*)\./g, '$1')
  691 + this.$set(this.detail, field, v)
  692 + },
  693 + onNonNegativeBlur(field, digits) {
  694 + var raw = this.detail[field]
  695 + if (raw === '' || raw === null || raw === undefined) {
  696 + this.$set(this.detail, field, '')
  697 + return
  698 + }
  699 + var val = parseFloat(raw)
  700 + if (isNaN(val)) val = 0
  701 + var m = Math.pow(10, digits)
  702 + var rounded = Math.round(val * m) / m
  703 + this.$set(this.detail, field, rounded)
  704 + },
  705 + openDeliverySheet() {
  706 + var cur = this.detail.deliveryMode != null ? this.detail.deliveryMode : ''
  707 + var match = this.deliveryOptions.find(function (o) { return String(o.value) === String(cur) })
  708 + this.deliverySheetValue = match ? match.value : ''
  709 + this.deliverySheetVisible = true
  710 + },
  711 + onDeliveryConfirm(e) {
  712 + this.$set(this.detail, 'deliveryMode', e.value != null ? e.value : '')
  713 + },
  714 + isTagSelected(field, code) {
  715 + var selected = this.detail ? this.detail[field] : undefined
  716 + if (Array.isArray(selected)) return selected.indexOf(code) >= 0
  717 + if (typeof selected === 'string' && selected) {
  718 + return selected.split(',').indexOf(code) >= 0
  719 + }
  720 + return false
  721 + },
  722 + toggleTag(field, code) {
  723 + var selected = this.detail[field]
  724 + var arr = Array.isArray(selected) ? selected.slice() : []
  725 + var idx = arr.indexOf(code)
  726 + if (idx >= 0) {
  727 + arr.splice(idx, 1)
  728 + } else {
  729 + arr.push(code)
  730 + }
  731 + this.$set(this.detail, field, arr)
  732 + },
  733 + validateForm() {
  734 + if (!this.form.planId) {
  735 + uni.showToast({ title: '请选择计划', icon: 'none' })
  736 + return false
  737 + }
  738 + var d = this.detail || {}
  739 + var textChecks = [
  740 + { key: 'supplierName', title: '供应商名称' },
  741 + { key: 'validityPeriod', title: '报价时效' },
  742 + { key: 'quoterName', title: '报价人' },
  743 + { key: 'deliveryMode', title: '交提货方式' },
  744 + { key: 'loadingFee', title: '装车费' },
  745 + { key: 'invoiceProductName', title: '开票品名' },
  746 + { key: 'deliveryDate', title: '交货日期' },
  747 + { key: 'settlementMethod', title: '结算方式' },
  748 + { key: 'settlementRatio', title: '结算比例' },
  749 + { key: 'coordinationReason', title: '协调事由' },
  750 + { key: 'invoiceTypeStatus', title: '票类状况' },
  751 + { key: 'changeReason', title: '变更事由' }
  752 + ]
  753 + for (var i = 0; i < textChecks.length; i++) {
  754 + var tc = textChecks[i]
  755 + var tv = d[tc.key]
  756 + if (tv === '' || tv === null || tv === undefined) {
  757 + uni.showToast({ title: '请填写' + tc.title, icon: 'none' })
  758 + return false
  759 + }
  760 + }
  761 + var boolChecks = [
  762 + { key: 'longTermOperation', title: '是否长单操作' },
  763 + { key: 'terminalCustomer', title: '是否终端客户' },
  764 + { key: 'priced', title: '是否未点价' },
  765 + { key: 'otherExpenseSettlement', title: '其他费用凭票到厂另行结算' },
  766 + { key: 'commodityBuyout', title: '是否通货买断' },
  767 + { key: 'qualityBuyout', title: '是否质量买断' },
  768 + { key: 'quantityBuyout', title: '是否数量买断' },
  769 + { key: 'doorDelivery', title: '是否送货上门' }
  770 + ]
  771 + if (d.priced === true) {
  772 + boolChecks.push({ key: 'temporaryPrice', title: '是否暂定价' })
  773 + var pd = d.pricingDeadline
  774 + if (pd === '' || pd === null || pd === undefined) {
  775 + uni.showToast({ title: '请选择点价截止日期', icon: 'none' })
  776 + return false
  777 + }
  778 + }
  779 + for (var j = 0; j < boolChecks.length; j++) {
  780 + var bc = boolChecks[j]
  781 + if (typeof d[bc.key] !== 'boolean') {
  782 + uni.showToast({ title: '请选择' + bc.title, icon: 'none' })
  783 + return false
  784 + }
  785 + }
  786 + var pr = this.$refs.productRel
  787 + if (pr && typeof pr.validate === 'function') {
  788 + if (!pr.validate()) return false
  789 + }
  790 + return true
  791 + },
  792 + onBack() {
  793 + uni.navigateBack({ delta: 1 })
  794 + },
  795 + joinStr(arr) {
  796 + if (Array.isArray(arr)) return arr.filter(Boolean).join(',')
  797 + if (typeof arr === 'string') return arr
  798 + return ''
  799 + },
  800 + pickId(v) {
  801 + if (v == null || v === '') return ''
  802 + if (typeof v === 'string' || typeof v === 'number') return String(v)
  803 + if (typeof v === 'object') {
  804 + return String(v.id != null ? v.id : (v.value != null ? v.value : (v.code != null ? v.code : '')))
  805 + }
  806 + return String(v)
  807 + },
  808 + boolToStr(v) {
  809 + return v === true ? 'true' : 'false'
  810 + },
  811 + buildPayload() {
  812 + var self = this
  813 + var d = this.detail || {}
  814 + var lines = Array.isArray(this.lineList) ? this.lineList.slice() : []
  815 + var workshopId = d.workshopId != null ? d.workshopId : ''
  816 + var lineList = lines.map(function (row, i) {
  817 + var r = row || {}
  818 + var itemId = r.itemId != null ? r.itemId : (r.id != null ? String(r.id) : (r._key != null ? r._key : ('line-' + Date.now() + '-' + i)))
  819 + if (!workshopId && r.workshopId != null) workshopId = r.workshopId
  820 + return {
  821 + productId: self.pickId(r.productId),
  822 + materialType: r.materialType != null ? String(r.materialType) : '',
  823 + quantity: r.quantity != null ? String(r.quantity) : '',
  824 + actualPurchasePrice: r.actualPurchasePrice != null ? String(r.actualPurchasePrice) : '',
  825 + includingShippingPrice: r.includingShippingPrice != null ? String(r.includingShippingPrice) : '',
  826 + priceListPrices: r.priceListPrices != null ? String(r.priceListPrices) : '',
  827 + coordinationRange: r.coordinationRange != null ? String(r.coordinationRange) : '',
  828 + estimatedLoss: r.estimatedLoss != null ? String(r.estimatedLoss) : '',
  829 + applicationAttrition: r.applicationAttrition != null ? String(r.applicationAttrition) : '',
  830 + paintDamageRatio: r.paintDamageRatio != null ? String(r.paintDamageRatio) : '',
  831 + workshopId: self.pickId(r.workshopId),
  832 + itemId: itemId
  833 + }
  834 + })
  835 + var body = {
  836 + id: this.id || d.id || '',
  837 + procurementPlanId: this.form.planId || d.id || '',
  838 + changeReason: d.changeReason != null ? String(d.changeReason) : '',
  839 + code: d.code != null ? String(d.code) : '',
  840 + companyShortId: this.pickId(d.companyShortId || d.companyId),
  841 + supplierId: this.pickId(d.supplierId),
  842 + purchaseDepartment: this.pickId(d.purchaseDepartment),
  843 + region: this.pickId(d.region),
  844 + date: d.date != null ? String(d.date).slice(0, 10) : '',
  845 + validityPeriod: d.validityPeriod != null ? String(d.validityPeriod) : '',
  846 + quoterId: this.pickId(d.quoterId),
  847 + workshopId: this.pickId(workshopId),
  848 + quoterName: d.quoterName != null ? String(d.quoterName) : '',
  849 + longTermOperation: this.boolToStr(d.longTermOperation),
  850 + terminalCustomer: this.boolToStr(d.terminalCustomer),
  851 + priced: this.boolToStr(d.priced),
  852 + pricingDeadline: d.pricingDeadline != null ? String(d.pricingDeadline) : '',
  853 + temporaryPrice: this.boolToStr(d.temporaryPrice),
  854 + otherExpenseSettlement: this.boolToStr(d.otherExpenseSettlement),
  855 + deliveryMode: d.deliveryMode != null ? String(d.deliveryMode) : '',
  856 + commodityBuyout: this.boolToStr(d.commodityBuyout),
  857 + qualityBuyout: this.boolToStr(d.qualityBuyout),
  858 + quantityBuyout: this.boolToStr(d.quantityBuyout),
  859 + doorDelivery: this.boolToStr(d.doorDelivery),
  860 + shippingCost: d.shippingCost != null ? String(d.shippingCost) : '',
  861 + loadingFee: d.loadingFee != null ? String(d.loadingFee) : '',
  862 + invoiceProductName: d.invoiceProductName != null ? String(d.invoiceProductName) : '',
  863 + deliveryDate: d.deliveryDate != null ? String(d.deliveryDate) : '',
  864 + settlementMethod: d.settlementMethod != null ? String(d.settlementMethod) : '',
  865 + settlementRatio: d.settlementRatio != null ? String(d.settlementRatio) : '',
  866 + priceId: this.pickId(d.priceId),
  867 + coordinationReason: d.coordinationReason != null ? String(d.coordinationReason) : '',
  868 + invoiceTypeStatus: d.invoiceTypeStatus != null ? String(d.invoiceTypeStatus) : '',
  869 + totalQuantity: d.totalQuantity != null ? String(d.totalQuantity) : '',
  870 + remark: d.remark != null ? String(d.remark) : '',
  871 + materialConditionEnabled: this.boolToStr(d.materialConditionEnabled),
  872 + lines: lineList
  873 + }
  874 + this.materialConditionConfigs.forEach(function (mc) {
  875 + body[mc.field] = self.joinStr(d[mc.field])
  876 + })
  877 + return body
  878 + },
  879 + async onSubmit() {
  880 + if (!this.validateForm()) return
  881 + var payload = this.buildPayload()
  882 + try {
  883 + await procurementPlanReplenishUpdateApi(payload)
  884 + uni.showToast({ title: '保存成功', icon: 'none' })
  885 + try {
  886 + uni.setStorageSync('SCHEDULE_PLAN_LIST_NEED_REFRESH', '1')
  887 + } catch (e) {}
  888 + var self = this
  889 + setTimeout(function () {
  890 + uni.navigateTo({ url: '/pages/schedule-plan/index' })
  891 + }, 400)
  892 + } catch (e) {
  893 + uni.showToast({ title: (e && (e.msg || e.message)) ? (e.msg || e.message) : '保存失败', icon: 'none' })
  894 + }
  895 + }
  896 + }
  897 +}
  898 +</script>
  899 +
  900 +<style lang="scss" scoped>
  901 +.page {
  902 + display: flex;
  903 + flex-direction: column;
  904 + height: 100%;
  905 +}
  906 +.scroll {
  907 + flex: 1;
  908 + padding: 12rpx 0 392rpx !important;
  909 +}
  910 +.bottom-bar {
  911 + z-index: 2;
  912 + position: fixed;
  913 + left: 0;
  914 + right: 0;
  915 + bottom: 0;
  916 + padding: 32rpx;
  917 + padding-bottom: calc(32rpx + env(safe-area-inset-bottom));
  918 + background: #fff;
  919 + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06);
  920 + display: flex;
  921 + gap: 24rpx;
  922 + .btn {
  923 + flex: 1;
  924 + height: 80rpx;
  925 + line-height: 80rpx;
  926 + border-radius: 12rpx;
  927 + font-size: 32rpx;
  928 + }
  929 + .btn-outline {
  930 + background: #fff;
  931 + color: $theme-primary;
  932 + border: 2rpx solid $theme-primary;
  933 + }
  934 + .btn-primary {
  935 + background: $theme-primary;
  936 + color: #fff;
  937 + border: 2rpx solid $theme-primary;
  938 + }
  939 +}
  940 +
  941 +::v-deep .uni-list {
  942 + .uni-easyinput {
  943 + display: flex;
  944 + .uni-input-input {
  945 + color: rgba(0, 0, 0, 0.9);
  946 + }
  947 + }
  948 + .uni-input-placeholder { z-index: 1; }
  949 + .uni-input-input { background-color: #ffffff; }
  950 + background: transparent;
  951 + &-item {
  952 + &__extra-text { font-size: 32rpx; }
  953 + &__content-title {
  954 + font-size: 32rpx;
  955 + color: rgba(0, 0, 0, 0.9);
  956 + }
  957 + &__container {
  958 + padding: 32rpx;
  959 + .uni-easyinput {
  960 + &__placeholder-class {
  961 + font-size: 32rpx;
  962 + color: rgba(0, 0, 0, 0.4);
  963 + }
  964 + &__content {
  965 + border: none;
  966 + background-color: #ffffff !important;
  967 + &-input {
  968 + padding-left: 0 !important;
  969 + height: 48rpx;
  970 + line-height: 48rpx;
  971 + font-size: 32rpx;
  972 + }
  973 + .content-clear-icon {
  974 + font-size: 44rpx !important;
  975 + }
  976 + }
  977 + }
  978 + .item-title,
  979 + .uni-list-item__content {
  980 + flex: none;
  981 + min-height: 48rpx;
  982 + line-height: 48rpx;
  983 + font-size: 32rpx;
  984 + position: relative;
  985 + width: 240rpx;
  986 + margin-right: 32rpx;
  987 + color: rgba(0, 0, 0, 0.9);
  988 + .required {
  989 + color: red;
  990 + position: absolute;
  991 + top: 50%;
  992 + transform: translateY(-50%);
  993 + left: -16rpx;
  994 + }
  995 + }
  996 + }
  997 + &.select-item {
  998 + &.is-empty {
  999 + .uni-list-item__extra-text {
  1000 + color: rgba(0, 0, 0, 0.4) !important;
  1001 + }
  1002 + }
  1003 + &.is-filled {
  1004 + .uni-list-item__extra-text {
  1005 + color: rgba(0, 0, 0, 0.9) !important;
  1006 + }
  1007 + }
  1008 + .serial-number-row {
  1009 + display: flex;
  1010 + align-items: center;
  1011 + }
  1012 + }
  1013 + }
  1014 +}
  1015 +
  1016 +.readonly-text {
  1017 + color: rgba(0, 0, 0, 0.9);
  1018 + font-size: 32rpx;
  1019 + line-height: 48rpx;
  1020 + text-align: right;
  1021 + white-space: pre-wrap;
  1022 + word-break: break-all;
  1023 +}
  1024 +.value-code {
  1025 + width: 260rpx;
  1026 + text-align: left;
  1027 +}
  1028 +
  1029 +.attach-list {
  1030 + flex: 1;
  1031 + display: flex;
  1032 + flex-direction: column;
  1033 + align-items: flex-end;
  1034 + gap: 8rpx;
  1035 +}
  1036 +.attach-item {
  1037 + display: flex;
  1038 + align-items: center;
  1039 + gap: 16rpx;
  1040 + .attach-name { font-size: 26rpx; color: rgba(0,0,0,0.9); }
  1041 + .attach-view { font-size: 26rpx; color: $theme-primary; }
  1042 +}
  1043 +
  1044 +.material-condition-section,
  1045 +.remark-section {
  1046 + margin-top: 20rpx;
  1047 + background: #fff;
  1048 +}
  1049 +.section-header {
  1050 + display: flex;
  1051 + align-items: center;
  1052 + padding: 24rpx 32rpx;
  1053 + border-bottom: 1rpx solid #f0f0f0;
  1054 +}
  1055 +.section-title {
  1056 + position: relative;
  1057 + font-size: 32rpx;
  1058 + color: rgba(0, 0, 0, 0.9);
  1059 + font-weight: 600;
  1060 + .required {
  1061 + color: red;
  1062 + position: absolute;
  1063 + top: 50%;
  1064 + transform: translateY(-50%);
  1065 + left: -16rpx;
  1066 + }
  1067 +}
  1068 +.opCollapse {
  1069 + width: 32rpx;
  1070 + height: 28rpx;
  1071 + margin-right: 16rpx;
  1072 + margin-top: 8rpx;
  1073 +}
  1074 +.section-content {
  1075 + padding: 32rpx;
  1076 +}
  1077 +.form-row {
  1078 + display: flex;
  1079 + align-items: center;
  1080 + justify-content: space-between;
  1081 + margin-bottom: 24rpx;
  1082 +}
  1083 +.form-row:last-child { margin-bottom: 0; }
  1084 +.form-label {
  1085 + font-size: 32rpx;
  1086 + color: rgba(0, 0, 0, 0.9);
  1087 +}
  1088 +.form-value {
  1089 + font-size: 32rpx;
  1090 + color: rgba(0, 0, 0, 0.9);
  1091 +}
  1092 +.toggle-link {
  1093 + color: $theme-primary;
  1094 +}
  1095 +.material-group {
  1096 + margin-top: 32rpx;
  1097 +}
  1098 +.material-label {
  1099 + display: block;
  1100 + font-size: 30rpx;
  1101 + color: rgba(0, 0, 0, 0.9);
  1102 + margin-bottom: 20rpx;
  1103 +}
  1104 +.tag-list {
  1105 + display: flex;
  1106 + flex-wrap: wrap;
  1107 + gap: 16rpx;
  1108 +}
  1109 +.tag-btn {
  1110 + padding: 12rpx 24rpx;
  1111 + border: 1rpx solid #ddd;
  1112 + border-radius: 8rpx;
  1113 + font-size: 28rpx;
  1114 + color: #666;
  1115 + background: #fff;
  1116 +}
  1117 +.tag-btn.active {
  1118 + background: $theme-primary;
  1119 + border-color: $theme-primary;
  1120 + color: #fff;
  1121 +}
  1122 +
  1123 +::v-deep .uni-easyinput {
  1124 + width: 100%;
  1125 + &__content {
  1126 + background: #f8f8f8 !important;
  1127 + border-radius: 8rpx;
  1128 + &-input { font-size: 30rpx; }
  1129 + }
  1130 +}
  1131 +</style>
... ...
  1 +<template>
  2 + <view class="product-rel">
  3 + <view class="header">
  4 + <image class="opCollapse" src="/static/images/title.png" />
  5 + <text class="title">明细信息</text>
  6 + <view class="ops">
  7 + <image v-if="mode === 'add' || mode === 'edit'" class="opAdd" @click="onAdd" src="/static/images/plus.png" />
  8 + </view>
  9 + </view>
  10 +
  11 + <view class="add-list">
  12 + <view v-for="(item, idx) in items" :key="item._key || idx" class="block">
  13 + <uni-list v-show="!item.collapsed">
  14 + <uni-list-item
  15 + class="select-item"
  16 + :class="item.productName ? 'is-filled' : 'is-empty'"
  17 + clickable
  18 + @click="openSelectSheet('product', idx)"
  19 + :rightText="item.productName || '请选择品种'"
  20 + showArrow
  21 + >
  22 + <template v-slot:body>
  23 + <view class="item-title">
  24 + <text class="required">*</text><text>品种</text>
  25 + </view>
  26 + </template>
  27 + </uni-list-item>
  28 +
  29 + <uni-list-item>
  30 + <template v-slot:body>
  31 + <view class="item-title"><text>料型</text></view>
  32 + </template>
  33 + <template v-slot:footer>
  34 + <uni-easyinput v-model="item.materialType" :inputBorder="false" placeholder="请输入料型" />
  35 + </template>
  36 + </uni-list-item>
  37 +
  38 + <uni-list-item>
  39 + <template v-slot:body>
  40 + <view class="item-title">
  41 + <text class="required">*</text><text>数量(吨)</text>
  42 + </view>
  43 + </template>
  44 + <template v-slot:footer>
  45 + <uni-easyinput
  46 + v-model="item.quantity"
  47 + type="digit"
  48 + :inputBorder="false"
  49 + placeholder="请输入数量"
  50 + @input="onNonNegativeInput(idx, 'quantity')"
  51 + @blur="onNonNegativeBlur(idx, 'quantity', 1)"
  52 + @change="recalcAll(idx)"
  53 + />
  54 + </template>
  55 + </uni-list-item>
  56 +
  57 + <uni-list-item>
  58 + <template v-slot:body>
  59 + <view class="item-title">
  60 + <text class="required">*</text><text>实际采购价</text>
  61 + </view>
  62 + </template>
  63 + <template v-slot:footer>
  64 + <uni-easyinput
  65 + v-model="item.actualPurchasePrice"
  66 + type="digit"
  67 + :inputBorder="false"
  68 + placeholder="请输入实际采购价"
  69 + @input="onNonNegativeInput(idx, 'actualPurchasePrice')"
  70 + @blur="onNonNegativeBlur(idx, 'actualPurchasePrice', 2)"
  71 + @change="recalcAll(idx)"
  72 + />
  73 + </template>
  74 + </uni-list-item>
  75 +
  76 + <uni-list-item title="含运到厂价">
  77 + <template v-slot:footer>
  78 + <text class="lock-value">{{ formatTextNumber(item.includingShippingPrice) }}</text>
  79 + </template>
  80 + </uni-list-item>
  81 +
  82 + <uni-list-item title="价格表价格">
  83 + <template v-slot:footer>
  84 + <text class="lock-value">{{ formatTextNumber(item.priceListPrices) }}</text>
  85 + </template>
  86 + </uni-list-item>
  87 +
  88 + <uni-list-item title="买断料预计损耗">
  89 + <template v-slot:footer>
  90 + <text class="lock-value">{{ formatTextNumber(item.estimatedLoss) }}</text>
  91 + </template>
  92 + </uni-list-item>
  93 +
  94 + <uni-list-item>
  95 + <template v-slot:body>
  96 + <view class="item-title"><text>申请损耗(%)</text></view>
  97 + </template>
  98 + <template v-slot:footer>
  99 + <uni-easyinput
  100 + v-model="item.applicationAttrition"
  101 + type="digit"
  102 + :inputBorder="false"
  103 + placeholder="请输入申请损耗"
  104 + @input="onNonNegativeInput(idx, 'applicationAttrition')"
  105 + @blur="onNonNegativeBlur(idx, 'applicationAttrition', 2)"
  106 + @change="recalcAll(idx)"
  107 + />
  108 + </template>
  109 + </uni-list-item>
  110 +
  111 + <uni-list-item>
  112 + <template v-slot:body>
  113 + <view class="item-title"><text>漆损率(%)</text></view>
  114 + </template>
  115 + <template v-slot:footer>
  116 + <uni-easyinput
  117 + v-model="item.paintDamageRatio"
  118 + type="digit"
  119 + :inputBorder="false"
  120 + placeholder="请输入漆损率"
  121 + @input="onNonNegativeInput(idx, 'paintDamageRatio')"
  122 + @blur="onNonNegativeBlur(idx, 'paintDamageRatio', 2)"
  123 + />
  124 + </template>
  125 + </uni-list-item>
  126 +
  127 + <uni-list-item title="协调幅度">
  128 + <template v-slot:footer>
  129 + <text class="lock-value">{{ formatTextNumber(item.coordinationRange) }}</text>
  130 + </template>
  131 + </uni-list-item>
  132 +
  133 + <uni-list-item
  134 + class="select-item"
  135 + :class="item.workshopName ? 'is-filled' : 'is-empty'"
  136 + clickable
  137 + @click="openSelectSheet('workshop', idx)"
  138 + :rightText="item.workshopName || '请选择分厂'"
  139 + showArrow
  140 + >
  141 + <template v-slot:body>
  142 + <view class="item-title"><text>分厂</text></view>
  143 + </template>
  144 + </uni-list-item>
  145 + </uni-list>
  146 +
  147 + <uni-list v-show="item.collapsed">
  148 + <uni-list-item
  149 + class="select-item"
  150 + :class="item.productName ? 'is-filled' : 'is-empty'"
  151 + clickable
  152 + @click="openSelectSheet('product', idx)"
  153 + :rightText="item.productName || '请选择品种'"
  154 + showArrow
  155 + >
  156 + <template v-slot:body>
  157 + <view class="item-title">
  158 + <text class="required">*</text><text>品种</text>
  159 + </view>
  160 + </template>
  161 + </uni-list-item>
  162 + </uni-list>
  163 +
  164 + <view class="block-ops">
  165 + <div class="del" @click="onRemove(idx)">
  166 + <image src="/static/images/delete.png" class="icon" />
  167 + 删除
  168 + </div>
  169 + <div class="toggle" @click="toggleItem(idx)">
  170 + <image :src="item.collapsed ? '/static/images/up.png' : '/static/images/down.png'" class="icon" />
  171 + {{ item.collapsed ? '展开' : '收起' }}
  172 + </div>
  173 + </view>
  174 + </view>
  175 + </view>
  176 +
  177 + <SingleSelectSheet
  178 + :visible.sync="sheet.visible"
  179 + :title="sheet.title"
  180 + :options="sheet.options"
  181 + v-model="sheet.value"
  182 + @confirm="onSheetConfirm"
  183 + />
  184 + </view>
  185 +</template>
  186 +
  187 +<script>
  188 +import SingleSelectSheet from '@/components/single-select/index.vue'
  189 +
  190 +export default {
  191 + name: 'SchedulePlanProductRel',
  192 + components: { SingleSelectSheet },
  193 + props: {
  194 + mode: { type: String, default: 'edit' },
  195 + list: { type: Array, default: function () { return [] } },
  196 + max: { type: Number, default: 50 },
  197 + productOptions: { type: Array, default: function () { return [] } },
  198 + workshopOptions: { type: Array, default: function () { return [] } },
  199 + shippingCost: { type: [String, Number], default: '' },
  200 + priceMap: { type: Object, default: function () { return {} } }
  201 + },
  202 + data() {
  203 + return {
  204 + items: [],
  205 + sheet: { visible: false, title: '请选择', options: [], value: '', idx: -1, type: '' },
  206 + _initialized: false,
  207 + _emitSuppressed: false,
  208 + _lastEmitSignature: ''
  209 + }
  210 + },
  211 + computed: {
  212 + productOptsComputed() {
  213 + var list = Array.isArray(this.productOptions) ? this.productOptions : []
  214 + return list.map(function (o) {
  215 + return {
  216 + label: o.label != null ? o.label : (o.name != null ? o.name : (o.productName || '')),
  217 + value: o.value != null ? o.value : (o.id != null ? o.id : o.productId)
  218 + }
  219 + })
  220 + },
  221 + workshopOptsComputed() {
  222 + var list = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  223 + return list.map(function (o) {
  224 + return {
  225 + label: o.label != null ? o.label : (o.name != null ? o.name : (o.workshopName || '')),
  226 + value: o.value != null ? o.value : (o.id != null ? o.id : o.workshopId)
  227 + }
  228 + })
  229 + },
  230 + shippingCostNum() {
  231 + var v = this.shippingCost
  232 + if (v == null || v === '') return 0
  233 + var n = Number(v)
  234 + return isNaN(n) ? 0 : n
  235 + }
  236 + },
  237 + watch: {
  238 + items: {
  239 + handler() {
  240 + this.emitChange()
  241 + },
  242 + deep: true
  243 + },
  244 + list: {
  245 + handler(newList) {
  246 + if (this._emitSuppressed) return
  247 + if (this.isListSameAsItems(newList)) return
  248 + this._emitSuppressed = true
  249 + this._initialized = false
  250 + this.initItems()
  251 + var self = this
  252 + this.$nextTick(function () {
  253 + self._initialized = true
  254 + self.recalcAllItems()
  255 + self.$nextTick(function () {
  256 + self._emitSuppressed = false
  257 + })
  258 + })
  259 + },
  260 + immediate: false
  261 + }
  262 + },
  263 + created() {
  264 + this._emitSuppressed = true
  265 + this.initItems()
  266 + var self = this
  267 + this.$nextTick(function () {
  268 + self._initialized = true
  269 + self.recalcAllItems()
  270 + self.$nextTick(function () {
  271 + self._emitSuppressed = false
  272 + })
  273 + })
  274 + },
  275 + methods: {
  276 + initItems() {
  277 + var src = Array.isArray(this.list) && this.list.length > 0 ? this.list : []
  278 + if (!src.length) {
  279 + if (this.mode === 'add' || this.mode === 'edit') {
  280 + this.items = [Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false })]
  281 + } else {
  282 + this.items = []
  283 + }
  284 + return
  285 + }
  286 + var existing = this.items || []
  287 + var existingMap = {}
  288 + existing.forEach(function (it) {
  289 + if (it.itemId) existingMap[it.itemId] = it
  290 + })
  291 + var self = this
  292 + this.items = src.map(function (x, i) {
  293 + var key = x && x.itemId ? x.itemId : (x && x._key ? x._key : self.newKey())
  294 + var old = existingMap[key]
  295 + var collapsed = old ? old.collapsed : (typeof x.collapsed === 'boolean' ? x.collapsed : false)
  296 + return Object.assign({}, self.defaultItem(), x, {
  297 + _key: key,
  298 + itemId: x && x.itemId ? x.itemId : key,
  299 + collapsed: collapsed
  300 + })
  301 + })
  302 + },
  303 + newKey() {
  304 + return Date.now() + '-' + Math.random().toString(16).slice(2)
  305 + },
  306 + defaultItem() {
  307 + return {
  308 + productId: '',
  309 + productName: '',
  310 + materialType: '',
  311 + quantity: '',
  312 + actualPurchasePrice: '',
  313 + includingShippingPrice: '',
  314 + priceListPrices: '',
  315 + coordinationRange: '',
  316 + estimatedLoss: '',
  317 + applicationAttrition: '',
  318 + paintDamageRatio: '',
  319 + workshopId: '',
  320 + workshopName: '',
  321 + fixedLossRate: ''
  322 + }
  323 + },
  324 + onNonNegativeInput(idx, field) {
  325 + var it = this.items[idx]
  326 + if (!it) return
  327 + var v = String(it[field] != null ? it[field] : '')
  328 + v = v.replace(/[^0-9.]/g, '')
  329 + v = v.replace(/(\..*)\./g, '$1')
  330 + it[field] = v
  331 + this.$set(this.items, idx, it)
  332 + },
  333 + onNonNegativeBlur(idx, field, digits) {
  334 + var it = this.items[idx]
  335 + if (!it) return
  336 + var raw = it[field]
  337 + if (raw === '' || raw === null || raw === undefined) {
  338 + this.$set(this.items, idx, it)
  339 + return
  340 + }
  341 + var val = parseFloat(raw)
  342 + if (isNaN(val)) val = 0
  343 + var m = Math.pow(10, digits)
  344 + var rounded = Math.round(val * m) / m
  345 + it[field] = rounded
  346 + this.$set(this.items, idx, it)
  347 + },
  348 + getProductOption(productId) {
  349 + var pid = productId != null ? String(productId) : ''
  350 + if (!pid) return null
  351 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  352 + for (var i = 0; i < pOpts.length; i++) {
  353 + var o = pOpts[i]
  354 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  355 + if (id === pid) return o
  356 + }
  357 + return null
  358 + },
  359 + getPriceFromMap(productId, productName) {
  360 + var pid = productId != null ? String(productId) : ''
  361 + var pname = (productName || '').trim()
  362 + var map = this.priceMap || {}
  363 + if (pid && map[pid] != null) {
  364 + var v = map[pid]
  365 + if (typeof v === 'object' && v != null) {
  366 + return v.price != null ? Number(v.price) : null
  367 + }
  368 + return Number(v)
  369 + }
  370 + if (pname) {
  371 + for (var k in map) {
  372 + if (!Object.prototype.hasOwnProperty.call(map, k)) continue
  373 + var meta = map[k]
  374 + if (meta && typeof meta === 'object' && meta.meta) {
  375 + var mm = meta.meta
  376 + if ((mm.productName && mm.productName === pname) || (mm.breedName && mm.breedName === pname) || (mm.varietyName && mm.varietyName === pname)) {
  377 + return meta.price != null ? Number(meta.price) : null
  378 + }
  379 + }
  380 + }
  381 + }
  382 + return null
  383 + },
  384 + recalcAll(idx) {
  385 + var it = this.items[idx]
  386 + if (!it) return
  387 + var self = this
  388 +
  389 + var actualPriceRaw = it.actualPurchasePrice
  390 + var actualPrice = parseFloat(actualPriceRaw)
  391 + var actualPriceIsNumber = actualPriceRaw !== '' && actualPriceRaw != null && !isNaN(actualPrice)
  392 +
  393 + if (actualPriceIsNumber) {
  394 + it.includingShippingPrice = this.round2(actualPrice + this.shippingCostNum)
  395 + } else {
  396 + it.includingShippingPrice = ''
  397 + }
  398 +
  399 + var pid = it.productId
  400 + var pname = (it.productName || '').trim()
  401 + if (pid || pname) {
  402 + var priceFromMap = this.getPriceFromMap(pid, pname)
  403 + if (priceFromMap != null && !isNaN(priceFromMap)) {
  404 + it.priceListPrices = this.round2(priceFromMap)
  405 + }
  406 + } else {
  407 + it.priceListPrices = ''
  408 + }
  409 +
  410 + var estimatedLoss = ''
  411 + if (actualPriceIsNumber) {
  412 + var app = it.applicationAttrition
  413 + var appNum = parseFloat(app)
  414 + var appHasVal = app !== '' && app != null && !isNaN(appNum)
  415 + if (appHasVal) {
  416 + estimatedLoss = this.round2(actualPrice * appNum / 100)
  417 + } else {
  418 + var pOpt = this.getProductOption(it.productId)
  419 + var fixedRate = null
  420 + if (pOpt) {
  421 + fixedRate = pOpt.fixedLossRate != null ? pOpt.fixedLossRate : (pOpt.lossRate != null ? pOpt.lossRate : (pOpt.attritionRate != null ? pOpt.attritionRate : null))
  422 + }
  423 + var fixedNum = parseFloat(fixedRate)
  424 + if (!isNaN(fixedNum)) {
  425 + estimatedLoss = this.round2(actualPrice * fixedNum / 100)
  426 + }
  427 + }
  428 + }
  429 + it.estimatedLoss = estimatedLoss
  430 +
  431 + var incShip = parseFloat(it.includingShippingPrice)
  432 + var estLoss = parseFloat(it.estimatedLoss)
  433 + var priceList = parseFloat(it.priceListPrices)
  434 + var hasAll = !isNaN(incShip) && !isNaN(estLoss) && !isNaN(priceList)
  435 + if (hasAll) {
  436 + it.coordinationRange = this.round2(incShip + estLoss - priceList)
  437 + } else {
  438 + it.coordinationRange = ''
  439 + }
  440 +
  441 + this.$set(this.items, idx, it)
  442 + },
  443 + recalcAllItems() {
  444 + var len = (this.items || []).length
  445 + for (var i = 0; i < len; i++) {
  446 + this.recalcAll(i)
  447 + }
  448 + },
  449 + round2(v) {
  450 + var n = Number(v)
  451 + if (isNaN(n)) return ''
  452 + return Math.round(n * 100) / 100
  453 + },
  454 + onAdd() {
  455 + if (this.items.length >= this.max) {
  456 + uni.showToast({ title: '最多' + this.max + '条明细', icon: 'none' })
  457 + return
  458 + }
  459 + this.items.push(Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false }))
  460 + },
  461 + onRemove(idx) {
  462 + this.items.splice(idx, 1)
  463 + if ((this.mode === 'add' || this.mode === 'edit') && this.items.length === 0) {
  464 + this.items.push(Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false }))
  465 + }
  466 + },
  467 + toggleItem(idx) {
  468 + var it = this.items[idx]
  469 + if (!it) return
  470 + this.$set(it, 'collapsed', !it.collapsed)
  471 + },
  472 + openSelectSheet(type, idx) {
  473 + if (type === 'product') {
  474 + var pOpts = this.productOptsComputed
  475 + var curP = this.items[idx] && this.items[idx].productId
  476 + var mP = pOpts.find(function (o) { return String(o.value) === String(curP) })
  477 + this.sheet = { visible: true, title: '请选择品种', options: pOpts, value: mP ? mP.value : '', idx: idx, type: type }
  478 + } else if (type === 'workshop') {
  479 + var wOpts = this.workshopOptsComputed
  480 + var curW = this.items[idx] && this.items[idx].workshopId
  481 + var mW = wOpts.find(function (o) { return String(o.value) === String(curW) })
  482 + this.sheet = { visible: true, title: '请选择分厂', options: wOpts, value: mW ? mW.value : '', idx: idx, type: type }
  483 + }
  484 + },
  485 + onSheetConfirm(_ref) {
  486 + var value = _ref.value
  487 + var label = _ref.label
  488 + var idx = this.sheet.idx
  489 + var type = this.sheet.type
  490 + if (idx < 0 || !this.items[idx]) return
  491 + var it = this.items[idx]
  492 + if (type === 'product') {
  493 + this.$set(it, 'productId', value)
  494 + this.$set(it, 'productName', label)
  495 + var pOpt = this.getProductOption(value)
  496 + if (pOpt) {
  497 + var rate = pOpt.fixedLossRate != null ? pOpt.fixedLossRate : (pOpt.lossRate != null ? pOpt.lossRate : (pOpt.attritionRate != null ? pOpt.attritionRate : ''))
  498 + this.$set(it, 'fixedLossRate', rate != null ? rate : '')
  499 + }
  500 + this.recalcAll(idx)
  501 + } else if (type === 'workshop') {
  502 + this.$set(it, 'workshopId', value)
  503 + this.$set(it, 'workshopName', label)
  504 + }
  505 + },
  506 + fillLineNames() {
  507 + if (!Array.isArray(this.items) || !this.items.length) return
  508 + var pOpts = Array.isArray(this.productOptions) ? this.productOptions : []
  509 + var wOpts = Array.isArray(this.workshopOptions) ? this.workshopOptions : []
  510 + var self = this
  511 + this.items = this.items.map(function (row) {
  512 + var r = Object.assign({}, row)
  513 + var pid = r.productId != null ? String(r.productId) : ''
  514 + var wid = r.workshopId != null ? String(r.workshopId) : ''
  515 + if ((r.productName == null || String(r.productName).trim() === '') && pid) {
  516 + var p = pOpts.find(function (o) {
  517 + var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
  518 + return id === pid
  519 + })
  520 + if (p) {
  521 + r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
  522 + }
  523 + }
  524 + if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) {
  525 + var w = wOpts.find(function (o) {
  526 + var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
  527 + return id === wid
  528 + })
  529 + if (w) {
  530 + r.workshopName = w.name != null ? w.name : (w.workshopName != null ? w.workshopName : (w.label != null ? w.label : ''))
  531 + }
  532 + }
  533 + return r
  534 + })
  535 + this.$nextTick(function () {
  536 + self.recalcAllItems()
  537 + self.emitChange()
  538 + })
  539 + },
  540 + emitChange() {
  541 + if (!this._initialized) return
  542 + if (this._emitSuppressed) return
  543 + var self = this
  544 + var list = (this.items || []).map(function (it) {
  545 + var c = Object.assign({}, it)
  546 + var key = c._key
  547 + delete c._key
  548 + delete c.collapsed
  549 + delete c._selected
  550 + delete c.fixedLossRate
  551 + if (!c.itemId) c.itemId = key
  552 + return c
  553 + })
  554 + var sig = list.length + '|' + list.map(function (r) {
  555 + return [r.itemId, r.productId, r.productName, r.materialType, r.quantity, r.actualPurchasePrice, r.includingShippingPrice, r.priceListPrices, r.coordinationRange, r.estimatedLoss, r.applicationAttrition, r.paintDamageRatio, r.workshopId, r.workshopName].join('~')
  556 + }).join('||')
  557 + if (sig === this._lastEmitSignature) return
  558 + this._lastEmitSignature = sig
  559 + this.$emit('change', list)
  560 + },
  561 + isListSameAsItems(newList) {
  562 + var a = Array.isArray(newList) ? newList : []
  563 + var b = (this.items || []).map(function (it) {
  564 + var c = Object.assign({}, it)
  565 + var key = c._key
  566 + delete c._key
  567 + delete c.collapsed
  568 + delete c._selected
  569 + delete c.fixedLossRate
  570 + if (!c.itemId) c.itemId = key
  571 + return c
  572 + })
  573 + if (a.length !== b.length) return false
  574 + for (var i = 0; i < a.length; i++) {
  575 + var x = a[i] || {}
  576 + var y = b[i] || {}
  577 + if ((x.itemId || '') !== (y.itemId || '')) return false
  578 + if (x.productId !== y.productId) return false
  579 + if (x.productName !== y.productName) return false
  580 + if (x.materialType !== y.materialType) return false
  581 + if (x.quantity !== y.quantity) return false
  582 + if (x.actualPurchasePrice !== y.actualPurchasePrice) return false
  583 + if (x.includingShippingPrice !== y.includingShippingPrice) return false
  584 + if (x.priceListPrices !== y.priceListPrices) return false
  585 + if (x.coordinationRange !== y.coordinationRange) return false
  586 + if (x.estimatedLoss !== y.estimatedLoss) return false
  587 + if (x.applicationAttrition !== y.applicationAttrition) return false
  588 + if (x.paintDamageRatio !== y.paintDamageRatio) return false
  589 + if (x.workshopId !== y.workshopId) return false
  590 + if (x.workshopName !== y.workshopName) return false
  591 + }
  592 + return true
  593 + },
  594 + safeText(v) {
  595 + var s = v == null ? '' : String(v)
  596 + return s.trim() ? s : '-'
  597 + },
  598 + formatTextNumber(v) {
  599 + if (v == null || v === '') return '-'
  600 + var n = Number(v)
  601 + if (isNaN(n)) return String(v)
  602 + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 })
  603 + },
  604 + validate() {
  605 + var items = this.items || []
  606 + if (!items.length) {
  607 + uni.showToast({ title: '请添加明细', icon: 'none' })
  608 + return false
  609 + }
  610 + for (var i = 0; i < items.length; i++) {
  611 + var it = items[i]
  612 + if (!it.productId && !it.productName) {
  613 + uni.showToast({ title: '请填写第' + (i + 1) + '条明细的品种', icon: 'none' })
  614 + return false
  615 + }
  616 + if (it.quantity === '' || it.quantity === null || it.quantity === undefined) {
  617 + uni.showToast({ title: '请填写第' + (i + 1) + '条明细的数量', icon: 'none' })
  618 + return false
  619 + }
  620 + if (it.actualPurchasePrice === '' || it.actualPurchasePrice === null || it.actualPurchasePrice === undefined) {
  621 + uni.showToast({ title: '请填写第' + (i + 1) + '条明细的实际采购价', icon: 'none' })
  622 + return false
  623 + }
  624 + }
  625 + return true
  626 + },
  627 + clearItems() {
  628 + this._emitSuppressed = true
  629 + this._initialized = false
  630 + this.items = [Object.assign({}, this.defaultItem(), { _key: this.newKey(), collapsed: false })]
  631 + var self = this
  632 + this.$nextTick(function () {
  633 + self._initialized = true
  634 + self.recalcAllItems()
  635 + self.$nextTick(function () {
  636 + self._emitSuppressed = false
  637 + })
  638 + })
  639 + }
  640 + }
  641 +}
  642 +</script>
  643 +
  644 +<style lang="scss" scoped>
  645 +.product-rel {
  646 + margin-top: 20rpx;
  647 + background: #fff;
  648 +}
  649 +.header {
  650 + display: flex;
  651 + align-items: center;
  652 + padding: 24rpx 32rpx;
  653 + border-bottom: 1rpx solid #f0f0f0;
  654 +}
  655 +.title {
  656 + font-size: 32rpx;
  657 + color: rgba(0, 0, 0, 0.9);
  658 + font-weight: 600;
  659 +}
  660 +.ops {
  661 + margin-left: auto;
  662 +}
  663 +.opAdd {
  664 + color: rgba(0, 0, 0, 0.6);
  665 + width: 40rpx;
  666 + height: 40rpx;
  667 +}
  668 +.opCollapse {
  669 + color: rgba(0, 0, 0, 0.6);
  670 + width: 32rpx;
  671 + height: 28rpx;
  672 + margin-right: 16rpx;
  673 + margin-top: 8rpx;
  674 +}
  675 +.block {
  676 + background: #fff;
  677 + margin-bottom: 20rpx;
  678 +}
  679 +::v-deep .uni-list-item__content {
  680 + display: flex;
  681 + justify-content: center;
  682 +}
  683 +::v-deep .uni-list {
  684 + .uni-easyinput {
  685 + display: flex;
  686 + .uni-input-input {
  687 + color: rgba(0, 0, 0, 0.9);
  688 + }
  689 + }
  690 + .uni-input-placeholder { z-index: 1; }
  691 + .uni-input-input { background-color: #ffffff; }
  692 + background: transparent;
  693 + &-item {
  694 + &__container { padding: 32rpx; }
  695 + &__content-title {
  696 + font-size: 28rpx;
  697 + color: rgba(0, 0, 0, 0.9);
  698 + }
  699 + &__extra-text { font-size: 32rpx; }
  700 + .uni-easyinput {
  701 + width: 100%;
  702 + &__placeholder-class {
  703 + font-size: 32rpx;
  704 + color: rgba(0, 0, 0, 0.4);
  705 + }
  706 + &__content {
  707 + border: none;
  708 + background-color: #ffffff !important;
  709 + display: flex;
  710 + &-input {
  711 + padding-left: 0 !important;
  712 + height: 48rpx;
  713 + line-height: 48rpx;
  714 + font-size: 32rpx;
  715 + }
  716 + }
  717 + }
  718 + &.select-item {
  719 + &.is-empty {
  720 + .uni-list-item__extra-text { color: rgba(0, 0, 0, 0.4) !important; }
  721 + }
  722 + &.is-filled {
  723 + .uni-list-item__extra-text { color: rgba(0, 0, 0, 0.9) !important; }
  724 + }
  725 + }
  726 + }
  727 +}
  728 +
  729 +::v-deep .uni-easyinput {
  730 + width: 100%;
  731 + &__content {
  732 + background: #f8f8f8 !important;
  733 + border-radius: 8rpx;
  734 + &-input { font-size: 30rpx; }
  735 + }
  736 +}
  737 +.block-ops {
  738 + display: flex;
  739 + padding: 20rpx 32rpx 20rpx;
  740 + justify-content: space-around;
  741 +}
  742 +.del {
  743 + color: #D54941;
  744 + font-size: 28rpx;
  745 + display: flex;
  746 + align-items: center;
  747 + image { width: 40rpx; height: 40rpx; }
  748 +}
  749 +.toggle {
  750 + color: $theme-primary;
  751 + font-size: 28rpx;
  752 + display: flex;
  753 + align-items: center;
  754 + image { width: 40rpx; height: 40rpx; }
  755 +}
  756 +.item-title {
  757 + position: relative;
  758 + width: 210rpx;
  759 + margin-right: 32rpx;
  760 + color: rgba(0, 0, 0, 0.9);
  761 + font-size: 32rpx;
  762 + min-height: 48rpx;
  763 + line-height: 48rpx;
  764 + .required {
  765 + color: red;
  766 + position: absolute;
  767 + top: 50%;
  768 + transform: translateY(-50%);
  769 + left: -16rpx;
  770 + }
  771 +}
  772 +.lock-value {
  773 + flex: 1;
  774 + text-align: right;
  775 + font-size: 32rpx;
  776 + color: rgba(0, 0, 0, 0.85);
  777 + padding: 8rpx 0;
  778 +}
  779 +</style>
... ...
... ... @@ -2,6 +2,7 @@ import CustomerDevelopViewer from '@/pages/dev_manage/viewer.vue'
2 2 import CustomerCreditViewer from '@/pages/credit_manage/viewer.vue'
3 3 import DomesticCustomerCreditViewer from '@/pages/domestic_trade/domesticCreditViewer.vue'
4 4 import SalesmanQuotationViewer from '@/pages/sales-price/salesmanQuotationViewer.vue'
  5 +import SchedulePlanChangeViewer from '@/pages/schedule-plan/schedulePlanChangeViewer.vue'
5 6 import ForeignTradeCreditViewer from '@/pages/foreign_trade/foreignTradeCreditViewer.vue'
6 7 import RetailViewer from '@/pages/contract_retail/retailViewer.vue'
7 8 import ForeignStdViewer from '@/pages/contract_foreign_std/foreignStdViewer.vue'
... ... @@ -31,6 +32,7 @@ export default function registerComponents(Vue) {
31 32 Vue.component('CustomerCreditViewer', CustomerCreditViewer)
32 33 Vue.component('DomesticCustomerCreditViewer', DomesticCustomerCreditViewer)
33 34 Vue.component('SalesmanQuotationViewer', SalesmanQuotationViewer)
  35 + Vue.component('SchedulePlanChangeViewer', SchedulePlanChangeViewer)
34 36 Vue.component('ForeignTradeCreditViewer', ForeignTradeCreditViewer)
35 37 Vue.component('RetailViewer', RetailViewer)
36 38 Vue.component('StandardContractViewer', StandardContractViewer)
... ...
... ... @@ -26,6 +26,12 @@ export const getSysFlowComponentPath = (bizFlag) => {
26 26 case 'SALESMAN_QUOTATION_EDIT': // 业务员报价单
27 27 componentPath = 'SalesmanQuotationViewer'; // 业务员报价单-审批
28 28 break;
  29 + case 'PLAN_CHANGE': // 采购计划变更单
  30 + componentPath = 'SchedulePlanChangeViewer'; // 采购计划变更单-审批详情
  31 + break;
  32 + case 'PLAN_CHANGE_EDIT': // 采购计划变更单
  33 + componentPath = 'SchedulePlanChangeViewer'; // 采购计划变更单-审批
  34 + break;
29 35 case 'CUSTOMER_CREDIT_OUT': // 客户资信(外贸)
30 36 componentPath = 'ForeignTradeCreditViewer'; // 客户资信(外贸)-审批详情
31 37 break;
... ...