import{h as D,s as F,i as G,e as T,g as q}from"./index-bc9666b7.js";import{S as y}from"./index-c238f14b.js";import{_ as L}from"./index-b1d3d9b0.js";import{f as U,r as v,bn as A,bw as E,bo as r,D as I,aW as c,aX as b,b3 as i,b4 as o,a$ as n,b0 as h,b1 as f,b2 as t,ac as m,a_ as k,ao as R,bq as W,bC as P,bd as X,aZ as Z}from"./index-7e19b821.js";import{d as j,a as H,N as J}from"./index-2b595d91.js";import"./_plugin-vue_export-helper-c27b6911.js";const K={class:"h-full"},O={class:"p-2"},Q={class:"overflow-auto w-full mt-[20px] bg-slate-200 dark:bg-zinc-900 rounded-xl",style:{height:"calc(100% - 65px)"}},Y={class:"flex items-center"},ee={class:"mr-[10px]"},se={class:"ml-auto"},le={class:"ml-[10px]"},de=U({__name:"index",setup(ae){const x=v(null),p=A(),S=E(),u=v(!1),w={title:"",icon:"material-symbols:folder-outline",sort:9999},a=v({show:!1,editStatus:1,model:w,rules:{title:[{required:!0,trigger:"blur",message:r("form.required")}]}}),d=v([]);function C(){a.value.show=!a.value.show}function z(s){a.value.show=!0,a.value.model=s,a.value.editStatus=2}function N(){u.value=!0}function $(){const s=[];for(let e=0;e<d.value.length;e++){const l=d.value[e];s.push({id:l.id,sort:e+1})}F(s).then(({code:e,msg:l})=>{e===0?(p.success(r("common.saveSuccess")),u.value=!1):p.error(`${r("common.saveFail")}:${l}`)})}function M(s){S.warning({title:r("common.warning"),content:r("apps.itemGroupManage.deleteWarnText",{name:s.title}),positiveText:r("common.confirm"),negativeText:r("common.cancel"),onPositiveClick:()=>{s.id&&G([s.id]).then(({code:e,msg:l})=>{e!==0?p.error(r("common.deleteFail")):g()})}})}function V(){var s;(s=x.value)==null||s.validate(e=>{e?console.log(e):T(a.value.model).then(({code:l,msg:_})=>{l!==0&&p.error(_),g(),a.value.show=!1,a.value.model={...w}})})}function g(){q().then(({code:s,data:e})=>{d.value=e.list})}return I(()=>{g()}),(s,e)=>(c(),b("div",K,[i("div",O,[o(t(m),{type:"success",size:"small",style:{"margin-right":"10px"},onClick:C},{default:n(()=>[h(f(s.$t("common.add")),1)]),_:1}),u.value?(c(),k(t(m),{key:1,type:"warning",size:"small",onClick:$},{default:n(()=>[h(f(s.$t("common.saveSort")),1)]),_:1})):(c(),k(t(m),{key:0,size:"small",onClick:N},{default:n(()=>[h(f(s.$t("common.sort")),1)]),_:1}))]),i("div",Q,[o(t(D),{modelValue:d.value,"onUpdate:modelValue":e[0]||(e[0]=l=>d.value=l),"item-key":"sort",animation:300,style:Z({padding:u.value?"20px":"10px"}),disabled:!u.value},{default:n(()=>[(c(!0),b(R,null,W(d.value,(l,_)=>(c(),b("div",{key:_,class:"w-full"},[o(t(P),{size:"small",style:{"border-radius":"10px","margin-bottom":"10px"}},{default:n(()=>[i("div",{class:X(["flex",u.value?"cursor-move":""])},[i("div",Y,[i("span",ee,[o(t(y),{class:"text-[20px]",icon:"material-symbols:ad-group-outline-rounded"})]),i("span",null,f(l.title),1)]),i("div",se,[i("span",null,[o(t(m),{strong:"",secondary:"",type:"success",size:"small",onClick:B=>z(l)},{icon:n(()=>[o(t(y),{icon:"basil:edit-solid"})]),_:2},1032,["onClick"])]),i("span",le,[o(t(m),{strong:"",secondary:"",type:"error",size:"small",class:"ml-[10px]",onClick:B=>M(l)},{icon:n(()=>[o(t(y),{icon:"material-symbols:delete"})]),_:2},1032,["onClick"])])])],2)]),_:2},1024)]))),128))]),_:1},8,["modelValue","style","disabled"])]),o(t(L),{show:a.value.show,"onUpdate:show":e[2]||(e[2]=l=>a.value.show=l),size:"small",type:"small",title:a.value.editStatus===1?"添加":"编辑",style:{width:"400px"}},{footer:n(()=>[o(t(m),{type:"success",size:"small",class:"float-right",onClick:V},{default:n(()=>[h(f(s.$t("common.confirm")),1)]),_:1})]),default:n(()=>[o(t(j),{ref_key:"formRef",ref:x,model:a.value.model,rules:a.value.rules},{default:n(()=>[o(t(H),{path:"title",label:s.$t("apps.itemGroupManage.groupName")},{default:n(()=>[o(t(J),{value:a.value.model.title,"onUpdate:value":e[1]||(e[1]=l=>a.value.model.title=l),type:"text",maxlength:20,"show-count":""},null,8,["value"])]),_:1},8,["label"])]),_:1},8,["model","rules"])]),_:1},8,["show","title"])]))}});export{de as default};
