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

2 lines
5.5 KiB
JavaScript

"use strict";const a=require("../../common/vendor.js"),e=require("../../request/api.js"),l=require("../../utils/draftCache.js"),o=require("../../utils/useDraftCache.js"),t=require("../../components/hazard/hazardForm.js");if(!Array){(a.resolveComponent("u-radio")+a.resolveComponent("u-radio-group")+a.resolveComponent("up-textarea"))()}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")+u)();const u=()=>"../../components/hazard/HazardFormPopup.js",r={__name:"Inspectionresult",setup(u){const r=a.ref(""),n=a.ref(null),d=a.ref(null),i=a.ref(!1),s=a.ref(t.createEmptyHazardPayload()),v=a.reactive([{name:"正常",value:1,disabled:!1},{name:"异常",value:2,disabled:!1},{name:"不涉及",value:3,disabled:!1}]),c=a.ref(""),m=a.ref(""),h=a=>a?(!a.hazardPayload&&a.hazardFormData&&(a.hazardPayload={formData:a.hazardFormData,address:a.hazardAddress||"",lng:a.hazardLng||0,lat:a.hazardLat||0,areaId:"",areaName:"",fileList:a.hazardFileList||[]}),{radiovalue1:a.radiovalue1||"",value1:a.value1||"",hazardPayload:a.hazardPayload||t.createEmptyHazardPayload()}):{radiovalue1:"",value1:"",hazardPayload:t.createEmptyHazardPayload()},{showRestoreBanner:f,clear:p,restore:y,bindAutoSave:g}=o.useDraftCache({getKey:()=>{var a;return l.buildDraftKey(l.DRAFT_NS.INSPECTION_RESULT,r.value,null==(a=n.value)?void 0:a.currentIndex)},getPayload:()=>({radiovalue1:c.value,value1:m.value,hazardPayload:JSON.parse(JSON.stringify(s.value))}),hasContent:a=>{var e,l;const o=h(a),t=o.hazardPayload;return!!(o.radiovalue1||o.value1||(null==(e=t.formData)?void 0:e.title)||(null==(l=t.formData)?void 0:l.description)||t.fileList&&t.fileList.length>0)},applyPayload:e=>{const l=h(e);c.value=l.radiovalue1,m.value=l.value1,s.value=l.hazardPayload,a.nextTick$1((()=>{var a;null==(a=d.value)||a.applyPayload(l.hazardPayload)}))},clearForm:()=>{c.value="",m.value="",L()},canSave:()=>!!r.value,requireInitialized:!0});g((()=>[c.value,m.value,s.value]));const x=a=>{"异常"!==a&&L()},z=a=>{console.log("radioChange",a)},P=a.computed((()=>t.hasValidHazardPayload(s.value))),w=a.computed((()=>{if(!n.value)return 0;const a=n.value.currentIndex||1,e=n.value.totalCount||1;return Math.round(a/e*100)})),D=()=>{i.value=!0},T=()=>{i.value=!0},I=a=>{a&&(s.value=JSON.parse(JSON.stringify(a)))},L=()=>{var a;s.value=t.createEmptyHazardPayload(),null==(a=d.value)||a.resetForm()},k=async()=>{var l,o,u,r;if(!c.value)return void a.index.showToast({title:"请选择检查结果",icon:"none"});const i=v.find((a=>a.name===c.value)),h=i?i.value:null;if(h)if("异常"!==c.value||P.value)try{if(a.index.showLoading({title:"提交中..."}),"异常"===c.value&&P.value){const r=(null==(l=d.value)?void 0:l.getPayload())||s.value,i=t.buildHiddenDangerParams(r,{taskId:null==(o=n.value)?void 0:o.taskId,checkPointId:null==(u=n.value)?void 0:u.checkPointId}),v=await e.addHiddenDanger(i);if(0!==v.code)return a.index.hideLoading(),void a.index.showToast({title:v.msg||"新增隐患失败",icon:"none"})}const i={taskId:null==(r=n.value)?void 0:r.taskId,result:h,remark:m.value},v=await e.submitCheckResult(i);a.index.hideLoading(),0===v.code?(p(!1),v.data&&!0===v.data.allFinished?(a.index.showToast({title:"全部检查已完成",icon:"success"}),setTimeout((()=>{a.index.navigateBack()}),1500)):v.data&&v.data.nextTask?(a.index.showToast({title:"提交成功,进入下一题",icon:"success"}),C(),n.value=v.data.nextTask):(a.index.showToast({title:"提交成功",icon:"success"}),setTimeout((()=>{a.index.navigateBack()}),1500))):a.index.showToast({title:v.msg||"提交失败",icon:"none"})}catch(f){a.index.hideLoading(),console.error("提交失败:",f),a.index.showToast({title:"提交失败",icon:"none"})}else a.index.showToast({title:"请填写隐患信息",icon:"none"});else a.index.showToast({title:"请选择检查结果",icon:"none"})},C=()=>{c.value="",m.value="",L()};return a.onLoad((a=>{a.id&&(r.value=a.id,(async()=>{try{const a=await e.enterCheckPlan(r.value);0===a.code&&(n.value=a.data,y())}catch(a){console.error(a)}})())})),(e,l)=>{var o,u,r,h;return a.e({a:n.value},n.value?{b:a.t(n.value.currentIndex||1),c:a.t(n.value.totalCount||1),d:w.value+"%"}:{},{e:a.t((null==(o=n.value)?void 0:o.name)||"加载中..."),f:(null==(u=n.value)?void 0:u.point)||"",g:a.f(v,((e,l,o)=>({a:l,b:a.o(z,l),c:"c5c09ac6-1-"+o+",c5c09ac6-0",d:a.p({customStyle:{marginBottom:"8px"},label:e.name,name:e.name})}))),h:a.o(x),i:a.o((a=>c.value=a)),j:a.p({placement:"row",modelValue:c.value}),k:"异常"===c.value},"异常"===c.value?a.e({l:!P.value},P.value?a.e({n:a.t(s.value.formData.title),o:a.t(null==(r=a.unref(t.LEVEL_OPTIONS)[s.value.formData.level])?void 0:r.title),p:0===s.value.formData.level?1:"",q:1===s.value.formData.level?1:"",r:2===s.value.formData.level?1:"",s:a.t((null==(h=a.unref(t.SOURCE_OPTIONS)[s.value.formData.source])?void 0:h.title)||"-"),t:a.t(s.value.formData.hazardSourceName||"-"),v:a.t(s.value.address||"-"),w:a.t(s.value.formData.description||"-"),x:s.value.fileList.length>0},s.value.fileList.length>0?{y:a.t(s.value.fileList.length)}:{},{z:a.o(T),A:a.o(L)}):{m:a.o(D)}):{},{B:a.o((a=>m.value=a)),C:a.p({placeholder:"请输入备注信息",modelValue:m.value}),D:a.o(k),E:a.sr(d,"c5c09ac6-3",{k:"hazardFormRef"}),F:a.o(I),G:a.o((e=>a.unref(p)(!0))),H:a.o((a=>i.value=a)),I:a.o((a=>s.value=a)),J:a.p({title:"填写隐患信息",mode:"collect","body-height":"60vh","show-draft-banner":a.unref(f),show:i.value,modelValue:s.value}),K:a.gei(e,"")})}}},n=a._export_sfc(r,[["__scopeId","data-v-c5c09ac6"]]);wx.createPage(n);