2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
import{_ as Z}from"./BasicMainCard-226652ff.js";import{_ as ee}from"./BasicModal.vue_vue_type_style_index_0_lang-234112c9.js";import{_ as te,u as ae}from"./useBaseTable-e60ec4b8.js";import{_ as ne}from"./button.vue_vue_type_style_index_0_lang-d41fbf64.js";import{I as B}from"./Icon-78d04a1c.js";import{t as se}from"./useDataTime-0f66fcd9.js";import{G as A,d as oe,g as b,A as ie,o as T,i as le,w as d,a as m,b as u,e as L,c as D,j as C,H as re,k as N,y as ue,t as F,D as f}from"./index-c3a83709.js";import{f as H,a as ce,b as de,c as fe,d as me,e as O}from"./supabaseTableQuery-9069679c.js";import{b as pe}from"./pushNotification-337c5cfe.js";import{_ as _e}from"./TextPreview.vue_vue_type_script_setup_true_lang-09f9bb62.js";import{e as ve,g as he}from"./convert-2ad76038.js";import{M as z}from"./index-3cee424d.js";import{C as xe}from"./index-4987f49a.js";import{I as ge}from"./index-588aa217.js";import{T as q}from"./isSymbol-933af901.js";import{U as ye}from"./index-f68a6e65.js";import"./index-51e1e412.js";import"./index-6d9d7b65.js";import"./_plugin-vue_export-helper-9424d566.js";import"./useState-edde538a.js";import"./vnode-13aafe4d.js";import"./useRefs-c83745ad.js";import"./_flatRest-09ea8109.js";import"./index-133c097e.js";import"./Col-f98af73f.js";import"./styleChecker-5d75eaf5.js";import"./isPlainObject-e4dd5edb.js";import"./index-55899d99.js";import"./updateLocale-ff27ed8b.js";import"./index-ce887100.js";import"./toArray-fdd672d9.js";import"./FormItemContext-89798113.js";import"./pickAttrs-948566e5.js";import"./lodash-35a3e948.js";import"./index-795d795f.js";import"./isNumeric-3f69e2aa.js";import"./index-1b40f734.js";import"./textUtils-c37780ad.js";import"./DialogWrap-99990cc9.js";import"./index-c0c82e0d.js";import"./css-aae66f86.js";import"./index-42c94377.js";const we=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:e=>e.record.index+1},{title:"نام ارسال کننده",dataIndex:"owner_name",key:"owner_name",filterField:"owner_name",customRender:e=>e.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:e=>e.record.pined?"پین شده":"-"},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:e=>se(e.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}],be=new Set(["text","file","pined","pined_at","created_at","updated_at","owner_id"]),ke=["text"];async function Ie(e){const{data:s,error:v}=await A.from("channel_message").insert([e]).select();if(v)throw v;return s}async function G(e,s){const{data:v,error:k}=await A.from("channel_message").update(s).eq("id",e).select();if(k)throw k;return v}async function Se(e){const{error:s}=await A.from("channel_message").delete().eq("id",e);if(s)throw s}function Ce(e){let s=null;if(e.owner_id){const v=Array.isArray(e.users)?e.users[0]:e.users;v?s=`${v.first_name||""} ${v.last_name||""}`.trim()||v.phone||`کاربر ${e.owner_id}`:s=`کاربر ${e.owner_id}`}return{...e,owner_name:s,text:e.text??"",file:e.file??null,pined:e.pined??!1,pined_at:e.pined_at??null,created_at:e.created_at??"",updated_at:e.updated_at??""}}async function Me(e){const s={...e};!s.sort&&!s.order&&(s.order="-id");const{limit:v=20,page:k=1,search:S,filters:g}=s;let o=A.from("channel_message").select("*, users!owner_id(first_name, last_name, phone)",{count:"exact"});if(S!=null&&S.trim()){const p=await H(A,S);o=ce(o,S,ke,p,"owner_id")}if(g!=null&&g.length){for(const p of g)if(!(p.hidden||!p.field)){if(p.field==="owner_name"){if(["eq","has","like"].includes(p.op)){const h=await H(A,String(p.value));h.length?o=o.in("owner_id",h):o=o.eq("owner_id","00000000-0000-0000-0000-000000000000")}continue}be.has(p.field)&&(o=de(o,p))}}o=fe(o,s,"-id",["id","created_at","updated_at","pined","text"]),o=me(o,k,v);const{data:M,error:y,count:w}=await o;return y?(console.error("[getCha
|