2 lines
7.8 KiB
JavaScript
2 lines
7.8 KiB
JavaScript
import{_ as E}from"./BasicMainCard-29eef376.js";import{_ as R}from"./BasicModal.vue_vue_type_style_index_0_lang-7803828f.js";import{_ as O,u as V}from"./useBaseTable-e4bbf0da.js";import{_ as j}from"./button.vue_vue_type_style_index_0_lang-99dfcd06.js";import{I as A}from"./Icon-c9ad16b9.js";import{t as z}from"./useDataTime-5442c624.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-bc4edd51.js";import{_ as W}from"./TextPreview.vue_vue_type_script_setup_true_lang-0733684f.js";import{M as D}from"./index-609e9a96.js";import{I as F}from"./index-49e2e544.js";import{T as q}from"./isSymbol-f9834f4f.js";import"./Grid-08ee34b6.js";import"./index-627337a8.js";import"./_plugin-vue_export-helper-c8347567.js";import"./shallowequal-cad00b6e.js";import"./index-47b6ba8f.js";import"./vnode-f2307909.js";import"./index-1d49b36b.js";import"./useState-47ff4833.js";import"./useRefs-225197bd.js";import"./_flatRest-9adb1e9a.js";import"./isMobile-e2e89480.js";import"./omit-6f60253b.js";import"./index-7fcb5f91.js";import"./Col-96f7f23f.js";import"./styleChecker-bc667521.js";import"./isPlainObject-ed8996b4.js";import"./index-d4870df7.js";import"./updateLocale-7b0be7e3.js";import"./index-9df7eaa1.js";import"./index-bc659f42.js";import"./useMemo-8275a234.js";import"./FormItemContext-4e017a44.js";import"./lodash-3efc1909.js";import"./BaseSwitch.vue_vue_type_script_setup_true_lang-9775c8a5.js";import"./index-5ea3cefd.js";import"./Badge-627fd6d3.js";import"./isNumeric-3f69e2aa.js";import"./index-34768277.js";import"./index-4e41e7b6.js";import"./index-393b875d.js";import"./DialogWrap-f12e49af.js";import"./pickAttrs-1c46cfba.js";import"./css-aae66f86.js";import"./index-727535d5.js";import"./toArray-b01cb1f9.js";import"./SearchOutlined-4504ec77.js";import"./index-ae018072.js";import"./index-3aafac3f.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}`}
|