Files
machartaa_admin_dist/dist/assets/index-2d23e660.js
T

2 lines
7.4 KiB
JavaScript
Raw Normal View History

import{_ as F}from"./BasicMainCard-ddae39ab.js";import{M as H,_ as J}from"./BasicModal.vue_vue_type_style_index_0_lang-5afc1014.js";import{_ as X}from"./BasicInput.vue_vue_type_style_index_0_lang-86bcfe9c.js";import{_ as G}from"./index-9454089e.js";import{_ as K}from"./button.vue_vue_type_style_index_0_lang-241a9705.js";import{I as U}from"./Icon-967ca316.js";import{u as Q}from"./useBaseTable-3aeb2499.js";import{t as Y}from"./useDataTime-56db82be.js";import{getBooksTable as Z,updateBook as ee,addBook as te,deleteBook as ae}from"./books-68b5883a.js";import{d as le,r as f,o as $,c as I,b as r,w as m,a as l,e as oe,a2 as se,L as k,N as T,X as re,O as ne,a0 as c,a4 as L}from"./index-a9671513.js";import{T as N}from"./styleChecker-8312d0ee.js";import{S as ie}from"./index-d4552ccf.js";import{U as ue}from"./index-0d82943c.js";import"./_plugin-vue_export-helper-d21b9c52.js";import"./index-470b960b.js";import"./useState-4aa9b7fe.js";import"./vnode-e4b7f976.js";import"./Col-ca1a058e.js";import"./index-837b6155.js";import"./usePrice-7afab779.js";import"./index-b5eb525c.js";const ce=[{title:"ردیف",dataIndex:"id",key:"id",filterable:!1,width:70,align:"center",customRender:v=>v.record.index+1},{title:"عنوان",dataIndex:"title",key:"title"},{title:"زیرعنوان",dataIndex:"sub_title",key:"sub_title"},{title:"تعداد قصه ها",dataIndex:"total_storys",key:"total_storys",align:"center",width:120,customRender:v=>v.record.total_storys??0},{title:"تصویر کاور",dataIndex:"cover",key:"cover",customRender:v=>v.record.cover||"-"},{title:"زمان ایجاد",dataIndex:"created_at",key:"created_at",customRender:v=>Y(v.record.created_at)},{title:"عملیات",dataIndex:"action",key:"action",slot:"action",filterable:!1,align:"center"}],de={class:"flex justify-between items-center mb-4"},me=l("h2",null,"کتاب ها",-1),ve={class:"gap-2 flex justify-center"},pe=l("span",null,"حذف",-1),_e=l("span",null,"ویرایش",-1),fe={class:"space-y-4 relative"},he={key:0,class:"absolute inset-0 bg-white/60 z-10 flex items-center justify-center"},ge=l("div",{class:"mb-1 text-sm text-gray-600"},"عنوان *",-1),be=l("div",{class:"mb-1 text-sm text-gray-600"},"زیرعنوان",-1),xe=l("div",{class:"mb-1 text-sm text-gray-600"},"آپلود تصویر کاور",-1),ye={key:0},ke=l("div",null,"آپلود کاور",-1),we={key:0,class:"mt-1"},Be={class:"h-2 rounded bg-gray-200 overflow-hidden"},Ce={class:"text-xs text-gray-700 font-semibold text-center mt-1"},Je=le({__name:"index",setup(v){const[R,D]=Q(),z=f({columns:ce,api:Z,defaultPageLimit:20}),x=f(!1),w=f(!1),B=f(null),h=f([]),g=f(0),p=f(0),u=f({title:"",sub_title:null,cover:null});function O(){h.value=[],w.value=!1,B.value=null,u.value={title:"",sub_title:null,cover:null},x.value=!0}function P(){x.value=!1}function W(a){return a.type.startsWith("image/")?a.size/1024/1024<5?!0:(c.error("حجم تصویر باید کمتر از 5MB باشد"),!1):(c.error("فقط فایل‌های تصویری مجاز است"),!1)}async function V(a){const{file:e,onSuccess:n,onError:o,onProgress:d}=a,C=new FormData;C.append("file",e);const M=`${L}/upload/machartaa-img`;p.value=0,g.value++,await new Promise((i,y)=>{const s=new XMLHttpRequest;s.open("POST",M),s.setRequestHeader("Authorization",`Bearer ${localStorage.getItem("token")||""}`),s.upload.onprogress=t=>{if(t.lengthComputable){const _=Math.round(t.loaded/t.total*100);p.value=_,d==null||d({percent:_})}},s.onload=()=>{if(p.value=100,s.status>=200&&s.status<300)try{const t=JSON.parse(s.responseText||"{}"),_=t.full_src||t.url||t.src||t.path||t.data&&(t.data.full_src||t.data.url||t.data.src||t.data.path)||"";let b=_;_!=null&&_.startsWith("http")&&(b=_.replace(/^https?:\/\/[^\/]+/,""));const S=b.startsWith("http")?b:`${L}${b}`;u.value.cover=b,h.value=S?[{uid:`${Date.now()}`,name:"cover.jpg",status:"done",url:S,response:{path:b}}]:[],n==null||n(t,s),c.success("کاور با موفقیت آپلود شد!"),i()}catch(t){o==null||o(t,s),y(t)}else{const t=new Error("خطا در آپلود تصویر");o==null||o(t,s),y(t)}},s.onerror=()=>{const t=