import{l as e,$ as a,z as l,x as s,L as t,a2 as i,d as o,A as n,_ as u}from"./utils-lib.js?v=20260328163632";import{k as d,Y as r,r as c,x as p,O as v,o as m,U as f,V as g,W as C,X as h,N as b,a3 as y,j as w,Z as x,l as _,a2 as V,ao as k,ap as P,c as j,_ as L,s as U}from"./base-lib.js?v=20260328163632";import{B as E}from"./index84.js?v=20260328163632";import{A as q,b as B,B as O,v as S,w as z,n as A}from"./naive-ui.js?v=20260328163632";const D={class:"p-[20px]"},M={class:"flex items-center w-full"},$={class:"flex-1"},I={class:"p-[20px]"},N={class:"mt-[8px] bt-tips-ul leading-8 text-[12px] list-disc"},W=d({__name:"class-manage",props:{compData:{default:()=>({ignore:[],getClassList:()=>Promise.resolve([]),addClass:()=>Promise.resolve({}),editClass:()=>Promise.resolve({}),deleteClass:()=>Promise.resolve({}),updateOptions:()=>Promise.resolve([]),field:"ps",showEdit:!0})}},setup(n){const u=n,{getClassList:d,addClass:k,editClass:P,deleteClass:j,ignore:L,field:U,updateOptions:A,showEdit:W}=r(u.compData),X=c(""),Y=c(""),Z=c(!1),F=c(!1),G=p({label:"",value:0}),H=o(),J=c({columns:[{title:e("分类名称"),key:"label",ellipsis:{tooltip:!0}},{title:e("操作"),key:"action",align:"right",titleAlign:"right",render:a=>"all"===a.value||(null==L?void 0:L.includes("".concat(a.value)))?e("不可操作"):v("div",{class:"flex items-center justify-end"},[W&&v("span",{class:"flex items-center"},[v("span",{class:"bt-link",onClick:()=>ee(a)},[e("编辑")]),v(q,{vertical:!0},null)]),v("span",{class:"bt-link",onClick:()=>le(a)},[e("删除")])])}],data:[]}),[K,Q]=a(J),R=async()=>{try{Z.value=!0;const e=await d();J.value.data=e||[],A&&A(J.value.data)}catch(e){}finally{Z.value=!1}},T=async()=>{try{if(!X.value)return H.error(e("请输入分类名称"));const a={[U]:X.value},l=await s({loading:e("正在添加分类，请稍后..."),request:k(a)});se(l),X.value=""}catch(a){}},ee=e=>{F.value=!0,G.value=e,Y.value=e.label},ae=async()=>{try{const a={[U]:Y.value,id:G.value.value},l=await s({loading:e("正在编辑分类，请稍后..."),request:P(a)});l.status&&(F.value=!1),Y.value="",se(l)}catch(a){}},le=async a=>{try{await l({title:e("提示"),content:e("确认删除该分类吗？该分类下的所有数据将会被移动至全部分类下，是否继续？")});const t=await s({loading:e("正在删除分类，请稍后..."),request:j({id:a.value})});se(t)}catch(t){}},se=e=>{e.status&&R(),H.request(e)};return m((()=>{R()})),(a,l)=>{const s=B,o=O,n=S,u=z,d=f("bt-loading");return g(),C("div",D,[h("div",M,[h("div",$,[v(s,{value:r(X),"onUpdate:value":l[0]||(l[0]=e=>b(X)?X.value=e:null),placeholder:r(e)("请输入分类名称")},null,8,["value","placeholder"])]),v(o,{type:"primary",class:"ml-[1rem]",onClick:T},{default:y((()=>[w(x(r(e)("添加分类")),1)])),_:1})]),v(r(i),null,{"header-left":y((()=>l[4]||(l[4]=[]))),content:y((()=>[_(v(r(K),{"max-height":250},null,512),[[d,r(Z)]])])),popup:y((()=>[v(r(t),{modelValue:r(F),"onUpdate:modelValue":l[3]||(l[3]=e=>b(F)?F.value=e:null),area:400,title:r(e)("编辑分类"),"show-footer":"",onConfirm:ae},{default:y((()=>[h("div",I,[v(u,{onSubmit:l[2]||(l[2]=V((()=>{}),["prevent"])),"label-placement":"left"},{default:y((()=>[v(n,{label:r(e)("分类名称"),prop:"name"},{default:y((()=>[v(r(E),{modelValue:r(Y),"onUpdate:modelValue":l[1]||(l[1]=e=>b(Y)?Y.value=e:null),autofocus:"",placeholder:r(e)("请输入分类名称"),onSubmit:ae,width:"220"},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1})])])),_:1},8,["modelValue","title"])])),_:1}),h("ul",N,[h("li",null,x(r(e)("【批量操作-设置分类】可修改当前分类，仅具备批量操作的列表")),1)])])}}}),X=u(d({__name:"index",props:k({name:{default:"bt-table-type"},size:{default:"default"},options:{default:()=>[{label:"全部分类",value:"all"}]},ignore:{default:()=>[]},config:{default:()=>({getClassList:()=>Promise.resolve([]),addClass:()=>Promise.resolve(),editClass:()=>Promise.resolve(),deleteClass:()=>Promise.resolve(),field:"ps"})},field:{default:"ps"},showEdit:{type:Boolean,default:!0}},{modelValue:{default:()=>"all",type:String},modelModifiers:{}}),emits:k(["change","update:options"],["update:modelValue"]),setup(a,{expose:l,emit:s}){const t=a,i=s,o=P(a,"modelValue"),{getClassList:u,addClass:d,editClass:c,deleteClass:p}=r(t.config),v=j((()=>"all"!==o.value)),m=j((()=>"small"===t.size)),f=e=>{i("change",e)},C=async e=>{i("update:options",e),e.some((e=>e.value===o.value.toString()))||(o.value="all",f(o.value))},b=()=>{n({title:e("分类管理"),area:540,compData:{ignore:t.ignore,field:t.field,getClassList:u,addClass:d,editClass:c,deleteClass:p,updateOptions:C,showEdit:t.showEdit},component:W})};return l({setClassManage:b}),(a,l)=>{const s=A;return g(),L(s,U({value:o.value,"onUpdate:value":l[0]||(l[0]=e=>o.value=e),options:a.options,class:["w-140px",{"select-active":r(v),"!w-[11rem]":r(m)}],"menu-props":{class:"select-menu-active"}},a.$attrs,{"consistent-menu-width":!1,"onUpdate:value":f}),{action:y((()=>[h("div",{class:"select-type-line",onClick:b},x(r(e)("分类管理")),1)])),_:1},16,["value","options","class"])}}}),[["__scopeId","data-v-3e4489d7"]]);export{X as B};
