2 lines
7.0 KiB
JavaScript
2 lines
7.0 KiB
JavaScript
import{_ as F}from"./brand-icon-CrDwHrcf.js";import{a as H,b as p,X as J}from"./model-BNUuQ7S0.js";import{_ as V}from"./TooltipBtn.vue_vue_type_script_setup_true_lang-BBll209y.js";import{u as z,d as K,b as N,c as m,w as o,r as u,o as i,h as C,p as a,a as d,i as y,f as c,t as w,Z as Q,G as _,m as S,s as X,j as W,y as B,_ as Y}from"./index-B13tkMpd.js";import{U as ee}from"./UserOutlined-tnfFbi-d.js";import"./filters-CHKbSAeg.js";import"./index-DXwUc_-g.js";import"./SettingOutlined-C2GWCiUw.js";import"./icons-BUM0Cj4i.js";import"./UnorderedListOutlined-DVq783q4.js";import"./PercentageOutlined-CpguakOP.js";import"./UserAddOutlined-GfYoiDJb.js";import"./CreditCardOutlined-BSGaXvdF.js";import"./AppstoreOutlined-Ca4USN1F.js";import"./TeamOutlined-BkaObMie.js";import"./CameraOutlined-CZeD3bSm.js";function te(){const x=z(),r=new H("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()),x.roles&&x.roles.includes("comment.state")&&r.add(new p("changeState","تغییر وضعیت").renderSlot("changeState").noSort()),r.add(new p("opt","عملیات").noSort().renderSlot("opt")),r}const oe={id:"page-user-list"},ne=["href"],se=["onClick"],le=["onClick"],ae={class:"flex"},me={key:0,class:"comments-list"},ie={class:"comment-item"},re={class:"img"},ue={class:"comment-body"},de={class:"time"},ce={class:"comment-item"},pe={class:"comment-body"},_e={key:0,class:"time"},ve=K({__name:"Comments",setup(x){const r=z(),v=n=>!!r.hasPermission(n),D=te(),h=S(null),l=S(void 0),k=S(!1),$=S(""),b=S(""),I=X(()=>{var n;return $.value!==(((n=l.value)==null?void 0:n.comment)??"")}),E=X(()=>{var n,e,s;return b.value!==(((s=(e=(n=l.value)==null?void 0:n.reply)==null?void 0:e[0])==null?void 0:s.comment)??"")});function L(n){var s,f;const e=String(((s=n.product)==null?void 0:s.title)??"").split(" ").join("-");return`${W.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=h.value)==null||s.fetch()}catch{_.error("خطا در تغییر وضعیت")}}function O(n){var e,s;l.value=n,$.value=n.comment??"",b.value=((s=(e=n.reply)==null?void 0:e[0])==null?void 0:s.comment)??"",k.value=!0}async function P(n){var e;try{await B.delete(`comment/${n}`),_.info("دیدگاه حذف شد"),(e=h.value)==null||e.fetch()}catch{_.error("خطا در حذف")}}async function G(n){var e;try{await B.post("comment",{product_id:n.product_id,customer_id:n.customer_id,comment:b.value,reply_to:n.id}),_.info("تغییرات ثبت شد "),k.value=!1,(e=h.value)==null||e.fetch()}catch{_.error("خطا در ثبت تغییرات")}}return(n,e)=>{const s=u("a-tag"),f=u("a-menu-item"),M=u("a-menu"),Z=u("a-dropdown"),U=u("a-textarea"),j=u("a-form-item"),R=u("a-button"),q=u("a-modal"),A=u("a-card");return i(),N("div",oe,[m(A,{title:"لیست دیدگاه ها",class:"page-card"},{default:o(()=>[m(J,{ref_key:"tbl",ref:h,model:C(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:L(t),target:"_blank"},w(t.product.title),9,ne)]),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(Z,{key:0},{overlay:o(()=>[m(M,null,{default:o(()=>[m(f,null,{default:o(()=>[a("div",{onClick:g=>t.sts!==2?T(t.id,2):C(_).error("حالت فعلی تایید می باشد")}," تایید ",8,se)]),_:2},1024),m(f,{class:"red"},{default:o(()=>[a("div",{onClick:g=>t.sts!==3?T(t.id,3):C(_).error("حالت فعلی عدم تایید می باشد")}," عدم تایید ",8,le)]),_: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]=g=>g.preventDefault())},{default:o(()=>[c(w(t.sts===1?"در انتظار تایید":t.sts===2?"تایید":"عدم تایید")+" ",1),m(C(Q))]),_:2},1032,["color"])]),_:2},1024)):y("",!0)]),opt:o(({record:t})=>[a("div",ae,[v("comment.view")?(i(),d(V,{key:0,"icon-class":"w-5 h-5 text-primary",class:"mr-3",icon:"EyeIcon",title:"مشاهده دیدگاه",onClick:g=>O(t)},null,8,["onClick"])):y("",!0),v("comment.remove")?(i(),d(V,{key:1,"icon-class":"w-5 h-5 text-danger",class:"mr-3",icon:"TrashIcon","pop-title":"دیدگاه حذف شود؟",onClick:g=>P(t.id)},null,8,["onClick"])):y("",!0)])]),_:1},8,["model"]),m(q,{open:k.value,"onUpdate:open":e[5]||(e[5]=t=>k.value=t),title:"مشاهده دیدگاه",width:"80%","wrap-class-name":"detail-modal"},{footer:o(()=>[m(R,{onClick:e[4]||(e[4]=t=>k.value=!1)},{default:o(()=>[...e[14]||(e[14]=[c("بستن",-1)])]),_:1})]),default:o(()=>[l.value?(i(),N("div",me,[a("ul",null,[a("li",ie,[a("span",re,[m(C(ee),{style:{"font-size":"48px",color:"#1c2d56"}})]),a("div",ue,[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",de," ارسال شده در تاریخ : "+w(l.value.caj?String(l.value.caj).split("-")[0]:null),1),m(j,{style:{width:"100%"}},{default:o(()=>[m(U,{value:$.value,"onUpdate:value":e[1]||(e[1]=t=>$.value=t),disabled:!v("comment.view.edit"),"auto-size":{minRows:3,maxRows:5}},null,8,["value","disabled"])]),_:1})]),a("ul",null,[a("li",ce,[e[13]||(e[13]=a("img",{src:F,alt:"comment author",class:"img border"},null,-1)),a("div",pe,[e[12]||(e[12]=a("h5",null,"ادمین",-1)),l.value.reply&&l.value.reply[0]?(i(),N("span",_e," ارسال شده در تاریخ : "+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(U,{value:b.value,"onUpdate:value":e[2]||(e[2]=t=>b.value=t),disabled:!v("comment.view.edit"),"auto-size":{minRows:3,maxRows:5}},null,8,["value","disabled"])]),_:1}),(E.value||I.value)&&v("comment.view.edit")?(i(),d(R,{key:1,class:"mr-4",onClick:e[3]||(e[3]=t=>G(l.value))},{default:o(()=>[...e[11]||(e[11]=[c(" ثبت تغییرات ",-1)])]),_:1})):y("",!0)])])])])])])):y("",!0)]),_:1},8,["open"])]),_:1})])}}}),Re=Y(ve,[["__scopeId","data-v-26513e49"]]);export{Re as default};
|