2 lines
6.7 KiB
JavaScript
2 lines
6.7 KiB
JavaScript
import{_ as G}from"./montzar-icon-B0wdL36O.js";import{a as H,b as p,X as J}from"./model-CvqTGmy8.js";import{_ as z}from"./TooltipBtn.vue_vue_type_script_setup_true_lang-DxnpxKjK.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,K as W,z as _,l as S,p as V,x as B}from"./index-CVG99b4v.js";import{U as Y}from"./icons-BaVxJrpa.js";import{_ as Z}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./filters-UavLT20t.js";import"./index-pLFqZCCf.js";import"./SettingOutlined-D7--Xtqg.js";import"./UnorderedListOutlined-CKa6XzC7.js";import"./TeamOutlined-BEJyrWYB.js";import"./CreditCardOutlined-wQJvlSrP.js";function ee(){const x=X(),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 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 K(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(J,{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,{
|