"use strict";const e=require("../../common/vendor.js"),t=require("../../stores/user.js"),o=require("../../stores/useHomeButton.js");if(!Array){(e.resolveComponent("up-icon")+e.resolveComponent("u-radio")+e.resolveComponent("u-radio-group")+e.resolveComponent("u--textarea")+e.resolveComponent("uni-icons")+e.resolveComponent("u-modal"))()}Math||((()=>"../../uni_modules/uview-plus/components/u-icon/u-icon.js")+(()=>"../../uni_modules/uview-plus/components/u-radio/u-radio.js")+(()=>"../../uni_modules/uview-plus/components/u-radio-group/u-radio-group.js")+(()=>"../../uni_modules/uview-plus/components/u--textarea/u--textarea.js")+(()=>"../../node-modules/@dcloudio/uni-ui/lib/uni-icons/uni-icons.js")+(()=>"../../uni_modules/uview-plus/components/u-modal/u-modal.js"))();const n={__name:"ethicalInfo",setup(n){const{showHomeButton:i,checkAutoLogin:a,goHome:l}=o.useHomeButton(),s=t.useUserStore();e.ref({});const r=e.ref({hospitalNo:"",donorName:"",gender:"",age:"",diagnosis:"",receiveStatus:"0",endtime:""}),u=e.ref(null),c=e.ref(null),d=e.ref([]);e.reactive({show:!1,url:"",title:""});const p=s.baseUrlHt,v=e.ref({expertconclusion:"",expertopinion:""}),m=e.ref({name:"",title:""}),f=e.ref(!1),g=e.ref("确认提交"),x=e.ref("确定要提交审查意见吗?提交后将无法修改。"),h=e.computed(()=>(new Date).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})),w=e.ref([{label:"不同意",value:"0"},{label:"同意",value:"1"},{label:"弃权",value:"3"},{label:"修改后同意",value:"4"}]),y=e.ref(!1),T=e.reactive({signatureUrl:"",signatureTime:"",fileName:"",serverData:null});let S=null,b=null,N=0,z=0,U={left:0,top:0},C=e.ref([]),L=[],j=4,P=!1;const k=[{label:"细",value:2},{label:"中",value:4},{label:"粗",value:6}],I=e.ref(4),$=e.ref(!1),_=e.computed(()=>C.value.length>0),D=e.reactive({uploadUrl:"/api/common/upload",extraParams:{caseNo:"",expertId:"",expertName:"",type:"ethics_review_signature",bizType:"expert_review"}}),W=e.ref(!0),R=e.ref(!0),H=e.ref("提交审查"),Y=e=>({0:"pending",1:"pending",2:"pending",3:"submitted",4:"submitted",5:"success",6:"error"}[e]||"pending"),F=e.computed(()=>"3"==r.value.receiveStatus),M=e.computed(()=>F.value);e.computed(()=>!M.value&&(""!==v.value.expertconclusion&&""!==T.signatureUrl&&T.signatureUrl.startsWith("http"))),e.onLoad(async e=>{a(e),u.value=e.id,c.value=e.fcid,c.value&&await B(c.value)}),e.onShow(()=>{const t=e.index.getStorageSync("userInfo");t&&(m.value.name=t.nickName||t.userName||"")});const B=async t=>{try{e.index.showLoading({title:"加载中..."});const o={fcid:t,pageNum:1,pageSize:1},n=await e.index.$uapi.get("/project/ethicalreviewopinions/listnew",o);if(200==n.code&&n.rows&&n.rows.length>0){const t=n.rows[0];if(console.log("加载的审查数据:",t),r.value={...r.value,inpatientno:t.inpatientno,name:t.name,sex:t.sex,age:t.age,ageunit:t.ageunit,expertType:t.expertType,diagnosisname:t.diagnosisname,receiveStatus:t.receiveStatus||"0",endtime:t.endtime||"",caseNo:t.caseNo||""},console.log(t.receiveStatus,"data.receiveStatus"),console.log(r.value.receiveStatus,"caseInfo.value"),null!==t.expertconclusion&&void 0!==t.expertconclusion&&""!==t.expertconclusion&&(v.value.expertconclusion=t.expertconclusion.toString()),t.expertopinion&&(v.value.expertopinion=t.expertopinion),t.expertname)m.value.name=t.expertname;else{const t=e.index.getStorageSync("userInfo");t&&(m.value.name=t.nickName||t.userName||"")}t.sigin&&(T.signatureUrl=q(t.sigin),T.signatureTime=t.conclusiontime||""),t.filePatch&&A(t.filePatch),O(t),E(t.receiveStatus),D.extraParams.caseNo=t.caseNo||"",D.extraParams.expertName=m.value.name}else e.index.showToast({title:n.msg||"未找到审查数据",icon:"none"})}catch(o){if("未登录"==o.message)return;e.index.showToast({title:"加载失败",icon:"none"})}finally{e.index.hideLoading()}},O=e=>{e.receiveStatus},q=e=>{if(!e)return"";if(e.startsWith("blob:")||e.startsWith("file://"))return e;if(e.startsWith("http://")||e.startsWith("https://")){const t=e.indexOf("://")+3,o=e.indexOf("/",t);return-1!==o?`${p}${e.substring(o)}`:p}return`${p}${e.startsWith("/")?"":"/"}${e}`},A=e=>{if(e)try{let t=[];if(e.startsWith("[")&&e.endsWith("]")){const o=e.replace(/\\"/g,'"');t=JSON.parse(o)}else if(e.includes("fileName"))t=JSON.parse(e);else{t=e.split(";").filter(e=>e.trim()).map(e=>({fileName:e.split("/").pop()||"附件",path:e,fileUrl:e}))}d.value=t.map((e,t)=>{const o=e.fileName||`附件${t+1}`,n=q(e.fileUrl||e.path||e.url||""),i=o.split(".").pop().toLowerCase();let a="file-text",l="#909399";return["jpg","jpeg","png","gif","bmp","webp"].includes(i)?(a="photo",l="#fa8c16"):["doc","docx"].includes(i)?(a="file-text",l="#1890ff"):["xls","xlsx","csv"].includes(i)?(a="file-text",l="#52c41a"):["pdf"].includes(i)?(a="file-text",l="#f56c6c"):["txt","text"].includes(i)?(a="file-text",l="#909399"):["zip","rar","7z"].includes(i)&&(a="folder",l="#722ed1"),{id:e.infoid||t+1,name:o,icon:a,color:l,size:"--",url:n,type:i,createTime:e.createTime||""}})}catch(t){console.error("解析附件失败:",t,e);const o=e.split(";").filter(e=>e.trim());d.value=o.map((e,t)=>{const o=e.split("/").pop()||`附件${t+1}`,n=q(e),i=o.split(".").pop().toLowerCase();let a="file-text",l="#909399";return["jpg","jpeg","png","gif","bmp"].includes(i)?(a="photo",l="#fa8c16"):["doc","docx"].includes(i)?(a="file-text",l="#1890ff"):["xls","xlsx"].includes(i)?(a="file-text",l="#52c41a"):["pdf"].includes(i)&&(a="file-text",l="#f56c6c"),{id:t+1,name:o,icon:a,color:l,size:"--",url:n}})}},E=e=>{switch(e){case"3":case"4":case"5":case"6":W.value=!1,R.value=!1;break;default:W.value=!0,R.value=!0,H.value="提交审查"}},J=()=>{M.value?e.index.showToast({title:"当前任务已超时,不可操作",icon:"none"}):(y.value=!0,C.value=[],L=[],$.value=!1,P=!1,S=null,b=null,e.nextTick$1(()=>{setTimeout(()=>{X()},100)}))},Q=()=>{y.value=!1,S=null,b=null},X=()=>{V()},V=()=>{const t=e.getCurrentInstance().proxy;e.index.createSelectorQuery().in(t).select("#signatureCanvas").fields({node:!0,rect:!0}).exec(o=>{const n=o&&o[0]&&o[0].node,i=o&&o[0]&&o[0].rect;return n?i&&i.width>0?(U={left:i.left,top:i.top},void G(n,i.width,i.height)):void e.index.createSelectorQuery().in(t).select("#signatureCanvas").boundingClientRect(t=>{t&&t.width>0?(U={left:t.left,top:t.top},G(n,t.width,t.height)):(console.error("[签名] 画布尺寸获取失败:",t),e.index.showToast({title:"签名初始化失败,请重试",icon:"none"}))}).exec():(console.error("[签名] 画布节点获取失败:",o),void e.index.showToast({title:"签名初始化失败,请重试",icon:"none"}))})},G=(t,o,n)=>{b=t,N=o,z=n;const i=e.index.getSystemInfoSync().pixelRatio||2;t.width=o*i,t.height=n*i,S=t.getContext("2d"),S.scale(i,i),console.log("[签名] 画布初始化",{cssW:o,cssH:n,dpr:i,bufferW:t.width,bufferH:t.height}),K()},K=()=>{S&&(S.clearRect(0,0,N,z),S.fillStyle="#ffffff",S.fillRect(0,0,N,z),S.strokeStyle="#000000",S.lineCap="round",S.lineJoin="round",C.value.forEach(e=>{const t=e.points;if(S.lineWidth=e.width,1==t.length)Z(t[0],e.width);else if(t.length>1){S.beginPath(),S.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)S.lineTo(t[e].x,t[e].y);S.stroke()}}))},Z=(e,t)=>{const o=Math.max(1,(t||3)/2);S.beginPath(),S.arc(e.x,e.y,o,0,2*Math.PI),S.fillStyle="#000000",S.fill()},ee=e=>{const t=e.touches[0]||e.changedTouches[0];if(!t)return{x:0,y:0};const o="number"==typeof t.clientX?t.clientX:t.pageX,n="number"==typeof t.clientY?t.clientY:t.pageY;return{x:o-U.left,y:n-U.top}},te=t=>{if(!S||M.value)return;e.index.createSelectorQuery().in(e.getCurrentInstance().proxy).select("#signatureCanvas").boundingClientRect(e=>{e&&void 0!==e.left&&(U={left:e.left,top:e.top})}).exec();(e=>{S&&!M.value&&(P=!0,L=[e],j=I.value,C.value.push({points:L,width:j}),$.value=!0,S.lineWidth=j,Z(e,j))})(ee(t))},oe=e=>{if(!P||!S)return;(e=>{if(!P||!S)return;const t=L[L.length-1];t&&(S.beginPath(),S.lineWidth=j,S.moveTo(t.x,t.y),S.lineTo(e.x,e.y),S.stroke()),L.push(e)})(ee(e))},ne=()=>{P&&(P=!1,L=[])},ie=()=>{C.value=[],L=[],$.value=!1,K()},ae=()=>{0!=C.value.length&&(C.value.pop(),$.value=C.value.length>0,K())},le=async()=>{if($.value)try{e.index.showLoading({title:"保存签名中..."});const t=await new Promise((t,o)=>{b?e.index.canvasToTempFilePath({canvas:b,fileType:"png",success:e=>t(e.tempFilePath),fail:e=>{console.error("获取画布图片失败:",e),o(e)}}):o(new Error("画布未初始化"))}),o=await se(t);o?(T.signatureUrl=q(o.url),T.signatureTime=(new Date).toLocaleString("zh-CN"),T.fileName=o.originalFilename||`signature_${Date.now()}.png`,T.serverData=o,re(o),e.index.hideLoading(),e.index.showToast({title:"签名保存成功",icon:"success"}),y.value=!1,S=null,b=null):(e.index.hideLoading(),e.index.showToast({title:"签名上传失败",icon:"none"}))}catch(t){console.error("签名上传失败:",t),e.index.hideLoading(),e.index.showToast({title:"签名上传失败",icon:"none"})}else e.index.showToast({title:"请先签名",icon:"none"})},se=t=>new Promise((o,n)=>{const i=e.index.getStorageSync("token"),a=e.index.getStorageSync("userInfo"),l=(null==a?void 0:a.nickName)||(null==a?void 0:a.userName)||m.value.name;e.index.uploadFile({url:"/api/common/upload",filePath:t,name:"file",header:{Authorization:`Bearer ${i}`},formData:{bizType:"expert_review_signature",caseNo:r.value.caseNo||"",expertName:l,uploadType:"signature"},success:e=>{if(200==e.statusCode){(e=>{console.log("签名上传成功:",e),200==e.code?o({url:e.url,fileName:e.fileName,newFileName:e.newFileName,originalFilename:e.originalFilename,filePath:e.filePath||e.fileName,size:e.size}):n(new Error(e.msg||"上传失败"))})(JSON.parse(e.data))}else n(new Error(`上传失败,状态码: ${e.statusCode}`))},fail:e=>{n(e)}})}),re=t=>{try{const o={signatureUrl:T.signatureUrl,signatureTime:T.signatureTime,fileName:T.fileName,uploadData:t,caseNo:r.value.caseNo,timestamp:Date.now()};e.index.setStorageSync("expert_review_signature",o)}catch(o){console.error("保存签名到本地失败:",o)}},ue=()=>{M.value?e.index.showToast({title:"当前任务已超时,不可操作",icon:"none"}):e.index.showModal({title:"提示",content:"确定要删除签名吗?",success:t=>{t.confirm&&(T.signatureUrl="",T.signatureTime="",T.fileName="",T.serverData=null,e.index.removeStorageSync("expert_review_signature"))}})},ce=()=>{if(T.signatureUrl){let t=q(T.signatureUrl);e.index.previewImage({urls:[t],success:()=>{console.log("签名预览成功")},fail:t=>{console.error("签名预览失败:",t),e.index.showToast({title:"签名加载失败",icon:"none"})}})}},de=e=>{console.log("选中结论:",e)},pe=async()=>{if(M.value)e.index.showToast({title:"当前任务已超时,不可操作",icon:"none"});else if(fe(!0))try{e.index.showLoading({title:"保存中..."});const t={fcid:c.value,expertconclusion:v.value.expertconclusion,expertopinion:v.value.expertopinion,sigin:T.signatureUrl,receiveStatus:"2",conclusiontime:e.dayjs().format("YYYY-MM-DD HH:mm:ss")},o=await e.index.$uapi.post("/project/ethicalreviewopinions/edit",t);200==o.code?(e.index.showToast({title:"保存成功",icon:"success"}),r.value.receiveStatus="2",E("2")):e.index.showToast({title:o.msg||"保存失败",icon:"none"})}catch(t){console.error("保存草稿失败:",t),e.index.showToast({title:"保存失败",icon:"none"})}finally{e.index.hideLoading()}},ve=()=>{console.log(1),M.value?e.index.showToast({title:"当前任务已超时,不可操作",icon:"none"}):(console.log(2),fe()&&(g.value="确认提交",x.value="确定要提交审查意见吗?提交后将无法修改。",f.value=!0))},me=async()=>{try{e.index.showLoading({title:"提交中..."}),console.log(r.value,"form.value");const t={id:c.value,expertconclusion:v.value.expertconclusion,expertopinion:v.value.expertopinion,sigin:T.signatureUrl,expertType:r.value.expertType,receiveStatus:"1"==v.value.expertconclusion||"4"==v.value.expertconclusion?"5":"6",conclusiontime:e.dayjs().format("YYYY-MM-DD HH:mm:ss")},o=await e.index.$uapi.post("/project/ethicalreviewopinions/edit",t);200==o.code?(e.index.showToast({title:"提交成功",icon:"success",duration:2e3}),r.value.receiveStatus=t.receiveStatus,E(t.receiveStatus),f.value=!1,setTimeout(()=>{e.index.navigateBack()},1500)):e.index.showToast({title:o.msg||"提交失败",icon:"none"})}catch(t){console.error("提交失败:",t),e.index.showToast({title:"提交失败",icon:"none"})}finally{e.index.hideLoading()}},fe=(t=!1)=>v.value.expertconclusion||t?(console.log(3),console.log(T,"signatureData"),!(!T.signatureUrl&&!t)||(e.index.showToast({title:"请进行手写签名",icon:"none"}),!1)):(e.index.showToast({title:"请选择审查结论",icon:"none"}),!1);return(t,o)=>{return e.e({a:e.t((n=r.value.receiveStatus,{0:"待接收",1:"未接收",2:"已接收",3:"超时",4:"中止",5:"完成",6:"驳回"}[n]||"未知状态")),b:e.n(Y(r.value.receiveStatus)),c:e.p({name:"file-text",size:"14",color:"#909399"}),d:e.t(r.value.inpatientno||"--"),e:e.p({name:"account",size:"14",color:"#909399"}),f:e.t(r.value.name||"--"),g:e.p({name:"man",size:"14",color:"#909399"}),h:e.t(1==r.value.sex?"男":2==r.value.sex?"女":"未知"),i:e.t(r.value.age||"--"),j:e.t(r.value.ageunit||"岁"),k:e.p({name:"heart",size:"14",color:"#909399"}),l:e.t(r.value.diagnosisname||"--"),m:e.t(d.value.length),n:e.f(d.value,(t,o,n)=>e.e({a:"4839a6ea-4-"+n,b:e.p({name:t.icon,color:t.color,size:"18"}),c:e.t(t.name),d:t.type},t.type?{e:e.t(t.type||"文件")}:{},{f:e.t(t.size),g:"4839a6ea-5-"+n,h:t.id,i:e.o(o=>(t=>{if(t.url){e.index.showLoading({title:"加载中..."});const o=t.type||t.url.split(".").pop().toLowerCase();let n=q(t.url);try{const e=new URL(n);n=e.origin+encodeURI(decodeURI(e.pathname))+(e.search||"")}catch{try{n=encodeURI(decodeURI(n))}catch{n=encodeURI(n)}}if(["jpg","jpeg","png","gif","bmp","webp"].includes(o))e.index.previewImage({urls:[n],current:0,success:()=>{console.log("图片预览成功")},fail:t=>{console.error("图片预览失败:",t),e.index.showToast({title:"图片加载失败",icon:"none"})},complete:()=>{e.index.hideLoading()}});else if(["pdf","doc","docx","xls","xlsx","ppt","pptx","txt"].includes(o)){const t=e.index.getStorageSync("token")||"";e.index.downloadFile({url:n,header:{Authorization:t?`Bearer ${t}`:""},success:t=>{if(200==t.statusCode){const n=t.tempFilePath;e.index.openDocument({filePath:n,showMenu:!0,fileType:"pdf"==o?"pdf":"",success:()=>{console.log("打开文档成功")},fail:t=>{console.error("打开文档失败:",t),e.index.showToast({title:"无法打开该文件",icon:"none"})}})}else console.error("下载状态码异常:",t.statusCode),e.index.showToast({title:`服务器返回异常(${t.statusCode})`,icon:"none"})},fail:t=>{console.error("下载文件失败:",t),console.error("下载URL:",n),e.index.showToast({title:"文件下载失败,请检查网络或域名配置",icon:"none",duration:3e3})},complete:()=>{e.index.hideLoading()}})}else e.index.showToast({title:`暂不支持预览${o}格式文件`,icon:"none"}),e.index.hideLoading()}else e.index.showToast({title:`预览: ${t.name}`,icon:"none"})})(t),t.id)})),o:e.p({name:"arrow-right",size:"14",color:"#c0c4cc"}),p:F.value},F.value?{q:e.p({name:"clock",size:"16"})}:{},{r:e.f(w.value,(t,o,n)=>({a:t.value,b:"4839a6ea-8-"+n+",4839a6ea-7",c:e.p({name:t.value,label:t.label,customStyle:{marginBottom:"16rpx"}})})),s:e.o(de),t:e.o(e=>v.value.expertconclusion=e),v:e.p({placement:"column",activeColor:"#007aff",disabled:M.value,modelValue:v.value.expertconclusion}),w:e.o(e=>v.value.expertopinion=e),x:e.p({placeholder:"请输入详细的审查意见和改进建议...",maxlength:"1000",count:!0,height:120,border:"surround",disabled:M.value,modelValue:v.value.expertopinion}),y:e.p({name:"edit-pen",size:"16",color:"#007aff"}),z:e.t(m.value.name),A:e.p({name:"clock",size:"16",color:"#007aff"}),B:e.t(h.value),C:F.value},F.value?{D:e.p({name:"clock",size:"16"})}:{},{E:T.signatureUrl},T.signatureUrl?e.e({F:T.signatureUrl,G:e.o(ce),H:e.t(m.value.name),I:e.t(T.signatureTime),J:!M.value},M.value?{}:{K:e.p({name:"photo",size:"16"}),L:e.o(ue)}):e.e({M:!M.value},M.value?{}:{N:e.p({name:"edit-pen",size:"48",color:"#c0c4cc"}),O:e.o(J)}),{P:e.p(t.N),Q:e.o((...e)=>t.O&&t.O(...e)),R:!M.value},M.value?{}:e.e({S:W.value},W.value?{T:e.p({name:"file-text",size:"16",color:"#606266"}),U:e.o(pe)}:{},{V:R.value},R.value?{W:e.p({name:"checkmark",size:"16",color:"#fff"}),X:e.t(H.value),Y:e.o(ve)}:{}),{Z:M.value},M.value?{aa:e.p({name:"info-circle",size:"20",color:"#fa8c16"})}:{},{ab:y.value},y.value?e.e({ac:e.o(Q),ad:e.o(ie),ae:e.o(te),af:e.o(oe),ag:e.o(ne),ah:e.o(ne),ai:!$.value},$.value?{}:{aj:e.p({name:"edit-pen",size:"44",color:"#c0c4cc"}),ak:e.o(()=>{})},{al:e.f(k,(t,o,n)=>({a:2*t.value+"px",b:2*t.value+"px",c:I.value==t.value?"#0f95b0":"#c0c4cc",d:e.t(t.label),e:I.value==t.value?1:"",f:t.value,g:e.o(e=>I.value=t.value,t.value)})),am:!_.value,an:e.o(ae),ao:!$.value,ap:e.o(le)}):{},{aq:e.unref(i)},e.unref(i)?{ar:e.p({type:"home",size:"24",color:"#fff"}),as:e.o((...t)=>e.unref(l)&&e.unref(l)(...t))}:{},{at:e.o(me),av:e.o(e=>f.value=!1),aw:e.p({show:f.value,title:g.value,content:x.value,showCancelButton:!0}),ax:e.gei(t,"")});var n}}};wx.createPage(n);
|