Files
threeonecheck_web/unpackage/dist/build/mp-weixin/pages/hiddendanger/acceptance.js

2 lines
7.8 KiB
JavaScript

"use strict";const e=require("../../common/vendor.js"),a=require("../../request/api.js"),t=require("../../request/request.js"),l=require("../../utils/draftCache.js"),r=require("../../utils/useDraftCache.js"),u=require("../../utils/upload.js");if(!Array){(e.resolveComponent("up-textarea")+e.resolveComponent("up-upload")+e.resolveComponent("wd-signature"))()}Math||((()=>"../../uni_modules/uview-plus/components/u-textarea/u-textarea.js")+(()=>"../../uni_modules/uview-plus/components/u-upload/u-upload.js")+(()=>"../../node-modules/wot-design-uni/components/wd-signature/wd-signature.js"))();const i={__name:"acceptance",setup(i){const n=e.ref(""),s=e.ref(""),o=e.ref(""),v=e.reactive({rectifyPlan:"",rectificationMeasures:"",controlMeasures:"",rectifyResult:"",planCost:null,actualCost:null,rectifierName:"",rectifyStatusName:""}),c=e=>{if(null==e||""===e)return"暂无";const a=Number(e);return Number.isNaN(a)?"暂无":`${a.toFixed(2)}`},f=e.ref([]),d=e.reactive({result:1,verifyRemark:""}),h=e.ref([]),m=e.ref(300),g=e.ref(300),y=e.ref(!0),p=e.ref(""),w=e.ref(""),C=e.ref(340),x=e.ref(null),P=e.ref(!0),R=e.ref(!1),T=e.ref([]),I=e.ref(""),k=e.ref(!1);let S=null;const L=e=>{const a=e?u.toSubmitFileUrl(e):"";if(!a)return y.value=!0,w.value="",p.value="",I.value="",void(P.value=!0);w.value=a,p.value=a,I.value="",y.value=!1,P.value=!1},N=e=>{e&&(I.value=e,p.value=e,w.value="",y.value=!1,P.value=!1)},{showRestoreBanner:D,clear:b,restore:q,save:A,bindAutoSave:M}=r.useDraftCache({getKey:()=>l.buildDraftKey(l.DRAFT_NS.ACCEPT,n.value),getFallbackKeys:()=>{const e=l.buildDraftKey(l.DRAFT_NS.ACCEPT,n.value),a=l.buildDraftKeyCompact(l.DRAFT_NS.ACCEPT,n.value);return a!==e?[a]:[]},getPayload:()=>({formData:{result:d.result,verifyRemark:d.verifyRemark},fileList1:h.value,signatureServerPath:w.value,signatureUrl:p.value,signatureLocalPath:I.value,showCanvas:y.value,signaturePaths:T.value}),hasContent:e=>!!((e.formData||{}).verifyRemark||e.fileList1&&e.fileList1.length>0||e.signatureServerPath||e.signatureLocalPath||e.signaturePaths&&e.signaturePaths.length>0),applyPayload:e=>{const a=e.formData||{};d.result=void 0!==a.result?a.result:1,d.verifyRemark=a.verifyRemark||"",h.value=e.fileList1||[],T.value=e.signaturePaths||[],e.signatureServerPath||e.signatureUrl?L(e.signatureServerPath||e.signatureUrl):e.signatureLocalPath?N(e.signatureLocalPath):(y.value=void 0===e.showCanvas||e.showCanvas,w.value="",p.value="",I.value="",P.value=!0)},clearForm:()=>{d.result=1,d.verifyRemark="",h.value=[],w.value="",p.value="",I.value="",y.value=!0,T.value=[],x.value&&x.value.clear()},canSave:()=>!!n.value,requireInitialized:!0,onAfterRestore:e=>{var a;e.signatureServerPath||e.signatureUrl||e.signatureLocalPath||(null==(a=e.signaturePaths)?void 0:a.length)>0&&setTimeout((()=>{x.value&&(P.value=!1)}),450)}});M((()=>[d.result,d.verifyRemark,h.value,w.value,p.value,I.value,y.value,T.value]));const _=e=>e?(e.startsWith("http://")||e.startsWith("https://"),t.toImageUrl(e)):"",j=async()=>{var t;if(s.value)try{const l=await a.getHiddenDangerDetail({hazardId:s.value,assignId:o.value});if(0===l.code&&l.data){const e=(e=>{if(!(null==e?void 0:e.length))return null;if(n.value){const a=e.find((e=>e.rectify&&String(e.rectify.rectifyId)===String(n.value)));if(a)return a}if(o.value){const a=e.find((e=>String(e.assignId)===String(o.value)&&e.rectify));if(a)return a}return e.find((e=>e.rectify))||null})(l.data.assigns);(null==e?void 0:e.rectify)&&((t=e.rectify)&&(v.rectifyPlan=t.rectifyPlan||"",v.rectificationMeasures=t.rectificationMeasures||"",v.controlMeasures=t.controlMeasures||"",v.rectifyResult=t.rectifyResult||"",v.planCost=t.planCost??null,v.actualCost=t.actualCost??null,v.rectifierName=t.rectifierName||"",v.rectifyStatusName=t.rectifyStatusName||"",f.value=t.attachments||[]),console.log("整改记录:",v),console.log("整改附件:",f.value))}else e.index.showToast({title:l.msg||"获取详情失败",icon:"none"})}catch(l){console.error("获取隐患详情失败:",l),e.index.showToast({title:"请求失败",icon:"none"})}},F=()=>{e.index.navigateBack()},U=async()=>{if(n.value)if(y.value){if(!x.value||P.value)return void e.index.showToast({title:"请进行电子签名",icon:"none"});R.value=!0,e.index.showLoading({title:"正在提交...",mask:!0}),x.value.confirm()}else{if(!w.value&&!I.value)return void e.index.showToast({title:"请进行电子签名",icon:"none"});R.value=!0,e.index.showLoading({title:"正在提交...",mask:!0});try{if(!w.value&&I.value){const{url:e}=await u.uploadToCloud(I.value);L(e)}await z()}catch(a){R.value=!1,e.index.hideLoading(),console.error("签名上传失败:",a),e.index.showToast({title:"签名上传失败,请重试",icon:"none"})}}else e.index.showToast({title:"缺少整改ID",icon:"none"})},z=async()=>{const t=h.value.filter((e=>"success"===e.status)).map((e=>u.buildAttachmentItem(e))),l={rectifyId:Number(n.value),result:d.result,verifyRemark:d.verifyRemark||"",attachments:t,signPath:w.value||""};console.log("提交验收参数:",l);try{const t=await a.acceptanceRectification(l);e.index.hideLoading(),0===t.code?(b(!1),e.index.showToast({title:"验收成功",icon:"success"}),setTimeout((()=>{e.index.navigateBack()}),1500)):e.index.showToast({title:t.msg||"验收失败",icon:"none"})}catch(r){e.index.hideLoading(),console.error("验收失败:",r),e.index.showToast({title:"请求失败",icon:"none"})}finally{R.value=!1}},H=e.getCurrentInstance(),{afterRead:K,deletePic:W}=u.createUploadListHandlers(h,{watermark:{canvasId:"watermarkCanvas",canvasWidthRef:m,canvasHeightRef:g,instance:H}}),B=()=>{P.value=!1},E=()=>{P.value=!1},$=()=>{P.value=!0,I.value=""},G=()=>{P.value=!1,clearTimeout(S),S=setTimeout((()=>{!y.value||P.value||!x.value||R.value||k.value||(k.value=!0,x.value.confirm())}),600)},J=()=>{clearTimeout(S),P.value=!0,I.value="",x.value&&x.value.clear()},O=()=>{clearTimeout(S),P.value=!0,y.value=!0,p.value="",w.value="",I.value="",e.nextTick$1((()=>{x.value&&x.value.clear()}))};return e.onHide((()=>{y.value&&!P.value&&x.value&&!k.value&&(k.value=!0,x.value.confirm()),A()})),e.onLoad((a=>{try{const a=e.index.getSystemInfoSync();C.value=a.windowWidth-40}catch(t){console.error("获取系统信息失败:",t)}a.rectifyId&&(n.value=a.rectifyId),a.hazardId&&(s.value=a.hazardId),a.assignId&&(o.value=a.assignId),console.log("验收页面参数:",{rectifyId:n.value,hazardId:s.value,assignId:o.value}),j(),q()})),(a,t)=>e.e({a:e.t(v.rectifyPlan||"暂无"),b:e.t(v.rectificationMeasures||"暂无"),c:e.t(v.controlMeasures||"暂无"),d:e.t(v.rectifyResult||"暂无"),e:e.t(c(v.planCost)),f:e.t(c(v.actualCost)),g:e.t(v.rectifierName||"暂无"),h:e.t(v.rectifyStatusName||"暂无"),i:f.value.length>0},f.value.length>0?{j:e.f(f.value,((a,t,l)=>({a:t,b:_(a.filePath),c:e.o((a=>(a=>{const t=f.value.map((e=>_(e.filePath)));e.index.previewImage({current:a,urls:t})})(t)),t)})))}:{},{k:e.n(1===d.result?"active":""),l:e.o((e=>d.result=1)),m:e.n(2===d.result?"active":""),n:e.o((e=>d.result=2)),o:e.o((e=>d.verifyRemark=e)),p:e.p({placeholder:"请输入验收备注",modelValue:d.verifyRemark}),q:e.o(e.unref(K)),r:e.o(e.unref(W)),s:e.p({fileList:h.value,name:"1",multiple:!0,imageMode:"aspectFill",maxCount:10}),t:m.value,v:g.value,w:m.value+"px",x:g.value+"px",y:y.value},y.value?{z:e.o(J)}:{A:e.o(O)},{B:!y.value},y.value?{}:e.e({C:p.value},p.value?{D:p.value}:{}),{E:y.value},y.value?{F:e.sr(x,"fa0c6117-2",{k:"signatureRef"}),G:e.o((a=>(async a=>{if(k.value)return k.value=!1,N(a),void A();try{const{url:e}=await u.uploadToCloud(a);L(e),A(),R.value&&await z()}catch(t){R.value=!1,e.index.hideLoading(),console.error("签名上传失败:",t),e.index.showToast({title:"签名上传失败,请重试",icon:"none"})}})(a.tempFilePath))),H:e.o(B),I:e.o(E),J:e.o(G),K:e.o($),L:e.p({width:C.value,height:160,backgroundColor:"#f8f8f8",penColor:"#000000",lineWidth:3,enableHistory:!1})}:{},{M:e.o(F),N:e.o(U),O:e.gei(a,"")})}},n=e._export_sfc(i,[["__scopeId","data-v-fa0c6117"]]);wx.createPage(n);