Files
machartaa_admin_dist/dist/assets/index-cd44febb.js
T

2 lines
7.5 KiB
JavaScript
Raw Normal View History

2026-07-16 16:44:06 +03:30
import{_ as E}from"./BasicMainCard-d0e0118a.js";import{_ as R}from"./BasicModal.vue_vue_type_style_index_0_lang-78720926.js";import{_ as O,u as V}from"./useBaseTable-ee2a5641.js";import{_ as j}from"./button.vue_vue_type_style_index_0_lang-976922e0.js";import{I as A}from"./Icon-d2a333f8.js";import{t as z}from"./useDataTime-42f03937.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-c7cfb6d0.js";import{_ as W}from"./TextPreview.vue_vue_type_script_setup_true_lang-281d8a7e.js";import{M as D}from"./index-accfa387.js";import{I as F}from"./index-ec42cf6b.js";import{T as q}from"./isSymbol-39130b1f.js";import"./index-f553b547.js";import"./index-e011592a.js";import"./_plugin-vue_export-helper-64344365.js";import"./useState-624b81a4.js";import"./vnode-d460d6f7.js";import"./useRefs-ac12ba74.js";import"./_flatRest-4bcfe4cb.js";import"./index-2c3e0423.js";import"./Col-85f675b3.js";import"./styleChecker-2280acc2.js";import"./isPlainObject-9edbc0c5.js";import"./index-5ce472da.js";import"./updateLocale-4490df87.js";import"./index-a85f4e3c.js";import"./toArray-69a6a276.js";import"./FormItemContext-c66bbc76.js";import"./pickAttrs-a95b5777.js";import"./lodash-ccbe62b4.js";import"./BaseSwitch.vue_vue_type_script_setup_true_lang-f1dbbf12.js";import"./index-2173586f.js";import"./isNumeric-3f69e2aa.js";import"./index-c22a9b5b.js";import"./index-394ef579.js";import"./index-f2204652.js";import"./LeftOutlined-91e9e8a5.js";import"./css-aae66f86.js";import"./DialogWrap-c08d6860.js";import"./index-234839ae.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:n,error:l}=await $.from("comments").insert([s]).select();if(l)throw l;return n}async function M(s,n){const{data:l,error:p}=await $.from("comments").update(n).eq("id",s).select();if(p)throw p;return l}async function X(s){const{error:n}=await $.from("comments").delete().eq("id",s);if(n)throw n}async function Y(s){const n={...s};!n.sort&&!n.order&&(n.order="-id");const{limit:l,filters:p,page:y,sort:f,order:v,search:g}=n;let e=$.from("comments").select("*, users!owner_id(first_name, last_name, phone)",{count:"exact"});if(g&&g.trim()){const o=`%${g}%`;e=e.ilike("text",o)}if(p&&Array.isArray(p)&&p.forEach(o=>{const{field:r,op:b,value:c,hidden:t}=o;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 o=(y-1)*l,r=o+l-1;e=e.range(o,r)}if(f&&f.key){const o=f.order==="asc";e=e.order(f.key,{ascending:o})}else if(v){const o=!v.startsWith("-"),r=v.replace(/^[-+]/,"");e=e.order(r,{ascending:o})}const{data:u,error:T,count:h}=await e;if(T)return console.error("[getCommentsTable] Supabase query error:",T),{query:{...n,limit:l||10,page:y||1,total:0},rows:[]};try{if(Array.isArray(u)){const o=y||1,r=l||200,b=(o-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:{...n,limit:l||10,page:y||1,total:h||0},rows:c}}}catch(o){console.log("[getCommentsTable] normalize error:",o)}return{query:{...n,limit