Files
threeonecheck_web/unpackage/dist/build/mp-weixin/pages/Inspectionresult/Inspectionresult.js
2026-05-03 09:08:56 +08:00

2 lines
9.3 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"),l=require("../../request/api.js"),a=require("../../request/request.js"),o=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-upload")+e.resolveComponent("up-input")+e.resolveComponent("up-choose")+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-upload/u-upload.js")+(()=>"../../uni_modules/uview-plus/components/u-input/u-input.js")+(()=>"../../uni_modules/uview-plus/components/u-choose/u-choose.js")+(()=>"../../uni_modules/uview-plus/components/u-popup/u-popup.js"))();const t={__name:"Inspectionresult",setup(t){const n=e.ref(""),u=e.ref(null),i=e.reactive([{name:"正常",value:1,disabled:!1},{name:"异常",value:2,disabled:!1},{name:"不涉及",value:3,disabled:!1}]),s=e.ref(""),r=e=>{console.log("groupChange",e),"异常"!==e&&z()},d=e=>{console.log("radioChange",e)},c=e.ref(""),v=e.ref(!1),p=e.reactive({title:"",level:0,source:0,description:"",tagIndex:0}),m=e.ref(""),h=e.ref(0),g=e.ref(0),f=e.ref(!1),x=e.ref([]),w=e.ref(""),I=e.ref(""),T=e.ref(""),y=()=>{if(T.value){w.value=T.value;const e=x.value.find((e=>e.id===T.value));I.value=e?e.name:""}f.value=!1},b=e.ref([]),k=e.ref(null),C=e.ref(!1),j=e.computed((()=>p.title&&b.value.length>0)),_=e.computed((()=>{if(!u.value)return 0;const e=u.value.currentIndex||1,l=u.value.totalCount||1;return Math.round(e/l*100)})),A=e.ref([{id:1,title:"轻微隐患"},{id:2,title:"一般隐患"},{id:3,title:"重大隐患"}]),L=e.ref([{id:1,title:"随手拍"},{id:2,title:"企业自查"},{id:3,title:"行业互查"},{id:4,title:"专家诊查"}]),q=e.ref([]),P=()=>{v.value=!0},V=()=>{v.value=!0},z=()=>{p.title="",p.level=0,p.source=0,p.description="",p.tagIndex=0,m.value="",h.value=0,g.value=0,b.value=[],w.value="",I.value=""},M=()=>{0!==b.value.length?p.title?m.value?p.description?(v.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"})},$=()=>{v.value=!1,setTimeout((()=>{e.index.chooseLocation({success:e=>{m.value=e.address+(e.name?`(${e.name})`:""),h.value=e.longitude,g.value=e.latitude,v.value=!0},fail:l=>{v.value=!0,l.errMsg&&-1===l.errMsg.indexOf("cancel")&&e.index.showToast({title:"选择位置失败",icon:"none"})}})}),300)},B=e=>{b.value.splice(e.index,1)},H=async e=>{let l=[].concat(e.file),o=b.value.length;l.map((e=>{b.value.push({...e,status:"uploading",message:"上传中"})}));for(let t=0;t<l.length;t++){const e=await S(l[t].url);let n=b.value[o];const u="string"==typeof e?e:(null==e?void 0:e.url)||(null==e?void 0:e.path)||"";b.value.splice(o,1,{...n,status:"success",message:"",url:a.baseUrl.replace("/prod-api","")+u,serverPath:u}),o++}},S=l=>new Promise(((o,t)=>{e.index.uploadFile({url:a.baseUrl+"/frontend/attachment/upload",filePath:l,name:"file",header:{Authorization:a.getToken()},success:e=>{const l=JSON.parse(e.data);0===l.code?o(l.data):t(l.msg||"上传失败")},fail:e=>{console.error("上传失败:",e),t(e)}})})),U=async()=>{const a=b.value.filter((e=>"success"===e.status&&e.url.toLowerCase().match(/\.(jpg|jpeg|png|gif|bmp|webp)$/)));if(0===a.length)return void e.index.showToast({title:"请先上传隐患图片",icon:"none"});const o=a[0].url;C.value=!0;try{console.log("开始调用AI分析接口图片地址:",o);const a=await l.analyzeHazardImage({imageUrl:o});if(0===a.code&&a.data){const l=a.data;if(console.log("AI分析结果:",l),l.title&&(p.title=l.title),l.description&&(p.description=l.description),l.level){const a={"轻微":0,"轻微隐患":0,"一般":1,"一般隐患":1,"重大":2,"重大隐患":2}[l.level];void 0!==a&&(p.level=a,e.nextTick$1((()=>{k.value&&k.value.$data&&(k.value.$data.currentIndex=a)})))}e.index.showToast({title:"AI分析完成已自动填充",icon:"success",duration:2e3})}else e.index.showToast({title:a.msg||"AI分析失败",icon:"none"})}catch(t){console.error("AI分析接口调用失败:",t),e.index.showToast({title:"AI分析失败请重试",icon:"none"})}finally{C.value=!1}},D=async()=>{var a,o,t,n;if(!s.value)return void e.index.showToast({title:"请选择检查结果",icon:"none"});const r=i.find((e=>e.name===s.value)),d=r?r.value:null;if(d)if("异常"!==s.value||j.value)try{if(e.index.showLoading({title:"提交中..."}),"异常"===s.value&&j.value){const n=b.value.map((e=>{let l="";"string"==typeof e.url?l=e.url:e.url&&"object"==typeof e.url&&(l=e.url.url||e.url.path||"");return{fileName:("string"==typeof l&&l?l.split("/").pop():e.name||"")||"",filePath:l||"",fileType:e.type||"image/png",fileSize:e.size||0}})),i=q.value[p.tagIndex],s=i?i.id:null,r={taskId:null==(a=u.value)?void 0:a.taskId,checkPointId:null==(o=u.value)?void 0:o.checkPointId,title:p.title,level:p.level+1,lng:h.value||0,lat:g.value||0,address:m.value||"",areaId:w.value||null,description:p.description||"",source:(null==(t=L.value[p.source])?void 0:t.title)||"",tagId:s,attachments:n};console.log("隐患参数:",r);const d=await l.addHiddenDanger(r);if(0!==d.code)return e.index.hideLoading(),void e.index.showToast({title:d.msg||"新增隐患失败",icon:"none"});console.log("新增隐患成功")}const i={taskId:null==(n=u.value)?void 0:n.taskId,result:d,remark:c.value};console.log("提交参数:",i);const r=await l.submitCheckResult(i);e.index.hideLoading(),0===r.code?r.data&&!0===r.data.allFinished?(e.index.showToast({title:"全部检查已完成",icon:"success"}),setTimeout((()=>{e.index.navigateBack()}),1500)):r.data&&r.data.nextTask?(e.index.showToast({title:"提交成功,进入下一题",icon:"success"}),F(),u.value=r.data.nextTask):(e.index.showToast({title:"提交成功",icon:"success"}),setTimeout((()=>{e.index.navigateBack()}),1500)):e.index.showToast({title:r.msg||"提交失败",icon:"none"})}catch(v){e.index.hideLoading(),console.error("提交失败:",v),e.index.showToast({title:"提交失败",icon:"none"})}else e.index.showToast({title:"请填写隐患信息",icon:"none"});else e.index.showToast({title:"请选择检查结果",icon:"none"})},F=()=>{s.value="",c.value="",z()};return e.onLoad((e=>{console.log("接收到的参数:",e),e.id&&(n.value=e.id,(async()=>{try{const e=await l.enterCheckPlan(n.value);console.log("检查项数据:",e),0===e.code&&(u.value=e.data)}catch(e){console.error(e)}})()),(async()=>{try{const e=await l.getHiddenDangerLabelList();0===e.code&&(q.value=e.data.map((e=>({id:e.id,title:e.name}))))}catch(e){console.error("获取标签列表失败:",e)}})(),(async()=>{try{const e=await o.getAreaList();0===e.code&&e.data&&e.data.records&&(x.value=e.data.records)}catch(e){console.error("获取区域列表失败:",e)}})()})),(l,a)=>{var o,t,n,h;return e.e({a:u.value},u.value?{b:e.t(u.value.currentIndex||1),c:e.t(u.value.totalCount||1),d:_.value+"%"}:{},{e:e.t((null==(o=u.value)?void 0:o.name)||"加载中..."),f:(null==(t=u.value)?void 0:t.point)||"",g:e.f(i,((l,a,o)=>({a:a,b:e.o(d,a),c:"93e4c0d1-1-"+o+",93e4c0d1-0",d:e.p({customStyle:{marginBottom:"8px"},label:l.name,name:l.name})}))),h:e.o(r),i:e.o((e=>s.value=e)),j:e.p({placement:"row",modelValue:s.value}),k:"异常"===s.value},"异常"===s.value?e.e({l:!j.value},j.value?e.e({n:e.t(p.title),o:e.t(null==(n=A.value[p.level])?void 0:n.title),p:0===p.level?1:"",q:1===p.level?1:"",r:2===p.level?1:"",s:e.t((null==(h=L.value[p.source])?void 0:h.title)||"-"),t:e.t(m.value||"-"),v:e.t(p.description||"-"),w:b.value.length>0},b.value.length>0?{x:e.t(b.value.length)}:{},{y:e.o(V),z:e.o(z)}):{m:e.o(P)}):{},{A:e.o((e=>c.value=e)),B:e.p({placeholder:"请输入备注信息",modelValue:c.value}),C:e.o(D),D:e.o((e=>v.value=!1)),E:e.o(H),F:e.o(B),G:e.p({fileList:b.value,name:"1",multiple:!0,maxCount:10}),H:!C.value},(C.value,{}),{I:e.t(C.value?"AI识别中...":"AI 识别隐患"),J:C.value,K:C.value,L:e.o(U),M:e.o((e=>p.title=e)),N:e.p({placeholder:"请输入内容",border:"surround",modelValue:p.title}),O:e.sr(k,"93e4c0d1-6,93e4c0d1-3",{k:"levelChooseRef"}),P:e.o((e=>p.level=e)),Q:e.p({options:A.value,wrap:!1,"item-width":"183rpx","item-height":"72rpx",modelValue:p.level}),R:e.o((e=>p.source=e)),S:e.p({options:L.value,wrap:!1,"item-width":"183rpx","item-height":"72rpx",modelValue:p.source}),T:e.o((e=>m.value=e)),U:e.p({placeholder:"请输入地址",border:"surround",modelValue:m.value}),V:e.o($),W:e.t(I.value||"请选择隐患区域"),X:I.value?"":1,Y:e.o((e=>f.value=!0)),Z:e.o((e=>p.description=e)),aa:e.p({placeholder:"请输入内容",modelValue:p.description}),ab:e.o((e=>p.tagIndex=e)),ac:e.p({options:q.value,modelValue:p.tagIndex}),ad:e.o((e=>v.value=!1)),ae:e.o(M),af:e.o((e=>v.value=!1)),ag:e.p({show:v.value,mode:"center",round:"20"}),ah:e.o((e=>f.value=!1)),ai:e.o(y),aj:e.f(x.value,((l,a,o)=>e.e({a:l.color,b:e.t(l.name),c:T.value===l.id},(T.value,l.id,{}),{d:l.id,e:T.value===l.id?1:"",f:e.o((e=>T.value=l.id),l.id)}))),ak:0===x.value.length},(x.value.length,{}),{al:e.o((e=>f.value=!1)),am:e.p({show:f.value,mode:"bottom",round:"20"}),an:e.gei(l,"")})}}},n=e._export_sfc(t,[["__scopeId","data-v-93e4c0d1"]]);wx.createPage(n);