2024-11-18 01:39:30 +08:00
|
|
|
import{d as D,bt as A,q as P,r as c,V as T,ay as u,x as U,g as t,C as o,e as l,as as h,aG as M,v as m,F as I,j as i,_ as d,M as S,cc as V}from"./index-e62f5c21.js";import{a as j}from"./inventory.mutations-a0cda30e.js";const q=i(()=>d(()=>import("./FelDataTable-30b8b751.js"),["assets/FelDataTable-30b8b751.js","assets/index-e62f5c21.js","assets/index-332ec99e.css"])),v=i(()=>d(()=>import("./FelDrawer-74dbd7a4.js"),["assets/FelDrawer-74dbd7a4.js","assets/index-e62f5c21.js","assets/index-332ec99e.css"])),x=i(()=>d(()=>import("./FelModal-44636049.js"),["assets/FelModal-44636049.js","assets/index-e62f5c21.js","assets/index-332ec99e.css","assets/FelModal-780aeea9.css"])),B=i(()=>d(()=>import("./StockReceiveForm-aaed0fda.js"),["assets/StockReceiveForm-aaed0fda.js","assets/index-e62f5c21.js","assets/index-332ec99e.css","assets/vue-multiselect.esm-b4ea8090.js","assets/array-4296cccc.js","assets/inventory.mutations-a0cda30e.js"])),E=i(()=>d(()=>import("./ProductDetail-2c5d5727.js"),["assets/ProductDetail-2c5d5727.js","assets/index-e62f5c21.js","assets/index-332ec99e.css"])),H=D({name:"stock-listing",setup(e,N){const{withClientMutation:w,withClientQuery:_}=S(),r=A();r.fetchProducts({first:50,after:"",text:"",sortBy:["-uid"]});const a=P({product:{},quantity:0,stockLotUid:"",type:"",remarks:""}),f=c(!1),y=c([]),L=s=>{_(V,{productUid:s},"stockLots").then(p=>{y.value=p})};T(()=>a.product?.uid,(s,p)=>s&&L(s));const b=c(!1),g=c(!1),k=c({}),C=c([{name:"UID",value:"uid",sortable:!0,sortBy:"asc",defaultSort:!0,showInToggler:!1,hidden:!0},{name:"Name",value:"stockItem.name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Type",value:"name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Category",value:"stockItem.category.name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Hazard",value:"stockItem.hazard.name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Quantity",value:"quantity",sortable:!1,sortBy:"asc",hidden:!1},{name:"Description",value:"description",sortable:!1,sortBy:"asc",hidden:!1},{name:"Actions",value:"",sortable:!1,sortBy:"asc",hidden:!1,customRender:function(s,p){return u("div",{class:"flex justify-start align-items-center gap-x-4"},[u("button",{type:"button",class:"bg-sky-800 text-white py-1 px-2 rounded-sm leading-none disabled:bg-gray-500",innerHTML:"+ Basket",disabled:s.quantity<1,onClick:()=>{a.product=s,a.quantity=0,f.value=!0}},[]),u("button",{type:"button",class:"bg-sky-800 text-white py-1 px-2 rounded-sm leading-none disabled:bg-gray-500",innerHTML:"+/- Adjust",disabled:s.quantity<1,onClick:()=>{a.product=s,a.quantity=0,b.value=!0}},[]),u("button",{type:"button",class:"bg-sky-800 text-white py-1 px-2 rounded-sm leading-none",innerHTML:"View Detail",onClick:()=>{g.value=!0,k.value=s}},[])])}}]);let n=P({first:50,before:"",text:"",sortBy:["-uid"],filterAction:!1});return{tableColumns:C,inventoryStore:r,openDrawer:c(!1),openAddProduct:f,choiceProduct:a,openAdjustProduct:b,stockLots:y,openProductDetail:g,productDetailItem:k,filterProducts:s=>{n.first=50,n.before="",n.text=s.filterText,n.filterAction=!0,r.fetchProducts(n)},showMoreProducts:s=>{n.first=s.fetchCount,n.before=r.productsPaging?.pageInfo?.endCursor??"",n.text=s.filterText,n.filterAction=!1,r.fetchProducts(n)},countNone:U(()=>r.products?.length+" of "+r.productsPaging.totalCount+" products"),validateMinMax:s=>{},adjustStock:()=>{w(j,{payload:{productUid:a.product.uid,stockLotUid:a.stockLotUid,adjustmentType:a.type,adjust:a.quantity,remarks:a.remarks}},"createStockAjustment").then(s=>{})}}},render(){return t(I,null,[t("div",null,[t("button",{onClick:()=>this.openDrawer=!0,class:"px-4 my-2 p-1 text-sm border-sky-800 border text-dark-700 transition-colors duration-150 rounded-sm focus:outline-none hover:bg-sky-800 hover:text-gray-100"},[o("Receive Stock")])]),t(q,{columns:this.tableColumns,data:this.inventoryStore.products,toggleColumns:!1,loading:!1,paginable:!0,pageMeta:{fetchCount:10,hasNextPage:!1,countNone:this.countNone},searchable:!0,filterable:!1,selectable:!1,onOnSearch:e=>this.filterProducts(e),onOnPaginate:e=>this.showMoreProducts(e)},null),t(v,{show:this.openDrawer,onCl
|