Showing
20 changed files
with
5139 additions
and
17 deletions
api/procure-manage/assayApply.js
0 → 100644
| 1 | +import request from '@/utils/request' | |
| 2 | +import { ContentTypeEnum } from '@/utils/httpEnum' | |
| 3 | + | |
| 4 | +// 化验送样单(对齐 PC 端 api/warehouse-manage/sample-submission) | |
| 5 | +const baseUrl = '/procurement/assay/apply' | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 生成送样单编号(直接返回编号字符串) | |
| 9 | + */ | |
| 10 | +export function assayApplyGenerateCodeApi() { | |
| 11 | + return request({ | |
| 12 | + url: baseUrl + '/generateCode', | |
| 13 | + method: 'get' | |
| 14 | + }) | |
| 15 | +} | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * 分页查询化验送样单列表 | |
| 19 | + * params: pageIndex, pageSize, weighingTicketCode, productName, | |
| 20 | + * planCode, approvalStatus, createBy, deleted(boolean) | |
| 21 | + */ | |
| 22 | +export function assayApplyQueryApi(params) { | |
| 23 | + return request({ | |
| 24 | + url: baseUrl + '/query', | |
| 25 | + method: 'get', | |
| 26 | + params | |
| 27 | + }) | |
| 28 | +} | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * 分页查询可选过磅码单列表(码单编号选择) | |
| 32 | + * params: pageIndex, pageSize, code, workshopId | |
| 33 | + */ | |
| 34 | +export function assayApplyTicketPageApi(params) { | |
| 35 | + return request({ | |
| 36 | + url: baseUrl + '/ticketPage', | |
| 37 | + method: 'get', | |
| 38 | + params | |
| 39 | + }) | |
| 40 | +} | |
| 41 | + | |
| 42 | +/** | |
| 43 | + * 根据过磅码单ID查询码单数据(含计划编号下拉选项 planOptions) | |
| 44 | + */ | |
| 45 | +export function assayApplyTicketDataApi(ticketId) { | |
| 46 | + return request({ | |
| 47 | + url: baseUrl + '/ticketData', | |
| 48 | + method: 'get', | |
| 49 | + params: { ticketId } | |
| 50 | + }) | |
| 51 | +} | |
| 52 | + | |
| 53 | +/** | |
| 54 | + * 根据过磅码单与采购计划查询过磅品种下拉选项 | |
| 55 | + * params: { ticketId(可选), planId } | |
| 56 | + */ | |
| 57 | +export function assayApplyBreedOptionsApi(params) { | |
| 58 | + return request({ | |
| 59 | + url: baseUrl + '/breedOptions', | |
| 60 | + method: 'get', | |
| 61 | + params | |
| 62 | + }) | |
| 63 | +} | |
| 64 | + | |
| 65 | +/** | |
| 66 | + * 新增化验送样单 | |
| 67 | + * data: { weighingTicketId, procurementPlanId, productId, department } | |
| 68 | + */ | |
| 69 | +export function assayApplyCreateApi(data) { | |
| 70 | + return request({ | |
| 71 | + url: baseUrl, | |
| 72 | + method: 'post', | |
| 73 | + data, | |
| 74 | + contentType: ContentTypeEnum.JSON | |
| 75 | + }) | |
| 76 | +} | |
| 77 | + | |
| 78 | +/** | |
| 79 | + * 查询化验送样单详情 | |
| 80 | + */ | |
| 81 | +export function assayApplyDetailApi(params) { | |
| 82 | + return request({ | |
| 83 | + url: baseUrl, | |
| 84 | + method: 'get', | |
| 85 | + params | |
| 86 | + }) | |
| 87 | +} | |
| 88 | + | |
| 89 | +/** | |
| 90 | + * 修改化验送样单 | |
| 91 | + * data: { id, weighingTicketId, procurementPlanId, productId, department } | |
| 92 | + */ | |
| 93 | +export function assayApplyUpdateApi(data) { | |
| 94 | + return request({ | |
| 95 | + url: baseUrl, | |
| 96 | + method: 'put', | |
| 97 | + data, | |
| 98 | + contentType: ContentTypeEnum.JSON | |
| 99 | + }) | |
| 100 | +} | |
| 101 | + | |
| 102 | +/** | |
| 103 | + * 提交审核 | |
| 104 | + */ | |
| 105 | +export function assayApplySubmitApi(id) { | |
| 106 | + return request({ | |
| 107 | + url: baseUrl + '/submit?id=' + id, | |
| 108 | + method: 'put' | |
| 109 | + }) | |
| 110 | +} | |
| 111 | + | |
| 112 | +/** | |
| 113 | + * 取消化验送样单 | |
| 114 | + */ | |
| 115 | +export function assayApplyCancelApi(id) { | |
| 116 | + return request({ | |
| 117 | + url: baseUrl + '/cancel?id=' + id, | |
| 118 | + method: 'put' | |
| 119 | + }) | |
| 120 | +} | ... | ... |
api/procure-manage/assayReport.js
0 → 100644
| 1 | +import request from '@/utils/request' | |
| 2 | +import { ContentTypeEnum } from '@/utils/httpEnum' | |
| 3 | + | |
| 4 | +// 原料化验报告单(对齐 PC 端 api/warehouse-manage/material-test) | |
| 5 | +const baseUrl = '/procurement/assay/report' | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 分页查询化验报告单列表 | |
| 9 | + * params: pageIndex, pageSize, weighingTicketCode, reportDateStart, reportDateEnd, | |
| 10 | + * supplierName, workshopId, approvalStatus, flowNode, createBy, | |
| 11 | + * startTime, endTime | |
| 12 | + */ | |
| 13 | +export function assayReportQueryApi(params) { | |
| 14 | + return request({ | |
| 15 | + url: baseUrl + '/query', | |
| 16 | + method: 'get', | |
| 17 | + params | |
| 18 | + }) | |
| 19 | +} | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * 分页查询可选过磅码单列表(码单编号选择) | |
| 23 | + * params: pageIndex, pageSize, code, supplierName, workshopId | |
| 24 | + */ | |
| 25 | +export function assayReportTicketPageApi(params) { | |
| 26 | + return request({ | |
| 27 | + url: baseUrl + '/ticketPage', | |
| 28 | + method: 'get', | |
| 29 | + params | |
| 30 | + }) | |
| 31 | +} | |
| 32 | + | |
| 33 | +/** | |
| 34 | + * 根据过磅码单ID查询码单数据(含计划编号下拉选项 planOptions) | |
| 35 | + */ | |
| 36 | +export function assayReportPlanOptionsApi(ticketId) { | |
| 37 | + return request({ | |
| 38 | + url: baseUrl + '/planOptions', | |
| 39 | + method: 'get', | |
| 40 | + params: { ticketId } | |
| 41 | + }) | |
| 42 | +} | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * 查询所选计划下的过磅品种下拉选项 | |
| 46 | + * params: { ticketId(可选), planId } | |
| 47 | + */ | |
| 48 | +export function assayReportProductOptionsApi(params) { | |
| 49 | + return request({ | |
| 50 | + url: baseUrl + '/productOptions', | |
| 51 | + method: 'get', | |
| 52 | + params | |
| 53 | + }) | |
| 54 | +} | |
| 55 | + | |
| 56 | +/** | |
| 57 | + * 查询化验明细(送样单)选项 | |
| 58 | + * params: { ticketId(可选), planId(可选), productId(可选) } | |
| 59 | + */ | |
| 60 | +export function assayReportApplyOptionsApi(params) { | |
| 61 | + return request({ | |
| 62 | + url: baseUrl + '/applyOptions', | |
| 63 | + method: 'get', | |
| 64 | + params | |
| 65 | + }) | |
| 66 | +} | |
| 67 | + | |
| 68 | +/** | |
| 69 | + * 新增化验报告单 | |
| 70 | + * data: { weighingTicketId, reportDate, procurementPlanId, productId, | |
| 71 | + * lines: [{ assayApplyId, cu, zn, pb, fe, p, sn, ni, al, cd, cr6, hg, bi }] } | |
| 72 | + */ | |
| 73 | +export function assayReportCreateApi(data) { | |
| 74 | + return request({ | |
| 75 | + url: baseUrl, | |
| 76 | + method: 'post', | |
| 77 | + data, | |
| 78 | + contentType: ContentTypeEnum.JSON | |
| 79 | + }) | |
| 80 | +} | |
| 81 | + | |
| 82 | +/** | |
| 83 | + * 查询化验报告单详情 | |
| 84 | + */ | |
| 85 | +export function assayReportDetailApi(params) { | |
| 86 | + return request({ | |
| 87 | + url: baseUrl, | |
| 88 | + method: 'get', | |
| 89 | + params | |
| 90 | + }) | |
| 91 | +} | |
| 92 | + | |
| 93 | +/** | |
| 94 | + * 修改化验报告单 | |
| 95 | + * data: { id, weighingTicketId, reportDate, procurementPlanId, productId, lines } | |
| 96 | + */ | |
| 97 | +export function assayReportUpdateApi(data) { | |
| 98 | + return request({ | |
| 99 | + url: baseUrl, | |
| 100 | + method: 'put', | |
| 101 | + data, | |
| 102 | + contentType: ContentTypeEnum.JSON | |
| 103 | + }) | |
| 104 | +} | |
| 105 | + | |
| 106 | +/** | |
| 107 | + * 提交化验报告单审核 | |
| 108 | + */ | |
| 109 | +export function assayReportSubmitAuditApi(id) { | |
| 110 | + return request({ | |
| 111 | + url: baseUrl + '/submit?id=' + id, | |
| 112 | + method: 'put' | |
| 113 | + }) | |
| 114 | +} | |
| 115 | + | |
| 116 | +/** | |
| 117 | + * 取消化验报告单 | |
| 118 | + */ | |
| 119 | +export function assayReportCancelApi(id) { | |
| 120 | + return request({ | |
| 121 | + url: baseUrl + '/cancel?id=' + id, | |
| 122 | + method: 'put' | |
| 123 | + }) | |
| 124 | +} | |
| 125 | +/** | |
| 126 | + * 作废化验报告单 | |
| 127 | + */ | |
| 128 | +export function assayReportInvalidApi(id) { | |
| 129 | + return request({ | |
| 130 | + url: baseUrl + '/delete?id=' + id, | |
| 131 | + method: 'put' | |
| 132 | + }) | |
| 133 | +} | |
| 134 | + | |
| 135 | +/** | |
| 136 | + * 修改意向(是否有质量问题、处理意见) | |
| 137 | + * data: { id, hasQualityProblem, processOpinion } | |
| 138 | + */ | |
| 139 | +export function assayReportQualityApi(data) { | |
| 140 | + return request({ | |
| 141 | + url: baseUrl + '/quality', | |
| 142 | + method: 'put', | |
| 143 | + data, | |
| 144 | + contentType: ContentTypeEnum.JSON | |
| 145 | + }) | |
| 146 | +} | |
| 147 | + | |
| 148 | +/** | |
| 149 | + * 分厂下拉数据(PC: base-data/maker,即 baseData/workshop) | |
| 150 | + */ | |
| 151 | +export function workshopQueryApi(params) { | |
| 152 | + return request({ | |
| 153 | + url: '/baseData/workshop/query', | |
| 154 | + method: 'get', | |
| 155 | + params | |
| 156 | + }) | |
| 157 | +} | ... | ... |
| ... | ... | @@ -589,6 +589,78 @@ |
| 589 | 589 | } |
| 590 | 590 | }, |
| 591 | 591 | { |
| 592 | + "path": "pages/sample-submission/index", | |
| 593 | + "style": { | |
| 594 | + "navigationBarTitleText": "化验送样单", | |
| 595 | + "navigationBarBackgroundColor": "#ffffff", | |
| 596 | + "navigationBarTextStyle": "black" | |
| 597 | + } | |
| 598 | + }, | |
| 599 | + { | |
| 600 | + "path": "pages/sample-submission/add", | |
| 601 | + "style": { | |
| 602 | + "navigationBarTitleText": "新增化验送样单", | |
| 603 | + "navigationBarBackgroundColor": "#ffffff", | |
| 604 | + "navigationBarTextStyle": "black" | |
| 605 | + } | |
| 606 | + }, | |
| 607 | + { | |
| 608 | + "path": "pages/sample-submission/detail", | |
| 609 | + "style": { | |
| 610 | + "navigationBarTitleText": "化验送样单详情", | |
| 611 | + "navigationBarBackgroundColor": "#ffffff", | |
| 612 | + "navigationBarTextStyle": "black" | |
| 613 | + } | |
| 614 | + }, | |
| 615 | + { | |
| 616 | + "path": "pages/sample-submission/modify", | |
| 617 | + "style": { | |
| 618 | + "navigationBarTitleText": "编辑化验送样单", | |
| 619 | + "navigationBarBackgroundColor": "#ffffff", | |
| 620 | + "navigationBarTextStyle": "black" | |
| 621 | + } | |
| 622 | + }, | |
| 623 | + { | |
| 624 | + "path": "pages/material-test/index", | |
| 625 | + "style": { | |
| 626 | + "navigationBarTitleText": "原料化验报告单", | |
| 627 | + "navigationBarBackgroundColor": "#ffffff", | |
| 628 | + "navigationBarTextStyle": "black" | |
| 629 | + } | |
| 630 | + }, | |
| 631 | + { | |
| 632 | + "path": "pages/material-test/add", | |
| 633 | + "style": { | |
| 634 | + "navigationBarTitleText": "新增原料化验报告单", | |
| 635 | + "navigationBarBackgroundColor": "#ffffff", | |
| 636 | + "navigationBarTextStyle": "black" | |
| 637 | + } | |
| 638 | + }, | |
| 639 | + { | |
| 640 | + "path": "pages/material-test/detail", | |
| 641 | + "style": { | |
| 642 | + "navigationBarTitleText": "原料化验报告单详情", | |
| 643 | + "navigationBarBackgroundColor": "#ffffff", | |
| 644 | + "navigationBarTextStyle": "black" | |
| 645 | + } | |
| 646 | + }, | |
| 647 | + { | |
| 648 | + "path": "pages/material-test/modify", | |
| 649 | + "style": { | |
| 650 | + "navigationBarTitleText": "编辑原料化验报告单", | |
| 651 | + "navigationBarBackgroundColor": "#ffffff", | |
| 652 | + "navigationBarTextStyle": "black" | |
| 653 | + } | |
| 654 | + }, | |
| 655 | + { | |
| 656 | + "path": "pages/material-test/quality", | |
| 657 | + "style": { | |
| 658 | + "navigationBarTitleText": "修改意向", | |
| 659 | + "navigationBarBackgroundColor": "#ffffff", | |
| 660 | + "navigationBarTextStyle": "black" | |
| 661 | + } | |
| 662 | + }, | |
| 663 | + { | |
| 592 | 664 | "path": "pages/order_list/index", |
| 593 | 665 | "style": { |
| 594 | 666 | "navigationBarTitleText": "订货单列表", | ... | ... |
pages/material-test/add.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <!-- 基础信息 --> | |
| 5 | + <uni-list> | |
| 6 | + <!-- 码单编号(弹窗选择) --> | |
| 7 | + <uni-list-item class="select-item" :class="form.weighingTicketCode ? 'is-filled' : 'is-empty'" clickable | |
| 8 | + @click="openTicketSheet" :rightText="form.weighingTicketCode || '请选择码单'" showArrow> | |
| 9 | + <template v-slot:body> | |
| 10 | + <view class="item-title"><text class="required">*</text><text>码单编号</text></view> | |
| 11 | + </template> | |
| 12 | + </uni-list-item> | |
| 13 | + | |
| 14 | + <!-- 日期(选择码单后带出) --> | |
| 15 | + <uni-list-item class="select-item" :class="form.reportDate ? 'is-filled' : 'is-empty'"> | |
| 16 | + <template v-slot:body> | |
| 17 | + <view class="item-title"><text class="required">*</text><text>日期</text></view> | |
| 18 | + </template> | |
| 19 | + <template v-slot:footer> | |
| 20 | + <view class="picker-value" :class="{ placeholder: !form.reportDate }"> | |
| 21 | + {{ form.reportDate || '选择码单后带出' }} | |
| 22 | + </view> | |
| 23 | + </template> | |
| 24 | + </uni-list-item> | |
| 25 | + | |
| 26 | + <!-- 客户名称(选择码单后带出) --> | |
| 27 | + <uni-list-item class="select-item" :class="form.supplierName ? 'is-filled' : 'is-empty'"> | |
| 28 | + <template v-slot:body> | |
| 29 | + <view class="item-title"><text class="required">*</text><text>客户名称</text></view> | |
| 30 | + </template> | |
| 31 | + <template v-slot:footer> | |
| 32 | + <view class="picker-value" :class="{ placeholder: !form.supplierName }"> | |
| 33 | + {{ form.supplierName || '选择码单后带出' }} | |
| 34 | + </view> | |
| 35 | + </template> | |
| 36 | + </uni-list-item> | |
| 37 | + | |
| 38 | + <!-- 计划编号 --> | |
| 39 | + <uni-list-item class="select-item" :class="form.procurementPlanId ? 'is-filled' : 'is-empty'"> | |
| 40 | + <template v-slot:body> | |
| 41 | + <view class="item-title"><text class="required">*</text><text>计划编号</text></view> | |
| 42 | + </template> | |
| 43 | + <template v-slot:footer> | |
| 44 | + <picker mode="selector" :range="planLabels" @change="onPlanChange" :disabled="!planOptions.length"> | |
| 45 | + <view class="picker-value" :class="{ placeholder: !form.procurementPlanId }"> | |
| 46 | + {{ getPlanLabel() || '请选择计划编号' }} | |
| 47 | + </view> | |
| 48 | + </picker> | |
| 49 | + </template> | |
| 50 | + </uni-list-item> | |
| 51 | + | |
| 52 | + <!-- 过磅品种 --> | |
| 53 | + <uni-list-item class="select-item" :class="form.productId ? 'is-filled' : 'is-empty'"> | |
| 54 | + <template v-slot:body> | |
| 55 | + <view class="item-title"><text class="required">*</text><text>过磅品种</text></view> | |
| 56 | + </template> | |
| 57 | + <template v-slot:footer> | |
| 58 | + <picker mode="selector" :range="productLabels" @change="onProductChange" :disabled="!productOptions.length"> | |
| 59 | + <view class="picker-value" :class="{ placeholder: !form.productId }"> | |
| 60 | + {{ getProductLabel() || '请选择过磅品种' }} | |
| 61 | + </view> | |
| 62 | + </picker> | |
| 63 | + </template> | |
| 64 | + </uni-list-item> | |
| 65 | + </uni-list> | |
| 66 | + | |
| 67 | + <!-- 化验明细:样品/数量/样号/送样编号 + 成份%(成分项按码单分厂区分) --> | |
| 68 | + <AssayDetailTable ref="detailTable" :options="applyDetailOptions" :workshop-name="ticketWorkshopName" /> | |
| 69 | + </scroll-view> | |
| 70 | + | |
| 71 | + <view class="footer"> | |
| 72 | + <button class="btn submit" type="primary" @click="onSubmit">保存</button> | |
| 73 | + </view> | |
| 74 | + | |
| 75 | + <RelateSelectSheet :visible.sync="ticketSheet.visible" title="选择码单" :multiple="false" | |
| 76 | + :fetchFn="ticketSheet.fetchFn" :display-fields="ticketSheet.displayFields" | |
| 77 | + row-key="id" :selectedKeys.sync="ticketSheet.selectedKeys" @confirm="onTicketConfirm" /> | |
| 78 | + </view> | |
| 79 | +</template> | |
| 80 | + | |
| 81 | +<script> | |
| 82 | +import RelateSelectSheet from '@/components/relate-select/index.vue' | |
| 83 | +import AssayDetailTable from './assay-detail-table.vue' | |
| 84 | +import { | |
| 85 | + assayReportTicketPageApi, | |
| 86 | + assayReportPlanOptionsApi, | |
| 87 | + assayReportProductOptionsApi, | |
| 88 | + assayReportApplyOptionsApi, | |
| 89 | + assayReportCreateApi | |
| 90 | +} from '@/api/procure-manage/assayReport.js' | |
| 91 | + | |
| 92 | +export default { | |
| 93 | + name: 'AddMaterialTest', | |
| 94 | + components: { RelateSelectSheet, AssayDetailTable }, | |
| 95 | + data() { | |
| 96 | + return { | |
| 97 | + form: { | |
| 98 | + weighingTicketId: '', | |
| 99 | + weighingTicketCode: '', | |
| 100 | + reportDate: '', | |
| 101 | + supplierName: '', | |
| 102 | + procurementPlanId: '', | |
| 103 | + productId: '' | |
| 104 | + }, | |
| 105 | + // 选中的码单行对象,供回显与分厂成分联动使用 | |
| 106 | + selectedTicketRow: null, | |
| 107 | + // 计划编号下拉选项(所选码单下的计划) | |
| 108 | + planOptions: [], | |
| 109 | + // 过磅品种下拉选项(所选计划下的品种) | |
| 110 | + productOptions: [], | |
| 111 | + // 化验明细数据源(applyOptions 返回),供明细子组件送样编号下拉与固定值使用 | |
| 112 | + applyDetailOptions: [], | |
| 113 | + ticketSheet: { | |
| 114 | + visible: false, | |
| 115 | + fetchFn: null, | |
| 116 | + displayFields: [ | |
| 117 | + { label: '码单编号', field: 'code' }, | |
| 118 | + { label: '供应商', field: 'supplierName' }, | |
| 119 | + { label: '分厂', field: 'workshopName' }, | |
| 120 | + { label: '创建人', field: 'createBy' }, | |
| 121 | + { label: '完成时间', field: 'completeTime' } | |
| 122 | + ], | |
| 123 | + selectedKeys: [] | |
| 124 | + } | |
| 125 | + } | |
| 126 | + }, | |
| 127 | + computed: { | |
| 128 | + // 码单分厂名称,决定化验明细成分项集合 | |
| 129 | + ticketWorkshopName() { | |
| 130 | + return (this.selectedTicketRow && this.selectedTicketRow.workshopName) || '' | |
| 131 | + }, | |
| 132 | + planLabels() { | |
| 133 | + return (this.planOptions || []).map(it => it.label) | |
| 134 | + }, | |
| 135 | + productLabels() { | |
| 136 | + return (this.productOptions || []).map(it => it.label) | |
| 137 | + } | |
| 138 | + }, | |
| 139 | + created() { | |
| 140 | + this.ticketSheet.fetchFn = this.fetchTickets.bind(this) | |
| 141 | + }, | |
| 142 | + methods: { | |
| 143 | + // 码单选择弹窗数据源(可选过磅码单分页,合并筛选条件) | |
| 144 | + fetchTickets({ pageIndex, pageSize, extra }) { | |
| 145 | + const keyword = (extra && extra.keyword) || '' | |
| 146 | + const params = { | |
| 147 | + pageIndex, | |
| 148 | + pageSize, | |
| 149 | + code: keyword || undefined | |
| 150 | + } | |
| 151 | + return assayReportTicketPageApi(params).then(res => { | |
| 152 | + const _data = (res && res.data) || {} | |
| 153 | + const records = _data.datas || _data.list || _data.records || [] | |
| 154 | + const totalCount = _data.totalCount || _data.count || 0 | |
| 155 | + const hasNext = _data.hasNext || false | |
| 156 | + return { records, totalCount, hasNext } | |
| 157 | + }).catch(() => ({ records: [], totalCount: 0, hasNext: false })) | |
| 158 | + }, | |
| 159 | + openTicketSheet() { | |
| 160 | + this.ticketSheet.selectedKeys = this.form.weighingTicketId ? [this.form.weighingTicketId] : [] | |
| 161 | + this.ticketSheet.visible = true | |
| 162 | + }, | |
| 163 | + // 码单选择回调:带出日期/客户名称,联动刷新计划编号下拉、按分厂刷新成分表格 | |
| 164 | + onTicketConfirm({ items }) { | |
| 165 | + const row = (items || [])[0] | |
| 166 | + if (!row) { | |
| 167 | + this.selectedTicketRow = null | |
| 168 | + this.form.weighingTicketId = '' | |
| 169 | + this.form.weighingTicketCode = '' | |
| 170 | + this.form.reportDate = '' | |
| 171 | + this.form.supplierName = '' | |
| 172 | + this.resetDownStream() | |
| 173 | + return | |
| 174 | + } | |
| 175 | + this.selectedTicketRow = row | |
| 176 | + this.form.weighingTicketId = row.id || '' | |
| 177 | + this.form.weighingTicketCode = row.code || '' | |
| 178 | + // 选择码单后带出日期与客户名称 | |
| 179 | + this.form.reportDate = String(row.completeTime || '').slice(0, 10) | |
| 180 | + this.form.supplierName = row.supplierName || '' | |
| 181 | + // 切换码单后重置计划编号、品种及化验明细(成分项随分厂名变化由明细子组件自动刷新) | |
| 182 | + this.resetDownStream() | |
| 183 | + this.loadPlanOptions(row.id) | |
| 184 | + }, | |
| 185 | + resetDownStream() { | |
| 186 | + this.form.procurementPlanId = '' | |
| 187 | + this.form.productId = '' | |
| 188 | + this.planOptions = [] | |
| 189 | + this.productOptions = [] | |
| 190 | + this.applyDetailOptions = [] | |
| 191 | + const detailTable = this.$refs.detailTable | |
| 192 | + detailTable && detailTable.setRows && detailTable.setRows([]) | |
| 193 | + }, | |
| 194 | + // 根据所选码单加载计划编号下拉选项 | |
| 195 | + loadPlanOptions(ticketId) { | |
| 196 | + assayReportPlanOptionsApi(ticketId) | |
| 197 | + .then(res => { | |
| 198 | + const list = (res && res.data) || [] | |
| 199 | + this.planOptions = (list || []).map(item => ({ | |
| 200 | + label: item.planCode, | |
| 201 | + value: item.planId | |
| 202 | + })) | |
| 203 | + }) | |
| 204 | + .catch(() => { | |
| 205 | + this.planOptions = [] | |
| 206 | + }) | |
| 207 | + }, | |
| 208 | + getPlanLabel() { | |
| 209 | + const found = (this.planOptions || []).find(it => it.value === this.form.procurementPlanId) | |
| 210 | + return found ? found.label : '' | |
| 211 | + }, | |
| 212 | + // 计划编号改选后:重置品种并按所选计划刷新过磅品种下拉 | |
| 213 | + onPlanChange(e) { | |
| 214 | + const opt = (this.planOptions || [])[Number(e.detail.value)] | |
| 215 | + if (!opt) return | |
| 216 | + this.form.procurementPlanId = opt.value | |
| 217 | + this.form.productId = '' | |
| 218 | + this.productOptions = [] | |
| 219 | + this.applyDetailOptions = [] | |
| 220 | + const detailTable = this.$refs.detailTable | |
| 221 | + detailTable && detailTable.setRows && detailTable.setRows([]) | |
| 222 | + assayReportProductOptionsApi({ | |
| 223 | + ticketId: this.form.weighingTicketId || undefined, | |
| 224 | + planId: opt.value | |
| 225 | + }) | |
| 226 | + .then(res => { | |
| 227 | + const list = (res && res.data) || [] | |
| 228 | + this.productOptions = (list || []).map(item => ({ | |
| 229 | + label: item.productName, | |
| 230 | + value: item.productId | |
| 231 | + })) | |
| 232 | + }) | |
| 233 | + .catch(() => { | |
| 234 | + this.productOptions = [] | |
| 235 | + }) | |
| 236 | + }, | |
| 237 | + getProductLabel() { | |
| 238 | + const found = (this.productOptions || []).find(it => it.value === this.form.productId) | |
| 239 | + return found ? found.label : '' | |
| 240 | + }, | |
| 241 | + // 过磅品种改选后:按码单/计划/品种加载化验明细并填充表格 | |
| 242 | + onProductChange(e) { | |
| 243 | + const opt = (this.productOptions || [])[Number(e.detail.value)] | |
| 244 | + if (!opt) return | |
| 245 | + this.form.productId = opt.value | |
| 246 | + this.applyDetailOptions = [] | |
| 247 | + const detailTable = this.$refs.detailTable | |
| 248 | + detailTable && detailTable.setRows && detailTable.setRows([]) | |
| 249 | + this.loadApplyDetail() | |
| 250 | + }, | |
| 251 | + // 加载化验明细数据 | |
| 252 | + loadApplyDetail() { | |
| 253 | + assayReportApplyOptionsApi({ | |
| 254 | + ticketId: this.form.weighingTicketId || undefined, | |
| 255 | + planId: this.form.procurementPlanId || undefined, | |
| 256 | + productId: this.form.productId || undefined | |
| 257 | + }) | |
| 258 | + .then(res => { | |
| 259 | + const list = (res && res.data) || [] | |
| 260 | + this.applyDetailOptions = (list || []).map(item => ({ | |
| 261 | + assayApplyId: item.assayApplyId || item.id || '', | |
| 262 | + assayApplyCode: item.assayApplyCode || '', | |
| 263 | + productName: item.productName || '', | |
| 264 | + productId: item.productId || '', | |
| 265 | + quantity: item.quantity | |
| 266 | + })) | |
| 267 | + // 默认按化验明细填充表格,样号从1开始编号 | |
| 268 | + const detailTable = this.$refs.detailTable | |
| 269 | + detailTable && detailTable.loadRows && detailTable.loadRows(this.applyDetailOptions) | |
| 270 | + }) | |
| 271 | + .catch(() => { | |
| 272 | + this.applyDetailOptions = [] | |
| 273 | + }) | |
| 274 | + }, | |
| 275 | + validate() { | |
| 276 | + const f = this.form | |
| 277 | + if (!f.weighingTicketId) return this.tip('请选择码单编号') | |
| 278 | + if (!f.reportDate) return this.tip('日期不能为空') | |
| 279 | + if (!f.procurementPlanId) return this.tip('请选择计划编号') | |
| 280 | + if (!f.productId) return this.tip('请选择过磅品种') | |
| 281 | + return true | |
| 282 | + }, | |
| 283 | + tip(msg) { | |
| 284 | + uni.showToast({ title: msg, icon: 'none' }) | |
| 285 | + return false | |
| 286 | + }, | |
| 287 | + async onSubmit() { | |
| 288 | + if (!this.validate()) return | |
| 289 | + const confirmRes = await new Promise(resolve => { | |
| 290 | + uni.showModal({ title: '提示', content: '确定保存原料化验报告单吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 291 | + }) | |
| 292 | + if (!(confirmRes && confirmRes.confirm)) return | |
| 293 | + const detailTable = this.$refs.detailTable | |
| 294 | + const lines = (detailTable && detailTable.getLines && detailTable.getLines()) || [] | |
| 295 | + uni.showLoading({ title: '提交中...', mask: true }) | |
| 296 | + assayReportCreateApi({ | |
| 297 | + weighingTicketId: this.form.weighingTicketId, | |
| 298 | + reportDate: this.form.reportDate, | |
| 299 | + procurementPlanId: this.form.procurementPlanId, | |
| 300 | + productId: this.form.productId, | |
| 301 | + lines | |
| 302 | + }) | |
| 303 | + .then(() => { | |
| 304 | + uni.hideLoading() | |
| 305 | + uni.showToast({ title: '保存成功', icon: 'none' }) | |
| 306 | + try { uni.setStorageSync('MATERIAL_TEST_LIST_NEED_REFRESH', '1') } catch (e) {} | |
| 307 | + setTimeout(() => { uni.navigateBack() }, 400) | |
| 308 | + }) | |
| 309 | + .catch(e => { | |
| 310 | + uni.hideLoading() | |
| 311 | + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' }) | |
| 312 | + }) | |
| 313 | + } | |
| 314 | + } | |
| 315 | +} | |
| 316 | +</script> | |
| 317 | + | |
| 318 | +<style lang="scss" scoped> | |
| 319 | +.page { | |
| 320 | + display: flex; | |
| 321 | + flex-direction: column; | |
| 322 | + height: 100%; | |
| 323 | +} | |
| 324 | + | |
| 325 | +.scroll { | |
| 326 | + flex: 1; | |
| 327 | + padding: 12rpx 0 200rpx !important; | |
| 328 | +} | |
| 329 | + | |
| 330 | +.footer { | |
| 331 | + z-index: 2; | |
| 332 | + position: fixed; | |
| 333 | + left: 0; | |
| 334 | + right: 0; | |
| 335 | + bottom: 0; | |
| 336 | + padding: 32rpx; | |
| 337 | + padding-bottom: calc(32rpx + env(safe-area-inset-bottom)); | |
| 338 | + background: #fff; | |
| 339 | + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06); | |
| 340 | + | |
| 341 | + .btn { | |
| 342 | + height: 80rpx; | |
| 343 | + line-height: 80rpx; | |
| 344 | + border-radius: 12rpx; | |
| 345 | + font-size: 32rpx; | |
| 346 | + } | |
| 347 | + | |
| 348 | + .submit { | |
| 349 | + background: $theme-primary; | |
| 350 | + color: #fff; | |
| 351 | + } | |
| 352 | +} | |
| 353 | + | |
| 354 | +::v-deep .uni-list { | |
| 355 | + .uni-easyinput { | |
| 356 | + display: flex; | |
| 357 | + | |
| 358 | + .uni-input-input { | |
| 359 | + color: rgba(0, 0, 0, 0.9); | |
| 360 | + } | |
| 361 | + } | |
| 362 | + | |
| 363 | + .uni-input-placeholder { | |
| 364 | + z-index: 1; | |
| 365 | + } | |
| 366 | + | |
| 367 | + .uni-input-input { | |
| 368 | + background-color: #ffffff; | |
| 369 | + } | |
| 370 | + | |
| 371 | + background: transparent; | |
| 372 | + | |
| 373 | + &-item { | |
| 374 | + &__extra-text { | |
| 375 | + font-size: 32rpx; | |
| 376 | + } | |
| 377 | + | |
| 378 | + &__content-title { | |
| 379 | + font-size: 32rpx; | |
| 380 | + color: rgba(0, 0, 0, 0.9); | |
| 381 | + } | |
| 382 | + | |
| 383 | + &__container { | |
| 384 | + padding: 32rpx; | |
| 385 | + | |
| 386 | + .item-title, | |
| 387 | + .uni-list-item__content { | |
| 388 | + flex: none; | |
| 389 | + min-height: 48rpx; | |
| 390 | + line-height: 48rpx; | |
| 391 | + font-size: 32rpx; | |
| 392 | + position: relative; | |
| 393 | + width: 240rpx; | |
| 394 | + margin-right: 32rpx; | |
| 395 | + color: rgba(0, 0, 0, 0.9); | |
| 396 | + | |
| 397 | + .required { | |
| 398 | + color: red; | |
| 399 | + position: absolute; | |
| 400 | + top: 50%; | |
| 401 | + transform: translateY(-50%); | |
| 402 | + left: -16rpx; | |
| 403 | + } | |
| 404 | + } | |
| 405 | + } | |
| 406 | + | |
| 407 | + &.select-item { | |
| 408 | + &.is-empty { | |
| 409 | + .uni-list-item__extra-text { | |
| 410 | + color: rgba(0, 0, 0, 0.4) !important; | |
| 411 | + } | |
| 412 | + } | |
| 413 | + | |
| 414 | + &.is-filled { | |
| 415 | + .uni-list-item__extra-text { | |
| 416 | + color: rgba(0, 0, 0, 0.9) !important; | |
| 417 | + } | |
| 418 | + } | |
| 419 | + } | |
| 420 | + } | |
| 421 | +} | |
| 422 | + | |
| 423 | +.picker-value { | |
| 424 | + font-size: 32rpx; | |
| 425 | + color: rgba(0, 0, 0, 0.9); | |
| 426 | + line-height: 48rpx; | |
| 427 | + text-align: right; | |
| 428 | + min-height: 48rpx; | |
| 429 | + | |
| 430 | + &.placeholder { | |
| 431 | + color: rgba(0, 0, 0, 0.4); | |
| 432 | + } | |
| 433 | +} | |
| 434 | +</style> | ... | ... |
pages/material-test/assay-detail-table.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <!-- 化验明细:样品/数量/样号/送样编号 + 成份%(成分项按码单分厂区分,逐行填写) --> | |
| 3 | + <view class="sub-table"> | |
| 4 | + <view class="sub-header"> | |
| 5 | + <image class="sub-bar" src="/static/images/title.png" /> | |
| 6 | + <text class="sub-title">化验明细</text> | |
| 7 | + <view class="add-btn" @click="addRow"> | |
| 8 | + <text class="add-btn_text">+ 新增行</text> | |
| 9 | + </view> | |
| 10 | + </view> | |
| 11 | + <view class="sub-body"> | |
| 12 | + <view v-if="!rows.length" class="empty-tip">暂无明细,请选择过磅品种后加载</view> | |
| 13 | + <view v-for="(row, idx) in rows" :key="'line-' + idx" class="card"> | |
| 14 | + <view class="card-index">第 {{ idx + 1 }} 行</view> | |
| 15 | + <view class="card-delete" @click="delRow(idx)"><text>删除</text></view> | |
| 16 | + | |
| 17 | + <view class="row"> | |
| 18 | + <text class="label">送样编号</text> | |
| 19 | + <picker | |
| 20 | + class="picker-box" | |
| 21 | + mode="selector" | |
| 22 | + :range="getRowCodeLabels(row)" | |
| 23 | + @change="onSendCodeChange($event, idx)" | |
| 24 | + > | |
| 25 | + <view class="picker-value" :class="{ placeholder: !row.assayApplyCode }"> | |
| 26 | + {{ row.assayApplyCode || '请选择送样编号' }} | |
| 27 | + </view> | |
| 28 | + </picker> | |
| 29 | + </view> | |
| 30 | + <view class="row"> | |
| 31 | + <text class="label">样品</text> | |
| 32 | + <text class="value">{{ row.productName || '-' }}</text> | |
| 33 | + </view> | |
| 34 | + <view class="row"> | |
| 35 | + <text class="label">数量</text> | |
| 36 | + <text class="value">{{ row.quantity === null || row.quantity === undefined || row.quantity === '' ? '-' : row.quantity }}</text> | |
| 37 | + </view> | |
| 38 | + | |
| 39 | + <!-- 成份%(按分厂区分的成分项,逐行填写) --> | |
| 40 | + <view class="component-title">成份%</view> | |
| 41 | + <view class="component-grid"> | |
| 42 | + <view v-for="key in componentKeys" :key="key" class="component-item"> | |
| 43 | + <text class="component-label">{{ componentLabels[key] || key }}</text> | |
| 44 | + <input | |
| 45 | + class="component-input" | |
| 46 | + type="digit" | |
| 47 | + :value="row[key] === null || row[key] === undefined ? '' : String(row[key])" | |
| 48 | + placeholder="未填" | |
| 49 | + placeholder-class="component-placeholder" | |
| 50 | + @input="onComponentInput($event, idx, key)" | |
| 51 | + /> | |
| 52 | + </view> | |
| 53 | + </view> | |
| 54 | + </view> | |
| 55 | + </view> | |
| 56 | + </view> | |
| 57 | +</template> | |
| 58 | + | |
| 59 | +<script> | |
| 60 | +import { COMPONENT_LABELS, ALL_COMPONENT_KEYS, getComponentKeys } from './component-config.js' | |
| 61 | + | |
| 62 | +export default { | |
| 63 | + name: 'AssayDetailTable', | |
| 64 | + props: { | |
| 65 | + // 化验明细数据源(applyOptions 返回),供送样编号下拉与固定值使用 | |
| 66 | + options: { | |
| 67 | + type: Array, | |
| 68 | + default: () => [] | |
| 69 | + }, | |
| 70 | + // 码单分厂名称,决定成份%项集合 | |
| 71 | + workshopName: { | |
| 72 | + type: String, | |
| 73 | + default: '' | |
| 74 | + } | |
| 75 | + }, | |
| 76 | + data() { | |
| 77 | + return { | |
| 78 | + componentLabels: COMPONENT_LABELS, | |
| 79 | + // 化验明细行数据 | |
| 80 | + rows: [] | |
| 81 | + } | |
| 82 | + }, | |
| 83 | + computed: { | |
| 84 | + // 当前分厂对应的成分项 key 列表 | |
| 85 | + componentKeys() { | |
| 86 | + return getComponentKeys(this.workshopName) | |
| 87 | + } | |
| 88 | + }, | |
| 89 | + methods: { | |
| 90 | + // 构造行对象(初始化全部成分字段,保证响应式) | |
| 91 | + buildRow(item, index) { | |
| 92 | + const row = { | |
| 93 | + productName: (item && item.productName) || '', | |
| 94 | + productId: (item && item.productId) || '', | |
| 95 | + quantity: item ? item.quantity : '', | |
| 96 | + testCode: String(index + 1), | |
| 97 | + assayApplyCode: (item && item.assayApplyCode) || '', | |
| 98 | + assayApplyId: (item && item.assayApplyId) || '' | |
| 99 | + } | |
| 100 | + ALL_COMPONENT_KEYS.forEach(key => { | |
| 101 | + row[key] = (item && item[key] !== undefined && item[key] !== null) ? item[key] : null | |
| 102 | + }) | |
| 103 | + return row | |
| 104 | + }, | |
| 105 | + // 按化验明细数据源填充表格(每条明细一行,样号从1开始编号) | |
| 106 | + loadRows(options) { | |
| 107 | + this.rows = (options || []).map((item, index) => this.buildRow(item, index)) | |
| 108 | + }, | |
| 109 | + // 回显表格数据(修改时使用),样号按行序重新编号 | |
| 110 | + setRows(list) { | |
| 111 | + this.rows = (list || []).map((item, index) => this.buildRow(item, index)) | |
| 112 | + }, | |
| 113 | + // 获取提交用明细行(含各行成分值,未填/分厂未包含的成分为 null) | |
| 114 | + getLines() { | |
| 115 | + return (this.rows || []) | |
| 116 | + .filter(row => row.assayApplyId) | |
| 117 | + .map(row => { | |
| 118 | + const line = { assayApplyId: row.assayApplyId } | |
| 119 | + ALL_COMPONENT_KEYS.forEach(key => { | |
| 120 | + const val = row[key] | |
| 121 | + line[key] = (val === undefined || val === null || val === '') ? null : Number(val) | |
| 122 | + }) | |
| 123 | + return line | |
| 124 | + }) | |
| 125 | + }, | |
| 126 | + // 送样编号下拉标签(化验明细数据中所有的送样编号,排除已被其他行选中的,避免重复选择) | |
| 127 | + getRowCodeLabels(row) { | |
| 128 | + return this.getRowCodeOptions(row).map(it => it.label) | |
| 129 | + }, | |
| 130 | + getRowCodeOptions(row) { | |
| 131 | + const selectedIds = (this.rows || []) | |
| 132 | + .filter(r => r !== row && r.assayApplyId) | |
| 133 | + .map(r => r.assayApplyId) | |
| 134 | + return (this.options || []) | |
| 135 | + .filter(item => item.assayApplyCode && !selectedIds.includes(item.assayApplyId)) | |
| 136 | + .map(item => ({ label: item.assayApplyCode, value: item.assayApplyId })) | |
| 137 | + }, | |
| 138 | + // 送样编号下拉变化:带出该送样编号对应的固定数据(成分值保留当前行已填写内容) | |
| 139 | + onSendCodeChange(e, index) { | |
| 140 | + const row = this.rows[index] | |
| 141 | + if (!row) return | |
| 142 | + const opt = this.getRowCodeOptions(row)[Number(e.detail.value)] | |
| 143 | + if (!opt) return | |
| 144 | + const item = (this.options || []).find(i => i.assayApplyId === opt.value) || {} | |
| 145 | + row.productId = item.productId || '' | |
| 146 | + row.assayApplyCode = item.assayApplyCode || '' | |
| 147 | + row.assayApplyId = item.assayApplyId || '' | |
| 148 | + row.productName = item.productName || '' | |
| 149 | + row.quantity = item.quantity !== undefined && item.quantity !== null ? item.quantity : '' | |
| 150 | + }, | |
| 151 | + // 成份值输入:仅允许数字与小数点,空值重置为 null | |
| 152 | + onComponentInput(e, index, key) { | |
| 153 | + const row = this.rows[index] | |
| 154 | + if (!row) return | |
| 155 | + let value = String((e && e.detail && e.detail.value) == null ? '' : e.detail.value) | |
| 156 | + value = value.replace(/[^\d.]/g, '') | |
| 157 | + const parts = value.split('.') | |
| 158 | + if (parts.length > 2) { | |
| 159 | + value = parts[0] + '.' + parts.slice(1).join('') | |
| 160 | + } | |
| 161 | + row[key] = value === '' ? null : value | |
| 162 | + }, | |
| 163 | + // 新增化验明细行:样品/数量为固定数据,样号按行序从1开始编号,成分值默认空 | |
| 164 | + addRow() { | |
| 165 | + const fixed = (this.options || [])[0] || {} | |
| 166 | + this.rows.push(this.buildRow(fixed, this.rows.length)) | |
| 167 | + }, | |
| 168 | + // 删除指定化验明细行,删除后样号重新从1开始编号 | |
| 169 | + delRow(index) { | |
| 170 | + if (index < 0 || index >= this.rows.length) return | |
| 171 | + this.rows.splice(index, 1) | |
| 172 | + this.rows.forEach((row, i) => { | |
| 173 | + row.testCode = String(i + 1) | |
| 174 | + }) | |
| 175 | + } | |
| 176 | + } | |
| 177 | +} | |
| 178 | +</script> | |
| 179 | + | |
| 180 | +<style lang="scss" scoped> | |
| 181 | +.sub-table { | |
| 182 | + background: #fff; | |
| 183 | + margin-bottom: 20rpx; | |
| 184 | +} | |
| 185 | +.sub-header { | |
| 186 | + display: flex; | |
| 187 | + align-items: center; | |
| 188 | + padding: 16rpx 24rpx 16rpx 32rpx; | |
| 189 | + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; } | |
| 190 | + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; } | |
| 191 | + .add-btn { | |
| 192 | + height: 52rpx; | |
| 193 | + line-height: 52rpx; | |
| 194 | + padding: 0 24rpx; | |
| 195 | + border-radius: 8rpx; | |
| 196 | + background: $theme-primary; | |
| 197 | + .add-btn_text { font-size: 26rpx; color: #fff; } | |
| 198 | + } | |
| 199 | +} | |
| 200 | +.sub-body { | |
| 201 | + padding: 0 32rpx 24rpx; | |
| 202 | + .empty-tip { | |
| 203 | + text-align: center; | |
| 204 | + padding: 60rpx 0; | |
| 205 | + color: rgba(0, 0, 0, 0.4); | |
| 206 | + font-size: 28rpx; | |
| 207 | + } | |
| 208 | + .card { | |
| 209 | + position: relative; | |
| 210 | + background: #fafafa; | |
| 211 | + border-radius: 12rpx; | |
| 212 | + padding: 32rpx 28rpx 20rpx; | |
| 213 | + margin-bottom: 24rpx; | |
| 214 | + .card-index { | |
| 215 | + position: absolute; | |
| 216 | + top: 0; | |
| 217 | + right: 0; | |
| 218 | + background: rgba(24, 144, 255, 0.08); | |
| 219 | + color: $theme-primary; | |
| 220 | + font-size: 22rpx; | |
| 221 | + line-height: 36rpx; | |
| 222 | + padding: 0 16rpx; | |
| 223 | + border-bottom-left-radius: 12rpx; | |
| 224 | + border-top-right-radius: 12rpx; | |
| 225 | + } | |
| 226 | + .card-delete { | |
| 227 | + position: absolute; | |
| 228 | + top: 8rpx; | |
| 229 | + left: 12rpx; | |
| 230 | + padding: 4rpx 12rpx; | |
| 231 | + text { font-size: 24rpx; color: #d54941; } | |
| 232 | + } | |
| 233 | + .row { | |
| 234 | + display: flex; | |
| 235 | + align-items: center; | |
| 236 | + justify-content: space-between; | |
| 237 | + padding: 14rpx 0; | |
| 238 | + border-bottom: 1rpx dashed #f2f2f2; | |
| 239 | + &:last-of-type { border-bottom: none; } | |
| 240 | + .label { | |
| 241 | + flex-shrink: 0; | |
| 242 | + width: 220rpx; | |
| 243 | + font-size: 28rpx; | |
| 244 | + color: rgba(0, 0, 0, 0.6); | |
| 245 | + line-height: 40rpx; | |
| 246 | + } | |
| 247 | + .picker-box { flex: 1; } | |
| 248 | + .picker-value { | |
| 249 | + font-size: 28rpx; | |
| 250 | + color: rgba(0, 0, 0, 0.9); | |
| 251 | + line-height: 40rpx; | |
| 252 | + text-align: right; | |
| 253 | + &.placeholder { color: rgba(0, 0, 0, 0.4); } | |
| 254 | + } | |
| 255 | + .value { | |
| 256 | + flex: 1; | |
| 257 | + text-align: right; | |
| 258 | + font-size: 28rpx; | |
| 259 | + color: rgba(0, 0, 0, 0.9); | |
| 260 | + line-height: 40rpx; | |
| 261 | + overflow: hidden; | |
| 262 | + text-overflow: ellipsis; | |
| 263 | + white-space: nowrap; | |
| 264 | + } | |
| 265 | + } | |
| 266 | + .component-title { | |
| 267 | + font-size: 28rpx; | |
| 268 | + font-weight: 600; | |
| 269 | + color: rgba(0, 0, 0, 0.9); | |
| 270 | + margin: 16rpx 0 4rpx; | |
| 271 | + } | |
| 272 | + .component-grid { | |
| 273 | + display: flex; | |
| 274 | + flex-wrap: wrap; | |
| 275 | + .component-item { | |
| 276 | + width: 33.33%; | |
| 277 | + box-sizing: border-box; | |
| 278 | + padding: 12rpx 8rpx 0 0; | |
| 279 | + .component-label { | |
| 280 | + display: block; | |
| 281 | + font-size: 24rpx; | |
| 282 | + color: rgba(0, 0, 0, 0.6); | |
| 283 | + line-height: 36rpx; | |
| 284 | + } | |
| 285 | + .component-input { | |
| 286 | + width: 100%; | |
| 287 | + height: 60rpx; | |
| 288 | + line-height: 60rpx; | |
| 289 | + margin-top: 6rpx; | |
| 290 | + padding: 0 16rpx; | |
| 291 | + border: 1rpx solid #e7e7e7; | |
| 292 | + border-radius: 8rpx; | |
| 293 | + font-size: 26rpx; | |
| 294 | + color: rgba(0, 0, 0, 0.9); | |
| 295 | + background: #fff; | |
| 296 | + box-sizing: border-box; | |
| 297 | + } | |
| 298 | + .component-placeholder { color: rgba(0, 0, 0, 0.3); } | |
| 299 | + } | |
| 300 | + } | |
| 301 | + } | |
| 302 | +} | |
| 303 | +</style> | ... | ... |
pages/material-test/component-config.js
0 → 100644
| 1 | +// 成分配置共享常量(化验明细的成份%列按此生成,成分项按码单分厂区分,对齐 PC 端 component-config.js) | |
| 2 | + | |
| 3 | +// 成分元素 key 与显示名映射 | |
| 4 | +export const COMPONENT_LABELS = { | |
| 5 | + cu: 'Cu', | |
| 6 | + zn: 'Zn', | |
| 7 | + pb: 'Pb', | |
| 8 | + fe: 'Fe', | |
| 9 | + p: 'P', | |
| 10 | + sn: 'Sn', | |
| 11 | + ni: 'Ni', | |
| 12 | + al: 'Al', | |
| 13 | + cd: 'Cd', | |
| 14 | + cr6: 'Cr⁶⁺', | |
| 15 | + hg: 'Hg', | |
| 16 | + bi: 'Bi' | |
| 17 | +} | |
| 18 | + | |
| 19 | +// 提交接口要求的全部成分字段(分厂未包含的成分提交 null) | |
| 20 | +export const ALL_COMPONENT_KEYS = ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al', 'cd', 'cr6', 'hg', 'bi'] | |
| 21 | + | |
| 22 | +// 各分厂成分配置(按码单分厂名匹配,紫铜优先) | |
| 23 | +const WORKSHOP_COMPONENTS = [ | |
| 24 | + { match: '紫铜', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'bi'] }, | |
| 25 | + { match: '二', keys: ['cu', 'pb', 'fe', 'p', 'sn', 'ni', 'al', 'cd', 'cr6', 'hg'] }, | |
| 26 | + { match: '三', keys: ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al'] } | |
| 27 | +] | |
| 28 | + | |
| 29 | +// 默认成分(一分厂/未匹配到分厂时) | |
| 30 | +const DEFAULT_COMPONENT_KEYS = ['cu', 'zn', 'pb', 'fe', 'p', 'sn', 'ni', 'al'] | |
| 31 | + | |
| 32 | +// 按分厂名获取成分 key 列表 | |
| 33 | +export function getComponentKeys(workshopName) { | |
| 34 | + const name = String(workshopName || '') | |
| 35 | + const config = WORKSHOP_COMPONENTS.find(item => name.includes(item.match)) | |
| 36 | + return config ? config.keys : DEFAULT_COMPONENT_KEYS | |
| 37 | +} | ... | ... |
pages/material-test/detail.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <view class="detail-page"> | |
| 5 | + <!-- 基础信息 --> | |
| 6 | + <view class="section"> | |
| 7 | + <text class="row company">{{ safeText(form.weighingTicketCode) }}</text> | |
| 8 | + <view class="row"><text class="label">日期</text><text class="value">{{ safeText(form.reportDate) }}</text></view> | |
| 9 | + <view class="row"><text class="label">客户名称</text><text class="value">{{ safeText(form.supplierName) }}</text></view> | |
| 10 | + <view class="row"><text class="label">分厂</text><text class="value">{{ safeText(form.workshopName) }}</text></view> | |
| 11 | + <view class="row"><text class="label">计划编号</text><text class="value">{{ safeText(form.planCode) }}</text></view> | |
| 12 | + <view class="row"><text class="label">过磅品种</text><text class="value">{{ safeText(form.productName) }}</text></view> | |
| 13 | + <view class="row"><text class="label">审核状态</text><text class="value">{{ approvalStatusName }}</text></view> | |
| 14 | + <view class="row"><text class="label">流程节点</text><text class="value">{{ flowNodeName }}</text></view> | |
| 15 | + <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view> | |
| 16 | + <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view> | |
| 17 | + </view> | |
| 18 | + | |
| 19 | + <!-- 化验明细 --> | |
| 20 | + <view class="sub-table"> | |
| 21 | + <view class="sub-header"> | |
| 22 | + <image class="sub-bar" src="/static/images/title.png" /> | |
| 23 | + <text class="sub-title">化验明细</text> | |
| 24 | + <view class="sub-toggle" @click="collapse = !collapse"> | |
| 25 | + <image class="sub-toggle_icon" :src="collapse ? '/static/images/down.png' : '/static/images/up.png'" /> | |
| 26 | + <text class="sub-toggle_text">{{ collapse ? '展开' : '收起' }}</text> | |
| 27 | + </view> | |
| 28 | + </view> | |
| 29 | + <view v-if="!collapse" class="sub-body"> | |
| 30 | + <view v-if="!lines.length" class="empty-tip">暂无明细</view> | |
| 31 | + <view v-for="(item, idx) in lineRows" :key="'l-' + (item.assayApplyId || idx)" class="card"> | |
| 32 | + <view class="card-index">第 {{ idx + 1 }} 行</view> | |
| 33 | + <view class="row"><text class="label">样品</text><text class="value">{{ safeText(item.productName) }}</text></view> | |
| 34 | + <view class="row"><text class="label">数量</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> | |
| 35 | + <view class="row"><text class="label">样号</text><text class="value">{{ safeText(item.testCode) }}</text></view> | |
| 36 | + <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> | |
| 37 | + <view v-for="key in componentKeys" :key="key" class="row"> | |
| 38 | + <text class="label">{{ componentLabels[key] || key }}</text> | |
| 39 | + <text class="value">{{ formatNumber(item[key]) }}</text> | |
| 40 | + </view> | |
| 41 | + </view> | |
| 42 | + </view> | |
| 43 | + </view> | |
| 44 | + </view> | |
| 45 | + </scroll-view> | |
| 46 | + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" /> | |
| 47 | + </view> | |
| 48 | +</template> | |
| 49 | + | |
| 50 | +<script> | |
| 51 | +import DetailButtons from '@/components/detail-buttons/index.vue' | |
| 52 | +import { getDicByCodes, getDicName } from '@/utils/dic.js' | |
| 53 | +import { COMPONENT_LABELS, getComponentKeys } from './component-config.js' | |
| 54 | +import { | |
| 55 | + assayReportDetailApi, | |
| 56 | + assayReportSubmitAuditApi, | |
| 57 | + assayReportCancelApi, | |
| 58 | + assayReportInvalidApi | |
| 59 | +} from '@/api/procure-manage/assayReport.js' | |
| 60 | +import { getInfo } from '@/api/login.js' | |
| 61 | + | |
| 62 | +export default { | |
| 63 | + name: 'MaterialTestDetail', | |
| 64 | + components: { DetailButtons }, | |
| 65 | + data() { | |
| 66 | + return { | |
| 67 | + id: '', | |
| 68 | + form: {}, | |
| 69 | + lines: [], | |
| 70 | + collapse: false, | |
| 71 | + currentUserId: '', | |
| 72 | + componentLabels: COMPONENT_LABELS, | |
| 73 | + dicOptions: { | |
| 74 | + AUDIT_STATUS: [], | |
| 75 | + FLOW_NODE: [] | |
| 76 | + }, | |
| 77 | + buttons: [ | |
| 78 | + { text: '修改', visible: true, variant: 'outline', event: 'edit' }, | |
| 79 | + { text: '提交', visible: true, variant: 'outline', event: 'submit' }, | |
| 80 | + { text: '修改意见', visible: true, variant: 'outline', event: 'quality' }, | |
| 81 | + { text: '提交审核', visible: true, variant: 'outline', event: 'submitAudit' }, | |
| 82 | + { text: '审核', visible: true, variant: 'primary', event: 'audit' }, | |
| 83 | + { text: '审核详情', visible: true, variant: 'outline', event: 'auditDetail' }, | |
| 84 | + { text: '取消', visible: true, variant: 'outline', event: 'cancel' }, | |
| 85 | + { text: '作废', visible: true, variant: 'outline', event: 'invalid' } | |
| 86 | + ] | |
| 87 | + } | |
| 88 | + }, | |
| 89 | + computed: { | |
| 90 | + componentKeys() { | |
| 91 | + return getComponentKeys(this.form.workshopName) | |
| 92 | + }, | |
| 93 | + approvalStatusName() { | |
| 94 | + const v = this.form.approvalStatus == null ? '' : String(this.form.approvalStatus) | |
| 95 | + if (!v) return '-' | |
| 96 | + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v | |
| 97 | + }, | |
| 98 | + flowNodeName() { | |
| 99 | + const v = this.form.flowNode == null ? '' : String(this.form.flowNode) | |
| 100 | + if (!v) return '-' | |
| 101 | + return getDicName('FLOW_NODE', v, this.dicOptions.FLOW_NODE) || v | |
| 102 | + }, | |
| 103 | + // 化验明细展示行(样号按行序编号展示) | |
| 104 | + lineRows() { | |
| 105 | + return (this.lines || []).map((item, index) => ({ | |
| 106 | + ...item, | |
| 107 | + testCode: item.testCode || String(index + 1) | |
| 108 | + })) | |
| 109 | + }, | |
| 110 | + displayButtons() { | |
| 111 | + const status = this.form.approvalStatus || '' | |
| 112 | + // 已删除单据仅可查看(对齐 PC 端 createActions) | |
| 113 | + if (this.form.deleted === true) return [] | |
| 114 | + const isMine = this.form.createById === this.currentUserId | |
| 115 | + const isDraft = status === 'DRAFT' | |
| 116 | + const isRefuse = status === 'REFUSE' | |
| 117 | + const isAudit = status === 'AUDIT' | |
| 118 | + const isPass = status === 'PASS'; | |
| 119 | + const flowNode = this.form.flowNode || '' | |
| 120 | + const showExamine = this.form.showExamine === true | |
| 121 | + const showExamineDetail = this.form.showExamineDetail === true | |
| 122 | + // 工艺考核意见节点(或无节点):修改/提交由创建人操作 | |
| 123 | + const canEditMine = (isDraft || isRefuse) && (flowNode === 'GYKHYY' || !flowNode) && isMine | |
| 124 | + // 仓库质检意见节点:修改意向/提交审核 | |
| 125 | + const canQuality = (isDraft || isRefuse) && flowNode === 'CKZJY' | |
| 126 | + | |
| 127 | + return [ | |
| 128 | + { | |
| 129 | + ...this.buttons[0], | |
| 130 | + visible: canEditMine && this.$auth.hasPermi('warehouse-manage:material-test:modify') | |
| 131 | + }, | |
| 132 | + { | |
| 133 | + ...this.buttons[1], | |
| 134 | + visible: canEditMine && this.$auth.hasPermi('warehouse-manage:material-test:submit') | |
| 135 | + }, | |
| 136 | + { | |
| 137 | + ...this.buttons[2], | |
| 138 | + visible: canQuality && this.$auth.hasPermi('warehouse-manage:material-test:updateOption') | |
| 139 | + }, | |
| 140 | + { | |
| 141 | + ...this.buttons[3], | |
| 142 | + visible: canQuality && this.$auth.hasPermi('warehouse-manage:material-test:submit') | |
| 143 | + }, | |
| 144 | + { | |
| 145 | + ...this.buttons[4], | |
| 146 | + visible: isAudit && showExamine && this.$auth.hasPermi('warehouse-manage:material-test:approve') | |
| 147 | + }, | |
| 148 | + { | |
| 149 | + ...this.buttons[5], | |
| 150 | + visible: showExamineDetail && this.$auth.hasPermi('warehouse-manage:material-test:review') | |
| 151 | + }, | |
| 152 | + { | |
| 153 | + ...this.buttons[6], | |
| 154 | + visible: (isDraft || isRefuse) && this.$auth.hasPermi('warehouse-manage:material-test:cancel') | |
| 155 | + }, | |
| 156 | + { | |
| 157 | + ...this.buttons[7], | |
| 158 | + visible: isPass && this.$auth.hasPermi('warehouse-manage:material-test:invalid') | |
| 159 | + } | |
| 160 | + ] | |
| 161 | + } | |
| 162 | + }, | |
| 163 | + onLoad(query) { | |
| 164 | + this.id = (query && query.id) || '' | |
| 165 | + this.loadDicData() | |
| 166 | + this.loadDetail() | |
| 167 | + this.getUserInfo() | |
| 168 | + }, | |
| 169 | + onShow() { | |
| 170 | + let needRefresh = '' | |
| 171 | + try { needRefresh = uni.getStorageSync('MATERIAL_TEST_DETAIL_NEED_REFRESH') } catch (e) {} | |
| 172 | + if (!needRefresh) return | |
| 173 | + try { uni.removeStorageSync('MATERIAL_TEST_DETAIL_NEED_REFRESH') } catch (e) {} | |
| 174 | + this.loadDetail() | |
| 175 | + }, | |
| 176 | + methods: { | |
| 177 | + async loadDicData() { | |
| 178 | + try { | |
| 179 | + const results = await getDicByCodes(['AUDIT_STATUS', 'FLOW_NODE']) | |
| 180 | + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || [] | |
| 181 | + this.dicOptions.FLOW_NODE = (results.FLOW_NODE && results.FLOW_NODE.data) || [] | |
| 182 | + } catch (e) { | |
| 183 | + this.dicOptions = { AUDIT_STATUS: [], FLOW_NODE: [] } | |
| 184 | + } | |
| 185 | + }, | |
| 186 | + async getUserInfo() { | |
| 187 | + try { | |
| 188 | + const res = await getInfo() | |
| 189 | + this.currentUserId = (res && (res.id || (res.data && res.data.id))) || '' | |
| 190 | + } catch (e) { | |
| 191 | + this.currentUserId = '' | |
| 192 | + } | |
| 193 | + }, | |
| 194 | + loadDetail() { | |
| 195 | + if (!this.id) { | |
| 196 | + uni.showToast({ title: '缺少单据ID', icon: 'none' }) | |
| 197 | + return | |
| 198 | + } | |
| 199 | + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true }) | |
| 200 | + assayReportDetailApi({ id: this.id }) | |
| 201 | + .then(res => { | |
| 202 | + const data = (res && res.data) || {} | |
| 203 | + this.form = Object.assign({}, data) | |
| 204 | + this.lines = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : [] | |
| 205 | + }) | |
| 206 | + .catch(() => { | |
| 207 | + uni.showToast({ title: '详情加载失败', icon: 'none' }) | |
| 208 | + }) | |
| 209 | + .finally(() => { | |
| 210 | + uni.hideLoading && uni.hideLoading() | |
| 211 | + }) | |
| 212 | + }, | |
| 213 | + handleButtonClick(btn) { | |
| 214 | + if (!btn || btn.disabled || !btn.visible) return | |
| 215 | + const e = btn.event || '' | |
| 216 | + if (e === 'edit') return this.onEdit() | |
| 217 | + if (e === 'submit') return this.onSubmitAudit() | |
| 218 | + if (e === 'quality') return this.onQuality() | |
| 219 | + if (e === 'submitAudit') return this.onSubmitAudit() | |
| 220 | + if (e === 'audit') return this.onAudit() | |
| 221 | + if (e === 'auditDetail') return this.onAuditDetail() | |
| 222 | + if (e === 'cancel') return this.onCancel() | |
| 223 | + if (e === 'invalid') return this.onInvalid() | |
| 224 | + }, | |
| 225 | + onEdit() { | |
| 226 | + uni.navigateTo({ url: '/pages/material-test/modify?id=' + this.id }) | |
| 227 | + }, | |
| 228 | + onQuality() { | |
| 229 | + uni.navigateTo({ url: '/pages/material-test/quality?id=' + this.id }) | |
| 230 | + }, | |
| 231 | + onAudit() { | |
| 232 | + const id = this.id || (this.form && this.form.id) || '' | |
| 233 | + if (!id) return | |
| 234 | + uni.setStorageSync('contractType', 'ASSAY_REPORT') | |
| 235 | + uni.setStorageSync('sourceBusinessId', id) | |
| 236 | + uni.navigateTo({ url: '/pages/flow/audit' }) | |
| 237 | + }, | |
| 238 | + onAuditDetail() { | |
| 239 | + const id = this.id || (this.form && this.form.id) || '' | |
| 240 | + if (!id) return | |
| 241 | + uni.setStorageSync('contractType', 'ASSAY_REPORT') | |
| 242 | + uni.setStorageSync('sourceBusinessId', id) | |
| 243 | + uni.navigateTo({ url: '/pages/flow/audit_detail' }) | |
| 244 | + }, | |
| 245 | + refreshListFlags() { | |
| 246 | + try { | |
| 247 | + uni.setStorageSync('MATERIAL_TEST_LIST_NEED_REFRESH', '1') | |
| 248 | + uni.setStorageSync('MATERIAL_TEST_DETAIL_NEED_REFRESH', '1') | |
| 249 | + } catch (e) {} | |
| 250 | + }, | |
| 251 | + runWithConfirm(opts) { | |
| 252 | + const title = opts.title || '提示' | |
| 253 | + const content = opts.content || '' | |
| 254 | + const run = opts.run | |
| 255 | + const loading = opts.loading || '处理中' | |
| 256 | + const successText = opts.successText || '操作成功' | |
| 257 | + const failText = opts.failText || '操作失败' | |
| 258 | + if (!this.id) { | |
| 259 | + uni.showToast({ title: '缺少单据ID', icon: 'none' }) | |
| 260 | + return | |
| 261 | + } | |
| 262 | + uni.showModal({ | |
| 263 | + title, | |
| 264 | + content, | |
| 265 | + confirmText: '确定', | |
| 266 | + cancelText: '取消', | |
| 267 | + success: res => { | |
| 268 | + if (!res || !res.confirm) return | |
| 269 | + uni.showLoading({ title: loading, mask: true }) | |
| 270 | + Promise.resolve(run(this.id)) | |
| 271 | + .then(() => { | |
| 272 | + uni.hideLoading() | |
| 273 | + uni.showToast({ title: successText, icon: 'none' }) | |
| 274 | + this.refreshListFlags() | |
| 275 | + this.loadDetail() | |
| 276 | + }) | |
| 277 | + .catch(e => { | |
| 278 | + uni.hideLoading() | |
| 279 | + uni.showToast({ title: (e && (e.msg || e.message)) || failText, icon: 'none' }) | |
| 280 | + }) | |
| 281 | + } | |
| 282 | + }) | |
| 283 | + }, | |
| 284 | + onInvalid() { | |
| 285 | + this.runWithConfirm({ | |
| 286 | + title: '作废确认', | |
| 287 | + content: '继续作废则对关联结算详情单作废,是否继续?', | |
| 288 | + loading: '处理中', | |
| 289 | + successText: '作废成功', | |
| 290 | + failText: '作废失败', | |
| 291 | + run: id => assayReportInvalidApi(id) | |
| 292 | + }) | |
| 293 | + }, | |
| 294 | + onSubmitAudit() { | |
| 295 | + this.runWithConfirm({ | |
| 296 | + title: '提交审核确认', | |
| 297 | + content: '确认提交审核吗?', | |
| 298 | + loading: '提交中', | |
| 299 | + successText: '提交审核成功', | |
| 300 | + failText: '提交审核失败', | |
| 301 | + run: id => assayReportSubmitAuditApi(id) | |
| 302 | + }) | |
| 303 | + }, | |
| 304 | + onCancel() { | |
| 305 | + this.runWithConfirm({ | |
| 306 | + title: '取消确认', | |
| 307 | + content: '确认取消该原料化验报告单吗?', | |
| 308 | + loading: '处理中', | |
| 309 | + successText: '取消成功', | |
| 310 | + failText: '取消失败', | |
| 311 | + run: id => assayReportCancelApi(id) | |
| 312 | + }) | |
| 313 | + }, | |
| 314 | + safeText(v) { | |
| 315 | + const s = v == null ? '' : String(v) | |
| 316 | + return s.trim() ? s : '-' | |
| 317 | + }, | |
| 318 | + formatNumber(v) { | |
| 319 | + if (v === null || v === undefined || v === '') return '-' | |
| 320 | + const n = Number(v) | |
| 321 | + if (isNaN(n)) return String(v) | |
| 322 | + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 }) | |
| 323 | + } | |
| 324 | + } | |
| 325 | +} | |
| 326 | +</script> | |
| 327 | + | |
| 328 | +<style lang="scss" scoped> | |
| 329 | +.page { | |
| 330 | + display: flex; | |
| 331 | + flex-direction: column; | |
| 332 | + height: 100%; | |
| 333 | +} | |
| 334 | +.scroll { | |
| 335 | + flex: 1; | |
| 336 | + padding: 8rpx 0 144rpx; | |
| 337 | +} | |
| 338 | +.detail-page { | |
| 339 | + background: #f3f3f3; | |
| 340 | +} | |
| 341 | +.section { | |
| 342 | + padding: 32rpx; | |
| 343 | + background: #fff; | |
| 344 | + margin-bottom: 20rpx; | |
| 345 | +} | |
| 346 | +.row { | |
| 347 | + display: flex; | |
| 348 | + margin-bottom: 28rpx; | |
| 349 | + &:last-child { margin-bottom: 0; } | |
| 350 | + &.company { | |
| 351 | + font-size: 36rpx; | |
| 352 | + font-weight: 600; | |
| 353 | + color: rgba(0, 0, 0, 0.9); | |
| 354 | + padding-top: 8rpx; | |
| 355 | + line-height: 50rpx; | |
| 356 | + } | |
| 357 | + .label { | |
| 358 | + max-width: 420rpx; | |
| 359 | + margin-right: 20rpx; | |
| 360 | + line-height: 32rpx; | |
| 361 | + font-size: 28rpx; | |
| 362 | + color: rgba(0, 0, 0, 0.6); | |
| 363 | + } | |
| 364 | + .value { | |
| 365 | + flex: 1; | |
| 366 | + line-height: 32rpx; | |
| 367 | + font-size: 28rpx; | |
| 368 | + color: rgba(0, 0, 0, 0.9); | |
| 369 | + text-align: right; | |
| 370 | + word-break: break-all; | |
| 371 | + } | |
| 372 | +} | |
| 373 | +.sub-table { | |
| 374 | + background: #fff; | |
| 375 | + margin-bottom: 20rpx; | |
| 376 | +} | |
| 377 | +.sub-header { | |
| 378 | + display: flex; | |
| 379 | + align-items: center; | |
| 380 | + padding: 16rpx 0 16rpx 32rpx; | |
| 381 | + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; } | |
| 382 | + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; } | |
| 383 | + .sub-toggle { | |
| 384 | + display: flex; | |
| 385 | + align-items: center; | |
| 386 | + padding: 0 12rpx; | |
| 387 | + height: 56rpx; | |
| 388 | + .sub-toggle_icon { width: 24rpx; height: 24rpx; margin-right: 8rpx; } | |
| 389 | + .sub-toggle_text { font-size: 26rpx; color: rgba(0, 0, 0, 0.6); } | |
| 390 | + } | |
| 391 | +} | |
| 392 | +.sub-body { | |
| 393 | + padding: 0 32rpx 24rpx; | |
| 394 | + .empty-tip { | |
| 395 | + text-align: center; | |
| 396 | + padding: 60rpx 0; | |
| 397 | + color: rgba(0, 0, 0, 0.4); | |
| 398 | + font-size: 28rpx; | |
| 399 | + } | |
| 400 | + .card { | |
| 401 | + position: relative; | |
| 402 | + background: #fafafa; | |
| 403 | + border-radius: 12rpx; | |
| 404 | + padding: 32rpx 28rpx 20rpx; | |
| 405 | + margin-bottom: 24rpx; | |
| 406 | + .card-index { | |
| 407 | + position: absolute; | |
| 408 | + top: 0; | |
| 409 | + right: 0; | |
| 410 | + background: rgba(24, 144, 255, 0.08); | |
| 411 | + color: $theme-primary; | |
| 412 | + font-size: 22rpx; | |
| 413 | + line-height: 36rpx; | |
| 414 | + padding: 0 16rpx; | |
| 415 | + border-bottom-left-radius: 12rpx; | |
| 416 | + border-top-right-radius: 12rpx; | |
| 417 | + } | |
| 418 | + .row { | |
| 419 | + align-items: center; | |
| 420 | + justify-content: space-between; | |
| 421 | + padding: 14rpx 0; | |
| 422 | + margin-bottom: 0; | |
| 423 | + border-bottom: 1rpx dashed #f2f2f2; | |
| 424 | + &:last-child { border-bottom: none; } | |
| 425 | + .label { | |
| 426 | + flex-shrink: 0; | |
| 427 | + width: 220rpx; | |
| 428 | + max-width: none; | |
| 429 | + margin-right: 0; | |
| 430 | + font-size: 28rpx; | |
| 431 | + color: rgba(0, 0, 0, 0.6); | |
| 432 | + line-height: 40rpx; | |
| 433 | + } | |
| 434 | + .value { | |
| 435 | + flex: 1; | |
| 436 | + text-align: right; | |
| 437 | + font-size: 28rpx; | |
| 438 | + color: rgba(0, 0, 0, 0.9); | |
| 439 | + line-height: 40rpx; | |
| 440 | + overflow: hidden; | |
| 441 | + text-overflow: ellipsis; | |
| 442 | + white-space: nowrap; | |
| 443 | + } | |
| 444 | + } | |
| 445 | + } | |
| 446 | +} | |
| 447 | +</style> | ... | ... |
pages/material-test/index.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <view class="ticket-list-fixed"> | |
| 4 | + <view class="search-row"> | |
| 5 | + <uni-search-bar | |
| 6 | + v-model="searchKeyword" | |
| 7 | + radius="6" | |
| 8 | + placeholder="请输入码单编号" | |
| 9 | + clearButton="auto" | |
| 10 | + cancelButton="none" | |
| 11 | + bgColor="#F3F3F3" | |
| 12 | + textColor="rgba(0,0,0,0.4)" | |
| 13 | + @confirm="search" | |
| 14 | + @input="onSearchInput" | |
| 15 | + /> | |
| 16 | + <view class="tool-icons"> | |
| 17 | + <image | |
| 18 | + v-if="$auth.hasPermi('warehouse-manage:material-test:add')" | |
| 19 | + class="tool-icon" | |
| 20 | + src="/static/images/dev_manage/add_icon.png" | |
| 21 | + @click="onAdd" | |
| 22 | + /> | |
| 23 | + <image class="tool-icon" src="/static/images/dev_manage/filter_icon.png" @click="openFilter" /> | |
| 24 | + </view> | |
| 25 | + </view> | |
| 26 | + | |
| 27 | + <view class="tabs"> | |
| 28 | + <view | |
| 29 | + v-for="(t, i) in tabs" | |
| 30 | + :key="i" | |
| 31 | + :class="['tab', { active: deleted === t.value }]" | |
| 32 | + @click="switchTab(t)" | |
| 33 | + > | |
| 34 | + {{ t.label }} | |
| 35 | + </view> | |
| 36 | + </view> | |
| 37 | + </view> | |
| 38 | + | |
| 39 | + <view class="list-box"> | |
| 40 | + <card-list | |
| 41 | + ref="cardRef" | |
| 42 | + :fetch-fn="fetchList" | |
| 43 | + :query="query" | |
| 44 | + :extra="extraParams" | |
| 45 | + row-key="id" | |
| 46 | + :enable-refresh="true" | |
| 47 | + :enable-load-more="true" | |
| 48 | + @loaded="onCardLoaded" | |
| 49 | + @error="onCardError" | |
| 50 | + > | |
| 51 | + <template v-slot="{ item }"> | |
| 52 | + <view class="card" @click="onCardClick(item)"> | |
| 53 | + <view class="card-header"> | |
| 54 | + <text class="title omit2">{{ item.weighingTicketCode || '-' }}</text> | |
| 55 | + <text :class="['status', `status_${item.approvalStatus}`]">{{ getAuditStatusText(item.approvalStatus) }}</text> | |
| 56 | + </view> | |
| 57 | + <view class="info-row"> | |
| 58 | + <text>日期</text> | |
| 59 | + <text>{{ formatDateOnly(item.reportDate) }}</text> | |
| 60 | + </view> | |
| 61 | + <view class="info-row"> | |
| 62 | + <text>客户名称</text> | |
| 63 | + <text>{{ item.supplierName || '-' }}</text> | |
| 64 | + </view> | |
| 65 | + <view class="info-row"> | |
| 66 | + <text>分厂</text> | |
| 67 | + <text>{{ item.workshopName || '-' }}</text> | |
| 68 | + </view> | |
| 69 | + <view class="info-row"> | |
| 70 | + <text>流程节点</text> | |
| 71 | + <text>{{ getFlowNodeText(item.flowNode) }}</text> | |
| 72 | + </view> | |
| 73 | + <view class="info-row"> | |
| 74 | + <text>创建人</text> | |
| 75 | + <text>{{ item.createBy || '-' }}</text> | |
| 76 | + </view> | |
| 77 | + <view class="info-row"> | |
| 78 | + <text>创建时间</text> | |
| 79 | + <text>{{ item.createTime || '-' }}</text> | |
| 80 | + </view> | |
| 81 | + </view> | |
| 82 | + </template> | |
| 83 | + </card-list> | |
| 84 | + </view> | |
| 85 | + | |
| 86 | + <filter-modal | |
| 87 | + :visible.sync="filterVisible" | |
| 88 | + :value.sync="filterForm" | |
| 89 | + title="筛选" | |
| 90 | + @reset="onFilterReset" | |
| 91 | + @confirm="onFilterConfirm" | |
| 92 | + > | |
| 93 | + <template v-slot="{ model }"> | |
| 94 | + <view class="filter-form"> | |
| 95 | + <view class="form-item"> | |
| 96 | + <view class="label">码单编号</view> | |
| 97 | + <input class="input" v-model="model.weighingTicketCode" placeholder="请输入码单编号" /> | |
| 98 | + </view> | |
| 99 | + <view class="form-item"> | |
| 100 | + <view class="label">日期</view> | |
| 101 | + <uni-datetime-picker type="daterange" v-model="model.reportDateRange" start="2023-01-01" /> | |
| 102 | + </view> | |
| 103 | + <view class="form-item"> | |
| 104 | + <view class="label">客户名称</view> | |
| 105 | + <input class="input" v-model="model.supplierName" placeholder="请输入客户名称" /> | |
| 106 | + </view> | |
| 107 | + <view class="form-item"> | |
| 108 | + <view class="label">分厂</view> | |
| 109 | + <picker mode="selector" :range="workshopLabels" @change="onWorkshopChange"> | |
| 110 | + <view class="fake-select"> | |
| 111 | + <text v-if="workshopLabel" class="value">{{ workshopLabel }}</text> | |
| 112 | + <text v-else class="placeholder">请选择分厂</text> | |
| 113 | + </view> | |
| 114 | + </picker> | |
| 115 | + </view> | |
| 116 | + <view class="form-item"> | |
| 117 | + <view class="label">审核状态</view> | |
| 118 | + <uni-data-checkbox | |
| 119 | + mode="tag" | |
| 120 | + :multiple="false" | |
| 121 | + :value-field="'value'" | |
| 122 | + :text-field="'text'" | |
| 123 | + v-model="model.approvalStatus" | |
| 124 | + :localdata="approvalStatusOptions" | |
| 125 | + /> | |
| 126 | + </view> | |
| 127 | + <view class="form-item"> | |
| 128 | + <view class="label">流程节点</view> | |
| 129 | + <picker mode="selector" :range="flowNodeLabels" @change="onFlowNodeChange"> | |
| 130 | + <view class="fake-select"> | |
| 131 | + <text v-if="flowNodeLabel" class="value">{{ flowNodeLabel }}</text> | |
| 132 | + <text v-else class="placeholder">请选择流程节点</text> | |
| 133 | + </view> | |
| 134 | + </picker> | |
| 135 | + </view> | |
| 136 | + <view class="form-item"> | |
| 137 | + <view class="label">创建人</view> | |
| 138 | + <input class="input" v-model="model.createBy" placeholder="请输入创建人" /> | |
| 139 | + </view> | |
| 140 | + <view class="form-item"> | |
| 141 | + <view class="label">创建时间</view> | |
| 142 | + <uni-datetime-picker type="daterange" v-model="model.createDateRange" start="2023-01-01" /> | |
| 143 | + </view> | |
| 144 | + </view> | |
| 145 | + </template> | |
| 146 | + </filter-modal> | |
| 147 | + </view> | |
| 148 | +</template> | |
| 149 | + | |
| 150 | +<script> | |
| 151 | +import CardList from '@/components/card/index.vue' | |
| 152 | +import FilterModal from '@/components/filter/index.vue' | |
| 153 | +import { getDicByCodes, getDicName } from '@/utils/dic.js' | |
| 154 | +import { assayReportQueryApi, workshopQueryApi } from '@/api/procure-manage/assayReport.js' | |
| 155 | + | |
| 156 | +export default { | |
| 157 | + name: 'MaterialTestList', | |
| 158 | + components: { CardList, FilterModal }, | |
| 159 | + data() { | |
| 160 | + return { | |
| 161 | + searchKeyword: '', | |
| 162 | + searchKeywordDebounced: '', | |
| 163 | + searchDebounceTimer: null, | |
| 164 | + deleted: false, | |
| 165 | + tabs: [ | |
| 166 | + { label: '有效', value: false }, | |
| 167 | + { label: '作废', value: true } | |
| 168 | + ], | |
| 169 | + query: { | |
| 170 | + weighingTicketCode: '', | |
| 171 | + reportDateRange: [], | |
| 172 | + supplierName: '', | |
| 173 | + workshopId: '', | |
| 174 | + approvalStatus: '', | |
| 175 | + flowNode: '', | |
| 176 | + createBy: '', | |
| 177 | + createDateRange: [] | |
| 178 | + }, | |
| 179 | + extraParams: {}, | |
| 180 | + currentItems: [], | |
| 181 | + filterVisible: false, | |
| 182 | + filterForm: { | |
| 183 | + weighingTicketCode: '', | |
| 184 | + reportDateRange: [], | |
| 185 | + supplierName: '', | |
| 186 | + workshopId: '', | |
| 187 | + approvalStatus: '', | |
| 188 | + flowNode: '', | |
| 189 | + createBy: '', | |
| 190 | + createDateRange: [] | |
| 191 | + }, | |
| 192 | + approvalStatusOptions: [ | |
| 193 | + { value: '', text: '全部' }, | |
| 194 | + { value: 'DRAFT', text: '草稿' }, | |
| 195 | + { value: 'AUDIT', text: '审核中' }, | |
| 196 | + { value: 'PASS', text: '审核通过' }, | |
| 197 | + { value: 'REFUSE', text: '已驳回' }, | |
| 198 | + { value: 'CANCEL', text: '已取消' } | |
| 199 | + ], | |
| 200 | + workshopOptions: [], | |
| 201 | + workshopLabel: '', | |
| 202 | + flowNodeLabel: '', | |
| 203 | + dicOptions: { | |
| 204 | + AUDIT_STATUS: [], | |
| 205 | + FLOW_NODE: [] | |
| 206 | + } | |
| 207 | + } | |
| 208 | + }, | |
| 209 | + computed: { | |
| 210 | + workshopLabels() { | |
| 211 | + return ['全部'].concat(this.workshopOptions.map(it => it.label)) | |
| 212 | + }, | |
| 213 | + flowNodeLabels() { | |
| 214 | + return ['全部'].concat((this.dicOptions.FLOW_NODE || []).map(it => it.name)) | |
| 215 | + }, | |
| 216 | + extraCombined() { | |
| 217 | + return { | |
| 218 | + keyword: this.searchKeywordDebounced || undefined, | |
| 219 | + deleted: this.deleted | |
| 220 | + } | |
| 221 | + } | |
| 222 | + }, | |
| 223 | + watch: { | |
| 224 | + extraCombined: { | |
| 225 | + deep: true, | |
| 226 | + handler(v) { | |
| 227 | + this.extraParams = v | |
| 228 | + }, | |
| 229 | + immediate: true | |
| 230 | + } | |
| 231 | + }, | |
| 232 | + created() { | |
| 233 | + this.loadDicData() | |
| 234 | + this.loadWorkshopOptions() | |
| 235 | + }, | |
| 236 | + onShow() { | |
| 237 | + let needRefresh = '' | |
| 238 | + try { needRefresh = uni.getStorageSync('MATERIAL_TEST_LIST_NEED_REFRESH') } catch (e) {} | |
| 239 | + if (!needRefresh) return | |
| 240 | + try { uni.removeStorageSync('MATERIAL_TEST_LIST_NEED_REFRESH') } catch (e) {} | |
| 241 | + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.reload) { | |
| 242 | + this.$refs.cardRef.reload() | |
| 243 | + } | |
| 244 | + }, | |
| 245 | + onReachBottom() { | |
| 246 | + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.onLoadMore) { | |
| 247 | + this.$refs.cardRef.onLoadMore() | |
| 248 | + } | |
| 249 | + }, | |
| 250 | + beforeDestroy() { | |
| 251 | + if (this.searchDebounceTimer) { | |
| 252 | + clearTimeout(this.searchDebounceTimer) | |
| 253 | + this.searchDebounceTimer = null | |
| 254 | + } | |
| 255 | + }, | |
| 256 | + methods: { | |
| 257 | + async loadDicData() { | |
| 258 | + try { | |
| 259 | + const results = await getDicByCodes(['AUDIT_STATUS', 'FLOW_NODE']) | |
| 260 | + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || [] | |
| 261 | + this.dicOptions.FLOW_NODE = (results.FLOW_NODE && results.FLOW_NODE.data) || [] | |
| 262 | + } catch (e) { | |
| 263 | + this.dicOptions = { AUDIT_STATUS: [], FLOW_NODE: [] } | |
| 264 | + } | |
| 265 | + }, | |
| 266 | + // 加载分厂下拉数据(PC: base-data/maker 页面数据) | |
| 267 | + async loadWorkshopOptions() { | |
| 268 | + try { | |
| 269 | + const res = await workshopQueryApi({ pageIndex: 1, pageSize: 9999 }) | |
| 270 | + const datas = (res && res.data && res.data.datas) || [] | |
| 271 | + this.workshopOptions = datas.map(item => ({ | |
| 272 | + label: item.name || '', | |
| 273 | + value: item.id || '' | |
| 274 | + })).filter(it => it.value) | |
| 275 | + } catch (e) { | |
| 276 | + this.workshopOptions = [] | |
| 277 | + } | |
| 278 | + }, | |
| 279 | + getAuditStatusText(status) { | |
| 280 | + const v = status == null ? '' : String(status) | |
| 281 | + if (!v) return '-' | |
| 282 | + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v | |
| 283 | + }, | |
| 284 | + getFlowNodeText(node) { | |
| 285 | + const v = node == null ? '' : String(node) | |
| 286 | + if (!v) return '-' | |
| 287 | + return getDicName('FLOW_NODE', v, this.dicOptions.FLOW_NODE) || v | |
| 288 | + }, | |
| 289 | + formatDateOnly(v) { | |
| 290 | + const s = v == null ? '' : String(v).trim() | |
| 291 | + if (!s) return '-' | |
| 292 | + if (s.length >= 10) return s.slice(0, 10) | |
| 293 | + return s | |
| 294 | + }, | |
| 295 | + onCardLoaded({ items }) { | |
| 296 | + this.currentItems = items | |
| 297 | + }, | |
| 298 | + onCardError() { | |
| 299 | + uni.showToast({ title: '列表加载失败', icon: 'none' }) | |
| 300 | + }, | |
| 301 | + onAdd() { | |
| 302 | + uni.navigateTo({ url: '/pages/material-test/add' }) | |
| 303 | + }, | |
| 304 | + onSearchInput() { | |
| 305 | + if (this.searchDebounceTimer) clearTimeout(this.searchDebounceTimer) | |
| 306 | + this.searchDebounceTimer = setTimeout(() => { | |
| 307 | + this.searchKeywordDebounced = this.searchKeyword | |
| 308 | + this.searchDebounceTimer = null | |
| 309 | + }, 1200) | |
| 310 | + }, | |
| 311 | + search(e) { | |
| 312 | + const val = e && e.value != null ? e.value : this.searchKeyword | |
| 313 | + this.searchKeyword = val | |
| 314 | + this.searchKeywordDebounced = val | |
| 315 | + }, | |
| 316 | + switchTab(t) { | |
| 317 | + this.deleted = t.value | |
| 318 | + }, | |
| 319 | + onWorkshopChange(e) { | |
| 320 | + const idx = Number(e.detail.value) | |
| 321 | + if (idx <= 0) { | |
| 322 | + this.filterForm.workshopId = '' | |
| 323 | + this.workshopLabel = '' | |
| 324 | + } else { | |
| 325 | + const opt = this.workshopOptions[idx - 1] | |
| 326 | + this.filterForm.workshopId = opt ? opt.value : '' | |
| 327 | + this.workshopLabel = opt ? opt.label : '' | |
| 328 | + } | |
| 329 | + }, | |
| 330 | + onFlowNodeChange(e) { | |
| 331 | + const idx = Number(e.detail.value) | |
| 332 | + if (idx <= 0) { | |
| 333 | + this.filterForm.flowNode = '' | |
| 334 | + this.flowNodeLabel = '' | |
| 335 | + } else { | |
| 336 | + const opt = (this.dicOptions.FLOW_NODE || [])[idx - 1] | |
| 337 | + this.filterForm.flowNode = opt ? opt.code : '' | |
| 338 | + this.flowNodeLabel = opt ? opt.name : '' | |
| 339 | + } | |
| 340 | + }, | |
| 341 | + openFilter() { | |
| 342 | + this.filterForm = { | |
| 343 | + weighingTicketCode: this.query.weighingTicketCode || '', | |
| 344 | + reportDateRange: Array.isArray(this.query.reportDateRange) ? this.query.reportDateRange.slice(0) : [], | |
| 345 | + supplierName: this.query.supplierName || '', | |
| 346 | + workshopId: this.query.workshopId || '', | |
| 347 | + approvalStatus: this.query.approvalStatus || '', | |
| 348 | + flowNode: this.query.flowNode || '', | |
| 349 | + createBy: this.query.createBy || '', | |
| 350 | + createDateRange: Array.isArray(this.query.createDateRange) ? this.query.createDateRange.slice(0) : [] | |
| 351 | + } | |
| 352 | + const found = this.workshopOptions.find(it => it.value === this.filterForm.workshopId) | |
| 353 | + this.workshopLabel = found ? found.label : '' | |
| 354 | + const node = (this.dicOptions.FLOW_NODE || []).find(it => it.code === this.filterForm.flowNode) | |
| 355 | + this.flowNodeLabel = node ? node.name : '' | |
| 356 | + this.filterVisible = true | |
| 357 | + }, | |
| 358 | + onFilterReset(payload) { | |
| 359 | + this.filterForm = payload | |
| 360 | + this.workshopLabel = '' | |
| 361 | + this.flowNodeLabel = '' | |
| 362 | + }, | |
| 363 | + onFilterConfirm(payload) { | |
| 364 | + this.query = { | |
| 365 | + weighingTicketCode: payload.weighingTicketCode || '', | |
| 366 | + reportDateRange: Array.isArray(payload.reportDateRange) ? payload.reportDateRange : [], | |
| 367 | + supplierName: payload.supplierName || '', | |
| 368 | + workshopId: payload.workshopId || '', | |
| 369 | + approvalStatus: payload.approvalStatus || '', | |
| 370 | + flowNode: payload.flowNode || '', | |
| 371 | + createBy: payload.createBy || '', | |
| 372 | + createDateRange: Array.isArray(payload.createDateRange) ? payload.createDateRange : [] | |
| 373 | + } | |
| 374 | + }, | |
| 375 | + fetchList({ pageIndex, pageSize, query, extra }) { | |
| 376 | + const q = query || {} | |
| 377 | + const e = extra || {} | |
| 378 | + const keyword = e.keyword || '' | |
| 379 | + const reportRange = Array.isArray(q.reportDateRange) ? q.reportDateRange : [] | |
| 380 | + const createRange = Array.isArray(q.createDateRange) ? q.createDateRange : [] | |
| 381 | + const params = { | |
| 382 | + pageIndex, | |
| 383 | + pageSize, | |
| 384 | + deleted: e.deleted === true, | |
| 385 | + weighingTicketCode: q.weighingTicketCode || keyword || '', | |
| 386 | + reportDateStart: reportRange && reportRange.length === 2 ? reportRange[0] : '', | |
| 387 | + reportDateEnd: reportRange && reportRange.length === 2 ? reportRange[1] : '', | |
| 388 | + supplierName: q.supplierName || '', | |
| 389 | + workshopId: q.workshopId || '', | |
| 390 | + approvalStatus: q.approvalStatus || '', | |
| 391 | + flowNode: q.flowNode || '', | |
| 392 | + createBy: q.createBy || '', | |
| 393 | + startTime: createRange && createRange.length === 2 ? createRange[0] + ' 00:00:00' : '', | |
| 394 | + endTime: createRange && createRange.length === 2 ? createRange[1] + ' 23:59:59' : '' | |
| 395 | + } | |
| 396 | + return assayReportQueryApi(params) | |
| 397 | + .then(res => { | |
| 398 | + const _data = (res && res.data) || {} | |
| 399 | + let records = _data.datas || _data.list || _data.records || [] | |
| 400 | + const totalCount = _data.totalCount || _data.count || 0 | |
| 401 | + const hasNext = _data.hasNext || false | |
| 402 | + records = records.map(it => ({ ...it })) | |
| 403 | + return { records, totalCount, hasNext } | |
| 404 | + }) | |
| 405 | + .catch(() => { | |
| 406 | + this.onCardError() | |
| 407 | + return { records: [], totalCount: 0, hasNext: false } | |
| 408 | + }) | |
| 409 | + }, | |
| 410 | + onCardClick(item) { | |
| 411 | + const id = item && item.id | |
| 412 | + if (!id) { | |
| 413 | + uni.showToast({ title: '缺少ID', icon: 'none' }) | |
| 414 | + return | |
| 415 | + } | |
| 416 | + uni.navigateTo({ url: '/pages/material-test/detail?id=' + id }) | |
| 417 | + } | |
| 418 | + } | |
| 419 | +} | |
| 420 | +</script> | |
| 421 | + | |
| 422 | +<style lang="scss" scoped> | |
| 423 | +.page { | |
| 424 | + display: flex; | |
| 425 | + flex-direction: column; | |
| 426 | + height: 100vh; | |
| 427 | +} | |
| 428 | +.ticket-list-fixed { | |
| 429 | + position: fixed; | |
| 430 | + top: 96rpx; | |
| 431 | + left: 0; | |
| 432 | + right: 0; | |
| 433 | + z-index: 2; | |
| 434 | + background: #fff; | |
| 435 | + border-bottom: solid 1px #e7e7e7; | |
| 436 | + .search-row { | |
| 437 | + display: flex; | |
| 438 | + align-items: center; | |
| 439 | + padding: 16rpx 32rpx; | |
| 440 | + .uni-searchbar { padding: 0; flex: 1; } | |
| 441 | + .tool-icons { | |
| 442 | + display: flex; | |
| 443 | + .tool-icon { width: 48rpx; height: 48rpx; display: block; margin-left: 32rpx; } | |
| 444 | + } | |
| 445 | + } | |
| 446 | + .tabs { | |
| 447 | + display: flex; | |
| 448 | + align-items: center; | |
| 449 | + justify-content: space-between; | |
| 450 | + padding: 26rpx 34rpx; | |
| 451 | + border-bottom: solid 1px #e7e7e7; | |
| 452 | + .tab { width: 50%; text-align: center; color: rgba(0, 0, 0, 0.9); line-height: 44rpx; position: relative; font-weight: 600; } | |
| 453 | + .tab.active { color: $theme-primary; } | |
| 454 | + .tab.active::after { | |
| 455 | + content: ''; | |
| 456 | + position: absolute; | |
| 457 | + left: 50%; | |
| 458 | + transform: translateX(-50%); | |
| 459 | + bottom: -13px; | |
| 460 | + width: 32rpx; | |
| 461 | + height: 6rpx; | |
| 462 | + border-radius: 4rpx; | |
| 463 | + background: $theme-primary; | |
| 464 | + } | |
| 465 | + } | |
| 466 | +} | |
| 467 | +::v-deep .uni-searchbar__box { | |
| 468 | + height: 80rpx !important; | |
| 469 | + justify-content: start; | |
| 470 | + .uni-searchbar__box-search-input { font-size: 32rpx !important; } | |
| 471 | +} | |
| 472 | +.list-box { | |
| 473 | + flex: 1; | |
| 474 | + padding-top: 236rpx; | |
| 475 | + .card { position: relative; } | |
| 476 | + .card-header { | |
| 477 | + margin-bottom: 28rpx; | |
| 478 | + position: relative; | |
| 479 | + .title { font-size: 36rpx; font-weight: 600; line-height: 50rpx; color: rgba(0, 0, 0, 0.9); width: 578rpx; } | |
| 480 | + .status { | |
| 481 | + position: absolute; | |
| 482 | + top: -32rpx; | |
| 483 | + right: -12rpx; | |
| 484 | + height: 48rpx; | |
| 485 | + line-height: 48rpx; | |
| 486 | + font-weight: 600; | |
| 487 | + color: #fff; | |
| 488 | + font-size: 24rpx; | |
| 489 | + padding: 0 14rpx; | |
| 490 | + border-radius: 6rpx; | |
| 491 | + box-sizing: content-box; | |
| 492 | + | |
| 493 | + &.status_AUDIT { background: $theme-primary; } | |
| 494 | + &.status_PASS { background: #2ba471; } | |
| 495 | + &.status_REFUSE { background: #d54941; } | |
| 496 | + &.status_DRAFT { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); } | |
| 497 | + &.status_CANCEL { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); } | |
| 498 | + } | |
| 499 | + } | |
| 500 | + .info-row { | |
| 501 | + display: flex; | |
| 502 | + align-items: center; | |
| 503 | + color: rgba(0, 0, 0, 0.6); | |
| 504 | + font-size: 28rpx; | |
| 505 | + margin-bottom: 24rpx; | |
| 506 | + height: 32rpx; | |
| 507 | + &:last-child { margin-bottom: 0; } | |
| 508 | + text { | |
| 509 | + width: 50%; | |
| 510 | + &:last-child { | |
| 511 | + color: rgba(0, 0, 0, 0.9); | |
| 512 | + width: 50%; | |
| 513 | + overflow: hidden; | |
| 514 | + text-overflow: ellipsis; | |
| 515 | + white-space: nowrap; | |
| 516 | + } | |
| 517 | + } | |
| 518 | + } | |
| 519 | +} | |
| 520 | +.filter-form { | |
| 521 | + .form-item { margin-bottom: 24rpx; } | |
| 522 | + .label { margin-bottom: 20rpx; color: rgba(0, 0, 0, 0.9); height: 44rpx; line-height: 44rpx; font-size: 30rpx; } | |
| 523 | + .input { | |
| 524 | + width: 100%; | |
| 525 | + height: 72rpx; | |
| 526 | + line-height: 72rpx; | |
| 527 | + padding: 0 24rpx; | |
| 528 | + border: 1rpx solid #e7e7e7; | |
| 529 | + border-radius: 8rpx; | |
| 530 | + font-size: 28rpx; | |
| 531 | + color: rgba(0, 0, 0, 0.9); | |
| 532 | + background: #fff; | |
| 533 | + box-sizing: border-box; | |
| 534 | + } | |
| 535 | + .fake-select { | |
| 536 | + height: 72rpx; | |
| 537 | + line-height: 72rpx; | |
| 538 | + padding: 0 24rpx; | |
| 539 | + border: 1rpx solid #e7e7e7; | |
| 540 | + border-radius: 8rpx; | |
| 541 | + font-size: 28rpx; | |
| 542 | + .placeholder { color: #999; } | |
| 543 | + .value { color: rgba(0, 0, 0, 0.9); } | |
| 544 | + } | |
| 545 | +} | |
| 546 | +</style> | ... | ... |
pages/material-test/materialTestViewer.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="detail-page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <!-- 基础信息 --> | |
| 5 | + <view class="section"> | |
| 6 | + <text class="row company">{{ safeText(form.weighingTicketCode) }}</text> | |
| 7 | + <view class="row"><text class="label">日期</text><text class="value">{{ safeText(form.reportDate) }}</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.workshopName) }}</text></view> | |
| 10 | + <view class="row"><text class="label">计划编号</text><text class="value">{{ safeText(form.planCode) }}</text></view> | |
| 11 | + <view class="row"><text class="label">过磅品种</text><text class="value">{{ safeText(form.productName) }}</text></view> | |
| 12 | + <view class="row"><text class="label">审核状态</text><text class="value">{{ approvalStatusName }}</text></view> | |
| 13 | + <view class="row"><text class="label">流程节点</text><text class="value">{{ flowNodeName }}</text></view> | |
| 14 | + <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view> | |
| 15 | + <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view> | |
| 16 | + </view> | |
| 17 | + | |
| 18 | + <!-- 化验明细(只读) --> | |
| 19 | + <view class="sub-table"> | |
| 20 | + <view class="sub-header"> | |
| 21 | + <image class="sub-bar" src="/static/images/title.png" /> | |
| 22 | + <text class="sub-title">化验明细</text> | |
| 23 | + </view> | |
| 24 | + <view class="sub-body"> | |
| 25 | + <view v-if="!lines.length" class="empty-tip">暂无明细</view> | |
| 26 | + <view v-for="(item, idx) in lineRows" :key="'l-' + (item.assayApplyId || idx)" class="card"> | |
| 27 | + <view class="card-index">第 {{ idx + 1 }} 行</view> | |
| 28 | + <view class="row"><text class="label">样品</text><text class="value">{{ safeText(item.productName) }}</text></view> | |
| 29 | + <view class="row"><text class="label">数量</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> | |
| 30 | + <view class="row"><text class="label">样号</text><text class="value">{{ safeText(item.testCode) }}</text></view> | |
| 31 | + <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> | |
| 32 | + <view v-for="key in componentKeys" :key="key" class="row"> | |
| 33 | + <text class="label">{{ componentLabels[key] || key }}</text> | |
| 34 | + <text class="value">{{ formatNumber(item[key]) }}</text> | |
| 35 | + </view> | |
| 36 | + </view> | |
| 37 | + </view> | |
| 38 | + </view> | |
| 39 | + </scroll-view> | |
| 40 | + </view> | |
| 41 | +</template> | |
| 42 | + | |
| 43 | +<script> | |
| 44 | +import { getDicByCodes, getDicName } from '@/utils/dic.js' | |
| 45 | +import { COMPONENT_LABELS, getComponentKeys } from './component-config.js' | |
| 46 | +import { assayReportDetailApi } from '@/api/procure-manage/assayReport.js' | |
| 47 | + | |
| 48 | +export default { | |
| 49 | + name: 'MaterialTestViewer', | |
| 50 | + props: { id: { type: [String, Number], default: '' } }, | |
| 51 | + data() { | |
| 52 | + return { | |
| 53 | + form: {}, | |
| 54 | + lines: [], | |
| 55 | + componentLabels: COMPONENT_LABELS, | |
| 56 | + dicOptions: { | |
| 57 | + AUDIT_STATUS: [], | |
| 58 | + FLOW_NODE: [] | |
| 59 | + } | |
| 60 | + } | |
| 61 | + }, | |
| 62 | + computed: { | |
| 63 | + componentKeys() { | |
| 64 | + return getComponentKeys(this.form.workshopName) | |
| 65 | + }, | |
| 66 | + approvalStatusName() { | |
| 67 | + const v = this.form.approvalStatus == null ? '' : String(this.form.approvalStatus) | |
| 68 | + if (!v) return '-' | |
| 69 | + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v | |
| 70 | + }, | |
| 71 | + flowNodeName() { | |
| 72 | + const v = this.form.flowNode == null ? '' : String(this.form.flowNode) | |
| 73 | + if (!v) return '-' | |
| 74 | + return getDicName('FLOW_NODE', v, this.dicOptions.FLOW_NODE) || v | |
| 75 | + }, | |
| 76 | + // 化验明细展示行(样号按行序编号展示) | |
| 77 | + lineRows() { | |
| 78 | + return (this.lines || []).map((item, index) => ({ | |
| 79 | + ...item, | |
| 80 | + testCode: item.testCode || String(index + 1) | |
| 81 | + })) | |
| 82 | + } | |
| 83 | + }, | |
| 84 | + created() { | |
| 85 | + this.loadDicData() | |
| 86 | + }, | |
| 87 | + watch: { | |
| 88 | + id: { | |
| 89 | + immediate: true, | |
| 90 | + handler(val) { | |
| 91 | + const v = (val !== undefined && val !== null) ? String(val) : '' | |
| 92 | + if (v) this.loadDetail(v) | |
| 93 | + } | |
| 94 | + } | |
| 95 | + }, | |
| 96 | + methods: { | |
| 97 | + async loadDicData() { | |
| 98 | + try { | |
| 99 | + const results = await getDicByCodes(['AUDIT_STATUS', 'FLOW_NODE']) | |
| 100 | + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || [] | |
| 101 | + this.dicOptions.FLOW_NODE = (results.FLOW_NODE && results.FLOW_NODE.data) || [] | |
| 102 | + } catch (e) { | |
| 103 | + this.dicOptions = { AUDIT_STATUS: [], FLOW_NODE: [] } | |
| 104 | + } | |
| 105 | + }, | |
| 106 | + // 按业务 id 加载化验报告单详情 | |
| 107 | + loadDetail(id) { | |
| 108 | + assayReportDetailApi({ id }) | |
| 109 | + .then(res => { | |
| 110 | + const data = (res && res.data) || {} | |
| 111 | + this.form = Object.assign({}, data) | |
| 112 | + this.lines = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : [] | |
| 113 | + }) | |
| 114 | + .catch(() => { | |
| 115 | + uni.showToast({ title: '详情加载失败', icon: 'none' }) | |
| 116 | + }) | |
| 117 | + }, | |
| 118 | + // 供审批页通过时取业务表单数据(variables,对齐 PC 端 viewer.vue getFormData) | |
| 119 | + getFormValues() { | |
| 120 | + return Object.assign({}, this.form) | |
| 121 | + }, | |
| 122 | + // 审批表单只读,无需校验 | |
| 123 | + checkForm() { | |
| 124 | + return true | |
| 125 | + }, | |
| 126 | + safeText(v) { | |
| 127 | + const s = v == null ? '' : String(v) | |
| 128 | + return s.trim() ? s : '-' | |
| 129 | + }, | |
| 130 | + formatNumber(v) { | |
| 131 | + if (v === null || v === undefined || v === '') return '-' | |
| 132 | + const n = Number(v) | |
| 133 | + if (isNaN(n)) return String(v) | |
| 134 | + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 }) | |
| 135 | + } | |
| 136 | + } | |
| 137 | +} | |
| 138 | +</script> | |
| 139 | + | |
| 140 | +<style lang="scss" scoped> | |
| 141 | +.detail-page { | |
| 142 | + background: #f3f3f3; | |
| 143 | + min-height: 100%; | |
| 144 | +} | |
| 145 | +.scroll { | |
| 146 | + height: 100%; | |
| 147 | +} | |
| 148 | +.section { | |
| 149 | + padding: 32rpx; | |
| 150 | + background: #fff; | |
| 151 | + margin-bottom: 20rpx; | |
| 152 | +} | |
| 153 | +.row { | |
| 154 | + display: flex; | |
| 155 | + margin-bottom: 28rpx; | |
| 156 | + | |
| 157 | + &:last-child { | |
| 158 | + margin-bottom: 0; | |
| 159 | + } | |
| 160 | + | |
| 161 | + &.company { | |
| 162 | + font-size: 36rpx; | |
| 163 | + font-weight: 600; | |
| 164 | + color: rgba(0, 0, 0, 0.9); | |
| 165 | + padding-top: 8rpx; | |
| 166 | + line-height: 50rpx; | |
| 167 | + } | |
| 168 | + | |
| 169 | + .label { | |
| 170 | + max-width: 420rpx; | |
| 171 | + margin-right: 20rpx; | |
| 172 | + line-height: 32rpx; | |
| 173 | + font-size: 28rpx; | |
| 174 | + color: rgba(0, 0, 0, 0.6); | |
| 175 | + } | |
| 176 | + | |
| 177 | + .value { | |
| 178 | + flex: 1; | |
| 179 | + line-height: 32rpx; | |
| 180 | + font-size: 28rpx; | |
| 181 | + color: rgba(0, 0, 0, 0.9); | |
| 182 | + text-align: right; | |
| 183 | + word-break: break-all; | |
| 184 | + } | |
| 185 | +} | |
| 186 | +.sub-table { | |
| 187 | + background: #fff; | |
| 188 | + margin-bottom: 20rpx; | |
| 189 | +} | |
| 190 | +.sub-header { | |
| 191 | + display: flex; | |
| 192 | + align-items: center; | |
| 193 | + padding: 16rpx 0 16rpx 32rpx; | |
| 194 | + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; } | |
| 195 | + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; } | |
| 196 | +} | |
| 197 | +.sub-body { | |
| 198 | + padding: 0 32rpx 24rpx; | |
| 199 | + .empty-tip { | |
| 200 | + text-align: center; | |
| 201 | + padding: 60rpx 0; | |
| 202 | + color: rgba(0, 0, 0, 0.4); | |
| 203 | + font-size: 28rpx; | |
| 204 | + } | |
| 205 | + .card { | |
| 206 | + position: relative; | |
| 207 | + background: #fafafa; | |
| 208 | + border-radius: 12rpx; | |
| 209 | + padding: 32rpx 28rpx 20rpx; | |
| 210 | + margin-bottom: 24rpx; | |
| 211 | + .card-index { | |
| 212 | + position: absolute; | |
| 213 | + top: 0; | |
| 214 | + right: 0; | |
| 215 | + background: rgba(24, 144, 255, 0.08); | |
| 216 | + color: $theme-primary; | |
| 217 | + font-size: 22rpx; | |
| 218 | + line-height: 36rpx; | |
| 219 | + padding: 0 16rpx; | |
| 220 | + border-bottom-left-radius: 12rpx; | |
| 221 | + border-top-right-radius: 12rpx; | |
| 222 | + } | |
| 223 | + .row { | |
| 224 | + align-items: center; | |
| 225 | + justify-content: space-between; | |
| 226 | + padding: 14rpx 0; | |
| 227 | + margin-bottom: 0; | |
| 228 | + border-bottom: 1rpx dashed #f2f2f2; | |
| 229 | + &:last-child { border-bottom: none; } | |
| 230 | + .label { | |
| 231 | + flex-shrink: 0; | |
| 232 | + width: 220rpx; | |
| 233 | + max-width: none; | |
| 234 | + margin-right: 0; | |
| 235 | + font-size: 28rpx; | |
| 236 | + color: rgba(0, 0, 0, 0.6); | |
| 237 | + line-height: 40rpx; | |
| 238 | + } | |
| 239 | + .value { | |
| 240 | + flex: 1; | |
| 241 | + text-align: right; | |
| 242 | + font-size: 28rpx; | |
| 243 | + color: rgba(0, 0, 0, 0.9); | |
| 244 | + line-height: 40rpx; | |
| 245 | + overflow: hidden; | |
| 246 | + text-overflow: ellipsis; | |
| 247 | + white-space: nowrap; | |
| 248 | + } | |
| 249 | + } | |
| 250 | + } | |
| 251 | +} | |
| 252 | +</style> | ... | ... |
pages/material-test/modify.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <!-- 基础信息 --> | |
| 5 | + <uni-list> | |
| 6 | + <!-- 码单编号(弹窗选择) --> | |
| 7 | + <uni-list-item class="select-item" :class="form.weighingTicketCode ? 'is-filled' : 'is-empty'" clickable | |
| 8 | + @click="openTicketSheet" :rightText="form.weighingTicketCode || '请选择码单'" showArrow> | |
| 9 | + <template v-slot:body> | |
| 10 | + <view class="item-title"><text class="required">*</text><text>码单编号</text></view> | |
| 11 | + </template> | |
| 12 | + </uni-list-item> | |
| 13 | + | |
| 14 | + <!-- 日期(选择码单后带出) --> | |
| 15 | + <uni-list-item class="select-item" :class="form.reportDate ? 'is-filled' : 'is-empty'"> | |
| 16 | + <template v-slot:body> | |
| 17 | + <view class="item-title"><text class="required">*</text><text>日期</text></view> | |
| 18 | + </template> | |
| 19 | + <template v-slot:footer> | |
| 20 | + <view class="picker-value" :class="{ placeholder: !form.reportDate }"> | |
| 21 | + {{ form.reportDate || '选择码单后带出' }} | |
| 22 | + </view> | |
| 23 | + </template> | |
| 24 | + </uni-list-item> | |
| 25 | + | |
| 26 | + <!-- 客户名称(选择码单后带出) --> | |
| 27 | + <uni-list-item class="select-item" :class="form.supplierName ? 'is-filled' : 'is-empty'"> | |
| 28 | + <template v-slot:body> | |
| 29 | + <view class="item-title"><text class="required">*</text><text>客户名称</text></view> | |
| 30 | + </template> | |
| 31 | + <template v-slot:footer> | |
| 32 | + <view class="picker-value" :class="{ placeholder: !form.supplierName }"> | |
| 33 | + {{ form.supplierName || '选择码单后带出' }} | |
| 34 | + </view> | |
| 35 | + </template> | |
| 36 | + </uni-list-item> | |
| 37 | + | |
| 38 | + <!-- 计划编号 --> | |
| 39 | + <uni-list-item class="select-item" :class="form.procurementPlanId ? 'is-filled' : 'is-empty'"> | |
| 40 | + <template v-slot:body> | |
| 41 | + <view class="item-title"><text class="required">*</text><text>计划编号</text></view> | |
| 42 | + </template> | |
| 43 | + <template v-slot:footer> | |
| 44 | + <picker mode="selector" :range="planLabels" @change="onPlanChange" :disabled="!planOptions.length"> | |
| 45 | + <view class="picker-value" :class="{ placeholder: !form.procurementPlanId }"> | |
| 46 | + {{ getPlanLabel() || '请选择计划编号' }} | |
| 47 | + </view> | |
| 48 | + </picker> | |
| 49 | + </template> | |
| 50 | + </uni-list-item> | |
| 51 | + | |
| 52 | + <!-- 过磅品种 --> | |
| 53 | + <uni-list-item class="select-item" :class="form.productId ? 'is-filled' : 'is-empty'"> | |
| 54 | + <template v-slot:body> | |
| 55 | + <view class="item-title"><text class="required">*</text><text>过磅品种</text></view> | |
| 56 | + </template> | |
| 57 | + <template v-slot:footer> | |
| 58 | + <picker mode="selector" :range="productLabels" @change="onProductChange" :disabled="!productOptions.length"> | |
| 59 | + <view class="picker-value" :class="{ placeholder: !form.productId }"> | |
| 60 | + {{ getProductLabel() || '请选择过磅品种' }} | |
| 61 | + </view> | |
| 62 | + </picker> | |
| 63 | + </template> | |
| 64 | + </uni-list-item> | |
| 65 | + </uni-list> | |
| 66 | + | |
| 67 | + <!-- 化验明细:样品/数量/样号/送样编号 + 成份%(成分项按码单分厂区分) --> | |
| 68 | + <AssayDetailTable ref="detailTable" :options="applyDetailOptions" :workshop-name="ticketWorkshopName" /> | |
| 69 | + </scroll-view> | |
| 70 | + | |
| 71 | + <view class="footer"> | |
| 72 | + <button class="btn submit" type="primary" @click="onSubmit">保存</button> | |
| 73 | + </view> | |
| 74 | + | |
| 75 | + <RelateSelectSheet :visible.sync="ticketSheet.visible" title="选择码单" :multiple="false" | |
| 76 | + :fetchFn="ticketSheet.fetchFn" :display-fields="ticketSheet.displayFields" | |
| 77 | + row-key="id" :selectedKeys.sync="ticketSheet.selectedKeys" @confirm="onTicketConfirm" /> | |
| 78 | + </view> | |
| 79 | +</template> | |
| 80 | + | |
| 81 | +<script> | |
| 82 | +import RelateSelectSheet from '@/components/relate-select/index.vue' | |
| 83 | +import AssayDetailTable from './assay-detail-table.vue' | |
| 84 | +import { | |
| 85 | + assayReportDetailApi, | |
| 86 | + assayReportTicketPageApi, | |
| 87 | + assayReportPlanOptionsApi, | |
| 88 | + assayReportProductOptionsApi, | |
| 89 | + assayReportApplyOptionsApi, | |
| 90 | + assayReportUpdateApi | |
| 91 | +} from '@/api/procure-manage/assayReport.js' | |
| 92 | + | |
| 93 | +export default { | |
| 94 | + name: 'ModifyMaterialTest', | |
| 95 | + components: { RelateSelectSheet, AssayDetailTable }, | |
| 96 | + data() { | |
| 97 | + return { | |
| 98 | + id: '', | |
| 99 | + form: { | |
| 100 | + weighingTicketId: '', | |
| 101 | + weighingTicketCode: '', | |
| 102 | + reportDate: '', | |
| 103 | + supplierName: '', | |
| 104 | + procurementPlanId: '', | |
| 105 | + productId: '' | |
| 106 | + }, | |
| 107 | + // 选中的码单行对象,供回显与分厂成分联动使用 | |
| 108 | + selectedTicketRow: null, | |
| 109 | + // 计划编号下拉选项(所选码单下的计划) | |
| 110 | + planOptions: [], | |
| 111 | + // 过磅品种下拉选项(所选计划下的品种) | |
| 112 | + productOptions: [], | |
| 113 | + // 化验明细数据源(applyOptions 返回),供明细子组件送样编号下拉与固定值使用 | |
| 114 | + applyDetailOptions: [], | |
| 115 | + ticketSheet: { | |
| 116 | + visible: false, | |
| 117 | + fetchFn: null, | |
| 118 | + displayFields: [ | |
| 119 | + { label: '码单编号', field: 'code' }, | |
| 120 | + { label: '供应商', field: 'supplierName' }, | |
| 121 | + { label: '分厂', field: 'workshopName' }, | |
| 122 | + { label: '创建人', field: 'createBy' }, | |
| 123 | + { label: '完成时间', field: 'completeTime' } | |
| 124 | + ], | |
| 125 | + selectedKeys: [] | |
| 126 | + } | |
| 127 | + } | |
| 128 | + }, | |
| 129 | + computed: { | |
| 130 | + // 码单分厂名称,决定化验明细成分项集合 | |
| 131 | + ticketWorkshopName() { | |
| 132 | + return (this.selectedTicketRow && this.selectedTicketRow.workshopName) || '' | |
| 133 | + }, | |
| 134 | + planLabels() { | |
| 135 | + return (this.planOptions || []).map(it => it.label) | |
| 136 | + }, | |
| 137 | + productLabels() { | |
| 138 | + return (this.productOptions || []).map(it => it.label) | |
| 139 | + } | |
| 140 | + }, | |
| 141 | + created() { | |
| 142 | + this.ticketSheet.fetchFn = this.fetchTickets.bind(this) | |
| 143 | + }, | |
| 144 | + onLoad(query) { | |
| 145 | + this.id = (query && query.id) || '' | |
| 146 | + this.loadDetail() | |
| 147 | + }, | |
| 148 | + methods: { | |
| 149 | + // 打开页面:按 id 加载详情并回显 | |
| 150 | + loadDetail() { | |
| 151 | + if (!this.id) { | |
| 152 | + uni.showToast({ title: '缺少单据ID', icon: 'none' }) | |
| 153 | + return | |
| 154 | + } | |
| 155 | + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true }) | |
| 156 | + assayReportDetailApi({ id: this.id }) | |
| 157 | + .then(res => { | |
| 158 | + const data = (res && res.data) || {} | |
| 159 | + this.form = { | |
| 160 | + weighingTicketId: data.weighingTicketId || '', | |
| 161 | + weighingTicketCode: data.weighingTicketCode || '', | |
| 162 | + reportDate: data.reportDate || '', | |
| 163 | + supplierName: data.supplierName || '', | |
| 164 | + procurementPlanId: data.procurementPlanId || '', | |
| 165 | + productId: data.productId || '' | |
| 166 | + } | |
| 167 | + // 码单编号回显:用详情返回的码单ID/编号构造已选行,供分厂成分联动使用 | |
| 168 | + this.selectedTicketRow = data.weighingTicketId | |
| 169 | + ? { id: data.weighingTicketId, code: data.weighingTicketCode || '', workshopName: data.workshopName || '' } | |
| 170 | + : null | |
| 171 | + // 计划编号/品种下拉:先用详情数据兜底,再异步刷新真实选项 | |
| 172 | + this.planOptions = data.procurementPlanId | |
| 173 | + ? [{ label: data.planCode || '', value: data.procurementPlanId }] | |
| 174 | + : [] | |
| 175 | + this.productOptions = data.productId | |
| 176 | + ? [{ label: data.productName || '', value: data.productId }] | |
| 177 | + : [] | |
| 178 | + // 化验明细回显(成分值随行回显,由明细子组件 buildRow 统一初始化字段) | |
| 179 | + const detailLines = Array.isArray(data.lines) ? data.lines : [] | |
| 180 | + const detailTable = this.$refs.detailTable | |
| 181 | + detailTable && detailTable.setRows && detailTable.setRows(detailLines) | |
| 182 | + // 异步刷新明细数据源与下拉选项 | |
| 183 | + if (data.weighingTicketId && data.procurementPlanId && data.productId) { | |
| 184 | + this.loadApplyDetail(data.weighingTicketId, data.procurementPlanId, data.productId, detailLines) | |
| 185 | + } | |
| 186 | + if (data.weighingTicketId) { | |
| 187 | + this.loadPlanOptions(data.weighingTicketId) | |
| 188 | + } | |
| 189 | + if (data.weighingTicketId && data.procurementPlanId) { | |
| 190 | + this.loadProductOptions(data.weighingTicketId, data.procurementPlanId) | |
| 191 | + } | |
| 192 | + }) | |
| 193 | + .catch(() => { | |
| 194 | + uni.showToast({ title: '详情加载失败', icon: 'none' }) | |
| 195 | + }) | |
| 196 | + .finally(() => { | |
| 197 | + uni.hideLoading && uni.hideLoading() | |
| 198 | + }) | |
| 199 | + }, | |
| 200 | + // 根据所选码单加载计划编号下拉选项 | |
| 201 | + loadPlanOptions(ticketId) { | |
| 202 | + assayReportPlanOptionsApi(ticketId) | |
| 203 | + .then(res => { | |
| 204 | + const list = (res && res.data) || [] | |
| 205 | + const options = (list || []).map(item => ({ | |
| 206 | + label: item.planCode, | |
| 207 | + value: item.planId | |
| 208 | + })) | |
| 209 | + // 兜底:确保当前已选计划仍在选项中(回显时不丢失显示) | |
| 210 | + if (this.form.procurementPlanId && !options.some(item => item.value === this.form.procurementPlanId)) { | |
| 211 | + const fallback = this.planOptions.find(item => item.value === this.form.procurementPlanId) | |
| 212 | + if (fallback) options.push(fallback) | |
| 213 | + } | |
| 214 | + this.planOptions = options | |
| 215 | + }) | |
| 216 | + .catch(() => {}) | |
| 217 | + }, | |
| 218 | + // 根据所选码单与计划加载过磅品种下拉选项 | |
| 219 | + loadProductOptions(ticketId, planId) { | |
| 220 | + assayReportProductOptionsApi({ | |
| 221 | + ticketId: ticketId || undefined, | |
| 222 | + planId | |
| 223 | + }) | |
| 224 | + .then(res => { | |
| 225 | + const list = (res && res.data) || [] | |
| 226 | + const options = (list || []).map(item => ({ | |
| 227 | + label: item.productName, | |
| 228 | + value: item.productId | |
| 229 | + })) | |
| 230 | + // 兜底:确保当前已选品种仍在选项中(回显时不丢失显示) | |
| 231 | + if (this.form.productId && !options.some(item => item.value === this.form.productId)) { | |
| 232 | + const fallback = this.productOptions.find(item => item.value === this.form.productId) | |
| 233 | + if (fallback) options.push(fallback) | |
| 234 | + } | |
| 235 | + this.productOptions = options | |
| 236 | + }) | |
| 237 | + .catch(() => {}) | |
| 238 | + }, | |
| 239 | + // 加载化验明细数据源(送样编号下拉选项),并合并详情明细兜底 | |
| 240 | + loadApplyDetail(ticketId, planId, productId, detailLines) { | |
| 241 | + assayReportApplyOptionsApi({ | |
| 242 | + ticketId: ticketId || undefined, | |
| 243 | + planId: planId || undefined, | |
| 244 | + productId: productId || undefined | |
| 245 | + }) | |
| 246 | + .then(res => { | |
| 247 | + const list = ((res && res.data) || []).map(item => ({ | |
| 248 | + assayApplyId: item.assayApplyId || item.id || '', | |
| 249 | + assayApplyCode: item.assayApplyCode || '', | |
| 250 | + productName: item.productName || '', | |
| 251 | + productId: item.productId || '', | |
| 252 | + quantity: item.quantity | |
| 253 | + })) | |
| 254 | + // 兜底:详情明细中不在数据源内的送样编号并入选项,避免已选行回显异常 | |
| 255 | + const extra = (detailLines || []).filter(line => | |
| 256 | + line.assayApplyId && !list.some(item => item.assayApplyId === line.assayApplyId) | |
| 257 | + ) | |
| 258 | + this.applyDetailOptions = list.concat(extra) | |
| 259 | + }) | |
| 260 | + .catch(() => { | |
| 261 | + this.applyDetailOptions = (detailLines || []).map(item => ({ ...item })) | |
| 262 | + }) | |
| 263 | + }, | |
| 264 | + // 码单选择弹窗数据源(可选过磅码单分页,合并筛选条件) | |
| 265 | + fetchTickets({ pageIndex, pageSize, extra }) { | |
| 266 | + const keyword = (extra && extra.keyword) || '' | |
| 267 | + const params = { | |
| 268 | + pageIndex, | |
| 269 | + pageSize, | |
| 270 | + code: keyword || undefined | |
| 271 | + } | |
| 272 | + return assayReportTicketPageApi(params).then(res => { | |
| 273 | + const _data = (res && res.data) || {} | |
| 274 | + const records = _data.datas || _data.list || _data.records || [] | |
| 275 | + const totalCount = _data.totalCount || _data.count || 0 | |
| 276 | + const hasNext = _data.hasNext || false | |
| 277 | + return { records, totalCount, hasNext } | |
| 278 | + }).catch(() => ({ records: [], totalCount: 0, hasNext: false })) | |
| 279 | + }, | |
| 280 | + openTicketSheet() { | |
| 281 | + this.ticketSheet.selectedKeys = this.form.weighingTicketId ? [this.form.weighingTicketId] : [] | |
| 282 | + this.ticketSheet.visible = true | |
| 283 | + }, | |
| 284 | + // 码单选择回调:带出日期/客户名称,联动刷新计划编号下拉并重置下游数据 | |
| 285 | + onTicketConfirm({ items }) { | |
| 286 | + const row = (items || [])[0] | |
| 287 | + if (!row) { | |
| 288 | + this.selectedTicketRow = null | |
| 289 | + this.form.weighingTicketId = '' | |
| 290 | + this.form.weighingTicketCode = '' | |
| 291 | + this.form.reportDate = '' | |
| 292 | + this.form.supplierName = '' | |
| 293 | + this.resetDownStream() | |
| 294 | + return | |
| 295 | + } | |
| 296 | + this.selectedTicketRow = row | |
| 297 | + this.form.weighingTicketId = row.id || '' | |
| 298 | + this.form.weighingTicketCode = row.code || '' | |
| 299 | + // 切换码单后带出日期与客户名称并重置计划编号、品种及化验明细 | |
| 300 | + this.form.reportDate = String(row.completeTime || '').slice(0, 10) | |
| 301 | + this.form.supplierName = row.supplierName || '' | |
| 302 | + this.resetDownStream() | |
| 303 | + this.loadPlanOptions(row.id) | |
| 304 | + }, | |
| 305 | + resetDownStream() { | |
| 306 | + this.form.procurementPlanId = '' | |
| 307 | + this.form.productId = '' | |
| 308 | + this.planOptions = [] | |
| 309 | + this.productOptions = [] | |
| 310 | + this.applyDetailOptions = [] | |
| 311 | + const detailTable = this.$refs.detailTable | |
| 312 | + detailTable && detailTable.setRows && detailTable.setRows([]) | |
| 313 | + }, | |
| 314 | + getPlanLabel() { | |
| 315 | + const found = (this.planOptions || []).find(it => it.value === this.form.procurementPlanId) | |
| 316 | + return found ? found.label : '' | |
| 317 | + }, | |
| 318 | + // 计划编号改选后:重置品种并按所选计划刷新过磅品种下拉 | |
| 319 | + onPlanChange(e) { | |
| 320 | + const opt = (this.planOptions || [])[Number(e.detail.value)] | |
| 321 | + if (!opt) return | |
| 322 | + this.form.procurementPlanId = opt.value | |
| 323 | + this.form.productId = '' | |
| 324 | + this.productOptions = [] | |
| 325 | + this.applyDetailOptions = [] | |
| 326 | + const detailTable = this.$refs.detailTable | |
| 327 | + detailTable && detailTable.setRows && detailTable.setRows([]) | |
| 328 | + this.loadProductOptions(this.form.weighingTicketId, opt.value) | |
| 329 | + }, | |
| 330 | + getProductLabel() { | |
| 331 | + const found = (this.productOptions || []).find(it => it.value === this.form.productId) | |
| 332 | + return found ? found.label : '' | |
| 333 | + }, | |
| 334 | + // 过磅品种改选后:按码单/计划/品种加载化验明细并填充表格 | |
| 335 | + onProductChange(e) { | |
| 336 | + const opt = (this.productOptions || [])[Number(e.detail.value)] | |
| 337 | + if (!opt) return | |
| 338 | + this.form.productId = opt.value | |
| 339 | + this.applyDetailOptions = [] | |
| 340 | + const detailTable = this.$refs.detailTable | |
| 341 | + detailTable && detailTable.setRows && detailTable.setRows([]) | |
| 342 | + assayReportApplyOptionsApi({ | |
| 343 | + ticketId: this.form.weighingTicketId || undefined, | |
| 344 | + planId: this.form.procurementPlanId || undefined, | |
| 345 | + productId: opt.value || undefined | |
| 346 | + }) | |
| 347 | + .then(res => { | |
| 348 | + const list = ((res && res.data) || []).map(item => ({ | |
| 349 | + assayApplyId: item.assayApplyId || item.id || '', | |
| 350 | + assayApplyCode: item.assayApplyCode || '', | |
| 351 | + productName: item.productName || '', | |
| 352 | + productId: item.productId || '', | |
| 353 | + quantity: item.quantity | |
| 354 | + })) | |
| 355 | + this.applyDetailOptions = list | |
| 356 | + // 默认按化验明细填充表格,样号从1开始编号 | |
| 357 | + detailTable && detailTable.loadRows && detailTable.loadRows(list) | |
| 358 | + }) | |
| 359 | + .catch(() => { | |
| 360 | + this.applyDetailOptions = [] | |
| 361 | + }) | |
| 362 | + }, | |
| 363 | + validate() { | |
| 364 | + const f = this.form | |
| 365 | + if (!f.weighingTicketId) return this.tip('请选择码单编号') | |
| 366 | + if (!f.reportDate) return this.tip('日期不能为空') | |
| 367 | + if (!f.procurementPlanId) return this.tip('请选择计划编号') | |
| 368 | + if (!f.productId) return this.tip('请选择过磅品种') | |
| 369 | + return true | |
| 370 | + }, | |
| 371 | + tip(msg) { | |
| 372 | + uni.showToast({ title: msg, icon: 'none' }) | |
| 373 | + return false | |
| 374 | + }, | |
| 375 | + async onSubmit() { | |
| 376 | + if (!this.validate()) return | |
| 377 | + const confirmRes = await new Promise(resolve => { | |
| 378 | + uni.showModal({ title: '提示', content: '确定保存原料化验报告单吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 379 | + }) | |
| 380 | + if (!(confirmRes && confirmRes.confirm)) return | |
| 381 | + const detailTable = this.$refs.detailTable | |
| 382 | + const lines = (detailTable && detailTable.getLines && detailTable.getLines()) || [] | |
| 383 | + uni.showLoading({ title: '提交中...', mask: true }) | |
| 384 | + assayReportUpdateApi({ | |
| 385 | + id: this.id, | |
| 386 | + weighingTicketId: this.form.weighingTicketId, | |
| 387 | + reportDate: this.form.reportDate, | |
| 388 | + procurementPlanId: this.form.procurementPlanId, | |
| 389 | + productId: this.form.productId, | |
| 390 | + lines | |
| 391 | + }) | |
| 392 | + .then(() => { | |
| 393 | + uni.hideLoading() | |
| 394 | + uni.showToast({ title: '保存成功', icon: 'none' }) | |
| 395 | + try { | |
| 396 | + uni.setStorageSync('MATERIAL_TEST_LIST_NEED_REFRESH', '1') | |
| 397 | + uni.setStorageSync('MATERIAL_TEST_DETAIL_NEED_REFRESH', '1') | |
| 398 | + } catch (e) {} | |
| 399 | + setTimeout(() => { uni.navigateBack() }, 400) | |
| 400 | + }) | |
| 401 | + .catch(e => { | |
| 402 | + uni.hideLoading() | |
| 403 | + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' }) | |
| 404 | + }) | |
| 405 | + } | |
| 406 | + } | |
| 407 | +} | |
| 408 | +</script> | |
| 409 | + | |
| 410 | +<style lang="scss" scoped> | |
| 411 | +.page { | |
| 412 | + display: flex; | |
| 413 | + flex-direction: column; | |
| 414 | + height: 100%; | |
| 415 | +} | |
| 416 | + | |
| 417 | +.scroll { | |
| 418 | + flex: 1; | |
| 419 | + padding: 12rpx 0 200rpx !important; | |
| 420 | +} | |
| 421 | + | |
| 422 | +.footer { | |
| 423 | + z-index: 2; | |
| 424 | + position: fixed; | |
| 425 | + left: 0; | |
| 426 | + right: 0; | |
| 427 | + bottom: 0; | |
| 428 | + padding: 32rpx; | |
| 429 | + padding-bottom: calc(32rpx + env(safe-area-inset-bottom)); | |
| 430 | + background: #fff; | |
| 431 | + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06); | |
| 432 | + | |
| 433 | + .btn { | |
| 434 | + height: 80rpx; | |
| 435 | + line-height: 80rpx; | |
| 436 | + border-radius: 12rpx; | |
| 437 | + font-size: 32rpx; | |
| 438 | + } | |
| 439 | + | |
| 440 | + .submit { | |
| 441 | + background: $theme-primary; | |
| 442 | + color: #fff; | |
| 443 | + } | |
| 444 | +} | |
| 445 | + | |
| 446 | +::v-deep .uni-list { | |
| 447 | + .uni-easyinput { | |
| 448 | + display: flex; | |
| 449 | + | |
| 450 | + .uni-input-input { | |
| 451 | + color: rgba(0, 0, 0, 0.9); | |
| 452 | + } | |
| 453 | + } | |
| 454 | + | |
| 455 | + .uni-input-placeholder { | |
| 456 | + z-index: 1; | |
| 457 | + } | |
| 458 | + | |
| 459 | + .uni-input-input { | |
| 460 | + background-color: #ffffff; | |
| 461 | + } | |
| 462 | + | |
| 463 | + background: transparent; | |
| 464 | + | |
| 465 | + &-item { | |
| 466 | + &__extra-text { | |
| 467 | + font-size: 32rpx; | |
| 468 | + } | |
| 469 | + | |
| 470 | + &__content-title { | |
| 471 | + font-size: 32rpx; | |
| 472 | + color: rgba(0, 0, 0, 0.9); | |
| 473 | + } | |
| 474 | + | |
| 475 | + &__container { | |
| 476 | + padding: 32rpx; | |
| 477 | + | |
| 478 | + .item-title, | |
| 479 | + .uni-list-item__content { | |
| 480 | + flex: none; | |
| 481 | + min-height: 48rpx; | |
| 482 | + line-height: 48rpx; | |
| 483 | + font-size: 32rpx; | |
| 484 | + position: relative; | |
| 485 | + width: 240rpx; | |
| 486 | + margin-right: 32rpx; | |
| 487 | + color: rgba(0, 0, 0, 0.9); | |
| 488 | + | |
| 489 | + .required { | |
| 490 | + color: red; | |
| 491 | + position: absolute; | |
| 492 | + top: 50%; | |
| 493 | + transform: translateY(-50%); | |
| 494 | + left: -16rpx; | |
| 495 | + } | |
| 496 | + } | |
| 497 | + } | |
| 498 | + | |
| 499 | + &.select-item { | |
| 500 | + &.is-empty { | |
| 501 | + .uni-list-item__extra-text { | |
| 502 | + color: rgba(0, 0, 0, 0.4) !important; | |
| 503 | + } | |
| 504 | + } | |
| 505 | + | |
| 506 | + &.is-filled { | |
| 507 | + .uni-list-item__extra-text { | |
| 508 | + color: rgba(0, 0, 0, 0.9) !important; | |
| 509 | + } | |
| 510 | + } | |
| 511 | + } | |
| 512 | + } | |
| 513 | +} | |
| 514 | + | |
| 515 | +.picker-value { | |
| 516 | + font-size: 32rpx; | |
| 517 | + color: rgba(0, 0, 0, 0.9); | |
| 518 | + line-height: 48rpx; | |
| 519 | + text-align: right; | |
| 520 | + min-height: 48rpx; | |
| 521 | + | |
| 522 | + &.placeholder { | |
| 523 | + color: rgba(0, 0, 0, 0.4); | |
| 524 | + } | |
| 525 | +} | |
| 526 | +</style> | ... | ... |
pages/material-test/quality.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <!-- 详情只读展示 --> | |
| 5 | + <view class="detail-page"> | |
| 6 | + <view class="section"> | |
| 7 | + <text class="row company">{{ safeText(form.weighingTicketCode) }}</text> | |
| 8 | + <view class="row"><text class="label">日期</text><text class="value">{{ safeText(form.reportDate) }}</text></view> | |
| 9 | + <view class="row"><text class="label">客户名称</text><text class="value">{{ safeText(form.supplierName) }}</text></view> | |
| 10 | + <view class="row"><text class="label">分厂</text><text class="value">{{ safeText(form.workshopName) }}</text></view> | |
| 11 | + <view class="row"><text class="label">计划编号</text><text class="value">{{ safeText(form.planCode) }}</text></view> | |
| 12 | + <view class="row"><text class="label">过磅品种</text><text class="value">{{ safeText(form.productName) }}</text></view> | |
| 13 | + <view class="row"><text class="label">审核状态</text><text class="value">{{ approvalStatusName }}</text></view> | |
| 14 | + <view class="row"><text class="label">流程节点</text><text class="value">{{ flowNodeName }}</text></view> | |
| 15 | + <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view> | |
| 16 | + <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view> | |
| 17 | + </view> | |
| 18 | + | |
| 19 | + <!-- 化验明细(只读) --> | |
| 20 | + <view class="sub-table"> | |
| 21 | + <view class="sub-header"> | |
| 22 | + <image class="sub-bar" src="/static/images/title.png" /> | |
| 23 | + <text class="sub-title">化验明细</text> | |
| 24 | + </view> | |
| 25 | + <view class="sub-body"> | |
| 26 | + <view v-if="!lines.length" class="empty-tip">暂无明细</view> | |
| 27 | + <view v-for="(item, idx) in lineRows" :key="'l-' + (item.assayApplyId || idx)" class="card"> | |
| 28 | + <view class="card-index">第 {{ idx + 1 }} 行</view> | |
| 29 | + <view class="row"><text class="label">样品</text><text class="value">{{ safeText(item.productName) }}</text></view> | |
| 30 | + <view class="row"><text class="label">数量</text><text class="value">{{ formatNumber(item.quantity) }}</text></view> | |
| 31 | + <view class="row"><text class="label">样号</text><text class="value">{{ safeText(item.testCode) }}</text></view> | |
| 32 | + <view class="row"><text class="label">送样编号</text><text class="value">{{ safeText(item.assayApplyCode) }}</text></view> | |
| 33 | + <view v-for="key in componentKeys" :key="key" class="row"> | |
| 34 | + <text class="label">{{ componentLabels[key] || key }}</text> | |
| 35 | + <text class="value">{{ formatNumber(item[key]) }}</text> | |
| 36 | + </view> | |
| 37 | + </view> | |
| 38 | + </view> | |
| 39 | + </view> | |
| 40 | + | |
| 41 | + <!-- 修改意向编辑 --> | |
| 42 | + <view class="title-header"> | |
| 43 | + <image class="title-header_icon" src="/static/images/title.png" /> | |
| 44 | + <span>修改意向</span> | |
| 45 | + </view> | |
| 46 | + <view class="section"> | |
| 47 | + <view class="edit-row"> | |
| 48 | + <view class="item-title"><text class="required">*</text><text>是否有质量问题</text></view> | |
| 49 | + <uni-data-checkbox | |
| 50 | + mode="tag" | |
| 51 | + :multiple="false" | |
| 52 | + :value-field="'value'" | |
| 53 | + :text-field="'text'" | |
| 54 | + v-model="formData.hasQualityProblem" | |
| 55 | + :localdata="qualityOptions" | |
| 56 | + @change="onQualityChange" | |
| 57 | + /> | |
| 58 | + </view> | |
| 59 | + <!-- 处理意见:仅在有质量问题(是)时显示并必填 --> | |
| 60 | + <view v-if="formData.hasQualityProblem === true" class="edit-row textarea-row"> | |
| 61 | + <view class="item-title"><text class="required">*</text><text>处理意见</text></view> | |
| 62 | + <textarea | |
| 63 | + class="textarea" | |
| 64 | + v-model="formData.processOpinion" | |
| 65 | + :maxlength="500" | |
| 66 | + placeholder="请输入处理意见" | |
| 67 | + placeholder-class="textarea-placeholder" | |
| 68 | + /> | |
| 69 | + </view> | |
| 70 | + </view> | |
| 71 | + </view> | |
| 72 | + </scroll-view> | |
| 73 | + | |
| 74 | + <view class="footer"> | |
| 75 | + <button class="btn submit" type="primary" @click="onSubmit">保存</button> | |
| 76 | + </view> | |
| 77 | + </view> | |
| 78 | +</template> | |
| 79 | + | |
| 80 | +<script> | |
| 81 | +import { getDicByCodes, getDicName } from '@/utils/dic.js' | |
| 82 | +import { COMPONENT_LABELS, getComponentKeys } from './component-config.js' | |
| 83 | +import { assayReportDetailApi, assayReportQualityApi } from '@/api/procure-manage/assayReport.js' | |
| 84 | + | |
| 85 | +export default { | |
| 86 | + name: 'MaterialTestQuality', | |
| 87 | + data() { | |
| 88 | + return { | |
| 89 | + id: '', | |
| 90 | + form: {}, | |
| 91 | + lines: [], | |
| 92 | + componentLabels: COMPONENT_LABELS, | |
| 93 | + formData: { | |
| 94 | + hasQualityProblem: undefined, | |
| 95 | + processOpinion: '' | |
| 96 | + }, | |
| 97 | + qualityOptions: [ | |
| 98 | + { value: true, text: '是' }, | |
| 99 | + { value: false, text: '否' } | |
| 100 | + ], | |
| 101 | + dicOptions: { | |
| 102 | + AUDIT_STATUS: [], | |
| 103 | + FLOW_NODE: [] | |
| 104 | + } | |
| 105 | + } | |
| 106 | + }, | |
| 107 | + computed: { | |
| 108 | + componentKeys() { | |
| 109 | + return getComponentKeys(this.form.workshopName) | |
| 110 | + }, | |
| 111 | + approvalStatusName() { | |
| 112 | + const v = this.form.approvalStatus == null ? '' : String(this.form.approvalStatus) | |
| 113 | + if (!v) return '-' | |
| 114 | + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v | |
| 115 | + }, | |
| 116 | + flowNodeName() { | |
| 117 | + const v = this.form.flowNode == null ? '' : String(this.form.flowNode) | |
| 118 | + if (!v) return '-' | |
| 119 | + return getDicName('FLOW_NODE', v, this.dicOptions.FLOW_NODE) || v | |
| 120 | + }, | |
| 121 | + // 化验明细展示行(样号按行序编号展示) | |
| 122 | + lineRows() { | |
| 123 | + return (this.lines || []).map((item, index) => ({ | |
| 124 | + ...item, | |
| 125 | + testCode: item.testCode || String(index + 1) | |
| 126 | + })) | |
| 127 | + } | |
| 128 | + }, | |
| 129 | + onLoad(query) { | |
| 130 | + this.id = (query && query.id) || '' | |
| 131 | + this.loadDicData() | |
| 132 | + this.loadDetail() | |
| 133 | + }, | |
| 134 | + methods: { | |
| 135 | + async loadDicData() { | |
| 136 | + try { | |
| 137 | + const results = await getDicByCodes(['AUDIT_STATUS', 'FLOW_NODE']) | |
| 138 | + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || [] | |
| 139 | + this.dicOptions.FLOW_NODE = (results.FLOW_NODE && results.FLOW_NODE.data) || [] | |
| 140 | + } catch (e) { | |
| 141 | + this.dicOptions = { AUDIT_STATUS: [], FLOW_NODE: [] } | |
| 142 | + } | |
| 143 | + }, | |
| 144 | + // 加载详情并回显(详情展示区 + 编辑字段) | |
| 145 | + loadDetail() { | |
| 146 | + if (!this.id) { | |
| 147 | + uni.showToast({ title: '缺少单据ID', icon: 'none' }) | |
| 148 | + return | |
| 149 | + } | |
| 150 | + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true }) | |
| 151 | + assayReportDetailApi({ id: this.id }) | |
| 152 | + .then(res => { | |
| 153 | + const data = (res && res.data) || {} | |
| 154 | + this.form = Object.assign({}, data) | |
| 155 | + this.lines = Array.isArray(data.lines) ? data.lines.map(x => ({ ...x })) : [] | |
| 156 | + // 编辑字段回显(兼容 1/0、true/false、'1'/'0' 返回) | |
| 157 | + const hqp = data.hasQualityProblem | |
| 158 | + this.formData = { | |
| 159 | + hasQualityProblem: | |
| 160 | + hqp === true || hqp === 1 || hqp === '1' | |
| 161 | + ? true | |
| 162 | + : hqp === false || hqp === 0 || hqp === '0' | |
| 163 | + ? false | |
| 164 | + : undefined, | |
| 165 | + processOpinion: data.processOpinion || '' | |
| 166 | + } | |
| 167 | + }) | |
| 168 | + .catch(() => { | |
| 169 | + uni.showToast({ title: '详情加载失败', icon: 'none' }) | |
| 170 | + }) | |
| 171 | + .finally(() => { | |
| 172 | + uni.hideLoading && uni.hideLoading() | |
| 173 | + }) | |
| 174 | + }, | |
| 175 | + // 是否有质量问题变化:仅选择"是"时显示处理意见,否则清空处理意见 | |
| 176 | + onQualityChange() { | |
| 177 | + if (this.formData.hasQualityProblem !== true) { | |
| 178 | + this.formData.processOpinion = '' | |
| 179 | + } | |
| 180 | + }, | |
| 181 | + validate() { | |
| 182 | + if (this.formData.hasQualityProblem !== true && this.formData.hasQualityProblem !== false) { | |
| 183 | + return this.tip('请选择是否有质量问题') | |
| 184 | + } | |
| 185 | + if (this.formData.hasQualityProblem === true && !this.formData.processOpinion) { | |
| 186 | + return this.tip('请输入处理意见') | |
| 187 | + } | |
| 188 | + return true | |
| 189 | + }, | |
| 190 | + tip(msg) { | |
| 191 | + uni.showToast({ title: msg, icon: 'none' }) | |
| 192 | + return false | |
| 193 | + }, | |
| 194 | + async onSubmit() { | |
| 195 | + if (!this.validate()) return | |
| 196 | + const confirmRes = await new Promise(resolve => { | |
| 197 | + uni.showModal({ title: '提示', content: '确定保存修改意向吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 198 | + }) | |
| 199 | + if (!(confirmRes && confirmRes.confirm)) return | |
| 200 | + uni.showLoading({ title: '提交中...', mask: true }) | |
| 201 | + assayReportQualityApi({ | |
| 202 | + id: this.id, | |
| 203 | + hasQualityProblem: this.formData.hasQualityProblem, | |
| 204 | + processOpinion: this.formData.processOpinion | |
| 205 | + }) | |
| 206 | + .then(() => { | |
| 207 | + uni.hideLoading() | |
| 208 | + uni.showToast({ title: '保存成功', icon: 'none' }) | |
| 209 | + try { | |
| 210 | + uni.setStorageSync('MATERIAL_TEST_LIST_NEED_REFRESH', '1') | |
| 211 | + uni.setStorageSync('MATERIAL_TEST_DETAIL_NEED_REFRESH', '1') | |
| 212 | + } catch (e) {} | |
| 213 | + setTimeout(() => { uni.navigateBack() }, 400) | |
| 214 | + }) | |
| 215 | + .catch(e => { | |
| 216 | + uni.hideLoading() | |
| 217 | + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' }) | |
| 218 | + }) | |
| 219 | + }, | |
| 220 | + safeText(v) { | |
| 221 | + const s = v == null ? '' : String(v) | |
| 222 | + return s.trim() ? s : '-' | |
| 223 | + }, | |
| 224 | + formatNumber(v) { | |
| 225 | + if (v === null || v === undefined || v === '') return '-' | |
| 226 | + const n = Number(v) | |
| 227 | + if (isNaN(n)) return String(v) | |
| 228 | + return n.toLocaleString('zh-CN', { maximumFractionDigits: 4 }) | |
| 229 | + } | |
| 230 | + } | |
| 231 | +} | |
| 232 | +</script> | |
| 233 | + | |
| 234 | +<style lang="scss" scoped> | |
| 235 | +.page { | |
| 236 | + display: flex; | |
| 237 | + flex-direction: column; | |
| 238 | + height: 100%; | |
| 239 | +} | |
| 240 | + | |
| 241 | +.scroll { | |
| 242 | + flex: 1; | |
| 243 | + padding: 8rpx 0 200rpx !important; | |
| 244 | +} | |
| 245 | + | |
| 246 | +.detail-page { | |
| 247 | + background: #f3f3f3; | |
| 248 | +} | |
| 249 | + | |
| 250 | +.section { | |
| 251 | + padding: 32rpx; | |
| 252 | + background: #fff; | |
| 253 | + margin-bottom: 20rpx; | |
| 254 | +} | |
| 255 | + | |
| 256 | +.title-header { | |
| 257 | + display: flex; | |
| 258 | + align-items: center; | |
| 259 | + padding: 24rpx 32rpx 12rpx; | |
| 260 | + background-color: #ffffff; | |
| 261 | + .title-header_icon { width: 36rpx; height: 36rpx; margin-right: 12rpx; } | |
| 262 | + span { font-size: 34rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); } | |
| 263 | +} | |
| 264 | + | |
| 265 | +.row { | |
| 266 | + display: flex; | |
| 267 | + margin-bottom: 28rpx; | |
| 268 | + &:last-child { margin-bottom: 0; } | |
| 269 | + &.company { | |
| 270 | + font-size: 36rpx; | |
| 271 | + font-weight: 600; | |
| 272 | + color: rgba(0, 0, 0, 0.9); | |
| 273 | + padding-top: 8rpx; | |
| 274 | + line-height: 50rpx; | |
| 275 | + } | |
| 276 | + .label { | |
| 277 | + max-width: 420rpx; | |
| 278 | + margin-right: 20rpx; | |
| 279 | + line-height: 32rpx; | |
| 280 | + font-size: 28rpx; | |
| 281 | + color: rgba(0, 0, 0, 0.6); | |
| 282 | + } | |
| 283 | + .value { | |
| 284 | + flex: 1; | |
| 285 | + line-height: 32rpx; | |
| 286 | + font-size: 28rpx; | |
| 287 | + color: rgba(0, 0, 0, 0.9); | |
| 288 | + text-align: right; | |
| 289 | + word-break: break-all; | |
| 290 | + } | |
| 291 | +} | |
| 292 | + | |
| 293 | +.sub-table { | |
| 294 | + background: #fff; | |
| 295 | + margin-bottom: 20rpx; | |
| 296 | +} | |
| 297 | +.sub-header { | |
| 298 | + display: flex; | |
| 299 | + align-items: center; | |
| 300 | + padding: 16rpx 0 16rpx 32rpx; | |
| 301 | + .sub-bar { width: 6rpx; height: 32rpx; margin-right: 14rpx; } | |
| 302 | + .sub-title { font-size: 30rpx; font-weight: 600; color: rgba(0, 0, 0, 0.9); flex: 1; line-height: 42rpx; } | |
| 303 | +} | |
| 304 | +.sub-body { | |
| 305 | + padding: 0 32rpx 24rpx; | |
| 306 | + .empty-tip { | |
| 307 | + text-align: center; | |
| 308 | + padding: 60rpx 0; | |
| 309 | + color: rgba(0, 0, 0, 0.4); | |
| 310 | + font-size: 28rpx; | |
| 311 | + } | |
| 312 | + .card { | |
| 313 | + position: relative; | |
| 314 | + background: #fafafa; | |
| 315 | + border-radius: 12rpx; | |
| 316 | + padding: 32rpx 28rpx 20rpx; | |
| 317 | + margin-bottom: 24rpx; | |
| 318 | + .card-index { | |
| 319 | + position: absolute; | |
| 320 | + top: 0; | |
| 321 | + right: 0; | |
| 322 | + background: rgba(24, 144, 255, 0.08); | |
| 323 | + color: $theme-primary; | |
| 324 | + font-size: 22rpx; | |
| 325 | + line-height: 36rpx; | |
| 326 | + padding: 0 16rpx; | |
| 327 | + border-bottom-left-radius: 12rpx; | |
| 328 | + border-top-right-radius: 12rpx; | |
| 329 | + } | |
| 330 | + .row { | |
| 331 | + align-items: center; | |
| 332 | + justify-content: space-between; | |
| 333 | + padding: 14rpx 0; | |
| 334 | + margin-bottom: 0; | |
| 335 | + border-bottom: 1rpx dashed #f2f2f2; | |
| 336 | + &:last-child { border-bottom: none; } | |
| 337 | + .label { | |
| 338 | + flex-shrink: 0; | |
| 339 | + width: 220rpx; | |
| 340 | + max-width: none; | |
| 341 | + margin-right: 0; | |
| 342 | + font-size: 28rpx; | |
| 343 | + color: rgba(0, 0, 0, 0.6); | |
| 344 | + line-height: 40rpx; | |
| 345 | + } | |
| 346 | + .value { | |
| 347 | + flex: 1; | |
| 348 | + text-align: right; | |
| 349 | + font-size: 28rpx; | |
| 350 | + color: rgba(0, 0, 0, 0.9); | |
| 351 | + line-height: 40rpx; | |
| 352 | + overflow: hidden; | |
| 353 | + text-overflow: ellipsis; | |
| 354 | + white-space: nowrap; | |
| 355 | + } | |
| 356 | + } | |
| 357 | + } | |
| 358 | +} | |
| 359 | + | |
| 360 | +.edit-row { | |
| 361 | + display: flex; | |
| 362 | + align-items: center; | |
| 363 | + justify-content: space-between; | |
| 364 | + margin-bottom: 28rpx; | |
| 365 | + | |
| 366 | + .item-title { | |
| 367 | + flex: none; | |
| 368 | + font-size: 32rpx; | |
| 369 | + color: rgba(0, 0, 0, 0.9); | |
| 370 | + position: relative; | |
| 371 | + padding-left: 16rpx; | |
| 372 | + | |
| 373 | + .required { | |
| 374 | + color: red; | |
| 375 | + position: absolute; | |
| 376 | + left: 0; | |
| 377 | + } | |
| 378 | + } | |
| 379 | + | |
| 380 | + .radio-group { | |
| 381 | + display: flex; | |
| 382 | + align-items: center; | |
| 383 | + | |
| 384 | + .radio-item { | |
| 385 | + display: flex; | |
| 386 | + align-items: center; | |
| 387 | + margin-left: 32rpx; | |
| 388 | + font-size: 30rpx; | |
| 389 | + color: rgba(0, 0, 0, 0.9); | |
| 390 | + } | |
| 391 | + } | |
| 392 | + | |
| 393 | + &.textarea-row { | |
| 394 | + flex-direction: column; | |
| 395 | + align-items: stretch; | |
| 396 | + margin-bottom: 0; | |
| 397 | + | |
| 398 | + .item-title { margin-bottom: 20rpx; } | |
| 399 | + | |
| 400 | + .textarea { | |
| 401 | + width: 100%; | |
| 402 | + min-height: 200rpx; | |
| 403 | + padding: 24rpx; | |
| 404 | + border: 1rpx solid #e7e7e7; | |
| 405 | + border-radius: 8rpx; | |
| 406 | + font-size: 28rpx; | |
| 407 | + color: rgba(0, 0, 0, 0.9); | |
| 408 | + background: #fff; | |
| 409 | + box-sizing: border-box; | |
| 410 | + } | |
| 411 | + | |
| 412 | + .textarea-placeholder { color: rgba(0, 0, 0, 0.4); } | |
| 413 | + } | |
| 414 | +} | |
| 415 | + | |
| 416 | +.footer { | |
| 417 | + z-index: 2; | |
| 418 | + position: fixed; | |
| 419 | + left: 0; | |
| 420 | + right: 0; | |
| 421 | + bottom: 0; | |
| 422 | + padding: 32rpx; | |
| 423 | + padding-bottom: calc(32rpx + env(safe-area-inset-bottom)); | |
| 424 | + background: #fff; | |
| 425 | + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06); | |
| 426 | + | |
| 427 | + .btn { | |
| 428 | + height: 80rpx; | |
| 429 | + line-height: 80rpx; | |
| 430 | + border-radius: 12rpx; | |
| 431 | + font-size: 32rpx; | |
| 432 | + } | |
| 433 | + | |
| 434 | + .submit { | |
| 435 | + background: $theme-primary; | |
| 436 | + color: #fff; | |
| 437 | + } | |
| 438 | +} | |
| 439 | +</style> | ... | ... |
pages/sample-submission/add.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <uni-list> | |
| 5 | + <!-- 送样编号 --> | |
| 6 | + <uni-list-item class="select-item" :class="form.code ? 'is-filled' : 'is-empty'"> | |
| 7 | + <template v-slot:body> | |
| 8 | + <view class="item-title"><text class="required">*</text><text>送样编号</text></view> | |
| 9 | + </template> | |
| 10 | + <template v-slot:footer> | |
| 11 | + <view class="serial-number-row"> | |
| 12 | + <text class="readonly-text value-code">{{ form.code || '-' }}</text> | |
| 13 | + <button class="generate-btn" @click="onGenerateCode">点此生成</button> | |
| 14 | + </view> | |
| 15 | + </template> | |
| 16 | + </uni-list-item> | |
| 17 | + | |
| 18 | + <!-- 码单编号(弹窗选择) --> | |
| 19 | + <uni-list-item class="select-item" :class="form.weighingTicketCode ? 'is-filled' : 'is-empty'" clickable | |
| 20 | + @click="openTicketSheet" :rightText="form.weighingTicketCode || '请选择码单'" showArrow> | |
| 21 | + <template v-slot:body> | |
| 22 | + <view class="item-title"><text class="required">*</text><text>码单编号</text></view> | |
| 23 | + </template> | |
| 24 | + </uni-list-item> | |
| 25 | + | |
| 26 | + <!-- 计划编号 --> | |
| 27 | + <uni-list-item class="select-item" :class="form.procurementPlanId ? 'is-filled' : 'is-empty'"> | |
| 28 | + <template v-slot:body> | |
| 29 | + <view class="item-title"><text class="required">*</text><text>计划编号</text></view> | |
| 30 | + </template> | |
| 31 | + <template v-slot:footer> | |
| 32 | + <picker mode="selector" :range="planLabels" @change="onPlanChange" :disabled="!planOptions.length"> | |
| 33 | + <view class="picker-value" :class="{ placeholder: !form.procurementPlanId }"> | |
| 34 | + {{ getPlanLabel() || '请选择计划编号' }} | |
| 35 | + </view> | |
| 36 | + </picker> | |
| 37 | + </template> | |
| 38 | + </uni-list-item> | |
| 39 | + | |
| 40 | + <!-- 品种 --> | |
| 41 | + <uni-list-item class="select-item" :class="form.productId ? 'is-filled' : 'is-empty'"> | |
| 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 | + <picker mode="selector" :range="productLabels" @change="onProductChange" :disabled="!productOptions.length"> | |
| 47 | + <view class="picker-value" :class="{ placeholder: !form.productId }"> | |
| 48 | + {{ getProductLabel() || '请选择品种' }} | |
| 49 | + </view> | |
| 50 | + </picker> | |
| 51 | + </template> | |
| 52 | + </uni-list-item> | |
| 53 | + | |
| 54 | + <!-- 科室 --> | |
| 55 | + <uni-list-item class="select-item" :class="form.department ? 'is-filled' : 'is-empty'"> | |
| 56 | + <template v-slot:body> | |
| 57 | + <view class="item-title"><text class="required">*</text><text>科室</text></view> | |
| 58 | + </template> | |
| 59 | + <template v-slot:footer> | |
| 60 | + <picker mode="selector" :range="departmentLabels" @change="onDepartmentChange"> | |
| 61 | + <view class="picker-value" :class="{ placeholder: !form.department }"> | |
| 62 | + {{ getDepartmentLabel() || '请选择科室' }} | |
| 63 | + </view> | |
| 64 | + </picker> | |
| 65 | + </template> | |
| 66 | + </uni-list-item> | |
| 67 | + </uni-list> | |
| 68 | + | |
| 69 | + <view class="footer"> | |
| 70 | + <button class="btn submit" type="primary" @click="onSubmit">保存</button> | |
| 71 | + </view> | |
| 72 | + </scroll-view> | |
| 73 | + | |
| 74 | + <RelateSelectSheet :visible.sync="ticketSheet.visible" title="选择码单" :multiple="false" | |
| 75 | + :fetchFn="ticketSheet.fetchFn" :display-fields="ticketSheet.displayFields" | |
| 76 | + row-key="id" :selectedKeys.sync="ticketSheet.selectedKeys" @confirm="onTicketConfirm" /> | |
| 77 | + </view> | |
| 78 | +</template> | |
| 79 | + | |
| 80 | +<script> | |
| 81 | +import RelateSelectSheet from '@/components/relate-select/index.vue' | |
| 82 | +import { | |
| 83 | + assayApplyGenerateCodeApi, | |
| 84 | + assayApplyTicketPageApi, | |
| 85 | + assayApplyTicketDataApi, | |
| 86 | + assayApplyBreedOptionsApi, | |
| 87 | + assayApplyCreateApi | |
| 88 | +} from '@/api/procure-manage/assayApply.js' | |
| 89 | +import { getDicByCodes } from '@/utils/dic.js' | |
| 90 | + | |
| 91 | +export default { | |
| 92 | + name: 'AddSampleSubmission', | |
| 93 | + components: { RelateSelectSheet }, | |
| 94 | + data() { | |
| 95 | + return { | |
| 96 | + form: { | |
| 97 | + code: '', | |
| 98 | + weighingTicketId: '', | |
| 99 | + weighingTicketCode: '', | |
| 100 | + procurementPlanId: '', | |
| 101 | + productId: '', | |
| 102 | + department: '' | |
| 103 | + }, | |
| 104 | + dicOptions: { DEPARTMENT: [] }, | |
| 105 | + // 计划编号下拉选项(所选码单下的计划) | |
| 106 | + planOptions: [], | |
| 107 | + // 品种下拉选项(所选计划下的过磅品种) | |
| 108 | + productOptions: [], | |
| 109 | + ticketSheet: { | |
| 110 | + visible: false, | |
| 111 | + fetchFn: null, | |
| 112 | + displayFields: [ | |
| 113 | + { label: '码单编号', field: 'code' }, | |
| 114 | + { label: '分厂', field: 'workshopName' }, | |
| 115 | + { label: '创建人', field: 'createBy' }, | |
| 116 | + { label: '创建时间', field: 'createTime' } | |
| 117 | + ], | |
| 118 | + selectedKeys: [] | |
| 119 | + } | |
| 120 | + } | |
| 121 | + }, | |
| 122 | + computed: { | |
| 123 | + planLabels() { | |
| 124 | + return (this.planOptions || []).map(it => it.label) | |
| 125 | + }, | |
| 126 | + productLabels() { | |
| 127 | + return (this.productOptions || []).map(it => it.label) | |
| 128 | + }, | |
| 129 | + departmentLabels() { | |
| 130 | + return (this.dicOptions.DEPARTMENT || []).map(it => it.name) | |
| 131 | + } | |
| 132 | + }, | |
| 133 | + created() { | |
| 134 | + this.ticketSheet.fetchFn = this.fetchTickets.bind(this) | |
| 135 | + this.loadDicData() | |
| 136 | + this.onGenerateCode() | |
| 137 | + }, | |
| 138 | + methods: { | |
| 139 | + async loadDicData() { | |
| 140 | + try { | |
| 141 | + const results = await getDicByCodes(['DEPARTMENT']) | |
| 142 | + this.dicOptions.DEPARTMENT = (results.DEPARTMENT && results.DEPARTMENT.data) || [] | |
| 143 | + } catch (e) { | |
| 144 | + this.dicOptions.DEPARTMENT = [] | |
| 145 | + } | |
| 146 | + }, | |
| 147 | + onGenerateCode() { | |
| 148 | + assayApplyGenerateCodeApi() | |
| 149 | + .then(res => { | |
| 150 | + this.form.code = (res && res.data) ? res.data : '' | |
| 151 | + }) | |
| 152 | + .catch(() => {}) | |
| 153 | + }, | |
| 154 | + // 码单选择弹窗数据源(可选过磅码单分页) | |
| 155 | + fetchTickets({ pageIndex, pageSize, extra }) { | |
| 156 | + const keyword = (extra && extra.keyword) || '' | |
| 157 | + const params = { | |
| 158 | + pageIndex, | |
| 159 | + pageSize, | |
| 160 | + code: keyword || undefined | |
| 161 | + } | |
| 162 | + return assayApplyTicketPageApi(params).then(res => { | |
| 163 | + const _data = (res && res.data) || {} | |
| 164 | + const records = _data.datas || _data.list || _data.records || [] | |
| 165 | + const totalCount = _data.totalCount || _data.count || 0 | |
| 166 | + const hasNext = _data.hasNext || false | |
| 167 | + return { records, totalCount, hasNext } | |
| 168 | + }).catch(() => ({ records: [], totalCount: 0, hasNext: false })) | |
| 169 | + }, | |
| 170 | + openTicketSheet() { | |
| 171 | + this.ticketSheet.selectedKeys = this.form.weighingTicketId ? [this.form.weighingTicketId] : [] | |
| 172 | + this.ticketSheet.visible = true | |
| 173 | + }, | |
| 174 | + // 码单选择回调:联动刷新计划编号下拉并重置品种 | |
| 175 | + onTicketConfirm({ items }) { | |
| 176 | + const row = (items || [])[0] | |
| 177 | + if (!row) { | |
| 178 | + this.resetDownStream() | |
| 179 | + return | |
| 180 | + } | |
| 181 | + this.form.weighingTicketId = row.id || '' | |
| 182 | + this.form.weighingTicketCode = row.code || '' | |
| 183 | + this.resetDownStream() | |
| 184 | + this.loadPlanOptions(row.id) | |
| 185 | + }, | |
| 186 | + resetDownStream() { | |
| 187 | + this.form.procurementPlanId = '' | |
| 188 | + this.form.productId = '' | |
| 189 | + this.planOptions = [] | |
| 190 | + this.productOptions = [] | |
| 191 | + }, | |
| 192 | + // 根据所选码单加载计划编号下拉选项 | |
| 193 | + loadPlanOptions(ticketId) { | |
| 194 | + assayApplyTicketDataApi(ticketId) | |
| 195 | + .then(res => { | |
| 196 | + const data = (res && res.data) || {} | |
| 197 | + this.planOptions = ((data && data.planOptions) || []).map(item => ({ | |
| 198 | + label: item.planCode, | |
| 199 | + value: item.planId | |
| 200 | + })) | |
| 201 | + }) | |
| 202 | + .catch(() => { | |
| 203 | + this.planOptions = [] | |
| 204 | + }) | |
| 205 | + }, | |
| 206 | + getPlanLabel() { | |
| 207 | + const found = (this.planOptions || []).find(it => it.value === this.form.procurementPlanId) | |
| 208 | + return found ? found.label : '' | |
| 209 | + }, | |
| 210 | + // 计划编号改选后:重置品种并按所选计划刷新过磅品种下拉 | |
| 211 | + onPlanChange(e) { | |
| 212 | + const opt = (this.planOptions || [])[Number(e.detail.value)] | |
| 213 | + if (!opt) return | |
| 214 | + this.form.procurementPlanId = opt.value | |
| 215 | + this.form.productId = '' | |
| 216 | + this.productOptions = [] | |
| 217 | + assayApplyBreedOptionsApi({ | |
| 218 | + ticketId: this.form.weighingTicketId || undefined, | |
| 219 | + planId: opt.value | |
| 220 | + }) | |
| 221 | + .then(res => { | |
| 222 | + const list = (res && res.data) || [] | |
| 223 | + this.productOptions = (list || []).map(item => ({ | |
| 224 | + label: item.productName, | |
| 225 | + value: item.productId | |
| 226 | + })) | |
| 227 | + }) | |
| 228 | + .catch(() => { | |
| 229 | + this.productOptions = [] | |
| 230 | + }) | |
| 231 | + }, | |
| 232 | + getProductLabel() { | |
| 233 | + const found = (this.productOptions || []).find(it => it.value === this.form.productId) | |
| 234 | + return found ? found.label : '' | |
| 235 | + }, | |
| 236 | + onProductChange(e) { | |
| 237 | + const opt = (this.productOptions || [])[Number(e.detail.value)] | |
| 238 | + if (!opt) return | |
| 239 | + this.form.productId = opt.value | |
| 240 | + }, | |
| 241 | + getDepartmentLabel() { | |
| 242 | + const found = (this.dicOptions.DEPARTMENT || []).find(it => String(it.code) === String(this.form.department)) | |
| 243 | + return found ? found.name : '' | |
| 244 | + }, | |
| 245 | + onDepartmentChange(e) { | |
| 246 | + const opt = (this.dicOptions.DEPARTMENT || [])[Number(e.detail.value)] | |
| 247 | + if (!opt) return | |
| 248 | + this.form.department = opt.code != null ? String(opt.code) : '' | |
| 249 | + }, | |
| 250 | + validate() { | |
| 251 | + const f = this.form | |
| 252 | + if (!f.code) return this.tip('请生成送样编号') | |
| 253 | + if (!f.weighingTicketId) return this.tip('请选择码单编号') | |
| 254 | + if (!f.procurementPlanId) return this.tip('请选择计划编号') | |
| 255 | + if (!f.productId) return this.tip('请选择品种') | |
| 256 | + if (!f.department) return this.tip('请选择科室') | |
| 257 | + return true | |
| 258 | + }, | |
| 259 | + tip(msg) { | |
| 260 | + uni.showToast({ title: msg, icon: 'none' }) | |
| 261 | + return false | |
| 262 | + }, | |
| 263 | + async onSubmit() { | |
| 264 | + if (!this.validate()) return | |
| 265 | + const confirmRes = await new Promise(resolve => { | |
| 266 | + uni.showModal({ title: '提示', content: '确定保存化验送样单吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 267 | + }) | |
| 268 | + if (!(confirmRes && confirmRes.confirm)) return | |
| 269 | + uni.showLoading({ title: '提交中...', mask: true }) | |
| 270 | + assayApplyCreateApi({ | |
| 271 | + code: this.form.code, | |
| 272 | + weighingTicketId: this.form.weighingTicketId, | |
| 273 | + procurementPlanId: this.form.procurementPlanId, | |
| 274 | + productId: this.form.productId, | |
| 275 | + department: this.form.department | |
| 276 | + }) | |
| 277 | + .then(() => { | |
| 278 | + uni.hideLoading() | |
| 279 | + uni.showToast({ title: '保存成功', icon: 'none' }) | |
| 280 | + try { uni.setStorageSync('SAMPLE_SUBMISSION_LIST_NEED_REFRESH', '1') } catch (e) {} | |
| 281 | + setTimeout(() => { uni.navigateBack() }, 400) | |
| 282 | + }) | |
| 283 | + .catch(e => { | |
| 284 | + uni.hideLoading() | |
| 285 | + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' }) | |
| 286 | + }) | |
| 287 | + } | |
| 288 | + } | |
| 289 | +} | |
| 290 | +</script> | |
| 291 | + | |
| 292 | +<style lang="scss" scoped> | |
| 293 | +.page { | |
| 294 | + display: flex; | |
| 295 | + flex-direction: column; | |
| 296 | + height: 100%; | |
| 297 | +} | |
| 298 | + | |
| 299 | +.scroll { | |
| 300 | + flex: 1; | |
| 301 | + padding: 12rpx 0 200rpx !important; | |
| 302 | +} | |
| 303 | + | |
| 304 | +.footer { | |
| 305 | + z-index: 2; | |
| 306 | + position: fixed; | |
| 307 | + left: 0; | |
| 308 | + right: 0; | |
| 309 | + bottom: 0; | |
| 310 | + padding: 32rpx; | |
| 311 | + padding-bottom: calc(32rpx + env(safe-area-inset-bottom)); | |
| 312 | + background: #fff; | |
| 313 | + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06); | |
| 314 | + | |
| 315 | + .btn { | |
| 316 | + height: 80rpx; | |
| 317 | + line-height: 80rpx; | |
| 318 | + border-radius: 12rpx; | |
| 319 | + font-size: 32rpx; | |
| 320 | + } | |
| 321 | + | |
| 322 | + .submit { | |
| 323 | + background: $theme-primary; | |
| 324 | + color: #fff; | |
| 325 | + } | |
| 326 | +} | |
| 327 | + | |
| 328 | +::v-deep .uni-list { | |
| 329 | + .uni-easyinput { | |
| 330 | + display: flex; | |
| 331 | + | |
| 332 | + .uni-input-input { | |
| 333 | + color: rgba(0, 0, 0, 0.9); | |
| 334 | + } | |
| 335 | + } | |
| 336 | + | |
| 337 | + .uni-input-placeholder { | |
| 338 | + z-index: 1; | |
| 339 | + } | |
| 340 | + | |
| 341 | + .uni-input-input { | |
| 342 | + background-color: #ffffff; | |
| 343 | + } | |
| 344 | + | |
| 345 | + background: transparent; | |
| 346 | + | |
| 347 | + &-item { | |
| 348 | + &__extra-text { | |
| 349 | + font-size: 32rpx; | |
| 350 | + } | |
| 351 | + | |
| 352 | + &__content-title { | |
| 353 | + font-size: 32rpx; | |
| 354 | + color: rgba(0, 0, 0, 0.9); | |
| 355 | + } | |
| 356 | + | |
| 357 | + &__container { | |
| 358 | + padding: 32rpx; | |
| 359 | + | |
| 360 | + .item-title, | |
| 361 | + .uni-list-item__content { | |
| 362 | + flex: none; | |
| 363 | + min-height: 48rpx; | |
| 364 | + line-height: 48rpx; | |
| 365 | + font-size: 32rpx; | |
| 366 | + position: relative; | |
| 367 | + width: 240rpx; | |
| 368 | + margin-right: 32rpx; | |
| 369 | + color: rgba(0, 0, 0, 0.9); | |
| 370 | + | |
| 371 | + .required { | |
| 372 | + color: red; | |
| 373 | + position: absolute; | |
| 374 | + top: 50%; | |
| 375 | + transform: translateY(-50%); | |
| 376 | + left: -16rpx; | |
| 377 | + } | |
| 378 | + } | |
| 379 | + } | |
| 380 | + | |
| 381 | + &.select-item { | |
| 382 | + &.is-empty { | |
| 383 | + .uni-list-item__extra-text { | |
| 384 | + color: rgba(0, 0, 0, 0.4) !important; | |
| 385 | + } | |
| 386 | + } | |
| 387 | + | |
| 388 | + &.is-filled { | |
| 389 | + .uni-list-item__extra-text { | |
| 390 | + color: rgba(0, 0, 0, 0.9) !important; | |
| 391 | + } | |
| 392 | + } | |
| 393 | + | |
| 394 | + .serial-number-row { | |
| 395 | + display: flex; | |
| 396 | + align-items: center; | |
| 397 | + | |
| 398 | + .generate-btn { | |
| 399 | + margin-left: 24rpx; | |
| 400 | + height: 48rpx; | |
| 401 | + line-height: 48rpx; | |
| 402 | + padding: 0 24rpx; | |
| 403 | + font-size: 24rpx; | |
| 404 | + border-radius: 8rpx; | |
| 405 | + background: $theme-primary; | |
| 406 | + color: #fff; | |
| 407 | + } | |
| 408 | + } | |
| 409 | + } | |
| 410 | + } | |
| 411 | +} | |
| 412 | + | |
| 413 | +.readonly-text { | |
| 414 | + color: rgba(0, 0, 0, 0.9); | |
| 415 | + font-size: 32rpx; | |
| 416 | + line-height: 48rpx; | |
| 417 | + text-align: right; | |
| 418 | + white-space: pre-wrap; | |
| 419 | + word-break: break-all; | |
| 420 | +} | |
| 421 | + | |
| 422 | +.value-code { | |
| 423 | + width: 260rpx; | |
| 424 | + text-align: left; | |
| 425 | +} | |
| 426 | + | |
| 427 | +.picker-value { | |
| 428 | + font-size: 32rpx; | |
| 429 | + color: rgba(0, 0, 0, 0.9); | |
| 430 | + line-height: 48rpx; | |
| 431 | + text-align: right; | |
| 432 | + min-height: 48rpx; | |
| 433 | + | |
| 434 | + &.placeholder { | |
| 435 | + color: rgba(0, 0, 0, 0.4); | |
| 436 | + } | |
| 437 | +} | |
| 438 | +</style> | ... | ... |
pages/sample-submission/detail.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <view class="detail-page"> | |
| 5 | + <!-- 基础信息 --> | |
| 6 | + <view class="section"> | |
| 7 | + <text class="row company">{{ safeText(form.code) }}</text> | |
| 8 | + <view class="row"><text class="label">码单编号</text><text class="value">{{ safeText(form.weighingTicketCode) }}</text></view> | |
| 9 | + <view class="row"><text class="label">计划编号</text><text class="value">{{ safeText(form.planCode) }}</text></view> | |
| 10 | + <view class="row"><text class="label">品种</text><text class="value">{{ safeText(form.productName) }}</text></view> | |
| 11 | + <view class="row"><text class="label">科室</text><text class="value">{{ departmentName }}</text></view> | |
| 12 | + <view class="row"><text class="label">审核状态</text><text class="value">{{ approvalStatusName }}</text></view> | |
| 13 | + <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view> | |
| 14 | + <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view> | |
| 15 | + </view> | |
| 16 | + </view> | |
| 17 | + </scroll-view> | |
| 18 | + <detail-buttons :buttons="displayButtons" @click="handleButtonClick" /> | |
| 19 | + </view> | |
| 20 | +</template> | |
| 21 | + | |
| 22 | +<script> | |
| 23 | +import DetailButtons from '@/components/detail-buttons/index.vue' | |
| 24 | +import { getDicByCodes, getDicName } from '@/utils/dic.js' | |
| 25 | +import { | |
| 26 | + assayApplyDetailApi, | |
| 27 | + assayApplySubmitApi, | |
| 28 | + assayApplyCancelApi | |
| 29 | +} from '@/api/procure-manage/assayApply.js' | |
| 30 | +import { getInfo } from '@/api/login.js' | |
| 31 | + | |
| 32 | +export default { | |
| 33 | + name: 'SampleSubmissionDetail', | |
| 34 | + components: { DetailButtons }, | |
| 35 | + data() { | |
| 36 | + return { | |
| 37 | + id: '', | |
| 38 | + form: {}, | |
| 39 | + currentUserId: '', | |
| 40 | + dicOptions: { | |
| 41 | + DEPARTMENT: [], | |
| 42 | + AUDIT_STATUS: [] | |
| 43 | + }, | |
| 44 | + buttons: [ | |
| 45 | + { text: '修改', visible: true, variant: 'outline', event: 'edit' }, | |
| 46 | + { text: '提交审核', visible: true, variant: 'outline', event: 'submitAudit' }, | |
| 47 | + { text: '审核', visible: true, variant: 'primary', event: 'audit' }, | |
| 48 | + { text: '审核详情', visible: true, variant: 'outline', event: 'auditDetail' }, | |
| 49 | + { text: '取消', visible: true, variant: 'outline', event: 'cancel' } | |
| 50 | + ] | |
| 51 | + } | |
| 52 | + }, | |
| 53 | + computed: { | |
| 54 | + departmentName() { | |
| 55 | + const v = this.form.department == null ? '' : String(this.form.department) | |
| 56 | + if (!v) return '-' | |
| 57 | + return getDicName('DEPARTMENT', v, this.dicOptions.DEPARTMENT) || v | |
| 58 | + }, | |
| 59 | + approvalStatusName() { | |
| 60 | + const v = this.form.approvalStatus == null ? '' : String(this.form.approvalStatus) | |
| 61 | + if (!v) return '-' | |
| 62 | + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v | |
| 63 | + }, | |
| 64 | + displayButtons() { | |
| 65 | + const status = this.form.approvalStatus || '' | |
| 66 | + const isMine = this.form.createById === this.currentUserId | |
| 67 | + const isPass = status === 'PASS' | |
| 68 | + const isAudit = status === 'AUDIT' | |
| 69 | + const canExamine = isAudit && this.form.showExamine === true | |
| 70 | + const canExamineDetail = this.form.showExamineDetail === true | |
| 71 | + const canEdit = (status === 'DRAFT' || status === 'REFUSE' || !status) && isMine | |
| 72 | + return [ | |
| 73 | + { | |
| 74 | + ...this.buttons[0], | |
| 75 | + visible: canEdit && this.$auth.hasPermi('warehouse-manage:sample-submission:modify') | |
| 76 | + }, | |
| 77 | + { | |
| 78 | + ...this.buttons[1], | |
| 79 | + visible: canEdit && this.$auth.hasPermi('warehouse-manage:sample-submission:submit') | |
| 80 | + }, | |
| 81 | + { | |
| 82 | + ...this.buttons[2], | |
| 83 | + visible: canExamine && this.$auth.hasPermi('warehouse-manage:sample-submission:approve') | |
| 84 | + }, | |
| 85 | + { | |
| 86 | + ...this.buttons[3], | |
| 87 | + visible: canExamineDetail && this.$auth.hasPermi('warehouse-manage:sample-submission:review') | |
| 88 | + }, | |
| 89 | + { | |
| 90 | + ...this.buttons[4], | |
| 91 | + visible: (status === 'DRAFT' || status === 'REFUSE') && this.$auth.hasPermi('warehouse-manage:sample-submission:cancel') | |
| 92 | + } | |
| 93 | + ] | |
| 94 | + } | |
| 95 | + }, | |
| 96 | + onLoad(query) { | |
| 97 | + this.id = (query && query.id) || '' | |
| 98 | + this.loadDicData() | |
| 99 | + this.loadDetail() | |
| 100 | + this.getUserInfo() | |
| 101 | + }, | |
| 102 | + onShow() { | |
| 103 | + let needRefresh = '' | |
| 104 | + try { needRefresh = uni.getStorageSync('SAMPLE_SUBMISSION_DETAIL_NEED_REFRESH') } catch (e) {} | |
| 105 | + if (!needRefresh) return | |
| 106 | + try { uni.removeStorageSync('SAMPLE_SUBMISSION_DETAIL_NEED_REFRESH') } catch (e) {} | |
| 107 | + this.loadDetail() | |
| 108 | + }, | |
| 109 | + methods: { | |
| 110 | + async loadDicData() { | |
| 111 | + try { | |
| 112 | + const results = await getDicByCodes(['DEPARTMENT', 'AUDIT_STATUS']) | |
| 113 | + this.dicOptions.DEPARTMENT = (results.DEPARTMENT && results.DEPARTMENT.data) || [] | |
| 114 | + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || [] | |
| 115 | + } catch (e) { | |
| 116 | + this.dicOptions = { DEPARTMENT: [], AUDIT_STATUS: [] } | |
| 117 | + } | |
| 118 | + }, | |
| 119 | + async getUserInfo() { | |
| 120 | + try { | |
| 121 | + const res = await getInfo() | |
| 122 | + this.currentUserId = (res && (res.id || (res.data && res.data.id))) || '' | |
| 123 | + } catch (e) { | |
| 124 | + this.currentUserId = '' | |
| 125 | + } | |
| 126 | + }, | |
| 127 | + loadDetail() { | |
| 128 | + if (!this.id) { | |
| 129 | + uni.showToast({ title: '缺少单据ID', icon: 'none' }) | |
| 130 | + return | |
| 131 | + } | |
| 132 | + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true }) | |
| 133 | + assayApplyDetailApi({ id: this.id }) | |
| 134 | + .then(res => { | |
| 135 | + const data = res && res.data ? res.data : {} | |
| 136 | + this.form = Object.assign({}, data) | |
| 137 | + }) | |
| 138 | + .catch(() => { | |
| 139 | + uni.showToast({ title: '详情加载失败', icon: 'none' }) | |
| 140 | + }) | |
| 141 | + .finally(() => { | |
| 142 | + uni.hideLoading && uni.hideLoading() | |
| 143 | + }) | |
| 144 | + }, | |
| 145 | + handleButtonClick(btn) { | |
| 146 | + if (!btn || btn.disabled || !btn.visible) return | |
| 147 | + const e = btn.event || '' | |
| 148 | + if (e === 'edit') return this.onEdit() | |
| 149 | + if (e === 'submitAudit') return this.onSubmitAudit() | |
| 150 | + if (e === 'audit') return this.onAudit() | |
| 151 | + if (e === 'auditDetail') return this.onAuditDetail() | |
| 152 | + if (e === 'cancel') return this.onCancel() | |
| 153 | + }, | |
| 154 | + onEdit() { | |
| 155 | + uni.navigateTo({ url: '/pages/sample-submission/modify?id=' + this.id }) | |
| 156 | + }, | |
| 157 | + onAudit() { | |
| 158 | + const id = this.id || (this.form && this.form.id) || '' | |
| 159 | + if (!id) return | |
| 160 | + uni.setStorageSync('contractType', 'ASSAY_APPLY') | |
| 161 | + uni.setStorageSync('sourceBusinessId', id) | |
| 162 | + uni.navigateTo({ url: '/pages/flow/audit' }) | |
| 163 | + }, | |
| 164 | + onAuditDetail() { | |
| 165 | + const id = this.id || (this.form && this.form.id) || '' | |
| 166 | + if (!id) return | |
| 167 | + uni.setStorageSync('contractType', 'ASSAY_APPLY') | |
| 168 | + uni.setStorageSync('sourceBusinessId', id) | |
| 169 | + uni.navigateTo({ url: '/pages/flow/audit_detail' }) | |
| 170 | + }, | |
| 171 | + refreshListFlags() { | |
| 172 | + try { | |
| 173 | + uni.setStorageSync('SAMPLE_SUBMISSION_LIST_NEED_REFRESH', '1') | |
| 174 | + uni.setStorageSync('SAMPLE_SUBMISSION_DETAIL_NEED_REFRESH', '1') | |
| 175 | + } catch (e) {} | |
| 176 | + }, | |
| 177 | + runWithConfirm(opts) { | |
| 178 | + const title = opts.title || '提示' | |
| 179 | + const content = opts.content || '' | |
| 180 | + const run = opts.run | |
| 181 | + const loading = opts.loading || '处理中' | |
| 182 | + const successText = opts.successText || '操作成功' | |
| 183 | + const failText = opts.failText || '操作失败' | |
| 184 | + if (!this.id) { | |
| 185 | + uni.showToast({ title: '缺少单据ID', icon: 'none' }) | |
| 186 | + return | |
| 187 | + } | |
| 188 | + uni.showModal({ | |
| 189 | + title, | |
| 190 | + content, | |
| 191 | + confirmText: '确定', | |
| 192 | + cancelText: '取消', | |
| 193 | + success: res => { | |
| 194 | + if (!res || !res.confirm) return | |
| 195 | + uni.showLoading({ title: loading, mask: true }) | |
| 196 | + Promise.resolve(run(this.id)) | |
| 197 | + .then(() => { | |
| 198 | + uni.hideLoading() | |
| 199 | + uni.showToast({ title: successText, icon: 'none' }) | |
| 200 | + this.refreshListFlags() | |
| 201 | + this.loadDetail() | |
| 202 | + }) | |
| 203 | + .catch(e => { | |
| 204 | + uni.hideLoading() | |
| 205 | + uni.showToast({ title: (e && (e.msg || e.message)) || failText, icon: 'none' }) | |
| 206 | + }) | |
| 207 | + } | |
| 208 | + }) | |
| 209 | + }, | |
| 210 | + onSubmitAudit() { | |
| 211 | + this.runWithConfirm({ | |
| 212 | + title: '提交审核', | |
| 213 | + content: '确认提交审核吗?', | |
| 214 | + loading: '提交中', | |
| 215 | + successText: '提交审核成功', | |
| 216 | + failText: '提交审核失败', | |
| 217 | + run: id => assayApplySubmitApi(id) | |
| 218 | + }) | |
| 219 | + }, | |
| 220 | + onCancel() { | |
| 221 | + this.runWithConfirm({ | |
| 222 | + title: '取消', | |
| 223 | + content: '确认取消该化验送样单吗?', | |
| 224 | + loading: '处理中', | |
| 225 | + successText: '取消成功', | |
| 226 | + failText: '取消失败', | |
| 227 | + run: id => assayApplyCancelApi(id) | |
| 228 | + }) | |
| 229 | + }, | |
| 230 | + safeText(v) { | |
| 231 | + const s = v == null ? '' : String(v) | |
| 232 | + return s.trim() ? s : '-' | |
| 233 | + } | |
| 234 | + } | |
| 235 | +} | |
| 236 | +</script> | |
| 237 | + | |
| 238 | +<style lang="scss" scoped> | |
| 239 | +.page { | |
| 240 | + display: flex; | |
| 241 | + flex-direction: column; | |
| 242 | + height: 100%; | |
| 243 | +} | |
| 244 | +.scroll { | |
| 245 | + flex: 1; | |
| 246 | + padding: 8rpx 0 144rpx; | |
| 247 | +} | |
| 248 | +.detail-page { | |
| 249 | + background: #f3f3f3; | |
| 250 | +} | |
| 251 | +.section { | |
| 252 | + padding: 32rpx; | |
| 253 | + background: #fff; | |
| 254 | + margin-bottom: 20rpx; | |
| 255 | +} | |
| 256 | +.row { | |
| 257 | + display: flex; | |
| 258 | + margin-bottom: 28rpx; | |
| 259 | + &:last-child { margin-bottom: 0; } | |
| 260 | + &.company { | |
| 261 | + font-size: 36rpx; | |
| 262 | + font-weight: 600; | |
| 263 | + color: rgba(0, 0, 0, 0.9); | |
| 264 | + padding-top: 8rpx; | |
| 265 | + line-height: 50rpx; | |
| 266 | + } | |
| 267 | + .label { | |
| 268 | + max-width: 420rpx; | |
| 269 | + margin-right: 20rpx; | |
| 270 | + line-height: 32rpx; | |
| 271 | + font-size: 28rpx; | |
| 272 | + color: rgba(0, 0, 0, 0.6); | |
| 273 | + } | |
| 274 | + .value { | |
| 275 | + flex: 1; | |
| 276 | + line-height: 32rpx; | |
| 277 | + font-size: 28rpx; | |
| 278 | + color: rgba(0, 0, 0, 0.9); | |
| 279 | + text-align: right; | |
| 280 | + word-break: break-all; | |
| 281 | + } | |
| 282 | +} | |
| 283 | +</style> | ... | ... |
pages/sample-submission/index.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <view class="ticket-list-fixed"> | |
| 4 | + <view class="search-row"> | |
| 5 | + <uni-search-bar | |
| 6 | + v-model="searchKeyword" | |
| 7 | + radius="6" | |
| 8 | + placeholder="请输入码单编号" | |
| 9 | + clearButton="auto" | |
| 10 | + cancelButton="none" | |
| 11 | + bgColor="#F3F3F3" | |
| 12 | + textColor="rgba(0,0,0,0.4)" | |
| 13 | + @confirm="search" | |
| 14 | + @input="onSearchInput" | |
| 15 | + /> | |
| 16 | + <view class="tool-icons"> | |
| 17 | + <image | |
| 18 | + v-if="$auth.hasPermi('warehouse-manage:sample-submission:add')" | |
| 19 | + class="tool-icon" | |
| 20 | + src="/static/images/dev_manage/add_icon.png" | |
| 21 | + @click="onAdd" | |
| 22 | + /> | |
| 23 | + <image class="tool-icon" src="/static/images/dev_manage/filter_icon.png" @click="openFilter" /> | |
| 24 | + </view> | |
| 25 | + </view> | |
| 26 | + | |
| 27 | + <view class="tabs"> | |
| 28 | + <view | |
| 29 | + v-for="(t, i) in tabs" | |
| 30 | + :key="i" | |
| 31 | + :class="['tab', { active: deleted === t.value }]" | |
| 32 | + @click="switchTab(t)" | |
| 33 | + > | |
| 34 | + {{ t.label }} | |
| 35 | + </view> | |
| 36 | + </view> | |
| 37 | + </view> | |
| 38 | + | |
| 39 | + <view class="list-box"> | |
| 40 | + <card-list | |
| 41 | + ref="cardRef" | |
| 42 | + :fetch-fn="fetchList" | |
| 43 | + :query="query" | |
| 44 | + :extra="extraParams" | |
| 45 | + row-key="id" | |
| 46 | + :enable-refresh="true" | |
| 47 | + :enable-load-more="true" | |
| 48 | + @loaded="onCardLoaded" | |
| 49 | + @error="onCardError" | |
| 50 | + > | |
| 51 | + <template v-slot="{ item }"> | |
| 52 | + <view class="card" @click="onCardClick(item)"> | |
| 53 | + <view class="card-header"> | |
| 54 | + <text class="title omit2">{{ item.weighingTicketCode || '-' }}</text> | |
| 55 | + <text :class="['status', `status_${item.approvalStatus}`]">{{ getAuditStatusText(item.approvalStatus) }}</text> | |
| 56 | + </view> | |
| 57 | + <view class="info-row"> | |
| 58 | + <text>品种</text> | |
| 59 | + <text>{{ item.productName || '-' }}</text> | |
| 60 | + </view> | |
| 61 | + <view class="info-row"> | |
| 62 | + <text>计划编号</text> | |
| 63 | + <text>{{ item.planCode || '-' }}</text> | |
| 64 | + </view> | |
| 65 | + <view class="info-row"> | |
| 66 | + <text>创建人</text> | |
| 67 | + <text>{{ item.createBy || '-' }}</text> | |
| 68 | + </view> | |
| 69 | + <view class="info-row"> | |
| 70 | + <text>时间</text> | |
| 71 | + <text>{{ item.createTime || '-' }}</text> | |
| 72 | + </view> | |
| 73 | + </view> | |
| 74 | + </template> | |
| 75 | + </card-list> | |
| 76 | + </view> | |
| 77 | + | |
| 78 | + <filter-modal | |
| 79 | + :visible.sync="filterVisible" | |
| 80 | + :value.sync="filterForm" | |
| 81 | + title="筛选" | |
| 82 | + @reset="onFilterReset" | |
| 83 | + @confirm="onFilterConfirm" | |
| 84 | + > | |
| 85 | + <template v-slot="{ model }"> | |
| 86 | + <view class="filter-form"> | |
| 87 | + <view class="form-item"> | |
| 88 | + <view class="label">码单编号</view> | |
| 89 | + <input class="input" v-model="model.weighingTicketCode" placeholder="请输入码单编号" /> | |
| 90 | + </view> | |
| 91 | + <view class="form-item"> | |
| 92 | + <view class="label">品种</view> | |
| 93 | + <input class="input" v-model="model.productName" placeholder="请输入品种" /> | |
| 94 | + </view> | |
| 95 | + <view class="form-item"> | |
| 96 | + <view class="label">计划编号</view> | |
| 97 | + <input class="input" v-model="model.planCode" placeholder="请输入计划编号" /> | |
| 98 | + </view> | |
| 99 | + <view class="form-item"> | |
| 100 | + <view class="label">审核状态</view> | |
| 101 | + <uni-data-checkbox | |
| 102 | + mode="tag" | |
| 103 | + :multiple="false" | |
| 104 | + :value-field="'value'" | |
| 105 | + :text-field="'text'" | |
| 106 | + v-model="model.approvalStatus" | |
| 107 | + :localdata="approvalStatusOptions" | |
| 108 | + /> | |
| 109 | + </view> | |
| 110 | + <view class="form-item"> | |
| 111 | + <view class="label">创建人</view> | |
| 112 | + <input class="input" v-model="model.createBy" placeholder="请输入创建人" /> | |
| 113 | + </view> | |
| 114 | + </view> | |
| 115 | + </template> | |
| 116 | + </filter-modal> | |
| 117 | + </view> | |
| 118 | +</template> | |
| 119 | + | |
| 120 | +<script> | |
| 121 | +import CardList from '@/components/card/index.vue' | |
| 122 | +import FilterModal from '@/components/filter/index.vue' | |
| 123 | +import { getDicByCodes, getDicName } from '@/utils/dic.js' | |
| 124 | +import { assayApplyQueryApi } from '@/api/procure-manage/assayApply.js' | |
| 125 | + | |
| 126 | +export default { | |
| 127 | + name: 'SampleSubmissionList', | |
| 128 | + components: { CardList, FilterModal }, | |
| 129 | + data() { | |
| 130 | + return { | |
| 131 | + searchKeyword: '', | |
| 132 | + searchKeywordDebounced: '', | |
| 133 | + searchDebounceTimer: null, | |
| 134 | + deleted: false, | |
| 135 | + tabs: [ | |
| 136 | + { label: '有效', value: false }, | |
| 137 | + { label: '作废', value: true } | |
| 138 | + ], | |
| 139 | + query: { | |
| 140 | + weighingTicketCode: '', | |
| 141 | + productName: '', | |
| 142 | + planCode: '', | |
| 143 | + approvalStatus: '', | |
| 144 | + createBy: '' | |
| 145 | + }, | |
| 146 | + extraParams: {}, | |
| 147 | + currentItems: [], | |
| 148 | + filterVisible: false, | |
| 149 | + filterForm: { | |
| 150 | + weighingTicketCode: '', | |
| 151 | + productName: '', | |
| 152 | + planCode: '', | |
| 153 | + approvalStatus: '', | |
| 154 | + createBy: '' | |
| 155 | + }, | |
| 156 | + approvalStatusOptions: [ | |
| 157 | + { value: '', text: '全部' }, | |
| 158 | + { value: 'DRAFT', text: '草稿' }, | |
| 159 | + { value: 'AUDIT', text: '审核中' }, | |
| 160 | + { value: 'PASS', text: '审核通过' }, | |
| 161 | + { value: 'REFUSE', text: '已驳回' }, | |
| 162 | + { value: 'CANCEL', text: '已取消' } | |
| 163 | + ], | |
| 164 | + dicOptions: { | |
| 165 | + AUDIT_STATUS: [] | |
| 166 | + } | |
| 167 | + } | |
| 168 | + }, | |
| 169 | + computed: { | |
| 170 | + extraCombined() { | |
| 171 | + return { | |
| 172 | + keyword: this.searchKeywordDebounced || undefined, | |
| 173 | + deleted: this.deleted | |
| 174 | + } | |
| 175 | + } | |
| 176 | + }, | |
| 177 | + watch: { | |
| 178 | + extraCombined: { | |
| 179 | + deep: true, | |
| 180 | + handler(v) { | |
| 181 | + this.extraParams = v | |
| 182 | + }, | |
| 183 | + immediate: true | |
| 184 | + } | |
| 185 | + }, | |
| 186 | + created() { | |
| 187 | + this.loadDicData() | |
| 188 | + }, | |
| 189 | + onShow() { | |
| 190 | + let needRefresh = '' | |
| 191 | + try { needRefresh = uni.getStorageSync('SAMPLE_SUBMISSION_LIST_NEED_REFRESH') } catch (e) {} | |
| 192 | + if (!needRefresh) return | |
| 193 | + try { uni.removeStorageSync('SAMPLE_SUBMISSION_LIST_NEED_REFRESH') } catch (e) {} | |
| 194 | + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.reload) { | |
| 195 | + this.$refs.cardRef.reload() | |
| 196 | + } | |
| 197 | + }, | |
| 198 | + onReachBottom() { | |
| 199 | + if (this.$refs && this.$refs.cardRef && this.$refs.cardRef.onLoadMore) { | |
| 200 | + this.$refs.cardRef.onLoadMore() | |
| 201 | + } | |
| 202 | + }, | |
| 203 | + beforeDestroy() { | |
| 204 | + if (this.searchDebounceTimer) { | |
| 205 | + clearTimeout(this.searchDebounceTimer) | |
| 206 | + this.searchDebounceTimer = null | |
| 207 | + } | |
| 208 | + }, | |
| 209 | + methods: { | |
| 210 | + async loadDicData() { | |
| 211 | + try { | |
| 212 | + const results = await getDicByCodes(['AUDIT_STATUS']) | |
| 213 | + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || [] | |
| 214 | + } catch (e) { | |
| 215 | + this.dicOptions.AUDIT_STATUS = [] | |
| 216 | + } | |
| 217 | + }, | |
| 218 | + getAuditStatusText(status) { | |
| 219 | + const v = status == null ? '' : String(status) | |
| 220 | + if (!v) return '-' | |
| 221 | + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v | |
| 222 | + }, | |
| 223 | + onCardLoaded({ items }) { | |
| 224 | + this.currentItems = items | |
| 225 | + }, | |
| 226 | + onCardError() { | |
| 227 | + uni.showToast({ title: '列表加载失败', icon: 'none' }) | |
| 228 | + }, | |
| 229 | + onAdd() { | |
| 230 | + uni.navigateTo({ url: '/pages/sample-submission/add' }) | |
| 231 | + }, | |
| 232 | + onSearchInput() { | |
| 233 | + if (this.searchDebounceTimer) clearTimeout(this.searchDebounceTimer) | |
| 234 | + this.searchDebounceTimer = setTimeout(() => { | |
| 235 | + this.searchKeywordDebounced = this.searchKeyword | |
| 236 | + this.searchDebounceTimer = null | |
| 237 | + }, 1200) | |
| 238 | + }, | |
| 239 | + search(e) { | |
| 240 | + const val = e && e.value != null ? e.value : this.searchKeyword | |
| 241 | + this.searchKeyword = val | |
| 242 | + this.searchKeywordDebounced = val | |
| 243 | + }, | |
| 244 | + switchTab(t) { | |
| 245 | + this.deleted = t.value | |
| 246 | + }, | |
| 247 | + openFilter() { | |
| 248 | + this.filterForm = { | |
| 249 | + weighingTicketCode: this.query.weighingTicketCode || '', | |
| 250 | + productName: this.query.productName || '', | |
| 251 | + planCode: this.query.planCode || '', | |
| 252 | + approvalStatus: this.query.approvalStatus || '', | |
| 253 | + createBy: this.query.createBy || '' | |
| 254 | + } | |
| 255 | + this.filterVisible = true | |
| 256 | + }, | |
| 257 | + onFilterReset(payload) { | |
| 258 | + this.filterForm = payload | |
| 259 | + }, | |
| 260 | + onFilterConfirm(payload) { | |
| 261 | + this.query = { | |
| 262 | + weighingTicketCode: payload.weighingTicketCode || '', | |
| 263 | + productName: payload.productName || '', | |
| 264 | + planCode: payload.planCode || '', | |
| 265 | + approvalStatus: payload.approvalStatus || '', | |
| 266 | + createBy: payload.createBy || '' | |
| 267 | + } | |
| 268 | + }, | |
| 269 | + fetchList({ pageIndex, pageSize, query, extra }) { | |
| 270 | + const q = query || {} | |
| 271 | + const e = extra || {} | |
| 272 | + const keyword = e.keyword || '' | |
| 273 | + const params = { | |
| 274 | + pageIndex, | |
| 275 | + pageSize, | |
| 276 | + deleted: e.deleted === true, | |
| 277 | + weighingTicketCode: q.weighingTicketCode || keyword || '', | |
| 278 | + productName: q.productName || '', | |
| 279 | + planCode: q.planCode || '', | |
| 280 | + approvalStatus: q.approvalStatus || '', | |
| 281 | + createBy: q.createBy || '' | |
| 282 | + } | |
| 283 | + return assayApplyQueryApi(params) | |
| 284 | + .then(res => { | |
| 285 | + const _data = (res && res.data) || {} | |
| 286 | + let records = _data.datas || _data.list || _data.records || [] | |
| 287 | + const totalCount = _data.totalCount || _data.count || 0 | |
| 288 | + const hasNext = _data.hasNext || false | |
| 289 | + records = records.map(it => ({ ...it })) | |
| 290 | + return { records, totalCount, hasNext } | |
| 291 | + }) | |
| 292 | + .catch(() => { | |
| 293 | + this.onCardError() | |
| 294 | + return { records: [], totalCount: 0, hasNext: false } | |
| 295 | + }) | |
| 296 | + }, | |
| 297 | + onCardClick(item) { | |
| 298 | + const id = item && item.id | |
| 299 | + if (!id) { | |
| 300 | + uni.showToast({ title: '缺少ID', icon: 'none' }) | |
| 301 | + return | |
| 302 | + } | |
| 303 | + uni.navigateTo({ url: '/pages/sample-submission/detail?id=' + id }) | |
| 304 | + } | |
| 305 | + } | |
| 306 | +} | |
| 307 | +</script> | |
| 308 | + | |
| 309 | +<style lang="scss" scoped> | |
| 310 | +.page { | |
| 311 | + display: flex; | |
| 312 | + flex-direction: column; | |
| 313 | + height: 100vh; | |
| 314 | +} | |
| 315 | +.ticket-list-fixed { | |
| 316 | + position: fixed; | |
| 317 | + top: 96rpx; | |
| 318 | + left: 0; | |
| 319 | + right: 0; | |
| 320 | + z-index: 2; | |
| 321 | + background: #fff; | |
| 322 | + .search-row { | |
| 323 | + display: flex; | |
| 324 | + align-items: center; | |
| 325 | + padding: 16rpx 32rpx; | |
| 326 | + .uni-searchbar { padding: 0; flex: 1; } | |
| 327 | + .tool-icons { | |
| 328 | + display: flex; | |
| 329 | + .tool-icon { width: 48rpx; height: 48rpx; display: block; margin-left: 32rpx; } | |
| 330 | + } | |
| 331 | + } | |
| 332 | + .tabs { | |
| 333 | + display: flex; | |
| 334 | + align-items: center; | |
| 335 | + justify-content: space-between; | |
| 336 | + padding: 26rpx 34rpx; | |
| 337 | + border-bottom: solid 1px #e7e7e7; | |
| 338 | + .tab { width: 50%; text-align: center; color: rgba(0, 0, 0, 0.9); line-height: 44rpx; position: relative; font-weight: 600; } | |
| 339 | + .tab.active { color: $theme-primary; } | |
| 340 | + .tab.active::after { | |
| 341 | + content: ''; | |
| 342 | + position: absolute; | |
| 343 | + left: 50%; | |
| 344 | + transform: translateX(-50%); | |
| 345 | + bottom: -13px; | |
| 346 | + width: 32rpx; | |
| 347 | + height: 6rpx; | |
| 348 | + border-radius: 4rpx; | |
| 349 | + background: $theme-primary; | |
| 350 | + } | |
| 351 | + } | |
| 352 | +} | |
| 353 | +::v-deep .uni-searchbar__box { | |
| 354 | + height: 80rpx !important; | |
| 355 | + justify-content: start; | |
| 356 | + .uni-searchbar__box-search-input { font-size: 32rpx !important; } | |
| 357 | +} | |
| 358 | +.list-box { | |
| 359 | + flex: 1; | |
| 360 | + padding-top: 236rpx; | |
| 361 | + .card { position: relative; } | |
| 362 | + .card-header { | |
| 363 | + margin-bottom: 28rpx; | |
| 364 | + position: relative; | |
| 365 | + .title { font-size: 36rpx; font-weight: 600; line-height: 50rpx; color: rgba(0, 0, 0, 0.9); width: 578rpx; } | |
| 366 | + .status { | |
| 367 | + position: absolute; | |
| 368 | + top: -32rpx; | |
| 369 | + right: -12rpx; | |
| 370 | + height: 48rpx; | |
| 371 | + line-height: 48rpx; | |
| 372 | + font-weight: 600; | |
| 373 | + color: #fff; | |
| 374 | + font-size: 24rpx; | |
| 375 | + padding: 0 14rpx; | |
| 376 | + border-radius: 6rpx; | |
| 377 | + box-sizing: content-box; | |
| 378 | + | |
| 379 | + &.status_AUDIT { background: $theme-primary; } | |
| 380 | + &.status_PASS { background: #2ba471; } | |
| 381 | + &.status_REFUSE { background: #d54941; } | |
| 382 | + &.status_DRAFT { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); } | |
| 383 | + &.status_CANCEL { background: #e7e7e7; color: rgba(0, 0, 0, 0.9); } | |
| 384 | + } | |
| 385 | + } | |
| 386 | + .info-row { | |
| 387 | + display: flex; | |
| 388 | + align-items: center; | |
| 389 | + color: rgba(0, 0, 0, 0.6); | |
| 390 | + font-size: 28rpx; | |
| 391 | + margin-bottom: 24rpx; | |
| 392 | + height: 32rpx; | |
| 393 | + &:last-child { margin-bottom: 0; } | |
| 394 | + text { | |
| 395 | + width: 50%; | |
| 396 | + &:last-child { | |
| 397 | + color: rgba(0, 0, 0, 0.9); | |
| 398 | + width: 50%; | |
| 399 | + overflow: hidden; | |
| 400 | + text-overflow: ellipsis; | |
| 401 | + white-space: nowrap; | |
| 402 | + } | |
| 403 | + } | |
| 404 | + } | |
| 405 | +} | |
| 406 | +.filter-form { | |
| 407 | + .form-item { margin-bottom: 24rpx; } | |
| 408 | + .label { margin-bottom: 20rpx; color: rgba(0, 0, 0, 0.9); height: 44rpx; line-height: 44rpx; font-size: 30rpx; } | |
| 409 | + .input { | |
| 410 | + width: 100%; | |
| 411 | + height: 72rpx; | |
| 412 | + line-height: 72rpx; | |
| 413 | + padding: 0 24rpx; | |
| 414 | + border: 1rpx solid #e7e7e7; | |
| 415 | + border-radius: 8rpx; | |
| 416 | + font-size: 28rpx; | |
| 417 | + color: rgba(0, 0, 0, 0.9); | |
| 418 | + background: #fff; | |
| 419 | + box-sizing: border-box; | |
| 420 | + } | |
| 421 | +} | |
| 422 | +</style> | ... | ... |
pages/sample-submission/modify.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <view class="page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <uni-list> | |
| 5 | + <!-- 送样编号(只读) --> | |
| 6 | + <uni-list-item class="select-item" :class="form.code ? 'is-filled' : 'is-empty'"> | |
| 7 | + <template v-slot:body> | |
| 8 | + <view class="item-title"><text class="required">*</text><text>送样编号</text></view> | |
| 9 | + </template> | |
| 10 | + <template v-slot:footer> | |
| 11 | + <text class="readonly-text value-code">{{ form.code || '-' }}</text> | |
| 12 | + </template> | |
| 13 | + </uni-list-item> | |
| 14 | + | |
| 15 | + <!-- 码单编号(弹窗选择) --> | |
| 16 | + <uni-list-item class="select-item" :class="form.weighingTicketCode ? 'is-filled' : 'is-empty'" clickable | |
| 17 | + @click="openTicketSheet" :rightText="form.weighingTicketCode || '请选择码单'" 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 | + <!-- 计划编号 --> | |
| 24 | + <uni-list-item class="select-item" :class="form.procurementPlanId ? 'is-filled' : 'is-empty'"> | |
| 25 | + <template v-slot:body> | |
| 26 | + <view class="item-title"><text class="required">*</text><text>计划编号</text></view> | |
| 27 | + </template> | |
| 28 | + <template v-slot:footer> | |
| 29 | + <picker mode="selector" :range="planLabels" @change="onPlanChange" :disabled="!planOptions.length"> | |
| 30 | + <view class="picker-value" :class="{ placeholder: !form.procurementPlanId }"> | |
| 31 | + {{ getPlanLabel() || '请选择计划编号' }} | |
| 32 | + </view> | |
| 33 | + </picker> | |
| 34 | + </template> | |
| 35 | + </uni-list-item> | |
| 36 | + | |
| 37 | + <!-- 品种 --> | |
| 38 | + <uni-list-item class="select-item" :class="form.productId ? 'is-filled' : 'is-empty'"> | |
| 39 | + <template v-slot:body> | |
| 40 | + <view class="item-title"><text class="required">*</text><text>品种</text></view> | |
| 41 | + </template> | |
| 42 | + <template v-slot:footer> | |
| 43 | + <picker mode="selector" :range="productLabels" @change="onProductChange" :disabled="!productOptions.length"> | |
| 44 | + <view class="picker-value" :class="{ placeholder: !form.productId }"> | |
| 45 | + {{ getProductLabel() || '请选择品种' }} | |
| 46 | + </view> | |
| 47 | + </picker> | |
| 48 | + </template> | |
| 49 | + </uni-list-item> | |
| 50 | + | |
| 51 | + <!-- 科室 --> | |
| 52 | + <uni-list-item class="select-item" :class="form.department ? 'is-filled' : 'is-empty'"> | |
| 53 | + <template v-slot:body> | |
| 54 | + <view class="item-title"><text class="required">*</text><text>科室</text></view> | |
| 55 | + </template> | |
| 56 | + <template v-slot:footer> | |
| 57 | + <picker mode="selector" :range="departmentLabels" @change="onDepartmentChange"> | |
| 58 | + <view class="picker-value" :class="{ placeholder: !form.department }"> | |
| 59 | + {{ getDepartmentLabel() || '请选择科室' }} | |
| 60 | + </view> | |
| 61 | + </picker> | |
| 62 | + </template> | |
| 63 | + </uni-list-item> | |
| 64 | + </uni-list> | |
| 65 | + | |
| 66 | + <view class="footer"> | |
| 67 | + <button class="btn submit" type="primary" @click="onSubmit">保存</button> | |
| 68 | + </view> | |
| 69 | + </scroll-view> | |
| 70 | + | |
| 71 | + <RelateSelectSheet :visible.sync="ticketSheet.visible" title="选择码单" :multiple="false" | |
| 72 | + :fetchFn="ticketSheet.fetchFn" :display-fields="ticketSheet.displayFields" | |
| 73 | + row-key="id" :selectedKeys.sync="ticketSheet.selectedKeys" @confirm="onTicketConfirm" /> | |
| 74 | + </view> | |
| 75 | +</template> | |
| 76 | + | |
| 77 | +<script> | |
| 78 | +import RelateSelectSheet from '@/components/relate-select/index.vue' | |
| 79 | +import { | |
| 80 | + assayApplyDetailApi, | |
| 81 | + assayApplyUpdateApi, | |
| 82 | + assayApplyTicketPageApi, | |
| 83 | + assayApplyTicketDataApi, | |
| 84 | + assayApplyBreedOptionsApi | |
| 85 | +} from '@/api/procure-manage/assayApply.js' | |
| 86 | +import { getDicByCodes } from '@/utils/dic.js' | |
| 87 | + | |
| 88 | +export default { | |
| 89 | + name: 'ModifySampleSubmission', | |
| 90 | + components: { RelateSelectSheet }, | |
| 91 | + data() { | |
| 92 | + return { | |
| 93 | + id: '', | |
| 94 | + form: { | |
| 95 | + code: '', | |
| 96 | + weighingTicketId: '', | |
| 97 | + weighingTicketCode: '', | |
| 98 | + procurementPlanId: '', | |
| 99 | + productId: '', | |
| 100 | + department: '' | |
| 101 | + }, | |
| 102 | + dicOptions: { DEPARTMENT: [] }, | |
| 103 | + // 计划编号下拉选项(所选码单下的计划) | |
| 104 | + planOptions: [], | |
| 105 | + // 品种下拉选项(所选计划下的过磅品种) | |
| 106 | + productOptions: [], | |
| 107 | + ticketSheet: { | |
| 108 | + visible: false, | |
| 109 | + fetchFn: null, | |
| 110 | + displayFields: [ | |
| 111 | + { label: '码单编号', field: 'code' }, | |
| 112 | + { label: '分厂', field: 'workshopName' }, | |
| 113 | + { label: '创建人', field: 'createBy' }, | |
| 114 | + { label: '创建时间', field: 'createTime' } | |
| 115 | + ], | |
| 116 | + selectedKeys: [] | |
| 117 | + } | |
| 118 | + } | |
| 119 | + }, | |
| 120 | + computed: { | |
| 121 | + planLabels() { | |
| 122 | + return (this.planOptions || []).map(it => it.label) | |
| 123 | + }, | |
| 124 | + productLabels() { | |
| 125 | + return (this.productOptions || []).map(it => it.label) | |
| 126 | + }, | |
| 127 | + departmentLabels() { | |
| 128 | + return (this.dicOptions.DEPARTMENT || []).map(it => it.name) | |
| 129 | + } | |
| 130 | + }, | |
| 131 | + created() { | |
| 132 | + this.ticketSheet.fetchFn = this.fetchTickets.bind(this) | |
| 133 | + this.loadDicData() | |
| 134 | + }, | |
| 135 | + onLoad(query) { | |
| 136 | + this.id = (query && query.id) || '' | |
| 137 | + this.loadDetail() | |
| 138 | + }, | |
| 139 | + methods: { | |
| 140 | + async loadDicData() { | |
| 141 | + try { | |
| 142 | + const results = await getDicByCodes(['DEPARTMENT']) | |
| 143 | + this.dicOptions.DEPARTMENT = (results.DEPARTMENT && results.DEPARTMENT.data) || [] | |
| 144 | + } catch (e) { | |
| 145 | + this.dicOptions.DEPARTMENT = [] | |
| 146 | + } | |
| 147 | + }, | |
| 148 | + loadDetail() { | |
| 149 | + if (!this.id) { | |
| 150 | + uni.showToast({ title: '缺少单据ID', icon: 'none' }) | |
| 151 | + return | |
| 152 | + } | |
| 153 | + uni.showLoading && uni.showLoading({ title: '加载中...', mask: true }) | |
| 154 | + assayApplyDetailApi({ id: this.id }) | |
| 155 | + .then(res => { | |
| 156 | + const data = res && res.data ? res.data : {} | |
| 157 | + this.form = { | |
| 158 | + code: data.code || '', | |
| 159 | + weighingTicketId: data.weighingTicketId || '', | |
| 160 | + weighingTicketCode: data.weighingTicketCode || '', | |
| 161 | + procurementPlanId: data.procurementPlanId || '', | |
| 162 | + productId: data.productId || '', | |
| 163 | + department: data.department == null ? '' : String(data.department) | |
| 164 | + } | |
| 165 | + // 计划编号/品种下拉:先用详情数据兜底,再异步刷新真实选项 | |
| 166 | + this.planOptions = this.form.procurementPlanId | |
| 167 | + ? [{ label: data.planCode || '', value: this.form.procurementPlanId }] | |
| 168 | + : [] | |
| 169 | + this.productOptions = this.form.productId | |
| 170 | + ? [{ label: data.productName || '', value: this.form.productId }] | |
| 171 | + : [] | |
| 172 | + if (this.form.weighingTicketId) { | |
| 173 | + this.loadPlanOptions(this.form.weighingTicketId) | |
| 174 | + } | |
| 175 | + if (this.form.weighingTicketId && this.form.procurementPlanId) { | |
| 176 | + this.loadProductOptions(this.form.weighingTicketId, this.form.procurementPlanId) | |
| 177 | + } | |
| 178 | + }) | |
| 179 | + .catch(() => { | |
| 180 | + uni.showToast({ title: '详情加载失败', icon: 'none' }) | |
| 181 | + }) | |
| 182 | + .finally(() => { | |
| 183 | + uni.hideLoading && uni.hideLoading() | |
| 184 | + }) | |
| 185 | + }, | |
| 186 | + // 码单选择弹窗数据源(可选过磅码单分页) | |
| 187 | + fetchTickets({ pageIndex, pageSize, extra }) { | |
| 188 | + const keyword = (extra && extra.keyword) || '' | |
| 189 | + const params = { | |
| 190 | + pageIndex, | |
| 191 | + pageSize, | |
| 192 | + code: keyword || undefined | |
| 193 | + } | |
| 194 | + return assayApplyTicketPageApi(params).then(res => { | |
| 195 | + const _data = (res && res.data) || {} | |
| 196 | + const records = _data.datas || _data.list || _data.records || [] | |
| 197 | + const totalCount = _data.totalCount || _data.count || 0 | |
| 198 | + const hasNext = _data.hasNext || false | |
| 199 | + return { records, totalCount, hasNext } | |
| 200 | + }).catch(() => ({ records: [], totalCount: 0, hasNext: false })) | |
| 201 | + }, | |
| 202 | + openTicketSheet() { | |
| 203 | + this.ticketSheet.selectedKeys = this.form.weighingTicketId ? [this.form.weighingTicketId] : [] | |
| 204 | + this.ticketSheet.visible = true | |
| 205 | + }, | |
| 206 | + // 码单选择回调:联动刷新计划编号下拉并重置品种 | |
| 207 | + onTicketConfirm({ items }) { | |
| 208 | + const row = (items || [])[0] | |
| 209 | + if (!row) { | |
| 210 | + this.resetDownStream() | |
| 211 | + return | |
| 212 | + } | |
| 213 | + this.form.weighingTicketId = row.id || '' | |
| 214 | + this.form.weighingTicketCode = row.code || '' | |
| 215 | + this.resetDownStream() | |
| 216 | + this.loadPlanOptions(row.id) | |
| 217 | + }, | |
| 218 | + resetDownStream() { | |
| 219 | + this.form.procurementPlanId = '' | |
| 220 | + this.form.productId = '' | |
| 221 | + this.planOptions = [] | |
| 222 | + this.productOptions = [] | |
| 223 | + }, | |
| 224 | + // 根据所选码单加载计划编号下拉选项 | |
| 225 | + loadPlanOptions(ticketId) { | |
| 226 | + assayApplyTicketDataApi(ticketId) | |
| 227 | + .then(res => { | |
| 228 | + const data = (res && res.data) || {} | |
| 229 | + const options = ((data && data.planOptions) || []).map(item => ({ | |
| 230 | + label: item.planCode, | |
| 231 | + value: item.planId | |
| 232 | + })) | |
| 233 | + // 兜底:确保当前已选计划仍在选项中(回显时不丢失显示) | |
| 234 | + if (this.form.procurementPlanId && | |
| 235 | + !options.some(item => item.value === this.form.procurementPlanId)) { | |
| 236 | + const fallback = this.planOptions.find( | |
| 237 | + item => item.value === this.form.procurementPlanId | |
| 238 | + ) | |
| 239 | + if (fallback) { | |
| 240 | + options.push(fallback) | |
| 241 | + } | |
| 242 | + } | |
| 243 | + this.planOptions = options | |
| 244 | + }) | |
| 245 | + .catch(() => {}) | |
| 246 | + }, | |
| 247 | + // 根据所选码单与计划加载品种下拉选项 | |
| 248 | + loadProductOptions(ticketId, planId) { | |
| 249 | + assayApplyBreedOptionsApi({ | |
| 250 | + ticketId: ticketId || undefined, | |
| 251 | + planId | |
| 252 | + }) | |
| 253 | + .then(res => { | |
| 254 | + const list = (res && res.data) || [] | |
| 255 | + const options = (list || []).map(item => ({ | |
| 256 | + label: item.productName, | |
| 257 | + value: item.productId | |
| 258 | + })) | |
| 259 | + // 兜底:确保当前已选品种仍在选项中(回显时不丢失显示) | |
| 260 | + if (this.form.productId && | |
| 261 | + !options.some(item => item.value === this.form.productId)) { | |
| 262 | + const fallback = this.productOptions.find( | |
| 263 | + item => item.value === this.form.productId | |
| 264 | + ) | |
| 265 | + if (fallback) { | |
| 266 | + options.push(fallback) | |
| 267 | + } | |
| 268 | + } | |
| 269 | + this.productOptions = options | |
| 270 | + }) | |
| 271 | + .catch(() => {}) | |
| 272 | + }, | |
| 273 | + getPlanLabel() { | |
| 274 | + const found = (this.planOptions || []).find(it => it.value === this.form.procurementPlanId) | |
| 275 | + return found ? found.label : '' | |
| 276 | + }, | |
| 277 | + // 计划编号改选后:重置品种并按所选计划刷新过磅品种下拉 | |
| 278 | + onPlanChange(e) { | |
| 279 | + const opt = (this.planOptions || [])[Number(e.detail.value)] | |
| 280 | + if (!opt) return | |
| 281 | + this.form.procurementPlanId = opt.value | |
| 282 | + this.form.productId = '' | |
| 283 | + this.productOptions = [] | |
| 284 | + this.loadProductOptions(this.form.weighingTicketId, opt.value) | |
| 285 | + }, | |
| 286 | + getProductLabel() { | |
| 287 | + const found = (this.productOptions || []).find(it => it.value === this.form.productId) | |
| 288 | + return found ? found.label : '' | |
| 289 | + }, | |
| 290 | + onProductChange(e) { | |
| 291 | + const opt = (this.productOptions || [])[Number(e.detail.value)] | |
| 292 | + if (!opt) return | |
| 293 | + this.form.productId = opt.value | |
| 294 | + }, | |
| 295 | + getDepartmentLabel() { | |
| 296 | + const found = (this.dicOptions.DEPARTMENT || []).find(it => String(it.code) === String(this.form.department)) | |
| 297 | + return found ? found.name : '' | |
| 298 | + }, | |
| 299 | + onDepartmentChange(e) { | |
| 300 | + const opt = (this.dicOptions.DEPARTMENT || [])[Number(e.detail.value)] | |
| 301 | + if (!opt) return | |
| 302 | + this.form.department = opt.code != null ? String(opt.code) : '' | |
| 303 | + }, | |
| 304 | + validate() { | |
| 305 | + const f = this.form | |
| 306 | + if (!f.weighingTicketId) return this.tip('请选择码单编号') | |
| 307 | + if (!f.procurementPlanId) return this.tip('请选择计划编号') | |
| 308 | + if (!f.productId) return this.tip('请选择品种') | |
| 309 | + if (!f.department) return this.tip('请选择科室') | |
| 310 | + return true | |
| 311 | + }, | |
| 312 | + tip(msg) { | |
| 313 | + uni.showToast({ title: msg, icon: 'none' }) | |
| 314 | + return false | |
| 315 | + }, | |
| 316 | + async onSubmit() { | |
| 317 | + if (!this.validate()) return | |
| 318 | + const confirmRes = await new Promise(resolve => { | |
| 319 | + uni.showModal({ title: '提示', content: '确定保存修改吗?', confirmText: '确定', cancelText: '取消', success: resolve }) | |
| 320 | + }) | |
| 321 | + if (!(confirmRes && confirmRes.confirm)) return | |
| 322 | + uni.showLoading({ title: '提交中...', mask: true }) | |
| 323 | + assayApplyUpdateApi({ | |
| 324 | + id: this.id, | |
| 325 | + code: this.form.code, | |
| 326 | + weighingTicketId: this.form.weighingTicketId, | |
| 327 | + procurementPlanId: this.form.procurementPlanId, | |
| 328 | + productId: this.form.productId, | |
| 329 | + department: this.form.department | |
| 330 | + }) | |
| 331 | + .then(() => { | |
| 332 | + uni.hideLoading() | |
| 333 | + uni.showToast({ title: '保存成功', icon: 'none' }) | |
| 334 | + try { | |
| 335 | + uni.setStorageSync('SAMPLE_SUBMISSION_LIST_NEED_REFRESH', '1') | |
| 336 | + uni.setStorageSync('SAMPLE_SUBMISSION_DETAIL_NEED_REFRESH', '1') | |
| 337 | + } catch (e) {} | |
| 338 | + setTimeout(() => { uni.navigateBack() }, 400) | |
| 339 | + }) | |
| 340 | + .catch(e => { | |
| 341 | + uni.hideLoading() | |
| 342 | + uni.showToast({ title: (e && (e.msg || e.message)) || '保存失败', icon: 'none' }) | |
| 343 | + }) | |
| 344 | + } | |
| 345 | + } | |
| 346 | +} | |
| 347 | +</script> | |
| 348 | + | |
| 349 | +<style lang="scss" scoped> | |
| 350 | +.page { | |
| 351 | + display: flex; | |
| 352 | + flex-direction: column; | |
| 353 | + height: 100%; | |
| 354 | +} | |
| 355 | + | |
| 356 | +.scroll { | |
| 357 | + flex: 1; | |
| 358 | + padding: 12rpx 0 200rpx !important; | |
| 359 | +} | |
| 360 | + | |
| 361 | +.footer { | |
| 362 | + z-index: 2; | |
| 363 | + position: fixed; | |
| 364 | + left: 0; | |
| 365 | + right: 0; | |
| 366 | + bottom: 0; | |
| 367 | + padding: 32rpx; | |
| 368 | + padding-bottom: calc(32rpx + env(safe-area-inset-bottom)); | |
| 369 | + background: #fff; | |
| 370 | + box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.06); | |
| 371 | + | |
| 372 | + .btn { | |
| 373 | + height: 80rpx; | |
| 374 | + line-height: 80rpx; | |
| 375 | + border-radius: 12rpx; | |
| 376 | + font-size: 32rpx; | |
| 377 | + } | |
| 378 | + | |
| 379 | + .submit { | |
| 380 | + background: $theme-primary; | |
| 381 | + color: #fff; | |
| 382 | + } | |
| 383 | +} | |
| 384 | + | |
| 385 | +::v-deep .uni-list { | |
| 386 | + .uni-easyinput { | |
| 387 | + display: flex; | |
| 388 | + | |
| 389 | + .uni-input-input { | |
| 390 | + color: rgba(0, 0, 0, 0.9); | |
| 391 | + } | |
| 392 | + } | |
| 393 | + | |
| 394 | + .uni-input-placeholder { | |
| 395 | + z-index: 1; | |
| 396 | + } | |
| 397 | + | |
| 398 | + .uni-input-input { | |
| 399 | + background-color: #ffffff; | |
| 400 | + } | |
| 401 | + | |
| 402 | + background: transparent; | |
| 403 | + | |
| 404 | + &-item { | |
| 405 | + &__extra-text { | |
| 406 | + font-size: 32rpx; | |
| 407 | + } | |
| 408 | + | |
| 409 | + &__content-title { | |
| 410 | + font-size: 32rpx; | |
| 411 | + color: rgba(0, 0, 0, 0.9); | |
| 412 | + } | |
| 413 | + | |
| 414 | + &__container { | |
| 415 | + padding: 32rpx; | |
| 416 | + | |
| 417 | + .item-title, | |
| 418 | + .uni-list-item__content { | |
| 419 | + flex: none; | |
| 420 | + min-height: 48rpx; | |
| 421 | + line-height: 48rpx; | |
| 422 | + font-size: 32rpx; | |
| 423 | + position: relative; | |
| 424 | + width: 240rpx; | |
| 425 | + margin-right: 32rpx; | |
| 426 | + color: rgba(0, 0, 0, 0.9); | |
| 427 | + | |
| 428 | + .required { | |
| 429 | + color: red; | |
| 430 | + position: absolute; | |
| 431 | + top: 50%; | |
| 432 | + transform: translateY(-50%); | |
| 433 | + left: -16rpx; | |
| 434 | + } | |
| 435 | + } | |
| 436 | + } | |
| 437 | + | |
| 438 | + &.select-item { | |
| 439 | + &.is-empty { | |
| 440 | + .uni-list-item__extra-text { | |
| 441 | + color: rgba(0, 0, 0, 0.4) !important; | |
| 442 | + } | |
| 443 | + } | |
| 444 | + | |
| 445 | + &.is-filled { | |
| 446 | + .uni-list-item__extra-text { | |
| 447 | + color: rgba(0, 0, 0, 0.9) !important; | |
| 448 | + } | |
| 449 | + } | |
| 450 | + } | |
| 451 | + } | |
| 452 | +} | |
| 453 | + | |
| 454 | +.readonly-text { | |
| 455 | + color: rgba(0, 0, 0, 0.9); | |
| 456 | + font-size: 32rpx; | |
| 457 | + line-height: 48rpx; | |
| 458 | + text-align: right; | |
| 459 | + white-space: pre-wrap; | |
| 460 | + word-break: break-all; | |
| 461 | +} | |
| 462 | + | |
| 463 | +.value-code { | |
| 464 | + width: 260rpx; | |
| 465 | + text-align: left; | |
| 466 | +} | |
| 467 | + | |
| 468 | +.picker-value { | |
| 469 | + font-size: 32rpx; | |
| 470 | + color: rgba(0, 0, 0, 0.9); | |
| 471 | + line-height: 48rpx; | |
| 472 | + text-align: right; | |
| 473 | + min-height: 48rpx; | |
| 474 | + | |
| 475 | + &.placeholder { | |
| 476 | + color: rgba(0, 0, 0, 0.4); | |
| 477 | + } | |
| 478 | +} | |
| 479 | +</style> | ... | ... |
| 1 | +<template> | |
| 2 | + <view class="detail-page"> | |
| 3 | + <scroll-view class="scroll" scroll-y> | |
| 4 | + <!-- 基础信息 --> | |
| 5 | + <view class="section"> | |
| 6 | + <text class="row company">{{ safeText(form.code) }}</text> | |
| 7 | + <view class="row"><text class="label">码单编号</text><text class="value">{{ safeText(form.weighingTicketCode) }}</text></view> | |
| 8 | + <view class="row"><text class="label">计划编号</text><text class="value">{{ safeText(form.planCode) }}</text></view> | |
| 9 | + <view class="row"><text class="label">品种</text><text class="value">{{ safeText(form.productName) }}</text></view> | |
| 10 | + <view class="row"><text class="label">科室</text><text class="value">{{ departmentName }}</text></view> | |
| 11 | + <view class="row"><text class="label">审核状态</text><text class="value">{{ approvalStatusName }}</text></view> | |
| 12 | + <view class="row"><text class="label">创建人</text><text class="value">{{ safeText(form.createBy) }}</text></view> | |
| 13 | + <view class="row"><text class="label">创建时间</text><text class="value">{{ safeText(form.createTime) }}</text></view> | |
| 14 | + </view> | |
| 15 | + </scroll-view> | |
| 16 | + </view> | |
| 17 | +</template> | |
| 18 | + | |
| 19 | +<script> | |
| 20 | +import { assayApplyDetailApi } from '@/api/procure-manage/assayApply.js' | |
| 21 | +import { getDicByCodes, getDicName } from '@/utils/dic.js' | |
| 22 | + | |
| 23 | +export default { | |
| 24 | + name: 'SampleSubmissionViewer', | |
| 25 | + props: { id: { type: [String, Number], default: '' } }, | |
| 26 | + data() { | |
| 27 | + return { | |
| 28 | + form: {}, | |
| 29 | + dicOptions: { | |
| 30 | + DEPARTMENT: [], | |
| 31 | + AUDIT_STATUS: [] | |
| 32 | + } | |
| 33 | + } | |
| 34 | + }, | |
| 35 | + computed: { | |
| 36 | + departmentName() { | |
| 37 | + const v = this.form.department == null ? '' : String(this.form.department) | |
| 38 | + if (!v) return '-' | |
| 39 | + return getDicName('DEPARTMENT', v, this.dicOptions.DEPARTMENT) || v | |
| 40 | + }, | |
| 41 | + approvalStatusName() { | |
| 42 | + const v = this.form.approvalStatus == null ? '' : String(this.form.approvalStatus) | |
| 43 | + if (!v) return '-' | |
| 44 | + return getDicName('AUDIT_STATUS', v, this.dicOptions.AUDIT_STATUS) || v | |
| 45 | + } | |
| 46 | + }, | |
| 47 | + created() { | |
| 48 | + this.loadDicData() | |
| 49 | + }, | |
| 50 | + watch: { | |
| 51 | + id: { | |
| 52 | + immediate: true, | |
| 53 | + handler(val) { | |
| 54 | + const v = (val !== undefined && val !== null) ? String(val) : '' | |
| 55 | + if (v) this.loadDetail(v) | |
| 56 | + } | |
| 57 | + } | |
| 58 | + }, | |
| 59 | + methods: { | |
| 60 | + async loadDicData() { | |
| 61 | + try { | |
| 62 | + const results = await getDicByCodes(['DEPARTMENT', 'AUDIT_STATUS']) | |
| 63 | + this.dicOptions.DEPARTMENT = (results.DEPARTMENT && results.DEPARTMENT.data) || [] | |
| 64 | + this.dicOptions.AUDIT_STATUS = (results.AUDIT_STATUS && results.AUDIT_STATUS.data) || [] | |
| 65 | + } catch (e) { | |
| 66 | + this.dicOptions = { DEPARTMENT: [], AUDIT_STATUS: [] } | |
| 67 | + } | |
| 68 | + }, | |
| 69 | + loadDetail(id) { | |
| 70 | + assayApplyDetailApi({ id }) | |
| 71 | + .then(res => { | |
| 72 | + const data = res && res.data ? res.data : {} | |
| 73 | + this.form = Object.assign({}, data) | |
| 74 | + }) | |
| 75 | + .catch(() => { | |
| 76 | + uni.showToast({ title: '详情加载失败', icon: 'none' }) | |
| 77 | + }) | |
| 78 | + }, | |
| 79 | + // 供审批页通过时取业务表单数据(variables,对齐 PC 端 approve.vue getFormData) | |
| 80 | + getFormValues() { | |
| 81 | + return Object.assign({}, this.form) | |
| 82 | + }, | |
| 83 | + // 审批表单只读,无需校验 | |
| 84 | + checkForm() { | |
| 85 | + return true | |
| 86 | + }, | |
| 87 | + safeText(v) { | |
| 88 | + const s = v == null ? '' : String(v) | |
| 89 | + return s.trim() ? s : '-' | |
| 90 | + } | |
| 91 | + } | |
| 92 | +} | |
| 93 | +</script> | |
| 94 | + | |
| 95 | +<style lang="scss" scoped> | |
| 96 | +.detail-page { | |
| 97 | + background: #f3f3f3; | |
| 98 | + min-height: 100%; | |
| 99 | +} | |
| 100 | +.scroll { | |
| 101 | + height: 100%; | |
| 102 | +} | |
| 103 | +.section { | |
| 104 | + padding: 32rpx; | |
| 105 | + background: #fff; | |
| 106 | + margin-bottom: 20rpx; | |
| 107 | +} | |
| 108 | +.row { | |
| 109 | + display: flex; | |
| 110 | + margin-bottom: 28rpx; | |
| 111 | + | |
| 112 | + &:last-child { | |
| 113 | + margin-bottom: 0; | |
| 114 | + } | |
| 115 | + | |
| 116 | + &.company { | |
| 117 | + font-size: 36rpx; | |
| 118 | + font-weight: 600; | |
| 119 | + color: rgba(0, 0, 0, 0.9); | |
| 120 | + padding-top: 8rpx; | |
| 121 | + line-height: 50rpx; | |
| 122 | + } | |
| 123 | + | |
| 124 | + .label { | |
| 125 | + max-width: 420rpx; | |
| 126 | + margin-right: 20rpx; | |
| 127 | + line-height: 32rpx; | |
| 128 | + font-size: 28rpx; | |
| 129 | + color: rgba(0, 0, 0, 0.6); | |
| 130 | + } | |
| 131 | + | |
| 132 | + .value { | |
| 133 | + flex: 1; | |
| 134 | + line-height: 32rpx; | |
| 135 | + font-size: 28rpx; | |
| 136 | + color: rgba(0, 0, 0, 0.9); | |
| 137 | + text-align: right; | |
| 138 | + word-break: break-all; | |
| 139 | + } | |
| 140 | +} | |
| 141 | +</style> | ... | ... |
| ... | ... | @@ -186,6 +186,8 @@ export default { |
| 186 | 186 | const isAudit = status === 'AUDIT' |
| 187 | 187 | const showExamine = this.form.showExamine === true |
| 188 | 188 | const showExamineDetail = this.form.showExamineDetail === true |
| 189 | + | |
| 190 | + const isReweigh = String(this.form.code || '').charAt(0) === 'F' | |
| 189 | 191 | return [ |
| 190 | 192 | { |
| 191 | 193 | ...this.buttons[0], |
| ... | ... | @@ -201,7 +203,7 @@ export default { |
| 201 | 203 | }, |
| 202 | 204 | { |
| 203 | 205 | ...this.buttons[3], |
| 204 | - visible: (isAudit || isPass) && showExamineDetail && this.$auth.hasPermi('warehouse-manage:weight-ticket:review') | |
| 206 | + visible: showExamineDetail && this.$auth.hasPermi('warehouse-manage:weight-ticket:review') | |
| 205 | 207 | }, |
| 206 | 208 | { |
| 207 | 209 | ...this.buttons[4], |
| ... | ... | @@ -217,7 +219,7 @@ export default { |
| 217 | 219 | }, |
| 218 | 220 | { |
| 219 | 221 | ...this.buttons[7], |
| 220 | - visible: isPass && this.$auth.hasPermi('warehouse-manage:weight-ticket:reweigh') | |
| 222 | + visible: isPass && !isReweigh && this.$auth.hasPermi('warehouse-manage:weight-ticket:reweigh') | |
| 221 | 223 | } |
| 222 | 224 | ] |
| 223 | 225 | } | ... | ... |
| ... | ... | @@ -12,23 +12,24 @@ |
| 12 | 12 | </template> |
| 13 | 13 | </uni-list-item> |
| 14 | 14 | |
| 15 | - <!-- 类型 --> | |
| 15 | + <!-- 类型(复磅单只读) --> | |
| 16 | 16 | <uni-list-item class="select-item" :class="form.type ? 'is-filled' : 'is-empty'"> |
| 17 | 17 | <template v-slot:body> |
| 18 | 18 | <view class="item-title"><text class="required">*</text><text>类型</text></view> |
| 19 | 19 | </template> |
| 20 | 20 | <template v-slot:footer> |
| 21 | - <picker mode="selector" :range="typeLabels" @change="onTypeChange"> | |
| 21 | + <picker v-if="!isReweigh" mode="selector" :range="typeLabels" @change="onTypeChange"> | |
| 22 | 22 | <view class="picker-value" :class="{ placeholder: !form.type }"> |
| 23 | 23 | {{ getTypeLabel() || '请选择类型' }} |
| 24 | 24 | </view> |
| 25 | 25 | </picker> |
| 26 | + <uni-easyinput v-else :value="getTypeLabel() || form.type" :inputBorder="false" disabled /> | |
| 26 | 27 | </template> |
| 27 | 28 | </uni-list-item> |
| 28 | 29 | |
| 29 | - <!-- 计划编号(弹窗多选计划) --> | |
| 30 | - <uni-list-item class="select-item" :class="form.planCode ? 'is-filled' : 'is-empty'" clickable | |
| 31 | - @click="openPlanSheet" :rightText="form.planCode || '请选择计划'" showArrow> | |
| 30 | + <!-- 计划编号(弹窗多选计划;复磅单只读) --> | |
| 31 | + <uni-list-item class="select-item" :class="form.planCode ? 'is-filled' : 'is-empty'" :clickable="!isReweigh" | |
| 32 | + @click="!isReweigh && openPlanSheet()" :rightText="form.planCode || '请选择计划'" :showArrow="!isReweigh"> | |
| 32 | 33 | <template v-slot:body> |
| 33 | 34 | <view class="item-title"><text class="required">*</text><text>计划编号</text></view> |
| 34 | 35 | </template> |
| ... | ... | @@ -86,12 +87,12 @@ |
| 86 | 87 | </view> |
| 87 | 88 | </view> |
| 88 | 89 | |
| 89 | - <!-- 过磅明细(可编辑) --> | |
| 90 | + <!-- 过磅明细(可编辑;复磅单仅过磅数量可编辑) --> | |
| 90 | 91 | <view class="sub-table"> |
| 91 | 92 | <view class="header"> |
| 92 | 93 | <image class="opCollapse" src="/static/images/title.png" /> |
| 93 | 94 | <text class="title">过磅明细</text> |
| 94 | - <view class="ops"> | |
| 95 | + <view v-if="!isReweigh" class="ops"> | |
| 95 | 96 | <image class="opAdd" @click="addWeightRow" src="/static/images/plus.png" /> |
| 96 | 97 | </view> |
| 97 | 98 | </view> |
| ... | ... | @@ -104,12 +105,13 @@ |
| 104 | 105 | <view class="item-title"><text class="required">*</text><text>计划编号</text></view> |
| 105 | 106 | </template> |
| 106 | 107 | <template v-slot:footer> |
| 107 | - <picker mode="selector" :range="planCodeLabels" | |
| 108 | + <picker v-if="!isReweigh" mode="selector" :range="planCodeLabels" | |
| 108 | 109 | @change="(e) => handleWeighPlanChange(idx, Number(e.detail.value))"> |
| 109 | 110 | <view class="picker-value" :class="{ placeholder: !item.planCode }"> |
| 110 | 111 | {{ item.planCode || '请选择计划编号' }} |
| 111 | 112 | </view> |
| 112 | 113 | </picker> |
| 114 | + <uni-easyinput v-else :value="item.planCode" :inputBorder="false" disabled /> | |
| 113 | 115 | </template> |
| 114 | 116 | </uni-list-item> |
| 115 | 117 | <uni-list-item class="select-item" :class="item.productId ? 'is-filled' : 'is-empty'"> |
| ... | ... | @@ -117,12 +119,13 @@ |
| 117 | 119 | <view class="item-title"><text class="required">*</text><text>过磅品种</text></view> |
| 118 | 120 | </template> |
| 119 | 121 | <template v-slot:footer> |
| 120 | - <picker mode="selector" :range="getWeightProductLabels(item)" | |
| 122 | + <picker v-if="!isReweigh" mode="selector" :range="getWeightProductLabels(item)" | |
| 121 | 123 | @change="(e) => handleWeightProductChange(idx, Number(e.detail.value))"> |
| 122 | 124 | <view class="picker-value" :class="{ placeholder: !item.productId }"> |
| 123 | 125 | {{ getWeightProductLabel(item) || '请选择过磅品种' }} |
| 124 | 126 | </view> |
| 125 | 127 | </picker> |
| 128 | + <uni-easyinput v-else :value="getWeightProductLabel(item) || item.productName" :inputBorder="false" disabled /> | |
| 126 | 129 | </template> |
| 127 | 130 | </uni-list-item> |
| 128 | 131 | <uni-list-item title="开票品名"> |
| ... | ... | @@ -139,7 +142,7 @@ |
| 139 | 142 | </template> |
| 140 | 143 | </uni-list-item> |
| 141 | 144 | </uni-list> |
| 142 | - <view class="block-ops"> | |
| 145 | + <view v-if="!isReweigh" class="block-ops"> | |
| 143 | 146 | <div class="del" @click="removeRow('weigh', idx)"> |
| 144 | 147 | <image src="/static/images/delete.png" class="icon" />删除 |
| 145 | 148 | </div> |
| ... | ... | @@ -148,12 +151,12 @@ |
| 148 | 151 | </view> |
| 149 | 152 | </view> |
| 150 | 153 | |
| 151 | - <!-- 申请数量明细(仅买断展示) --> | |
| 154 | + <!-- 申请数量明细(仅买断展示;复磅单只读) --> | |
| 152 | 155 | <view v-if="isBuyout" class="sub-table"> |
| 153 | 156 | <view class="header"> |
| 154 | 157 | <image class="opCollapse" src="/static/images/title.png" /> |
| 155 | 158 | <text class="title">申请数量明细</text> |
| 156 | - <view class="ops"> | |
| 159 | + <view v-if="!isReweigh" class="ops"> | |
| 157 | 160 | <image class="opAdd" @click="addApplyRow" src="/static/images/plus.png" /> |
| 158 | 161 | </view> |
| 159 | 162 | </view> |
| ... | ... | @@ -166,12 +169,13 @@ |
| 166 | 169 | <view class="item-title"><text class="required">*</text><text>类别</text></view> |
| 167 | 170 | </template> |
| 168 | 171 | <template v-slot:footer> |
| 169 | - <picker mode="selector" :range="varietyLabels" | |
| 172 | + <picker v-if="!isReweigh" mode="selector" :range="varietyLabels" | |
| 170 | 173 | @change="(e) => handleVarietyChange(idx, Number(e.detail.value))"> |
| 171 | 174 | <view class="picker-value" :class="{ placeholder: !item.breedRelationshipId }"> |
| 172 | 175 | {{ getVarietyLabel(item) || '请选择类别' }} |
| 173 | 176 | </view> |
| 174 | 177 | </picker> |
| 178 | + <uni-easyinput v-else :value="getVarietyLabel(item) || item.category" :inputBorder="false" disabled /> | |
| 175 | 179 | </template> |
| 176 | 180 | </uni-list-item> |
| 177 | 181 | <uni-list-item title="数量"> |
| ... | ... | @@ -179,11 +183,11 @@ |
| 179 | 183 | <view class="item-title"><text class="required">*</text><text>数量</text></view> |
| 180 | 184 | </template> |
| 181 | 185 | <template v-slot:footer> |
| 182 | - <uni-easyinput v-model="item.quantity" type="digit" :inputBorder="false" placeholder="请输入数量" /> | |
| 186 | + <uni-easyinput v-model="item.quantity" type="digit" :inputBorder="false" placeholder="请输入数量" :disabled="isReweigh" /> | |
| 183 | 187 | </template> |
| 184 | 188 | </uni-list-item> |
| 185 | 189 | </uni-list> |
| 186 | - <view class="block-ops"> | |
| 190 | + <view v-if="!isReweigh" class="block-ops"> | |
| 187 | 191 | <div class="del" @click="removeRow('apply', idx)"> |
| 188 | 192 | <image src="/static/images/delete.png" class="icon" />删除 |
| 189 | 193 | </div> |
| ... | ... | @@ -365,6 +369,10 @@ export default { |
| 365 | 369 | } |
| 366 | 370 | }, |
| 367 | 371 | computed: { |
| 372 | + // 编号以F开头 = 复磅生成的单据,可编辑字段与复磅一致 | |
| 373 | + isReweigh() { | |
| 374 | + return String(this.form.code || '').charAt(0) === 'F' | |
| 375 | + }, | |
| 368 | 376 | typeLabels() { |
| 369 | 377 | return (this.dicOptions.TYPE || []).map(it => it.name) |
| 370 | 378 | }, | ... | ... |
| ... | ... | @@ -30,6 +30,8 @@ import DomesticPlanViewer from '@/pages/domestic-plan/domesticPlanViewer.vue' |
| 30 | 30 | import SupplePlanViewer from '@/pages/supple-plan/supplePlanViewer.vue' |
| 31 | 31 | import DomesticAgreementViewer from '@/pages/domestic-agreement/domesticAgreementViewer.vue' |
| 32 | 32 | import WeightTicketViewer from '@/pages/weight-ticket/weightTicketViewer.vue' |
| 33 | +import SampleSubmissionViewer from '@/pages/sample-submission/sampleSubmissionViewer.vue' | |
| 34 | +import MaterialTestViewer from '@/pages/material-test/materialTestViewer.vue' | |
| 33 | 35 | |
| 34 | 36 | export default function registerComponents(Vue) { |
| 35 | 37 | Vue.component('CustomerDevelopViewer', CustomerDevelopViewer) |
| ... | ... | @@ -64,4 +66,6 @@ export default function registerComponents(Vue) { |
| 64 | 66 | Vue.component('SupplePlanViewer', SupplePlanViewer) |
| 65 | 67 | Vue.component('DomesticAgreementViewer', DomesticAgreementViewer) |
| 66 | 68 | Vue.component('WeightTicketViewer', WeightTicketViewer) |
| 69 | + Vue.component('SampleSubmissionViewer', SampleSubmissionViewer) | |
| 70 | + Vue.component('MaterialTestViewer', MaterialTestViewer) | |
| 67 | 71 | } | ... | ... |
| ... | ... | @@ -159,6 +159,18 @@ export const getSysFlowComponentPath = (bizFlag) => { |
| 159 | 159 | case 'WEIGHING_RECORD_EDIT': // 过磅码单 |
| 160 | 160 | componentPath = 'WeightTicketViewer'; // 过磅码单-审批 |
| 161 | 161 | break; |
| 162 | + case 'ASSAY_APPLY': // 化验送样单 | |
| 163 | + componentPath = 'SampleSubmissionViewer'; // 化验送样单-审批详情 | |
| 164 | + break; | |
| 165 | + case 'ASSAY_APPLY_EDIT': // 化验送样单 | |
| 166 | + componentPath = 'SampleSubmissionViewer'; // 化验送样单-审批 | |
| 167 | + break; | |
| 168 | + case 'ASSAY_REPORT': // 原料化验报告单 | |
| 169 | + componentPath = 'MaterialTestViewer'; // 原料化验报告单-审批详情 | |
| 170 | + break; | |
| 171 | + case 'ASSAY_REPORT_EDIT': // 原料化验报告单 | |
| 172 | + componentPath = 'MaterialTestViewer'; // 原料化验报告单-审批 | |
| 173 | + break; | |
| 162 | 174 | } |
| 163 | 175 | return componentPath; |
| 164 | 176 | }; | ... | ... |