import{o as C,r,a as $,j as t}from"./react.e658030c.js";import{I as w,S as L}from"./zarm.5a521378.js";import{U as u,L as D}from"./List.d63dc7db.js";import{s as F}from"./index.5596e121.js";import{b as N,u as z,L as I}from"./index.52024c57.js";import{l as M}from"./lodash.fa27d04d.js";import"./Fetch.aadb98ec.js";import"./Project.b97a5292.js";import"./Empty.350ce403.js";import"./moment.40bc58bf.js";const T="_button_bar_1fjb8_12",U="_button_1_1fjb8_22",V="_button_2_1fjb8_33",q="_unity_pop_new_1fjb8_42",G="_unity_pop_1fjb8_42",H="_unity_check_1fjb8_66",J="_unity_check_2_1fjb8_73",K="_unity_choose_1fjb8_79",O="_unity_empty_1fjb8_98",Q="_unity_close_1fjb8_108",R="_projects_1fjb8_126",W="_search_bar_1fjb8_130",X="_search_1fjb8_130",Y="_list_1fjb8_145",Z="_affix_1fjb8_149",ee="_circle_1fjb8_156",te="_pop_body_1fjb8_169";var i={"detail-cell":"_detail-cell_1fjb8_1",button_bar:T,button_1:U,button_2:V,unity_pop_new:q,unity_pop:G,unity_check:H,unity_check_2:J,unity_choose:K,unity_empty:O,unity_close:Q,projects:R,search_bar:W,search:X,list:Y,affix:Z,circle:ee,pop_body:te,"button-bar":"_button-bar_1fjb8_174"};const se=w.createFromIconfont("//at.alicdn.com/t/font_3322051_t57u0j0b1ek.js"),re=()=>{const{getProjects:j}=F.ProjectStore,s=N(),n=z(),[h,l]=r.exports.useState(""),[f,b]=r.exports.useState([]),[y,m]=r.exports.useState(""),[p,E]=r.exports.useState(""),[d,g]=r.exports.useState(!0);r.exports.useEffect(()=>{(async()=>{switch(s.role){case"self":document.title="\u5B9E\u9A8C\u5BA4\u81EA\u67E5",l("\u5B9E\u9A8C\u5BA4\u81EA\u67E5"),_({currentPage:1,pageSize:10,type:"0",refresh:!0});break;case"admin-self":document.title="\u5B9E\u9A8C\u5BA4\u81EA\u67E5",l("\u5B9E\u9A8C\u5BA4\u81EA\u67E5"),_({currentPage:1,pageSize:10,type:"0",refresh:!0});break;case"admin-specific":document.title="\u5B89\u5168\u5DE1\u67E5",l("\u5B89\u5168\u5DE1\u67E5"),_({currentPage:1,pageSize:10,type:"1,2",refresh:!0});break;case"inspector":document.title="\u6211\u8981\u68C0\u67E5",l("\u6211\u8981\u68C0\u67E5");const e=await u.getCurrentUser();e&&await _({currentPage:1,pageSize:10,type:"1,2",refresh:!0,currentUser:e});break}})()},[p]);const _=async({currentPage:e,pageSize:o,type:x,refresh:v,currentUser:P})=>{let c={};c.currentPage=e,c.pageSize=o,c.is_inspection=x,P&&(c.user_id=u.user.id),p&&(c.title=p);const a=await j(c);return(a==null?void 0:a.code)==200?(b(v?a.list:[...f,...a.list||[]]),m(a.total),g(!1),!0):!1},k=(e,o)=>{switch(e){case"\u5B9E\u9A8C\u5BA4\u81EA\u67E5":n(`/project-detail/${o.id}/${s.role}`);break;case"\u5B89\u5168\u5DE1\u67E5":n(`/project-detail/${o.id}/${s.role}`);break;case"\u8F96\u4E0B\u623F\u95F4":n(`/project-detail/${o.id}/${s.role}`);break;case"\u6211\u8981\u68C0\u67E5":n(`/project-detail/${o.id}/${s.role}`);break}},A=e=>{n(`/add-project/${e}`)},B=M.exports.debounce(e=>{E(e)},500),S=r.exports.useMemo(()=>{switch(s.role){case"admin-self":return!0;case"admin-specific":return!0;case"inspector":return u?!!(u.user.permissions&&u.user.permissions.includes("lsi-v1-edit-project")):!1}},[s.role,u.user]);return $("div",{className:i.projects,children:[d&&t(I,{}),t("div",{className:i.search_bar,children:t("div",{className:i.search,children:t(L,{shape:"rect",value:p,placeholder:"\u8BF7\u8F93\u5165\u9879\u76EE\u540D\u79F0",onChange:B})})}),t("div",{className:i.list,children:t(D,{loading:d,listData:f,total:y,type:h,getList:_,goDetail:k})}),S?t("div",{className:i.affix,children:t("div",{className:i.circle,onClick:()=>A(s.role),children:t(se,{type:"icon-plus"})})}):null]})};var be=C(re);export{be as default};
