Browse Source

fix:[模板管理][PCR007]

zhangteng
HanLong 4 days ago
parent
commit
2eaa683a0c
3 changed files with 69 additions and 17 deletions
  1. +1
    -0
      src/lang/en/template/commonTemplate.js
  2. +1
    -0
      src/lang/zh/template/commonTemplate.js
  3. +67
    -17
      src/views/business/comps/template/comps/pcr/PCR007.vue

+ 1
- 0
src/lang/en/template/commonTemplate.js View File

@ -57,6 +57,7 @@ export default {
addBtn: 'Add', addBtn: 'Add',
deleteBtn: 'Delete', deleteBtn: 'Delete',
downloadTemplate: 'Download Template', downloadTemplate: 'Download Template',
downloadTableData: 'Download Table',
importTemplate: 'Import Template', importTemplate: 'Import Template',
// 错误提示 // 错误提示

+ 1
- 0
src/lang/zh/template/commonTemplate.js View File

@ -58,6 +58,7 @@ export default {
saveBtn: '保存', saveBtn: '保存',
deleteBtn: '刪除', deleteBtn: '刪除',
downloadTemplate: '下载模板', downloadTemplate: '下载模板',
downloadTableData: '下载表格数据',
importTemplate: '导入模板', importTemplate: '导入模板',
// 错误提示 // 错误提示

+ 67
- 17
src/views/business/comps/template/comps/pcr/PCR007.vue View File

@ -21,13 +21,16 @@
$t('template.common.downloadTemplate') }}</el-button> $t('template.common.downloadTemplate') }}</el-button>
<el-button type="primary" @click="showImportExcelDialog">{{ <el-button type="primary" @click="showImportExcelDialog">{{
$t('template.common.importTemplate') $t('template.common.importTemplate')
}}</el-button>
}}</el-button>
</div> </div>
<el-button type="primary" @click="downloadTableData">{{
$t('template.common.downloadTableData') }}</el-button>
<CustomTable @blur="onHandleTableBlur" @headerSelectChange="onHandleTableBlur" <CustomTable @blur="onHandleTableBlur" @headerSelectChange="onHandleTableBlur"
:ref="`stepTableRef`" :columns="tableStepColumns" :formData="formData" :prefixKey="`table`" :ref="`stepTableRef`" :columns="tableStepColumns" :formData="formData" :prefixKey="`table`"
:showOperation="fillType === 'preFill'"
fieldItemLabel="template.common.operationSteps" @clickButton="handleClickButton">
:showOperation="fillType === 'preFill'" fieldItemLabel="template.common.operationSteps"
@clickButton="handleClickButton">
<template slot="operation" slot-scope="{ row, rowIndex, columns }"> <template slot="operation" slot-scope="{ row, rowIndex, columns }">
<TableOpertaion :fillType="fillType" :row="row" :rowIndex="rowIndex" :columns="columns" <TableOpertaion :fillType="fillType" :row="row" :rowIndex="rowIndex" :columns="columns"
@deleteRow="(rowIndex) => deleteRow(rowIndex)"></TableOpertaion> @deleteRow="(rowIndex) => deleteRow(rowIndex)"></TableOpertaion>
@ -53,19 +56,21 @@ import TableList from "@/components/Template/Table";
import Step from "@/components/Template/Step"; import Step from "@/components/Template/Step";
import templateMixin from "../../mixins/templateMixin.js"; import templateMixin from "../../mixins/templateMixin.js";
import CustomTable from '@/components/Template/CustomTable.vue'; import CustomTable from '@/components/Template/CustomTable.vue';
import { isValueEmpty } from '@/utils/index';
import { isValueEmpty, getStringWidth } from '@/utils/index';
import { getLatestSnArr } from '@/api/template'; import { getLatestSnArr } from '@/api/template';
import { EventBus } from "@/utils/eventBus"; import { EventBus } from "@/utils/eventBus";
import { volumeConverter } from "@/utils/volConverter";// import { volumeConverter } from "@/utils/volConverter";//
import { convertConcentration } from "@/utils/conConverter";// import { convertConcentration } from "@/utils/conConverter";//
import SelectReagentDialog from '../../dialog/SelectReagentDialog.vue'; import SelectReagentDialog from '../../dialog/SelectReagentDialog.vue';
import { getPCR007Config } from "../../formConfig/PCRTableConfig.js";
import { getPCR007Config } from "../../formConfig/PCRTableConfig.js";
import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue" import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue"
import { addTj, uniqeResource, uniqeResourceOne, addDecimals,uniqeYqOne } from "@/utils/calUnitTools";
import { addTj, uniqeResource, uniqeResourceOne, addDecimals, uniqeYqOne } from "@/utils/calUnitTools";
import ImportExcelDialog from '../../dialog/ImportExcelDialog' import ImportExcelDialog from '../../dialog/ImportExcelDialog'
import { getBalance } from '@/utils/tpph.js'; import { getBalance } from '@/utils/tpph.js';
import * as XLSX from 'xlsx'
export default { export default {
name: "PCR005",
name: "PCR007",
components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, TableOpertaion, SelectReagentDialog, ImportExcelDialog }, components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, TableOpertaion, SelectReagentDialog, ImportExcelDialog },
mixins: [templateMixin], mixins: [templateMixin],
props: { props: {
@ -192,9 +197,54 @@ export default {
}, },
mounted() { mounted() {
const formData = this.getFormDataByTemplateData(); const formData = this.getFormDataByTemplateData();
this.onHandleTableBlur() this.onHandleTableBlur()
}, },
methods: { methods: {
downloadTableData() {
this.$modal.loading()
let content = this.getFilledFormData();
var tabelStr =
'<table border="1" class="html-tabel">' +
'<tr style="background:#eee;">' +
'<th style="text-align: center;">' + '样品名称' + '</th>' +
'<th style="text-align: center;">' + '采集管重量' + content.headerSelectFields.cjgzlUnit + '</th>' +
' </tr>'
let _datastr = ''
_.forEach(content.stepTableFormData, function (value) {
_datastr =
_datastr +
'<tr style="text-align: center;">' +
' <td>' +
value.ypmc +
'</td>' +
' <td>' +
value.cjgzl +
'</td>' +
'</tr>'
})
tabelStr = tabelStr + _datastr + ' <table>'
// Worksheet
var worksheet = this.formData.bdmc
var uri = 'data:application/vnd.ms-excel;base64,'
// HTML
var exportTemplate = `<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>
<x:Name>${worksheet}</x:Name>
<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>
</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
</head>
<body>
${tabelStr}
</body>
</html>`
var a = document.createElement('a')
a.download = worksheet + '.xls'
a.href = uri + window.btoa(unescape(encodeURIComponent(exportTemplate)))
a.click()
this.$modal.closeLoading()
},
downloadExcelTemplate() { downloadExcelTemplate() {
this.exportExcel(['样品名称', '样品初始浓采样前样品管试剂预计添加体积度'], 'PCR分析采集管称重记录表导入模板') this.exportExcel(['样品名称', '样品初始浓采样前样品管试剂预计添加体积度'], 'PCR分析采集管称重记录表导入模板')
}, },
@ -212,7 +262,7 @@ export default {
list.push({ list.push({
ypmc: item[0], ypmc: item[0],
cyqypgsjyjtjtj: item[1], cyqypgsjyjtjtj: item[1],
id:this.getuuid(),
id: this.getuuid(),
}) })
}) })
this.$refs.stepTableRef.addRows(list) this.$refs.stepTableRef.addRows(list)
@ -256,11 +306,11 @@ export default {
//使 //使
tmpYq.push(content.selectInfo_solution || formData.selectInfo_solution) tmpYq.push(content.selectInfo_solution || formData.selectInfo_solution)
//使 //使
const stepResource = this.$refs.stepRef.getStepResource() const stepResource = this.$refs.stepRef.getStepResource()
this.resourceTmp = uniqeResource(tmpResource, stepResource.sjResource || []) this.resourceTmp = uniqeResource(tmpResource, stepResource.sjResource || [])
this.yqResourceTmp = uniqeYqOne([...stepResource.yqResource || [],...tmpYq])
this.yqResourceTmp = uniqeYqOne([...stepResource.yqResource || [], ...tmpYq])
return this.resourceTmp; return this.resourceTmp;
}, },
// //
@ -276,18 +326,18 @@ export default {
} }
}, },
// //
async handleClickButton(e, rowIndex,colIndex,ee,data) {
if(e==='targetDiluentVolumePrecision'){
async handleClickButton(e, rowIndex, colIndex, ee, data) {
if (e === 'targetDiluentVolumePrecision') {
const content = this.getFilledFormData() const content = this.getFilledFormData()
let formData = this.formData;
let formData = this.formData;
let qy = content.yqInfo_solution || formData.yqInfo_solution let qy = content.yqInfo_solution || formData.yqInfo_solution
let dw = content.headerSelectFields.cjgzlUnit let dw = content.headerSelectFields.cjgzlUnit
let x = await getBalance({yq:qy,dw:dw})
if(x && x.success){
this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { cjgzl: x.value },{signData:data,updateFields:['cjgzl']});
}else{
let x = await getBalance({ yq: qy, dw: dw })
if (x && x.success) {
this.$refs.stepTableRef?.updateDataSourceByRowIndex(rowIndex, { cjgzl: x.value }, { signData: data, updateFields: ['cjgzl'] });
} else {
this.$message.error(x.message || '称量失败') this.$message.error(x.message || '称量失败')
} }
} }

Loading…
Cancel
Save