2026-08-20 11:30:22 +03:30
|
|
|
import{_ as E}from"./BasicMainCard-4207a822.js";import{_ as R}from"./BasicModal.vue_vue_type_style_index_0_lang-12600cfe.js";import{_ as O,u as V}from"./useBaseTable-09dec183.js";import{_ as j}from"./button.vue_vue_type_style_index_0_lang-485aa400.js";import{I as A}from"./Icon-b61699b8.js";import{t as z}from"./useDataTime-c34f53fe.js";import{G as $,d as N,g as I,A as U,o as G,c as H,b as m,w as u,a as x,e as J,H as L,j as C,D as w}from"./index-5a216054.js";import{_ as W}from"./TextPreview.vue_vue_type_script_setup_true_lang-a1296ba9.js";import{M as D}from"./index-21b3e11b.js";import{I as F}from"./index-f7d24d7c.js";import{T as q}from"./isSymbol-67342ebb.js";import"./Grid-91e1bfd6.js";import"./index-a94d8106.js";import"./_plugin-vue_export-helper-bf156267.js";import"./shallowequal-9390c690.js";import"./index-99d6fd3f.js";import"./vnode-4ae36afb.js";import"./index-70ec4858.js";import"./useState-aaca7c53.js";import"./useRefs-88e72f09.js";import"./_flatRest-65586b5d.js";import"./isMobile-e2e89480.js";import"./omit-0e04d816.js";import"./index-704d428b.js";import"./Col-a3540e0e.js";import"./styleChecker-559f6f42.js";import"./isPlainObject-3c9a77e7.js";import"./index-efc9438a.js";import"./updateLocale-67e6a89b.js";import"./index-35a2fbcb.js";import"./index-bc659f42.js";import"./useMemo-f3fe2319.js";import"./FormItemContext-c093a4c8.js";import"./lodash-724580df.js";import"./BaseSwitch.vue_vue_type_script_setup_true_lang-5d13f90f.js";import"./index-7e28a3d1.js";import"./Badge-f954f9ce.js";import"./isNumeric-3f69e2aa.js";import"./index-16772af6.js";import"./index-fe5d35f1.js";import"./index-8a5836b4.js";import"./DialogWrap-104be95a.js";import"./pickAttrs-ca601ed4.js";import"./css-aae66f86.js";import"./index-14d22686.js";import"./toArray-6764992d.js";import"./SearchOutlined-4a9dd4f9.js";import"./index-89aa8d2e.js";import"./textUtils-c37780ad.js";const K=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:i=>i.record.index+1},{title:"نام کاربر",dataIndex:"owner_id",key:"owner_id",customRender:i=>i.record.owner_name||i.record.owner_id||"-"},{title:"متن نظر یا ایده",dataIndex:"text",key:"text",slot:"text"},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:i=>z(i.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"},{title:"پین شده",dataIndex:"pined",key:"pined",type:"Boolean",filterable:!0,show:!1}];async function Q(i){const{data:r,error:l}=await $.from("comments").insert([i]).select();if(l)throw l;return r}async function M(i,r){const{data:l,error:p}=await $.from("comments").update(r).eq("id",i).select();if(p)throw p;return l}async function X(i){const{error:r}=await $.from("comments").delete().eq("id",i);if(r)throw r}async function Y(i){const r={...i};!r.sort&&!r.order&&(r.order="-id");const{limit:l,filters:p,page:y,sort:f,order:v,search:g}=r;let e=$.from("comments").select("*, users!owner_id(first_name, last_name, phone)",{count:"exact"});if(g&&g.trim()){const a=`%${g}%`;e=e.ilike("text",a)}if(p&&Array.isArray(p)&&p.forEach(a=>{const{field:n,op:b,value:c,hidden:t}=a;if(!t)switch(b){case"eq":e=e.eq(n,c);break;case"neq":e=e.neq(n,c);break;case"gt":e=e.gt(n,c);break;case"lt":e=e.lt(n,c);break;case"gte":e=e.gte(n,c);break;case"lte":e=e.lte(n,c);break;case"has":e=e.ilike(n,`%${c}%`);break;case"like":e=e.like(n,`%${c}%`);break}}),l&&y){const a=(y-1)*l,n=a+l-1;e=e.range(a,n)}if(f&&f.key){const a=f.order==="asc";e=e.order(f.key,{ascending:a})}else if(v){const a=!v.startsWith("-"),n=v.replace(/^[-+]/,"");e=e.order(n,{ascending:a})}const{data:d,error:T,count:h}=await e;if(T)return console.error("[getCommentsTable] Supabase query error:",T),{query:{...r,limit:l||10,page:y||1,total:0},rows:[]};try{if(Array.isArray(d)){const a=y||1,n=l||200,b=(a-1)*n,c=d.map((t,o)=>{let s=null;if(t.owner_id){const k=Array.isArray(t.users)?t.users[0]:t.users;k?s=`${k.first_name||""} ${k.last_name||""}`.trim()||k.phone||`کاربر ${t.owner_id}`:s=`کاربر ${t.owner_id}`}return{id:t.id,owner_id:t.ow
|