import{o as g}from"./index.a42041f7.js";import{r as d,a as n,j as c,F as N}from"./react.b0bedc10.js";import{R as u,f as S,T as p}from"./zarm.80120c4d.js";import{s as k}from"./index.9b0ee734.js";import{F as w}from"./Fetch.e6ea9900.js";import{a as F,u as C}from"./index.a3f0fe79.js";import"./Patrol.49bc16dd.js";import"./Project.fe0152f3.js";const E="_button_bar_1j7lc_12",I="_button_1_1j7lc_22",$="_button_2_1j7lc_33",J="_unity_pop_new_1j7lc_42",O="_unity_pop_1j7lc_42",A="_unity_check_1j7lc_66",x="_unity_check_2_1j7lc_73",B="_unity_choose_1j7lc_79",R="_unity_empty_1j7lc_98",G="_unity_close_1j7lc_108",T="_top_1j7lc_130",L="_list_1j7lc_145",P="_item_1j7lc_149",q="_title_1j7lc_153",z="_select_1j7lc_158",H="_remarks_1j7lc_162",K="_input_1j7lc_162";var o={"detail-cell":"_detail-cell_1j7lc_1",button_bar:E,button_1:I,button_2:$,unity_pop_new:J,unity_pop:O,unity_check:A,unity_check_2:x,unity_choose:B,unity_empty:R,unity_close:G,"schedule-detail":"_schedule-detail_1j7lc_126",top:T,list:L,item:P,title:q,select:z,remarks:H,input:K,"button-bar":"_button-bar_1j7lc_167"};const M=()=>{const{getScheduleDetail:b}=k.ProjectStore,{state:e}=F(),y=C(),[a,_]=d.exports.useState([]),[f,h]=d.exports.useState(void 0);d.exports.useEffect(()=>{(async()=>{const t=await b({},{projectID:e.ids.projectID,roomID:e.ids.roomID,periodID:e.ids.periodID});_(t)})()},[]),d.exports.useEffect(()=>{if(a.length){let t=!0;a.map((s,l)=>{l!=a.length-1&&s.result!=a[l+1].result&&(t=!1)}),h(t?a[0].result:void 0)}},[a]);const m=async t=>{const s=new FormData;if(s.append("submit",t),console.log(a),t=="1"&&a.some((i,r)=>i.result==null||i.result=="")){p.show("\u5B58\u5728\u672A\u9009\u62E9\u7684\u68C0\u67E5\u9879");return}a.map((i,r)=>{s.append(`items[${r}][item_id]`,i.id||""),s.append(`items[${r}][result]`,i.result||""),s.append(`items[${r}][desc]`,i.desc||""),s.append(`items[${r}][status]`,i.status||"")}),(await w.post({url:`/safe/project/${e.ids.projectID}/room/${e.ids.roomID}/period/${e.ids.periodID}`,form:s})).code==200&&(t=="0"?p.show("\u4FDD\u5B58\u6210\u529F"):(p.show("\u63D0\u4EA4\u6210\u529F"),y(-1)))},j=(t,s)=>{let l=JSON.parse(JSON.stringify(a));l[s].desc=t,_(l)},v=(t,s)=>{let l=JSON.parse(JSON.stringify(a));l[s].result=t,_(l)},D=t=>{let s=JSON.parse(JSON.stringify(a));s.map(l=>{l.disabled||(l.result=t)}),_(s)};return n("div",{className:o["schedule-detail"],children:[c("div",{className:o.top,children:n(u.Group,{block:!0,type:"button",value:f,onChange:t=>D(t),disabled:e.role=="admin-self"?e.isCharger?e.disabled:!0:e.disabled,children:[c(u,{value:"1",children:"\u5168\u90E8\u662F"}),c(u,{value:"0",children:"\u5168\u90E8\u5426"}),c(u,{value:"2",children:"\u5168\u90E8\u4E0D\u9002\u7528"})]})}),c("div",{className:o.list,children:a.length>0&&a.map((t,s)=>n("div",{className:o.item,children:[n("div",{className:o.title,children:[t.code,"\xA0",t.title]}),c("div",{className:o.select,children:n(u.Group,{block:!0,value:t.result,disabled:e.role=="admin-self"?e.isCharger?e.disabled:!0:e.disabled,onChange:l=>v(l,s),children:[c(u,{value:"1",children:"\u662F"}),c(u,{value:"0",children:"\u5426"}),c(u,{value:"2",children:"\u4E0D\u9002\u7528"})]})}),c("div",{className:o.remarks,children:c(S,{className:o.input,rows:3,type:"text",placeholder:"\u8BF7\u8F93\u5165\u5907\u6CE8",value:t.desc,onChange:l=>j(l,s),disabled:e.role=="admin-self"?e.isCharger?e.disabled:!0:e.disabled})})]},+s))}),c("div",{className:o.button_bar,children:(e.role!="admin-self"||e.isCharger)&&!e.disabled&&n(N,{children:[c("div",{className:o.button_1,onClick:()=>m("1"),children:"\u63D0\u4EA4"}),c("div",{className:o.button_2,onClick:()=>m("0"),children:"\u4FDD\u5B58"})]})})]})};var te=g(M);export{te as default};
