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

2 lines
13 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";const e=require("../../common/vendor.js"),a=require("../../request/api.js");require("../../request/request.js");const l=require("../../utils/upload.js"),t=require("../../request/three_one_api/area.js");if(!Array){(e.resolveComponent("u-radio")+e.resolveComponent("u-radio-group")+e.resolveComponent("up-textarea")+e.resolveComponent("up-choose")+e.resolveComponent("up-upload")+e.resolveComponent("up-input")+e.resolveComponent("u-popup"))()}Math||((()=>"../../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")+(()=>"../../uni_modules/uview-plus/components/u-choose/u-choose.js")+(()=>"../../uni_modules/uview-plus/components/u-upload/u-upload.js")+(()=>"../../uni_modules/uview-plus/components/u-input/u-input.js")+(()=>"../../uni_modules/uview-plus/components/u-popup/u-popup.js"))();const o={__name:"Inspectionresult",setup(o){const u=e.ref(""),n=e.ref(300),i=e.ref(300),r=e.ref(null),s=e.reactive([{name:"正常",value:1,disabled:!1},{name:"异常",value:2,disabled:!1},{name:"不涉及",value:3,disabled:!1}]),v=e.ref(""),d=e=>{console.log("groupChange",e),"异常"!==e&&W()},c=e=>{console.log("radioChange",e)},p=e.ref(""),g=e.ref(!1),m=e.reactive({title:"",level:0,source:0,description:"",tagIndex:0,regulationId:null,regulationName:""}),h=e.ref(""),f=e.ref(0),x=e.ref(0),w=e.ref(!1),I=e.ref([]),b=e.ref(""),y=e.ref(""),T=e.ref(""),z=e.ref(!1),L=e.ref(""),k=e.ref(null),D=e.ref(""),C=e.ref([]),_=e.ref(!1),A=e.ref(1),j=e.ref(10),F=e.ref(!0),S=()=>{z.value=!0,0===C.value.length&&q()},q=async(e=!1)=>{if(!_.value){_.value=!0;try{const l={pageNum:A.value,pageSize:j.value,status:1};L.value&&L.value.trim()&&(l.keyword=L.value.trim());const t=await a.getRegulationList(l);if(0===t.code){const a=t.data.records||t.data||[];C.value=e?[...C.value,...a]:a;const l=t.data.total||0;F.value=C.value.length<l}}catch(l){console.error("获取法规列表失败:",l)}finally{_.value=!1}}},$=()=>{A.value=1,C.value=[],F.value=!0,q()},N=()=>{F.value&&!_.value&&(A.value++,q(!0))},V=()=>{k.value&&(m.regulationId=k.value,m.regulationName=D.value),z.value=!1},B=()=>{if(T.value){b.value=T.value;const e=I.value.find((e=>e.id===T.value));y.value=e?e.name:""}w.value=!1},R=e.ref([]),H=e.ref(null),K=e.ref(!1),M=e.computed((()=>m.title&&R.value.length>0)),P=e.computed((()=>{if(!r.value)return 0;const e=r.value.currentIndex||1,a=r.value.totalCount||1;return Math.round(e/a*100)})),J=e.ref([{id:2,title:"一般隐患"},{id:3,title:"重大隐患"}]),O=e.ref([{id:1,title:"部门检查"},{id:2,title:"都导检查"},{id:3,title:"企业自查"},{id:4,title:"行业互查"}]),U=e.ref([]),E=()=>{g.value=!0},G=()=>{g.value=!0},W=()=>{m.regulationId=null,m.regulationName="",k.value=null,D.value="",m.title="",m.level=0,m.source=0,m.description="",m.tagIndex=0,h.value="",f.value=0,x.value=0,R.value=[],b.value="",y.value=""},Q=()=>{0!==R.value.length?m.title?h.value?m.description?(g.value=!1,e.index.showToast({title:"隐患信息已暂存",icon:"success"})):e.index.showToast({title:"请输入隐患描述",icon:"none"}):e.index.showToast({title:"请输入隐患位置",icon:"none"}):e.index.showToast({title:"请输入隐患标题",icon:"none"}):e.index.showToast({title:"请上传隐患图片",icon:"none"})},X=()=>{g.value=!1,setTimeout((()=>{e.index.chooseLocation({success:e=>{h.value=e.address+(e.name?`(${e.name})`:""),f.value=e.longitude,x.value=e.latitude,g.value=!0},fail:a=>{g.value=!0,a.errMsg&&-1===a.errMsg.indexOf("cancel")&&e.index.showToast({title:"选择位置失败",icon:"none"})}})}),300)},Y=e.getCurrentInstance(),{afterRead:Z,deletePic:ee}=l.createUploadListHandlers(R,{watermark:{canvasId:"watermarkCanvas",canvasWidthRef:n,canvasHeightRef:i,instance:Y}}),ae=async()=>{const l=R.value.filter((e=>"success"===e.status&&e.url.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)));if(0===l.length)return void e.index.showToast({title:"请先上传隐患图片",icon:"none"});const t=l[0].url;K.value=!0;try{console.log("开始调用AI分析接口图片地址:",t);const l=await a.analyzeHazardImage({imageUrl:t});if(0===l.code&&l.data){const a=l.data;if(console.log("AI分析结果:",a),a.title&&(m.title=a.title),a.description&&(m.description=a.description),a.level){const l={"轻微":0,"轻微隐患":0,"一般":1,"一般隐患":1,"重大":2,"重大隐患":2}[a.level];void 0!==l&&(m.level=l,e.nextTick$1((()=>{H.value&&H.value.$data&&(H.value.$data.currentIndex=l)})))}e.index.showToast({title:"AI分析完成已自动填充",icon:"success",duration:2e3})}else e.index.showToast({title:l.msg||"AI分析失败",icon:"none"})}catch(o){console.error("AI分析接口调用失败:",o),e.index.showToast({title:"AI分析失败请重试",icon:"none"})}finally{K.value=!1}},le=async()=>{var t,o,u,n,i;if(!v.value)return void e.index.showToast({title:"请选择检查结果",icon:"none"});const d=s.find((e=>e.name===v.value)),c=d?d.value:null;if(c)if("异常"!==v.value||M.value)try{if(e.index.showLoading({title:"提交中..."}),"异常"===v.value&&M.value){const i=R.value.filter((e=>"success"===e.status)).map((e=>l.buildAttachmentItem(e))),s=U.value[m.tagIndex],v=s?s.id:null,d={taskId:null==(t=r.value)?void 0:t.taskId,checkPointId:null==(o=r.value)?void 0:o.checkPointId,title:m.title,level:(null==(u=J.value[m.level])?void 0:u.id)||2,lng:f.value||0,lat:x.value||0,address:h.value||"",areaId:b.value||null,description:m.description||"",source:(null==(n=O.value[m.source])?void 0:n.title)||"",tagId:v,attachments:i,regulationId:m.regulationId||null};console.log("隐患参数:",d);const c=await a.addHiddenDanger(d);if(0!==c.code)return e.index.hideLoading(),void e.index.showToast({title:c.msg||"新增隐患失败",icon:"none"});console.log("新增隐患成功")}const s={taskId:null==(i=r.value)?void 0:i.taskId,result:c,remark:p.value};console.log("提交参数:",s);const d=await a.submitCheckResult(s);e.index.hideLoading(),0===d.code?(se(!1),d.data&&!0===d.data.allFinished?(e.index.showToast({title:"全部检查已完成",icon:"success"}),setTimeout((()=>{e.index.navigateBack()}),1500)):d.data&&d.data.nextTask?(e.index.showToast({title:"提交成功,进入下一题",icon:"success"}),te(),r.value=d.data.nextTask):(e.index.showToast({title:"提交成功",icon:"success"}),setTimeout((()=>{e.index.navigateBack()}),1500))):e.index.showToast({title:d.msg||"提交失败",icon:"none"})}catch(g){e.index.hideLoading(),console.error("提交失败:",g),e.index.showToast({title:"提交失败",icon:"none"})}else e.index.showToast({title:"请填写隐患信息",icon:"none"});else e.index.showToast({title:"请选择检查结果",icon:"none"})},te=()=>{v.value="",p.value="",W()},oe=e.ref(!1),ue=e.ref(!1),ne=e.ref(!1),ie=e.ref(!1),re=()=>{var e;return`draft_inspection_result_${u.value||""}_${(null==(e=r.value)?void 0:e.currentIndex)||""}`},se=(a=!0)=>{const l=re();console.log("【草稿Debug - 巡检】手动清空草稿, Key:",l),e.index.removeStorageSync(l),oe.value=!1,ue.value=!1,ne.value=!0,v.value="",p.value="",m.title="",m.level=0,m.source=0,m.description="",m.tagIndex=0,R.value=[],h.value="",f.value=0,x.value=0,e.nextTick$1((()=>{ne.value=!1})),a&&e.index.showToast({title:"草稿已清空",icon:"none"})},ve=()=>{const a=re(),l=e.index.getStorageSync(a);if(console.log("【草稿Debug - 巡检】尝试恢复草稿, Key:",a,"获取本地缓存结果:",!!l),l)try{const a=JSON.parse(l),t=a.radiovalue1||a.value1||a.hazardFormData.title||a.hazardFormData.description||a.hazardFileList&&a.hazardFileList.length>0;if(console.log("【草稿Debug - 巡检】解析本地缓存成功, 是否有实质内容:",!!t,"缓存数据:",a),!t)return void(ie.value=!0);ne.value=!0,v.value=a.radiovalue1||"",p.value=a.value1||"",m.title=a.hazardFormData.title||"",m.level=a.hazardFormData.level||0,m.source=a.hazardFormData.source||0,m.description=a.hazardFormData.description||"",m.tagIndex=a.hazardFormData.tagIndex||0,R.value=a.hazardFileList||[],h.value=a.hazardAddress||"",f.value=a.hazardLng||0,x.value=a.hazardLat||0,oe.value=!0,ue.value=!0,e.nextTick$1((()=>{ne.value=!1,ie.value=!0,H.value&&H.value.$data&&(H.value.$data.currentIndex=m.level),console.log("【草稿Debug - 巡检】UI与多选组件状态同步重绘完毕")})),e.index.showToast({title:"已自动恢复您上次未提交的内容",icon:"none",duration:2500})}catch(t){console.error("【草稿Debug - 巡检】解析草稿异常:",t),ne.value=!1,ie.value=!0}else console.log("【草稿Debug - 巡检】本地无任何缓存, 页面已安全标记为 initialized"),ie.value=!0};return e.watch((()=>[v.value,p.value,m.title,m.level,m.source,m.description,m.tagIndex,h.value,R.value]),(()=>{u.value&&(()=>{if(ne.value||!ie.value)return void console.log("【草稿Debug - 巡检】saveDraft 被跳过:",{isRestoring:ne.value,isInitialized:ie.value});const a=re(),l=v.value||p.value||m.title||m.description||R.value.length>0;if(console.log("【草稿Debug - 巡检】尝试自动保存草稿. Key:",a,"是否有实质内容:",!!l,"当前数据:",{radiovalue1:v.value,value1:p.value,title:m.title,description:m.description,fileCount:R.value.length}),!l)return e.index.removeStorageSync(a),console.log("【草稿Debug - 巡检】当前表单为空,自动删除本地缓存 Key:",a),void(oe.value=!1);const t={radiovalue1:v.value,value1:p.value,hazardFormData:{title:m.title,level:m.level,source:m.source,description:m.description,tagIndex:m.tagIndex},hazardFileList:R.value,hazardAddress:h.value,hazardLng:f.value,hazardLat:x.value};e.index.setStorageSync(a,JSON.stringify(t)),console.log("【草稿Debug - 巡检】成功保存草稿到 LocalStorage, Key:",a),oe.value=!0})()}),{deep:!0}),e.onLoad((e=>{console.log("接收到的参数:",e),e.id&&(u.value=e.id,(async()=>{try{const e=await a.enterCheckPlan(u.value);console.log("检查项数据:",e),0===e.code&&(r.value=e.data,ve())}catch(e){console.error(e)}})()),(async()=>{try{const e=await a.getHiddenDangerLabelList();0===e.code&&(U.value=e.data.map((e=>({id:e.id,title:e.name}))))}catch(e){console.error("获取标签列表失败:",e)}})(),(async()=>{try{const e=await t.getAreaList();0===e.code&&e.data&&e.data.records&&(I.value=e.data.records)}catch(e){console.error("获取区域列表失败:",e)}})()})),(a,l)=>{var t,o,u,f;return e.e({a:r.value},r.value?{b:e.t(r.value.currentIndex||1),c:e.t(r.value.totalCount||1),d:P.value+"%"}:{},{e:e.t((null==(t=r.value)?void 0:t.name)||"加载中..."),f:(null==(o=r.value)?void 0:o.point)||"",g:e.f(s,((a,l,t)=>({a:l,b:e.o(c,l),c:"a1b78696-1-"+t+",a1b78696-0",d:e.p({customStyle:{marginBottom:"8px"},label:a.name,name:a.name})}))),h:e.o(d),i:e.o((e=>v.value=e)),j:e.p({placement:"row",modelValue:v.value}),k:"异常"===v.value},"异常"===v.value?e.e({l:!M.value},M.value?e.e({n:e.t(m.title),o:e.t(null==(u=J.value[m.level])?void 0:u.title),p:0===m.level?1:"",q:1===m.level?1:"",r:2===m.level?1:"",s:e.t((null==(f=O.value[m.source])?void 0:f.title)||"-"),t:e.t(h.value||"-"),v:e.t(m.description||"-"),w:R.value.length>0},R.value.length>0?{x:e.t(R.value.length)}:{},{y:e.o(G),z:e.o(W)}):{m:e.o(E)}):{},{A:e.o((e=>p.value=e)),B:e.p({placeholder:"请输入备注信息",modelValue:p.value}),C:e.o(le),D:e.o((e=>g.value=!1)),E:ue.value},ue.value?{F:e.o((e=>se(!0)))}:{},{G:e.o((e=>m.source=e)),H:e.p({options:O.value,wrap:!1,"item-width":"152rpx","item-height":"64rpx",modelValue:m.source}),I:e.o(e.unref(Z)),J:e.o(e.unref(ee)),K:e.p({fileList:R.value,name:"1",multiple:!0,imageMode:"aspectFill",maxCount:10}),L:n.value,M:i.value,N:n.value+"px",O:i.value+"px",P:!K.value},(K.value,{}),{Q:e.t(K.value?"AI识别中...":"AI 识别隐患"),R:K.value,S:K.value,T:e.o(ae),U:e.o((e=>m.title=e)),V:e.p({placeholder:"请输入内容",border:"surround",modelValue:m.title}),W:e.sr(H,"a1b78696-7,a1b78696-3",{k:"levelChooseRef"}),X:e.o((e=>m.level=e)),Y:e.p({options:J.value,wrap:!1,"item-width":"183rpx","item-height":"72rpx",modelValue:m.level}),Z:e.o((e=>h.value=e)),aa:e.p({placeholder:"请输入地址",border:"surround",modelValue:h.value}),ab:e.o(X),ac:e.t(m.regulationName||"请选择法律依据"),ad:m.regulationName?"":1,ae:e.o(S),af:e.t(y.value||"请选择隐患区域"),ag:y.value?"":1,ah:e.o((e=>w.value=!0)),ai:e.o((e=>m.description=e)),aj:e.p({placeholder:"请输入内容",modelValue:m.description}),ak:e.o((e=>m.tagIndex=e)),al:e.p({options:U.value,modelValue:m.tagIndex}),am:e.o((e=>g.value=!1)),an:e.o(Q),ao:e.o((e=>g.value=!1)),ap:e.p({show:g.value,mode:"center",round:"20",safeAreaInsetBottom:!1}),aq:e.o((e=>z.value=!1)),ar:e.o($),as:L.value,at:e.o((e=>L.value=e.detail.value)),av:e.o($),aw:_.value&&0===C.value.length},_.value&&0===C.value.length?{}:_.value||0!==C.value.length?e.e({ay:e.f(C.value,((a,l,t)=>({a:e.t(a.depict),b:e.t(a.legalBasis),c:k.value===a.id?1:"",d:a.id,e:e.o((e=>(e=>{k.value=e.id,D.value=e.depict||e.keyword||""})(a)),a.id)}))),az:_.value},(_.value,{})):{},{ax:!_.value&&0===C.value.length,aA:e.o(N),aB:e.o((e=>z.value=!1)),aC:e.o(V),aD:e.o((e=>z.value=!1)),aE:e.p({show:z.value,mode:"center",round:"20",safeAreaInsetBottom:!1}),aF:e.o((e=>w.value=!1)),aG:e.o(B),aH:e.f(I.value,((a,l,t)=>e.e({a:a.color,b:e.t(a.name),c:T.value===a.id},(T.value,a.id,{}),{d:a.id,e:T.value===a.id?1:"",f:e.o((e=>T.value=a.id),a.id)}))),aI:0===I.value.length},(I.value.length,{}),{aJ:e.o((e=>w.value=!1)),aK:e.p({show:w.value,mode:"bottom",round:"20"}),aL:e.gei(a,"")})}}},u=e._export_sfc(o,[["__scopeId","data-v-a1b78696"]]);wx.createPage(u);