From f6d81adfd71fba2490052306d2e2b3613cedd9cd Mon Sep 17 00:00:00 2001 From: pengjun <158915633@qq.com> Date: Wed, 14 Aug 2024 18:30:53 +0800 Subject: [PATCH] import --- .../basic-dictionary/ThirdPartyInterfaces.vue | 6 + src/views/doctorCheck/lisResultImport.vue | 234 +++++++++++++----- 2 files changed, 175 insertions(+), 65 deletions(-) diff --git a/src/views/basic-dictionary/ThirdPartyInterfaces.vue b/src/views/basic-dictionary/ThirdPartyInterfaces.vue index 652e3a7..75abd0c 100644 --- a/src/views/basic-dictionary/ThirdPartyInterfaces.vue +++ b/src/views/basic-dictionary/ThirdPartyInterfaces.vue @@ -386,6 +386,12 @@ export default { },{ id:"08", displayName:"心电图结果导入" + },{ + id:"09", + displayName:"同步组合项目价格" + },{ + id:"10", + displayName:"短信推送" }] } }, diff --git a/src/views/doctorCheck/lisResultImport.vue b/src/views/doctorCheck/lisResultImport.vue index 98cfd89..3a808a8 100644 --- a/src/views/doctorCheck/lisResultImport.vue +++ b/src/views/doctorCheck/lisResultImport.vue @@ -30,7 +30,7 @@
- @@ -64,12 +64,12 @@ -
+
- @@ -79,13 +79,13 @@
-
- Excel结果排列方式: +
+ Excel结果排列方式: 纵向排列 横向排列
-
- 条码方式: +
+ 条码方式: 人员条码 项目条码
@@ -95,7 +95,8 @@ :picker-options="pickerOptions" value-format="yyyy-MM-dd HH:mm:ss" style="width:160px;" size="small"> 标本间隔时间: - +
@@ -143,7 +144,7 @@
- + @@ -169,7 +170,7 @@ export default { }, data() { return { - + startPoint: -1, // 多选起点 -1 表示未选择 endPoint: -1, // 多选终点 -1 表示未选择 rClickRow: null, //右击的行 @@ -182,12 +183,12 @@ export default { }, oldSeq: -2, //旧的步骤(辅助区分上一步,下一步) seq: 10, //当前显示窗口 - + excelCols: [{ dispLabel: '', val: '', dataLabel: '' }], //excel数据列名 {dispLabel:'',val:'',dataLabel:''} importCols: [], // 实际导入的列(即有设置与 dataCols 匹配的列) excelData: [], // excel表格数据 choosedData: [], // 选中的待导入的数据 - + toApiBodys: [], // api需要的数据格式 dataCols: [ { dispLabel: '不设置', val: '' }, { dispLabel: '条码号', val: 'barcode' }, @@ -198,7 +199,8 @@ export default { { dispLabel: '项目', val: 'itemName' }, { dispLabel: '结果', val: 'itemResult' } ], - + preBarcode: '', // 上一人条码号 + curCheckDate: '', // 当前检查时间 tableData: [], //导入数据状态显示 @@ -212,14 +214,13 @@ export default { }, readDataOptsInit: {}, - dataImportOpts: { - startRow: 0, //从 excelData 的第几行开始导入 + dataImportOpts: { barcodeMode: '1', // 条码方式: '0'/人员条码;'1'/项目条码 - startCheckDate:'', // 检查起始时间 - checkInterval:30, // 标本间隔时间(秒) + startCheckDate: '', // 检查起始时间 + checkInterval: 30, // 标本间隔时间(秒) }, - dataImportOptsInit: {}, - + dataImportOptsInit: {}, + pickerOptions: { shortcuts: [{ text: '今天', @@ -255,7 +256,7 @@ export default { //组件创建完成,一般页面初始布局放在这里 created() { - this.seq = 10 + this.seq = 10 this.readDataOptsInit = Object.assign({}, this.readDataOpts) this.dataImportOptsInit = Object.assign({}, this.dataImportOpts) }, @@ -288,10 +289,6 @@ export default { this.readDataOpts = Object.assign({}, this.readDataOptsInit) this.dataImportOpts = Object.assign({}, this.dataImportOptsInit) - this.customerOrgIds = [] //选中单位节点 - this.customerOrgRegisterList = [] //体检次数列表 - this.customerOrgRegister = {} //体检次数 - this.startPoint = -1 // 多选起点 -1 表示未选择 this.endPoint = -1 // 多选终点 -1 表示未选择 @@ -326,10 +323,10 @@ export default { this.dialogGroup[e] = false }) this.clearProcess() - break; + break; case 10: this.excelCols = [] - this.tableData = [] + this.tableData = [] this.startPoint = -1 // 多选起点 -1 表示未选择 this.endPoint = -1 // 多选终点 -1 表示未选择 //显示 EXCEL 导入 @@ -359,8 +356,24 @@ export default { break; } } - //显示 数据分析操作 窗口 + + if (!this.dataImportOpts.startCheckDate) { + this.$message.warning({ showClose: true, message: '请选择起始检查时间' }) + break; + } + if (!this.dataImportOpts.checkInterval) { + this.$message.warning({ showClose: true, message: '请填写标本间隔时间' }) + break; + } else { + try { + Number(this.dataImportOpts.checkInterval) + } catch (error) { + this.$message.warning({ showClose: true, message: '标本间隔时间只能填写数字' }) + break; + } + } + keys.forEach(e => { if (e == 'fileDataOpr') { this.dialogGroup[e] = true @@ -388,7 +401,7 @@ export default { this.dialogGroup[e] = false } }) - break; + break; default: @@ -636,12 +649,14 @@ export default { let items = [] //菜单 this.dataCols.forEach(e => { - items.push({ - label: e.dispLabel, - onClick: () => { - this.setColumn(chooseCol, e) - }, - }) + if (!(this.readDataOpts.resultMode == 'H' && (e.val == 'itemResult' || e.val == 'itemName'))) { + items.push({ + label: e.dispLabel, + onClick: () => { + this.setColumn(chooseCol, e) + }, + }) + } }) //右击显示的菜单 @@ -695,7 +710,7 @@ export default { // 确定导入数据库 btnImport() { - + this.elProgress.display = true; this.elProgress.percentage = 0; @@ -711,61 +726,150 @@ export default { if (e.choosed) this.choosedData.push(e) }); + //导入进行中 - this.importing(this.dataImportOpts.startRow) + this.importing() // 开始导入时,清除选择的 文件 document.getElementById('fileNames').value = ''; }, //导入进行时 - // startRow : 从第几行开始导入 - async importing(startRow) { - let body = {} - for (let i = startRow; i < this.choosedData.length; i++) { + async importing() { + + // 将Excel的数据转换成接口的数据 + this.excelDataToApiBodys(this.choosedData) + console.log('this.toApiBodys', this.toApiBodys) + + // 旧接口:/api/app/patientregister/createpatientregisterexcel + for (let i = 0; i < this.toApiBodys.length; i++) { this.elProgress.percentage = Math.floor( ((i + 1) * 100) / this.choosedData.length ); - // 将Excel的数据转换成接口的数据 - body = this.excelDataToApiBody(this.choosedData[i]) - console.log(`this.choosedData[${i}],body`,this.choosedData[i],body) - - // 旧接口:/api/app/patientregister/createpatientregisterexcel - let res = await postapi('/api/app/patientregister/CreatePatientRegisterFromExcel', body) - this.choosedSameMan = {} // 清除选择同一人员的记录 + let res = await postapi('/api/app/patientregister/CreatePatientRegisterFromExcel', this.toApiBodys[i]) if (res.code >= 0) { - this.tableData.push(Object.assign({ importState: '导入成功' }, this.choosedData[i])) + this.tableData.push(Object.assign({ importState: '导入成功' }, this.toApiBodys[i])) } else { - this.tableData.push(Object.assign({ importState: '导入失败', importDes: res.message }, this.choosedData[i])) - } - - // 结束导入 - if (i == this.choosedData.length - 1) { - this.elProgress.display = false; - this.seq = -1 + this.tableData.push(Object.assign({ importState: '导入失败', importDes: res.message }, this.toApiBodys[i])) } + } + + // 结束导入 + this.elProgress.display = false; + this.seq = -1 + + }, - + //将Excel的数据转换成接口的数据 + excelDataToApiBodys(ExcelAllChoosedData) { + this.toApiBodys = [] + ExcelAllChoosedData.forEach(e => { + this.excelDataToApiBody(e) + }); + }, //将Excel的数据转换成接口的数据 excelDataToApiBody(ExcelData) { + console.log('ExcelData,this.excelCols', ExcelData, this.excelCols) let body = { - customerOrgId: this.customerOrgIds[this.customerOrgIds.length - 1], - customerOrgRegisterId: this.customerOrgRegister.id, - medicalCenterId: this.peisid, - completeFlag: this.dataImportOpts.completeFlag, - cardStartNum: this.dataImportOpts.cardStartNum, - cardLength: this.dataImportOpts.cardLength + barcodeMode: this.dataImportOpts.barcodeMode } + // 纵向数据 + if (this.readDataOpts.resultMode == 'V') { + + this.excelCols.forEach(e => { + if (e.val) { + switch (e.val) { + // case 'age': + // if (ExcelData[e.dispLabel]) body[e.val] = parseInt(ExcelData[e.dispLabel]) + // break; + // case 'birthDate': + // if(ExcelData[e.dispLabel]) body[e.val] = moment(new Date(ExcelData[e.dispLabel])).format('yyyy-MM-DD') + // break; + // case 'poisons': + // if (ExcelData[e.dispLabel]) body[e.val] = ExcelData[e.dispLabel].replaceAll(",", ",").split(",") + // break; + default: + body[e.val] = ExcelData[e.dispLabel] + break; + } + } + }) + + if (!body.checkDate) { + // console.log('body.checkDate,this.preBarcode,this.curCheckDate',body.checkDate,this.preBarcode,this.curCheckDate) + if (!this.preBarcode) { + this.preBarcode = body.barcode + this.curCheckDate = this.dataImportOpts.startCheckDate + } + + if (this.preBarcode != body.barcode) { + this.preBarcode = body.barcode + this.curCheckDate = moment(new Date(new Date(this.curCheckDate).getTime() + Number(this.dataImportOpts.checkInterval) * 1000)).format('yyyy-MM-DD HH:mm:ss') + } + body.checkDate = this.curCheckDate + } + if (body.deviceChannel == undefined) delete body.deviceChannel + if (body.sampleNo == undefined) delete body.sampleNo + + let lfind = arrayExistObj(this.toApiBodys,'barcode',body.barcode) + if(lfind == -1){ + this.toApiBodys.push(Object.assign({},body,{details:[{ itemName: body.itemName, itemResult: body.itemResult, checkDate: body.checkDate }]})) + }else{ + this.toApiBodys[this.toApiBodys.length - 1].details.push({ itemName: body.itemName, itemResult: body.itemResult, checkDate: body.checkDate }) + } + } else { + // 横向数据 + // { dataLabel: "", dispLabel: "P LCR", val: "" } + body = { + barcode: ExcelData['条码号'], + barcodeMode: this.dataImportOpts.barcodeMode, + patientName: ExcelData['姓名'], + sampleNo: ExcelData['标本号'], + deviceChannel: ExcelData['仪器通道'], + checkDate: ExcelData['检查时间'], + details: [] + } + + + if (!body.checkDate) { + // console.log('body.checkDate,this.preBarcode,this.curCheckDate',body.checkDate,this.preBarcode,this.curCheckDate) + if (!this.preBarcode) { + this.preBarcode = body.barcode + this.curCheckDate = this.dataImportOpts.startCheckDate + } - - return body + if (this.preBarcode != body.barcode) { + this.preBarcode = body.barcode + this.curCheckDate = moment(new Date(new Date(this.curCheckDate).getTime() + Number(this.dataImportOpts.checkInterval) * 1000)).format('yyyy-MM-DD HH:mm:ss') + } + body.checkDate = this.curCheckDate + } + + if (body.deviceChannel == undefined) delete body.deviceChannel + if (body.sampleNo == undefined) delete body.sampleNo + // [ + // { dispLabel: '条码号', val: 'barcode' }, + // { dispLabel: '姓名', val: 'patientName' }, + // { dispLabel: '标本号', val: 'sampleNo' }, + // { dispLabel: '仪器通道', val: 'deviceChannel' }, + // { dispLabel: '检查时间', val: 'checkDate' }, + // { dispLabel: '项目', val: 'itemName' }, + // { dispLabel: '结果', val: 'itemResult' } + // ] + this.excelCols.forEach(e => { + if (!e.dataLabel && !e.val) { + body.details.push({ itemName: e.dispLabel, itemResult: ExcelData[e.dispLabel], checkDate: body.checkDate }) + } + }) + this.toApiBodys.push(body) + } }, - + //选择要导入的数据 rowClickPrList(row) { // console.log("this.excelData",this.excelData);