|
|
@@ -0,0 +1,806 @@
|
|
|
+<template>
|
|
|
+ <view class="mainBox">
|
|
|
+ <uni-nav-bar
|
|
|
+ fixed="true"
|
|
|
+ statusBar="true"
|
|
|
+ left-icon="back"
|
|
|
+ :title="isEdit ? '编辑检测报告' : '检测报告'"
|
|
|
+ @clickLeft="back"
|
|
|
+ >
|
|
|
+ </uni-nav-bar>
|
|
|
+
|
|
|
+ <view class="page-body">
|
|
|
+ <!-- 按 reportTemplateCode 渲染对应模板 -->
|
|
|
+ <component
|
|
|
+ :is="templateComp"
|
|
|
+ v-if="templateComp"
|
|
|
+ :basicInfoData="basicInfoData"
|
|
|
+ :inspectionItems="inspectionItems"
|
|
|
+ :isEdit="isEdit"
|
|
|
+ ref="templateRef"
|
|
|
+ ></component>
|
|
|
+ <view class="empty-tip" v-else-if="!loading"
|
|
|
+ >暂不支持该报告模板({{ templateCode }})</view
|
|
|
+ >
|
|
|
+
|
|
|
+ <!-- 检验结论(对应Web端报告容器通用区) -->
|
|
|
+ <view class="card">
|
|
|
+ <view class="card-title">
|
|
|
+ <view class="herder_text"></view>
|
|
|
+ <view class="card-title-text">检验结论</view>
|
|
|
+ </view>
|
|
|
+ <view class="info-row column" v-if="isEdit">
|
|
|
+ <text class="label">结论</text>
|
|
|
+ <u-radio-group
|
|
|
+ class="radio-group"
|
|
|
+ v-model="basicInfoData.qualityResults"
|
|
|
+ placement="row"
|
|
|
+ iconSize="28"
|
|
|
+ labelSize="24"
|
|
|
+ @change="selectResult"
|
|
|
+ >
|
|
|
+ <u-radio
|
|
|
+ v-for="(it, idx) in qualityResultsList"
|
|
|
+ :key="idx"
|
|
|
+ :customStyle="{ marginRight: '12rpx', marginTop: '8rpx' }"
|
|
|
+ :label="it.label"
|
|
|
+ :name="it.value"
|
|
|
+ ></u-radio>
|
|
|
+ </u-radio-group>
|
|
|
+ </view>
|
|
|
+ <view class="info-row" v-else>
|
|
|
+ <text class="label">结论</text>
|
|
|
+ <text class="value">{{
|
|
|
+ qualityResultsText(basicInfoData.qualityResults)
|
|
|
+ }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">合格数</text>
|
|
|
+ <text class="value">{{ basicInfoData.qualifiedNumber || 0 }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">不合格数</text>
|
|
|
+ <text class="value">{{ basicInfoData.noQualifiedNumber || 0 }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">留样数(合格)</text>
|
|
|
+ <text class="value">{{
|
|
|
+ basicInfoData.retainedSampleQuantity || 0
|
|
|
+ }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">留样数(不合格)</text>
|
|
|
+ <text class="value">{{
|
|
|
+ basicInfoData.retainedSampleUnqualified || 0
|
|
|
+ }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">消耗数(合格)</text>
|
|
|
+ <text class="value">{{ basicInfoData.lossNumber || 0 }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="info-row">
|
|
|
+ <text class="label">消耗数(不合格)</text>
|
|
|
+ <text class="value">{{
|
|
|
+ basicInfoData.lossNumberUnqualified || 0
|
|
|
+ }}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view style="height: 160rpx"></view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 底部操作栏 -->
|
|
|
+ <view class="footerButton" v-if="canEdit">
|
|
|
+ <view>
|
|
|
+ <u-button v-if="isEdit" @click="cancelEdit">取消</u-button>
|
|
|
+ <u-button
|
|
|
+ v-else
|
|
|
+ type="primary"
|
|
|
+ text="编辑"
|
|
|
+ @click="enterEdit"
|
|
|
+ ></u-button>
|
|
|
+ </view>
|
|
|
+ <view v-if="isEdit">
|
|
|
+ <u-button
|
|
|
+ type="primary"
|
|
|
+ text="保存"
|
|
|
+ :loading="saving"
|
|
|
+ @click="save"
|
|
|
+ ></u-button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <u-toast ref="uToast" />
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import inspection_report1 from "./template/inspection_report1.vue";
|
|
|
+import inspection_report2 from "./template/inspection_report2.vue";
|
|
|
+import inspection_report4 from "./template/inspection_report4.vue";
|
|
|
+import inspection_report5 from "./template/inspection_report5.vue";
|
|
|
+import inspection_report6 from "./template/inspection_report6.vue";
|
|
|
+import {
|
|
|
+ queryInspectionReportData,
|
|
|
+ queryInspectionReportList,
|
|
|
+ generateReport,
|
|
|
+ getCode,
|
|
|
+ getList,
|
|
|
+ getById,
|
|
|
+} from "@/api/inspectionReport/index.js";
|
|
|
+import {
|
|
|
+ queryQualitySamplContent,
|
|
|
+ queryQualityInventory,
|
|
|
+} from "@/api/inspectionWork";
|
|
|
+const templateComponents = {
|
|
|
+ inspection_report1,
|
|
|
+ inspection_report2,
|
|
|
+ inspection_report4,
|
|
|
+ inspection_report5,
|
|
|
+ inspection_report6,
|
|
|
+};
|
|
|
+
|
|
|
+const qualityResultsList = [
|
|
|
+ { label: "整单合格", value: 1 },
|
|
|
+ { label: "整单不合格", value: 2 },
|
|
|
+ { label: "部分合格", value: 3 },
|
|
|
+ { label: "整单让步接收", value: 4 },
|
|
|
+];
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ inspection_report1,
|
|
|
+ inspection_report2,
|
|
|
+ inspection_report4,
|
|
|
+ inspection_report5,
|
|
|
+ inspection_report6,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ id: "",
|
|
|
+ isEdit: false,
|
|
|
+ saving: false,
|
|
|
+ loading: false,
|
|
|
+ currentRow: {},
|
|
|
+ basicInfoData: {},
|
|
|
+ inspectionItems: [],
|
|
|
+ inventoryList: [],
|
|
|
+ sampleList: [],
|
|
|
+ oldList: [],
|
|
|
+ poList: [],
|
|
|
+
|
|
|
+ qualityResultsList,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ templateCode() {
|
|
|
+ let code =
|
|
|
+ this.currentRow.reportTemplateCode ||
|
|
|
+ this.basicInfoData.reportTemplateCode ||
|
|
|
+ (this.currentRow.reportTemplateJson &&
|
|
|
+ this.currentRow.reportTemplateJson.reportTemplateCode) ||
|
|
|
+ "";
|
|
|
+ code = String(code)
|
|
|
+ .replace(/\.vue$/i, "")
|
|
|
+ .trim();
|
|
|
+ if (!templateComponents[code]) {
|
|
|
+ code = "inspection_report1";
|
|
|
+ }
|
|
|
+ return code;
|
|
|
+ },
|
|
|
+ templateComp() {
|
|
|
+ return templateComponents[this.templateCode] || inspection_report1;
|
|
|
+ },
|
|
|
+ canEdit() {
|
|
|
+ // 从工单“生成质检报告”进入时可直接编辑;查看模式仅未提交/审核不通过可编辑
|
|
|
+ if (this.isEdit) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ const status = this.currentRow.reportApprovalStatus;
|
|
|
+ return status == 0 || status == 3;
|
|
|
+ },
|
|
|
+ // 可用总数 = 总数 - 留样数 - 消耗数
|
|
|
+ availableTotal() {
|
|
|
+ if (!this.sampleList.length) return this.basicInfoData.total;
|
|
|
+ const usedQuantity = this.sampleList
|
|
|
+ .filter((item) => item.disposeType == 6 || item.disposeType == 7)
|
|
|
+ .reduce((sum, item) => sum + (item.measureQuantity || 0), 0);
|
|
|
+ return this.basicInfoData.total - usedQuantity;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ onLoad(options) {
|
|
|
+ this.id = options.id || "";
|
|
|
+ this.isEdit = options.edit == "1";
|
|
|
+ const row = uni.getStorageSync("inspectionReportRow");
|
|
|
+ if (row && row.id == this.id) {
|
|
|
+ this.currentRow = row;
|
|
|
+ uni.removeStorageSync("inspectionReportRow");
|
|
|
+ } else {
|
|
|
+ this.currentRow = { id: this.id };
|
|
|
+ }
|
|
|
+ // URL兜底:模板编码(从工单生成/查看时带入)
|
|
|
+ if (!this.currentRow.reportTemplateCode && options.templateCode) {
|
|
|
+ this.$set(
|
|
|
+ this.currentRow,
|
|
|
+ "reportTemplateCode",
|
|
|
+ decodeURIComponent(options.templateCode),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async init() {
|
|
|
+ this.loading = true;
|
|
|
+ uni.showLoading({ title: "加载中", mask: true });
|
|
|
+ try {
|
|
|
+ if (
|
|
|
+ this.currentRow.reportTemplateJson &&
|
|
|
+ this.currentRow.reportTemplateJson.basicInfoData
|
|
|
+ ) {
|
|
|
+ this.basicInfoData =
|
|
|
+ this.currentRow.reportTemplateJson.basicInfoData || {};
|
|
|
+ this.inspectionItems =
|
|
|
+ this.currentRow.reportTemplateJson.inspectionItems || [];
|
|
|
+ this.afterDataReady();
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "qualityResults",
|
|
|
+ this.basicInfoData.qualityResults,
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "qualifiedNumber",
|
|
|
+ this.basicInfoData.qualifiedNumber,
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "noQualifiedNumber",
|
|
|
+ this.basicInfoData.noQualifiedNumber,
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ await this.getBasicInfo();
|
|
|
+ await this.getInspectionItems();
|
|
|
+ this.afterDataReady();
|
|
|
+
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "qualityResults",
|
|
|
+ this.currentRow.noQualifiedNumber == this.basicInfoData.total
|
|
|
+ ? 2
|
|
|
+ : this.currentRow.noQualifiedNumber == 0
|
|
|
+ ? 1
|
|
|
+ : 3,
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "qualifiedNumber",
|
|
|
+ this.currentRow.qualifiedNumber,
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "noQualifiedNumber",
|
|
|
+ this.currentRow.noQualifiedNumber,
|
|
|
+ );
|
|
|
+ this.$set(this.basicInfoData, "qualityWorkerId", this.currentRow.id);
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "workOrderId",
|
|
|
+ this.currentRow.workOrderId,
|
|
|
+ );
|
|
|
+ this.$set(this.basicInfoData, "type", this.type || 0);
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "source",
|
|
|
+ this.currentRow.workOrderCode,
|
|
|
+ );
|
|
|
+
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "qualityType",
|
|
|
+ this.currentRow.qualityType,
|
|
|
+ );
|
|
|
+ this.initUnqualifiedProduct();
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: "error",
|
|
|
+ icon: false,
|
|
|
+ message: err.message || "数据获取失败",
|
|
|
+ });
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ uni.hideLoading();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getBasicInfo() {
|
|
|
+ return queryInspectionReportData({
|
|
|
+ id: this.currentRow.id || this.id,
|
|
|
+ type: this.currentRow.type || 0,
|
|
|
+ }).then((res) => {
|
|
|
+ this.basicInfoData = res || {};
|
|
|
+ this.basicInfoData.reportCode = res.reportCode || "";
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getInspectionItems() {
|
|
|
+ return queryInspectionReportList({
|
|
|
+ id: this.currentRow.id || this.id,
|
|
|
+ type: this.currentRow.type || 0,
|
|
|
+ }).then((res) => {
|
|
|
+ this.inspectionItems = res || [];
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ async initUnqualifiedProduct() {
|
|
|
+ const data = await getList({
|
|
|
+ sourceCode: this.currentRow.code,
|
|
|
+ });
|
|
|
+ // console.log(data,'data')
|
|
|
+ if (data.list[0]) {
|
|
|
+ const res = await getById(data.list[0].id);
|
|
|
+ this.poList = res.poList || [];
|
|
|
+ this.oldList = JSON.parse(JSON.stringify(res.poList || []));
|
|
|
+ }
|
|
|
+ await this.getQueryQualityInventory();
|
|
|
+ await this.queryQualitySamplContent();
|
|
|
+ this.setQualifiedNumber();
|
|
|
+ },
|
|
|
+
|
|
|
+ async getQueryQualityInventory() {
|
|
|
+ const res = await queryQualityInventory({
|
|
|
+ qualityWorkerId: this.basicInfoData.qualityWorkerId,
|
|
|
+ size: -1,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (res.list.length > 0) {
|
|
|
+ this.inventoryList = res.list;
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ },
|
|
|
+
|
|
|
+ async queryQualitySamplContent() {
|
|
|
+ const res = await queryQualitySamplContent({
|
|
|
+ qualityWorkerId: this.basicInfoData.qualityWorkerId,
|
|
|
+ size: 1000,
|
|
|
+ });
|
|
|
+ this.sampleList = res.list;
|
|
|
+ let retainedSampleQuantity = 0;
|
|
|
+ let retainedSampleUnqualified = 0;
|
|
|
+ let lossNumber = 0;
|
|
|
+ let lossNumberUnqualified = 0;
|
|
|
+ [
|
|
|
+ "retainedSampleQuantity",
|
|
|
+ "retainedSampleUnqualified",
|
|
|
+ "lossNumber",
|
|
|
+ "lossNumberUnqualified",
|
|
|
+ ].forEach((key) => {
|
|
|
+ this[key] = 0;
|
|
|
+ });
|
|
|
+ if (this.sampleList.length > 0 && this.inventoryList.length > 0) {
|
|
|
+ const processedList = this.sampleList.filter(
|
|
|
+ (item) => item.disposeType == 6 || item.disposeType == 7,
|
|
|
+ );
|
|
|
+ processedList.forEach((sampleItem) => {
|
|
|
+ if (sampleItem.disposeType == 6) {
|
|
|
+ sampleItem.qualityResults == 2
|
|
|
+ ? (retainedSampleUnqualified += sampleItem.measureQuantity)
|
|
|
+ : (retainedSampleQuantity += sampleItem.measureQuantity);
|
|
|
+ } else {
|
|
|
+ sampleItem.qualityResults == 2
|
|
|
+ ? (lossNumberUnqualified += sampleItem.measureQuantity)
|
|
|
+ : (lossNumber += sampleItem.measureQuantity);
|
|
|
+ }
|
|
|
+ const inventoryItem = this.inventoryList.find(
|
|
|
+ (item) => item.sourceId === sampleItem.sourceId,
|
|
|
+ );
|
|
|
+ if (inventoryItem) {
|
|
|
+ inventoryItem.measureQuantity = Math.max(
|
|
|
+ 0,
|
|
|
+ (inventoryItem.measureQuantity || 0) -
|
|
|
+ (sampleItem.measureQuantity || 0),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (this.inventoryList.length == 1 && !this.inventoryList[0].sourceId) {
|
|
|
+ this.inventoryList[0].measureQuantity =
|
|
|
+ this.inventoryList[0].measureQuantity -
|
|
|
+ lossNumber -
|
|
|
+ lossNumberUnqualified -
|
|
|
+ retainedSampleQuantity -
|
|
|
+ retainedSampleUnqualified;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "retainedSampleQuantity",
|
|
|
+ retainedSampleQuantity,
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "retainedSampleUnqualified",
|
|
|
+ retainedSampleUnqualified,
|
|
|
+ );
|
|
|
+ this.$set(this.basicInfoData, "lossNumber", lossNumber);
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "lossNumberUnqualified",
|
|
|
+ lossNumberUnqualified,
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ },
|
|
|
+
|
|
|
+ setQualifiedNumber() {
|
|
|
+ let isQualifiedNumber = true;
|
|
|
+ console.log(this.poList, "this.poList");
|
|
|
+ let noQualifiedNumber = this.poList
|
|
|
+ .filter((item) => ![5, 6, 7].includes(item.disposeType))
|
|
|
+ .reduce((acc, cur) => acc + cur.measureQuantity, 0);
|
|
|
+
|
|
|
+ if (
|
|
|
+ this.poList
|
|
|
+ .filter((item) => item.disposeType == 5)
|
|
|
+ .reduce((acc, cur) => acc + cur.measureQuantity, 0) ==
|
|
|
+ this.availableTotal
|
|
|
+ ) {
|
|
|
+ isQualifiedNumber = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.basicInfoData.qualifiedNumber =
|
|
|
+ this.availableTotal - noQualifiedNumber;
|
|
|
+ this.basicInfoData.noQualifiedNumber = noQualifiedNumber;
|
|
|
+
|
|
|
+ console.log(noQualifiedNumber, "noQualifiedNumber");
|
|
|
+ console.log(this.basicInfoData.qualifiedNumber, "qualifiedNumber");
|
|
|
+ if (!noQualifiedNumber) {
|
|
|
+ if (isQualifiedNumber) {
|
|
|
+ this.basicInfoData.qualityResults = 1;
|
|
|
+ } else {
|
|
|
+ this.basicInfoData.qualityResults = 4;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!this.basicInfoData.qualifiedNumber) {
|
|
|
+ this.basicInfoData.qualityResults = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.basicInfoData.qualifiedNumber && noQualifiedNumber) {
|
|
|
+ this.basicInfoData.qualityResults = 3;
|
|
|
+ }
|
|
|
+ console.log(this.basicInfoData, "this.basicInfoData");
|
|
|
+ },
|
|
|
+ selectResult(qualityResults) {
|
|
|
+ if (qualityResults == 1) {
|
|
|
+ this.poList = JSON.parse(JSON.stringify(this.oldList));
|
|
|
+ this.poList = this.poList.map((item) => {
|
|
|
+ if (item.disposalStatus != 2) {
|
|
|
+ item.disposalStatus = 1;
|
|
|
+ item.disposeType = 5;
|
|
|
+ }
|
|
|
+
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (qualityResults == 4) {
|
|
|
+ this.poList = [
|
|
|
+ ...JSON.parse(JSON.stringify(this.inventoryList)),
|
|
|
+ ...JSON.parse(
|
|
|
+ JSON.stringify(
|
|
|
+ this.oldList.filter((item) => item.disposalStatus == 2),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ];
|
|
|
+ this.poList = this.poList.map((item) => {
|
|
|
+ if (item.disposalStatus != 2) {
|
|
|
+ item.disposalStatus = 1;
|
|
|
+ item.disposeType = 5;
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (qualityResults == 2) {
|
|
|
+ this.poList = [
|
|
|
+ ...JSON.parse(JSON.stringify(this.inventoryList)),
|
|
|
+ ...JSON.parse(
|
|
|
+ JSON.stringify(
|
|
|
+ this.oldList.filter((item) => item.disposalStatus == 2),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ if (qualityResults == 3) {
|
|
|
+ this.poList = JSON.parse(JSON.stringify(this.oldList));
|
|
|
+ }
|
|
|
+ this.setQualifiedNumber();
|
|
|
+ },
|
|
|
+
|
|
|
+ afterDataReady() {
|
|
|
+ const vos = this.currentRow.reportApprovalTaskVos || [];
|
|
|
+ const reviewTime = vos[vos.length - 2]?.endTime?.split(" ")[0] || "";
|
|
|
+ const approvedDate = vos[vos.length - 3]?.endTime?.split(" ")[0] || "";
|
|
|
+ const reviewer = vos[vos.length - 2]?.approvalUserName || "";
|
|
|
+ const checker = vos[vos.length - 3]?.approvalUserName || "";
|
|
|
+
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "inspectionTime",
|
|
|
+ (this.basicInfoData.inspectionTime || "").split(" ")[0] || "",
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "reviewTime",
|
|
|
+ (this.basicInfoData.reviewTime || "").split(" ")[0] || reviewTime || "",
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "approvedDate",
|
|
|
+ (this.basicInfoData.approvedDate || "").split(" ")[0] ||
|
|
|
+ approvedDate ||
|
|
|
+ "",
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "reviewer",
|
|
|
+ this.basicInfoData.reviewer || reviewer || "",
|
|
|
+ );
|
|
|
+ this.$set(
|
|
|
+ this.basicInfoData,
|
|
|
+ "checker",
|
|
|
+ this.basicInfoData.checker || checker || "",
|
|
|
+ );
|
|
|
+
|
|
|
+ // 版本号:参考PC端由模板版本字段拼接
|
|
|
+ if (!this.basicInfoData.version) {
|
|
|
+ const v =
|
|
|
+ (this.currentRow.versionSymbol ?? "") +
|
|
|
+ (this.currentRow.bigVersion ?? "") +
|
|
|
+ (this.currentRow.versionMark ?? "") +
|
|
|
+ (this.currentRow.smallVersion ?? "");
|
|
|
+ if (v) {
|
|
|
+ this.$set(this.basicInfoData, "version", v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 编辑日期控件默认值
|
|
|
+ [
|
|
|
+ "reportDate",
|
|
|
+ "expirationDate",
|
|
|
+ "manufactureTime",
|
|
|
+ "pleaseVerifyDate",
|
|
|
+ "inspectionTime",
|
|
|
+ "reviewTime",
|
|
|
+ "approvedDate",
|
|
|
+ ].forEach((key) => {
|
|
|
+ if (!this.basicInfoData[key]) {
|
|
|
+ this.$set(this.basicInfoData, key, "");
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!this.basicInfoData.source && this.currentRow.workOrderCode) {
|
|
|
+ this.$set(this.basicInfoData, "source", this.currentRow.workOrderCode);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ qualityResultsText(value) {
|
|
|
+ return (
|
|
|
+ (qualityResultsList.find((it) => it.value == value) || {}).label || ""
|
|
|
+ );
|
|
|
+ },
|
|
|
+ enterEdit() {
|
|
|
+ this.isEdit = true;
|
|
|
+ if (!this.basicInfoData.reportNumber) {
|
|
|
+ getCode("quality_Inspection_report_number")
|
|
|
+ .then((res) => {
|
|
|
+ this.$set(this.basicInfoData, "reportNumber", res);
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cancelEdit() {
|
|
|
+ this.isEdit = false;
|
|
|
+ // 放弃修改,重新加载原始数据
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ getValueUnqualifiedProducts() {
|
|
|
+ let unqualifiedProducts = {};
|
|
|
+ if (this.poList.length > 0) {
|
|
|
+ unqualifiedProducts.poList = this.poList.map((item) => {
|
|
|
+ item.qualityResults = 1;
|
|
|
+ item.qualityStatus = 1;
|
|
|
+ item.qualityWorkOrderId = this.basicInfoData.qualityWorkerId;
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ [
|
|
|
+ "batchNo",
|
|
|
+ "brandNum",
|
|
|
+ "categoryCode",
|
|
|
+ "categoryId",
|
|
|
+ "categoryName",
|
|
|
+ "factoriesId",
|
|
|
+ "measureUnit",
|
|
|
+ "modelType",
|
|
|
+ "produceRoutingId",
|
|
|
+ "produceRoutingName",
|
|
|
+ "productCategory",
|
|
|
+ ].forEach((item) => {
|
|
|
+ unqualifiedProducts[item] = this.poList[0][item];
|
|
|
+ });
|
|
|
+
|
|
|
+ unqualifiedProducts.qualityType = this.basicInfoData.qualityType;
|
|
|
+ unqualifiedProducts.qualityWorkOrderId =
|
|
|
+ this.basicInfoData.qualityWorkerId;
|
|
|
+ unqualifiedProducts.sourceCode = this.basicInfoData.source;
|
|
|
+ unqualifiedProducts.quantity = this.poList.reduce(
|
|
|
+ (total, item) => total + item.measureQuantity,
|
|
|
+ 0,
|
|
|
+ );
|
|
|
+ unqualifiedProducts.sourceType = this.basicInfoData.workOrderId ? 1 : 0;
|
|
|
+
|
|
|
+ return unqualifiedProducts;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ },
|
|
|
+ save() {
|
|
|
+ if (!this.basicInfoData.reportNumber) {
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: "error",
|
|
|
+ icon: false,
|
|
|
+ message: "请输入报告单号",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.saving = true;
|
|
|
+ const params = {
|
|
|
+ id: this.currentRow.id || this.id,
|
|
|
+ type: this.currentRow.type || this.basicInfoData.type || 0,
|
|
|
+ reportTemplateId:
|
|
|
+ this.currentRow.reportTemplateId || this.currentRow.id || this.id,
|
|
|
+ reportTemplateCode:
|
|
|
+ this.currentRow.reportTemplateCode || this.currentRow.code || "",
|
|
|
+ reportTemplateName:
|
|
|
+ this.currentRow.reportTemplateName || this.currentRow.name || "",
|
|
|
+ unqualifiedProducts: this.getValueUnqualifiedProducts(),
|
|
|
+ reportTemplateJson: {
|
|
|
+ template:
|
|
|
+ (this.currentRow.reportTemplateJson &&
|
|
|
+ this.currentRow.reportTemplateJson.template) ||
|
|
|
+ "",
|
|
|
+ basicInfoData: this.basicInfoData,
|
|
|
+ inspectionItems: this.inspectionItems,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ // console.log(params, 'params')
|
|
|
+ // return
|
|
|
+ generateReport(params)
|
|
|
+ .then(() => {
|
|
|
+ this.saving = false;
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: "success",
|
|
|
+ icon: false,
|
|
|
+ message: "保存成功",
|
|
|
+ });
|
|
|
+ uni.$emit("inspectionReportRefresh");
|
|
|
+ uni.$emit("successInit");
|
|
|
+ setTimeout(() => {
|
|
|
+ this.back();
|
|
|
+ }, 500);
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ this.saving = false;
|
|
|
+ this.$refs.uToast.show({
|
|
|
+ type: "error",
|
|
|
+ icon: false,
|
|
|
+ message: err.message || "保存失败",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.mainBox {
|
|
|
+ background-color: #f3f8fb;
|
|
|
+ height: 100vh;
|
|
|
+ font-size: 27rpx;
|
|
|
+ overflow-y: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.page-body {
|
|
|
+ padding-bottom: 20rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.card {
|
|
|
+ width: 720rpx;
|
|
|
+ background: #fff;
|
|
|
+ margin: 20rpx auto 0;
|
|
|
+ border-radius: 30rpx;
|
|
|
+ padding: 26rpx;
|
|
|
+ box-sizing: border-box;
|
|
|
+
|
|
|
+ .card-title {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ font-weight: bold;
|
|
|
+ font-size: 30rpx;
|
|
|
+ margin-bottom: 16rpx;
|
|
|
+
|
|
|
+ .herder_text {
|
|
|
+ min-width: 10rpx;
|
|
|
+ height: 32rpx;
|
|
|
+ border-radius: 10rpx;
|
|
|
+ background: #00c0a1;
|
|
|
+ margin-right: 12rpx;
|
|
|
+ margin-top: 5rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .info-row {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin-top: 20rpx;
|
|
|
+ font-size: 26rpx;
|
|
|
+
|
|
|
+ .label {
|
|
|
+ color: #666;
|
|
|
+ min-width: 150rpx;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+
|
|
|
+ .value {
|
|
|
+ flex: 1;
|
|
|
+ word-break: break-all;
|
|
|
+ color: #333;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.column {
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: flex-start;
|
|
|
+
|
|
|
+ .label {
|
|
|
+ margin-bottom: 12rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .value {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.radio-group {
|
|
|
+ flex-wrap: wrap;
|
|
|
+}
|
|
|
+
|
|
|
+.empty-tip {
|
|
|
+ color: #999;
|
|
|
+ text-align: center;
|
|
|
+ padding: 60rpx 40rpx;
|
|
|
+ font-size: 26rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.footerButton {
|
|
|
+ width: 100%;
|
|
|
+ height: 110rpx;
|
|
|
+ display: flex;
|
|
|
+ position: fixed;
|
|
|
+ bottom: 0;
|
|
|
+ left: 0;
|
|
|
+ z-index: 10;
|
|
|
+ background-color: #fff;
|
|
|
+ padding: 12rpx 24rpx;
|
|
|
+ box-sizing: border-box;
|
|
|
+
|
|
|
+ /deep/.u-button {
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ > view {
|
|
|
+ flex: 1;
|
|
|
+ margin: 0 10rpx;
|
|
|
+ }
|
|
|
+}
|
|
|
+/deep/.u-radio__icon-wrap {
|
|
|
+ width: 30rpx !important;
|
|
|
+ height: 30rpx !important;
|
|
|
+}
|
|
|
+/deep/.u-radio__text {
|
|
|
+ font-size: 26rpx !important;
|
|
|
+}
|
|
|
+</style>
|