Files
tehran_tala/apps/admin-panel/dist/assets/model-BWgePExC.js
T
2026-10-11 15:24:16 +03:30

2 lines
10 KiB
JavaScript

import{c as n,I as W,d as ve,v as me,o as p,b as y,n as U,a as b,i as x,w as u,s as ye,f as S,h as F,F as z,e as R,X as be,Y,t as E,p as g,l as C,y as ge,x as we,r as v,_ as ke}from"./index-u3RAcmrU.js";import{g as xe}from"./filters-ByyR-YPd.js";import{S as Se}from"./SettingOutlined-D0fY98sW.js";var Oe={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 A(o){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?Object(arguments[t]):{},s=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(s=s.concat(Object.getOwnPropertySymbols(r).filter(function(_){return Object.getOwnPropertyDescriptor(r,_).enumerable}))),s.forEach(function(_){Fe(o,_,r[_])})}return o}function Fe(o,t,r){return t in o?Object.defineProperty(o,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[t]=r,o}var D=function(t,r){var s=A({},t,r.attrs);return n(W,A({},s,{icon:Oe}),null)};D.displayName="FilterOutlined";D.inheritAttrs=!1;var Ce={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 Q(o){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?Object(arguments[t]):{},s=Object.keys(r);typeof Object.getOwnPropertySymbols=="function"&&(s=s.concat(Object.getOwnPropertySymbols(r).filter(function(_){return Object.getOwnPropertyDescriptor(r,_).enumerable}))),s.forEach(function(_){Ve(o,_,r[_])})}return o}function Ve(o,t,r){return t in o?Object.defineProperty(o,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[t]=r,o}var H=function(t,r){var s=Q({},t,r.attrs);return n(W,Q({},s,{icon:Ce}),null)};H.displayName="PrinterOutlined";H.inheritAttrs=!1;const Pe={class:"x-table"},Te={class:"x-table__toolbar"},Ue={class:"x-table__search-group"},$e={class:"x-table__actions"},Ie={key:0,class:"x-table__add"},ze={key:0,class:"x-table__filters"},De={class:"x-table__filter-actions"},He=ve({__name:"XTable",props:{model:{},hasSelection:{type:Boolean,default:!1},modelValue:{default:()=>[]}},emits:["query","update:modelValue"],setup(o,{expose:t,emit:r}){const s=o,_=r,G=g(()=>s.hasSelection?{selectedRowKeys:s.modelValue.map(e=>e.id),onChange:(e,l)=>{_("update:modelValue",l)}}:void 0),M=C([]),V=C(!1),w=C(!1),P=C(void 0),j=C("asc"),i=ge({search:void 0,filters:[],total:0,limit:10,page:1}),J={emptyText:"هیج رکوردی یافت نشد."},K=[{value:"=",label:"برابر"},{value:"!=",label:"نامساوی"},{value:"like",label:"شامل"},{value:">",label:"بزرگتر"},{value:">=",label:"بزرگتر مساوی"},{value:"<",label:"کوچکتر"},{value:"<=",label:"کوچکتر مساوی"},{value:"between",label:"بین"}],T=g(()=>{var e;return((e=s.model)==null?void 0:e.cols)??[]}),$=g(()=>T.value.filter(e=>e.show)),Z=g(()=>T.value.filter(e=>e.filtered).map(e=>({value:e.__fkey??e.key,label:e.title}))),ee=g(()=>P.value?`${j.value==="asc"?"+":"-"}${P.value}`:void 0),te=g(()=>$.value.map(e=>{var l;return{key:e.key,title:e.title,dataIndex:e.dataIndex.includes(".")?e.dataIndex.split("."):e.dataIndex,sorter:e.__sorter,width:e.width,__slot:(l=e.scopedSlots)==null?void 0:l.customRender,__date:e.filterType==="date"}}));function q(e){return e.__slot}function N(e){if(e)return T.value.find(l=>(l.__fkey??l.key)===e)}function B(e){const l=N(e);if(!((l==null?void 0:l.filterType)!=="select"||!l.filterItems))return Object.entries(l.filterItems).map(([c,d])=>({value:c,label:d}))}function le(e){var l;return((l=N(e))==null?void 0:l.filterType)==="date"}const ae=g(()=>{var e;return(e=s.model)!=null&&e._hidePagination?!1:{current:i.page,pageSize:i.limit,total:i.total,showSizeChanger:!0}});function ie(e){var f;const l={};$.value.forEach(m=>{l[m.key]=m.title});const c=$.value.map(m=>m.key),d={search:i.search,filters:i.filters.filter(m=>m.field&&m.op),total:i.total,limit:i.limit,page:i.page,order:ee.value,select:c,titles:l,report_title:(f=s.model)==null?void 0:f.title};return e?{...d,op:e}:d}async function k(e){var l,c,d;if(s.model)try{V.value=!0;const{data:f}=await we.post(s.model.url,ie(e));M.value=f.rows,i.total=((l=f.query)==null?void 0:l.total)??0,i.page=((c=f.query)==null?void 0:c.page)??i.page,i.limit=((d=f.query)==null?void 0:d.limit)??i.limit,_("query",f.query)}catch(f){throw console.log(f),f}finally{V.value=!1}}function re(e){i.search=e,i.page=1,k()}function oe(){w.value=!w.value,w.value&&i.filters.length===0&&X()}function X(){i.filters.push({id:parseFloat(`${i.filters.length}.${Math.floor(Math.random()*1e3)}`)})}function ne(e){i.filters.splice(e,1)}function se(){w.value=!1,i.page=1,k()}function ue(e,l,c){i.page=e.current??1,i.limit=e.pageSize??i.limit,c!=null&&c.columnKey&&c.order?(P.value=String(c.columnKey),j.value=c.order==="ascend"?"asc":"desc"):P.value=void 0,k()}return me(()=>{var e;for(const l of((e=s.model)==null?void 0:e.defaultFilters)??[])i.filters.push({id:Math.random(),...l});k()}),t({fetch:k}),(e,l)=>{const c=v("a-input-search"),d=v("a-button"),f=v("a-badge"),m=v("a-tooltip"),ce=v("a-checkbox"),de=v("a-menu-item"),he=v("a-menu"),pe=v("a-dropdown"),I=v("a-select"),fe=v("a-date-picker"),L=v("a-input"),_e=v("a-table");return p(),y("div",Pe,[U("div",Te,[U("div",Ue,[o.model._hideSearch?x("",!0):(p(),b(c,{key:0,value:i.search,"onUpdate:value":l[0]||(l[0]=a=>i.search=a),placeholder:"جستجو","allow-clear":"",style:{"max-width":"260px"},onSearch:re},null,8,["value"])),U("div",$e,[o.model._noFilters?x("",!0):(p(),b(f,{key:0,count:i.filters.length},{default:u(()=>[n(d,{type:"text",class:ye({"x-table__action--active":w.value}),onClick:oe},{icon:u(()=>[n(F(D))]),default:u(()=>[l[2]||(l[2]=S(" فیلتر ",-1))]),_:1},8,["class"])]),_:1},8,["count"])),n(m,{title:"چاپ"},{default:u(()=>[n(d,{type:"text",shape:"circle"},{icon:u(()=>[n(F(H))]),_:1})]),_:1}),n(pe,{trigger:["click"]},{overlay:u(()=>[n(he,null,{default:u(()=>[(p(!0),y(z,null,R(T.value,a=>(p(),b(de,{key:a.key},{default:u(()=>[n(ce,{checked:a.show,"onUpdate:checked":O=>a.show=O},{default:u(()=>[S(E(a.title),1)]),_:2},1032,["checked","onUpdate:checked"])]),_:2},1024))),128))]),_:1})]),default:u(()=>[n(m,{title:"ستون‌ها"},{default:u(()=>[n(d,{type:"text",shape:"circle"},{icon:u(()=>[n(F(Se))]),_:1})]),_:1})]),_:1}),n(m,{title:"بارگذاری مجدد"},{default:u(()=>[n(d,{class:"refresh-btn",type:"text",shape:"circle",loading:V.value,onClick:l[1]||(l[1]=a=>k())},{icon:u(()=>[n(F(be))]),_:1},8,["loading"])]),_:1})])]),e.$slots.add?(p(),y("div",Ie,[Y(e.$slots,"add",{},void 0,!0)])):x("",!0)]),w.value?(p(),y("div",ze,[(p(!0),y(z,null,R(i.filters,(a,O)=>(p(),y("div",{key:a.id,class:"x-table__filter-row"},[n(I,{value:a.field,"onUpdate:value":h=>a.field=h,placeholder:"ستون",style:{width:"180px"},options:Z.value},null,8,["value","onUpdate:value","options"]),n(I,{value:a.op,"onUpdate:value":h=>a.op=h,placeholder:"شرط",style:{width:"130px"},options:K},null,8,["value","onUpdate:value"]),B(a.field)?(p(),b(I,{key:0,value:a.value,"onUpdate:value":h=>a.value=h,placeholder:"مقدار",style:{width:"200px"},options:B(a.field)},null,8,["value","onUpdate:value","options"])):le(a.field)?(p(),b(fe,{key:1,value:a.value,"onUpdate:value":h=>a.value=h,placeholder:"مقدار",style:{width:"200px"},"value-format":"YYYY-MM-DD"},null,8,["value","onUpdate:value"])):(p(),b(L,{key:2,value:a.value,"onUpdate:value":h=>a.value=h,placeholder:"مقدار",style:{width:"200px"}},null,8,["value","onUpdate:value"])),a.op==="between"?(p(),b(L,{key:3,value:a.value2,"onUpdate:value":h=>a.value2=h,placeholder:"تا",style:{width:"200px"}},null,8,["value","onUpdate:value"])):x("",!0),n(d,{danger:"",onClick:h=>ne(O)},{default:u(()=>[...l[3]||(l[3]=[S("حذف",-1)])]),_:1},8,["onClick"])]))),128)),U("div",De,[n(d,{onClick:X},{default:u(()=>[...l[4]||(l[4]=[S("افزودن فیلتر",-1)])]),_:1}),n(d,{type:"primary",onClick:se},{default:u(()=>[...l[5]||(l[5]=[S("اعمال",-1)])]),_:1})])])):x("",!0),n(_e,{columns:te.value,"data-source":M.value,loading:V.value,pagination:ae.value,locale:J,"row-selection":G.value,"row-key":"id",size:"middle",bordered:"",onChange:ue},{bodyCell:u(({column:a,record:O,text:h})=>[q(a)?Y(e.$slots,q(a),{text:h,record:O},void 0,!0,0):a.__date?(p(),y(z,{key:1},[S(E(F(xe)(h)),1)],64)):x("",!0)]),_:3},8,["columns","data-source","loading","pagination","row-selection"])])}}}),Ne=ke(He,[["__scopeId","data-v-ba485c1a"]]);class Be{constructor(t,r){this.show=!0,this.__sorter=!0,this.filtered=!1,this.key=t,this.title=r,this.dataIndex=t}__filter(){this.filtered=!0,this.scopedSlots||(this.scopedSlots={}),this.scopedSlots.filterDropdown=`${this.key}_filterDropdown`,this.scopedSlots.filterIcon=`${this.key}_filterIcon`}filterKey(t){return this.__fkey=t,this}renderSlot(t){return this.scopedSlots||(this.scopedSlots={}),this.scopedSlots.customRender=t,this}filterText(){return this.__filter(),this.filterType="default",this}filterSwitch(){return this.__filter(),this.filterType="switch",this}filterQuery(t){return this.__filter(),this.filterType="query",this.filterAction=t,this}filterDate(){return this.__filter(),this.filterType="date",this}filterNumber(){return this.__filter(),this.filterType="number",this}filterSelect(t){return this.__filter(),this.filterType="select",this.filterItems=t,this}noSort(){return this.__sorter=!1,this}hidden(){return this.show=!1,this}setWidth(t){return this.width=t,this}}class Xe{constructor(t,r){this.cols=[],this._hidePagination=!1,this._hideSearch=!1,this._noFilters=!1,this.url=t,this.title=r}add(t){return this.cols.push(t),this}addDefaultFilter(t){return this.defaultFilters||(this.defaultFilters=[]),this.defaultFilters.push(t),this}hidePagination(){return this._hidePagination=!0,this}hideSearch(){return this._hideSearch=!0,this}noFilters(){return this._noFilters=!0,this}getSortFields(){return this.cols.filter(t=>t.__sorter)}}export{Ne as X,Xe as a,Be as b};