2 lines
24 KiB
JavaScript
2 lines
24 KiB
JavaScript
import{I as J,d as Me,g as q,Q as ee,x as Le,_ as re,X as ne,o as W,c as E,b,w as D,a,e as se,G as ue,j as R,t as K,i as Ie,k as O,z as ce,D as L,H as X}from"./index-69112d2d.js";import{_ as Ne}from"./BasicMainCard-116dd373.js";import{M as Ae,_ as Ue}from"./BasicModal.vue_vue_type_style_index_0_lang-0138fcce.js";import{_ as Be}from"./BasicInput.vue_vue_type_style_index_0_lang-24c81742.js";import{d as te,_ as Ve,l as Pe}from"./index-65f4ae30.js";import{_ as Fe}from"./button.vue_vue_type_style_index_0_lang-cb9bab68.js";import{I as j}from"./Icon-14389e7e.js";import{_ as de}from"./BasicSelect.vue_vue_type_style_index_0_lang-9b38459a.js";import{u as me}from"./useBaseTable-3aeb2499.js";import{t as he}from"./useDataTime-9dd670d7.js";import{S as _e}from"./index-fe404104.js";import{D as Re}from"./dayjs-38467f9e.js";import{T as Z}from"./styleChecker-3dd17850.js";import{U as ve}from"./index-bb4bae6e.js";import"./_plugin-vue_export-helper-58457e60.js";import"./index-a892ffea.js";import"./index-d31f2800.js";import"./useState-508680d6.js";import"./vnode-48e303b0.js";import"./Col-3b3cdac3.js";import"./index-c567b779.js";import"./usePrice-7afab779.js";import"./index-3c2c722d.js";const ze=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:c=>c.record.index+1},{title:"عنوان",dataIndex:"title",key:"title"},{title:"زیرعنوان",dataIndex:"sub_title",key:"sub_title"},{title:"کتاب مرتبط",dataIndex:"book_id",key:"book_id",align:"center",customRender:c=>{const o=c.record.book_title,h=c.record.book_id;return o||(h?`کتاب #${h}`:"-")}},{title:"زمان",dataIndex:"time",key:"time",customRender:c=>{const o=c.record.time||{minutes:0,seconds:0},h=Number(o.minutes||0),g=Number(o.seconds||0),U=k=>String(k).padStart(2,"0");return`${U(h)}:${U(g)}`}},{title:"صوت",dataIndex:"src",key:"src",customRender:c=>c.record.src?"دارد":"-"},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:c=>he(c.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}],We=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:c=>c.record.index+1},{title:"نام کاربر",dataIndex:"user_name",key:"user_name",filterable:!0,filterField:"user_name"},{title:"شماره همراه",dataIndex:"user_phone",key:"user_phone",filterable:!0,filterField:"user_phone"},{title:"تاریخ بازدید",dataIndex:"viewed_at",key:"viewed_at",filterable:!0,filterField:"viewed_at",customRender:c=>he(c.record.viewed_at)}];async function Ye(c){const{data:o,error:h}=await J.from("storys").insert([{title:c.title,sub_title:c.sub_title,cover:c.cover,src:c.src,time:c.time,book_id:c.book_id||null,show_time:c.show_time||null}]).select();if(h)throw h;return o}async function fe(c,o){const{data:h,error:g}=await J.from("storys").update({title:o.title,sub_title:o.sub_title,cover:o.cover,src:o.src,time:o.time,book_id:o.book_id||null,show_time:o.show_time||null}).eq("id",c).select();if(g)throw g;return h}async function Ee(c,o){const{data:h,error:g}=await J.from("storys").update({show:o}).eq("id",c).select();if(g)throw g;return h}async function He(c){const{error:o}=await J.from("storys").delete().eq("id",c);if(o)throw o}async function Oe(c){try{const{limit:o,filters:h,page:g,sort:U,order:k,search:I}=c;let d=J.from("storys").select("*, books!book_id(id, title, sub_title, cover)",{count:"exact"});if(I&&I.trim()){const r=`%${I.trim()}%`;d=d.or(`title.ilike.${r},sub_title.ilike.${r}`)}if(h&&Array.isArray(h)&&h.forEach(r=>{const{field:x,op:V,value:T,hidden:y}=r;if(!y)switch(V){case"eq":d=d.eq(x,T);break;case"neq":d=d.neq(x,T);break;case"gt":d=d.gt(x,T);break;case"lt":d=d.lt(x,T);break;case"gte":d=d.gte(x,T);break;case"lte":d=d.lte(x,T);break;case"has":d=d.ilike(x,`%${T}%`);break;case"like":d=d.like(x,`%${T}%`);break}}),U&&U.key){const r=U.order==="asc";d=d.order(U.key,{ascending:r})}else if(k){const r=!k.startsWith("-"),x=k.replace(/^[-+]/,"");d=d.order(x,{ascending:r})}else d=d.order("id",{ascending:!1});if(o&&g){con
|