From 9a2b763b5bb3195ccde6abd4f2e5c8527cea51e3 Mon Sep 17 00:00:00 2001
From: HanLong <404402223@qq.com>
Date: Thu, 12 Feb 2026 10:27:11 +0800
Subject: [PATCH] =?UTF-8?q?feat:[=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86]?=
=?UTF-8?q?=E5=AF=BC=E5=85=A5=E3=80=81=E8=A7=A3=E6=9E=90excel?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 3 +-
.../business/comps/template/comps/pcr/PCR002.vue | 15 +++-
.../comps/template/dialog/ImportExcelDialog.vue | 97 ++++++++++++++++++++++
.../comps/template/mixins/templateMixin.js | 50 +++++++++--
4 files changed, 153 insertions(+), 12 deletions(-)
create mode 100644 src/views/business/comps/template/dialog/ImportExcelDialog.vue
diff --git a/package.json b/package.json
index b8f8638..40c461d 100644
--- a/package.json
+++ b/package.json
@@ -54,7 +54,8 @@
"vue-pdf": "^4.3.0",
"vue-router": "3.4.9",
"vuedraggable": "2.24.3",
- "vuex": "3.6.0"
+ "vuex": "3.6.0",
+ "xlsx": "^0.18.5"
},
"devDependencies": {
"@vue/cli-plugin-babel": "4.4.6",
diff --git a/src/views/business/comps/template/comps/pcr/PCR002.vue b/src/views/business/comps/template/comps/pcr/PCR002.vue
index b159b6c..f729857 100644
--- a/src/views/business/comps/template/comps/pcr/PCR002.vue
+++ b/src/views/business/comps/template/comps/pcr/PCR002.vue
@@ -19,7 +19,8 @@
@onSureModifyRecord="onSureModifyRecord"
@resetRecord="resetRecord"
:formConfig="stepFormConfig" @blur="onHandleBlur" :formData="formData" />
- 导入模板
+ 下载模板
+ 导入模板
+
@@ -68,10 +70,10 @@ import SelectReagentDialog from '../../dialog/SelectReagentDialog.vue';
import { getLadderColumnsConfig } from "../../formConfig/PCRTableConfig.js";
import TableOpertaion from "@/components/Template/operation/TableOpertaion.vue"
import { addTj,uniqeResource,uniqeResourceOne,addDecimals } from "@/utils/calUnitTools";
-
+import ImportExcelDialog from '../../dialog/ImportExcelDialog'
export default {
name: "PCR002",
- components: { BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, TableOpertaion, SelectReagentDialog },
+ components: { ImportExcelDialog, BaseInfoFormPackage, LineLabel, TableList, Step, CustomTable, TableOpertaion, SelectReagentDialog },
mixins: [templateMixin],
props: {
fillType: {
@@ -259,6 +261,13 @@ export default {
},
methods: {
+ showImportExcelDialog() {
+ this.$refs.ImportExcelDialog.show()
+ },
+ onLoadData(excelData) {
+ console.log('onLoadData')
+ console.log(excelData)
+ },
//更新记录
onSureModifyRecord(key) {
if (key === "subStartSolution") {//选择起始源溶液需要同步更新table的变更记录。
diff --git a/src/views/business/comps/template/dialog/ImportExcelDialog.vue b/src/views/business/comps/template/dialog/ImportExcelDialog.vue
new file mode 100644
index 0000000..94aabfe
--- /dev/null
+++ b/src/views/business/comps/template/dialog/ImportExcelDialog.vue
@@ -0,0 +1,97 @@
+
+
+
+
+
+
+ 将文件拖到此处,或点击上传
+
+ 仅允许导入xls、xlsx格式文件
+
+
+
+
+
+
+
+
diff --git a/src/views/business/comps/template/mixins/templateMixin.js b/src/views/business/comps/template/mixins/templateMixin.js
index 1396b26..5634fca 100644
--- a/src/views/business/comps/template/mixins/templateMixin.js
+++ b/src/views/business/comps/template/mixins/templateMixin.js
@@ -29,7 +29,7 @@ export default {
'business_sp_xskkx', //色谱-编号-稀释可靠性
'business_sp_cbydb', //色谱-编号-储备液对比
'business_pcr_gzy', // PCR-编号-工作液
-
+
'business_lba_jg' // LBA006-结果
],
props: {
@@ -359,7 +359,7 @@ export default {
subTargetStartSolution,
headerSelectFields
}
-
+
arr.forEach((item, rowIndex) => {
this.updateTargetStartSolutionVolume(
item,
@@ -447,7 +447,7 @@ export default {
// 实际目标溶液浓度 = 实际源溶液浓度÷(实际终体积÷源溶液加入体积);
const actNd = (
parseFloat(targetAcSolution) / (
- parseFloat(actVol)/parseFloat(actStartSolutionVolume)
+ parseFloat(actVol)/parseFloat(actStartSolutionVolume)
)
).toFixed(precision)
const nd = actNd === 'Infinity' ? 0 : Number(actNd)
@@ -487,19 +487,19 @@ export default {
const {subTargetStartSolution,headerSelectFields} = unitParams
const {targetSolutionConcentrationUnit,targetSolutionVolumeUnit,targetStartSolutionVolumeUnit,targetDiluentVolumeUnit} = headerSelectFields
const targetStartVolUnit = targetSolutionConcentrationUnit.split("/")[1];//先按照预设目标溶液浓度的单位标准
-
+
if(
- isValueEmpty(concentration) ||
+ isValueEmpty(concentration) ||
isValueEmpty(targetVolume)||
isValueEmpty(subTargetStartSolution)||
isValueEmpty(targetSolutionConcentrationUnit)||
isValueEmpty(targetSolutionVolumeUnit)||
- isValueEmpty(targetStartSolutionVolumeUnit)||
+ isValueEmpty(targetStartSolutionVolumeUnit)||
isValueEmpty(targetDiluentVolumeUnit)
){
return;
}
- //将起始溶液浓度转换为和预设目标溶液浓度一样的单位再计算;
+ //将起始溶液浓度转换为和预设目标溶液浓度一样的单位再计算;
const converStartCon = convertConcentration.convert(volume+subTargetStartSolution,targetSolutionConcentrationUnit)
//将预设目标溶液体积转换为和预设目标溶液浓度单位的分母一样的单位再计算;如:预设目标溶液浓度单位为mg/mL,预设目标溶液体积单位为uL,则将预设目标溶液体积转换为mL
const convertTargetVol = volumeConverter.convert(targetVolume+targetSolutionVolumeUnit,targetStartVolUnit)
@@ -521,6 +521,40 @@ export default {
item.targetDiluentVolume = volumeConverter.convert(result1+targetStartSolutionVolumeUnit,targetDiluentVolumeUnit)
// this.$refs.stepTableRef.updateDataSourceByRowIndex(rowIndex, { targetDiluentVolume: result1 });
}
- }
+ },
+ // 导出excel模板
+ exportExcel(rows, title) {
+ let that = this
+ that.$modal.loading()
+ var tabelStr =
+ '' +
+ ''
+
+ rows.forEach(item => {
+ tabelStr = tabelStr + '| ' + item + ' | '
+ })
+ tabelStr = tabelStr + '
'
+
+ // Worksheet名
+ var worksheet = title ? title : '导入模板'
+ var uri = 'data:application/vnd.ms-excel;base64,'
+ // 真正要导出(下载)的HTML模板
+ var exportTemplate = `
+
+
+
+ ${tabelStr}
+
+ `
+ var a = document.createElement('a')
+ a.download = worksheet + '.xls'
+ a.href = uri + window.btoa(unescape(encodeURIComponent(exportTemplate)))
+ a.click()
+ that.$modal.closeLoading()
+ },
}
}