2026-08-19 18:36:32 +03:30
|
|
|
import{_ as E}from"./BasicMainCard-c1077cbf.js";import{_ as R}from"./BasicModal.vue_vue_type_style_index_0_lang-0121d908.js";import{_ as O,u as V}from"./useBaseTable-7b78293f.js";import{_ as j}from"./button.vue_vue_type_style_index_0_lang-dcd86e7a.js";import{I as A}from"./Icon-8dedfa53.js";import{t as z}from"./useDataTime-a337f5c6.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-b0561d74.js";import{_ as W}from"./TextPreview.vue_vue_type_script_setup_true_lang-7903e918.js";import{M as D}from"./index-12bdf78c.js";import{I as F}from"./index-d18c8f13.js";import{T as q}from"./isSymbol-a4291d99.js";import"./Grid-80c38bfa.js";import"./index-f9091817.js";import"./_plugin-vue_export-helper-130a5518.js";import"./shallowequal-4f931fa5.js";import"./index-2dc7fe57.js";import"./vnode-531f9d95.js";import"./index-5d725680.js";import"./useState-94528018.js";import"./useRefs-899ec8f3.js";import"./_flatRest-39f9ed6b.js";import"./isMobile-e2e89480.js";import"./omit-e6701bfc.js";import"./index-9a77c0e9.js";import"./Col-08664037.js";import"./styleChecker-d39a1d44.js";import"./isPlainObject-3a5eccde.js";import"./index-b7f1770d.js";import"./updateLocale-b730d578.js";import"./index-092c5981.js";import"./index-bc659f42.js";import"./useMemo-0162b583.js";import"./FormItemContext-5520cb52.js";import"./lodash-9a3882db.js";import"./BaseSwitch.vue_vue_type_script_setup_true_lang-71825e72.js";import"./index-46f9dc77.js";import"./Badge-d2c862d8.js";import"./isNumeric-3f69e2aa.js";import"./index-7febe226.js";import"./index-93c22234.js";import"./index-b618fa76.js";import"./DialogWrap-9c2d8a9c.js";import"./pickAttrs-69dd58a4.js";import"./css-aae66f86.js";import"./index-482a46a3.js";import"./toArray-1ab9b01c.js";import"./SearchOutlined-ca6a4719.js";import"./index-840dd6b2.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
|