2 lines
6.7 KiB
JavaScript
2 lines
6.7 KiB
JavaScript
import{_ as K}from"./brand-icon-COpT6LnI.js";import{I}from"./Icon-fSTUMLnE.js";import{a as O,b as p,X as Q}from"./model-DEZgUuUh.js";import{_ as U}from"./TooltipBtn.vue_vue_type_script_setup_true_lang-DGMw5LlU.js";import{u as X,d as W,a as x,p as m,w as o,r as u,o as i,q as N,m as a,c as d,f as y,e as c,t as w,A as _,k as b,g as V,h as Y,x as B,_ as Z}from"./index-BAVzA63z.js";import"./filters-BdLgkBz9.js";import"./index-DOvHH1wV.js";import"./icons-B-oOLPAt.js";function ee(){const $=X(),r=new O("admin/comments/list","لیست دیدگاه ها");return r.add(new p("product_id","شناسه محصول").filterNumber().hidden()),r.add(new p("product.title","نام محصول").filterNumber().renderSlot("productName")),r.add(new p("customer.id","شناسه نویسنده دیدگاه").filterNumber().hidden()),r.add(new p("customer","نام نویسنده ").filterText().renderSlot("customer")),r.add(new p("reply","پاسخ").renderSlot("reply").noSort()),r.add(new p("sts","وضعیت").renderSlot("sts").noSort()),$.roles&&$.roles.includes("comment.state")&&r.add(new p("changeState","تغییر وضعیت").renderSlot("changeState").noSort()),r.add(new p("opt","عملیات").noSort().renderSlot("opt")),r}const te={id:"page-user-list"},oe=["href"],ne=["onClick"],se=["onClick"],le={class:"flex"},ae={key:0,class:"comments-list"},me={class:"comment-item"},ie={class:"img"},re={class:"comment-body"},ue={class:"time"},de={class:"comment-item"},ce={class:"comment-body"},pe={key:0,class:"time"},_e=W({__name:"Comments",setup($){const r=X(),v=n=>!!r.hasPermission(n),D=ee(),S=b(null),l=b(void 0),k=b(!1),h=b(""),g=b(""),E=V(()=>{var n;return h.value!==(((n=l.value)==null?void 0:n.comment)??"")}),L=V(()=>{var n,e,s;return g.value!==(((s=(e=(n=l.value)==null?void 0:n.reply)==null?void 0:e[0])==null?void 0:s.comment)??"")});function P(n){var s,f;const e=String(((s=n.product)==null?void 0:s.title)??"").split(" ").join("-");return`${Y.siteUrl}/product/${e}/${(f=n.product)==null?void 0:f.id}`}async function T(n,e){var s;try{await B.post("comment/sts",{id:n,sts:e}),_.info("تغییرات ثبت شد "),(s=S.value)==null||s.fetch()}catch{_.error("خطا در تغییر وضعیت")}}function q(n){var e,s;l.value=n,h.value=n.comment??"",g.value=((s=(e=n.reply)==null?void 0:e[0])==null?void 0:s.comment)??"",k.value=!0}async function A(n){var e;try{await B.delete(`comment/${n}`),_.info("دیدگاه حذف شد"),(e=S.value)==null||e.fetch()}catch{_.error("خطا در حذف")}}async function M(n){var e;try{await B.post("comment",{product_id:n.product_id,customer_id:n.customer_id,comment:g.value,reply_to:n.id}),_.info("تغییرات ثبت شد "),k.value=!1,(e=S.value)==null||e.fetch()}catch{_.error("خطا در ثبت تغییرات")}}return(n,e)=>{const s=u("a-tag"),f=u("a-menu-item"),F=u("a-menu"),G=u("a-dropdown"),R=u("a-textarea"),j=u("a-form-item"),z=u("a-button"),H=u("a-modal"),J=u("a-card");return i(),x("div",te,[m(J,{title:"لیست دیدگاه ها",class:"page-card"},{default:o(()=>[m(Q,{ref_key:"tbl",ref:S,model:N(D),"mobile-cards":""},{customer:o(({text:t})=>[c(w(t&&t.fname&&t.lname?`${t.fname} ${t.lname}`:"بدون نام"),1)]),productName:o(({record:t})=>[a("a",{href:P(t),target:"_blank"},w(t.product.title),9,oe)]),sts:o(({text:t})=>[t==1?(i(),d(s,{key:0},{default:o(()=>[...e[6]||(e[6]=[c("در انتظار تایید",-1)])]),_:1})):t==2?(i(),d(s,{key:1,color:"green"},{default:o(()=>[...e[7]||(e[7]=[c("تایید شده",-1)])]),_:1})):(i(),d(s,{key:2,color:"red"},{default:o(()=>[...e[8]||(e[8]=[c("عدم تایید",-1)])]),_:1}))]),reply:o(({text:t})=>[t&&t.length>0&&t[0].comment!==null?(i(),d(s,{key:0,color:"green"},{default:o(()=>[...e[9]||(e[9]=[c(" پاسخ داده شده ",-1)])]),_:1})):(i(),d(s,{key:1},{default:o(()=>[...e[10]||(e[10]=[c("بدون پاسخ",-1)])]),_:1}))]),changeState:o(({record:t})=>[v("comment.state")?(i(),d(G,{key:0},{overlay:o(()=>[m(F,null,{default:o(()=>[m(f,null,{default:o(()=>[a("div",{onClick:C=>t.sts!==2?T(t.id,2):N(_).error("حالت فعلی تایید می باشد")}," تایید ",8,ne)]),_:2},1024),m(f,{class:"red"},{default:o(()=>[a("div",{onClick:C=>t.sts!==3?T(t.id,3):N(_).error("حالت فعلی عدم تایید می باشد")}," عدم تایید ",8,se)]),_:2},1024)]),_:2},1024)]),default:o(()=>[m(s,{style:{cursor:"pointer"},color:t.sts===1?"":t.sts===2?"green":t.sts===3?"red":"",onClick:e[0]||(e[0]=C=>C.preventDefault())},{default:o(()=>[c(w(t.sts===1?"در انتظار تایید":t.sts===2?"تایید":"عدم تایید")+" ",1),m(I,{icon:"vuesax-linear:arrow-down",size:"16"})]),_:2},1032,["color"])]),_:2},1024)):y("",!0)]),opt:o(({record:t})=>[a("div",le,[v("comment.view")?(i(),d(U,{key:0,"icon-class":"w-5 h-5 text-primary",class:"mr-3",icon:"EyeIcon",title:"مشاهده دیدگاه",onClick:C=>q(t)},null,8,["onClick"])):y("",!0),v("comment.remove")?(i(),d(U,{key:1,"icon-class":"w-5 h-5 text-danger",class:"mr-3",icon:"TrashIcon","pop-title":"دیدگاه حذف شود؟",onClick:C=>A(t.id)},null,8,["onClick"])):y("",!0)])]),_:1},8,["model"]),m(H,{open:k.value,"onUpdate:open":e[5]||(e[5]=t=>k.value=t),title:"مشاهده دیدگاه",width:"80%","wrap-class-name":"detail-modal"},{footer:o(()=>[m(z,{onClick:e[4]||(e[4]=t=>k.value=!1)},{default:o(()=>[...e[14]||(e[14]=[c("بستن",-1)])]),_:1})]),default:o(()=>[l.value?(i(),x("div",ae,[a("ul",null,[a("li",me,[a("span",ie,[m(I,{icon:"vuesax-linear:user",size:"16",style:{"font-size":"48px",color:"#1d4ed8"}})]),a("div",re,[a("h5",null,w(l.value.customer&&l.value.customer.fname&&l.value.customer.lname?`${l.value.customer.fname} ${l.value.customer.lname}`:"بدون نام"),1),a("span",ue," ارسال شده در تاریخ : "+w(l.value.caj?String(l.value.caj).split("-")[0]:null),1),m(j,{style:{width:"100%"}},{default:o(()=>[m(R,{value:h.value,"onUpdate:value":e[1]||(e[1]=t=>h.value=t),disabled:!v("comment.view.edit"),"auto-size":{minRows:3,maxRows:5}},null,8,["value","disabled"])]),_:1})]),a("ul",null,[a("li",de,[e[13]||(e[13]=a("img",{src:K,alt:"comment author",class:"img border"},null,-1)),a("div",ce,[e[12]||(e[12]=a("h5",null,"ادمین",-1)),l.value.reply&&l.value.reply[0]?(i(),x("span",pe," ارسال شده در تاریخ : "+w(l.value.reply[0].caj?String(l.value.reply[0].caj).split("-")[0]:""),1)):y("",!0),m(j,{style:{width:"100%"}},{default:o(()=>[m(R,{value:g.value,"onUpdate:value":e[2]||(e[2]=t=>g.value=t),disabled:!v("comment.view.edit"),"auto-size":{minRows:3,maxRows:5}},null,8,["value","disabled"])]),_:1}),(L.value||E.value)&&v("comment.view.edit")?(i(),d(z,{key:1,class:"mr-4",onClick:e[3]||(e[3]=t=>M(l.value))},{default:o(()=>[...e[11]||(e[11]=[c(" ثبت تغییرات ",-1)])]),_:1})):y("",!0)])])])])])])):y("",!0)]),_:1},8,["open"])]),_:1})])}}}),Se=Z(_e,[["__scopeId","data-v-2efe4af0"]]);export{Se as default};
|