관리-도구
편집 파일: StoreOrderShow.1a5c97a32ce998b7.js
/*! For license information please see StoreOrderShow.1a5c97a32ce998b7.js.LICENSE.txt */ "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[6593],{70854:(t,e,r)=>{r.r(e),r.d(e,{default:()=>h});var n=r(72505),o=r.n(n),i=r(95353);function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}function s(){s=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},c=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",l=i.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function d(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),s=new T(n||[]);return o(a,"_invoke",{value:L(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=d;var v="suspendedStart",p="suspendedYield",y="executing",m="completed",g={};function b(){}function _(){}function w(){}var x={};f(x,c,(function(){return this}));var C=Object.getPrototypeOf,O=C&&C(C($([])));O&&O!==r&&n.call(O,c)&&(x=O);var P=w.prototype=b.prototype=Object.create(x);function j(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function r(o,i,s,c){var u=h(t[o],t,i);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==a(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,s,c)}),(function(t){r("throw",t,s,c)})):e.resolve(f).then((function(t){l.value=t,s(l)}),(function(t){return r("throw",t,s,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function L(e,r,n){var o=v;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var c=S(s,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var u=h(e,r,n);if("normal"===u.type){if(o=n.done?m:p,u.arg===g)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=m,n.method="throw",n.arg=u.arg)}}}function S(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,S(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function $(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(a(e)+" is not iterable")}return _.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:_,configurable:!0}),_.displayName=f(w,l,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,l,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},j(E.prototype),f(E.prototype,u,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new E(d(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},j(P),f(P,l,"Generator"),f(P,c,(function(){return this})),f(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=$,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return s.type="throw",s.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),N(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:$(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function c(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){c(i,n,o,a,s,"next",t)}function s(t){c(i,n,o,a,s,"throw",t)}a(void 0)}))}}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function f(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=a(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=a(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==a(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}const d={metaInfo:{title:"Store Order"},props:{id:{type:[String,Number],required:!0}},data:function(){return{loading:!0,actionBusy:!1,order:{items:[],status:"pending"},code:""}},mounted:function(){this.fetch()},computed:function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?l(Object(r),!0).forEach((function(e){f(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},(0,i.L8)(["currentUser"])),methods:{currency:function(t){var e=this.currentUser.currency;try{return new Intl.NumberFormat(void 0,{style:"currency",currency:e}).format(t||0)}catch(r){return e+" "+Number(t||0).toFixed(2)}},badgeVariant:function(t){return{pending:"warning",confirmed:"success",cancelled:"danger"}[t]||"secondary"},fetch:function(){var t=this;return u(s().mark((function e(){var r,n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,o().get("/store/orders/".concat(t.id));case 3:r=e.sent,n=r.data,t.order=n||{items:[],status:"pending"},t.code=n&&(n.code||"#".concat(n.id));case 7:return e.prev=7,t.loading=!1,e.finish(7);case 10:case"end":return e.stop()}}),e,null,[[0,,7,10]])})))()},confirmOrder:function(){var t=this;this.order&&"pending"===this.order.status&&this.$swal({title:"Confirm this order?",text:"This will convert the online order into a Sale and deduct stock.",type:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",cancelButtonText:"Cancel",confirmButtonText:"Confirm"}).then(function(){var e=u(s().mark((function e(r){var n,i,a,c,u,l;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.value){e.next=2;break}return e.abrupt("return");case 2:return window.NProgress&&(NProgress.start(),NProgress.set(.1)),t.actionBusy=!0,e.prev=4,e.next=7,o().patch("/store/orders/".concat(t.id),{status:"confirmed"});case 7:n=e.sent,i=n.data,t.order.status="confirmed",a=i&&i.sale_ref?"Order confirmed as Sale ".concat(i.sale_ref):"Order confirmed",t.$swal("Success",a,"success"),e.next=20;break;case 14:e.prev=14,e.t0=e.catch(4),c="Operation failed. Please try again.",(u=e.t0&&e.t0.response&&e.t0.response.data)&&(Array.isArray(u.items)&&u.items.length?(l=u.items.map((function(t){return"".concat(t.name," — 'Available': ").concat(t.available,", 'Required': ").concat(t.required)})),c="Insufficient stock for:\n"+l.join("\n")):(u.error||u.message)&&(c=u.error||u.message)),t.$swal("Error",c,"warning");case 20:return e.prev=20,t.actionBusy=!1,window.NProgress&&setTimeout((function(){return NProgress.done()}),300),e.finish(20);case 24:case"end":return e.stop()}}),e,null,[[4,14,20,24]])})));return function(t){return e.apply(this,arguments)}}())},cancelOrder:function(){var t=this;this.order&&"pending"===this.order.status&&this.$swal({title:"Cancel this order?",text:"This will mark the order as cancelled.",type:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",cancelButtonText:"Keep",confirmButtonText:"Cancel"}).then(function(){var e=u(s().mark((function e(r){return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r.value){e.next=2;break}return e.abrupt("return");case 2:return window.NProgress&&(NProgress.start(),NProgress.set(.1)),t.actionBusy=!0,e.prev=4,e.next=7,o().patch("/store/orders/".concat(t.id),{status:"cancelled"});case 7:t.order.status="cancelled",t.$swal("Success","Order cancelled","success"),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(4),t.$swal("Error","Operation failed. Please try again.","warning");case 14:return e.prev=14,t.actionBusy=!1,window.NProgress&&setTimeout((function(){return NProgress.done()}),300),e.finish(14);case 18:case"end":return e.stop()}}),e,null,[[4,11,14,18]])})));return function(t){return e.apply(this,arguments)}}())},toast:function(t,e,r){this.$bvToast&&this.$bvToast.toast?this.$bvToast.toast(r,{title:e,variant:t,autoHideDelay:3e3,solid:!0}):"danger"===t?alert((e||"Error")+": "+r):console.log(e+": "+r)}}};const h=(0,r(14486).A)(d,(function(){var t=this,e=t._self._c;return e("div",{staticClass:"main-content"},[e("breadcumb",{attrs:{page:t.$t("Order"),folder:t.$t("Store")}}),t._v(" "),t.loading?e("div",{staticClass:"loading_page spinner spinner-primary mr-3"}):e("b-card",{staticClass:"wrapper"},[e("div",{staticClass:"d-flex justify-content-between align-items-center mb-3"},[e("h5",{staticClass:"mb-0"},[t._v(t._s(t.code))]),t._v(" "),e("div",{staticClass:"d-flex align-items-center"},[e("b-badge",{staticClass:"mr-2 text-uppercase",attrs:{variant:t.badgeVariant(t.order.status)}},[t._v("\n "+t._s(t.order.status)+"\n ")])],1)]),t._v(" "),e("div",{staticClass:"row"},[e("div",{staticClass:"col-md-7"},[e("b-card",{staticClass:"mb-3"},[e("h6",{staticClass:"mb-3"},[t._v(t._s(t.$t("Items")))]),t._v(" "),e("div",{staticClass:"table-responsive"},[e("table",{staticClass:"table table-sm"},[e("thead",[e("tr",[e("th",[t._v(t._s(t.$t("Product")))]),t._v(" "),e("th",[t._v(t._s(t.$t("Qty")))]),t._v(" "),e("th",[t._v(t._s(t.$t("Price")))]),t._v(" "),e("th",{staticClass:"text-right"},[t._v(t._s(t.$t("Total")))])])]),t._v(" "),e("tbody",t._l(t.order.items,(function(r){return e("tr",{key:r.id},[e("td",[t._v(t._s(r.name))]),t._v(" "),e("td",[t._v(t._s(r.qty))]),t._v(" "),e("td",[t._v(t._s(t.currency(r.price)))]),t._v(" "),e("td",{staticClass:"text-right"},[t._v(t._s(t.currency(r.price*r.qty)))])])})),0)])])])],1),t._v(" "),e("div",{staticClass:"col-md-5"},[e("b-card",{staticClass:"mb-3"},[e("h6",[t._v("Customer")]),t._v(" "),e("div",{staticClass:"text-muted"},[t._v(t._s(t.order.customer_name))]),t._v(" "),e("div",{staticClass:"text-muted"},[t._v(t._s(t.order.customer_email))]),t._v(" "),e("div",{staticClass:"text-muted"},[t._v(t._s(t.order.customer_phone))])]),t._v(" "),e("b-card",{staticClass:"mb-3"},[e("h6",[t._v("Warehouse")]),t._v(" "),e("div",{staticClass:"text-muted"},[t._v("\n "+t._s(t.order.warehouse_name||"-")+"\n ")])]),t._v(" "),e("b-card",{staticClass:"mb-3"},[e("h6",[t._v("Summary")]),t._v(" "),e("ul",{staticClass:"list-unstyled mb-0"},[e("li",{staticClass:"d-flex justify-content-between"},[e("span",[t._v("Subtotal")]),t._v(" "),e("strong",[t._v(t._s(t.currency(t.order.subtotal)))])]),t._v(" "),Number(t.order.shipping||0)>0?e("li",{staticClass:"d-flex justify-content-between"},[e("span",[t._v("Shipping")]),t._v(" "),e("strong",[t._v(t._s(t.currency(t.order.shipping||0)))])]):t._e(),t._v(" "),Number(t.order.discount||0)>0?e("li",{staticClass:"d-flex justify-content-between"},[e("span",[t._v("Discount")]),t._v(" "),e("strong",[t._v("-"+t._s(t.currency(t.order.discount||0)))])]):t._e(),t._v(" "),e("li",{staticClass:"d-flex justify-content-between border-top pt-2"},[e("span",[t._v("Total")]),t._v(" "),e("strong",[t._v(t._s(t.currency(t.order.total)))])])])])],1)])])],1)}),[],!1,null,null,null).exports}}]);