import{d as G,r,z as H,c as f,a,w as s,a$ as J,br as K,B as b,b as o,q as Q,b3 as W,b4 as X,i as ee,h as c,aY as te,Z as L,b0 as ae,t as d,b1 as le,b2 as se,bc as oe,A as S,F as ne,j as ie,x as N,L as re,C as m,o as _}from"./index-DqVhJ65C.js";/* empty css                  *//* empty css                *//* empty css                      *//* empty css               *//* empty css                  *//* empty css                     *//* empty css                  *//* empty css                        *//* empty css                    */import"./el-tooltip-l0sNRNKZ.js";const de={class:"p-6"},ue={class:"mb-4 flex gap-2"},ce={class:"mt-4 flex justify-end"},pe={key:0,class:"flex flex-col h-full"},me={class:"mb-4 p-4 bg-gray-50 rounded"},_e={class:"font-bold text-lg mb-2"},ve={class:"text-gray-600"},ge={class:"mt-2 flex gap-4 text-sm text-gray-400"},fe={class:"flex-1 overflow-y-auto space-y-4 p-2 border-t border-b"},be={class:"text-xs opacity-70 mb-1"},ye={class:"whitespace-pre-wrap"},xe={class:"mt-4"},he={class:"flex justify-end gap-2 mt-2"},Pe=G({__name:"List",setup(we){const E=r([]),y=r(!1),x=r(1),T=r(20),B=r(0),h=r(""),w=r(!1),i=r(null),p=r(""),k=r(!1),v=async()=>{y.value=!0;try{const e=await b.get("/admin/ticket/list",{params:{page:x.value,limit:T.value,status:h.value}});e.code===0&&(E.value=e.data.data,B.value=e.data.total)}catch(e){console.error(e)}finally{y.value=!1}},C=async e=>{try{const t=await b.get(`/admin/ticket/detail/${e.id}`);t.code===0&&(i.value=t.data,p.value="",w.value=!0)}catch{m.error("获取详情失败")}},P=async()=>{if(!p.value)return m.warning("请输入内容");k.value=!0;try{await b.post("/admin/ticket/reply",{id:i.value.id,content:p.value}),m.success("回复成功"),p.value="",C(i.value)}catch(e){m.error(e.message)}finally{k.value=!1}},U=async()=>{try{await b.post("/admin/ticket/close",{id:i.value.id}),m.success("已关闭"),C(i.value)}catch(e){m.error(e.message)}},j=e=>["低","中","高"][e]||"普通",$=e=>["info","warning","danger"][e]||"",F=e=>["待处理","已回复","已关闭"][e]||"未知",I=e=>["danger","success","info"][e]||"";return H(()=>{v()}),(e,t)=>{const V=X,M=W,g=ee,u=ae,z=le,q=se,A=oe,O=J,R=re,Y=K,Z=te;return _(),f("div",de,[a(O,{shadow:"hover"},{default:s(()=>[o("div",ue,[a(M,{modelValue:h.value,"onUpdate:modelValue":t[0]||(t[0]=l=>h.value=l),placeholder:"状态筛选",clearable:"",onChange:v},{default:s(()=>[a(V,{label:"待处理",value:0}),a(V,{label:"已回复",value:1}),a(V,{label:"已关闭",value:2})]),_:1},8,["modelValue"]),a(g,{onClick:v},{default:s(()=>[...t[4]||(t[4]=[c("刷新",-1)])]),_:1})]),Q((_(),L(q,{data:E.value,stripe:"",border:""},{default:s(()=>[a(u,{prop:"id",label:"ID",width:"80"}),a(u,{prop:"title",label:"标题","min-width":"200","show-overflow-tooltip":""}),a(u,{label:"用户",width:"120"},{default:s(({row:l})=>{var n;return[c(d((n=l.user)==null?void 0:n.username),1)]}),_:1}),a(u,{prop:"priority",label:"优先级",width:"100"},{default:s(({row:l})=>[a(z,{type:$(l.priority)},{default:s(()=>[c(d(j(l.priority)),1)]),_:2},1032,["type"])]),_:1}),a(u,{prop:"status",label:"状态",width:"100"},{default:s(({row:l})=>[a(z,{type:I(l.status)},{default:s(()=>[c(d(F(l.status)),1)]),_:2},1032,["type"])]),_:1}),a(u,{prop:"create_time",label:"创建时间",width:"180"}),a(u,{label:"操作",width:"150",fixed:"right"},{default:s(({row:l})=>[a(g,{link:"",type:"primary",onClick:n=>C(l)},{default:s(()=>[...t[5]||(t[5]=[c("查看/回复",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[Z,y.value]]),o("div",ce,[a(A,{background:"",layout:"prev, pager, next",total:B.value,"current-page":x.value,"onUpdate:currentPage":t[1]||(t[1]=l=>x.value=l),"page-size":T.value,onCurrentChange:v},null,8,["total","current-page","page-size"])])]),_:1}),a(Y,{modelValue:w.value,"onUpdate:modelValue":t[3]||(t[3]=l=>w.value=l),title:"工单详情",size:"50%"},{default:s(()=>{var l;return[i.value?(_(),f("div",pe,[o("div",me,[o("h3",_e,d(i.value.title),1),o("p",ve,d(i.value.content),1),o("div",ge,[o("span",null,"用户: "+d((l=i.value.user)==null?void 0:l.username),1),o("span",null,"时间: "+d(i.value.create_time),1)])]),o("div",fe,[(_(!0),f(ne,null,ie(i.value.replies,n=>{var D;return _(),f("div",{key:n.id,class:N(["flex flex-col",n.is_admin?"items-end":"items-start"])},[o("div",{class:N(["max-w-[80%] rounded-lg p-3",n.is_admin?"bg-blue-100 text-blue-900":"bg-gray-100 text-gray-800"])},[o("div",be,d(n.is_admin?"管理员":((D=n.user)==null?void 0:D.username)||"用户")+" - "+d(n.create_time),1),o("div",ye,d(n.content),1)],2)],2)}),128))]),o("div",xe,[a(R,{modelValue:p.value,"onUpdate:modelValue":t[2]||(t[2]=n=>p.value=n),type:"textarea",rows:3,placeholder:"请输入回复内容..."},null,8,["modelValue"]),o("div",he,[i.value.status!==2?(_(),L(g,{key:0,type:"danger",plain:"",onClick:U},{default:s(()=>[...t[6]||(t[6]=[c("关闭工单",-1)])]),_:1})):S("",!0),a(g,{type:"primary",loading:k.value,onClick:P},{default:s(()=>[...t[7]||(t[7]=[c("发送回复",-1)])]),_:1},8,["loading"])])])])):S("",!0)]}),_:1},8,["modelValue"])])}}});export{Pe as default};
