Refresh admin-panel and user-app dist bundles produced by the production build. Co-authored-by: Cursor <cursoragent@cursor.com>
2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{I as A}from"./Icon-B1Oy_KgZ.js";import{d as Oe,s as Ne,v as Re,o,a as r,n as W,m as b,c as y,f as p,w as c,p as u,e as w,F as S,b as B,O as z,t as T,q as G,g as h,k as O,y as re,x as Ke,r as _,_ as Xe}from"./index-DHam5nqk.js";import{g as ue}from"./filters-RVjQA319.js";const Ye={class:"x-table__toolbar"},Ee={class:"x-table__search-group"},Ae={class:"x-table__actions"},je={key:0,class:"x-table__add"},Le={key:0,class:"x-table__filters"},Qe={class:"x-table__filter-actions"},We={key:1,class:"x-table__cards"},Ge={class:"x-card__head"},He={class:"x-card__title"},Je={key:1,class:"x-card__media"},Ze={key:2,class:"x-card__id"},et={class:"x-card__name"},tt={key:0,class:"x-card__actions"},lt={key:0,class:"x-card__body"},at={key:0,class:"x-table__card-pager"},st={class:"x-table__card-total"},it=Oe({__name:"XTable",props:{model:{},hasSelection:{type:Boolean,default:!1},modelValue:{default:()=>[]},mobileCards:{type:Boolean,default:!1}},emits:["query","update:modelValue"],setup(x,{expose:n,emit:U}){const f=x,j=Ne(),L=h(()=>f.mobileCards&&j.isMobile),N=U,de=h(()=>f.hasSelection?{selectedRowKeys:f.modelValue.map(e=>e.id),onChange:(e,t)=>{N("update:modelValue",t)}}:void 0),k=O([]),$=O(!1),I=O(!1),C=O(void 0),R=O("asc"),s=re({search:void 0,filters:[],total:0,limit:10,page:1}),H={emptyText:"هیج رکوردی یافت نشد."},ce=[{value:"=",label:"برابر"},{value:"!=",label:"نامساوی"},{value:"like",label:"شامل"},{value:">",label:"بزرگتر"},{value:">=",label:"بزرگتر مساوی"},{value:"<",label:"کوچکتر"},{value:"<=",label:"کوچکتر مساوی"},{value:"between",label:"بین"}],K=h(()=>f.model?re(f.model).cols:[]),D=h(()=>K.value.filter(e=>e.show)),he=h(()=>K.value.filter(e=>e.filtered).map(e=>({value:e.__fkey??e.key,label:e.title}))),ve=h(()=>C.value?`${R.value==="asc"?"+":"-"}${C.value}`:void 0),pe=h(()=>D.value.map(e=>{var t;return{key:e.key,title:e.title,dataIndex:e.dataIndex.includes(".")?e.dataIndex.split("."):e.dataIndex,sorter:e.__sorter,width:e.width,__slot:(t=e.scopedSlots)==null?void 0:t.customRender,__date:e.filterType==="date"}}));function J(e){return e.__slot}const _e=["opt","op","action"],M=h(()=>D.value.map(e=>{var t;return{key:e.key,title:e.title,path:e.dataIndex.split("."),slot:(t=e.scopedSlots)==null?void 0:t.customRender,date:e.filterType==="date"}})),q=h(()=>M.value.find(e=>_e.includes(e.key)&&e.slot)),X=h(()=>M.value.find(e=>e.key==="id")),P=h(()=>M.value.find(e=>e.slot==="image")),Z=h(()=>{const e=M.value.filter(i=>i!==q.value&&i!==X.value&&i!==P.value),t=e.find(i=>i.key==="name"||i.key==="title");if(t)return[t];const a=e.find(i=>i.key==="fname");return a?[a,...e.filter(i=>i.key==="lname")]:e.slice(0,1)}),ee=h(()=>M.value.filter(e=>e!==q.value&&e!==X.value&&e!==P.value&&!Z.value.includes(e)));function Y(e){return f.modelValue.some(t=>t.id===e.id)}function fe(e,t){const a=f.modelValue.filter(i=>i.id!==e.id);N("update:modelValue",t?[...a,e]:a)}const te=h(()=>k.value.length>0&&k.value.every(Y)),me=h(()=>k.value.some(Y));function ye(e){const t=new Set(k.value.map(i=>i.id)),a=f.modelValue.filter(i=>!t.has(i.id));N("update:modelValue",e?[...a,...k.value]:a)}function V(e,t){return t.path.reduce((a,i)=>a&&typeof a=="object"?a[i]:void 0,e)}function le(e,t){const a=V(e,t);return a==null||a===""?"-":t.date?ue(a):a}const ae=h(()=>D.value.filter(e=>e.__sorter).flatMap(e=>[{value:`${e.key}|asc`,label:`${e.title} ↑`},{value:`${e.key}|desc`,label:`${e.title} ↓`}])),ge=h(()=>C.value?`${C.value}|${R.value}`:void 0);function ke(e){if(e){const[t,a]=e.split("|");C.value=t,R.value=a}else C.value=void 0;s.page=1,F()}function be(e,t){var a;s.page=e,s.limit=t,F(),(a=document.getElementById("content-area"))==null||a.scrollTo({top:0,behavior:"smooth"})}function se(e){if(e)return K.value.find(t=>(t.__fkey??t.key)===e)}function ie(e){const t=se(e);if(!((t==null?void 0:t.filterType)!=="select"||!t.filterItems))return Object.entries(t.filterItems).map(([a,i])=>({value:a,label:i}))}function xe(e){var t;return((t=se(e))==null?void 0:t.filterType)==="date"}const we=h(()=>{var e;return(e=f.model)!=null&&e._hidePagination?!1:{current:s.page,pageSize:s.limit,total:s.total,showSizeChanger:!0}});function Se(e){var m;const t={};D.value.forEach(g=>{t[g.key]=g.title});const a=D.value.map(g=>g.key),i={search:s.search,filters:s.filters.filter(g=>g.field&&g.op),total:s.total,limit:s.limit,page:s.page,order:ve.value,select:a,titles:t,report_title:(m=f.model)==null?void 0:m.title};return e?{...i,op:e}:i}async function F(e){var t,a,i;if(f.model)try{$.value=!0;const{data:m}=await Ke.post(f.model.url,Se(e));k.value=m.rows,s.total=((t=m.query)==null?void 0:t.total)??0,s.page=((a=m.query)==null?void 0:a.page)??s.page,s.limit=((i=m.query)==null?void 0:i.limit)??s.limit,N("query",m.query)}catch(m){throw console.log(m),m}finally{$.value=!1}}function Ce(e){s.search=e,s.page=1,F()}function Fe(){I.value=!I.value,I.value&&s.filters.length===0&&oe()}function oe(){s.filters.push({id:parseFloat(`${s.filters.length}.${Math.floor(Math.random()*1e3)}`)})}function Te(e){s.filters.splice(e,1)}function $e(){I.value=!1,s.page=1,F()}function Ie(e,t,a){s.page=e.current??1,s.limit=e.pageSize??s.limit,a!=null&&a.columnKey&&a.order?(C.value=String(a.columnKey),R.value=a.order==="ascend"?"asc":"desc"):C.value=void 0,F()}return Re(()=>{var e;for(const t of((e=f.model)==null?void 0:e.defaultFilters)??[])s.filters.push({id:Math.random(),...t});F()}),n({fetch:F}),(e,t)=>{const a=_("a-input-search"),i=_("a-button"),m=_("a-badge"),g=_("a-tooltip"),Q=_("a-checkbox"),Ve=_("a-menu-item"),ze=_("a-menu"),Ue=_("a-dropdown"),E=_("a-select"),De=_("a-date-picker"),ne=_("a-input"),Me=_("a-empty"),qe=_("a-spin"),Pe=_("a-pagination"),Be=_("a-table");return o(),r("div",{class:W(["x-table",{"x-table--cards":L.value}])},[b("div",Ye,[b("div",Ee,[x.model._hideSearch?p("",!0):(o(),y(a,{key:0,value:s.search,"onUpdate:value":t[0]||(t[0]=l=>s.search=l),class:"x-table__search",placeholder:"جستجو","allow-clear":"",onSearch:Ce},null,8,["value"])),b("div",Ae,[x.model._noFilters?p("",!0):(o(),y(m,{key:0,count:s.filters.length},{default:c(()=>[u(i,{type:"text",class:W({"x-table__action--active":I.value}),onClick:Fe},{icon:c(()=>[u(A,{icon:"vuesax-linear:filter",size:"16"})]),default:c(()=>[t[3]||(t[3]=w(" فیلتر ",-1))]),_:1},8,["class"])]),_:1},8,["count"])),u(g,{title:"چاپ"},{default:c(()=>[u(i,{type:"text",shape:"circle"},{icon:c(()=>[u(A,{icon:"vuesax-linear:printer",size:"16"})]),_:1})]),_:1}),u(Ue,{trigger:["click"]},{overlay:c(()=>[u(ze,null,{default:c(()=>[(o(!0),r(S,null,B(K.value,l=>(o(),y(Ve,{key:l.key},{default:c(()=>[u(Q,{checked:l.show,"onUpdate:checked":d=>l.show=d},{default:c(()=>[w(T(l.title),1)]),_:2},1032,["checked","onUpdate:checked"])]),_:2},1024))),128))]),_:1})]),default:c(()=>[u(g,{title:"ستونها"},{default:c(()=>[u(i,{type:"text",shape:"circle"},{icon:c(()=>[u(A,{icon:"vuesax-linear:setting-2",size:"16"})]),_:1})]),_:1})]),_:1}),u(g,{title:"بارگذاری مجدد"},{default:c(()=>[u(i,{class:"refresh-btn",type:"text",shape:"circle",loading:$.value,onClick:t[1]||(t[1]=l=>F())},{icon:c(()=>[u(A,{icon:"vuesax-linear:refresh-2",size:"16",class:"icon-spin"})]),_:1},8,["loading"])]),_:1}),L.value&&ae.value.length?(o(),y(E,{key:1,value:ge.value,class:"x-table__sort",size:"small",placeholder:"مرتبسازی","allow-clear":"",options:ae.value,onChange:ke},null,8,["value","options"])):p("",!0)])]),e.$slots.add?(o(),r("div",je,[z(e.$slots,"add",{},void 0,!0)])):p("",!0)]),I.value?(o(),r("div",Le,[(o(!0),r(S,null,B(s.filters,(l,d)=>(o(),r("div",{key:l.id,class:"x-table__filter-row"},[u(E,{value:l.field,"onUpdate:value":v=>l.field=v,placeholder:"ستون",style:{width:"180px"},options:he.value},null,8,["value","onUpdate:value","options"]),u(E,{value:l.op,"onUpdate:value":v=>l.op=v,placeholder:"شرط",style:{width:"130px"},options:ce},null,8,["value","onUpdate:value"]),ie(l.field)?(o(),y(E,{key:0,value:l.value,"onUpdate:value":v=>l.value=v,placeholder:"مقدار",style:{width:"200px"},options:ie(l.field)},null,8,["value","onUpdate:value","options"])):xe(l.field)?(o(),y(De,{key:1,value:l.value,"onUpdate:value":v=>l.value=v,placeholder:"مقدار",style:{width:"200px"},"value-format":"YYYY-MM-DD"},null,8,["value","onUpdate:value"])):(o(),y(ne,{key:2,value:l.value,"onUpdate:value":v=>l.value=v,placeholder:"مقدار",style:{width:"200px"}},null,8,["value","onUpdate:value"])),l.op==="between"?(o(),y(ne,{key:3,value:l.value2,"onUpdate:value":v=>l.value2=v,placeholder:"تا",style:{width:"200px"}},null,8,["value","onUpdate:value"])):p("",!0),u(i,{danger:"",onClick:v=>Te(d)},{default:c(()=>[...t[4]||(t[4]=[w("حذف",-1)])]),_:1},8,["onClick"])]))),128)),b("div",Qe,[u(i,{onClick:oe},{default:c(()=>[...t[5]||(t[5]=[w("افزودن فیلتر",-1)])]),_:1}),u(i,{type:"primary",onClick:$e},{default:c(()=>[...t[6]||(t[6]=[w("اعمال",-1)])]),_:1})])])):p("",!0),L.value?(o(),r("div",We,[u(qe,{spinning:$.value},{default:c(()=>[!k.value.length&&!$.value?(o(),y(Me,{key:0,description:H.emptyText},null,8,["description"])):p("",!0),x.hasSelection&&k.value.length?(o(),y(Q,{key:1,class:"x-table__select-all",checked:te.value,indeterminate:me.value&&!te.value,onChange:t[2]||(t[2]=l=>ye(l.target.checked))},{default:c(()=>[...t[7]||(t[7]=[w(" انتخاب همه در این صفحه ",-1)])]),_:1},8,["checked","indeterminate"])):p("",!0),(o(!0),r(S,null,B(k.value,l=>(o(),r("div",{key:String(l.id),class:W(["x-card",{"x-card--selected":x.hasSelection&&Y(l)}])},[b("div",Ge,[b("div",He,[x.hasSelection?(o(),y(Q,{key:0,checked:Y(l),onChange:d=>fe(l,d.target.checked)},null,8,["checked","onChange"])):p("",!0),P.value?(o(),r("span",Je,[z(e.$slots,P.value.slot,{text:V(l,P.value),record:l},void 0,!0)])):p("",!0),X.value?(o(),r("span",Ze,"#"+T(V(l,X.value)),1)):p("",!0),b("span",et,[(o(!0),r(S,null,B(Z.value,d=>(o(),r(S,{key:d.key},[d.slot?z(e.$slots,d.slot,{text:V(l,d),record:l},void 0,!0,0):(o(),r(S,{key:1},[w(T(le(l,d)),1)],64))],64))),128))])]),q.value?(o(),r("div",tt,[z(e.$slots,q.value.slot,{text:V(l,q.value),record:l},void 0,!0)])):p("",!0)]),ee.value.length?(o(),r("dl",lt,[(o(!0),r(S,null,B(ee.value,d=>(o(),r("div",{key:d.key,class:"x-card__row"},[b("dt",null,T(d.title),1),b("dd",null,[d.slot?z(e.$slots,d.slot,{text:V(l,d),record:l},void 0,!0,0):(o(),r(S,{key:1},[w(T(le(l,d)),1)],64))])]))),128))])):p("",!0)],2))),128))]),_:3},8,["spinning"]),!x.model._hidePagination&&s.total>0?(o(),r("div",at,[b("span",st,T(s.total)+" مورد",1),u(Pe,{size:"small","show-less-items":"",current:s.page,"page-size":s.limit,total:s.total,"show-size-changer":!1,onChange:be},null,8,["current","page-size","total"])])):p("",!0)])):(o(),y(Be,{key:2,columns:pe.value,"data-source":k.value,loading:$.value,pagination:we.value,locale:H,"row-selection":de.value,"row-key":"id",size:G(j).isMobile?"small":"middle",scroll:G(j).isSmallScreen?{x:"max-content"}:void 0,bordered:"",onChange:Ie},{bodyCell:c(({column:l,record:d,text:v})=>[J(l)?z(e.$slots,J(l),{text:v,record:d},void 0,!0,0):l.__date?(o(),r(S,{key:1},[w(T(G(ue)(v)),1)],64)):p("",!0)]),_:3},8,["columns","data-source","loading","pagination","row-selection","size","scroll"]))],2)}}}),ut=Xe(it,[["__scopeId","data-v-240cae87"]]);class dt{constructor(n,U){this.show=!0,this.__sorter=!0,this.filtered=!1,this.key=n,this.title=U,this.dataIndex=n,n==="id"&&(this.show=!1)}__filter(){this.filtered=!0,this.scopedSlots||(this.scopedSlots={}),this.scopedSlots.filterDropdown=`${this.key}_filterDropdown`,this.scopedSlots.filterIcon=`${this.key}_filterIcon`}filterKey(n){return this.__fkey=n,this}renderSlot(n){return this.scopedSlots||(this.scopedSlots={}),this.scopedSlots.customRender=n,this}filterText(){return this.__filter(),this.filterType="default",this}filterSwitch(){return this.__filter(),this.filterType="switch",this}filterQuery(n){return this.__filter(),this.filterType="query",this.filterAction=n,this}filterDate(){return this.__filter(),this.filterType="date",this}filterNumber(){return this.__filter(),this.filterType="number",this}filterSelect(n){return this.__filter(),this.filterType="select",this.filterItems=n,this}noSort(){return this.__sorter=!1,this}hidden(){return this.show=!1,this}setWidth(n){return this.width=n,this}}class ct{constructor(n,U){this.cols=[],this._hidePagination=!1,this._hideSearch=!1,this._noFilters=!1,this.url=n,this.title=U}add(n){return this.cols.push(n),this}addDefaultFilter(n){return this.defaultFilters||(this.defaultFilters=[]),this.defaultFilters.push(n),this}hidePagination(){return this._hidePagination=!0,this}hideSearch(){return this._hideSearch=!0,this}noFilters(){return this._noFilters=!0,this}getSortFields(){return this.cols.filter(n=>n.__sorter)}}export{ut as X,ct as a,dt as b};
|