mirror of
https://github.com/beak-insights/felicity-lims.git
synced 2025-02-24 08:53:00 +08:00
1 line
6.5 KiB
JavaScript
1 line
6.5 KiB
JavaScript
import{d as k,bp as P,C as y,r as l,ak as d,D as x,g as e,H as t,e as i,v as f,ac as w,F as A,j as u,_ as c,O as _}from"./index-2a6c9271.js";import{a as C}from"./inventory.mutations-6db1ac57.js";const T=u(()=>c(()=>import("./DataTable-ef278be7.js"),["assets/DataTable-ef278be7.js","assets/index-2a6c9271.js","assets/index-88806377.css"])),D=u(()=>c(()=>import("./Drawer-6ff1eac7.js"),["assets/Drawer-6ff1eac7.js","assets/index-2a6c9271.js","assets/index-88806377.css"])),b=u(()=>c(()=>import("./SimpleModal-0c0664c5.js"),["assets/SimpleModal-0c0664c5.js","assets/index-2a6c9271.js","assets/index-88806377.css","assets/SimpleModal-f645a074.css"])),j=u(()=>c(()=>import("./StockProductForm-2515ae1f.js"),["assets/StockProductForm-2515ae1f.js","assets/index-2a6c9271.js","assets/index-88806377.css","assets/vue-multiselect.esm-82622b05.js","assets/array-52a0b0d0.js","assets/inventory.mutations-6db1ac57.js"])),N=k({name:"stock-listing",setup(a,B){const{withClientMutation:v}=_(),r=P();r.fetchProducts({first:50,after:"",text:"",sortBy:["-uid"]});const o=y({product:{},quantity:0,type:"",remarks:""}),p=l(!1),h=l(!1),g=l([{name:"UID",value:"uid",sortable:!0,sortBy:"asc",defaultSort:!0,showInToggler:!1,hidden:!0},{name:"Name",value:"name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Department",value:"department.name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Supplier",value:"supplier.name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Lot Number",value:"lotNumber",sortable:!1,sortBy:"asc",hidden:!1},{name:"Batch",value:"batch",sortable:!1,sortBy:"asc",hidden:!1},{name:"Size",value:"size",sortable:!1,sortBy:"asc",hidden:!1},{name:"Unit",value:"unit.name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Packaging",value:"packaging.name",sortable:!1,sortBy:"asc",hidden:!1},{name:"Quantity Received",value:"quantityReceived",sortable:!1,sortBy:"asc",hidden:!1},{name:"Quantity Available",value:"remaining",sortable:!1,sortBy:"asc",hidden:!1},{name:"Expiration",value:"expiryDate",sortable:!1,sortBy:"asc",hidden:!1},{name:"Actions",value:"",sortable:!1,sortBy:"asc",hidden:!1,customRender:function(n,m){return d("div",{class:"flex justify-between align-items-center"},[d("button",{type:"button",class:"bg-sky-800 text-white py-1 px-2 rounded-sm leading-none",innerHTML:"+ Basket",onClick:()=>{o.product=n,o.quantity=0,p.value=!0}},[]),d("button",{type:"button",class:"bg-sky-800 text-white py-1 px-2 rounded-sm leading-none",innerHTML:"+/- Adjust",onClick:()=>{o.product=n,o.quantity=0,h.value=!0}},[])])}}]);let s=y({first:50,before:"",text:"",sortBy:["-uid"],filterAction:!1});return{tableColumns:g,inventoryStore:r,openDrawer:l(!1),openAddProduct:p,choiceProduct:o,openAdjustProduct:h,filterProducts:n=>{s.first=50,s.before="",s.text=n.filterText,s.filterAction=!0,r.fetchProducts(s)},showMoreProducts:n=>{s.first=n.fetchCount,s.before=r.productsPaging?.pageInfo?.endCursor??"",s.text=n.filterText,s.filterAction=!1,r.fetchProducts(s)},countNone:x(()=>r.products?.length+" of "+r.productsPaging.totalCount+" products"),validateMinMax:n=>{const m=Math.max(0,Math.min(o.product.remaining??0,Number(n.target.value)));o.quantity=m},adjustStock:()=>{v(C,{payload:{productUid:o.product.uid,adjustmentType:o.type,adjust:o.quantity,remarks:o.remarks}},"createStockAjustment").then(n=>{})}}},render(){return e(A,null,[e("div",null,[e("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"},[t("New Stock")])]),e(T,{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:a=>this.filterProducts(a),onOnPaginate:a=>this.showMoreProducts(a)},null),e(D,{show:this.openDrawer,onClose:()=>this.openDrawer=!1},{header:()=>"New Stock",body:()=>[e(j,{product:void 0,onClose:()=>this.openDrawer=!1},null)],footer:()=>[e("span",null,[t("one")]),e("span",null,[t("two")])]}),this.openAddProduct&&e(b,{onClose:()=>this.openAddProduct=!1,contentWidth:"w-1/4"},{header:()=>e("h3",null,[this.choiceProduct.product.name]),body:()=>e("form",{action:"post",class:"p-1"},[e("label",{class:"flex justify-between items-center gap-4 mb-4"},[e("span",{class:"text-gray-700"},[t("Quantiy")]),i(e("input",{class:"form-input mt-1 block w-full",type:"number",onChange:this.validateMinMax,"onUpdate:modelValue":a=>this.choiceProduct.quantity=a,placeholder:"Name ..."},null),[[f,this.choiceProduct.quantity]])]),e("hr",null,null),e("button",{type:"button",onClick:()=>{this.inventoryStore.addToBasket(this.choiceProduct.product.uid,this.choiceProduct.quantity),this.openAddProduct=!1},class:"-mb-4 w-full 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"},[t("Add to basket")])])}),this.openAdjustProduct&&e(b,{onClose:()=>this.openAdjustProduct=!1,contentWidth:"w-1/4"},{header:()=>e("h3",null,[this.choiceProduct.product.name]),body:()=>e("form",{action:"post",class:"p-1"},[e("label",{class:"flex justify-between items-center gap-4 mb-4"},[e("span",{class:"text-gray-700"},[t("Adjustmet")]),i(e("select",{class:"form-select block w-full mt-1","onUpdate:modelValue":a=>this.choiceProduct.type=a},[e("option",{value:"lost"},[t("Lost")]),e("option",{value:"theft"},[t("Theft")]),e("option",{value:"transfer-in"},[t("Transfer In")]),e("option",{value:"transfer-out"},[t("Transfer Out")])]),[[w,this.choiceProduct.type]])]),e("label",{class:"flex justify-between items-center gap-4 mb-4"},[e("span",{class:"text-gray-700"},[t("Quantiy")]),i(e("input",{class:"form-input mt-1 block w-full",type:"number",onChange:this.validateMinMax,"onUpdate:modelValue":a=>this.choiceProduct.quantity=a,placeholder:"Name ..."},null),[[f,this.choiceProduct.quantity]])]),e("label",{class:"flex justify-between items-center gap-4 mb-4"},[e("span",{class:"text-gray-700"},[t("Remarks")]),i(e("textarea",{class:"form-input mt-1 block w-full",rows:"3","onUpdate:modelValue":a=>this.choiceProduct.remarks=a,placeholder:"Remarks ..."},null),[[f,this.choiceProduct.remarks]])]),e("hr",null,null),e("button",{type:"button",onClick:()=>{this.adjustStock(),this.openAdjustProduct=!1},class:"-mb-4 w-full 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"},[t("Adjust")])])})])}});export{N as InventoryListing,N as default};
|