2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
|
import{_ as D,a as d,S as x}from"./main-9b36f05f.js";import{r as S,a as h,o as r,s as b,e as t,d as a,aa as v,b as m,w as i,u as T,ab as U,t as c,A as w,c as y}from"./vendor-adef9cb4.js";const j={name:"buysellByPerson",data:()=>({loading:S(!0),sumSelected:0,sumTotal:0,year:{},persons:[],types:[{id:"buy",label:"خرید"},{id:"sell",label:"فروش"},{id:"rfbuy",label:"برگشت از خرید"},{id:"rfsell",label:"برگشت از فروش"},{id:"all",label:"همه موارد"}],dateStart:"",dateEnd:"",selectedType:{},selectedPerson:{},searchValue:"",loading:S(!0),items:[],itemsSelected:[],headers:[{text:"کد",value:"code"},{text:"سند حسابداری",value:"docCode"},{text:"نوع",value:"type"},{text:"تاریخ",value:"date"},{text:"کالا / خدمات",value:"khadamat",sortable:!0},{text:"نام کالا و خدمات",value:"name",sortable:!0},{text:"واحد شمارش",value:"unit",sortable:!0},{text:"تعداد",value:"count",sortable:!0},{text:"مبلغ فی",value:"priceOne",sortable:!0},{text:"مبلغ کل",value:"priceAll",sortable:!0},{text:"تجمعی",value:"amountInc",sortable:!0}]}),methods:{searchPerson(s,e){e(!0),d.post("/api/person/list/search",{search:s}).then(o=>{this.persons=o.data,e(!1)})},loadData(){d.post("/api/person/list/search").then(s=>{this.persons=s.data,this.persons.length!=0&&(this.selectedPerson=this.persons[0]),this.selectedType=this.types[0],this.loading=!1}),d.post("/api/year/get").then(s=>{this.year=s.data,this.loading=!1})},filter(){this.loading=!0,this.itemsSelected=[],d.post("/api/report/person/buysell",{type:this.selectedType.id,person:this.selectedPerson.code,dateStart:this.dateStart,dateEnd:this.dateEnd}).then(s=>{this.items=s.data;let e=0;this.sumTotal=0,this.items.forEach(o=>{e+=parseInt(o.priceAll.replaceAll(",","")),o.amountInc=this.$filters.formatNumber(e)}),this.sumTotal=e,this.loading=!1})},excellOutput(s=!0){s?d({method:"post",url:"/api/report/person/buysell/export/excel",responseType:"arraybuffer",data:{items:this.items}}).then(e=>{window.URL.createObjectURL(new Blob([e.data]));var o=window.URL.createObjectURL(new Blob([e.data])),n=document.createElement("a");n.href=o,n.setAttribute("download","buysell-report-list.xlsx"),document.body.appendChild(n),n.click()}):this.itemsSelected.length===0?x.fire({text:"هیچ آیتمی انتخاب نشده است.",icon:"info",confirmButtonText:"قبول"}):d({method:"post",url:"/api/report/person/buysell/export/excel",responseType:"arraybuffer",data:{items:this.itemsSelected}}).then(e=>{window.URL.createObjectURL(new Blob([e.data]));var o=window.URL.createObjectURL(new Blob([e.data])),n=document.createElement("a");n.href=o,n.setAttribute("download","buysell-report-list.xlsx"),document.body.appendChild(n),n.click()})},print(s=!0){s?d.post("/api/person/list/print").then(e=>{this.printID=e.data.id,window.open(this.$API_URL+"/front/print/"+this.printID,"_blank","noreferrer")}):this.itemsSelected.length===0?x.fire({text:"هیچ آیتمی انتخاب نشده است.",icon:"info",confirmButtonText:"قبول"}):d.post("/api/person/list/print",{items:this.itemsSelected}).then(e=>{this.printID=e.data.id,window.open(this.$API_URL+"/front/print/"+this.printID,"_blank","noreferrer")})}},beforeMount(){this.loadData()},watch:{dateStart:{handler:function(s,e){this.filter()},deep:!1},dateEnd:{handler:function(s,e){this.filter()},deep:!1},selectedPerson:{handler:function(s,e){this.filter()},deep:!0},selectedType:{handler:function(s,e){this.filter()},deep:!0},itemsSelected:{handler:function(s,e){this.sumSelected=0,this.itemsSelected.forEach(o=>{this.sumSelected+=parseInt(o.priceAll.replaceAll(",",""))})},deep:!0}}},M={class:"block block-content-full"},I={id:"fixed-header",class:"block-header block-header-default bg-gray-light pt-2 pb-1"},L={class:"block-title text-primary-dark"},Y={class:"block-options"},P={hidden:"",class:"dropdown"},R={class:"dropdown-menu"},E={class:"dropdown"},$={class:"dropdown-menu"},A={class:"block-content pt-1 pb-3"},B={class:"row"},N={class:"col-sm-12 col-md-12 m-0 p-0"},O={class:"block-content pt-1 pb-3"},C={cl
|