2 lines
5.5 KiB
JavaScript
2 lines
5.5 KiB
JavaScript
"use strict";const e=require("../../common/vendor.js"),t=require("../../request/api.js");if(!Array){(e.resolveComponent("up-picker")+e.resolveComponent("up-textarea")+e.resolveComponent("u-popup"))()}Math||((()=>"../../uni_modules/uview-plus/components/u-picker/u-picker.js")+(()=>"../../uni_modules/uview-plus/components/u-textarea/u-textarea.js")+(()=>"../../uni_modules/uview-plus/components/u-popup/u-popup.js"))();const n={__name:"application",setup(n){const a=e.ref(!1),o=e.ref(!1),s=e.ref(""),i=e.ref(""),l=e.ref([["暂无数据"]]),r=e.ref([]),u=e.ref([]),d=e.ref(""),c=e.ref(!1),p=e.reactive({rectifyDeadline:"",responsibleDeptId:"",responsiblePerson:"",mainTreatmentContent:"",treatmentResult:"",selfVerifyContent:""}),v=async()=>{try{const e=await t.getMyWriteOffList();0===e.code&&e.data&&(u.value=e.data,console.log("销号申请列表:",e.data))}catch(e){console.error("获取销号申请列表失败:",e)}},f=()=>{y(),(async()=>{try{const e=await t.getAcceptanceList();if(0===e.code&&e.data){const t=e.data.records||e.data||[];r.value=t,t.length>0?l.value=[t.map((e=>e.title||e.hazardTitle||`隐患${e.hazardId}`))]:l.value=[["暂无可申请销号的隐患"]],console.log("可申请销号的隐患列表:",t)}}catch(e){console.error("获取可申请销号隐患列表失败:",e)}})(),a.value=!0},m=e=>{if(console.log("选择的隐患:",e),e.value&&e.value.length>0){s.value=e.value[0];const t=e.indexs[0],n=r.value[t];n&&(i.value=n.hazardId,(e=>{p.rectifyDeadline=e.deadline||"",d.value=e.deptName||"",p.responsiblePerson=e.rectifierName||"",p.responsibleDeptId=e.deptId||""})(n))}o.value=!1},y=()=>{s.value="",i.value="",d.value="",p.rectifyDeadline="",p.responsibleDeptId="",p.responsiblePerson="",p.mainTreatmentContent="",p.treatmentResult="",p.selfVerifyContent=""},h=async()=>{if(i.value){c.value=!0;try{const n=await t.getHiddenDangerDetail({hazardId:i.value});if(0!==n.code||!n.data)return void e.index.showToast({title:"获取隐患详情失败",icon:"none"});const a=n.data.assigns;if(!a||0===a.length||!a[0].rectify)return void e.index.showToast({title:"该隐患暂无整改记录",icon:"none"});const o=a[0].rectify.rectifyId,s=await t.getRectifyDetail({rectifyId:o});if(0!==s.code||!s.data)return void e.index.showToast({title:"获取整改详情失败",icon:"none"});const l=s.data.rectifyPlan;if(!l)return void e.index.showToast({title:"整改方案内容为空",icon:"none"});const r=await t.generateWriteoffContent({rectifyContent:l});0===r.code&&r.data?(p.mainTreatmentContent=r.data.mainContent||"",p.treatmentResult=r.data.completionContent||"",p.selfVerifyContent=r.data.selfInspection||"",e.index.showToast({title:"AI生成成功",icon:"success"})):e.index.showToast({title:r.msg||"AI生成失败",icon:"none"})}catch(n){console.error("AI生成销号方案失败:",n),e.index.showToast({title:"AI生成失败,请重试",icon:"none"})}finally{c.value=!1}}else e.index.showToast({title:"请先选择隐患",icon:"none"})},g=async()=>{if(!i.value)return void e.index.showToast({title:"请选择隐患",icon:"none"});const n={hazardId:Number(i.value),rectifyDeadline:p.rectifyDeadline||"",responsibleDeptId:Number(p.responsibleDeptId)||0,responsiblePerson:p.responsiblePerson||"",mainTreatmentContent:p.mainTreatmentContent||"",treatmentResult:p.treatmentResult||"",selfVerifyContent:p.selfVerifyContent||""};console.log("提交数据:",n);try{const o=await t.applyDelete(n);0===o.code?(e.index.showToast({title:"申请成功",icon:"success"}),a.value=!1,y(),v()):e.index.showToast({title:o.msg||"申请失败",icon:"none"})}catch(o){console.error("申请失败:",o),e.index.showToast({title:"请求失败",icon:"none"})}},w=e=>{const t=(null==e?void 0:e.verifyResultName)||"";return"待审核"===t?"status-pending":"审核通过"===t||"已通过"===t?"status-passed":"审核驳回"===t||"已驳回"===t?"status-rejected":"已重新申请"===t?"status-reapply":1===(null==e?void 0:e.verifyResult)?"status-passed":2===(null==e?void 0:e.verifyResult)?"status-rejected":"status-default"};return e.onMounted((()=>{v()})),(t,n)=>e.e({a:e.f(u.value,((t,n,a)=>({a:e.t(t.hazardTitle),b:e.t(t.verifyResultName||"未知"),c:e.n(w(t)),d:e.t(t.hazardCreatedAt),e:e.t(t.responsibleDeptName),f:e.t(t.responsiblePerson),g:e.t(t.createdAt),h:e.o((n=>(t=>{(null==t?void 0:t.id)?e.index.navigateTo({url:`/pages/closeout/editor?applyId=${t.id}`}):e.index.showToast({title:"缺少申请ID",icon:"none"})})(t)),t.hazardId||t.id),i:t.hazardId||t.id}))),b:e.o(f),c:e.o((e=>a.value=!1)),d:e.t(s.value||"请选择隐患"),e:e.n(s.value?"":"text-gray"),f:e.o((e=>o.value=!0))},{},{k:e.t(p.rectifyDeadline||"请先选择隐患"),l:e.n(p.rectifyDeadline?"":"text-gray"),m:e.t(d.value||"请先选择隐患"),n:e.n(d.value?"":"text-gray"),o:e.t(p.responsiblePerson||"请先选择隐患"),p:e.n(p.responsiblePerson?"":"text-gray"),q:!c.value},(c.value,{}),{r:e.t(c.value?"AI生成中...":"AI 生成销号方案"),s:c.value,t:c.value,v:e.o(h),w:e.o((e=>p.mainTreatmentContent=e)),x:e.p({placeholder:"请输入主要治理内容",modelValue:p.mainTreatmentContent}),y:e.o((e=>p.treatmentResult=e)),z:e.p({placeholder:"请输入隐患治理完成情况",modelValue:p.treatmentResult}),A:e.o((e=>p.selfVerifyContent=e)),B:e.p({placeholder:"请输入隐患治理责任单位自行验收的情况",modelValue:p.selfVerifyContent}),C:e.o((e=>a.value=!1)),D:e.o(g),E:e.o((e=>a.value=!1)),F:e.p({show:a.value,mode:"center",round:"20",safeAreaInsetBottom:!1}),G:e.o(m),H:e.o((e=>o.value=!1)),I:e.o((e=>o.value=!1)),J:e.p({show:o.value,columns:l.value}),K:e.gei(t,"")})}},a=e._export_sfc(n,[["__scopeId","data-v-310af818"]]);wx.createPage(a);
|