felicity-lims/felicity/templates/static/assets/InvListing-a5dd0fe3.js
2024-11-17 19:39:30 +02:00

1 line
7.9 KiB
JavaScript

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,onClose:()=>this.openDrawer=!1},{header:()=>"Receive Stock",body:()=>[t(B,{onClose:()=>this.openDrawer=!1},null)]}),t(v,{show:this.openProductDetail,onClose:()=>this.openProductDetail=!1},{header:()=>"Product Details",body:()=>[t(E,{product:this.productDetailItem,onClose:()=>this.openProductDetail=!1},null)]}),this.openAddProduct&&t(x,{onClose:()=>this.openAddProduct=!1,contentWidth:"w-1/4"},{header:()=>t("h3",null,[this.choiceProduct.product?.stockItem?.name,o(" ("),this.choiceProduct.product.name,o(")")]),body:()=>t("form",{action:"post",class:"p-1"},[t("label",{class:"grid grid-cols-4 items-center gap-4 mb-4"},[t("span",{class:"col-span-1 text-gray-700 text-nowrap"},[o("Product Lot")]),l(t("select",{class:"col-span-3 form-select block w-full mt-1","onUpdate:modelValue":e=>this.choiceProduct.stockLotUid=e},[t("option",null,null),this.stockLots?.map(e=>t("option",{key:e.uid,value:e.uid},[e.lotNumber,o(" ("),e.quantity,o(") ["),M(e.expiryDate,!1),o("]")]))]),[[h,this.choiceProduct.stockLotUid]])]),t("label",{class:"grid grid-cols-4 items-center gap-4 mb-4"},[t("span",{class:"col-span-1 text-gray-700 text-nowrap"},[o("Quantiy")]),l(t("input",{class:"col-span-3 form-input mt-1 block w-full",type:"number",onChange:this.validateMinMax,"onUpdate:modelValue":e=>this.choiceProduct.quantity=e,placeholder:"Name ..."},null),[[m,this.choiceProduct.quantity]])]),t("hr",null,null),t("button",{type:"button",onClick:()=>{this.inventoryStore.addToBasket(this.choiceProduct.product.uid,this.choiceProduct.stockLotUid,this.choiceProduct.quantity),this.openAddProduct=!1},class:"-mb-4 border border-sky-800 bg-sky-800 text-white rounded-sm px-4 py-2 m-2 transition-colors duration-500 ease select-none hover:bg-sky-800 focus:outline-none focus:shadow-outline disabled:bg-gray-500",disabled:!this.choiceProduct.stockLotUid},[o("Add to basket")])])}),this.openAdjustProduct&&t(x,{onClose:()=>this.openAdjustProduct=!1,contentWidth:"w-1/4"},{header:()=>t("h3",null,[this.choiceProduct.product?.stockItem?.name,o(" ("),this.choiceProduct.product.name,o(")")]),body:()=>t("form",{action:"post",class:"p-1"},[t("label",{class:"grid grid-cols-4 items-center gap-4 mb-4"},[t("span",{class:"col-span-1 text-gray-700 text-nowrap"},[o("Product Lot")]),l(t("select",{class:"col-span-3 form-select block w-full mt-1","onUpdate:modelValue":e=>this.choiceProduct.stockLotUid=e},[t("option",null,null),this.stockLots?.map(e=>t("option",{key:e.uid,value:e.uid},[e.lotNumber]))]),[[h,this.choiceProduct.stockLotUid]])]),t("label",{class:"grid grid-cols-4 items-center gap-4 mb-4"},[t("span",{class:"col-span-1 text-gray-700"},[o("Adjustmet")]),l(t("select",{class:"col-span-3 form-select block w-full mt-1","onUpdate:modelValue":e=>this.choiceProduct.type=e},[t("option",{value:"lost"},[o("Lost")]),t("option",{value:"theft"},[o("Theft")]),t("option",{value:"transfer-out"},[o("Transfer Out")])]),[[h,this.choiceProduct.type]])]),t("label",{class:"grid grid-cols-4 items-center gap-4 mb-4"},[t("span",{class:"col-span-1 text-gray-700"},[o("Quantiy")]),l(t("input",{class:"col-span-3 form-input mt-1 block w-full",type:"number",onChange:this.validateMinMax,"onUpdate:modelValue":e=>this.choiceProduct.quantity=e,placeholder:"Name ..."},null),[[m,this.choiceProduct.quantity]])]),t("label",{class:"grid grid-cols-4 items-center gap-4 mb-4"},[t("span",{class:"col-span-1 text-gray-700"},[o("Remarks")]),l(t("textarea",{class:"col-span-3 form-input mt-1 block w-full",rows:"3","onUpdate:modelValue":e=>this.choiceProduct.remarks=e,placeholder:"Remarks ..."},null),[[m,this.choiceProduct.remarks]])]),t("hr",null,null),t("button",{type:"button",onClick:()=>{this.adjustStock(),this.openAdjustProduct=!1},class:"-mb-4 border border-sky-800 bg-sky-800 text-white rounded-sm px-4 py-2 m-2 transition-colors duration-500 ease select-none hover:bg-sky-800 focus:outline-none focus:shadow-outline disabled:bg-gray-500",disabled:!this.choiceProduct.stockLotUid},[o("Adjust")])])})])}});export{H as InventoryListing,H as default};