Files
tehran_taj/apps/admin-panel/dist/assets/Comments-B3Vbrzgi.js
T
2026-09-25 19:12:39 +03:30

2 lines
6.7 KiB
JavaScript

import{_ as G}from"./montzar-icon-B0wdL36O.js";import{a as J,b as p,X as K}from"./model-Cu9jLjyk.js";import{_ as z}from"./TooltipBtn.vue_vue_type_script_setup_true_lang-D9rYu58q.js";import{u as X,d as Q,b as N,c as m,w as o,r as u,o as i,h as b,n as a,a as d,i as y,f as c,t as w,H as W,z as _,l as S,p as V,x as B}from"./index-CaCGCy-S.js";import{U as Y}from"./icons-BqGdEQ8f.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./SettingOutlined-BBHg-1Oy.js";import"./UnorderedListOutlined-DlwDSU5E.js";import"./TeamOutlined-BrwhpGFC.js";import"./CreditCardOutlined-CDai_0GE.js";function ee(){const x=X(),r=new J("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 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=Q({__name:"Comments",setup(x){const r=X(),v=n=>!!r.hasPermission(n),D=ee(),h=S(null),l=S(void 0),k=S(!1),$=S(""),g=S(""),I=V(()=>{var n;return $.value!==(((n=l.value)==null?void 0:n.comment)??"")}),E=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 L(n){var s,f;return`https://bnk.montzar.ir/product/${String(((s=n.product)==null?void 0:s.title)??"").split(" ").join("-")}/${(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??"",g.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 H(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=h.value)==null||e.fetch()}catch{_.error("خطا در ثبت تغییرات")}}return(n,e)=>{const s=u("a-tag"),f=u("a-menu-item"),M=u("a-menu"),q=u("a-dropdown"),R=u("a-textarea"),U=u("a-form-item"),j=u("a-button"),A=u("a-modal"),F=u("a-card");return i(),N("div",te,[m(F,{title:"لیست دیدگاه ها"},{default:o(()=>[m(K,{ref_key:"tbl",ref:h,model:b(D)},{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,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(q,{key:0},{overlay:o(()=>[m(M,null,{default:o(()=>[m(f,null,{default:o(()=>[a("div",{onClick:C=>t.sts!==2?T(t.id,2):b(_).error("حالت فعلی تایید می باشد")}," تایید ",8,ne)]),_:2},1024),m(f,{class:"red"},{default:o(()=>[a("div",{onClick:C=>t.sts!==3?T(t.id,3):b(_).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(b(W))]),_:2},1032,["color"])]),_:2},1024)):y("",!0)]),opt:o(({record:t})=>[a("div",le,[v("comment.view")?(i(),d(z,{key:0,"icon-class":"w-5 h-5 text-primary",class:"mr-3",icon:"EyeIcon",title:"مشاهده دیدگاه",onClick:C=>O(t)},null,8,["onClick"])):y("",!0),v("comment.remove")?(i(),d(z,{key:1,"icon-class":"w-5 h-5 text-danger",class:"mr-3",icon:"TrashIcon","pop-title":"دیدگاه حذف شود؟",onClick:C=>P(t.id)},null,8,["onClick"])):y("",!0)])]),_:1},8,["model"]),m(A,{open:k.value,"onUpdate:open":e[5]||(e[5]=t=>k.value=t),title:"مشاهده دیدگاه",width:"80%"},{footer:o(()=>[m(j,{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",ae,[a("ul",null,[a("li",me,[a("span",ie,[m(b(Y),{style:{"font-size":"48px",color:"#1c2d56"}})]),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(U,{style:{width:"100%"}},{default:o(()=>[m(R,{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",de,[e[13]||(e[13]=a("img",{src:G,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(),N("span",pe," ارسال شده در تاریخ : "+w(l.value.reply[0].caj?String(l.value.reply[0].caj).split("-")[0]:""),1)):y("",!0),m(U,{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}),(E.value||I.value)&&v("comment.view.edit")?(i(),d(j,{key:1,class:"mr-4",onClick:e[3]||(e[3]=t=>H(l.value))},{default:o(()=>[...e[11]||(e[11]=[c(" ثبت تغییرات ",-1)])]),_:1})):y("",!0)])])])])])])):y("",!0)]),_:1},8,["open"])]),_:1})])}}}),$e=Z(_e,[["__scopeId","data-v-6332a204"]]);export{$e as default};