From f02019d58a6229fffdc72757cfe7a52ea3bd1d66 Mon Sep 17 00:00:00 2001 From: pengjun <158915633@qq.com> Date: Tue, 26 Sep 2023 15:07:14 +0800 Subject: [PATCH] idcard seo --- public/pic/Photo.jpg | Bin 0 -> 14852 bytes .../patientRegister/PatientRegisterEdit.vue | 103 +++++++++-- .../patientRegister/PatientRegisterList.vue | 1 + src/components/sumDoctorCheck/ButtonList.vue | 4 +- src/store/index.js | 19 +- src/utlis/mm.js | 7 +- src/utlis/proFunc.js | 171 ++++++++++++++---- 7 files changed, 247 insertions(+), 58 deletions(-) create mode 100644 public/pic/Photo.jpg diff --git a/public/pic/Photo.jpg b/public/pic/Photo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1c8b051a6ca431dc014de73c67b14dfe0c18c854 GIT binary patch literal 14852 zcmeHtcUV(N_wd|QLhr?bp(9e#3yKgr0)jLJbulCXA|;rFqH7m%?TCnq6-5+#0qhNX zR}@gNfQn*WL9r{pxi{2(-FNr#d%i!u@8{&X=bkxb=FFLMGqwG8djrrN<{RJ(5F7&h z;SaPol3IMSr11a*2LlHHfEpkp`T!3x1pWZh2M{qFfHR+b=V5i&p7KmkW5^89oOes?&%F?J_;Y{jCX{uP3sQ?Tb zgXv1+yE52RI@^`Sa%FH}5dgm)>9%b>uB-eN>+xOqdQ=c55`yoLCG~6vV&2^j#I|QU zpiesNMVxV6WfKppibK7HdPMbZ@99gFhWhdq(8Ssl>lF-;_SZlg%K`CpRI|MvWCKk# zH8qNwCWWG@r=hN)XQZR4sbgenU|?imV5+ByrH+>>^H+#yX=rF^Yw2oh>l$inYa60K z+fb#V_iqYlKLPaAzO5QrqQ8bw_L zhC^>A0&w_FrY=AT2p&hk5y>PqB3_dTnR;d!;5T_7yhQPMWkRGZ`eD_)_ZA$*r#%%l4DX8`B2ijFZ+!oy!5nAUNP@|k&F;YK0_tHp+d8bG#XS5`qIHkyciA~{OQ!!8s4 z-U7RB6WZ&5CLXI(54eLi{Dq*^t>Kolt@8o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mj1lG4^RWH8zYUcY*#YV@MM)j4k z?yM?L3Ze1y>cFbedmam3w1h5cys2Yiv#IZ5+hFH4P4!uA0`tx5{oR~G{XF9cYy0st zHp~dGe_(D?d@ic>V0GKQK@kU!I*CfY29_AzKCeSPx$W+Zm_@hehQ>$^8t$25<*_Qb zrtMYaYkmK=4BtgI1jdA2VNSM!8r2n*|^S`Bk%Tk}y{=fR4`TxU__RjwR DcrY{O literal 0 HcmV?d00001 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; + + + + + +