Files
tehran_taj/apps/admin-panel/dist/assets/model-jivQdHnP.js
T

2 lines
14 KiB
JavaScript

import{c,I as ve,d as Re,v as Ee,x as Le,o,b as h,q as Q,p as w,a as k,i as m,w as p,f as O,h as $,F as C,e as B,a6 as Ae,a7 as M,t as P,s as f,m as H,z as ue,y as Xe,r as y,_ as Ye}from"./index-CfFqH7Y1.js";import{g as de}from"./filters-DWtPewx7.js";import{S as Ke}from"./SettingOutlined-BsS6G0WY.js";var Qe={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M880.1 154H143.9c-24.5 0-39.8 26.7-27.5 48L349 597.4V838c0 17.7 14.2 32 31.8 32h262.4c17.6 0 31.8-14.3 31.8-32V597.4L907.7 202c12.2-21.3-3.1-48-27.6-48zM603.4 798H420.6V642h182.9v156zm9.6-236.6l-9.5 16.6h-183l-9.5-16.6L212.7 226h598.6L613 561.4z"}}]},name:"filter",theme:"outlined"};function ce(r){for(var a=1;a<arguments.length;a++){var u=arguments[a]!=null?Object(arguments[a]):{},d=Object.keys(u);typeof Object.getOwnPropertySymbols=="function"&&(d=d.concat(Object.getOwnPropertySymbols(u).filter(function(g){return Object.getOwnPropertyDescriptor(u,g).enumerable}))),d.forEach(function(g){We(r,g,u[g])})}return r}function We(r,a,u){return a in r?Object.defineProperty(r,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):r[a]=u,r}var W=function(a,u){var d=ce({},a,u.attrs);return c(ve,ce({},d,{icon:Qe}),null)};W.displayName="FilterOutlined";W.inheritAttrs=!1;var Ge={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M820 436h-40c-4.4 0-8 3.6-8 8v40c0 4.4 3.6 8 8 8h40c4.4 0 8-3.6 8-8v-40c0-4.4-3.6-8-8-8zm32-104H732V120c0-4.4-3.6-8-8-8H300c-4.4 0-8 3.6-8 8v212H172c-44.2 0-80 35.8-80 80v328c0 17.7 14.3 32 32 32h168v132c0 4.4 3.6 8 8 8h424c4.4 0 8-3.6 8-8V772h168c17.7 0 32-14.3 32-32V412c0-44.2-35.8-80-80-80zM360 180h304v152H360V180zm304 664H360V568h304v276zm200-140H732V500H292v204H160V412c0-6.6 5.4-12 12-12h680c6.6 0 12 5.4 12 12v292z"}}]},name:"printer",theme:"outlined"};function he(r){for(var a=1;a<arguments.length;a++){var u=arguments[a]!=null?Object(arguments[a]):{},d=Object.keys(u);typeof Object.getOwnPropertySymbols=="function"&&(d=d.concat(Object.getOwnPropertySymbols(u).filter(function(g){return Object.getOwnPropertyDescriptor(u,g).enumerable}))),d.forEach(function(g){Je(r,g,u[g])})}return r}function Je(r,a,u){return a in r?Object.defineProperty(r,a,{value:u,enumerable:!0,configurable:!0,writable:!0}):r[a]=u,r}var G=function(a,u){var d=he({},a,u.attrs);return c(ve,he({},d,{icon:Ge}),null)};G.displayName="PrinterOutlined";G.inheritAttrs=!1;const Ze={class:"x-table__toolbar"},et={class:"x-table__search-group"},tt={class:"x-table__actions"},lt={key:0,class:"x-table__add"},at={key:0,class:"x-table__filters"},it={class:"x-table__filter-actions"},st={key:1,class:"x-table__cards"},nt={class:"x-card__head"},ot={class:"x-card__title"},rt={key:1,class:"x-card__media"},ut={key:2,class:"x-card__id"},dt={class:"x-card__name"},ct={key:0,class:"x-card__actions"},ht={key:0,class:"x-card__body"},vt={key:0,class:"x-table__card-pager"},pt={class:"x-table__card-total"},ft=Re({__name:"XTable",props:{model:{},hasSelection:{type:Boolean,default:!1},modelValue:{default:()=>[]},mobileCards:{type:Boolean,default:!1}},emits:["query","update:modelValue"],setup(r,{expose:a,emit:u}){const d=r,g=Ee(),Y=f(()=>d.mobileCards&&g.isMobile),N=u,pe=f(()=>d.hasSelection?{selectedRowKeys:d.modelValue.map(e=>e.id),onChange:(e,t)=>{N("update:modelValue",t)}}:void 0),S=H([]),T=H(!1),z=H(!1),F=H(void 0),R=H("asc"),s=ue({search:void 0,filters:[],total:0,limit:10,page:1}),J={emptyText:"هیج رکوردی یافت نشد."},fe=[{value:"=",label:"برابر"},{value:"!=",label:"نامساوی"},{value:"like",label:"شامل"},{value:">",label:"بزرگتر"},{value:">=",label:"بزرگتر مساوی"},{value:"<",label:"کوچکتر"},{value:"<=",label:"کوچکتر مساوی"},{value:"between",label:"بین"}],E=f(()=>d.model?ue(d.model).cols:[]),U=f(()=>E.value.filter(e=>e.show)),_e=f(()=>E.value.filter(e=>e.filtered).map(e=>({value:e.__fkey??e.key,label:e.title}))),me=f(()=>F.value?`${R.value==="asc"?"+":"-"}${F.value}`:void 0),ye=f(()=>U.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 Z(e){return e.__slot}const ge=["opt","op","action"],D=f(()=>U.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"}})),j=f(()=>D.value.find(e=>ge.includes(e.key)&&e.slot)),L=f(()=>D.value.find(e=>e.key==="id")),q=f(()=>D.value.find(e=>e.slot==="image")),ee=f(()=>{const e=D.value.filter(n=>n!==j.value&&n!==L.value&&n!==q.value),t=e.find(n=>n.key==="name"||n.key==="title");if(t)return[t];const i=e.find(n=>n.key==="fname");return i?[i,...e.filter(n=>n.key==="lname")]:e.slice(0,1)}),te=f(()=>D.value.filter(e=>e!==j.value&&e!==L.value&&e!==q.value&&!ee.value.includes(e)));function A(e){return d.modelValue.some(t=>t.id===e.id)}function be(e,t){const i=d.modelValue.filter(n=>n.id!==e.id);N("update:modelValue",t?[...i,e]:i)}const le=f(()=>S.value.length>0&&S.value.every(A)),ke=f(()=>S.value.some(A));function xe(e){const t=new Set(S.value.map(n=>n.id)),i=d.modelValue.filter(n=>!t.has(n.id));N("update:modelValue",e?[...i,...S.value]:i)}function I(e,t){return t.path.reduce((i,n)=>i&&typeof i=="object"?i[n]:void 0,e)}function ae(e,t){const i=I(e,t);return i==null||i===""?"-":t.date?de(i):i}const ie=f(()=>U.value.filter(e=>e.__sorter).flatMap(e=>[{value:`${e.key}|asc`,label:`${e.title} ↑`},{value:`${e.key}|desc`,label:`${e.title} ↓`}])),Se=f(()=>F.value?`${F.value}|${R.value}`:void 0);function we(e){if(e){const[t,i]=e.split("|");F.value=t,R.value=i}else F.value=void 0;s.page=1,V()}function Oe(e,t){var i;s.page=e,s.limit=t,V(),(i=document.getElementById("content-area"))==null||i.scrollTo({top:0,behavior:"smooth"})}function se(e){if(e)return E.value.find(t=>(t.__fkey??t.key)===e)}function ne(e){const t=se(e);if(!((t==null?void 0:t.filterType)!=="select"||!t.filterItems))return Object.entries(t.filterItems).map(([i,n])=>({value:i,label:n}))}function Ce(e){var t;return((t=se(e))==null?void 0:t.filterType)==="date"}const Fe=f(()=>{var e;return(e=d.model)!=null&&e._hidePagination?!1:{current:s.page,pageSize:s.limit,total:s.total,showSizeChanger:!0}});function Ve(e){var b;const t={};U.value.forEach(x=>{t[x.key]=x.title});const i=U.value.map(x=>x.key),n={search:s.search,filters:s.filters.filter(x=>x.field&&x.op),total:s.total,limit:s.limit,page:s.page,order:me.value,select:i,titles:t,report_title:(b=d.model)==null?void 0:b.title};return e?{...n,op:e}:n}async function V(e){var t,i,n;if(d.model)try{T.value=!0;const{data:b}=await Xe.post(d.model.url,Ve(e));S.value=b.rows,s.total=((t=b.query)==null?void 0:t.total)??0,s.page=((i=b.query)==null?void 0:i.page)??s.page,s.limit=((n=b.query)==null?void 0:n.limit)??s.limit,N("query",b.query)}catch(b){throw console.log(b),b}finally{T.value=!1}}function $e(e){s.search=e,s.page=1,V()}function Pe(){z.value=!z.value,z.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 ze(){z.value=!1,s.page=1,V()}function Ie(e,t,i){s.page=e.current??1,s.limit=e.pageSize??s.limit,i!=null&&i.columnKey&&i.order?(F.value=String(i.columnKey),R.value=i.order==="ascend"?"asc":"desc"):F.value=void 0,V()}return Le(()=>{var e;for(const t of((e=d.model)==null?void 0:e.defaultFilters)??[])s.filters.push({id:Math.random(),...t});V()}),a({fetch:V}),(e,t)=>{const i=y("a-input-search"),n=y("a-button"),b=y("a-badge"),x=y("a-tooltip"),K=y("a-checkbox"),Me=y("a-menu-item"),Ue=y("a-menu"),De=y("a-dropdown"),X=y("a-select"),je=y("a-date-picker"),re=y("a-input"),qe=y("a-empty"),Be=y("a-spin"),He=y("a-pagination"),Ne=y("a-table");return o(),h("div",{class:Q(["x-table",{"x-table--cards":Y.value}])},[w("div",Ze,[w("div",et,[r.model._hideSearch?m("",!0):(o(),k(i,{key:0,value:s.search,"onUpdate:value":t[0]||(t[0]=l=>s.search=l),class:"x-table__search",placeholder:"جستجو","allow-clear":"",onSearch:$e},null,8,["value"])),w("div",tt,[r.model._noFilters?m("",!0):(o(),k(b,{key:0,count:s.filters.length},{default:p(()=>[c(n,{type:"text",class:Q({"x-table__action--active":z.value}),onClick:Pe},{icon:p(()=>[c($(W))]),default:p(()=>[t[3]||(t[3]=O(" فیلتر ",-1))]),_:1},8,["class"])]),_:1},8,["count"])),c(x,{title:"چاپ"},{default:p(()=>[c(n,{type:"text",shape:"circle"},{icon:p(()=>[c($(G))]),_:1})]),_:1}),c(De,{trigger:["click"]},{overlay:p(()=>[c(Ue,null,{default:p(()=>[(o(!0),h(C,null,B(E.value,l=>(o(),k(Me,{key:l.key},{default:p(()=>[c(K,{checked:l.show,"onUpdate:checked":v=>l.show=v},{default:p(()=>[O(P(l.title),1)]),_:2},1032,["checked","onUpdate:checked"])]),_:2},1024))),128))]),_:1})]),default:p(()=>[c(x,{title:"ستون‌ها"},{default:p(()=>[c(n,{type:"text",shape:"circle"},{icon:p(()=>[c($(Ke))]),_:1})]),_:1})]),_:1}),c(x,{title:"بارگذاری مجدد"},{default:p(()=>[c(n,{class:"refresh-btn",type:"text",shape:"circle",loading:T.value,onClick:t[1]||(t[1]=l=>V())},{icon:p(()=>[c($(Ae))]),_:1},8,["loading"])]),_:1}),Y.value&&ie.value.length?(o(),k(X,{key:1,value:Se.value,class:"x-table__sort",size:"small",placeholder:"مرتب‌سازی","allow-clear":"",options:ie.value,onChange:we},null,8,["value","options"])):m("",!0)])]),e.$slots.add?(o(),h("div",lt,[M(e.$slots,"add",{},void 0,!0)])):m("",!0)]),z.value?(o(),h("div",at,[(o(!0),h(C,null,B(s.filters,(l,v)=>(o(),h("div",{key:l.id,class:"x-table__filter-row"},[c(X,{value:l.field,"onUpdate:value":_=>l.field=_,placeholder:"ستون",style:{width:"180px"},options:_e.value},null,8,["value","onUpdate:value","options"]),c(X,{value:l.op,"onUpdate:value":_=>l.op=_,placeholder:"شرط",style:{width:"130px"},options:fe},null,8,["value","onUpdate:value"]),ne(l.field)?(o(),k(X,{key:0,value:l.value,"onUpdate:value":_=>l.value=_,placeholder:"مقدار",style:{width:"200px"},options:ne(l.field)},null,8,["value","onUpdate:value","options"])):Ce(l.field)?(o(),k(je,{key:1,value:l.value,"onUpdate:value":_=>l.value=_,placeholder:"مقدار",style:{width:"200px"},"value-format":"YYYY-MM-DD"},null,8,["value","onUpdate:value"])):(o(),k(re,{key:2,value:l.value,"onUpdate:value":_=>l.value=_,placeholder:"مقدار",style:{width:"200px"}},null,8,["value","onUpdate:value"])),l.op==="between"?(o(),k(re,{key:3,value:l.value2,"onUpdate:value":_=>l.value2=_,placeholder:"تا",style:{width:"200px"}},null,8,["value","onUpdate:value"])):m("",!0),c(n,{danger:"",onClick:_=>Te(v)},{default:p(()=>[...t[4]||(t[4]=[O("حذف",-1)])]),_:1},8,["onClick"])]))),128)),w("div",it,[c(n,{onClick:oe},{default:p(()=>[...t[5]||(t[5]=[O("افزودن فیلتر",-1)])]),_:1}),c(n,{type:"primary",onClick:ze},{default:p(()=>[...t[6]||(t[6]=[O("اعمال",-1)])]),_:1})])])):m("",!0),Y.value?(o(),h("div",st,[c(Be,{spinning:T.value},{default:p(()=>[!S.value.length&&!T.value?(o(),k(qe,{key:0,description:J.emptyText},null,8,["description"])):m("",!0),r.hasSelection&&S.value.length?(o(),k(K,{key:1,class:"x-table__select-all",checked:le.value,indeterminate:ke.value&&!le.value,onChange:t[2]||(t[2]=l=>xe(l.target.checked))},{default:p(()=>[...t[7]||(t[7]=[O(" انتخاب همه در این صفحه ",-1)])]),_:1},8,["checked","indeterminate"])):m("",!0),(o(!0),h(C,null,B(S.value,l=>(o(),h("div",{key:String(l.id),class:Q(["x-card",{"x-card--selected":r.hasSelection&&A(l)}])},[w("div",nt,[w("div",ot,[r.hasSelection?(o(),k(K,{key:0,checked:A(l),onChange:v=>be(l,v.target.checked)},null,8,["checked","onChange"])):m("",!0),q.value?(o(),h("span",rt,[M(e.$slots,q.value.slot,{text:I(l,q.value),record:l},void 0,!0)])):m("",!0),L.value?(o(),h("span",ut,"#"+P(I(l,L.value)),1)):m("",!0),w("span",dt,[(o(!0),h(C,null,B(ee.value,v=>(o(),h(C,{key:v.key},[v.slot?M(e.$slots,v.slot,{text:I(l,v),record:l},void 0,!0,0):(o(),h(C,{key:1},[O(P(ae(l,v)),1)],64))],64))),128))])]),j.value?(o(),h("div",ct,[M(e.$slots,j.value.slot,{text:I(l,j.value),record:l},void 0,!0)])):m("",!0)]),te.value.length?(o(),h("dl",ht,[(o(!0),h(C,null,B(te.value,v=>(o(),h("div",{key:v.key,class:"x-card__row"},[w("dt",null,P(v.title),1),w("dd",null,[v.slot?M(e.$slots,v.slot,{text:I(l,v),record:l},void 0,!0,0):(o(),h(C,{key:1},[O(P(ae(l,v)),1)],64))])]))),128))])):m("",!0)],2))),128))]),_:3},8,["spinning"]),!r.model._hidePagination&&s.total>0?(o(),h("div",vt,[w("span",pt,P(s.total)+" مورد",1),c(He,{size:"small","show-less-items":"",current:s.page,"page-size":s.limit,total:s.total,"show-size-changer":!1,onChange:Oe},null,8,["current","page-size","total"])])):m("",!0)])):(o(),k(Ne,{key:2,columns:ye.value,"data-source":S.value,loading:T.value,pagination:Fe.value,locale:J,"row-selection":pe.value,"row-key":"id",size:$(g).isMobile?"small":"middle",scroll:$(g).isSmallScreen?{x:"max-content"}:void 0,bordered:"",onChange:Ie},{bodyCell:p(({column:l,record:v,text:_})=>[Z(l)?M(e.$slots,Z(l),{text:_,record:v},void 0,!0,0):l.__date?(o(),h(C,{key:1},[O(P($(de)(_)),1)],64)):m("",!0)]),_:3},8,["columns","data-source","loading","pagination","row-selection","size","scroll"]))],2)}}}),gt=Ye(ft,[["__scopeId","data-v-e767d7dc"]]);class bt{constructor(a,u){this.show=!0,this.__sorter=!0,this.filtered=!1,this.key=a,this.title=u,this.dataIndex=a,a==="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(a){return this.__fkey=a,this}renderSlot(a){return this.scopedSlots||(this.scopedSlots={}),this.scopedSlots.customRender=a,this}filterText(){return this.__filter(),this.filterType="default",this}filterSwitch(){return this.__filter(),this.filterType="switch",this}filterQuery(a){return this.__filter(),this.filterType="query",this.filterAction=a,this}filterDate(){return this.__filter(),this.filterType="date",this}filterNumber(){return this.__filter(),this.filterType="number",this}filterSelect(a){return this.__filter(),this.filterType="select",this.filterItems=a,this}noSort(){return this.__sorter=!1,this}hidden(){return this.show=!1,this}setWidth(a){return this.width=a,this}}class kt{constructor(a,u){this.cols=[],this._hidePagination=!1,this._hideSearch=!1,this._noFilters=!1,this.url=a,this.title=u}add(a){return this.cols.push(a),this}addDefaultFilter(a){return this.defaultFilters||(this.defaultFilters=[]),this.defaultFilters.push(a),this}hidePagination(){return this._hidePagination=!0,this}hideSearch(){return this._hideSearch=!0,this}noFilters(){return this._noFilters=!0,this}getSortFields(){return this.cols.filter(a=>a.__sorter)}}export{gt as X,kt as a,bt as b};