????
Current Path : C:/inetpub/vhost/qlk.nextform.vn/www/wwwroot/static/js/ |
Current File : C:/inetpub/vhost/qlk.nextform.vn/www/wwwroot/static/js/390.22e72e85.chunk.js |
"use strict";(self.webpackChunkgdt=self.webpackChunkgdt||[]).push([[390],{25602:(a,e,t)=>{t.d(e,{M:()=>n});const n={SanPham:"SanPham",DichVu:"DichVu"}},70390:(a,e,t)=>{t.r(e),t.d(e,{default:()=>z});var n=t(9950),i=t(30616),s=t(28412),h=t(23931),l=t(18849),o=t(76991),d=t(21205),r=t(27220),c=t(62181),g=t(4370),u=t(67116),p=t(32385),m=t(95888),G=t(53744),D=t(36841),N=t(86803),x=t.n(N),T=t(53139),b=t(73613),B=t(65597),I=t(85560),C=t(97540),S=t(70349),L=t(53832),f=t(44414);const j={TenBangGia:{field_name:"TenBangGia",title:"T\xean b\u1ea3ng gi\xe1",type:"textbox",required:!0},TrangThai:{field_name:"TrangThai",title:"Tr\u1ea1ng th\xe1i s\u1eed d\u1ee5ng",type:"checkbox"},MacDinh:{field_name:"MacDinh",title:"M\u1eb7c \u0111\u1ecbnh",type:"checkbox"},DiemKinhDoanhId:{field_name:"DiemKinhDoanhId",title:"\u0110i\u1ec3m kinh doanh",required:!1,dataSelect:{url:"DiemKinhDoanhs",column:["Id","Ten"],value_field:"Id",text_field:"Ten"}},IsChung:{field_name:"IsChung",title:"B\u1ea3ng gi\xe1 \u0111\u01b0\u1ee3c d\xf9ng chung",type:"checkbox"}};class v extends n.Component{constructor(a){super(a),this.getDataBangGia=()=>{const{IdBangGia:a}=this.props;(0,g.Pq)("Sale_BangGia(".concat(a,")?$expand=DM_DiemKinhDoanh")).then((a=>{this.setState({data:{Id:a.Id,TenBangGia:a.Ten,TrangThai:a.TrangThai,MacDinh:a.MacDinh,DiemKinhDoanhId:a.DiemKinhDoanh_Id,IsChung:a.IsChung,TenDKD:a.DM_DiemKinhDoanh.Ten},loading:!1})})).catch((a=>(0,u.a3)(a.Message)))},this.handleValidate=a=>{const e=Object.values(j).filter((a=>a.required));let{data:t}=this.state;for(let n=0;n<e.length;n++){const a=e[n];let i=t[a.field_name];if(null===i||""===i||void 0===i||0===i.length)return(0,u.AB)('Vui l\xf2ng nh\u1eadp "'+a.title+'"'),!1}return!0},this.setStateData=(a,e)=>{var{data:t}=this.state;t[a]=e,this.setState({data:t})},this.handleChange=(a,e)=>{this.setStateData(a,e)},this.save=()=>{const{data:a}=this.state,{IdBangGia:e}=this.props;if(this.handleValidate())if(e){let e={Id:a.Id,Ten:a.TenBangGia,TrangThai:a.TrangThai||!1,MacDinh:a.MacDinh||!1,IsChung:a.IsChung||!1,DiemKinhDoanhId:"dieuhanh"===G.lg.MaVaiTro?a.DiemKinhDoanhId:G.b9.DiemKinhDoanhId};this.setState({disBtn:!0},(()=>{(0,g.Pq)("BangGia/CapNhatBangGia","POST",JSON.stringify(e),!1,!0).then((a=>this.setState({disBtn:!1},(()=>(0,u.nw)(a.Message).then((()=>{this.setState({disBtn:!1}),this.props.getDataBangGia(),this.props.addCallback(),this.props.closeCreate(),this.props.reloadTable()})))))).catch((a=>(0,u.a3)(a.Message).then((()=>this.setState({disBtn:!1})))))}))}else{let e={Ten:a.TenBangGia,TrangThai:a.TrangThai||!1,MacDinh:a.MacDinh||!1,DiemKinhDoanhId:"dieuhanh"===G.lg.MaVaiTro?a.DiemKinhDoanhId:G.b9.DiemKinhDoanhId};this.setState({disBtn:!0},(()=>{(0,g.Pq)("BangGia/TaoBangGia","POST",JSON.stringify(e),!1,!0).then((a=>this.setState({disBtn:!1},(()=>(0,u.nw)(a).then((()=>{this.setState({disBtn:!1}),this.props.getDataBangGia(),this.props.addCallback(),this.props.closeCreate(),this.props.reloadTable()})))))).catch((a=>(0,u.a3)(a.Message).then((()=>this.setState({disBtn:!1})))))}))}},this.state={data:{},loading:!0,disBtn:!1}}componentDidMount(){const{IdBangGia:a}=this.props;a?this.getDataBangGia():"dieuhanh"===G.lg.MaVaiTro?(j.DiemKinhDoanhId.required=!0,this.setState({data:{DiemKinhDoanhId:G.lg.DiemKinhDoanhId,TrangThai:!0},loading:!1})):this.setState({data:{},loading:!1})}render(){const{openCreate:a,closeCreate:e,title:t,IdBangGia:n}=this.props,{data:i,loading:s,disBtn:o}=this.state;return(0,f.jsx)(B.A,{open:a,maxWidth:"sm",handleClose:e,title:t,children:o?(0,f.jsx)(C.A,{style:{display:"flex",margin:"auto",color:"#f19898",zIndex:1e4}}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(S.A,{children:(0,f.jsxs)(h.A,{children:[(0,f.jsx)(L.A,{data:j.TenBangGia,value:i.TenBangGia,onChange:this.handleChange}),"dieuhanh"===G.lg.MaVaiTro&&(0,f.jsx)(L.A,{data:{...j.DiemKinhDoanhId,type:n?"label":"data-select"},value:n?i.TenDKD:i.DiemKinhDoanhId,onChange:this.handleChange})]})}),(0,f.jsx)(S.A,{children:(0,f.jsxs)(h.A,{style:{textAlign:"right"},children:[(0,f.jsxs)(l.A,{disabled:o,size:"sm",color:"success",onClick:this.save,children:[(0,f.jsx)(b.A,{fa:"save"})," L\u01b0u"]}),(0,f.jsxs)(l.A,{size:"sm",style:{marginLeft:"10px"},color:"dark",onClick:e,children:[(0,f.jsx)(b.A,{fa:"ban"})," B\u1ecf qua"]})]})})]})})}}var P=t(78873);const A=[{title:"Id",field:"Id",type:"numeric",dataID:!0,hidden:!0,editable:"never",cellStyle:{textAlign:"center"}},{title:"Ng\xe0y t\u1ea1o",field:"NgayTao",type:"datetime",defaultSort:"desc",cellStyle:{textAlign:"left"}},{title:"B\u1ea3ng gi\xe1",field:"Ten",type:"string",dataCheck:!0,searchable:!0,cellStyle:{textAlign:"left"}},{title:"Tr\u1ea1ng th\xe1i ho\u1ea1t \u0111\u1ed9ng",field:"TrangThai",type:"boolean",hidden:!0,cellStyle:{textAlign:"center"},render:a=>a.TrangThai?(0,f.jsx)(P.A,{color:"success",children:"\u0110ang ho\u1ea1t \u0111\u1ed9ng"}):(0,f.jsx)(P.A,{color:"danger",children:"Kh\xf4ng ho\u1ea1t \u0111\u1ed9ng"})},{title:"M\u1eb7c \u0111\u1ecbnh",field:"MacDinh",type:"boolean",cellStyle:{textAlign:"center"},render:a=>a.MacDinh&&(0,f.jsx)(P.A,{color:"success",children:"\u0110ang s\u1eed d\u1ee5ng"})},{title:"B\u1ea3ng gi\xe1 chung",field:"IsChung",type:"boolean",hidden:!0,cellStyle:{textAlign:"center"},render:a=>a.IsChung&&(0,f.jsx)(P.A,{color:"success",children:"\u0110ang ho\u1ea1t \u0111\u1ed9ng"})},{title:"\u0110i\u1ec3m kinh doanh",field:"DiemKinhDoanh_Id",type:"numeric",hidden:!0,cellStyle:{textAlign:"left"}},{title:"\u0110i\u1ec3m kinh doanh",field:"DM_DiemKinhDoanh.Ten",type:"string",hidden:!1,searchable:!0,cellStyle:{textAlign:"left"}}],y=n.createRef(),V=()=>y.current&&y.current.onQueryChange();class M extends n.Component{constructor(a){super(a),this.deleteBangGia=a=>{(0,g.Pq)("BangGia/XoaBangGia?bangGiaId=".concat(a),"DELETE",null,!1).then((a=>(0,u.nw)(a).then((()=>{this.props.getDataBangGia(),this.props.addCallback(),V()})))).catch((a=>(0,u.a3)(a.Message)))},this.state={openCreate:!1}}render(){const{open:a,onClose:e,addCallback:t,updateCallback:i,deleteCallback:s,getDataBangGia:h}=this.props,{openCreate:l,IdBangGia:o}=this.state;return(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(B.A,{className:"dialog-bang-gia",open:a,maxWidth:"md",handleClose:e,children:(0,f.jsx)(I.A,{tableRef:y,deleteCallback:()=>s(),updateCallback:()=>i(),addCallback:()=>t(),title:"Danh s\xe1ch b\u1ea3ng gi\xe1",url:"Sale_BangGia",columns:A,selectType:"withColumns",onActions:[{icon:"check",tooltip:"Ch\u1ecdn m\u1eb7c \u0111\u1ecbnh",onClick:(a,e)=>{(0,u.A1)("B\u1ea1n c\xf3 mu\u1ed1n ch\u1ecdn m\u1eb7c \u0111\u1ecbnh kh\xf4ng?","Th\xf4ng b\xe1o").then((a=>{(0,g.Pq)("BangGia/ChonLamMacDinh?BangGia_Id=".concat(e.Id),"POST",null,!1).then((a=>{(0,u.nw)("Th\xe0nh c\xf4ng!"),V()})).catch((a=>(0,u.a3)(a)))}))}}],onAdd:{onClick:a=>this.setState({openCreate:!0,IdBangGia:null})},onEdit:{onClick:(a,e)=>this.setState({openCreate:!0,IdBangGia:e.Id})},onDelete:{onClick:(a,e)=>(0,u.A1)("B\u1ea1n c\xf3 ch\u1eafc ch\u1eafn mu\u1ed1n x\xf3a ".concat(e.Ten," kh\xf4ng?"),"C\u1ea3nh b\xe1o").then((()=>this.deleteBangGia(e.Id)))}})}),l&&(0,f.jsx)(v,{getDataBangGia:()=>h(),IdBangGia:o,openCreate:l,closeCreate:()=>this.setState({openCreate:!1}),title:o?"C\u1eadp nh\u1eadt b\u1ea3ng gi\xe1":"T\u1ea1o m\u1edbi b\u1ea3ng gi\xe1",addCallback:()=>t(),reloadTable:V})]})}}var k=t(65907),F=(t(25602),t(58195)),K=t(14113),w=t(99308),_=t(85907),E=t(55002);const q=a=>{let{resetGiaBanDau:e,setSetting:t,open:i,onClose:s}=a;const[h,l]=(0,n.useState)(localStorage.getItem("Setting")),o=(0,n.useCallback)((a=>{t(a),l(a)}),[t]),d=(0,n.useCallback)((()=>{localStorage.setItem("Setting",h),(0,u.nw)("L\u01b0u c\xe0i \u0111\u1eb7t th\xe0nh c\xf4ng"),e(),s()}),[h,s]);return(0,f.jsx)(f.Fragment,{children:(0,f.jsxs)(F.A,{size:"sm",isOpen:i,toggle:s,zIndex:"1301",children:[(0,f.jsx)(K.A,{children:"C\xe0i \u0111\u1eb7t hi\u1ec3n th\u1ecb"}),(0,f.jsx)(w.A,{children:(0,f.jsx)(L.A,{data:{title:"Hi\u1ec3n th\u1ecb l\u1ee3i nhu\u1eadn",type:"radio-list",required:!0,data:[{value:"2",label:"Ph\u1ea7n tr\u0103m"},{value:"1",label:"S\u1ed1 ti\u1ec1n c\u1ee5 th\u1ec3"}]},value:h,onChange:(a,e)=>o(e)})}),(0,f.jsx)(_.A,{children:(0,f.jsx)(E.QB,{onClick:()=>d(),children:"L\u01b0u"})})]})})},X=a=>{let{open:e,close:t,IdBangGia:i}=a;const[s,h]=(0,n.useState)([]);return(0,n.useEffect)((()=>{i&&(0,g.Pq)("QuanLyKho/GetListSanPham?BangGia_Id=".concat(i),"GET",null,!1).then((a=>{h(a.value)}))}),[i]),(0,f.jsx)(f.Fragment,{children:(0,f.jsxs)(F.A,{size:"lg",isOpen:e,toggle:t,children:[(0,f.jsx)(K.A,{toggle:t,children:"Danh s\xe1ch c\xe1c s\u1ea3n ph\u1ea9m ch\u01b0a \u0111\u01b0\u1ee3c th\xeam v\xe0o b\u1ea3ng gi\xe1"}),(0,f.jsx)(w.A,{children:(0,f.jsxs)(d.A,{hover:!0,className:"border",children:[(0,f.jsx)("thead",{children:(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{children:"STT"}),(0,f.jsx)("th",{children:"M\xe3 s\u1ea3n ph\u1ea9m"}),(0,f.jsx)("th",{children:"T\xean s\u1ea3n ph\u1ea9m"}),(0,f.jsx)("th",{children:"\u0110\u01a1n v\u1ecb t\xednh"})]})}),(0,f.jsx)("tbody",{children:s.map(((a,e)=>(0,f.jsx)(f.Fragment,{children:(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{scope:"row",children:e+1}),(0,f.jsx)("td",{children:null===a||void 0===a?void 0:a.MaSanPham}),(0,f.jsx)("td",{children:null===a||void 0===a?void 0:a.TenSanPham}),(0,f.jsx)("td",{children:null===a||void 0===a?void 0:a.DonViTinh})]})})))})]})})]})})};class O extends n.Component{constructor(a){super(a),this.getNhomDonviTinh=()=>{(0,g.Pq)("DM_NhomDonViTinh").then((a=>this.setState({dataNhomDVT:a.value.map((a=>({label:a.TenNhom,value:a.MaNhom})))})))},this.handleDeleteSP=a=>{(0,u.A1)("B\u1ea1n ch\u1eafc ch\u1eafn mu\u1ed1n x\xf3a s\u1ea3n ph\u1ea9m n\xe0y?","Th\xf4ng b\xe1o").then((()=>{(0,g.Pq)("Sale_ChiTietBangGia(".concat(a,")"),"DELETE").then((a=>{this.getDataThietLapGia(this.state.defaultValueSelect),(0,u.nw)("Xo\xe1 s\u1ea3n ph\u1ea9m th\xe0nh c\xf4ng!","Th\xf4ng b\xe1o")}))}))},this.setDefaultValueSelect=a=>{let e=a.find((a=>!0===a.MacDinh&&a.DiemKinhDoanh_Id===G.lg.DiemKinhDoanhId));if(e)this.setState({defaultValueSelect:e.Id},(()=>this.getDataThietLapGia(this.state.defaultValueSelect)));else{let e=a.find((a=>!0===a.IsChung));var t;if(e)this.setState({defaultValueSelect:e.Id},(()=>this.getDataThietLapGia(this.state.defaultValueSelect)));else this.setState({defaultValueSelect:null===(t=a[0])||void 0===t?void 0:t.Id},(()=>this.getDataThietLapGia(this.state.defaultValueSelect)))}},this.tinhGiaBan=(a,e,t,n,i)=>(0,D.EP)()?t||"2"===i?(parseInt(e||0)+parseFloat(t||0)/100*parseInt(e||0)).toFixed(0):parseInt(e||0)+parseInt(n||0):t||"2"===i?(parseInt(a||0)+parseFloat(t||0)/100*parseInt(a||0)).toFixed(0):parseInt(a||0)+parseInt(n||0),this.tinhGiaDeXuat=(a,e,t,n,i)=>(0,D.EP)()?t||"2"===i?(parseInt(e||0)+parseFloat(t||0)/100*parseInt(e||0)).toFixed(0):parseInt(e||0)+parseInt(n||0):t||"2"===i?(parseInt(a||0)+parseFloat(t||0)/100*parseInt(a||0)).toFixed(0):parseInt(a||0)+parseInt(n||0),this.tinhPhanTramLoiNhuan=(a,e,t)=>(void 0===e&&(e=0),(0,D.EP)()?parseFloat(((parseInt(a)-parseInt(t))/parseInt(t)*100).toFixed(2)):parseFloat(((parseInt(a)-parseInt(e))/parseInt(e)*100).toFixed(2))),this.tinhLoiNhuan=(a,e,t)=>(void 0===e&&(e=0),(0,D.EP)()?parseInt(a)-parseInt(t):parseInt(a)-parseInt(e)),this.getDataThietLapGia=a=>{const{loai:e,textSeachSanPham:t,IdLoiNhuan:n,maNhomDVT:i,NCC_Id:s}=this.state;(0,g.Pq)("QuanLyKho/SanPhams?bangGiaId=".concat(a,"&diemKinhDoanhId=").concat(G.b9.DiemKinhDoanhId,"&loai=").concat(e,"&key=").concat(t,"&nhomDonViTinh=").concat(i,"&ncc=").concat(s),"GET",null,!1).then((a=>{let e=[];a.map(((a,t)=>{let i=[];i=a.BangGias?[{...a.BangGias,PTLoiNhuan:parseFloat(a.BangGias.PTLoiNhuan)||0,LoiNhuan:parseFloat(a.BangGias.LoiNhuan)||0,GiaBan:a.BangGias.GiaBan||this.tinhGiaBan(a.BangGias.GiaVon,a.BangGias.GiaNhapCuoi,a.BangGias.PTLoiNhuan,a.BangGias.LoiNhuan,n),GiaDeXuat:a.BangGias.GiaDeXuat||this.tinhGiaDeXuat(a.BangGias.GiaVon,a.BangGias.GiaNhapCuoi,a.BangGias.PTLoiNhuan,a.BangGias.LoiNhuan,n),SanPhamDichVuId:a.Id,IdLoiNhuan:a.BangGias.PTLoiNhuan?"2":"1"}]:[{GiaVon:0,GiaBan:0,PTLoiNhuan:0,LoiNhuan:0,GiaDeXuat:0,SanPhamDichVuId:a.Id,IdLoiNhuan:n}],e.push({...a,BangGias:i})})),this.setState({dataThietLapGia:e})})).catch((a=>{(0,u.Zz)("Ch\u01b0a c\xf3 b\u1ea3ng gi\xe1, Vui l\xf2ng t\u1ea1o b\u1ea3ng gi\xe1","TH\xd4NG B\xc1O","T\u1ea1o b\u1ea3ng gi\xe1","\u0110\xf3ng").then((()=>{this.setState({openCreateBangGia:!0}),console.log(this.state.openCreateBangGia)}))}))},this.handleChangeSelect=a=>{a&&this.setState({defaultValueSelect:a},(()=>{this.getDataThietLapGia(a),this.updateBangGiaMacDinh(a)}))},this.updateBangGiaMacDinh=async a=>{let e=await(0,g.ID)("Sale_BangGia(".concat(a,")"));e.Id,e.Ten,e.TrangThai,e.IsChung,e.DiemKinhDoanh_Id},this.onChangeLoai=a=>{const{defaultValueSelect:e}=this.state;this.setState({loai:a},(()=>this.getDataThietLapGia(e)))},this.handleChangeGiaBanDeXuat=(a,e,t)=>{let{dataThietLapGia:n}=this.state,i=n.find((e=>e.Id===a.Id)),s=i.BangGias.map(((a,t)=>({...a,GiaBan:parseInt(e)||0,GiaDeXuat:a.GiaDeXuat,statusGiaBan:!0,PTLoiNhuan:"2"===a.IdLoiNhuan?this.tinhPhanTramLoiNhuan(e,a.GiaVon,a.GiaNhapCuoi):0,LoiNhuan:"1"===a.IdLoiNhuan?this.tinhLoiNhuan(e,a.GiaVon,a.GiaNhapCuoi):0})));i={...i,BangGias:s},n[t]=i,this.setState({dataThietLapGia:n})},this.handleChangeGiaVon=(a,e,t)=>{let{dataThietLapGia:n}=this.state,i=n.find((e=>e.Id===a.Id)),s=i.BangGias.map(((t,n)=>({...t,GiaVon:parseInt(e),SanPhamDichVuId:a.Id,GiaDeXuat:this.tinhGiaDeXuat(e,t.PTLoiNhuan,t.LoiNhuan),GiaBan:this.tinhGiaBan(e,t.PTLoiNhuan,t.LoiNhuan)})));i={...i,BangGias:s},n[t]=i,this.setState({dataThietLapGia:n})},this.handlePTLoiNhuanChange=(a,e,t)=>{let{dataThietLapGia:n}=this.state,i=n.find((e=>e.Id===a.Id)),s=i.BangGias.map(((a,e)=>({...a,PTLoiNhuan:parseFloat(t),LoiNhuan:0,GiaDeXuat:this.tinhGiaDeXuat(a.GiaVon,a.GiaNhapCuoi,t,null,a.IdLoiNhuan),GiaBan:this.tinhGiaBan(a.GiaVon,a.GiaNhapCuoi,t,null,a.IdLoiNhuan)})));i={...i,BangGias:s},n[e]=i,this.setState({dataThietLapGia:n})},this.handleLoiNhuanChange=(a,e,t)=>{let{dataThietLapGia:n}=this.state,i=n.find((e=>e.Id===a.Id)),s=i.BangGias.map(((a,e)=>({...a,PTLoiNhuan:0,LoiNhuan:parseFloat(t),GiaDeXuat:this.tinhGiaDeXuat(a.GiaVon,a.GiaNhapCuoi,null,t,a.IdLoiNhuan),GiaBan:this.tinhGiaBan(a.GiaVon,a.GiaNhapCuoi,null,t,a.IdLoiNhuan)})));i={...i,BangGias:s},n[e]=i,this.setState({dataThietLapGia:n})},this.onChangeInputPhanTram=(a,e)=>{let{dataThietLapGia:t}=this.state,n=a.target.value;if(13===a.charCode||e){let a=[];t.map(((e,t)=>{let i=e.BangGias.map(((a,t)=>({...a,SanPhamDichVuId:e.Id,LoiNhuan:0,PTLoiNhuan:parseFloat(n)||0,GiaBan:this.tinhGiaBan(a.GiaVon,a.GiaNhapCuoi,n,null,a.IdLoiNhuan),GiaDeXuat:this.tinhGiaDeXuat(a.GiaVon,a.GiaNhapCuoi,n,null,a.IdLoiNhuan)})));a.push({...e,BangGias:i})})),this.setState({dataThietLapGia:a,PTLoiNhuan:n})}},this.onChangeInputVND=(a,e)=>{let{dataThietLapGia:t}=this.state;if(13===e||"eventBlur"===e){let e=[];t.map(((t,n)=>{let i=t.BangGias.map(((e,n)=>({...e,SanPhamDichVuId:t.Id,LoiNhuan:parseFloat(a)||0,PTLoiNhuan:0,GiaBan:this.tinhGiaBan(e.GiaVon,e.GiaNhapCuoi,null,a),GiaDeXuat:this.tinhGiaDeXuat(e.GiaVon,e.GiaNhapCuoi,null,a)})));e.push({...t,BangGias:i})})),this.setState({dataThietLapGia:e,LoiNhuan:a})}},this.save=()=>{const{dataThietLapGia:a,defaultValueSelect:e}=this.state;let t=[];a.map((a=>{a.BangGias.map((a=>{t.push({SanPhamDichVuId:a.SanPhamDichVuId,PTLoiNhuan:parseFloat(a.PTLoiNhuan),LoiNhuan:parseFloat(a.LoiNhuan),GiaVon:a.GiaVon||0,GiaBan:a.GiaBan})}))}));let n={GiaBanSanPhamDichVus:t,DiemKinhDoanhId:G.b9.DiemKinhDoanhId,BangGiaId:e};(0,g.Pq)("QuanLyKho/NhapGiaBanSanPham","POST",JSON.stringify(n),!1).then((a=>(0,u.nw)(a).then((()=>{this.getDataThietLapGia(e)})))).catch((a=>(0,u.a3)(a)))},this.openDialogBangGia=()=>{this.setState({openDialogBangGia:!0})},this.resetGiaBanDau=()=>{const{defaultValueSelect:a}=this.state;this.getDataThietLapGia(a)},this.onKeyPressSearch=a=>{const{defaultValueSelect:e}=this.state;13===a.charCode&&this.setState({textSeachSanPham:a.target.value},(()=>this.getDataThietLapGia(e)))},this.handleChangeRadioLoiNhuan=a=>{let{dataThietLapGia:e}=this.state,t=[];e.map(((e,n)=>{let i=e.BangGias.map(((t,n)=>({...t,SanPhamDichVuId:e.Id,IdLoiNhuan:a,LoiNhuan:0,PTLoiNhuan:0,GiaBan:t.GiaBan,GiaDeXuat:t.GiaDeXuat})));t.push({...e,BangGias:i})})),this.setState({dataThietLapGia:t,LoiNhuan:0,PTLoiNhuan:0,IdLoiNhuan:a})},this.handleChangeNhomDVT=a=>{const{defaultValueSelect:e}=this.state;this.setState({maNhomDVT:a},(()=>this.getDataThietLapGia(e)))},this.handleChangeNCC=a=>{const{defaultValueSelect:e}=this.state;this.setState({NCC_Id:a}),this.getDataThietLapGia(e)},this.state={loai:"SanPham",optionsBangGia:[],defaultValueSelect:null,dataThietLapGia:[],openDialogBangGia:!1,openPopupCaiDat:!1,dataSeach:[],textSeachSanPham:"",IdLoiNhuan:localStorage.getItem("Setting"),PTLoiNhuan:"",LoiNhuan:"",dataNhomDVT:[],maNhomDVT:"hang-le",NCC_Id:null,openCreateBangGia:!1,listLoaiSP:[],openListPriceNotAdd:!1},this.FilterCard=n.createRef(),this.resetGiaTungSP=this.resetGiaTungSP.bind(this)}componentDidMount(){this.getDataBangGia(),this.getNhomDonviTinh(),this.getDataLoaiSanPham()}getDataLoaiSanPham(){(0,g.Pq)("DM_LoaiSanPham","GET").then((a=>{this.setState({listLoaiSP:a.value.map((a=>({label:a.TenLoai,value:a.MaLoai})))})}))}getDataBangGia(){(0,g.Pq)("Sale_BangGia?$orderby=NgayTao desc","GET",null).then((a=>this.setState({optionsBangGia:a.value},(()=>this.setDefaultValueSelect(this.state.optionsBangGia))))).catch((a=>(0,u.a3)(a)))}async resetGiaTungSP(a,e){const{defaultValueSelect:t,loai:n,dataThietLapGia:i,IdLoiNhuan:s,maNhomDVT:h,NCC_Id:l}=this.state;let o=(await(0,g.Pq)("QuanLyKho/SanPhams?bangGiaId=".concat(t,"&diemKinhDoanhId=").concat(G.b9.DiemKinhDoanhId,"&loai=").concat(n,"&key=&nhomDonViTinh=").concat(h,"&ncc=").concat(l),"GET",null,!1)).find((e=>e.Id===a.Id)),d=[];d=o.BangGias?o.BangGias.map(((a,e)=>({...a,PTLoiNhuan:parseFloat(a.PTLoiNhuan)||0,LoiNhuan:parseFloat(a.LoiNhuan)||0,IdLoiNhuan:a.PTLoiNhuan?"2":"1",GiaDeXuat:this.tinhGiaDeXuat(a.GiaVon,a.GiaNhapCuoi,a.PTLoiNhuan,a.LoiNhuan),GiaBan:a.GiaBan||0}))):[{GiaVon:0,GiaBan:0,PTLoiNhuan:0,GiaDeXuat:0,SanPhamDichVuId:a.Id}],o={...o,BangGias:d},i[e]=o,this.setState({dataThietLapGia:i})}render(){const{loai:a,defaultValueSelect:e,dataThietLapGia:t,openDialogBangGia:n,IdLoiNhuan:g,PTLoiNhuan:u,LoiNhuan:N,maNhomDVT:B,NCC_Id:I,openCreateBangGia:C,openPopupCaiDat:S,openListPriceNotAdd:L}=this.state,j="dieuhanh"===G.lg.MaTaiKhoan?"":"DiemKinhDoanh_Id eq ".concat(G.lg.DiemKinhDoanhId);return(0,f.jsxs)(f.Fragment,{children:[L&&(0,f.jsx)(X,{open:L,IdBangGia:e,close:()=>this.setState({openListPriceNotAdd:!1})}),(0,f.jsxs)(i.A,{children:[(0,f.jsxs)(s.A,{NoTabs:!0,children:[(0,f.jsx)(h.A,{md:"12",className:"p-0 mb-2",children:(0,f.jsx)(c.A,{ref:this.FilterCard,renderButton:(0,f.jsx)("span",{onClick:this.openDialogBangGia,children:(0,f.jsx)(b.A,{fa:"list"})}),type:"dropdown-list",title:"B\u1ea3ng gi\xe1",url:"Sale_BangGia",where:j,onChange:a=>this.handleChangeSelect(a),valueField:"Id",textField:"Ten",value:e})}),(0,f.jsx)(h.A,{md:"12",className:"p-0 mb-2",children:e&&(0,f.jsxs)("div",{className:"bg-white border rounded ",children:[(0,f.jsx)("div",{style:{backgroundColor:"#f0f3f5"},className:"pl-4 pt-3 pb-3 rounded-top border-bottom",children:(0,f.jsx)("strong",{children:"Nh\xf3m \u0111\u01a1n v\u1ecb t\xednh"})}),(0,f.jsx)("div",{className:"p-3",children:(0,f.jsx)(k.A,{type:"radio-list",title:"Nh\xf3m \u0111\u01a1n v\u1ecb t\xednh",data:this.state.dataNhomDVT,value:B,onChange:a=>this.handleChangeNhomDVT(a)})})]})}),(0,f.jsx)(h.A,{md:"12",className:"p-0 mb-2",children:(0,f.jsx)(c.A,{type:"dropdown-list",title:"Nh\xe0 cung c\u1ea5p",placeholder:"Ch\u1ecdn nh\xe0 cung c\u1ea5p",url:"DM_LienHe",where:"NhomLienHe_Id eq 'nhacungcap'",valueField:"Id",textField:"Ten",value:I,onChange:a=>this.handleChangeNCC(a)})}),(0,f.jsx)(h.A,{md:"12",className:"p-0 mb-2",children:(0,f.jsx)(c.A,{type:"textbox",title:"T\xecm ki\u1ebfm s\u1ea3n ph\u1ea9m",placeholder:"T\xecm ki\u1ebfm theo m\xe3 ho\u1eb7c t\xean s\u1ea3n ph\u1ea9m",onKeyPress:a=>this.onKeyPressSearch(a)})}),(0,D.EP)()?null:(0,f.jsx)(h.A,{md:"12",className:"p-0 mb-2",children:e&&(0,f.jsx)(c.A,{type:"radio-list",title:"Lo\u1ea1i",data:this.state.listLoaiSP,value:a,onChange:(a,e)=>this.onChangeLoai(e)})})]}),(0,f.jsxs)(p.A,{children:[(0,f.jsxs)("h5",{children:[(0,f.jsx)("b",{children:"Thi\u1ebft l\u1eadp gi\xe1"})," "]}),(0,f.jsxs)("div",{className:"tieu-de mb-3 rounded",children:[(0,f.jsx)("div",{style:{gap:"0.5rem"},className:"d-flex align-items-center",children:e&&(0,f.jsxs)(l.A,{onClick:()=>this.setState({openListPriceNotAdd:!0}),className:"btn-bang-gia btn-bang-gia-list",children:[(0,f.jsx)(b.A,{fa:"list-ul"}),"C\xe1c s\u1ea3n ph\u1ea9m ch\u01b0a thi\u1ebft l\u1eadp gi\xe1"]})}),(0,f.jsx)("div",{className:"ml-auto d-flex align-items-center",children:t&&0!==t.length&&(0,f.jsx)("span",{className:"input-all-ptln",children:(0,f.jsx)("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"}})})})]}),(0,f.jsxs)("div",{className:"bg-white box-shadow-bang-gia",children:[(0,f.jsx)("div",{className:"d-flex mb-2 pt-2",children:(0,f.jsxs)(l.A,{className:"ml-auto btn-refresh-all-bang-gia",size:"sm",onClick:this.resetGiaBanDau,children:[(0,f.jsx)(b.A,{fa:"repeat"})," \u0110\u1eb7t l\u1ea1i"]})}),(0,f.jsxs)(m.A,{className:"card-thiet-lap-gia rounded-0",children:[(0,f.jsx)(o.A,{className:"rounded-0",style:{padding:0},children:(0,f.jsx)("div",{className:"table-thiet-lap-gia",children:(0,f.jsxs)(d.A,{size:"sm",bordered:!0,children:[(0,f.jsx)("thead",{children:(0,f.jsxs)("tr",{children:[(0,f.jsx)("th",{className:"th-hinh-anh font-weight-bold",children:"H\xecnh \u1ea3nh"}),(0,f.jsx)("th",{className:"th-ma-sp font-weight-bold",children:"M\xe3 SP"}),(0,f.jsx)("th",{className:"th-ten-sp font-weight-bold",children:"T\xean SP"}),(0,f.jsx)("th",{className:"th-gia-von font-weight-bold",children:(0,D.EP)()?"Gi\xe1 nh\u1eadp cu\u1ed1i":"Gi\xe1 v\u1ed1n"}),(0,f.jsx)("th",{className:"th-loi-nhuan font-weight-bold",children:"L\u1ee3i nhu\u1eadn"}),(0,f.jsx)("th",{className:"th-gia-ban font-weight-bold",children:"Gi\xe1 b\xe1n"}),(0,f.jsx)("th",{className:"th-dvt font-weight-bold",children:"\u0110VT"}),(0,f.jsx)("th",{})]})}),(0,f.jsx)("tbody",{children:t&&0!==t.length?t.map(((a,e)=>(0,f.jsxs)("tr",{children:[(0,f.jsx)("td",{className:"text-center",children:(0,f.jsx)("img",{width:"50",height:"50",src:a.HinhAnh?"".concat(G.Eh+a.HinhAnh):"assets/default.jpg",alt:""})}),(0,f.jsx)("td",{children:a.MaSanPham}),(0,f.jsx)("td",{children:a.TenSanPham}),(0,f.jsx)("td",{className:"text-right",children:a.BangGias.map((a=>(0,D.vv)((0,D.EP)()?a.GiaNhapCuoi:a.GiaVon)))}),(0,f.jsx)("td",{children:a.BangGias.map(((t,n)=>(0,f.jsxs)(f.Fragment,{children:["2"===localStorage.getItem("Setting")?(0,f.jsx)(T.YI,{style:{width:"80%",display:"inline-block"},placeholder:"0",min:"0",value:t.PTLoiNhuan,onFocus:a=>a.target.select(),onChange:t=>this.handlePTLoiNhuanChange(a,e,t.target.value)},n):(0,f.jsx)(x(),{style:{width:"80%",display:"inline-block"},className:"form-control form-control-sm",placeholder:"0",min:"0",onFocus:a=>a.target.select(),value:t.LoiNhuan||0,thousandSeparator:".",decimalSeparator:",",onValueChange:t=>{const{value:n}=t;this.handleLoiNhuanChange(a,e,n)}},n),(0,f.jsx)("span",{style:{fontSize:11,fontWeight:500},children:"2"===localStorage.getItem("Setting")?"(%)":"(VN\u0110)"})]})))}),(0,f.jsx)("td",{children:a.BangGias.map(((t,n)=>(0,f.jsxs)("div",{children:[(0,f.jsx)(x(),{className:"form-control form-control-sm",placeholder:"0",min:"0",onFocus:a=>a.target.select(),value:t.statusGiaBan||t.GiaBan?t.GiaBan:t.GiaDeXuat,thousandSeparator:".",decimalSeparator:",",onValueChange:t=>{const{value:n}=t;this.handleChangeGiaBanDeXuat(a,n,e)}}),(0,f.jsx)("div",{className:"pt-2",children:(0,f.jsx)("div",{className:"outline-gia-de-suat",children:(0,f.jsx)("span",{className:"text-gia-de-suat",children:(0,f.jsxs)("i",{children:["Gi\xe1 \u0111\u1ec1 xu\u1ea5t:"," ",(0,f.jsx)("b",{children:(0,D.vv)(t.GiaDeXuat)})]})})})})]},n)))}),(0,f.jsx)("td",{children:a.DonViTinh}),(0,f.jsx)("td",{children:(0,f.jsxs)("div",{className:"d-flex",children:[(0,f.jsx)(l.A,{color:"link",className:"btn-none-boxshadown btn-refresh-detail-bang-gia",onClick:()=>this.resetGiaTungSP(a,e),children:(0,f.jsx)(b.A,{fa:"repeat"})}),(0,f.jsx)(l.A,{className:"btn-none-boxshadown btn-delete-bang-gia",onClick:()=>this.handleDeleteSP(a.ChiTietBangGia_Id),children:(0,f.jsx)(b.A,{fa:"trash-o"})})]})})]},e))):(0,f.jsx)("tr",{children:(0,f.jsx)("td",{style:{padding:0,border:"none"},children:(0,f.jsxs)("div",{className:"td-no-product text-secondary",children:[(0,f.jsx)(b.A,{style:{fontSize:"90px"},fa:"dropbox"}),(0,f.jsx)("p",{children:"Kh\xf4ng c\xf3 h\xe0ng h\xf3a"})]})})})})]})})}),(0,f.jsx)(r.A,{className:"d-flex p-2",style:{textAlign:"right",padding:"5px 13px"},children:(0,f.jsxs)(l.A,{disabled:0===t.length,style:{width:"10%",fontSize:15,fontWeight:"bold",cursor:0!==t.length?"pointer":"no-drop"},className:"btn-bang-gia btn-luu-bang-gia ml-auto mr-3",size:"lg",onClick:this.save,children:[(0,f.jsx)(b.A,{fa:"save"})," L\u01b0u"]})})]})]})]}),n&&(0,f.jsx)(M,{getDataBangGia:()=>this.getDataBangGia(),updateCallback:()=>this.FilterCard.current.reLoadDataDropDownList(),deleteCallback:()=>this.FilterCard.current.reLoadDataDropDownList(),addCallback:()=>this.FilterCard.current.reLoadDataDropDownList(),open:n,onClose:()=>this.setState({openDialogBangGia:!1}),openCreateBangGia:this.state.openCreateBangGia}),C&&(0,f.jsx)(v,{getDataBangGia:()=>this.getDataBangGia(),openCreate:C,closeCreate:()=>this.setState({openCreateBangGia:!1}),title:"T\u1ea1o m\u1edbi b\u1ea3ng gi\xe1",addCallback:()=>this.FilterCard.current.reLoadDataDropDownList(),reloadTable:()=>console.log("da them")}),S&&(0,f.jsx)(q,{resetGiaBanDau:this.resetGiaBanDau,setSetting:a=>this.setState({IdLoiNhuan:a}),open:S,onClose:()=>this.setState({openPopupCaiDat:!1})})]})]})}}class z extends n.Component{render(){return(0,f.jsx)(O,{})}}},32385:(a,e,t)=>{t.d(e,{A:()=>h});var n=t(9950),i=t(23931),s=t(44414);class h extends n.Component{render(){let{children:a,className:e,FilterSearchAdvanced:t,FilterNoHeader:n,NoTabs:h}=this.props,l=[];return e&&l.push(e),l.push("filter-datatable"),t&&l.push("filter-search-advanced"),n&&l.push("filter-no-header"),h&&l.push("filter-no-tabs"),(0,s.jsx)(i.A,{className:l.join(" "),md:"9",children:a})}}h.defaultProps={className:"",FilterSearchAdvanced:"",FilterNoHeader:"",NoTabs:""}},95888:(a,e,t)=>{t.d(e,{A:()=>r});var n=t(58168),i=t(80045),s=t(9950),h=t(2803),l=t(77882),o=t(33720),d=s.forwardRef((function(a,e){var t=a.classes,o=a.className,d=a.raised,r=void 0!==d&&d,c=(0,i.A)(a,["classes","className","raised"]);return s.createElement(l.A,(0,n.A)({className:(0,h.A)(t.root,o),elevation:r?8:1,ref:e},c))}));const r=(0,o.A)({root:{overflow:"hidden"}},{name:"MuiCard"})(d)},78873:(a,e,t)=>{t.d(e,{A:()=>p});var n=t(58168),i=t(98587),s=t(9950),h=t(11942),l=t.n(h),o=t(48738),d=t.n(o),r=t(44208),c=["className","cssModule","color","innerRef","pill","tag"],g={color:l().string,pill:l().bool,tag:r.Wx,innerRef:l().oneOfType([l().object,l().func,l().string]),children:l().node,className:l().string,cssModule:l().object},u=function(a){var e=a.className,t=a.cssModule,h=a.color,l=a.innerRef,o=a.pill,g=a.tag,u=(0,i.A)(a,c),p=(0,r.qO)(d()(e,"badge","badge-"+h,!!o&&"badge-pill"),t);return u.href&&"span"===g&&(g="a"),s.createElement(g,(0,n.A)({},u,{className:p,ref:l}))};u.propTypes=g,u.defaultProps={color:"secondary",pill:!1,tag:"span"};const p=u},27220:(a,e,t)=>{t.d(e,{A:()=>p});var n=t(58168),i=t(98587),s=t(9950),h=t(11942),l=t.n(h),o=t(48738),d=t.n(o),r=t(44208),c=["className","cssModule","tag"],g={tag:r.Wx,className:l().string,cssModule:l().object},u=function(a){var e=a.className,t=a.cssModule,h=a.tag,l=(0,i.A)(a,c),o=(0,r.qO)(d()(e,"card-footer"),t);return s.createElement(h,(0,n.A)({},l,{className:o}))};u.propTypes=g,u.defaultProps={tag:"div"};const p=u},85907:(a,e,t)=>{t.d(e,{A:()=>p});var n=t(58168),i=t(98587),s=t(9950),h=t(11942),l=t.n(h),o=t(48738),d=t.n(o),r=t(44208),c=["className","cssModule","tag"],g={tag:r.Wx,className:l().string,cssModule:l().object},u=function(a){var e=a.className,t=a.cssModule,h=a.tag,l=(0,i.A)(a,c),o=(0,r.qO)(d()(e,"modal-footer"),t);return s.createElement(h,(0,n.A)({},l,{className:o}))};u.propTypes=g,u.defaultProps={tag:"div"};const p=u},97540:(a,e,t)=>{t.d(e,{A:()=>p});var n=t(58168),i=t(98587),s=t(9950),h=t(11942),l=t.n(h),o=t(48738),d=t.n(o),r=t(44208),c=["className","cssModule","type","size","color","children","tag"],g={tag:r.Wx,type:l().string,size:l().string,color:l().string,className:l().string,cssModule:l().object,children:l().string},u=function(a){var e=a.className,t=a.cssModule,h=a.type,l=a.size,o=a.color,g=a.children,u=a.tag,p=(0,i.A)(a,c),m=(0,r.qO)(d()(e,!!l&&"spinner-"+h+"-"+l,"spinner-"+h,!!o&&"text-"+o),t);return s.createElement(u,(0,n.A)({role:"status"},p,{className:m}),g&&s.createElement("span",{className:(0,r.qO)("sr-only",t)},g))};u.propTypes=g,u.defaultProps={tag:"div",type:"border",children:"Loading..."};const p=u},21205:(a,e,t)=>{t.d(e,{A:()=>p});var n=t(58168),i=t(98587),s=t(9950),h=t(11942),l=t.n(h),o=t(48738),d=t.n(o),r=t(44208),c=["className","cssModule","size","bordered","borderless","striped","dark","hover","responsive","tag","responsiveTag","innerRef"],g={className:l().string,cssModule:l().object,size:l().string,bordered:l().bool,borderless:l().bool,striped:l().bool,dark:l().bool,hover:l().bool,responsive:l().oneOfType([l().bool,l().string]),tag:r.Wx,responsiveTag:r.Wx,innerRef:l().oneOfType([l().func,l().string,l().object])},u=function(a){var e=a.className,t=a.cssModule,h=a.size,l=a.bordered,o=a.borderless,g=a.striped,u=a.dark,p=a.hover,m=a.responsive,G=a.tag,D=a.responsiveTag,N=a.innerRef,x=(0,i.A)(a,c),T=(0,r.qO)(d()(e,"table",!!h&&"table-"+h,!!l&&"table-bordered",!!o&&"table-borderless",!!g&&"table-striped",!!u&&"table-dark",!!p&&"table-hover"),t),b=s.createElement(G,(0,n.A)({},x,{ref:N,className:T}));if(m){var B=(0,r.qO)(!0===m?"table-responsive":"table-responsive-"+m,t);return s.createElement(D,{className:B},b)}return b};u.propTypes=g,u.defaultProps={tag:"table",responsiveTag:"div"};const p=u}}]);