2026-08-17 13:34:14 +03:30
|
|
|
import{_ as E}from"./BasicMainCard-a49bf313.js";import{_ as R}from"./BasicModal.vue_vue_type_style_index_0_lang-050248e0.js";import{_ as O,u as V}from"./useBaseTable-a962a6e3.js";import{_ as j}from"./button.vue_vue_type_style_index_0_lang-cf170adf.js";import{I as A}from"./Icon-21c28098.js";import{t as z}from"./useDataTime-64353302.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-e0c2af95.js";import{_ as W}from"./TextPreview.vue_vue_type_script_setup_true_lang-c64dd012.js";import{M as D}from"./index-ba1a268c.js";import{I as F}from"./index-ff6425ec.js";import{T as q}from"./isSymbol-16519357.js";import"./Grid-6f435e3e.js";import"./index-2170cfa5.js";import"./_plugin-vue_export-helper-ede5981c.js";import"./shallowequal-94cf06f1.js";import"./index-329abdc2.js";import"./vnode-1d9a5f19.js";import"./index-77288b74.js";import"./useState-9f37179f.js";import"./useRefs-f2d2b66f.js";import"./_flatRest-7f56bd12.js";import"./isMobile-e2e89480.js";import"./omit-ef5483a7.js";import"./index-d7731afc.js";import"./Col-f312538f.js";import"./styleChecker-fa192349.js";import"./isPlainObject-475d5f63.js";import"./index-55df0a19.js";import"./updateLocale-ddc4d420.js";import"./index-ccf41683.js";import"./index-bc659f42.js";import"./useMemo-8582dbbb.js";import"./FormItemContext-31ef74d8.js";import"./lodash-7e5e5813.js";import"./BaseSwitch.vue_vue_type_script_setup_true_lang-751e37cd.js";import"./index-3be03c15.js";import"./Badge-0df70937.js";import"./isNumeric-3f69e2aa.js";import"./index-beff19b5.js";import"./index-777eb3d4.js";import"./index-89e8edb2.js";import"./DialogWrap-3bd23522.js";import"./pickAttrs-e6a1c834.js";import"./css-aae66f86.js";import"./index-71bd3b00.js";import"./toArray-590d8ecb.js";import"./SearchOutlined-9dbd40a5.js";import"./index-f062f0ac.js";import"./index-4a6bfbb1.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}`}
|