2 lines
7.6 KiB
JavaScript
2 lines
7.6 KiB
JavaScript
import{_ as E}from"./BasicMainCard-989ffa54.js";import{_ as R}from"./BasicModal.vue_vue_type_style_index_0_lang-8174f671.js";import{_ as O,u as V}from"./useBaseTable-e1239fc4.js";import{_ as j}from"./button.vue_vue_type_style_index_0_lang-6d9e6004.js";import{I as A}from"./Icon-3cba35ff.js";import{t as z}from"./useDataTime-39d365d2.js";import{G as $,d as N,g as I,A as U,o as G,c as H,b as d,w as m,a as x,e as J,H as L,j as C,D as w}from"./index-03881eed.js";import{_ as W}from"./TextPreview.vue_vue_type_script_setup_true_lang-e9e24e71.js";import{M as D}from"./index-a6dd452f.js";import{I as F}from"./index-ef10ea82.js";import{T as q}from"./isSymbol-72806280.js";import"./Grid-669bdab6.js";import"./index-577e5a04.js";import"./_plugin-vue_export-helper-7a7517f7.js";import"./index-6e050cc2.js";import"./vnode-dddce04c.js";import"./omit-0bf0f784.js";import"./useState-164294d5.js";import"./useRefs-d2ce1514.js";import"./_flatRest-08d5cdb1.js";import"./index-67119fea.js";import"./Col-8b6b3139.js";import"./styleChecker-230f1d69.js";import"./isPlainObject-b1bc5d24.js";import"./index-c4251c82.js";import"./updateLocale-ce915111.js";import"./index-bc659f42.js";import"./index-2b937264.js";import"./toArray-9d324686.js";import"./FormItemContext-77a35a1f.js";import"./pickAttrs-bd4d06ea.js";import"./lodash-78d38859.js";import"./BaseSwitch.vue_vue_type_script_setup_true_lang-9e1881c0.js";import"./index-fbef06fa.js";import"./Badge-7d333aab.js";import"./isNumeric-3f69e2aa.js";import"./index-245d34d2.js";import"./index-2245e0eb.js";import"./index-b336c82b.js";import"./DialogWrap-ab772604.js";import"./css-aae66f86.js";import"./index-d1c6db2d.js";import"./textUtils-c37780ad.js";const K=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:s=>s.record.index+1},{title:"نام کاربر",dataIndex:"owner_id",key:"owner_id",customRender:s=>s.record.owner_name||s.record.owner_id||"-"},{title:"متن نظر یا ایده",dataIndex:"text",key:"text",slot:"text"},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:s=>z(s.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(s){const{data:o,error:l}=await $.from("comments").insert([s]).select();if(l)throw l;return o}async function M(s,o){const{data:l,error:p}=await $.from("comments").update(o).eq("id",s).select();if(p)throw p;return l}async function X(s){const{error:o}=await $.from("comments").delete().eq("id",s);if(o)throw o}async function Y(s){const o={...s};!o.sort&&!o.order&&(o.order="-id");const{limit:l,filters:p,page:y,sort:f,order:v,search:g}=o;let e=$.from("comments").select("*, users!owner_id(first_name, last_name, phone)",{count:"exact"});if(g&&g.trim()){const n=`%${g}%`;e=e.ilike("text",n)}if(p&&Array.isArray(p)&&p.forEach(n=>{const{field:r,op:b,value:c,hidden:t}=n;if(!t)switch(b){case"eq":e=e.eq(r,c);break;case"neq":e=e.neq(r,c);break;case"gt":e=e.gt(r,c);break;case"lt":e=e.lt(r,c);break;case"gte":e=e.gte(r,c);break;case"lte":e=e.lte(r,c);break;case"has":e=e.ilike(r,`%${c}%`);break;case"like":e=e.like(r,`%${c}%`);break}}),l&&y){const n=(y-1)*l,r=n+l-1;e=e.range(n,r)}if(f&&f.key){const n=f.order==="asc";e=e.order(f.key,{ascending:n})}else if(v){const n=!v.startsWith("-"),r=v.replace(/^[-+]/,"");e=e.order(r,{ascending:n})}const{data:u,error:T,count:h}=await e;if(T)return console.error("[getCommentsTable] Supabase query error:",T),{query:{...o,limit:l||10,page:y||1,total:0},rows:[]};try{if(Array.isArray(u)){const n=y||1,r=l||200,b=(n-1)*r,c=u.map((t,a)=>{let i=null;if(t.owner_id){const k=Array.isArray(t.users)?t.users[0]:t.users;k?i=`${k.first_name||""} ${k.last_name||""}`.trim()||k.phone||`کاربر ${t.owner_id}`:i=`کاربر ${t.owner_id}`}return{id:t.id,owner_id:t.owner_id??null,owner_name:i,text:t.text??"",created_at:t.created_at??"",updated_at:t.updated_at??"",index:b+a,...t}});return{query:{...o,limit:l||10,page:y||1,total:h||0},rows:c}}}catch(n){co
|