diff --git a/public/pic/Photo.jpg b/public/pic/Photo.jpg new file mode 100644 index 0000000..1c8b051 Binary files /dev/null and b/public/pic/Photo.jpg differ diff --git a/src/components/patientRegister/PatientRegisterEdit.vue b/src/components/patientRegister/PatientRegisterEdit.vue index cbf70ff..64f4bd0 100644 --- a/src/components/patientRegister/PatientRegisterEdit.vue +++ b/src/components/patientRegister/PatientRegisterEdit.vue @@ -315,7 +315,7 @@ + :src="photoParse(patientRegister.photo)">
加载中...
@@ -327,10 +327,10 @@
- 拍照 + 拍照
- 读身份证 + 读身份证
复制新增 @@ -445,11 +445,12 @@ 确定 - + @@ -471,7 +472,7 @@ import { mapState } from "vuex"; import { getapi, postapi, putapi, deletapi } from "@/api/api"; import mm from "../../utlis/mm"; -import { objCopy, setNull, dddw, parseID, birthdayToAge, deepCopy, arrayFilter } from "../../utlis/proFunc"; +import { objCopy, setNull, dddw, parseID, birthdayToAge, deepCopy, arrayFilter, parsIcCardtoLocal, photoParse, savePeoplePhoto } from "../../utlis/proFunc"; import Camera from "./Camera.vue"; import PatientRegisterItem from "./PatientRegisterItem.vue"; import LisRequest from "./LisRequest.vue"; @@ -509,7 +510,6 @@ export default { personnelTypeId: null, //人员类别 jobPost: "", //职务 jobTitle: "", //职称 - photo: "", //照片 salesman: "", //介绍人 sexHormoneTermId: null, //性激素期限 isNameHide: "N", //隐藏姓名 @@ -587,18 +587,35 @@ export default { }, computed: { - ...mapState(["window", "dict", "patientRegister", "customerOrg"]), + ...mapState(["window", "dict", "patientRegister", "customerOrg", "projPriv"]), }, methods: { - readIdCard() { - console.log("this.form1", this.form); + photoParse, + + peopleIcCard() { + this.$peisAPI.peopleIcCard().then(res => { + //console.log('peopleIcCard',res) + let lres = JSON.parse(res) + if (lres.Code && lres.Code.toLowerCase() == 'success') { + this.projPriv.idNos = lres + let idNos = parsIcCardtoLocal(this.projPriv.idNos, this.dict.sex, this.dict.nation) + this.form.patientName = idNos.Name + this.form.birthDate = idNos.birthDate + this.form.sexId = idNos.sexId + this.form.age = idNos.age + this.form.nationId = idNos.nationId + this.form.idNo = idNos.IDCode + this.form.address = idNos.Address + this.patientRegister.photo = 'data:image/bmp;base64,' + idNos.Photo + } + }) }, //获取单位体检次数列表,并默认赋最后一次体检次数 async getCustomerOrgRegisterList() { this.customerOrgRegisterList = [] - if (this.form.customerOrgId == this.dict.personOrgId){ - this.form.customerOrgRegisterId = null + if (this.form.customerOrgId == this.dict.personOrgId) { + this.form.customerOrgRegisterId = null return } try { @@ -627,14 +644,14 @@ export default { }, //获取体检次数下的分组 - getCustomerOrgGroup(customerOrgRegisterId){ + getCustomerOrgGroup(customerOrgRegisterId) { this.patientRegister.customerOrgGroup = [] getapi(`/api/app/customerorggroup/getlistinfilter?CustomerOrgRegisterId=${customerOrgRegisterId}`).then(res => { if (res.code != - 1) { this.patientRegister.customerOrgGroup = res.data.items; } }) - }, + }, //修改出生日期 changeBirthDate() { @@ -652,7 +669,7 @@ export default { }, //分组改变时触发 - changeCustomerOrgGroupId() { + changeCustomerOrgGroupId() { this.patientRegister.customerOrgGroupChange++; if (this.form.id) this.Onsubmit('form', false); }, @@ -774,6 +791,11 @@ export default { //赋值 let body = deepCopy(this.form); + if(this.form.birthDate){ + body.birthDate = moment(this.form.birthDate).format("yyyy-MM-DD") + } + + delete body.id; delete body.patientRegisterNo; delete body.medicalTimes; @@ -788,6 +810,7 @@ export default { delete body.isNameHideBox; delete body.isPhoneFollowBox; delete body.isLockBox; + delete body.photo; setNull(body, this.defaultNull); @@ -807,6 +830,9 @@ export default { if (res.code == 1) { //console.log('res',res) if (msgTip) this.$message.success("创健 操作成功"); + //一般读身份证照片时,会出现这种情况 + if (this.patientRegister.photo.indexOf("data:image") > -1) savePeoplePhoto(res.data.id, this.patientRegister.photo); + objCopy(res.data, this.form); // this.patientRegister.prList.push(res.data); //列表添加记录 this.patientRegister.patientRegisterId = res.data.id; @@ -827,6 +853,8 @@ export default { postapi(`/api/patientregister/updatepatientregister?PatientRegisterId=${this.form.id}`, body).then((res) => { if (res.code == 1) { if (msgTip) this.$message.success("更新 操作成功"); + //一般读身份证照片时,会出现这种情况 + if (this.patientRegister.photo.indexOf("data:image") > -1) savePeoplePhoto(res.data.id, this.patientRegister.photo); this.patientRegister.query.times++; //this.patientRegister.saveTimes++; //更新保存时,无需触发组合项目保存 } @@ -875,7 +903,7 @@ export default { }); }, - //拍照 + //拍照(已废弃) openCamera() { if (!this.form.id) { alert("请先保存人员信息"); @@ -884,6 +912,49 @@ export default { this.patientRegister.cameraVisble = true; }, + //拍照(调壳程序) + photoGrah() { + if (!this.form.id) { + alert("请先保存人员信息"); + return; + } + this.$peisAPI.photoGrah() + .then(res => { + console.log(res) + //alert(res) + let lres = JSON.parse(res) + if (lres.Code && lres.Code.toLowerCase() == 'success') { + let uploadPhoto = { + patientRegisterId: this.form.id, + photo: lres.Photo, + }; + this.patientRegister.photo = `data:image/${lres.PhotoFormat};base64,${lres.Photo}` + return postapi(`/api/app/patient-register/up-load-img`, uploadPhoto) + } else { + this.$message.error("上传照片错误" + lres.Code) + } + }).then(res => { + if (res.code == 1) { + let body = { + patientRegisterId: this.form.id, + photo: res.data, + }; + console.log(body); + return postapi(`/api/app/patient-register/update-photo`, body); + } + }).then(res => { + if (res.code != -1) { + //console.log('拍照',res.data) + this.patientRegister.patientRegisterRd.photo = res.data.photo + this.$message.success("操作成功"); + } + }).catch(err => { + console.log('this.$peisAPI.photoGrah', err) + }) + }, + + + // 打印指引单(isPreview) async guidePrint(ReportCode, isPreview) { if (this.form.id.length < 1) { diff --git a/src/components/patientRegister/PatientRegisterList.vue b/src/components/patientRegister/PatientRegisterList.vue index 834434a..55c2fda 100644 --- a/src/components/patientRegister/PatientRegisterList.vue +++ b/src/components/patientRegister/PatientRegisterList.vue @@ -460,6 +460,7 @@ export default { this.patientRegister.photo = ""; //清除照片缓存 this.patientRegister.patientRegisterId = row.id; + this.patientRegister.photo = row.photo; this.patientRegister.patientRegisterRd = row; this.patientRegister.query.customerOrgParentId = row.customerOrgParentId; this.patientRegister.customerOrgGroupChange = 0; //控制体检列表记录切换时,0 无需触发更换分组操作 diff --git a/src/components/sumDoctorCheck/ButtonList.vue b/src/components/sumDoctorCheck/ButtonList.vue index 65ace05..dffc601 100644 --- a/src/components/sumDoctorCheck/ButtonList.vue +++ b/src/components/sumDoctorCheck/ButtonList.vue @@ -46,9 +46,9 @@ - - +
diff --git a/src/store/index.js b/src/store/index.js index 603e412..3f0d455 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -54,7 +54,7 @@ export default new Vuex.Store({ patientRegisterTimes: 0, //体检人员登记窗口显示次数(弃用) addTimes: 0, //用于触发新增时初始化赋值 saveTimes: 0, //用于体检登记时,触发分组调整保存 - photo: "", //单独抽出,拍照时会更新 + photo: "/pic/Photo.jpg", //单独抽出,拍照时会更新 cameraVisble: false, //拍照控件显示 lisRequestVisble: false, //检验条码补打 mergeAsbitemVisble: false, //合并项目 @@ -227,6 +227,23 @@ export default new Vuex.Store({ asbItem: [], //显示的 未选组合项目 asbItemQuick: [], //显示的 未选组合项目(供快速选择) }, + + //项目特有的对象数据 + projPriv:{ + idNos:{ + Code: "Success", //读取成功/失败 + Name: "刘滔", + Sex: "男", + Nation: "汉", + Birthday: "1986-01-22", + Address: "湖南省长沙县春华镇九木村新元组367号", + DepartmentIC: "长沙县公安局", + StartDateIC: "2019-11-25", + EndDateIC: "2039-11-25", + IDCode: "430121198601223693", + Photo: "base64编码字符串" + }, //读取身份证信息 + }, }, getters: {}, diff --git a/src/utlis/mm.js b/src/utlis/mm.js index f313f78..441be16 100644 --- a/src/utlis/mm.js +++ b/src/utlis/mm.js @@ -1,3 +1,8 @@ -export default{ +// export default{ +// apiurl:'http://140.143.162.39:9529', +// } + +// modify by pengjun +module.exports = { apiurl:'http://140.143.162.39:9529', } \ No newline at end of file diff --git a/src/utlis/proFunc.js b/src/utlis/proFunc.js index 28c8299..4486207 100644 --- a/src/utlis/proFunc.js +++ b/src/utlis/proFunc.js @@ -1,16 +1,22 @@ +// import sysConfig from "./mm"; +// import { getapi, postapi, putapi, deletapi } from "@/api/api"; +const sysConfig = require('./mm'); +const {getapi, postapi, putapi, deletapi} = require('../api/api'); + //多级联动选择数据处理 add by pengjun -exports.tcdate = (date) => { +function tcdate(date) { for (var i = 0; i < date.length; i++) { if (date[i].treeChildren.length == 0) { date[i].treeChildren = undefined; } else { - this.tcdate(date[i].treeChildren); + tcdate(date[i].treeChildren); } } }; +exports.tcdate = tcdate; //json 对像赋值 只从 from 对象 赋值 to 中有的 key 项 add by pengjun -exports.objCopy = (from, to) => { +function objCopy(from, to) { if (from && to) { let keys = Object.keys(to); for (let key in keys) { @@ -20,30 +26,32 @@ exports.objCopy = (from, to) => { } } }; +exports.objCopy = objCopy; //对象深拷贝 function deepCopy(obj) { if (obj == null || typeof obj != 'object') { - return obj; + return obj; } let copy; if (Array.isArray(obj)) { - copy = []; - for (let i = 0; i < obj.length; i++) { - copy[i] = deepCopy(obj[i]); - } + copy = []; + for (let i = 0; i < obj.length; i++) { + copy[i] = deepCopy(obj[i]); + } } else { - copy = {}; - for (let key in obj) { - copy[key] = deepCopy(obj[key]); - } + copy = {}; + for (let key in obj) { + copy[key] = deepCopy(obj[key]); + } } return copy; }; exports.deepCopy = deepCopy; + //类似PB中的dddw的功能 add by pengjun -exports.dddw = (arrayData, key, value, display) => { +function dddw(arrayData, key, value, display) { //console.log(arrayData,key,value,display) let ret = value; if (arrayData) { @@ -56,9 +64,10 @@ exports.dddw = (arrayData, key, value, display) => { } return ret; }; +exports.dddw = dddw; //一般uuid字段为空时,需设置为null值 -exports.setNull = (obj, arrayKeys) => { +function setNull(obj, arrayKeys) { if (arrayKeys) { for (let i = 0; i < arrayKeys.length; i++) { if (!obj[arrayKeys[i]] || obj[arrayKeys[i]].length < 1) { @@ -67,9 +76,10 @@ exports.setNull = (obj, arrayKeys) => { } } }; +exports.setNull = setNull; //将字符串转换成二进制形式,中间用空格隔开 -exports.strToBinary = function (str) { +function strToBinary(str) { let result = []; let list = str.split(""); for (var i = 0; i < list.length; i++) { @@ -82,9 +92,10 @@ exports.strToBinary = function (str) { } return result.join(""); }; +exports.strToBinary = strToBinary; //将二进制字符串转换成Unicode字符串 -exports.binaryToStr = function (str) { +function binaryToStr(str) { var result = []; var list = str.split(" "); for (var i = 0; i < list.length; i++) { @@ -95,9 +106,10 @@ exports.binaryToStr = function (str) { } return result.join(""); }; +exports.binaryToStr = binaryToStr; //数组过滤出符合条件的 -exports.arrayFilter = function (arr, key, value) { +function arrayFilter(arr, key, value) { let result = []; for (let i = 0; i < arr.length; i++) { if (arr[i][key] == value) { @@ -106,9 +118,10 @@ exports.arrayFilter = function (arr, key, value) { } return result; }; +exports.arrayFilter = arrayFilter; //数组相减 arrFront = arrFront - reduceArr ; -exports.arrayReduce = function (arrFront, reduceArr, key) { +function arrayReduce(arrFront, reduceArr, key) { let keys = key.split("="); let keyF = keys[0]; let keyR = keys.length > 1 ? keys[1] : keys[0]; @@ -128,51 +141,133 @@ exports.arrayReduce = function (arrFront, reduceArr, key) { } return arrFront; }; +exports.arrayReduce = arrayReduce; //判断数组中 是否存在 某个值的对象记录 如不存在返回 - 1,存在返回相应的 序列 -exports.arrayExistObj = function (arr, key, value) { +function arrayExistObj(arr, key, value) { let ret = - 1 - for(let i = 0;i 12 || id.substring(10,12).parseInt == 0) return ret - if(id.substring(12,14).parseInt > 31 || id.substring(12,14).parseInt == 0) return ret + if (!id || id.length != 18) return ret + if (id.substring(10, 12).parseInt > 12 || id.substring(10, 12).parseInt == 0) return ret + if (id.substring(12, 14).parseInt > 31 || id.substring(12, 14).parseInt == 0) return ret //出生日期 - ret.birthday = id.substring(6,10) + '-' + id.substring(10,12) + '-' + id.substring(12,14) + ret.birthday = id.substring(6, 10) + '-' + id.substring(10, 12) + '-' + id.substring(12, 14) //年龄 - ret.age = Math.floor((new Date().getTime() - new Date(ret.birthday).getTime())/yearInMs) + ret.age = Math.floor((new Date().getTime() - new Date(ret.birthday).getTime()) / yearInMs) //奇数 男, 偶数 女 - if(id.substring(16,17)%2 == 0){ + if (id.substring(16, 17) % 2 == 0) { ret.sex = 'F' - }else{ + } else { ret.sex = 'M' } - + return ret -} +}; +exports.parseID = parseID; //根据出生日期,计算当前年龄 粗犷式,不精确判断闰年平年 -exports.birthdayToAge = function (birthday) { +function birthdayToAge(birthday) { let yearInMs = 1000 * 60 * 60 * 24 * 365.2425; //年龄 - return Math.floor((new Date().getTime() - new Date(birthday).getTime())/yearInMs) -} + return Math.floor((new Date().getTime() - new Date(birthday).getTime()) / yearInMs) +}; +exports.birthdayToAge = birthdayToAge; + +//分析身份证数据 +function parsIcCardtoLocal(idNos, dictSex, dictNation) { + let local = deepCopy(idNos); + // { + // "Code": "Success", + // "Name": "刘滔", + // "Sex": "男", + // "Nation": "汉", + // "Birthday": "1986-01-22", + // "Address": "湖南省长沙县春华镇九木村新元组367号", + // "DepartmentIC": "长沙县公安局", + // "StartDateIC": "2019-11-25", + // "EndDateIC": "2039-11-25", + // "IDCode": "430121198601223693", + // "Photo": "" + // } + console.log(local, dictSex, dictNation) + let lfind = -1; + lfind = arrayExistObj(dictSex, 'displayName', local.Sex) + console.log(lfind,local.Sex) + if (lfind > -1) local.sexId = dictSex[lfind].id; + + lfind = arrayExistObj(dictNation, 'displayName', local.Nation + '族') + console.log(lfind,local.Nation) + if (lfind > -1) local.nationId = dictNation[lfind].nationId; + + local.birthDate = new Date(local.Birthday) + local.age = birthdayToAge(local.Birthday) + return local +}; +exports.parsIcCardtoLocal = parsIcCardtoLocal; + +function photoParse(photo) { + //console.log(sysConfig,photo) + let lphoto = '' //data:image、UpLoad/、/pic/Photo.jpg + if (photo.indexOf("UpLoad/") > - 1) { + lphoto = sysConfig.apiurl + '/' + photo + '?' + new Date().getTime() + } else { + lphoto = photo + } + //console.log(lphoto) + return lphoto +}; +exports.photoParse = photoParse; + +async function savePeoplePhoto(peopleId, photoBase64) { + let lres = { code: -1, msg: '' } + if (!peopleId) return { code: -1, msg: '人员ID不能为空' } + if (!photoBase64 || photoBase64.indexOf('data:image') < 0) return { code: -1, msg: '图像数据不是合法的base64编码数据' } + + + let uploadPhoto = { + patientRegisterId: peopleId, + photo: photoBase64.split(",")[1], + }; + + try { + lres = await postapi(`/api/app/patient-register/up-load-img`, uploadPhoto) + let body = { + patientRegisterId: peopleId, + photo: lres.data, + } + await postapi(`/api/app/patient-register/update-photo`, body) + + } catch (error) { + lres = { code: -1, msg: error } + } + + return lres +}; +exports.savePeoplePhoto = savePeoplePhoto; + + + + + +