| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546 |
- <template>
- <ele-modal
- :visible="visible"
- width="70%"
- append-to-body
- title="检测报告"
- @close="cancel"
- :maxable="true"
- >
- <div class="switch">
- <div class="switch_left">
- <ul>
- <li
- v-for="item in tabOptions"
- :key="item.key"
- :class="{ active: activeComp == item.key }"
- @click="activeComp = item.key"
- >
- {{ item.name }}
- </li>
- </ul>
- </div>
- </div>
- <component
- :is="targetComponent"
- ref="templateRef"
- v-if="visible"
- v-show="activeComp == 'main'"
- :key="componentName"
- :isView="isView"
- :type="type"
- ></component>
- <template v-slot:footer>
- <el-button v-if="isView" type="primary" @click="print">打印</el-button>
- <el-button v-if="!isView" type="primary" @click="save">确认</el-button>
- <el-button @click="cancel">关闭</el-button>
- </template>
- <unqualifiedProduct
- ref="unqualifiedProductRef"
- v-show="activeComp == 'unqualifiedList'"
- @setQualifiedNumber="setQualifiedNumber"
- :total="basicInfoData.total"
- :isView="isView"
- @setLossNumber="setLossNumber"
- >
- </unqualifiedProduct>
- <div style="margin-top: 10px" v-if="activeComp != 'bpm'">
- 结论:
- <el-select
- v-model="basicInfoData.qualityResults"
- placeholder="请选择"
- style="width: 120px"
- @change="selectResult"
- :disabled="isView"
- >
- <el-option label="整单合格" :value="1" />
- <el-option label="整单不合格" :value="2" />
- <el-option label="部分合格" :value="3" />
- <el-option label="整单让步接收" :value="4" />
- </el-select>
- 合格数:
- <el-input
- v-model="basicInfoData.qualifiedNumber"
- placeholder="合格数"
- style="width: 110px"
- disabled
- ></el-input>
- 不合格数:
- <el-input
- v-model="basicInfoData.noQualifiedNumber"
- placeholder="不合格数"
- disabled
- style="width: 110px"
- ></el-input>
- 留样数(合格):
- <el-input
- v-model="basicInfoData.retainedSampleQuantity"
- placeholder=" "
- disabled
- style="width: 80px"
- ></el-input>
- 留样数(不合格):
- <el-input
- v-model="basicInfoData.retainedSampleUnqualified"
- placeholder=" "
- disabled
- style="width: 80px"
- ></el-input>
- 消耗数(合格):
- <el-input
- v-model="basicInfoData.lossNumber"
- placeholder=" "
- disabled
- style="width: 80px"
- ></el-input>
- 消耗数(不合格):
- <el-input
- v-model="basicInfoData.lossNumberUnqualified"
- placeholder=" "
- disabled
- style="width: 80px"
- ></el-input>
- </div>
- <bpmDetail
- v-if="activeComp === 'bpm' && processInstanceId"
- :id="processInstanceId"
- ></bpmDetail>
- </ele-modal>
- </template>
- <script>
- import inspection_report1 from '../template/inspection_report1.vue';
- import inspection_report2 from '../template/inspection_report2.vue';
- import {
- queryInspectionReportData,
- queryInspectionReportList,
- generateReport
- } from '@/api/inspectionReport';
- import bpmDetail from '@/views/bpm/processInstance/detail.vue';
- import unqualifiedProduct from '@/views/inspectionReport/components/unqualifiedProduct.vue';
- import { getList } from '@/api/unacceptedProduct/index';
- import { getCode } from '@/api/login';
- const defForm = {
- poList: [],
- unqualifiedProductsCode: '',
- sourceCode: '',
- batchNo: '',
- brandNum: '',
- categoryCode: '',
- categoryId: '',
- categoryName: '',
- specification: '',
- modelType: '',
- produceRoutingId: '',
- produceRoutingName: '',
- taskId: '',
- taskName: '',
- quantity: '',
- measureQuantity: '',
- measureUnit: '',
- weight: '',
- weightUnit: '',
- qualityType: ''
- };
- export default {
- name: 'ReportTemplateWrapper',
- components: {
- inspection_report1,
- inspection_report2,
- unqualifiedProduct,
- bpmDetail
- },
- data() {
- return {
- unqualifiedProducts: {
- ...defForm
- },
- isView: false,
- visible: false,
- loading: false,
- currentRow: {}, // 存储当前行数据
- templateItem: {}, // 存储当前模板项数据
- // 基本信息数据
- basicInfoData: {},
- componentName: '',
- // 检验项目
- inspectionItems: [],
- tabOptions: [],
- activeComp: 'main',
- processInstanceId: '',
- reportApprovalTaskVos: []
- };
- },
- props: {
- type: {
- type: String,
- default: '0'
- }
- },
- methods: {
- /* 打开质检报告 */
- async open({ row, item }, isView) {
- // this.visible = true;
- this.activeComp = 'main';
- this.isView = isView;
- this.componentName = row.reportTemplateCode;
- this.currentRow = row;
- this.templateItem = item?.id ? item : row;
- this.processInstanceId = row.reportProcessInstanceId;
- this.reportApprovalTaskVos = row.reportApprovalTaskVos;
- this.tabOptions = [
- { key: 'main', name: '业务详情' },
- { key: 'unqualifiedList', name: '不合格品台账' }
- ];
- if (this.processInstanceId) {
- this.tabOptions.push({ key: 'bpm', name: '流程详情' });
- }
- this.visible = true;
- if (this.currentRow.reportTemplateJson?.basicInfoData) {
- this.basicInfoData =
- this.currentRow.reportTemplateJson.basicInfoData || {};
- this.inspectionItems =
- this.currentRow.reportTemplateJson.inspectionItems || [];
- const reviewTime =
- this.reportApprovalTaskVos?.[
- this.reportApprovalTaskVos.length - 2
- ]?.endTime?.split(' ')[0] || '';
- const approvedDate =
- this.reportApprovalTaskVos?.[
- this.reportApprovalTaskVos.length - 3
- ]?.endTime?.split(' ')[0] || '';
- const reviewer =
- this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 2]
- ?.approvalUserName || '';
- const checker =
- this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.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 || ''
- );
- this.$set(
- this.basicInfoData,
- 'qualityResults',
- this.basicInfoData.qualityResults
- );
- this.$set(
- this.basicInfoData,
- 'qualifiedNumber',
- this.basicInfoData.qualifiedNumber
- );
- this.$set(
- this.basicInfoData,
- 'noQualifiedNumber',
- this.basicInfoData.noQualifiedNumber
- );
- this.$nextTick(() => {
- this.$refs.templateRef.init(
- this.basicInfoData,
- this.inspectionItems
- );
- });
- this.initUnqualifiedProduct();
- } else {
- await this.getBasicInfo();
- await this.getInspectionItems();
- this.$nextTick(() => {
- this.$refs.templateRef.init(
- this.basicInfoData,
- this.inspectionItems
- );
- });
- }
- },
- async initUnqualifiedProduct() {
- const data = await getList({
- sourceCode: this.currentRow.code
- });
- if (data.list[0]) {
- this.unqualifiedProducts = data.list[0];
- }
- this.$nextTick(() => {
- this.$refs.unqualifiedProductRef.init({
- id: this.unqualifiedProducts?.id,
- qualityType: this.basicInfoData.qualityType,
- workOrderCode: this.currentRow.code,
- qualityWorkerId: this.basicInfoData.qualityWorkerId,
- workOrderId: this.currentRow.workOrderId,
- qualityResults: this.basicInfoData.qualityResults
- });
- });
- },
- setQualifiedNumber(data) {
- this.basicInfoData.qualifiedNumber = data.qualifiedNumber;
- this.basicInfoData.noQualifiedNumber = data.noQualifiedNumber;
- if (!data.noQualifiedNumber) {
- if (data.isQualifiedNumber) {
- this.basicInfoData.qualityResults = 1;
- } else {
- this.basicInfoData.qualityResults = 4;
- }
- }
- if (!data.qualifiedNumber) {
- this.basicInfoData.qualityResults = 2;
- }
- if (data.qualifiedNumber && data.noQualifiedNumber) {
- this.basicInfoData.qualityResults = 3;
- }
- },
- selectResult() {
- this.$refs.unqualifiedProductRef.selectResult(
- this.basicInfoData.qualityResults
- );
- },
- getBasicInfo() {
- return queryInspectionReportData({
- id: this.currentRow.id,
- type: this.type || this.currentRow.type || 0
- }).then((res) => {
- this.basicInfoData = res;
- this.basicInfoData.reportCode = res.reportCode || '';
- const reviewTime =
- this.reportApprovalTaskVos?.[
- this.reportApprovalTaskVos.length - 2
- ]?.endTime?.split(' ')[0] || '';
- const approvedDate =
- this.reportApprovalTaskVos?.[
- this.reportApprovalTaskVos.length - 3
- ]?.endTime?.split(' ')[0] || '';
- const reviewer =
- this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 2]
- ?.approvalUserName || '';
- const checker =
- this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 3]
- ?.approvalUserName || '';
- this.$set(
- this.basicInfoData,
- 'version',
- this.templateItem.versionSymbol +
- this.templateItem.bigVersion +
- this.templateItem.versionMark +
- this.templateItem.smallVersion
- );
- 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 || ''
- );
- 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,
- '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,
- 'qualityType',
- this.currentRow.qualityType
- );
- if (!this.basicInfoData.reportNumber) {
- getCode('quality_Inspection_report_number').then((res) => {
- this.$set(this.basicInfoData, 'reportNumber', res);
- });
- }
- this.initUnqualifiedProduct();
- });
- },
- getInspectionItems() {
- return queryInspectionReportList({
- id: this.currentRow.id,
- type: this.type || this.currentRow.type || 0
- }).then((res) => {
- this.inspectionItems = res;
- });
- },
- setLossNumber({
- 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
- );
- },
- cancel() {
- this.visible = false;
- this.$emit('close');
- this.unqualifiedProducts = { ...defForm };
- this.basicInfoData = {};
- },
- /* 打印 */
- print() {
- const printSection = document.getElementById('printSection');
- console.log('printSection', printSection.innerHTML);
- // 创建打印任务
- const printWindow = window.open('', '_blank');
- printWindow.document.open();
- printWindow.document.write('<html><head><title>打印预览</title>');
- printWindow.document.write(
- '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
- );
- printWindow.document.write('</head><body>');
- printWindow.document.write(printSection.innerHTML);
- printWindow.document.write('</body></html>');
- printWindow.document.close();
- printWindow.onload = function () {
- printWindow.print();
- };
- },
- /* 保存编辑 */
- save() {
- this.loading = true;
- this.isView = true;
- this.$nextTick(() => {
- const printSection = document.getElementById('printSection');
- const params = {
- id: this.currentRow.id,
- type: this.type || this.basicInfoData.type || 0,
- reportTemplateId:
- this.templateItem.reportTemplateId || this.templateItem.id,
- reportTemplateCode:
- this.templateItem.reportTemplateCode || this.templateItem.code,
- reportTemplateName:
- this.templateItem.reportTemplateName || this.templateItem.name,
- unqualifiedProducts: this.$refs.unqualifiedProductRef.getValue(),
- reportTemplateJson: {
- template: printSection.innerHTML,
- basicInfoData: this.$refs.templateRef.getValue(),
- inspectionItems: this.inspectionItems
- }
- };
- generateReport(params)
- .then((res) => {
- this.loading = false;
- this.isView = false;
- this.$message({
- message: '保存成功',
- type: 'success'
- });
- this.$emit('reload');
- this.cancel();
- // this.$emit('update:visible', false);
- // this.visible = false;
- })
- .catch((err) => {
- this.loading = false;
- this.isView = false;
- this.$message({
- message: err.message,
- type: 'error'
- });
- });
- });
- }
- },
- computed: {
- targetComponent() {
- return this.componentName;
- }
- }
- };
- </script>
|