diff --git a/src/views/customerOrg/patientRegisterImport.vue b/src/views/customerOrg/patientRegisterImport.vue index abc4c68..2901643 100644 --- a/src/views/customerOrg/patientRegisterImport.vue +++ b/src/views/customerOrg/patientRegisterImport.vue @@ -20,7 +20,8 @@ 导入
- 导入后结果状态导出 + 导入后结果状态导出
@@ -35,7 +36,8 @@ :label="item.dataLabel || item.dispLabel" min-width="100" /> + :height="window.pageHeight < 600 ? 440 : (window.pageHeight - 210)" highlight-current-row size="small" + :summary-method="getSummaries" show-summary> @@ -105,7 +107,7 @@ :append-to-body="true" :close-on-click-modal="false">
-
+
标题行: 第 - +
@@ -203,7 +204,8 @@ 正式登记
-
+ +
工卡号:
@@ -300,6 +302,7 @@ 性别: +
@@ -545,6 +548,7 @@ export default { excelCols: [{ dispLabel: '', val: '', dataLabel: '' }], //excel数据列名 {dispLabel:'',val:'',dataLabel:''} importCols: [], //实际导入的列(即有设置与 dataCols 匹配的列) excelData: [], //excel表格数据 + choosedData: [], // 选中的待导入的数据 dataCols: [ { dispLabel: '不设置', val: '' }, @@ -696,6 +700,9 @@ export default { //清空进度数据数据 clearProcess() { + let elo = document.getElementById('fileNames') + if(elo) elo.value = ''; // 清空选择的文件 + this.workBook = null //EXCEL 工作薄 this.sheetNames = [] //EXCEL 工作薄中的表单 {sheetName:} @@ -963,7 +970,7 @@ export default { columns.forEach((column, index) => { //显示合计列 if (index === 1) { - sums[index] = "合计"; + sums[index] = "导入合计"; return; } @@ -974,15 +981,16 @@ export default { } data.forEach((item) => { - if (item[column.property] == '导入成功') { - success++ + console.log('item,column.property',item,column.property) + if (item[column.property]) { + fail++ } else { - fail++ + success++ } }); }); - sums[2] = `导入 成功:${success} 条,失败:${fail} 条。` + sums[2] = `成功:${success} 条,失败:${fail} 条。` return sums; }, @@ -1221,7 +1229,7 @@ export default { } }, - // 导入后,批量分析Excel列 与 数据字段 的匹配关系 + // 选择EXCEL文件后,批量分析Excel列 与 数据字段 的匹配关系 parseExcelData() { let lfind = -1 this.excelCols.forEach((e, i) => { @@ -1251,61 +1259,155 @@ export default { this.importCols.push(e) } }) - this.tableData = [] + this.tableData = [] // 记录导入后结果状态 + this.choosedData = [] //选中待导入的数据 + this.excelData.forEach(e => { + if (e.choosed) this.choosedData.push(e) + }); //导入进行中 this.importing(this.dataImportOpts.startRow, this.dataImportOpts.nameType) + // 开始导入时,清除选择的 文件 + document.getElementById('fileNames').value = ''; }, //导入进行时 // startRow : 从第几行开始导入,同名判断交互时,续接导入 - // startRowNameType : 续接导入的第1行,执行 同名判断模式, 3.不提示,按新人导入 + // startRowNameType : 续接导入的第1行,执行 同名判断模式, 3.不提示,按新人导入(前端不用管) async importing(startRow, startRowNameType) { let body = {} - for (let i = startRow; i < this.excelData.length; i++) { + for (let i = startRow; i < this.choosedData.length; i++) { this.elProgress.percentage = Math.floor( - ((i + 1) * 100) / this.excelData.length + ((i + 1) * 100) / this.choosedData.length ); - if (this.excelData[i].choosed) { - body = this.excelDataToApiBody(this.excelData[i]) - if (i == startRow) body.nameType = startRowNameType - if (this.choosedSameMan.patientId) { - body.patientId = this.choosedSameMan.patientId - this.choosedSameMan = {} // 清除选择 - } - console.log('this.excelData[i]', i, body) - try { - let res = await postapi('/api/app/patientregister/createpatientregisterexcel', body) - if (res.code != -1) { - if (res.data.code == 1) { - this.tableData.push(Object.assign({ importState: '导入成功' }, this.excelData[i])) - } else if (res.data.code == -2) { - this.sameMans = res.data.details - this.dialogSameMan = true - this.dataImportOpts.startRow = i - break; - } else { - this.tableData.push(Object.assign({ importState: '导入失败', importDes: res.data.msg }, this.excelData[i])) + // 将Excel的数据转换成接口的数据 + body = this.excelDataToApiBody(this.choosedData[i]) + if (i == startRow) body.nameType = startRowNameType + console.log(`this.choosedData[${i}],startRowNameType,body`) + + try { + // 同一人判断 + if (this.choosedSameMan.patientNo) { + // 上一次循环已经判断是否同一人,此次循环不需再判断了 + if (this.choosedSameMan.patientNo == '$newPatient$') { + body.nameType = '3' + } else { + body.patientNo = this.choosedSameMan.patientNo + } + } else if (startRowNameType != '3') { + let result = await this.isSamePatient(startRowNameType, body) + if (result.isContinue) { + if (result.err) { + this.tableData.push(Object.assign({ importState: '导入失败', importDes: result.err }, this.choosedData[i])) + continue } } else { - this.tableData.push(Object.assign({ importState: '导入失败', importDes: res.message }, this.excelData[i])) + this.dataImportOpts.startRow = i + break; // 跳出循环,重新从 i 开执行 this.importing } - } catch (error) { - break; } + + // 旧接口:/api/app/patientregister/createpatientregisterexcel + let res = await postapi('/api/app/patientregister/CreatePatientRegisterFromExcel', body) + this.choosedSameMan = {} // 清除选择同一人员的记录 + if (res.code >= 0) { + this.tableData.push(Object.assign({ importState: '导入成功' }, this.choosedData[i])) + } else { + this.tableData.push(Object.assign({ importState: '导入失败', importDes: res.message }, this.choosedData[i])) + } + } catch (error) { + this.tableData.push(Object.assign({ importState: '导入失败', importDes: `${error}` }, this.choosedData[i])) } + // 结束导入 - if (i == this.excelData.length - 1) { + if (i == this.choosedData.length - 1) { this.elProgress.display = false; this.seq = -1 } } }, + // 同一人判断 + async isSamePatient(startRowNameType, body) { + console.log('isSamePatient', startRowNameType, body) + let result = { + isContinue: true, + err: '' + } + let res + if (body.idNo) { + try { + res = await postapi('/api/app/patient/GetByIdNo', { idNo: body.idNo }) + if (res.code < 0) { + result.err = `身份证号查重错误,原因:${res.message}` + return result + } else if (res.code == 1) { + body.patientNo = res.data.patientNo + return result + } + } catch (error) { + result.err = `身份证号查重错误,原因:${error}` + return result + } + } + + // 没有身份证号或身份证号未找到同名人员时,按姓名查重 + let url, localBody = { + customerOrgId: body.customerOrgId, + name: body.patientName + } + switch (startRowNameType) { + case '1': + case '2': + if (startRowNameType == '1') url = '/api/app/patientregister/GetSameNamePatient' + if (startRowNameType == '2') url = '/api/app/patientregister/GetCustomerOrgSameNamePatient' + res = await postapi(url, localBody) + if (res.code >= 0) { + if (res.data.length > 0) { + result.isContinue = false + this.sameMans = res.data + this.dialogSameMan = true + } + } else { + result.err = `${startRowNameType == '2' ? '同单位内' : ''}同名查重错误,原因:${res.message}` + } + break; + default: + break; + } + return result + + // if (this.choosedSameMan.patientNo) { + // body.patientNo = this.choosedSameMan.patientNo + // // body.patientId = this.choosedSameMan.patientId + // this.choosedSameMan = {} // 清除选择人员 + // } + // try { + // switch (key) { + // case value: + + // break; + + // default: + // break; + // } + + // { dispLabel: '姓名', val: 'patientName' }, + // { dispLabel: '性别', val: 'sexName' }, + // { dispLabel: '年龄', val: 'age' }, + // { dispLabel: '出生日期', val: 'birthDate' }, + // { dispLabel: '婚姻状况', val: 'maritalStatusName' }, + // { dispLabel: '民族', val: 'nationName' }, + // { dispLabel: '身份证号', val: 'idNo' }, + }, + + + + //将Excel的数据转换成接口的数据 excelDataToApiBody(ExcelData) { let body = { @@ -1340,22 +1442,22 @@ export default { //选中同名人员档案 rowClickSameMan(row) { - this.choosedSameMan = Object.assign({}, row) + this.choosedSameMan = deepCopy(row) }, // 同名人员,按档案人员导入 btnOldMan() { - if (!this.choosedSameMan.patientId) { + if (!this.choosedSameMan.patientNo) { this.$message.warning("请选择要导入的档案人员") return } - this.importing(this.dataImportOpts.startRow) + this.importing(this.dataImportOpts.startRow, this.dataImportOpts.nameType) this.dialogSameMan = false }, // 同名人员,按新人方式导入 btnNewMan() { - this.choosedSameMan = {} - this.importing(this.dataImportOpts.startRow, '3') + this.choosedSameMan = { patientNo: '$newPatient$' } // 约定按新人导入 + this.importing(this.dataImportOpts.startRow, this.dataImportOpts.nameType) this.dialogSameMan = false }, @@ -1520,7 +1622,8 @@ export default { payTypeFlag: this.payTypeFlag, medicalCenterId: this.peisid, } - // { + + //{ // "patientRegisterId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", // "customerOrgId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", // "customerOrgRegisterId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", @@ -1529,6 +1632,7 @@ export default { // "payTypeFlag": "string", // "medicalCenterId": "3fa85f64-5717-4562-b3fc-2c963f66afa6" // } + this.elProgress.display = true this.elProgress.percentage = 0 for (let i = 0; i < this.prList.length; i++) { @@ -1539,20 +1643,16 @@ export default { body.customerOrgId = this.newCustomerOrgFlag ? customerOrgId : this.prList[i].customerOrgId try { - let res = await postapi('/api/app/patientregister/createpatientregisterhistory', body) - if (res.code != -1) { - if (res.data.code != -1) { - this.tableData.push(Object.assign({ importState: '导入成功' }, this.prList[i])) - } else { - this.tableData.push(Object.assign({ importState: '导入失败', importDes: res.data.msg }, this.prList[i])) - } + // 旧接口:/api/app/patientregister/createpatientregisterhistory + let res = await postapi('/api/app/patientregister/CreatePatientRegisterFromHistory', body) + if (res.code >= 0) { + this.tableData.push(Object.assign({ importState: '导入成功' }, this.prList[i])) } else { this.tableData.push(Object.assign({ importState: '导入失败', importDes: res.message }, this.prList[i])) } } catch (error) { this.tableData.push(Object.assign({ importState: '导入失败', importDes: res.message }, this.prList[i])) } - } this.elProgress.display = false diff --git a/src/views/customerOrg/patientRegisterImport240409.vue b/src/views/customerOrg/patientRegisterImport240409.vue new file mode 100644 index 0000000..abc4c68 --- /dev/null +++ b/src/views/customerOrg/patientRegisterImport240409.vue @@ -0,0 +1,1658 @@ + + +