3 changed files with 206 additions and 56 deletions
-
20src/components/patientRegister/PatientRegisterEdit.vue
-
6src/components/patientRegister/patientRegisterAsbItem.vue
-
148src/views/customerOrg/patientRegisterImport.vue
@ -0,0 +1,148 @@ |
|||
<template> |
|||
<div> |
|||
<div>123</div> |
|||
<el-dialog title="选择文件" :visible.sync="dialogGroup[0]" width="400" height="800" :show-close="false" |
|||
:append-to-body="true" :close-on-click-modal="false"> |
|||
<span slot="footer" class="dialog-footer"> |
|||
<el-button type="primary" @click="btnNext">下一步</el-button> |
|||
<el-button @click="seq = -1">关闭</el-button> |
|||
</span> |
|||
</el-dialog> |
|||
<el-dialog title="选择文件" :visible.sync="dialogGroup[1]" width="400" height="800" :show-close="false" |
|||
:append-to-body="true" :close-on-click-modal="false"> |
|||
<span slot="footer" class="dialog-footer"> |
|||
<el-button type="primary" @click="btnPre">上一步</el-button> |
|||
<el-button type="primary" @click="btnNext">上一步</el-button> |
|||
<el-button @click="seq = -1">关闭</el-button> |
|||
</span> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
<script> |
|||
import { mapState, mapActions } from "vuex"; |
|||
import ExcelJS from "exceljs"; |
|||
import { getapi, postapi, putapi, deletapi } from "@/api/api"; |
|||
|
|||
|
|||
export default { |
|||
components: { |
|||
|
|||
}, |
|||
data() { |
|||
return { |
|||
dialogGroup:[true,false,false], |
|||
seq: 0, //当前显示窗口 |
|||
excelCol: [], //excel数据列名 |
|||
excelData: [], //excel表格数据 |
|||
}; |
|||
}, |
|||
|
|||
//组件创建完成,一般页面初始布局放在这里 |
|||
created() { |
|||
|
|||
}, |
|||
|
|||
//页面挂载完成,一般页面渲染数据放在这里 |
|||
mounted() { |
|||
|
|||
}, |
|||
|
|||
computed: { |
|||
...mapState(["window", "dict", "patientRegister", "customerOrg"]), |
|||
}, |
|||
|
|||
methods: { |
|||
//上一步 |
|||
btnPre() { |
|||
if(this.seq == 0) return; |
|||
this.seq--; |
|||
this.setDialogDisp(); |
|||
}, |
|||
|
|||
//下一步 |
|||
btnNext() { |
|||
if(this.seq == 0) return; |
|||
this.seq++; |
|||
this.setDialogDisp(); |
|||
}, |
|||
|
|||
//显示数据 |
|||
setDialogDisp(){ |
|||
this.dialogGroup.forEach((item,index) =>{ |
|||
if(index == this.seq){ |
|||
item = true; |
|||
}else{ |
|||
item = false; |
|||
} |
|||
return item; |
|||
}); |
|||
}, |
|||
|
|||
onFileChange(event) { |
|||
// 获取上传的文件 |
|||
const file = event.target.files[0]; |
|||
|
|||
// 调用导入Excel文件的方法 |
|||
this.importExcelFile(file); |
|||
}, |
|||
|
|||
importExcelFile(file) { |
|||
this.filepopupdialogVisible = true; |
|||
|
|||
console.log("333"); |
|||
// 创建一个工作簿 |
|||
const workbook = new ExcelJS.Workbook(); |
|||
// 读取Excel文件 |
|||
const reader = new FileReader(); |
|||
console.log(reader); |
|||
reader.onload = () => { |
|||
const buffer = reader.result; |
|||
const typedArray = new Uint8Array(buffer); |
|||
const blob = new Blob([typedArray], { |
|||
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", |
|||
}); |
|||
|
|||
// 从Blob中读取Excel文件 |
|||
workbook.xlsx.load(blob).then((workbook) => { |
|||
// 获取第一个工作表 |
|||
const worksheet = workbook.getWorksheet(1); |
|||
// 处理Excel文件内容 |
|||
worksheet.eachRow((row, rowNumber) => { |
|||
// const rowData = row.values; |
|||
// this.rowData = row.values; |
|||
|
|||
// console.log(this.rowData,'rowdata'); |
|||
// console.log(rowData); |
|||
//console.log('row,rowNumber',row,rowNumber); |
|||
this.importData.push(row.values); |
|||
|
|||
// console.log(`第${rowNumber}行的数据:${rowData}`); |
|||
}); |
|||
}); |
|||
}; |
|||
reader.readAsArrayBuffer(file); |
|||
}, |
|||
|
|||
parseImportData(importData) { |
|||
console.log("importData", importData.length, importData); |
|||
importData.forEach((item) => { |
|||
item.forEach((item2) => { |
|||
// this.$set(item2[0], "name", true); |
|||
item2[0]['names'] = true |
|||
console.log(item2); |
|||
// console.log(item2); |
|||
}); |
|||
// console.log(item,'item',item.length); |
|||
}); |
|||
}, |
|||
|
|||
}, |
|||
|
|||
|
|||
}; |
|||
</script> |
|||
<style scoped> |
|||
.box { |
|||
display: flex; |
|||
} |
|||
</style> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue