import{o as N}from"./index.a42041f7.js";import{r as m,a as o,j as e}from"./react.b0bedc10.js";import{b as f,f as S,F as b,B as x,T as d,e as D}from"./zarm.80120c4d.js";import{s as t}from"./Form.module.f0e327b6.js";import"./index.87202aac.js";import{a as w,u as A,L as $}from"./index.a3f0fe79.js";import{F as k}from"./Fetch.e6ea9900.js";import{M as y}from"./md5.171e6df9.js";import{s as r}from"./index.9b0ee734.js";import{F as j}from"./Plus.92b0b989.js";import{F as _}from"./Close.c1c6d2c9.js";import"./Patrol.49bc16dd.js";import"./Project.fe0152f3.js";const M=()=>{document.title="\u968F\u624B\u62CD\u9690\u60A3";const{state:u}=w(),h=A(),[v,z]=m.exports.useState(!1),n=m.exports.useMemo(()=>r.ItemStore.selectedItems,[r.ItemStore.selectedItems]),p=m.exports.useMemo(()=>r.ItemStore.content,[r.ItemStore.content]),c=m.exports.useMemo(()=>r.ItemStore.files,[r.ItemStore.files]),B=s=>{const i=c.concat(s);if(i.length>4){d.show("\u6700\u591A\u53EA\u80FD\u4E0A\u4F20\u56DB\u5F20\u7167\u7247");return}r.ItemStore.setFiles(i)},E=s=>{const i=[].concat(c);i.splice(s,1),r.ItemStore.setFiles(i)},g=async()=>{if(!p)return d.show("\u8BF7\u586B\u5199\u68C0\u67E5\u60C5\u51B5");const s=new FormData,i=y.hashStr(`${u.projectId}|${u.room.roomId}`);if(s.append("remark",p),s.append("is_create","1"),s.append("anon_submit_token",i),c.map((a,l)=>{s.append(`file${l}item`,a.file)}),n&&n.length){let a="";n.map((l,I)=>{I==0?a=`${l}`:a=`${a},${l}`}),s.append("items",a)}const F=await k.post({url:`/project/${u.projectId}/room/${u.room.roomId}/record`,form:s});F.code==200?(d.show("\u63D0\u4EA4\u6210\u529F"),r.ItemStore.setContent(""),r.ItemStore.setFiles([]),r.ItemStore.setSelectedItems([]),h(-1)):d.show(F.msg)},C=()=>c.map((s,i)=>e(D,{style:{margin:"5px 0px",width:"10px",height:"10px"},shape:"circle",text:e("span",{className:t.close,children:e(_,{size:"sm",onClick:()=>E(i)})}),children:e("div",{children:e("a",{href:s.thumbnail,target:"_blank",rel:"noopener noreferrer",children:e("img",{style:{padding:"5px",width:"60px",height:"60px"},src:s.thumbnail,alt:""})})})},+i));return o("div",{className:t.body,children:[e(f,{className:t.info,title:o("div",{children:[e("div",{className:t.title,children:u.room.name||"--"}),o("div",{className:t.des,children:[o("div",{children:["\u6240\u5C5E\u697C\u5B87\uFF1A",u.room.campus," - ",u.room.building]}),o("div",{children:["\u623F\u95F4\u8D1F\u8D23\u4EBA\uFF1A",u.room.owner||"--"]}),o("div",{children:["\u8054\u7CFB\u7535\u8BDD\uFF1A",u.room.ownerPhone||"--"]})]})]})}),o("div",{className:t.operation,children:[o("div",{className:t.middle,children:[e("div",{className:t.content,children:"* \u68C0\u67E5\u60C5\u51B5"}),e(S,{className:t.input,rows:5,type:"text",placeholder:"\u8BF7\u8F93\u5165\u9690\u60A3\u63CF\u8FF0\uFF1B\u82E5\u60A8\u65B9\u4FBF\u8BF7\u4E00\u5E76\u5F55\u5165\u60A8\u7684\u59D3\u540D\u3001\u7535\u8BDD\uFF0C\u4FBF\u4E8E\u540E\u7EED\u6838\u5B9E\u8054\u7CFB",value:p,onChange:r.ItemStore.setContent}),e("div",{className:t.content,children:"\u73B0\u573A\u7167\u7247"}),o("div",{className:t.img,children:[e("div",{children:C()}),e("div",{children:c.length<4&&e(f,{className:t.file,children:e(b,{multiple:!0,accept:"image/*",onChange:B,children:e(j,{size:"sm",style:{color:"rgb(192, 189, 189)"}})})})})]})]}),o("div",{className:t["operation-other"],children:[e("div",{className:t.content,children:"\u5173\u8054\u68C0\u67E5\u9879"}),o("div",{className:t.item,children:[o("div",{className:t.total,children:["\u5DF2\u9009\u62E9",n&&n.length||0,"\u6761\u5173\u8054\u9879\u76EE"]}),e(x,{size:"xs",theme:"primary",className:t.button,onClick:()=>{h(`/item-selector/${u.projectId}`)},children:"\u9009\u62E9\u68C0\u67E5\u9879"})]})]})]}),e("div",{className:t.button_bar,children:e("div",{onClick:g,className:t.button_1,children:"\u63D0\u4EA4"})}),v&&e($,{})]})};var W=N(M);export{W as default};
