(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-7f8a9218"],{"02f4":function(e,t,n){var r=n("4588"),a=n("be13");e.exports=function(e){return function(t,n){var i,c,s=String(a(t)),o=r(n),u=s.length;return o<0||o>=u?e?"":void 0:(i=s.charCodeAt(o),i<55296||i>56319||o+1===u||(c=s.charCodeAt(o+1))<56320||c>57343?e?s.charAt(o):i:e?s.slice(o,o+2):c-56320+(i-55296<<10)+65536)}}},"0390":function(e,t,n){"use strict";var r=n("02f4")(!0);e.exports=function(e,t,n){return t+(n?r(e,t).length:1)}},"0bfb":function(e,t,n){"use strict";var r=n("cb7c");e.exports=function(){var e=r(this),t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.unicode&&(t+="u"),e.sticky&&(t+="y"),t}},"214f":function(e,t,n){"use strict";n("b0c5");var r=n("2aba"),a=n("32e9"),i=n("79e5"),c=n("be13"),s=n("2b4c"),o=n("520a"),u=s("species"),l=!i(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")}),d=function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var n="ab".split(e);return 2===n.length&&"a"===n[0]&&"b"===n[1]}();e.exports=function(e,t,n){var h=s(e),p=!i(function(){var t={};return t[h]=function(){return 7},7!=""[e](t)}),f=p?!i(function(){var t=!1,n=/a/;return n.exec=function(){return t=!0,null},"split"===e&&(n.constructor={},n.constructor[u]=function(){return n}),n[h](""),!t}):void 0;if(!p||!f||"replace"===e&&!l||"split"===e&&!d){var g=/./[h],v=n(c,h,""[e],function(e,t,n,r,a){return t.exec===o?p&&!a?{done:!0,value:g.call(t,n,r)}:{done:!0,value:e.call(n,t,r)}:{done:!1}}),m=v[0],b=v[1];r(String.prototype,e,m),a(RegExp.prototype,h,2==t?function(e,t){return b.call(e,this,t)}:function(e){return b.call(e,this)})}}},"28a5":function(e,t,n){"use strict";var r=n("aae3"),a=n("cb7c"),i=n("ebd6"),c=n("0390"),s=n("9def"),o=n("5f1b"),u=n("520a"),l=n("79e5"),d=Math.min,h=[].push,p="split",f="length",g="lastIndex",v=4294967295,m=!l(function(){RegExp(v,"y")});n("214f")("split",2,function(e,t,n,l){var b;return b="c"=="abbc"[p](/(b)*/)[1]||4!="test"[p](/(?:)/,-1)[f]||2!="ab"[p](/(?:ab)*/)[f]||4!="."[p](/(.?)(.?)/)[f]||"."[p](/()()/)[f]>1||""[p](/.?/)[f]?function(e,t){var a=String(this);if(void 0===e&&0===t)return[];if(!r(e))return n.call(a,e,t);var i,c,s,o=[],l=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),d=0,p=void 0===t?v:t>>>0,m=new RegExp(e.source,l+"g");while(i=u.call(m,a)){if(c=m[g],c>d&&(o.push(a.slice(d,i.index)),i[f]>1&&i.index=p))break;m[g]===i.index&&m[g]++}return d===a[f]?!s&&m.test("")||o.push(""):o.push(a.slice(d)),o[f]>p?o.slice(0,p):o}:"0"[p](void 0,0)[f]?function(e,t){return void 0===e&&0===t?[]:n.call(this,e,t)}:n,[function(n,r){var a=e(this),i=void 0==n?void 0:n[t];return void 0!==i?i.call(n,a,r):b.call(String(a),n,r)},function(e,t){var r=l(b,e,this,t,b!==n);if(r.done)return r.value;var u=a(e),h=String(this),p=i(u,RegExp),f=u.unicode,g=(u.ignoreCase?"i":"")+(u.multiline?"m":"")+(u.unicode?"u":"")+(m?"y":"g"),y=new p(m?u:"^(?:"+u.source+")",g),x=void 0===t?v:t>>>0;if(0===x)return[];if(0===h.length)return null===o(y,h)?[h]:[];var w=0,k=0,S=[];while(k1&&i.call(c[0],n,function(){for(l=1;l]*>)/g,p=/\$([$&`']|\d\d?)/g,f=function(e){return void 0===e?e:String(e)};n("214f")("replace",2,function(e,t,n,g){return[function(r,a){var i=e(this),c=void 0==r?void 0:r[t];return void 0!==c?c.call(r,i,a):n.call(String(i),r,a)},function(e,t){var a=g(n,e,this,t);if(a.done)return a.value;var d=r(e),h=String(this),p="function"===typeof t;p||(t=String(t));var m=d.global;if(m){var b=d.unicode;d.lastIndex=0}var y=[];while(1){var x=o(d,h);if(null===x)break;if(y.push(x),!m)break;var w=String(x[0]);""===w&&(d.lastIndex=s(h,i(d.lastIndex),b))}for(var k="",S=0,C=0;C=S&&(k+=h.slice(S,R)+T,S=R+I.length)}return k+h.slice(S)}];function v(e,t,r,i,c,s){var o=r+e.length,u=i.length,l=p;return void 0!==c&&(c=a(c),l=h),n.call(s,l,function(n,a){var s;switch(a.charAt(0)){case"$":return"$";case"&":return e;case"`":return t.slice(0,r);case"'":return t.slice(o);case"<":s=c[a.slice(1,-1)];break;default:var l=+a;if(0===l)return n;if(l>u){var h=d(l/10);return 0===h?n:h<=u?void 0===i[h-1]?a.charAt(1):i[h-1]+a.charAt(1):n}s=i[l-1]}return void 0===s?"":s})}})},adc8:function(e,t,n){"use strict";var r=n("de30"),a=n.n(r);a.a},b0c5:function(e,t,n){"use strict";var r=n("520a");n("5ca1")({target:"RegExp",proto:!0,forced:r!==/./.exec},{exec:r})},c2f6:function(e,t,n){"use strict";n.r(t);var r=function(){var e=this,t=this,n=t.$createElement,r=t._self._c||n;return r("a-layout-content",{staticClass:"ProductGroupList"},[r("a-breadcrumb",{staticStyle:{margin:"16px 24px"}},[r("a-breadcrumb-item",[r("router-link",{staticClass:"nav-link",attrs:{to:{path:"/"}}},[t._v("\n Trang chủ\n ")])],1),r("a-breadcrumb-item",[r("router-link",{staticClass:"nav-link",attrs:{to:{path:"/groups"}}},[t._v("\n Danh sách\n ")])],1),r("a-breadcrumb-item",[r("router-link",{staticClass:"nav-link",attrs:{to:{path:"/groups"}}},[t._v("\n "+t._s(t.group?t.group.name:"")+"\n ")])],1),r("a-breadcrumb-item",[t._v(t._s(this.$route.name))])],1),r("div",{style:{minHeight:"calc(100vh - 120px)",backgroundColor:"#fff",margin:"15px",padding:"15px"}},[r("a-layout-content",{style:{padding:"0 24px"}},[t.group?r("h2",[r("a-avatar",{attrs:{shape:"square",size:"small",src:t.group.groupIcon.url}}),t._v("\n "+t._s(t.group?t.group.name:"")+" ("+t._s(t.products.length)+" sản phẩm)\n ")],1):t._e(),r("a-divider"),r("div",{staticClass:"content-header"},[r("div",{staticClass:"content-header__right"},[r("div",{staticClass:"bulk-action"},[r("span",[t._v("Hành động:")]),r("a-popconfirm",{attrs:{visible:t.popupVisible,title:"Bạn có chắc chắn muốn thực hiện?"},on:{visibleChange:t.handleVisibleChange,confirm:t.handleBulkActionConfirm}},[r("a-button",{staticStyle:{"margin-left":"15px"},attrs:{disabled:!t.hasSelected,type:"primary"}},[t._v("Xóa "+t._s(t.selectedRowKeys.length)+" sản phẩm")])],1)],1)]),r("div",{staticClass:"content-header__left"},[r("a-button",{attrs:{type:"primary",icon:"plus-circle"},on:{click:t.showModalSelectProduct}},[t._v("Thêm sản phẩm")]),r("a-input-search",{staticStyle:{width:"200px","margin-left":"30px"},attrs:{placeholder:"Tìm kiếm..."},on:{change:function(t){return e.search=t.target.value}}})],1)]),r("a-divider"),r("a-table",{attrs:{rowSelection:{selectedRowKeys:t.selectedRowKeys,onChange:t.onSelectChange},columns:t.columns,rowKey:function(e){return e.id},dataSource:t.productFilter,pagination:!0,loading:t.loading,bordered:""},scopedSlots:t._u([{key:"name",fn:function(e){return[t._v("\n "+t._s(e.first)+" "+t._s(e.last)+"\n ")]}},{key:"price",fn:function(e,n){return[t._v("\n "+t._s(t.numberWithCommas(n.price))+"đ\n ")]}},{key:"category",fn:function(e){return[t._v("\n "+t._s(e?e.name:"")+"\n ")]}},{key:"featuredImage",fn:function(e){return[r("a-avatar",{attrs:{shape:"square",size:"large",src:e.url}})]}},{key:"action",fn:function(e,n){return[r("div",[r("a-button",{staticStyle:{margin:"5px"},attrs:{icon:"edit",type:"default"},on:{click:function(){return t.handleEdit(n)}}})],1)]}}])})],1)],1),r("select-store-products",{attrs:{visible:t.visible,groupId:t.groupId,ids:t.productIds,buttonLoading:t.buttonLoading},on:{cancel:t.handleCancel,create:t.handleAddProduct}})],1)},a=[],i=(n("55dd"),n("96cf"),n("3b8d")),c=(n("6b54"),n("a481"),n("386d"),n("6762"),n("2fdb"),n("7f7f"),n("4012")),s=n("9928"),o=function(){var e=this,t=this,n=t.$createElement,r=t._self._c||n;return r("a-modal",{attrs:{visible:t.visible,width:760,title:t.addText,okButtonProps:{props:{disabled:t.buttonLoading,loading:t.buttonLoading}},cancelText:"Hủy"},on:{cancel:function(){t.$emit("cancel")},ok:t.handleSubmit}},[r("a-layout",{staticClass:"container"},[r("div",{staticClass:"header"},[r("div",{staticClass:"header-right"},[r("span",[t._v("Danh mục:")]),r("a-select",{staticStyle:{width:"180px","margin-left":"15px"},attrs:{defaultValue:"all",disabled:t.buttonLoading},on:{change:t.handleCateChange}},[r("a-select-option",{attrs:{value:"all"}},[t._v("Tất cả")]),t._l(t.categories,function(e){return r("a-select-option",{key:e.id,attrs:{value:e.id}},[r("a-avatar",{attrs:{shape:"square",size:"small",src:e.featuredImage.url}}),r("span",{staticStyle:{"margin-left":"5px"}},[t._v(t._s(e.name))])],1)})],2)],1),r("div",{staticClass:"header-left"},[r("a-select",{staticStyle:{width:"70px"},attrs:{defaultValue:t.searchType,disabled:t.buttonLoading},on:{change:t.handleSearchTypeChange}},[r("a-select-option",{attrs:{value:"key"}},[t._v("Tên")]),r("a-select-option",{attrs:{value:"id"}},[t._v("ID")])],1),r("a-input-search",{staticStyle:{width:"300px","margin-left":"3px"},attrs:{placeholder:t.searchPlaceHolder,disabled:t.buttonLoading},on:{change:function(t){e.selectedRowKeys=[],e.search=t.target.value}}})],1)]),r("a-divider"),r("a-table",{attrs:{rowSelection:{selectedRowKeys:t.selectedRowKeys,onChange:t.onSelectChange,getCheckboxProps:t.getCheckboxProps},columns:t.columns,rowKey:function(e){return e.id},dataSource:t.productFilter,pagination:!0,loading:t.loading,bordered:"",size:"small"},scopedSlots:t._u([{key:"name",fn:function(e){return[t._v("\n "+t._s(e.first)+" "+t._s(e.last)+"\n ")]}},{key:"price",fn:function(e,n){return[t._v("\n "+t._s(t.numberWithCommas(n.price))+"đ\n ")]}},{key:"category",fn:function(e){return[t._v("\n "+t._s(e?e.name:"")+"\n ")]}},{key:"featuredImage",fn:function(e){return[r("a-avatar",{attrs:{shape:"square",size:"large",src:e.url}})]}},{key:"active",fn:function(e,n){return[r("div",{staticStyle:{"text-align":"center",display:"flex","flex-direction":"row","justify-content":"center"}},[r("a-popconfirm",{attrs:{title:"Bạn có chắc chắn muốn thay đổi?"},on:{confirm:function(){return t.handleActiveChange(n)}}},[r("a-checkbox",{attrs:{checked:e}})],1)],1)]}},{key:"action",fn:function(e,n){return[r("div",[r("a-button",{staticStyle:{margin:"5px"},attrs:{icon:"edit",type:"default"},on:{click:function(){return t.handleEdit(n)}}})],1)]}}])})],1)],1)},u=[],l=(n("28a5"),c["a"].get("category")),d=c["a"].get("product"),h={name:"SelectStoreProducts",props:["visible","groupId","ids","buttonLoading"],data:function(){return{selectedRowKeys:[],products:[],productCaches:[],search:"",searchType:"id",loading:!1,categories:[],columns:[{title:"ID",dataIndex:"id",key:"id",width:"3%"},{title:"Hình ảnh",dataIndex:"featuredImage",key:"featuredImage",width:"10%",scopedSlots:{customRender:"featuredImage"}},{title:"Tên sản phẩm",dataIndex:"name",key:"name",width:"50%"},{title:"Giá sản phẩm",dataIndex:"price",key:"price",width:"15%",scopedSlots:{customRender:"price"}},{title:"Danh mục",dataIndex:"category",key:"category",width:"20%",scopedSlots:{customRender:"category"}}]}},methods:{numberWithCommas:function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")},onSelectChange:function(e){this.selectedRowKeys=e},getCheckboxProps:function(e){var t={disabled:this.ids.includes(e.id)};return{props:t}},getProducts:function(){var e=Object(i["a"])(regeneratorRuntime.mark(function e(){var t;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,d.getAll();case 2:if(t=e.sent,t.data.meta.success){e.next=5;break}throw new Error("Product data"+t.data.meta.externalMessage);case 5:this.products=t.data.data,this.productCaches=JSON.parse(JSON.stringify(this.products));case 7:case"end":return e.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}(),handleCateChange:function(e){this.selectedRowKeys=[],this.products="all"===e?this.productCaches:this.productCaches.filter(function(t){return t.category.id===e})},handleSearchTypeChange:function(e){this.search="",this.searchType=e},handleSubmit:function(){this.$emit("create",this.selectedRowKeys)}},computed:{productFilter:function(){var e=this;if("key"===this.searchType)return this.products.map(function(e){return Object.assign({},e)}).filter(function(t){return t.name&&Object(s["a"])(t.name).toUpperCase().includes(Object(s["a"])(e.search).toUpperCase())});if(0===this.search.length)return this.products;var t=this.search.split(",");return this.products.filter(function(e){return t.includes(e.id.toString())})},addText:function(){return this.selectedRowKeys.length>0?"Chọn "+this.selectedRowKeys.length+" sản phẩm":"Chọn sản phẩm"},searchPlaceHolder:function(){return"id"===this.searchType?"Danh sách id cách nhau bởi dấu phẩy...":"Nhập tên sản phẩm để tìm kiếm..."}},watch:{visible:function(e){e||(this.selectedRowKeys=[])}},created:function(){var e=Object(i["a"])(regeneratorRuntime.mark(function e(){var t,n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,this.loading=!0,e.next=4,l.getAll();case 4:if(t=e.sent,n=t.data,n.meta.success){e.next=8;break}throw new Error(n.meta.externalMessage);case 8:return this.categories=n.data,e.next=11,this.getProducts();case 11:e.next=17;break;case 13:return e.prev=13,e.t0=e["catch"](0),e.next=17,this.$message.error(e.t0.message);case 17:return e.prev=17,this.loading=!1,e.finish(17);case 20:case"end":return e.stop()}},e,this,[[0,13,17,20]])}));function t(){return e.apply(this,arguments)}return t}()},p=h,f=(n("adc8"),n("2877")),g=Object(f["a"])(p,o,u,!1,null,"d9aba67a",null),v=g.exports,m=c["a"].get("group"),b={name:"ProductGroupList",components:{SelectStoreProducts:v},data:function(){return{products:[],productIds:[],group:null,buttonLoading:!1,selectedRowKeys:[],groupId:this.$route.params.groupId,loading:!1,visible:!1,popupVisible:!1,search:"",columns:[{title:"ID",dataIndex:"id",key:"id",width:"5%"},{title:"Hình ảnh",dataIndex:"featuredImage",key:"featuredImage",width:"10%",scopedSlots:{customRender:"featuredImage"}},{title:"Tên sản phẩm",dataIndex:"name",key:"name",width:"40%"},{title:"Giá sản phẩm",dataIndex:"price",key:"price",width:"10%",scopedSlots:{customRender:"price"}},{title:"Danh mục",dataIndex:"category",key:"category",width:"15%",scopedSlots:{customRender:"category"}},{title:"Thứ tự hiển thị",dataIndex:"priority",key:"priority",width:"10%",scopedSlots:{customRender:"priority"}},{title:"Action",width:"20%",scopedSlots:{customRender:"action"}}]}},computed:{productFilter:function(){var e=this;return this.products.map(function(e){return Object.assign({},e)}).filter(function(t){return t.name&&Object(s["a"])(t.name).toUpperCase().includes(Object(s["a"])(e.search).toUpperCase())})},hasSelected:function(){return this.selectedRowKeys.length>0}},methods:{numberWithCommas:function(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")},onSelectChange:function(e){this.selectedRowKeys=e},handleCancel:function(){this.visible=!1},handleAddProduct:function(){var e=Object(i["a"])(regeneratorRuntime.mark(function e(t){var n,r,a,i=this;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:if(e.prev=0,0!==t.length){e.next=3;break}return e.abrupt("return");case 3:return this.loading=!0,this.buttonLoading=!0,n=t.map(function(e,t){return{id:{productId:e,groupId:i.groupId},priority:i.products.length+t+1}}),e.next=8,m.addProductsToGroup({groupId:this.groupId,productGroups:n});case 8:if(r=e.sent,a=r.data,a.meta.success){e.next=12;break}throw new Error;case 12:return this.openNotification("Thêm thành công "+t.length+" sản phẩm!","success"),e.next=15,this.fetchProduct();case 15:this.selectedRowKeys=[],e.next=22;break;case 18:e.prev=18,e.t0=e["catch"](0),console.log(e.t0),this.openNotification("Có lỗi xảy ra! Vui lòng liên hệ team phát triển!","error");case 22:return e.prev=22,this.visible=!1,this.loading=!1,this.buttonLoading=!1,e.finish(22);case 27:case"end":return e.stop()}},e,this,[[0,18,22,27]])}));function t(t){return e.apply(this,arguments)}return t}(),handleBulkActionConfirm:function(){var e=Object(i["a"])(regeneratorRuntime.mark(function e(){var t,n,r=this;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,this.loading=!0,e.next=4,m.deleteProducts({groupId:this.groupId,productIds:this.selectedRowKeys});case 4:if(t=e.sent,n=t.data,n.meta.success){e.next=8;break}throw new Error;case 8:this.openNotification("Xóa thành công "+this.selectedRowKeys.length+" sản phẩm!","success"),this.products=this.products.filter(function(e){return!r.selectedRowKeys.includes(e.id)}),this.productIds=this.products.map(function(e){return e.id}),this.selectedRowKeys=[],e.next=18;break;case 14:e.prev=14,e.t0=e["catch"](0),console.log(e.t0),this.openNotification("Có lỗi xảy ra! Vui lòng liên hệ team phát triển!","error");case 18:return e.prev=18,this.loading=!1,e.finish(18);case 21:case"end":return e.stop()}},e,this,[[0,14,18,21]])}));function t(){return e.apply(this,arguments)}return t}(),showModalSelectProduct:function(){this.visible=!0},fetchProduct:function(){var e=Object(i["a"])(regeneratorRuntime.mark(function e(){var t,n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,this.loading=!0,e.next=4,m.getProductsByGroupId(this.groupId);case 4:if(t=e.sent,n=t.data,n.meta.success){e.next=8;break}throw new Error;case 8:this.products=n.data.sort(function(e,t){return e.priority-t.priority}),this.productIds=this.products.map(function(e){return e.id}),e.next=16;break;case 12:e.prev=12,e.t0=e["catch"](0),console.log(e.t0),this.openNotification("Có lỗi xảy ra! Không lấy được dữ liệu!","error");case 16:return e.prev=16,this.loading=!1,e.finish(16);case 19:case"end":return e.stop()}},e,this,[[0,12,16,19]])}));function t(){return e.apply(this,arguments)}return t}(),fetchGroupInfo:function(){var e=Object(i["a"])(regeneratorRuntime.mark(function e(){var t,n;return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.prev=0,this.loading=!0,e.next=4,m.getGroupById(this.groupId);case 4:if(t=e.sent,n=t.data,n.meta.success){e.next=8;break}throw new Error;case 8:this.group=n.data,e.next=15;break;case 11:e.prev=11,e.t0=e["catch"](0),console.log(e.t0),this.openNotification("Có lỗi xảy ra! Không lấy được dữ liệu!","error");case 15:return e.prev=15,this.loading=!1,e.finish(15);case 18:case"end":return e.stop()}},e,this,[[0,11,15,18]])}));function t(){return e.apply(this,arguments)}return t}(),handleVisibleChange:function(e){e&&this.hasSelected?this.popupVisible=!0:this.popupVisible=!1},openNotification:function(e,t){this.$notification[t]({message:"Hệ thống",description:e})}},created:function(){var e=Object(i["a"])(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,this.fetchGroupInfo();case 2:return e.next=4,this.fetchProduct();case 4:case"end":return e.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}()},y=b,x=(n("7ee3"),Object(f["a"])(y,r,a,!1,null,"388f3390",null));t["default"]=x.exports},de30:function(e,t,n){},e16b:function(e,t,n){}}]); //# sourceMappingURL=chunk-7f8a9218.677b0709.js.map