PageSourceSearch

https://smartecom.ai/static/js/3957.dc3ba21f.chunk.js

js smartecom.ai collected 2026-10-05 15:06:13 UTC 15,397 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunklight_bootstrap_dashboard_react=self.webpackChunklight_bootstrap_dashboard_react||[]).push([[3957],{83957:function(e,t,r){r.r(t);var n=r(93433),a=r(1413),d=r(4942),o=r(15671),i=r(43144),c=r(60136),s=r(29388),l=r(88391),h=r(23774),u=r(66023),p=r(71739),_=r(7734),m=r(59633),y=r(71097),f=r(13559),x=r(39437),v=r(52580),g=r(5226),j=r(58171),Z=r(1885),C=r(37920),b=r.n(C),I=r(23712),N=function(e){(0,c.Z)(r,e);var t=(0,s.Z)(r);function r(){var e;(0,o.Z)(this,r);for(var i=arguments.length,c=new Array(i),s=0;s<i;s++)c[s]=arguments[s];return(e=t.call.apply(t,[this].concat(c))).state={loading:!1,factory_order_id:"",order_date:(new Date).toISOString().split("T")[0],order_month:b()().format("YYYY-MM"),expected_delivery_date:"",factory_id:"",factory_name:"",status:"PENDING",items:[{_id:null,product_code:"",product_name:"",ordered_quantity:0,unit_price_vnd:0,base_price_vnd:0,expected_delivery_date:""}],system_note:"",staff_note:"",factory_note:"",saving:!1,isEdit:!1,orderId:null},e.loadOrderData=function(t){t&&(e.setState({factory_order_id:t.factory_order_id||"",order_date:t.order_date?b()(t.order_date).format("YYYY-MM-DD"):(new Date).toISOString().split("T")[0],order_month:t.order_month||b()().format("YYYY-MM"),expected_delivery_date:t.expected_delivery_date?b()(t.expected_delivery_date).format("YYYY-MM-DD"):"",factory_id:t.factory_id||"",factory_name:t.factory_name||"",status:t.status||"PENDING",system_note:t.system_note||"",staff_note:t.staff_note||"",factory_note:t.factory_note||"",loading:!1}),t.factory_order_id&&e.props.getFactoryProductOrderItemsByFactoryOrderId(t.factory_order_id).then((function(t){var r=Array.isArray(t)?t:t.data||t.result||[];r&&r.length>0&&e.setState({items:r.map((function(e){return{_id:e._id||null,product_code:e.product_code||"",product_name:e.product_name||"",ordered_quantity:e.ordered_quantity||0,unit_price_vnd:e.unit_price_vnd||0,base_price_vnd:e.base_price_vnd||0,expected_delivery_date:e.expected_delivery_date?b()(e.expected_delivery_date).format("YYYY-MM-DD"):"",is_deleted:e.is_deleted||!1}}))})})).catch((function(e){console.error("Error loading order items:",e)})))},e.handleFactoryChange=function(t){var r=t.target.value,n=e.getFactoryOptions().find((function(e){return e.value===r}));e.setState({factory_id:r,factory_name:n?n.label:""})},e.handleInputChange=function(t){var r=t.target,n=r.name,o=r.value;e.setState((function(e){var t=(0,d.Z)({},n,o);return"expected_delivery_date"===n&&o&&(t.items=e.items.map((function(e){return(0,a.Z)((0,a.Z)({},e),{},{expected_delivery_date:e.expected_delivery_date||o})}))),t}))},e.handleAddItem=function(){e.setState((function(e){return{items:[].concat((0,n.Z)(e.items),[{_id:null,product_code:"",product_name:"",ordered_quantity:0,unit_price_vnd:0,base_price_vnd:0,expected_delivery_date:e.expected_delivery_date||""}])}}))},e.handleRemoveItem=function(t){e.setState((function(e){return{items:e.items.map((function(e,r){return r===t?(0,a.Z)((0,a.Z)({},e),{},{is_deleted:!0}):e}))}}))},e.handleItemChange=function(t,r,n){e.setState((function(o){return{items:o.items.map((function(i,c){if(c===t){var s=(0,a.Z)((0,a.Z)({},i),{},(0,d.Z)({},r,n));if("product_code"===r){var l=(e.props.products||[]).find((function(e){return e.product_code===n}));if(l){s.product_name=l.product_name||"";var h=l.base_price_vnd||l.current_price_vnd||0;s.base_price_vnd=h,s.unit_price_vnd=h,s.expected_delivery_date||(s.expected_delivery_date=o.expected_delivery_date||"")}}return s}return i}))}}))},e.generateFactoryOrderId=function(){var e=b()(),t=e.format("MM"),r=e.format("YYYY");return"FO-".concat(r,"-").concat(t,"-001")},e.handleSubmit=function(){var t=e.state,r=t.factory_order_id,n=t.order_date,a=t.order_month,d=t.expected_delivery_date,o=t.factory_id,i=t.factory_name,c=t.status,s=t.items,l=t.system_note,h=t.staff_note,u=t.factory_note,p=t.isEdit,_=t.orderId;if(o)if(s.filter((function(e){return!e.is_deleted})).some((function(e){return!e.product_code||e.ordered_quantity<=0})))alert("Vui l\xf2ng \u0111i\u1ec1n \u0111\u1ea7y \u0111\u1ee7 m\xe3 s\u1ea3n ph\u1ea9m v\xe0 s\u1ed1 l\u01b0\u1ee3ng cho t\u1ea5t c\u1ea3 c\xe1c s\u1ea3n ph\u1ea9m");else{e.setState({saving:!0});var m={factory_order_id:r||e.generateFactoryOrderId(),order_date:n,order_month:a,expected_delivery_date:d||null,factory_id:o,factory_name:i,status:c,system_note:l,staff_note:h,factory_note:u},y=s.map((function(e){var t={factory_order_id:m.factory_order_id,product_code:e.product_code,product_name:e.product_name,ordered_quantity:e.ordered_quantity,unit_price_vnd:e.unit_price_vnd||0,base_price_vnd:e.base_price_vnd||e.unit_price_vnd||0,expected_delivery_date:e.expected_delivery_date||null,is_deleted:e.is_deleted||!1};
1return e._id&&(t._id=e._id),t}));p?e.props.updateFactoryProductOrder(_,m).then((function(){return e.props.createFactoryProductOrderItems(y)})).then((function(){alert("C\u1eadp nh\u1eadt \u0111\u01a1n \u0111\u1eb7t h\xe0ng th\xe0nh c\xf4ng"),e.props.history.push("/admin/fulfill/factory-order")})).catch((function(t){console.error("Error updating order:",t),alert("Kh\xf4ng th\u1ec3 c\u1eadp nh\u1eadt \u0111\u01a1n \u0111\u1eb7t h\xe0ng. Vui l\xf2ng th\u1eed l\u1ea1i."),e.setState({saving:!1})})):e.props.createFactoryProductOrder(m).then((function(){return e.props.createFactoryProductOrderItems(y)})).then((function(){alert("T\u1ea1o \u0111\u01a1n \u0111\u1eb7t h\xe0ng th\xe0nh c\xf4ng"),e.props.history.push("/admin/fulfill/factory-order")})).catch((function(t){console.error("Error creating order:",t),alert("Kh\xf4ng th\u1ec3 t\u1ea1o \u0111\u01a1n \u0111\u1eb7t h\xe0ng. Vui l\xf2ng th\u1eed l\u1ea1i."),e.setState({saving:!1})}))}else alert("Vui l\xf2ng ch\u1ecdn x\u01b0\u1edfng")},e.getFactoryOptions=function(){return(0,Z.br)(e.props.currentCompany,{filter:!1,publicPartners:e.props.publicPartners})},e}return(0,i.Z)(r,[{key:"componentDidMount",value:function(){var e=this;try{var t=this.props.match&&this.props.match.params?this.props.match.params.id:null;this.props.getSESProducts({currentPage:1,itemsPerPage:9999,sortBy:"product_code",sortOrder:1}),t&&"create"!==t?(this.setState({isEdit:!0,orderId:t,loading:!0}),this.props.getFactoryProductOrderById(t).then((function(t){e.loadOrderData(t)})).catch((function(t){console.error("Error loading order:",t),alert("Kh\xf4ng th\u1ec3 t\u1ea3i th\xf4ng tin \u0111\u01a1n h\xe0ng"),e.setState({loading:!1})}))):this.setState({isEdit:!1,loading:!1})}catch(r){console.error("Error in componentDidMount:",r),this.setState({loading:!1})}}},{key:"render",value:function(){var e=this;try{var t=this.state,r=t.factory_order_id,n=t.order_date,d=t.order_month,o=t.expected_delivery_date,i=t.factory_id,c=t.status,s=t.items,l=t.system_note,h=t.staff_note,j=t.factory_note,Z=t.saving,C=t.loading,b=t.isEdit,N=this.props.products,O=N?N.map((function(e){return{value:e.product_code,label:"".concat(e.product_code," - ").concat(e.product_name)}})):[],P=this.getFactoryOptions();return C?(0,I.jsx)(u.Z,{fluid:!0,children:(0,I.jsxs)("div",{className:"text-center mt-5",children:[(0,I.jsx)(p.Z,{animation:"border",variant:"primary"}),(0,I.jsx)("p",{className:"mt-2",children:"\u0110ang t\u1ea3i..."})]})}):(0,I.jsxs)(u.Z,{fluid:!0,children:[(0,I.jsx)("h2",{className:"text-center mb-4",children:b?"Ch\u1ec9nh s\u1eeda \u0111\u01a1n \u0111\u1eb7t h\xe0ng":"T\u1ea1o \u0111\u01a1n \u0111\u1eb7t h\xe0ng m\u1edbi"}),(0,I.jsxs)(_.Z,{className:"mb-4",children:[(0,I.jsx)(m.Z,{md:4,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"M\xe3 \u0111\u01a1n \u0111\u1eb7t h\xe0ng"}),(0,I.jsx)(y.Z.Control,{type:"text",name:"factory_order_id",value:r,onChange:this.handleInputChange,placeholder:"T\u1ef1 \u0111\u1ed9ng t\u1ea1o n\u1ebfu \u0111\u1ec3 tr\u1ed1ng",disabled:b})]})}),(0,I.jsx)(m.Z,{md:4,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"Ng\xe0y \u0111\u1eb7t h\xe0ng"}),(0,I.jsx)(y.Z.Control,{type:"date",name:"order_date",value:n,onChange:this.handleInputChange})]})}),(0,I.jsx)(m.Z,{md:4,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"Th\xe1ng \u0111\u1eb7t h\xe0ng"}),(0,I.jsx)(y.Z.Control,{type:"month",name:"order_month",value:d,onChange:this.handleInputChange})]})})]}),(0,I.jsxs)(_.Z,{className:"mb-4",children:[(0,I.jsx)(m.Z,{md:4,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"X\u01b0\u1edfng"}),(0,I.jsxs)(y.Z.Select,{value:i,onChange:this.handleFactoryChange,children:[(0,I.jsx)("option",{value:"",children:"Ch\u1ecdn x\u01b0\u1edfng..."}),P.map((function(e){return(0,I.jsx)("option",{value:e.value,children:e.label},e.value)}))]})]})}),(0,I.jsx)(m.Z,{md:4,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"Ng\xe0y d\u1ef1 ki\u1ebfn nh\u1eadn h\xe0ng"}),(0,I.jsx)(y.Z.Control,{type:"date",name:"expected_delivery_date",value:o,onChange:this.handleInputChange})]})}),(0,I.jsx)(m.Z,{md:4,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"Tr\u1ea1ng th\xe1i"}),(0,I.jsxs)(y.Z.Select,{name:"status",value:c,onChange:this.handleInputChange,children:[(0,I.jsx)("option",{value:"PENDING",children:"Ch\u1edd x\u1eed l\xfd"}),(0,I.jsx)("option",{value:"CONFIRMED",children:"\u0110\xe3 x\xe1c nh\u1eadn"}),(0,I.jsx)("option",{value:"PROCESSING",children:"\u0110ang s\u1ea3n xu\u1ea5t"}),(0,I.jsx)("option",{value:"PARTIAL",children:"\u0110\xe3 nh\u1eadn m\u1ed9t ph\u1ea7n"}),(0,I.jsx)("option",{value:"COMPLETED",children:"\u0110\xe3 ho\xe0n th\xe0nh"}),(0,I.jsx)("option",{value:"CANCELLED",children:"\u0110\xe3 h\u1ee7y"}),(0,I.jsx)("option",{value:"DELAYED",children:"B\u1ecb tr\u1ec5"})]})]})})]}),(0,I.jsx)("h4",{className:"mb-3",children:"Danh s\xe1ch s\u1ea3n ph\u1ea9m"}),(0,I.jsxs)(f.Z,{striped:!0,bordered:!0,hover:!0,style:{tableLayout:"fixed",width:"100%"},children:[(0,I.jsx)("thead",{children:(0,I.jsxs)("tr",{children:[(0,I.jsx)("th",{style:{width:"35%"},children:"M\xe3 s\u1ea3n ph\u1ea9m"}),(0,I.jsx)("th",{style:{width:"12%"},children:"S\u1ed1 l\u01b0\u1ee3ng \u0111\u1eb7t"}),(0,I.jsx)("th",{style:{width:"15%"},children:"\u0110\u01a1n gi\xe1 (VND)"}),(0,I.jsx)("th",{style:{width:"15%"},children:"Gi\xe1 c\u01a1 b\u1ea3n (VND)"}),(0,I.jsx)("th",{style:{width:"15%"},children:"Ng\xe0y d\u1ef1 ki\u1ebfn nh\u1eadn"}),(0,I.jsx)("th",{style:{width:"8%"},children:"Thao t\xe1c"})]})}),(0,I.jsx)("tbody",{children:s.map((function(t,r){return t.is_deleted?null:(0,I.jsxs)("tr",{children:[(0,I.jsx)("td",{style:{width:"35%"},children:(0,I.jsx)(g.ZP,{value:O.find((function(e){return e.value===t.product_code}
1)),onChange:function(t){return e.handleItemChange(r,"product_code",t?t.value:"")},options:O,isClearable:!0,placeholder:"Ch\u1ecdn s\u1ea3n ph\u1ea9m...",noOptionsMessage:function(){return"Kh\xf4ng t\xecm th\u1ea5y s\u1ea3n ph\u1ea9m"},styles:{control:function(e){return(0,a.Z)((0,a.Z)({},e),{},{minWidth:"100%",width:"100%"})},container:function(e){return(0,a.Z)((0,a.Z)({},e),{},{width:"100%"})}}})}),(0,I.jsx)("td",{children:(0,I.jsx)(y.Z.Control,{type:"text",inputMode:"numeric",value:t.ordered_quantity,onChange:function(t){return e.handleItemChange(r,"ordered_quantity",t.target.value)}})}),(0,I.jsx)("td",{children:(0,I.jsx)(y.Z.Control,{type:"text",inputMode:"decimal",value:t.unit_price_vnd,onChange:function(t){return e.handleItemChange(r,"unit_price_vnd",t.target.value)}})}),(0,I.jsx)("td",{children:(0,I.jsx)(y.Z.Control,{type:"text",inputMode:"decimal",value:t.base_price_vnd,onChange:function(t){return e.handleItemChange(r,"base_price_vnd",t.target.value)}})}),(0,I.jsx)("td",{children:(0,I.jsx)(y.Z.Control,{type:"date",value:t.expected_delivery_date,onChange:function(t){return e.handleItemChange(r,"expected_delivery_date",t.target.value)}})}),(0,I.jsx)("td",{style:{textAlign:"center",verticalAlign:"middle"},children:(0,I.jsxs)(x.Z,{variant:"danger",size:"sm",onClick:function(){return e.handleRemoveItem(r)},disabled:1===s.filter((function(e){return!e.is_deleted})).length,style:{minWidth:"70px",fontWeight:"bold",padding:"6px 12px",fontSize:"14px"},children:[(0,I.jsx)(v.Xm5,{})," X\xf3a"]})})]},r)}))})]}),(0,I.jsx)(_.Z,{className:"mb-4",children:(0,I.jsx)(m.Z,{children:(0,I.jsxs)(x.Z,{variant:"primary",onClick:this.handleAddItem,children:[(0,I.jsx)(v.wEH,{})," Th\xeam s\u1ea3n ph\u1ea9m"]})})}),(0,I.jsx)(_.Z,{className:"mb-4",children:(0,I.jsx)(m.Z,{md:12,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"Ghi ch\xfa h\u1ec7 th\u1ed1ng"}),(0,I.jsx)(y.Z.Control,{as:"textarea",rows:3,name:"system_note",value:l,onChange:this.handleInputChange,placeholder:"Ghi ch\xfa h\u1ec7 th\u1ed1ng..."})]})})}),(0,I.jsx)(_.Z,{className:"mb-4",children:(0,I.jsx)(m.Z,{md:12,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"Ghi ch\xfa nh\xe2n vi\xean"}),(0,I.jsx)(y.Z.Control,{as:"textarea",rows:3,name:"staff_note",value:h,onChange:this.handleInputChange,placeholder:"Ghi ch\xfa c\u1ee7a nh\xe2n vi\xean..."})]})})}),(0,I.jsx)(_.Z,{className:"mb-4",children:(0,I.jsx)(m.Z,{md:12,children:(0,I.jsxs)(y.Z.Group,{children:[(0,I.jsx)(y.Z.Label,{children:"Ghi ch\xfa t\u1eeb x\u01b0\u1edfng"}),(0,I.jsx)(y.Z.Control,{as:"textarea",rows:3,name:"factory_note",value:j,onChange:this.handleInputChange,placeholder:"Ghi ch\xfa t\u1eeb x\u01b0\u1edfng..."})]})})}),(0,I.jsx)(_.Z,{children:(0,I.jsxs)(m.Z,{className:"text-end",children:[(0,I.jsx)(x.Z,{variant:"secondary",onClick:function(){return e.props.history.push("/admin/fulfill/factory-order")},className:"me-2",children:"H\u1ee7y"}),(0,I.jsx)(x.Z,{variant:"success",onClick:this.handleSubmit,disabled:Z,children:Z?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(p.Z,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),"\u0110ang l\u01b0u..."]}):b?"C\u1eadp nh\u1eadt":"T\u1ea1o \u0111\u01a1n"})]})})]})}catch(S){return console.error("Error in render:",S),(0,I.jsx)(u.Z,{fluid:!0,children:(0,I.jsxs)("div",{className:"alert alert-danger",children:[(0,I.jsx)("h4",{children:"L\u1ed7i khi t\u1ea3i trang"}),(0,I.jsx)("p",{children:S.message}),(0,I.jsx)(x.Z,{onClick:function(){return window.location.reload()},children:"T\u1ea3i l\u1ea1i trang"})]})})}}}]),r}(l.Component);t.default=(0,h.$j)((function(e){return{products:e.sesProductReducer.products,currentOrder:e.factoryProductOrderReducer.currentOrder,currentCompany:e.companyReducer.currentCompany,publicPartners:e.companyReducer.publicPartners}}),{getSESProducts:j.GZ,createFactoryProductOrder:j.kw,updateFactoryProductOrder:j.dW,getFactoryProductOrderById:j.Hp,getFactoryProductOrderItemsByFactoryOrderId:j.yF,createFactoryProductOrderItems:j.M2})(N)},13559:function(e,t,r){var n=r(1413),a=r(45987),d=r(55831),o=r.n(d),i=r(88391),c=r(81279),s=r(23712),l=["bsPrefix","className","striped","bordered","borderless","hover","size","variant","responsive"],h=i.forwardRef((function(e,t){var r=e.bsPrefix,d=e.className,i=e.striped,h=e.bordered,u=e.borderless,p=e.hover,_=e.size,m=e.variant,y=e.responsive,f=(0,a.Z)(e,l),x=(0,c.vE)(r,"table"),v=o()(d,x,m&&"".concat(x,"-").concat(m),_&&"".concat(x,"-").concat(_),i&&"".concat(x,"-").concat("string"===typeof i?"striped-".concat(i):"striped"),h&&"".concat(x,"-bordered"),u&&"".concat(x,"-borderless"),p&&"".concat(x,"-hover")),g=(0,s.jsx)("table",(0,n.Z)((0,n.Z)({},f),{},{className:v,ref:t}));if(y){var j="".concat(x,"-responsive");return"string"===typeof y&&(j="".concat(j,"-").concat(y)),(0,s.jsx)("div",{className:j,children:g})}return g}));t.Z=h}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.