????
Your IP : 3.134.109.116
"use strict";(self.webpackChunkgdt=self.webpackChunkgdt||[]).push([[4213],{66202:(e,a,n)=>{n.d(a,{A:()=>p});var t=n(9950),i=n(70349),h=n(23931),l=n(52308),o=n(8743),s=n(36640),d=n(51445),c=n(52088),u=n(48738),r=n.n(u),m=n(53744),D=n(44414);const p=e=>{const{OnChangeActiveTab:a,className:n,propsActiveTab:u}=e,[p,g]=(0,t.useState)(0);(0,t.useEffect)((()=>{g(u||0)}),[u]),(0,t.useEffect)((()=>{a&&a(p)}),[p]);const T=e=>{p!==e&&g(e)};return(0,D.jsx)("div",{className:e.IsPageSoQuy?"win10-container page-so-quy":"win10-container",children:(0,D.jsxs)(i.A,{className:n,children:[(0,D.jsx)(h.A,{md:"12",children:(0,D.jsx)(l.A,{tabs:!0,children:e.data&&e.data.map(((a,n)=>{let t=a.MaChucNang;const i=m.oC.filter((e=>e.ma_chuc_nang===t));return t?i[0]&&i[0].access&&(0,D.jsx)(o.A,{children:(0,D.jsx)(s.A,{className:r()({active:p===n}),onClick:()=>{T(n),e.onChangeTab&&e.onChangeTab(n)},children:a.TabName})},n):(0,D.jsx)(o.A,{children:(0,D.jsx)(s.A,{className:r()({active:p===n}),onClick:()=>{T(n),e.onChangeTab&&e.onChangeTab(n)},children:a.TabName})},n)}))})}),(0,D.jsx)(h.A,{md:"12",children:(0,D.jsx)(d.A,{activeTab:p,children:e.data&&e.data.map(((e,a)=>(0,D.jsx)(c.A,{tabId:a,children:p===a&&e.TabContent},a)))})})]})})}},16594:(e,a,n)=>{n.r(a),n.d(a,{default:()=>_e});var t=n(9950),i=n(77923),h=n(67116),l=n(73613),o=n(85560),s=n(4370),d=n(28412),c=n(62181),u=n(32385),r=n(30616),m=n(8434),D=n(37684),p=n(58195),g=n(99308),T=(n(95714),n(49775),n(66202)),S=n(15986),C=n(73032),x=n(53744),_=n(53139),y=n(97159),I=n(36841),f=n(44414);const v=[{title:"Id",field:"Id",type:"numeric",dataID:!0,hidden:!0,editable:"never",cellStyle:{textAlign:"center"}},{title:"Kho",field:"DM_Kho.Ten",type:"string",searchable:!0},{title:"S\u1ed1 l\u01b0\u1ee3ng t\u1ed3n",field:"SoLuongTon",type:"currency"},{title:"\u0110\u01a1n v\u1ecb t\xednh",field:"DM_SanPhamDichVu.DM_DonViTinh.Ten",type:"string",searchable:!0}],V=[{title:"Id",field:"Id",type:"numeric",dataID:!0,hidden:!0,editable:"never",cellStyle:{textAlign:"center"}},{title:"Ch\u1ee9ng t\u1eeb",type:"string",field:"MaChungTu",render:e=>(0,f.jsx)("span",{style:{color:"#0090da",cursor:"pointer"},children:e.MaChungTu})},{title:"H\xecnh th\u1ee9c",field:"HinhThuc",type:"string"},{title:"Ng\xe0y ch\u1ee9ng t\u1eeb",field:"NgayChungTu",type:"datetime",defaultSort:"desc",cellStyle:{textAlign:"left"}},{title:"Gi\xe1 v\u1ed1n",field:"GiaVon",type:"currency"},{title:"S\u1ed1 l\u01b0\u1ee3ng",field:"SoLuong",type:"currency"},{title:"T\u1ed3n cu\u1ed1i",field:"TonCuoi",type:"currency"}],P=[{title:"M\xe3 h\xe0ng",field:"MaSanPham",type:"string",searchable:!0},{title:"T\xean h\xe0ng",field:"TenSanPham",type:"string",searchable:!0},{title:"\u0110VT",field:"DonViTinh",type:"string"},{title:"Gi\xe1 b\xe1n",field:"GiaBan",type:"currency"},{title:"Gi\xe1 v\u1ed1n",field:"GiaVon",type:"currency"},{title:"T\u1ed3n kho",field:"TonKho",type:"currency"}],j=t.createRef(),N=()=>j.current&&j.current.onQueryChange();function b(e){let{ID:a}=e;const[n,i]=(0,t.useState)(null),[l,d]=(0,t.useState)([]),[c,u]=(0,t.useState)(null),[r,m]=(0,t.useState)(null);(0,t.useEffect)((()=>{if(n&&n.length){var e,a;let t=[];t.push({IdSanPham:n[0].SanPhamDichVu_Id,TenDonViTinh:null===(e=n[0].DM_SanPhamDichVu)||void 0===e||null===(a=e.DM_DonViTinh)||void 0===a?void 0:a.Ten}),n.forEach((e=>{var a,n;t.push({IdSanPham:e.SanPhamDichVuQuyDoi_Id,TenDonViTinh:null===(a=e.DM_SanPhamDichVu1)||void 0===a||null===(n=a.DM_DonViTinh)||void 0===n?void 0:n.Ten})})),d(t)}}),[n]);let D=[];c&&D.push("substringof('".concat(c,"', DM_Kho/Ten)")),r?D.push("Kho_Id eq ".concat(x.b9.Kho_Id," and SanPhamDichVu_Id eq ").concat(r)):D.push("Kho_Id eq ".concat(x.b9.Kho_Id," and SanPhamDichVu_Id eq ").concat(a));const p=(0,t.useCallback)((()=>{(0,s.Pq)("DM_QuyDoiDonVi?$expand=DM_SanPhamDichVu/DM_DonViTinh,DM_SanPhamDichVu1/DM_DonViTinh&$filter=SanPhamDichVu_Id eq ".concat(a," and IsDeleted ne true"),"GET",null).then((e=>i(e.value))).catch((e=>(0,h.a3)("Kh\xf4ng th\u1ec3 l\u1ea5y d\u1eef li\u1ec7u quy \u0111\u1ed5i \u0111\u01a1n v\u1ecb!")))}),[a]);return(0,t.useEffect)((()=>{p()}),[p]),(0,f.jsx)(o.A,{url:"Sale_TonKho",tableRef:j,where:D.join(" and "),columns:v,selectType:"withColumns",SearchAdvanced:e=>(0,f.jsxs)(C.default,{children:[(0,f.jsx)(S.default,{md:"3",children:(0,f.jsx)(_.Sm,{defaultValue:c,placeholder:"T\xecm ki\u1ebfm...",onKeyPress:e=>{13===e.charCode&&u(e.target.value.trim()),13===e.charCode&&N()}})}),(0,f.jsx)(S.default,{md:"3",children:l.length?(0,f.jsx)(y.A,{options:l,valueField:"IdSanPham",textField:"TenDonViTinh",value:r||a,onChange:e=>{m(e),N()},placeholder:"Ch\u1ecdn \u0111\u01a1n v\u1ecb t\xednh..."}):""})]})})}function M(e){let{ID:a}=e;return(0,f.jsx)(o.A,{urlExt:"SanPham/HangHoaCungLoai?SanPhamDichVu_Id=".concat(a,"&Kho_Id=").concat(x.b9.Kho_Id,"&DiemKinhDoanh_Id=").concat(x.b9.DiemKinhDoanhId),columns:P,selectType:"withColumns"})}var A=n(86803),L=n.n(A),K=n(70349),q=n(23931),H=n(50651),k=n(75490),R=n(18849),E=n(76991),w=n(7137),F=n(3021),Q=n(2258),$=n(43212),G=n(22940),B=n(53832),X={MaSanPham:{field_name:"MaSanPham",title:"M\xe3 s\u1ea3n ph\u1ea9m: ",type:"textbox"},TenSanPham:{field_name:"TenSanPham",title:"T\xean s\u1ea3n ph\u1ea9m: ",type:"textbox"},DonViTinh_Id:{field_name:"DonViTinh_Id",title:"\u0110\u01a1n v\u1ecb t\xednh: ",type:"data-select",dataSelect:{url:"DM_DonViTinh",column:["Id","Ten"],value_field:"Id",text_field:"Ten"}},MaLoai:{field_name:"MaLoai",title:"Lo\u1ea1i s\u1ea3n ph\u1ea9m: ",type:"data-select",required:!0,dataSelect:{url:"DM_LoaiSanPham",column:["MaLoai","TenLoai"],value_field:"MaLoai",text_field:"TenLoai"}},NhomSanPhamDichVu_Id:{field_name:"NhomSanPhamDichVu_Id",title:"Nh\xf3m s\u1ea3n ph\u1ea9m: ",type:"data-select",dataSelect:{url:"DM_NhomSanPhamDichVu",column:["Id","Ten"],value_field:"Id",text_field:"Ten"}},NhaCungCap_Id:{field_name:"NhaCungCap_Id",title:"Nh\xe0 cung c\u1ea5p: ",type:"data-select",dataSelect:{url:"DM_LienHe",column:["Id","Ten"],value_field:"Id",text_field:"Ten"}},HinhAnh:{field_name:"HinhAnh",title:"H\xecnh \u1ea3nh",type:"textbox"}};function O(e){var a;let{ID:n,dataDonViTinh:i,reloadList:o}=e;const[d,c]=(0,t.useState)({}),[u,r]=(0,t.useState)(!1),[m,D]=(0,t.useState)(""),[p,g]=(0,t.useState)(""),[T,S]=(0,t.useState)(null),[C,x]=(0,t.useState)(null),[_,v]=(0,t.useState)([]);(0,t.useEffect)((()=>{j(),P()}),[]),(0,t.useEffect)((()=>{var e;C&&((0,s.Pq)("DM_QuyDoiDonVi?$filter=SanPhamDichVu_Id eq ".concat(n,"&$expand=DM_SanPhamDichVu1")).then((e=>{let a=e.value.map((e=>({DonViTinhQuyDoi_Id:e.DM_SanPhamDichVu1.DonViTinh_Id,SoLuongQuyDoi:e.SoLuongQuyDoi}))),n=[];n.push("Id ne ".concat(d.DonViTinh_Id)),a.map((e=>{var a;(null===(a=C.DM_SanPhamDichVu1)||void 0===a?void 0:a.DonViTinh_Id)!==e.DonViTinhQuyDoi_Id&&n.push("Id ne ".concat(e.DonViTinhQuyDoi_Id))})),D(n.join(" and "))})).then((()=>r(!0))),g(null===C||void 0===C?void 0:C.SoLuongQuyDoi),S(null===C||void 0===C||null===(e=C.DM_SanPhamDichVu1)||void 0===e?void 0:e.DonViTinh_Id))}),[C]),(0,t.useEffect)((()=>{u||x(null)}),[u]);const V=e=>{var a;return null===(a=i.find((a=>a.Id===e)))||void 0===a?void 0:a.Ten},P=()=>{(0,s.Pq)("Sale_TheKho?$filter=SanPhamDichVu_Id eq ".concat(n),"GET",null).then((e=>v(e.value))).catch((e=>(0,h.AB)(e,"TH\xd4NG B\xc1O")))},j=()=>{n?(0,s.Pq)("DM_SanPhamDichVu(".concat(n,")?$expand=DM_NhomSanPhamDichVu,DM_DonViTinh,DM_QuyDoiDonVi/DM_SanPhamDichVu1,DM_LoaiSanPham"),"GET",null).then((e=>{c({...e,DM_QuyDoiDonVi:e.DM_QuyDoiDonVi.filter((e=>!e.IsDeleted)),MaLoai:e.DM_LoaiSanPham.MaLoai})})).catch((e=>(0,h.AB)(e,"TH\xd4NG B\xc1O"))):c({})};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(K.A,{className:"mt-3 mb-5",children:[(0,f.jsx)(q.A,{md:5,children:(0,f.jsxs)("div",{className:"form-image-danh-muc-san-pham",children:[(0,f.jsx)("h3",{children:"H\xecnh \u1ea3nh m\xf4 t\u1ea3"}),(0,f.jsx)("p",{className:"text-secondary",children:"H\xecnh \u1ea3nh ch\u1ec9 mang t\xednh ch\u1ea5t minh h\u1ecda cho s\u1ea3n ph\u1ea9m"}),(0,f.jsx)("img",{className:"image-danh-muc-san-pham",src:d.HinhAnh?"api/"+d.HinhAnh:"assets/default.jpg",alt:"L\u1ed7i h\xecnh \u1ea3nh"})]})}),(0,f.jsxs)("div",{className:"form-right-detail-thong-tin-sp col ml-3 mr-3",children:[(0,f.jsx)(B.A,{data:X.MaSanPham,value:d.MaSanPham,styleTitle:{color:"gray"},isDetail:!0}),(0,f.jsx)(B.A,{data:X.TenSanPham,value:d.TenSanPham,styleTitle:{color:"gray"},isDetail:!0}),(0,f.jsx)(B.A,{styleTitle:{color:"gray"},data:X.MaLoai,value:d.MaLoai,isDetail:!0}),(0,f.jsx)(B.A,{data:X.DonViTinh_Id,value:d.DonViTinh_Id,styleTitle:{color:"gray"},isDetail:!0}),(0,f.jsx)(B.A,{data:null===X||void 0===X?void 0:X.NhomSanPhamDichVu_Id,value:null===d||void 0===d?void 0:d.NhomSanPhamDichVu_Id,styleTitle:{color:"gray"},isDetail:!0}),(0,f.jsx)(B.A,{data:null===X||void 0===X?void 0:X.NhaCungCap_Id,value:null===d||void 0===d?void 0:d.NhaCungCap_Id,styleTitle:{color:"gray"},isDetail:!0}),(0,f.jsxs)("div",{className:"row",children:[(0,f.jsx)("h6",{style:{color:"gray"},className:"col-4 mt-2 mb-3",children:"Cho ph\xe9p b\xe1n h\xe0ng:"}),(0,f.jsx)("p",{className:"col mt-2",children:d.ChoPhepBanHang?"Cho ph\xe9p":"Kh\xf4ng"})]}),(0,f.jsxs)("div",{className:"row",children:[(0,f.jsx)("h6",{style:{color:"gray"},className:"col-4 mb-3",children:"Tr\u1ea1ng th\xe1i t\u1ed3n kho:"}),(0,f.jsx)("p",{className:"col",children:d.TrangThaiTonKho?"\u0110ang t\u1ed3n kho":"Kh\xf4ng"})]})]})]}),!d.Base_Id&&(0,f.jsx)(f.Fragment,{children:(0,f.jsxs)(H.A,{children:[(0,f.jsxs)(k.A,{className:"card-header-quy-doi",children:[(0,f.jsx)("span",{children:(0,f.jsx)("b",{children:"Quy \u0111\u1ed5i \u0111\u01a1n v\u1ecb"})}),0===_.length&&(0,f.jsx)("span",{children:(0,f.jsx)(R.A,{className:"icon icon-add",onClick:()=>{(0,s.Pq)("DM_QuyDoiDonVi?$filter=SanPhamDichVu_Id eq ".concat(n,"&$expand=DM_SanPhamDichVu1")).then((e=>{let a=e.value.map((e=>({DonViTinhQuyDoi_Id:e.DM_SanPhamDichVu1.DonViTinh_Id,SoLuongQuyDoi:e.SoLuongQuyDoi,IsDeleted:e.IsDeleted}))),n=[];n.push("Id ne ".concat(d.DonViTinh_Id)),a.forEach((e=>!e.IsDeleted&&n.push("Id ne ".concat(e.DonViTinhQuyDoi_Id)))),D(n.join(" and "))})),r(!0)},children:"Th\xeam m\u1edbi"})})]}),(0,f.jsx)(E.A,{className:"card-body-quy-doi",children:(0,f.jsxs)(G.default,{bordered:!0,size:"sm",className:"table-quy-doi",children:[(0,f.jsx)("thead",{children:(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{children:"STT"}),(0,f.jsx)("th",{children:"C\xf4ng th\u1ee9c quy \u0111\u1ed5i"}),0===_.length&&(0,f.jsx)("th",{children:"Thao t\xe1c"})]})}),(0,f.jsx)("tbody",{children:null===d||void 0===d||null===(a=d.DM_QuyDoiDonVi)||void 0===a?void 0:a.map(((e,a)=>(0,f.jsxs)("tr",{children:[(0,f.jsx)("td",{className:"td-stt",children:a+1}),(0,f.jsxs)("td",{className:"text-left",children:[(0,f.jsx)("span",{style:{paddingRight:10},children:"1"}),(0,f.jsx)("span",{style:{paddingRight:10},children:V(e.DM_SanPhamDichVu1.DonViTinh_Id)}),(0,f.jsx)("span",{style:{paddingRight:10},children:"="}),(0,f.jsx)("span",{style:{paddingRight:10},children:(0,I.vv)(e.SoLuongQuyDoi)}),(0,f.jsx)("span",{style:{paddingRight:10},children:V(d.DonViTinh_Id)})]}),0===_.length&&(0,f.jsxs)("td",{className:"td-thao-tac",children:[(0,f.jsxs)("span",{className:"mr-2",onClick:()=>x(e),children:[(0,f.jsx)(l.A,{fa:"edit"})," S\u1eeda"]}),(0,f.jsxs)("span",{className:"ml-2",onClick:()=>(0,h.A1)("B\u1ea1n mu\u1ed1n x\xf3a \u0111\u01a1n v\u1ecb quy \u0111\u1ed5i n\xe0y?","Th\xf4ng b\xe1o").then((()=>(e=>{(0,s.Pq)("SanPham/XoaDonViQuyDoi?quyDoiDonVi_Id=".concat(e.Id),"DELETE",null,!1).then((e=>(0,h.nw)("X\xf3a \u0111\u01a1n v\u1ecb quy \u0111\u1ed5i th\xe0nh c\xf4ng!","Th\xf4ng b\xe1o").then((()=>j())))).catch((e=>(0,h.a3)(e.Message,"Th\xf4ng b\xe1o")))})(e))),children:[(0,f.jsx)(l.A,{fa:"times"})," X\xf3a"]})]})]},a)))})]})})]})}),(0,f.jsxs)(w.default,{isOpen:u,toggle:()=>r(!1),children:[(0,f.jsx)($.default,{toggle:()=>r(!1),children:"\u0110\u01a1n v\u1ecb quy \u0111\u1ed5i"}),(0,f.jsx)(F.default,{children:(0,f.jsxs)("div",{className:"content-popup-quy-doi",children:[(0,f.jsx)("span",{style:{paddingRight:10},children:"Quy \u0111\u1ed5i:"}),(0,f.jsx)("span",{style:{paddingRight:10},children:"1"}),(0,f.jsx)("span",{style:{paddingRight:10},children:(0,f.jsx)(y.A,{disabled:!!C,className:"dropdownList-normal",placeholder:"Nh\u1eadp...",url:"DM_DonViTinh",where:m,value:T,valueField:"Id",textField:"Ten",onChange:e=>{S(e)}})}),(0,f.jsx)("span",{style:{paddingRight:10},children:"="}),(0,f.jsx)("span",{style:{paddingRight:10},children:(0,f.jsx)(L(),{placeholder:"Nh\u1eadp s\u1ed1 l\u01b0\u1ee3ng...",className:"form-control form-control-sm",min:"0",onFocus:e=>e.target.select(),value:p,thousandSeparator:".",decimalSeparator:",",onValueChange:e=>{const{value:a}=e;(e=>{g(e)})(a)}})}),(0,f.jsx)("span",{style:{paddingRight:10},children:V(d.DonViTinh_Id)})]})}),(0,f.jsx)(Q.default,{children:(0,f.jsx)(R.A,{color:"success",onClick:()=>{let e=JSON.stringify({listDonViTinhQuyDoi:[{DonViTinhQuyDoi_Id:T,SoLuongQuyDoi:p}],IdSanPhamDichVu:n});C&&(e=null);let a=C?"SanPham/CapNhatDonViQuyDoi?quyDoiDonVi_Id=".concat(C.Id,"&soLuong=").concat(p):"/SanPham/ThemDonViQuyDoi";(0,s.Pq)(a,"POST",e,!1).then((e=>(0,h.nw)("C\u1eadp nh\u1eadt \u0111\u01a1n v\u1ecb quy \u0111\u1ed5i th\xe0nh c\xf4ng!","Th\xf4ng b\xe1o").then((()=>{o(),j(),r(!1)})))).catch((e=>(0,h.a3)(e.Message,"Th\xf4ng b\xe1o")))},children:"L\u01b0u"})})]})]})}var z=n(93443),J=n(68754),W=n(55413),Y=n(10001),Z=n(85148),U=n(21812),ee=n(78042),ae="PN",ne="PX",te="CK",ie="KK",he="BH",le="TH";const oe=t.createRef(),se=()=>oe.current&&oe.current.onQueryChange();function de(e){let{ID:a,dataDonViTinh:n}=e;const[i,l]=(0,t.useState)(!1),[d,c]=(0,t.useState)(""),[u,r]=(0,t.useState)(null),[D,p]=(0,t.useState)(null),[g,T]=(0,t.useState)([]),[S,C]=(0,t.useState)([]),[I,v]=(0,t.useState)([]),[P,j]=(0,t.useState)(null),[N,b]=(0,t.useState)([]),[M,A]=(0,t.useState)(null),[L,H]=(0,t.useState)(null),k=(0,t.useRef)();let R=[];M&&R.push("substringof('".concat(M,"', MaChungTu)")),L?R.push("Kho_Id eq ".concat(x.b9.Kho_Id," and SanPhamDichVu_Id eq ").concat(L)):R.push("Kho_Id eq ".concat(x.b9.Kho_Id," and SanPhamDichVu_Id eq ").concat(a)),(0,t.useEffect)((()=>{i||p(null),c(null),r(null)}),[i]),(0,t.useEffect)((()=>{if(P&&P.length){var e,a;let n=[];n.push({IdSanPham:P[0].SanPhamDichVu_Id,TenDonViTinh:null===(e=P[0].DM_SanPhamDichVu)||void 0===e||null===(a=e.DM_DonViTinh)||void 0===a?void 0:a.Ten}),P.forEach((e=>{var a,t;n.push({IdSanPham:e.SanPhamDichVuQuyDoi_Id,TenDonViTinh:null===(a=e.DM_SanPhamDichVu1)||void 0===a||null===(t=a.DM_DonViTinh)||void 0===t?void 0:t.Ten})})),b(n)}}),[P]);const E=(0,t.useCallback)((()=>{(0,s.Pq)("DM_QuyDoiDonVi?$expand=DM_SanPhamDichVu/DM_DonViTinh,DM_SanPhamDichVu1/DM_DonViTinh&$filter=SanPhamDichVu_Id eq ".concat(a," and IsDeleted ne true"),"GET",null).then((e=>j(e.value))).catch((e=>(0,h.a3)("Kh\xf4ng th\u1ec3 l\u1ea5y d\u1eef li\u1ec7u quy \u0111\u1ed5i \u0111\u01a1n v\u1ecb!")))}),[a]),w=(0,t.useCallback)((()=>{(0,s.Pq)("DM_LienHe?$filter=NhomLienHe_Id eq '".concat(m.M.NCC,"' and IsDeleted ne true"),"GET",null).then((e=>T(e.value))).catch((e=>(0,h.a3)("Kh\xf4ng th\u1ec3 l\u1ea5y d\u1eef li\u1ec7u nh\xe0 cung c\u1ea5p!")))}),[]),F=(0,t.useCallback)((e=>{if(!e)return(0,h.a3)("Kh\xf4ng t\u1ed3n t\u1ea1i m\xe3 ch\u1ee9ng t\u1eeb!","Th\xf4ng b\xe1o"),!1;c(e.substring(0,2)),r(e)}),[]),Q=(0,t.useCallback)((()=>{if(u){let e="";switch(d){case ae:e="Sale_NhapHang?$expand=Sale_ChiTietNhapHang/DM_Kho,DM_LienHe,Sale_ChiTietNhapHang/DM_SanPhamDichVu,Sale_ChiTietNhapHang,Sale_ChiTietNhapHang/DM_DonViTinh&$filter=MaNhapHang eq '".concat(u,"'");break;case ne:e="Sale_XuatHang?$expand=Sale_ChiTietXuatHang/DM_Kho,Sale_ChiTietXuatHang/DM_SanPhamDichVu,Sale_ChiTietXuatHang/DM_DonViTinh,Sale_ChiTietXuatHang&$filter=MaXuatHang eq '".concat(u,"'");break;case te:e="Sale_ChuyenKho?$expand=Sale_XuatHang,Sale_NhapHang,DM_Kho,DM_Kho1,Sale_ChiTietChuyenKho/DM_SanPhamDichVu,Sale_ChiTietChuyenKho&$filter=MaPhieu eq '".concat(u,"'");break;case he:e="DonHangs?$expand=DM_DiemKinhDoanh,DM_HinhThucThanhToan,Sale_DonTraHang&$filter=MaDonHang eq '".concat(u,"'");break;case le:e="DonTraHangs?&$filter=MaTraHang eq '".concat(u,"'");break;default:return!1}(0,s.Pq)(e,"GET",null).then((e=>p(e.value[0]))).catch((e=>{(0,h.a3)("L\u1ea5y d\u1eef li\u1ec7u phi\u1ebfu kh\xf4ng th\xe0nh c\xf4ng!","Th\xf4ng b\xe1o")}))}}),[d,u]);return(0,t.useEffect)((()=>{u&&d&&Q(),l(!0)}),[Q,d,u]),(0,t.useEffect)((()=>{w(),(0,s.Pq)("DM_Kho?$filter=IsKhoTong eq true","GET",null).then((e=>C(e.value))).catch((e=>(0,h.a3)("Kh\xf4ng th\u1ec3 l\u1ea5y d\u1eef li\u1ec7u kho!"))),(0,s.Pq)("DM_Kho?$filter=IsKhoTong eq false or IsKhoTong eq null","GET",null).then((e=>v(e.value))).catch((e=>(0,h.a3)("Kh\xf4ng th\u1ec3 l\u1ea5y d\u1eef li\u1ec7u kho!"))),E()}),[w,E]),(0,f.jsxs)(t.Fragment,{children:[(0,f.jsx)(o.A,{tableRef:oe,url:"Sale_TheKho",where:R.join(" and "),columns:V,selectType:"withColumns",onRowClick:(e,a)=>F(a.MaChungTu),SearchAdvanced:e=>(0,f.jsxs)(K.A,{children:[(0,f.jsx)(q.A,{md:"3",children:(0,f.jsx)(_.Sm,{defaultValue:M,placeholder:"T\xecm ki\u1ebfm theo m\xe3...",onKeyPress:e=>{13===e.charCode&&A(e.target.value.trim()),13===e.charCode&&se()}})}),(0,f.jsx)(q.A,{md:"3",children:N.length?(0,f.jsx)(y.A,{options:N,valueField:"IdSanPham",textField:"TenDonViTinh",value:L||a,onChange:e=>{H(e),se()},placeholder:"Ch\u1ecdn \u0111\u01a1n v\u1ecb t\xednh..."}):""})]})}),i&&d===ae&&D&&(0,f.jsx)(z.A,{modeDialog:"detail",phieuNhapSelected:D,dataNhaCungCap:g,openTaoPhieu:i,onCloseTaoPhieu:()=>l(!1)}),i&&d===ne&&D&&(0,f.jsx)(J.A,{modeDialog:"detail",phieuNhapSelected:D,openTaoPhieu:i,onCloseTaoPhieu:()=>l(!1)}),i&&d===te&&D&&(0,f.jsx)(f.Fragment,{children:(0,f.jsx)(W.A,{ref:k,reloadList:se,modeDialog:"detail",phieuNhapSelected:D,dataKhoXuat:S,dataKhoNhap:I,dataDonViTinh:n,openTaoPhieu:i,isYeuCauChuyenKho:!1,isChuyenKhoCNPhu:!1,CurrentKho:{Id:x.lg.KhoId,IsKhoTong:ee.Ze},onCloseTaoPhieu:()=>l(!1)})}),i&&d===ie&&D&&(0,f.jsx)(Y.A,{modeDialog:"detail",CurrentKho:{Id:x.b9.Kho_Id,IsKhoTong:x.b9.IsKhoTong},phieuNhapSelected:D,dataDonViTinh:n,openTaoPhieu:i,onCloseTaoPhieu:()=>l(!1)}),i&&d===he&&D&&(0,f.jsx)(Z.A,{isDetailTheKho:!0,data:D,IdDonHang:D.Id,openDetail:i,closeDetail:()=>l(!1)}),i&&d===le&&D&&(0,f.jsx)(U.A,{isDetailTheKho:!0,openDetailTraHang:i,closeDetailTraHang:()=>l(!1),IdDonTraHang:D.Id,MaTraHang:D.MaTraHang})]})}class ce extends t.Component{constructor(e){super(e),this.state={dataDonViTinh:[]}}componentDidMount(){this.getDataDonViTinh()}getDataDonViTinh(){(0,s.Pq)("DM_DonViTinh?$select=Id,Ten","GET",null).then((e=>this.setState({dataDonViTinh:e.value}))).catch((e=>(0,h.a3)("Kh\xf4ng th\u1ec3 l\u1ea5y d\u1eef li\u1ec7u kho!")))}render(){let{dataDonViTinh:e}=this.state;const{open:a,onClose:n,ID:t,reloadList:i}=this.props;return(0,f.jsx)("div",{className:"custom-detail-san-pham",children:(0,f.jsx)(p.A,{size:"xl",isOpen:a,toggle:n,className:"Detail-SanPham",children:(0,f.jsx)(g.A,{children:(0,f.jsx)(T.A,{data:[{TabName:"Th\xf4ng tin",TabContent:(0,f.jsx)(O,{ID:t,dataDonViTinh:e,reloadList:i})},{TabName:"Th\u1ebb kho",TabContent:(0,f.jsx)(de,{ID:t,dataDonViTinh:e})},{TabName:"T\u1ed3n kho",TabContent:(0,f.jsx)(b,{ID:t})},{TabName:"H\xe0ng h\xf3a c\xf9ng lo\u1ea1i",TabContent:(0,f.jsx)(M,{ID:t})}]})})})})}}var ue=n(65597),re=n(28521);n(98548);class me extends t.Component{componentDidMount(){const{value:e,onChange:a}=this.props;a(e||null)}render(){const{options:e,value:a,onChange:n,valueField:t,textField:i}=this.props;return(0,f.jsx)(y.A,{valueField:t,textField:i,options:e,value:a,onChange:e=>n(e||null)})}}var De=[{title:"Id",field:"Id",type:"numeric",dataID:!0,hidden:!0,editable:"never",cellStyle:{textAlign:"center"}},{title:"T\xean",field:"Ten",type:"string",dataCheck:!0,searchable:!0,cellStyle:{textAlign:"left"}},{title:"Lo\u1ea1i",field:"Loai",type:"string",searchable:!0,isColLoai:!0,hidden:!0,cellStyle:{textAlign:"center"},editComponent:e=>(0,f.jsx)(y.A,{valueField:"value",textField:"label",options:[],column:{field:"Id",label:"Ten",type:"int"},value:e.value,onChange:a=>a?e.onChange(a.value):e.onChange(null)}),render:e=>console.log(e)},{title:"Hi\u1ec3n th\u1ecb",field:"Display",type:"boolean",cellStyle:{textAlign:"center"}}];const pe=t.createRef();class ge extends t.Component{constructor(e){super(e),this.state={}}render(){const{open:e,onClose:a,Loai:n,reloadDataNhomSanPhamDichVu:t}=this.props;let i,h,l,s,d,c;return s=De.find((e=>e.isColLoai)),l=De.findIndex((e=>e.isColLoai)),De.splice(l,1),d=n.split("-")[0]===re.$.san_pham?[{label:"S\u1ea3n ph\u1ea9m",value:re.$.san_pham}]:[{label:"D\u1ecbch v\u1ee5",value:re.$.dich_vu}],c=n.split("-")[0]===re.$.san_pham?re.$.san_pham:re.$.dich_vu,s={...s,editComponent:e=>(0,f.jsx)(me,{valueField:"value",textField:"label",options:d,value:c,onChange:a=>e.onChange(a)})},i=De.slice(0,l),h=De.slice(l,De.length),i.push(s),De=i.concat(h),(0,f.jsx)(ue.A,{className:"dialog-nhom-san-pham-dich-vu",open:e,maxWidth:"md",handleClose:a,children:(0,f.jsx)(o.A,{tableRef:pe,title:"Danh s\xe1ch nh\xf3m s\u1ea3n ph\u1ea9m d\u1ecbch v\u1ee5",url:"DM_NhomSanPhamDichVu",where:"Loai eq '".concat(n,"'"),columns:De,selectType:"withColumns",onAdd:{defaultValues:[{field:"Loai",value:n}],disabled:!1},onEdit:{},onDelete:{},defaultValues:{Loai:n},addCallback:()=>t(),updateCallback:()=>t(),deleteCallback:()=>t()})})}}var Te=[{title:"Id",field:"Id",type:"numeric",dataID:!0,hidden:!1,editable:"never",cellStyle:{textAlign:"center"}},{title:"H\xecnh \u1ea3nh",field:"Thumbnail50",type:"string",cellStyle:{textAlign:"center"},render:e=>(0,f.jsx)(i.LazyLoadImage,{style:{objectFit:"cover",borderRadius:"50%"},height:50,src:e.Thumbnail50?"/api"+e.Thumbnail50:"assets/default.jpg",width:50})},{title:"M\xe3 s\u1ea3n ph\u1ea9m",field:"MaSanPham",type:"string",searchable:!0,cellStyle:{textAlign:"left"}},{title:"\u0110VT",field:"DM_DonViTinh.Ten",type:"string",dataRef:["DonViTinh_Id"]},{title:"T\xean s\u1ea3n ph\u1ea9m",field:"TenSanPham",type:"string",searchable:!0,cellStyle:{textAlign:"left"}},{title:"Nh\xf3m s\u1ea3n ph\u1ea9m",field:"DM_NhomSanPhamDichVu.Ten",type:"string",dataRef:["NhomSanPhamDichVu_Id","Id"],dataCheck:!0,cellStyle:{textAlign:"left"}},{title:"Nh\xf3m \u0111\u01a1n v\u1ecb",field:"DM_DonViTinh.NhomDonViTinh",type:"string",dataRef:["DonViTinh_Id"],hidden:!0},{field:"Base_Id",hidden:!0}];const Se=t.createRef(),Ce=()=>Se.current&&Se.current.onQueryChange();class xe extends t.Component{constructor(e){super(e),this.setSearchTenSanPham=e=>{13===e.charCode&&this.setState({searchTenSanPham:e.target.value},(()=>Ce()))},this.onCloseCreate=(e,a)=>{this.setState({openCreate:!1},(()=>{"number"===typeof e&&a&&this.setState({ID:e},(()=>this.setState({openDetail:!0})))}))},this.state={openCreate:!1,openDetail:!1,ID:null,nhomSanPhamDichVuId:null,searchTenSanPham:null,dataNhomSanPhamDichVu:null,dataNhaCungCap:null,openDialogNhom:!1,Loai:"Combo",nhomDonVi:null,title:"Combo",listLoaiSP:[],isTonKho:null,isBanHang:null,isRender:!1},this.FilterCard=t.createRef(),this.DropdownlistDataNhomSanPhamDichVu=t.createRef(),this.getDataNhomSanPhamDichVu=this.getDataNhomSanPhamDichVu.bind(this)}componentDidMount(){this.getDataNhomSanPhamDichVu(),this.getDataNhaCungCap(),this.getDataLoaiSanPham()}renderListLoaiSP(e){let a=[];return e.length&&e.forEach((e=>{a.push({label:e.TenLoai,value:e.MaLoai})})),a}getDataLoaiSanPham(){(0,s.Pq)("DM_LoaiSanPham","GET").then((e=>{e.value.length&&this.setState({listLoaiSP:this.renderListLoaiSP(e.value)})}))}getDataNhaCungCap(){(0,s.Pq)("DM_LienHe?$filter=NhomLienHe_Id eq '".concat(m.M.NCC,"' and IsDeleted ne true"),"GET",null).then((e=>this.setState({dataNhaCungCap:e.value}))).catch((e=>(0,h.a3)(e,"Th\xf4ng b\xe1o")))}async getDataNhomSanPhamDichVu(){const{Loai:e}=this.state;await(0,s.Pq)("DM_NhomSanPhamDichVu?$filter=Loai eq '".concat(e.split("-")[0],"' and Display eq ",!0),"GET",null).then((e=>{!this.state.isRender&&this.setState({isRender:!0}),this.setState({dataNhomSanPhamDichVu:e.value})})).catch((e=>(0,h.a3)(e,"Th\xf4ng b\xe1o")))}setLoai(e){return new Promise(((a,n)=>{this.setState({Loai:e},(()=>a(!0)))}))}deleteSanPham(e){(0,s.Pq)("SanPham/XoaSanPham?sanPhamDichVu_Id=".concat(e),"DELETE",null,!1).then((e=>(0,h.nw)("X\xf3a th\xe0nh c\xf4ng!","Th\xf4ng b\xe1o").then((()=>Ce())))).catch((e=>(0,h.a3)(e.Message,"Th\xf4ng b\xe1o")))}render(){const{Loai:e,nhomSanPhamDichVuId:a,dataNhomSanPhamDichVu:n,searchTenSanPham:t,openCreate:i,ID:s,openDetail:m,openDialogNhom:p,nhaCungCapId:g,dataNhaCungCap:T,nhomDonVi:S,isTonKho:C,isBanHang:x,isRender:_}=this.state,y=e=>{let a="";return!_&&this.setState({isRender:!0}),this.state.listLoaiSP.forEach((n=>{n.value===e&&(a=n.label)})),a};let I=[];return e&&I.push("Loai eq '".concat(e.split("-")[0],"'")),I.push("IsDeleted ne true"),S&&I.push("DM_DonViTinh/NhomDonViTinh eq '".concat(S,"'")),g&&I.push("NhaCungCap_Id eq ".concat(g)),a&&I.push("NhomSanPhamDichVu_Id eq ".concat(a)),t&&I.push("(substringof('".concat(t,"', TenSanPham) or substringof('").concat(t,"', MaSanPham))")),null!==C&&"true"===C?I.push("TrangThaiTonKho eq true"):"false"===C&&I.push("TrangThaiTonKho eq false"),null!==x&&"true"===x?I.push("ChoPhepBanHang eq true"):"false"===x&&I.push("ChoPhepBanHang eq false"),(0,f.jsxs)(r.A,{children:[(0,f.jsxs)(d.A,{NoTabs:!0,children:[(0,f.jsx)(c.A,{ref:this.FilterCard,className:"mb-2",field_name:"loai-san-pham",type:"radio-list",title:"Lo\u1ea1i s\u1ea3n ph\u1ea9m",data:this.state.listLoaiSP,value:e,onChange:(e,a)=>{this.setState({nhomSanPhamDichVuId:null}),this.setLoai(a).then((e=>this.getDataNhomSanPhamDichVu().then((e=>Ce())))),_&&this.setState({isRender:!1}),this.setState({title:y(a)})}}),(0,f.jsx)(c.A,{className:"mb-2",title:"T\xecm ki\u1ebfm",defaultValue:t,onKeyPress:e=>this.setSearchTenSanPham(e),placeholder:"T\xecm ki\u1ebfm theo m\xe3, t\xean ..."}),(0,f.jsx)(c.A,{renderButton:(0,f.jsx)("div",{onClick:()=>this.setState({openDialogNhom:!0}),children:(0,f.jsx)(l.A,{fa:"list"})}),ref:this.DropdownlistDataNhomSanPhamDichVu,className:"mb-2",type:"dropdown-list",title:"Nh\xf3m",placeholder:"Ch\u1ecdn nh\xf3m s\u1ea3n ph\u1ea9m",url:"DM_NhomSanPhamDichVu",where:"Loai eq '".concat(e.split("-")[0],"'"),valueField:"Id",textField:"Ten",value:a,onChange:e=>this.setState({nhomSanPhamDichVuId:e},(()=>Ce()))}),(0,f.jsx)(c.A,{className:"mb-2",type:"dropdown-list",title:"Nh\xf3m \u0111\u01a1n v\u1ecb",placeholder:"Ch\u1ecdn nh\xf3m \u0111\u01a1n v\u1ecb",url:"DM_DonViTinh",valueField:"Id",textField:"Ten",value:S,onChange:e=>this.setState({nhomDonVi:e},(()=>Ce()))}),(0,f.jsx)(c.A,{className:"mb-2",type:"dropdown-list",title:"Nh\xe0 cung c\u1ea5p",placeholder:"Ch\u1ecdn nh\xe0 cung c\u1ea5p",options:T,valueField:"Id",textField:"Ten",value:g,onChange:e=>this.setState({nhaCungCapId:e},(()=>Ce()))}),(0,f.jsx)(c.A,{type:"dropdown-list",className:"mb-2",title:"Cho ph\xe9p b\xe1n h\xe0ng",placeholder:"Cho ph\xe9p b\xe1n h\xe0ng",options:[{Name:"T\u1ea5t c\u1ea3",Id:null},{Name:"Cho ph\xe9p",Id:"true"},{Name:"Kh\xf4ng cho ph\xe9p",Id:"false"}],value:x,valueField:"Id",textField:"Name",onChange:e=>this.setState({isBanHang:e},(()=>Ce()))}),(0,f.jsx)(c.A,{type:"dropdown-list",className:"mb-2",title:"Tr\u1ea1ng th\xe1i t\u1ed3n kho",placeholder:"Tr\u1ea1ng th\xe1i t\u1ed3n kho",options:[{Name:"T\u1ea5t c\u1ea3",Id:null},{Name:"T\u1ed3n kho",Id:"true"},{Name:"Kh\xf4ng",Id:"false"}],valueField:"Id",textField:"Name",value:C,onChange:e=>this.setState({isTonKho:e},(()=>Ce()))})]}),(0,f.jsxs)(u.A,{NoTabs:!0,children:[_&&(0,f.jsx)(o.A,{tableRef:Se,title:"Danh s\xe1ch ".concat(this.state.title),url:"DM_SanPhamDichVu",columns:Te,where:I.join(" and "),selectType:"withColumns",updateCountRadioList:()=>this.FilterCard.current&&this.FilterCard.current.updateCountRadioList(),onAdd:{onClick:e=>this.setState({openCreate:!0,ID:null}),defaultValues:[{field:"Loai",value:e.value}]},onEdit:{disabled:e=>"dong-goi"===S&&null!==e.Base_Id,onClick:(e,a)=>this.setState({openCreate:!0,ID:a.Id})},onDelete:{onClick:(e,a)=>(0,h.A1)("B\u1ea1n ch\u1eafc ch\u1eafc mu\u1ed1n x\xf3a s\u1ea3n ph\u1ea9m n\xe0y?","Th\xf4ng b\xe1o").then((()=>this.deleteSanPham(a.Id)))},messageCustomDetele:"X\xf3a kh\xf4ng th\xe0nh c\xf4ng v\xec s\u1ea3n ph\u1ea9m n\xe0y \u0111\xe3 ph\xe1t sinh d\u1eef li\u1ec7u",onRowClick:(e,a)=>this.setState({openDetail:!0,ID:a.Id})}),i&&(0,f.jsx)(D.A,{ID:s,dataNhomSanPhamDichVu:n,dataNhaCungCap:T,updateCountRadioList:()=>this.FilterCard.current&&this.FilterCard.current.updateCountRadioList(),Loai:e.split("-")[0],TrangThaiTonKho:"true"===e.split("-")[1],open:i,onClose:this.onCloseCreate,reloadList:Ce}),m&&(0,f.jsx)(ce,{ID:s,open:m,onClose:()=>this.setState({openDetail:!1,ID:null}),reloadList:Ce}),p&&(0,f.jsx)(ge,{Loai:e.split("-")[0],reloadDataNhomSanPhamDichVu:()=>{this.DropdownlistDataNhomSanPhamDichVu.current.reLoadDataDropDownList(),this.getDataNhomSanPhamDichVu()},open:p,onClose:()=>this.setState({openDialogNhom:!1,ID:null})})]})]})}}class _e extends t.Component{render(){return(0,f.jsx)(xe,{title:"Danh s\xe1ch s\u1ea3n ph\u1ea9m"})}}},98548:()=>{}}]);