Files
2026-08-17 13:59:12 +08:00

3 lines
17 KiB
JavaScript

"use strict";const e=require("../../common/vendor.js");Array||e.resolveComponent("uni-icons")();const re=()=>"../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";Math||re();const ue={__name:"edit_card",setup(N){const{proxy:y}=e.getCurrentInstance(),m=e.ref(!1),k=e.ref(!1),v=e.ref(!0),b=e.ref(!1),w=e.ref(null),p=e.ref(null),f=e.ref(!1),T=e.ref(""),t=e.ref({patient_name:"",id_card:"",gender:1,age:"",height:"",weight:"",systolic_pressure:"",diastolic_pressure:"",fasting_blood_sugar:"",diabetes_discovery_year:"",local_hospital_diagnosis:[],local_hospital_name:"",local_hospital_visit_date:"",diagnosis_date:"",diagnosis_type:"",syndrome_type:"",diabetes_type:"",appetite:"",water_intake:"",diet_condition:[],weight_change:"",body_feeling:[],sleep_condition:[],eye_condition:[],head_feeling:[],sweat_condition:[],skin_condition:[],urine_condition:[],stool_condition:[],kidney_condition:[],fatty_liver_degree:"",past_history:[],trauma_history:0,surgery_history:0,allergy_history:0,family_history:0,pregnancy_history:0,symptoms:"",tongue_coating:"",tongue_images:[],report_files:[],pulse:"",treatment_principle:"",prescription:"",doctor_advice:"",remark:""}),V=e.ref([]),q=e.ref([]),H=e.ref([]),C=e.ref([]),S=e.ref([]),O=e.ref([]),I=e.ref([]),P=e.ref([]),D=e.ref([]),F=e.ref([]),A=e.ref([]),M=e.ref([]),U=e.ref([]),R=e.ref([]),E=e.ref([]),L=e.ref([]),j=e.ref([]),z=e.ref([]),h=e.ref([0,0,0]),x=e.ref([]),B=e.ref(Array.from({length:12},(s,o)=>o+1)),Y=e.ref(Array.from({length:31},(s,o)=>o+1));e.onMounted(()=>{W(),X(),K()});const W=async()=>{try{const s=["diagnosis_type","syndrome_type","diabetes_type","past_history","appetite","water_intake","diet_condition","weight_change","body_feeling","sleep_condition","eye_condition","head_feeling","sweat_condition","skin_condition","urine_condition","stool_condition","kidney_condition","fatty_liver_degree"];(await Promise.all(s.map(a=>y.apiUrl({url:"/api/tcm/getDict",method:"GET",data:{type:a}})))).forEach((a,i)=>{const l=s[i];if(a.code===1&&a.data){const r=a.data[l]||[],n=Array.isArray(r)?r:Object.entries(r).map(([c,d])=>({value:c,name:d}));switch(l){case"diagnosis_type":V.value=n;break;case"syndrome_type":q.value=n;break;case"diabetes_type":H.value=n;break;case"past_history":C.value=n;break;case"appetite":S.value=n;break;case"water_intake":O.value=n;break;case"diet_condition":I.value=n;break;case"weight_change":P.value=n;break;case"body_feeling":D.value=n;break;case"sleep_condition":F.value=n;break;case"eye_condition":A.value=n;break;case"head_feeling":M.value=n;break;case"sweat_condition":U.value=n;break;case"skin_condition":R.value=n;break;case"urine_condition":E.value=n;break;case"stool_condition":L.value=n;break;case"kidney_condition":j.value=n;break;case"fatty_liver_degree":z.value=n;break}}})}catch(s){e.index.__f__("error","at pages/Card/edit_card.vue:979","加载字典数据失败:",s)}},K=()=>{const s=new Date().getFullYear();x.value=Array.from({length:100},(o,a)=>s-50+a)},Q=s=>{if(s)try{const o=s.split("-");if(o.length!==3)return;const a=parseInt(o[0]),i=parseInt(o[1]),l=parseInt(o[2]),r=x.value.indexOf(a);if(r===-1)return;const n=i-1,c=l-1;h.value=[r,n,c]}catch(o){e.index.__f__("error","at pages/Card/edit_card.vue:1014","初始化日期选择器失败:",o)}},X=async()=>{var s;m.value=!0;try{const o=getCurrentPages(),i=o[o.length-1].options||{};if(w.value=i.id,f.value=i.add==="1"||i.add===1,i.returnUrl)try{T.value=decodeURIComponent(String(i.returnUrl))}catch{T.value=String(i.returnUrl)}const l=e.index.getStorageSync("userData");if(p.value=(s=l==null?void 0:l.diagnosis)==null?void 0:s.patient_id,f.value){if(!e.index.getStorageSync("token")){e.index.showToast({title:"请先登录",icon:"none"}),setTimeout(()=>e.index.redirectTo({url:"/tongji/pages/weekly"}),1500);return}m.value=!1;return}if(!p.value){e.index.showToast({title:"请先登录",icon:"none"}),setTimeout(()=>e.index.redirectTo({url:"/tongji/pages/weekly"}),1500);return}if(!w.value){e.index.showToast({title:"诊单ID不存在",icon:"none"}),setTimeout(()=>e.index.navigateBack(),1500);return}const r=await y.apiUrl({url:"/api/tcm/diagnosisDetail",method:"GET",data:{id:w.value,user_id:p.value}});if(r.code===1){const n=r.data;["diet_condition","body_feeling","sleep_condition","eye_condition","head_feeling","sweat_condition","skin_condition","urine_condition","stool_condition","kidney_condition","past_history","local_hospital_diagnosis","report_files","tongue_images"].forEach(_=>{typeof n[_]=="string"&&n[_]?n[_]=n[_].split(","):n[_]||(n[_]=[])}),t.value=n;const d=n.diabetes_discovery_year;t.value.diabetes_discovery_year=d==null||d===""?"":String(d),!n.local_hospital_visit_date&&n.diagnosis_date&&(t.value.local_hospital_visit_date=n.diagnosis_date),t.value.local_hospital_visit_date&&Q(t.value.local_hospital_visit_date)}else e.index.showToast({title:r.msg||"获取失败",icon:"none"}),setTimeout(()=>e.index.navigateBack(),1500)}catch(o){e.index.__f__("error","at pages/Card/edit_card.vue:1109","加载诊单详情失败:",o),e.index.showToast({title:"加载失败",icon:"none"}),setTimeout(()=>e.index.navigateBack(),1500)}finally{m.value=!1}},u=(s,o)=>{const a=t.value[s].indexOf(o);a>-1?t.value[s].splice(a,1):t.value[s].push(o)},Z=s=>{if(!s||s.length!==18)return"";const o=parseInt(s.substring(6,10)),a=parseInt(s.substring(10,12)),i=parseInt(s.substring(12,14)),l=new Date,r=l.getFullYear(),n=l.getMonth()+1,c=l.getDate();let d=r-o;return(n<a||n===a&&c<i)&&d--,d},ee=()=>{if(t.value.id_card&&t.value.id_card.length===18){const s=Z(t.value.id_card);s&&(t.value.age=s)}},ae=s=>{h.value=s.detail.value},te=()=>{const s=x.value[h.value[0]],o=String(B.value[h.value[1]]).padStart(2,"0"),a=String(Y.value[h.value[2]]).padStart(2,"0");t.value.local_hospital_visit_date=`${s}-${o}-${a}`,b.value=!1},G=s=>{e.index.navigateTo({url:"/pages/Card/contact?type="+s})},ne=async()=>{var s;if(!v.value){e.index.showToast({title:"请先阅读并同意相关协议",icon:"none"});return}if(!t.value.patient_name){e.index.showToast({title:"患者姓名不能为空",icon:"none"});return}if(t.value.gender===null||t.value.gender===void 0){e.index.showToast({title:"请选择性别",icon:"none"});return}if(!t.value.weight){e.index.showToast({title:"体重不能为空",icon:"none"});return}if(!t.value.height){e.index.showToast({title:"身高不能为空",icon:"none"});return}if(!t.value.fasting_blood_sugar){e.index.showToast({title:"空腹血糖不能为空",icon:"none"});return}if(!String(t.value.diabetes_discovery_year??"").trim()){e.index.showToast({title:"发现糖尿病患病史不能为空",icon:"none"});return}if(String(t.value.diabetes_discovery_year).trim().length>50){e.index.showToast({title:"发现糖尿病患病史最多50个字",icon:"none"});return}if(!t.value.local_hospital_diagnosis||t.value.local_hospital_diagnosis.length===0){e.index.showToast({title:"当地医院诊断结果不能为空",icon:"none"});return}if(!t.value.local_hospital_name){e.index.showToast({title:"当地就诊医院名称不能为空",icon:"none"});return}if(!t.value.local_hospital_visit_date){e.index.showToast({title:"当地医院就诊时间不能为空",icon:"none"});return}k.value=!0;try{const o={...t.value};o.diabetes_discovery_year=String(o.diabetes_discovery_year??"").trim(),["diet_condition","body_feeling","sleep_condition","eye_condition","head_feeling","sweat_condition","skin_condition","urine_condition","stool_condition","kidney_condition","past_history","local_hospital_diagnosis","report_files","tongue_images"].forEach(n=>{Array.isArray(o[n])&&(o[n]=o[n].join(","))}),o.local_hospital_visit_date&&(o.diagnosis_date=o.local_hospital_visit_date);const i=f.value?"/api/tcm/addCard":"/api/tcm/updateCard",l=f.value?{...o,...p.value?{patient_id:p.value}:{}}:{id:w.value,patient_id:p.value,...o},r=await y.apiUrl({url:i,method:"POST",data:l});if(r.code===1){if(f.value&&((s=r.data)!=null&&s.patient_id)){const n=e.index.getStorageSync("userData")||{};n.diagnosis||(n.diagnosis={}),n.diagnosis.patient_id=r.data.patient_id,e.index.setStorageSync("userData",n)}e.index.showToast({title:f.value?"创建成功":"保存成功",icon:"success"}),setTimeout(()=>{const n=T.value;n&&n.startsWith("/")?e.index.redirectTo({url:n}):e.index.navigateBack()},1500)}else e.index.showToast({title:r.msg||"保存失败",icon:"none"})}catch(o){e.index.__f__("error","at pages/Card/edit_card.vue:1324","保存失败:",o),e.index.showToast({title:"保存失败",icon:"none"})}finally{k.value=!1}},oe=()=>{var o;const s=9-(((o=t.value.tongue_images)==null?void 0:o.length)||0);e.index.chooseImage({count:s,sizeType:["compressed"],sourceType:["album","camera"],success:async a=>{const i=a.tempFilePaths;try{e.index.showLoading({title:"上传中..."});const l=e.index.getStorageSync("token"),r=y.$url;t.value.tongue_images||(t.value.tongue_images=[]);for(let n=0;n<i.length;n++){const c=await new Promise((d,_)=>{e.index.uploadFile({url:r+"/api/upload/image",filePath:i[n],name:"file",header:{token:l,"content-type":"multipart/form-data"},success:g=>{const $=JSON.parse(g.data);d($)},fail:g=>{_(g)}})});c.code===1&&(t.value.tongue_images.push(c.data.uri||c.data),e.index.__f__("log","at pages/Card/edit_card.vue:1377","-",t))}e.index.hideLoading(),e.index.showToast({title:"上传成功",icon:"success"})}catch(l){e.index.hideLoading(),e.index.__f__("error","at pages/Card/edit_card.vue:1385","上传照片失败:",l),e.index.showToast({title:"上传失败",icon:"none"})}},fail:a=>{e.index.__f__("error","at pages/Card/edit_card.vue:1390","选择图片失败:",a),e.index.showToast({title:"选择图片失败",icon:"none"})}})},ie=s=>{e.index.showModal({title:"提示",content:"确定要删除这张舌苔照片吗?",success:o=>{o.confirm&&(t.value.tongue_images.splice(s,1),e.index.showToast({title:"已删除",icon:"success"}))}})},se=()=>{var o;const s=9-(((o=t.value.report_files)==null?void 0:o.length)||0);e.index.chooseImage({count:s,sizeType:["compressed"],sourceType:["album","camera"],success:async a=>{const i=a.tempFilePaths;try{e.index.showLoading({title:"上传中..."});const l=e.index.getStorageSync("token"),r=y.$url;t.value.report_files||(t.value.report_files=[]);for(let n=0;n<i.length;n++){const c=await new Promise((d,_)=>{e.index.uploadFile({url:r+"/api/upload/image",filePath:i[n],name:"file",header:{token:l,"content-type":"multipart/form-data"},success:g=>{const $=JSON.parse(g.data);d($)},fail:g=>{_(g)}})});c.code===1&&t.value.report_files.push(c.data.uri||c.data)}e.index.hideLoading(),e.index.showToast({title:"上传成功",icon:"success"})}catch(l){e.index.hideLoading(),e.index.__f__("error","at pages/Card/edit_card.vue:1471","上传检查报告失败:",l),e.index.showToast({title:"上传失败",icon:"none"})}},fail:a=>{e.index.__f__("error","at pages/Card/edit_card.vue:1476","选择图片失败:",a),e.index.showToast({title:"选择图片失败",icon:"none"})}})},le=s=>{e.index.showModal({title:"提示",content:"确定要删除这张图片吗?",success:o=>{o.confirm&&(t.value.report_files.splice(s,1),e.index.showToast({title:"已删除",icon:"success"}))}})},J=(s,o)=>{e.index.previewImage({urls:s,current:o})};return(s,o)=>e.e({a:m.value},m.value?{}:e.e({b:t.value.patient_name,c:e.o(a=>t.value.patient_name=a.detail.value,"d0"),d:e.t(t.value.gender===1?"✓":""),e:t.value.gender===1?1:"",f:e.o(a=>t.value.gender=1,"38"),g:e.t(t.value.gender===0?"✓":""),h:t.value.gender===0?1:"",i:e.o(a=>t.value.gender=0,"0f"),j:e.o(ee,"47"),k:t.value.id_card,l:e.o(a=>t.value.id_card=a.detail.value,"f0"),m:t.value.age,n:e.o(a=>t.value.age=a.detail.value,"ef"),o:t.value.weight,p:e.o(e.m(a=>t.value.weight=a.detail.value,{number:!0}),"f1"),q:t.value.height,r:e.o(e.m(a=>t.value.height=a.detail.value,{number:!0}),"7f"),s:t.value.systolic_pressure,t:e.o(e.m(a=>t.value.systolic_pressure=a.detail.value,{number:!0}),"52"),v:t.value.diastolic_pressure,w:e.o(e.m(a=>t.value.diastolic_pressure=a.detail.value,{number:!0}),"7e"),x:t.value.fasting_blood_sugar,y:e.o(e.m(a=>t.value.fasting_blood_sugar=a.detail.value,{number:!0}),"75"),z:t.value.diabetes_discovery_year,A:e.o(a=>t.value.diabetes_discovery_year=a.detail.value,"f7"),B:t.value.local_hospital_diagnosis.includes("糖尿病")?1:"",C:e.o(a=>u("local_hospital_diagnosis","糖尿病"),"e0"),D:t.value.local_hospital_diagnosis.includes("消渴病")?1:"",E:e.o(a=>u("local_hospital_diagnosis","消渴病"),"79"),F:t.value.local_hospital_diagnosis.includes("糖尿病前期")?1:"",G:e.o(a=>u("local_hospital_diagnosis","糖尿病前期"),"f6"),H:t.value.local_hospital_name,I:e.o(a=>t.value.local_hospital_name=a.detail.value,"20"),J:e.t(t.value.local_hospital_visit_date||"请选择确诊时间"),K:e.o(a=>b.value=!0,"1b"),L:e.f(S.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.appetite===a.value?1:"",d:e.o(r=>t.value.appetite=a.value,a.value)})),M:e.f(I.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.diet_condition.includes(a.value)?1:"",d:e.o(r=>u("diet_condition",a.value),a.value)})),N:e.f(O.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.water_intake===a.value?1:"",d:e.o(r=>t.value.water_intake=a.value,a.value)})),O:e.f(P.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.weight_change===a.value?1:"",d:e.o(r=>t.value.weight_change=a.value,a.value)})),P:e.f(z.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.fatty_liver_degree===a.value?1:"",d:e.o(r=>t.value.fatty_liver_degree=a.value,a.value)})),Q:e.f(D.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.body_feeling.includes(a.value)?1:"",d:e.o(r=>u("body_feeling",a.value),a.value)})),R:e.f(F.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.sleep_condition.includes(a.value)?1:"",d:e.o(r=>u("sleep_condition",a.value),a.value)})),S:e.f(A.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.eye_condition.includes(a.value)?1:"",d:e.o(r=>u("eye_condition",a.value),a.value)})),T:e.f(M.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.head_feeling.includes(a.value)?1:"",d:e.o(r=>u("head_feeling",a.value),a.value)})),U:e.f(U.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.sweat_condition.includes(a.value)?1:"",d:e.o(r=>u("sweat_condition",a.value),a.value)})),V:e.f(R.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.skin_condition.includes(a.value)?1:"",d:e.o(r=>u("skin_condition",a.value),a.value)})),W:e.f(E.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.urine_condition.includes(a.value)?1:"",d:e.o(r=>u("urine_condition",a.value),a.value)})),X:e.f(L.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.stool_condition.includes(a.value)?1:"",d:e.o(r=>u("stool_condition",a.value),a.value)})),Y:e.f(j.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.kidney_condition.includes(a.value)?1:"",d:e.o(r=>u("kidney_condition",a.value),a.value)})),Z:e.f(C.value,(a,i,l)=>({a:e.t(a.name),b:a.value,c:t.value.past_history.includes(a.value)?1:"",d:e.o(r=>u("past_history",a.value),a.value)})),aa:t.value.trauma_history===1?1:"",ab:e.o(a=>t.value.trauma_history=1,"5e"),ac:t.value.trauma_history===0?1:"",ad:e.o(a=>t.value.trauma_history=0,"db"),ae:t.value.surgery_history===1?1:"",af:e.o(a=>t.value.surgery_history=1,"f6"),ag:t.value.surgery_history===0?1:"",ah:e.o(a=>t.value.surgery_history=0,"69"),ai:t.value.allergy_history===1?1:"",aj:e.o(a=>t.value.allergy_history=1,"b7"),ak:t.value.allergy_history===0?1:"",al:e.o(a=>t.value.allergy_history=0,"f0"),am:t.value.family_history===1?1:"",an:e.o(a=>t.value.family_history=1,"e3"),ao:t.value.family_history===0?1:"",ap:e.o(a=>t.value.family_history=0,"18"),aq:t.value.pregnancy_history===1?1:"",ar:e.o(a=>t.value.pregnancy_history=1,"71"),as:t.value.pregnancy_history===0?1:"",at:e.o(a=>t.value.pregnancy_history=0,"a3"),av:t.value.tongue_images&&t.value.tongue_images.length>0},t.value.tongue_images&&t.value.tongue_images.length>0?{aw:e.f(t.value.tongue_images,(a,i,l)=>({a,b:e.o(r=>J(t.value.tongue_images,i),i),c:e.o(r=>ie(i),i),d:i}))}:{},{ax:t.value.tongue_images.length<9},t.value.tongue_images.length<9?{ay:e.p({type:"camera",size:"30"}),az:e.o(oe,"ec")}:{},{aA:t.value.report_files&&t.value.report_files.length>0},t.value.report_files&&t.value.report_files.length>0?{aB:e.f(t.value.report_files,(a,i,l)=>({a,b:e.o(r=>J(t.value.report_files,i),i),c:e.o(r=>le(i),i),d:i}))}:{},{aC:t.value.report_files.length<9},t.value.report_files.length<9?{aD:e.p({type:"camera",size:"30"}),aE:e.o(se,"6a")}:{},{aF:t.value.remark,aG:e.o(a=>t.value.remark=a.detail.value,"c8"),aH:v.value},v.value?{}:{},{aI:v.value?1:"",aJ:!v.value},v.value?{}:{},{aK:v.value?"":1,aL:e.o(a=>v.value=!1,"2e"),aM:e.o(a=>G("service"),"98"),aN:e.o(a=>G("privacy"),"cc"),aO:e.o(a=>v.value=!0,"db"),aP:e.t(k.value?"保存中...":"我已确认无误,提交给医生"),aQ:e.o(ne,"17"),aR:k.value||!v.value}),{aS:b.value},b.value?{aT:e.o(a=>b.value=!1,"4e"),aU:e.o(te,"61"),aV:e.f(x.value,(a,i,l)=>({a:e.t(a),b:a})),aW:e.f(B.value,(a,i,l)=>({a:e.t(String(a).padStart(2,"0")),b:a})),aX:e.f(Y.value,(a,i,l)=>({a:e.t(String(a).padStart(2,"0")),b:a})),aY:h.value,aZ:e.o(ae,"78")}:{})}},ce=e._export_sfc(ue,[["__scopeId","data-v-47b8e7b0"]]);wx.createPage(ce);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/Card/edit_card.js.map