|
|
@@ -348,9 +348,22 @@
|
|
|
buildFinishedProductReportData(item = {}, index = 0) {
|
|
|
const basicInfo = item.basicInfo || {};
|
|
|
const selected = this.getSelectedReport(basicInfo, index);
|
|
|
+ const reportTemplate = this.getReportTemplateData(item, selected);
|
|
|
+ const templateBasicInfo = reportTemplate.basicInfoData;
|
|
|
const detailList = Array.isArray(item.detailList)
|
|
|
? item.detailList
|
|
|
: [];
|
|
|
+ const inspectionItems = reportTemplate.inspectionItems.length
|
|
|
+ ? reportTemplate.inspectionItems.map((detail) => ({
|
|
|
+ inspectionItem: detail.item || '',
|
|
|
+ standard: detail.standardRegulations || '',
|
|
|
+ result: detail.results || ''
|
|
|
+ }))
|
|
|
+ : detailList.map((detail) => ({
|
|
|
+ inspectionItem: detail.inspectionItem || '',
|
|
|
+ standard: detail.standardRequirement || '',
|
|
|
+ result: detail.inspectionResult || ''
|
|
|
+ }));
|
|
|
return {
|
|
|
...selected,
|
|
|
...basicInfo,
|
|
|
@@ -361,6 +374,10 @@
|
|
|
selected.productName
|
|
|
),
|
|
|
specification: this.getValue(
|
|
|
+ this.buildSpecification(
|
|
|
+ templateBasicInfo.specification,
|
|
|
+ templateBasicInfo.modelType
|
|
|
+ ),
|
|
|
basicInfo.specModel,
|
|
|
selected.specification
|
|
|
),
|
|
|
@@ -383,6 +400,7 @@
|
|
|
selected.sampleQuantity
|
|
|
),
|
|
|
packagingSpec: this.getValue(
|
|
|
+ templateBasicInfo.packingSpecification,
|
|
|
basicInfo.packageSpec,
|
|
|
selected.packagingSpec
|
|
|
),
|
|
|
@@ -401,19 +419,53 @@
|
|
|
selected.validityPeriod
|
|
|
),
|
|
|
inspectionBasis: this.getValue(
|
|
|
+ templateBasicInfo.inspectionBasis,
|
|
|
basicInfo.inspectionBasis,
|
|
|
selected.inspectionBasis
|
|
|
),
|
|
|
inspector: selected.reportTemplateCreateUserName || '',
|
|
|
reviewer: selected.reportApprovalUserName || '',
|
|
|
- conclusion: selected.reportApprovalStatus === 2 ? '合格' : '',
|
|
|
- inspectionItems: detailList.map((detail) => ({
|
|
|
- inspectionItem: detail.inspectionItem || '',
|
|
|
- standard: detail.standardRequirement || '',
|
|
|
- result: detail.inspectionResult || ''
|
|
|
- }))
|
|
|
+ conclusion: this.getValue(
|
|
|
+ templateBasicInfo.conclusion,
|
|
|
+ selected.reportApprovalStatus === 2 ? '合格' : ''
|
|
|
+ ),
|
|
|
+ inspectionItems
|
|
|
};
|
|
|
},
|
|
|
+ getReportTemplateData(item = {}, selected = {}) {
|
|
|
+ const reportTemplateJson = this.parseReportTemplateJson(
|
|
|
+ this.getValue(item.reportTemplateJson, selected.reportTemplateJson)
|
|
|
+ );
|
|
|
+ const basicInfoData =
|
|
|
+ reportTemplateJson.basicInfoData || reportTemplateJson;
|
|
|
+ let inspectionItems = reportTemplateJson.inspectionItems;
|
|
|
+ if (!Array.isArray(inspectionItems)) {
|
|
|
+ inspectionItems = Array.isArray(reportTemplateJson.items)
|
|
|
+ ? reportTemplateJson.items
|
|
|
+ : this.hasValue(reportTemplateJson.item)
|
|
|
+ ? [reportTemplateJson]
|
|
|
+ : [];
|
|
|
+ }
|
|
|
+ return { basicInfoData, inspectionItems };
|
|
|
+ },
|
|
|
+ parseReportTemplateJson(value) {
|
|
|
+ if (!value) {
|
|
|
+ return {};
|
|
|
+ }
|
|
|
+ if (typeof value === 'object') {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return JSON.parse(value);
|
|
|
+ } catch (error) {
|
|
|
+ return {};
|
|
|
+ }
|
|
|
+ },
|
|
|
+ buildSpecification(specification, modelType) {
|
|
|
+ return [specification, modelType]
|
|
|
+ .filter((value) => this.hasValue(value))
|
|
|
+ .join('/');
|
|
|
+ },
|
|
|
getPrintRows() {
|
|
|
return this.selection.length ? this.selection : this.tableData;
|
|
|
},
|