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

2 lines
10 KiB
JavaScript
Raw Normal View History

2026-01-07 11:50:06 +03:30
import{_ as j}from"./BasicMainCard-06dad464.js";import{_ as K}from"./BasicModal.vue_vue_type_style_index_0_lang-c07380a4.js";import{_ as Q,u as Y}from"./useBaseTable-89e367b0.js";import{_ as Z}from"./button.vue_vue_type_style_index_0_lang-80cf0b72.js";import{I as z}from"./Icon-e9a9d64e.js";import{t as ee}from"./useDataTime-60875705.js";import{I as O,d as te,g as T,A as ae,o as P,c as U,b as m,w as v,a as p,e as H,G as ne,j as A,z as se,t as E,k as F,D as g}from"./index-10f45eca.js";import{_ as le}from"./TextPreview.vue_vue_type_script_setup_true_lang-42c9e2e4.js";import{M as G}from"./index-5bc6b40d.js";import{I as oe}from"./index-cca2d62a.js";import{T as J}from"./index-ceff8631.js";import{U as ie}from"./index-4b9d78ea.js";import"./_plugin-vue_export-helper-2f157ef4.js";import"./index-ecb339ad.js";import"./index-1b352863.js";import"./Col-c6f28462.js";import"./vnode-b14d5532.js";import"./useState-4f4a8c99.js";import"./isPlainObject-75024cd7.js";import"./index-00f73089.js";import"./index-db46c961.js";import"./pickAttrs-2c86ae65.js";import"./index-9601d570.js";import"./toArray-45e57117.js";import"./FormItemContext-a11ae724.js";import"./index-2707819c.js";const re=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:r=>r.record.index+1},{title:"نام ارسال کننده",dataIndex:"owner_name",key:"owner_name",customRender:r=>r.record.owner_name||"-"},{title:"متن پیام",dataIndex:"text",key:"text",slot:"text"},{title:"فایل",dataIndex:"file",key:"file",align:"center",width:120,slot:"file"},{title:"وضعیت پین",dataIndex:"pined",key:"pined",align:"center",width:100,customRender:r=>r.record.pined?"پین شده":"-"},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:r=>ee(r.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}];async function ce(r){const{data:c,error:_}=await O.from("channel_message").insert([r]).select();if(_)throw _;return c}async function W(r,c){const{data:_,error:k}=await O.from("channel_message").update(c).eq("id",r).select();if(k)throw k;return _}async function ue(r){const{error:c}=await O.from("channel_message").delete().eq("id",r);if(c)throw c}async function de(r){const c={...r};!c.sort&&!c.order&&(c.order="-id");const{limit:_,filters:k,page:b,sort:w,order:I,search:C}=c;let e=O.from("channel_message").select("*, users!owner_id(first_name, last_name, phone)",{count:"exact"});if(C&&C.trim()){const t=`%${C}%`;e=e.ilike("text",t)}if(k&&Array.isArray(k)&&k.forEach(t=>{const{field:u,op:S,value:x,hidden:l}=t;if(!l)switch(S){case"eq":e=e.eq(u,x);break;case"neq":e=e.neq(u,x);break;case"gt":e=e.gt(u,x);break;case"lt":e=e.lt(u,x);break;case"gte":e=e.gte(u,x);break;case"lte":e=e.lte(u,x);break;case"has":e=e.ilike(u,`%${x}%`);break;case"like":e=e.like(u,`%${x}%`);break}}),_&&b){const t=(b-1)*_,u=t+_-1;e=e.range(t,u)}if(w&&w.key){const t=w.order==="asc";e=e.order(w.key,{ascending:t})}else if(I){const t=!I.startsWith("-"),u=I.replace(/^[-+]/,"");e=e.order(u,{ascending:t})}const{data:y,error:$,count:h}=await e;if($)return console.error("[getChannelMessagesTable] Supabase query error:",$),{query:{...c,limit:_||10,page:b||1,total:0},rows:[]};try{if(Array.isArray(y)){const t=b||1,u=_||200,S=(t-1)*u,x=y.map((l,N)=>{let D=null;if(l.owner_id){const M=Array.isArray(l.users)?l.users[0]:l.users;M?D=`${M.first_name||""} ${M.last_name||""}`.trim()||M.phone||`کاربر ${l.owner_id}`:D=`کاربر ${l.owner_id}`}return{id:l.id,owner_id:l.owner_id??null,owner_name:D,text:l.text??"",file:l.file??null,pined:l.pined??!1,pined_at:l.pined_at??null,created_at:l.created_at??"",updated_at:l.updated_at??"",index:S+N,...l}});return{query:{...c,limit:_||10,page:b||1,total:h||0},rows:x}}}catch(t){console.log("[getChannelMessagesTable] normalize error:",t)}return{query:{...c,limit:_||10,page:b||1,total:h||0},rows:y||[]}}const fe={class:"flex justify-between items-center mb-4"},me=p("h2",null,"اطلاع رسانی",-1),pe=["href"],_e={key:1},ve={class:"gap-2 flex justify-center"},ge=p("span