text: (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-66df641c"],{"0397":function(e,t,n){"use strict";n.r(t);var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",["list"===e.redirectType?n("div",{staticClass:"container"},[n("div",{staticClass:"header"},[n("div",{staticClass:"title"},[n("span",[e._v("SKU列表")]),n("el-button",{staticClass:"add-banner-item",attrs:{type:"primary",plain:""},on:{click:e.handleAdd}},[e._v("添加SKU")])],1)]),n("lin-table",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],attrs:{tableColumn:e.tableColumn,tableData:e.tableData,operate:e.operate,pagination:e.pagination,curPage:e.currentPage},on:{currentChange:e.currentChange,handleEdit:e.handleEdit,handleDelete:e.handleDelete,"row-click":e.rowClick}})],1):"add"===e.redirectType?n("sku-add",{on:{close:e.closePage}}):"edit"===e.redirectType?n("sku-edit",{attrs:{editID:e.editID},on:{close:e.closePage}}):e._e()],1)},i=[],r=n("a34a"),s=n.n(r),o=n("5725"),c=n("4b94"),l=n("605a");function u(e,t,n,a,i,r,s){try{var o=e[r](s),c=o.value}catch(l){return void n(l)}o.done?t(c):Promise.resolve(c).then(a,i)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(a,i){var r=e.apply(t,n);function s(e){u(r,a,i,s,o,"next",e)}function o(e){u(r,a,i,s,o,"throw",e)}s(void 0)})}}var d={name:"SkuList",components:{SkuAdd:c["default"],SkuEdit:l["default"]},data:function(){return{loading:!1,tableColumn:[{prop:"id",label:"id",width:100},{prop:"img",label:"图片",type:"image",width:150},{prop:"title",label:"标题",width:350},{prop:"spu_id",label:"spu_id",width:100},{prop:"discount_price",label:"折扣",width:100},{prop:"price",label:"价格（元）",width:150},{prop:"online",label:"是否上架",width:150},{prop:"code",label:"编码",width:200},{prop:"stock",label:"库存(个)",width:150}],tableData:[],operate:[],pagination:{pageTotal:0},showEdit:!1,editID:1,redirectType:"list",currentPage:1}},created:function(){this.operate=[{name:"编辑",func:"handleEdit",type:"primary"},{name:"删除",func:"handleDelete",type:"danger",auth:"删除sku"}],this.getSkus()},methods:{getSkus:function(){var e=p(s.a.mark(function e(){var t,n,a=arguments;return s.a.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:0,this.loading=!0,e.next=4,o["default"].getSkus(t);case 4:if(n=e.sent,this.loading=!1,!(n.total_nums<=0)){e.next=9;break}return this.tableData=[],e.abrupt("return");case 9:this.pagination.pageTotal||(this.pagination={pageTotal:n.total_nums}),n.collection.forEach(function(e){var t=e.category;e["category"]=t?t["name"]:"暂无",e["online"]=0===e["online"]?"否":"是"}),this.tableData=n.collection;case 12:case"end":return e.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}(),currentChange:function(e){e<=0||(e-=1,this.currentPage=e+1,this.getSkus(e))},handleAdd:function(){this.redirectType="add"},handleEdit:function(e){var t=e.row;this.editID=t.id,this.redirectType="edit"},handleDelete:function(e){var t=this;this.$confirm("此操作将永久删除该sku, 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(p(s.a.mark(function n(){var a,i;return s.a.wrap(function(n){while(1)switch(n.prev=n.next){case 0:return a=[e.row.id],t.loading=!0,n.next=4,o["default"].delSku(a);case 4:i=n.sent,t.loading=!1,0===i.error_code&&(t.getSkus(t.currentPage-1),t.$message({type:"success",message:"".concat(i.msg)}));case 7:case"end":return n.stop()}},n)})))},rowClick:function(){},closePage:function(e){this.redirectType="list",console.log(this.currentPage),e&&this.getSkus(this.currentPage-1)}}},f=d,m=(n("a4e1"),n("2877")),h=Object(m["a"])(f,a,i,!1,null,"63335e84",null);t["default"]=h.exports},"4b94":function(e,t,n){"use strict";n.r(t);var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"container"},[n("div",{staticClass:"title"},[e._v("新建SKU "),n("span",{staticClass:"back",on:{click:function(t){return e.back(!1)}}},[n("i",{staticClass:"iconfont icon-fanhui"}),e._v(" 返回 ")])]),n("div",{staticClass:"wrap"},[n("el-row",[n("el-col",{attrs:{lg:16,md:20,sm:24,xs:24}},[n("el-form",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],ref:"form",attrs:{model:e.form,"status-icon":"",rules:e.rules,"label-width":"120px"},nativeOn:{submit:function(e){e.preventDefault()}}},[n("el-form-item",{attrs:{label:"标题",prop:"title"}},[n("el-input",{attrs:{size:"medium",placeholder:"请填写标题"},model:{value:e.form.title,callback:function(t){e.$set(e.form,"title",t)},expression:"form.title"}})],1),n("el-form-item",{attrs:{label:"价格",prop:"price"}},[n("el-input-number",{attrs:{precision:2,step:.1,min:0,label:"描述文字"},on:{change:e.handlePriceChange},model:{value:e.form.price,callback:function(t){e.$set(e.form,"price",t)},expression:"form.price"}})],1),n("el-form-item",{staticClass:"discount_price",attrs:{label:"折扣",prop:"discount_price"}},[n("el-radio-group",{model:{value:e.discountRadio,callback:function(t){e.discountRadio=t},expression:"discountRadio"}},[n("el-radio",{attrs:{label:1}},[e._v("无折扣")]),n("el-radio",{attrs:{label:2}},[e._v("折扣价")]),n("el-radio",{attrs:{label:3}},[e._v("打折")])],1),n("el-input",{staticClass:"discount-input",attrs:{size:"medium",disabled:1===e.discountRadio,placeholder:"请输入折扣值"},on:{input:e.handleDiscountInput},model:{value:e.discountPrice,callback:function(t){e.discountPrice=t},expression:"discountPrice"}}),n("el-input",{attrs:{size:"medium",disabled:"",placeholder:"最终折扣值"},model:{value:e.form.discount_price,callback:function(t){e.$set(e.form,"discount_price",t)},expression:"form.discount_price"}})],1),n("el-form-item",{attrs:{label:"库存",prop:"stock"}},[n("el-input-number",{attrs:{min:0,label:"库存"},model:{value:e.form.stock,callback:function(t){e.$set(e.form,"stock",t)},expression:"form.stock"}})],1),n("el-form-item",{attrs:{label:"分类",prop:"category_id"}},[n("el-option",{attrs:{value:0,label:"请选择分类"}},[n("span",[e._v("请选择分类")])]),n("el-select",{attrs:{size:"medium",filterable:"",placeholder:"请选择分类"},model:{value:e.form.category_id,callback:function(t){e.$set(e.form,"category_id",t)},expression:"form.category_id"}},[e._l(e.cateData,function(t){return[n("el-option",{attrs:{value:t.id,label:t.name,disabled:""}},[n("span",{staticStyle:{color:"#b4b4b4","margin-right":"15px","font-size":"12px"}},[e._v(e._s(t.id))]),n("span",[e._v(e._s(t.name))])]),e._l(t.sub,function(a){return t.sub?[n("el-option",{attrs:{value:a.id,label:a.name}},[n("span",{staticStyle:{color:"#b4b4b4","margin-right":"15px","font-size":"12px"}},[e._v("┞----"+e._s(a.id))]),n("span",[e._v(e._s(a.name))])])]:e._e()})]})],2)],1),n("el-form-item",{attrs:{label:"SPU",prop:"category_id"}},[n("el-select",{attrs:{size:"medium",filterable:"",placeholder:"请选择所属SPU"},on:{change:e.spuChange},model:{value:e.form.spu_id,callback:function(t){e.$set(e.form,"spu_id",t)},expression:"form.spu_id"}},e._l(e.spuData,function(t){return n("el-option",{attrs:{value:t.id,label:t.title}},[n("span",{staticStyle:{color:"#b4b4b4","margin-right":"15px","font-size":"12px"}},[e._v(e._s(t.id))]),n("span",[e._v(e._s(t.title))])])}),1)],1),n("el-form-item",{attrs:{label:"是否上架",prop:"online"}},[n("el-switch",{attrs:{"active-color":"#3963bc"},model:{value:e.form.online,callback:function(t){e.$set(e.form,"online",t)},expression:"form.online"}})],1),n("el-form-item",{attrs:{label:"主图",prop:"img"}},[n("upload-imgs",{ref:"uploadEleMain",attrs:{rules:e.imgRules,maxNum:1}})],1),e._l(e.spuSpecData,function(t,a){return n("el-form-item",{attrs:{label:t.name,prop:"spec"}},[n("el-select",{attrs:{size:"medium",filterable:"",placeholder:"请选择"+t.name+"值"},model:{value:e.selSpecValue[t.id],callback:function(n){e.$set(e.selSpecValue,t.id,n)},expression:"selSpecValue[spec.id]"}},e._l(t.items,function(t){return n("el-option",{key:t.name,attrs:{value:t.id,label:t.name}},[n("span",{staticStyle:{color:"#b4b4b4","margin-right":"15px","font-size":"12px"}},[e._v(e._s(t.id))]),n("span",[e._v(e._s(t.name))])])}),1)],1)}),n("el-form-item",{staticClass:"submit"},[n("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.submitForm("form")}}},[e._v("保 存")]),n("el-button",{on:{click:function(t){return e.resetForm("form")}}},[e._v("重 置")])],1)],2)],1)],1)],1)])},i=[],r=n("a34a"),s=n.n(r),o=n("c1bd"),c=n("5725"),l=n("7954"),u=(n("87e7"),n("306b")),p=n("e0ba"),d=n("f941");function f(e){return f="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function m(e,t,n,a,i,r,s){try{var o=e[r](s),c=o.value}catch(l){return void n(l)}o.done?t(c):Promise.resolve(c).then(a,i)}function h(e){return function(){var t=this,n=arguments;return new Promise(function(a,i){var r=e.apply(t,n);function s(e){m(r,a,i,s,o,"next",e)}function o(e){m(r,a,i,s,o,"throw",e)}s(void 0)})}}var v={name:"SkuAdd",components:{UploadImgs:p["default"],tag:d["default"]},data:function(){return{loading:!1,cateData:{},spuData:[],spuSpecData:[],discountRadio:1,discountPrice:"",specData:[],selSpecValue:{},form:{title:"",description:"",online:!0,specs:[],img:"",price:0,stock:0,discount_price:0},imgRules:{minWidth:100,minHeight:100,maxSize:5},rules:{}}},created:function(){this._initialize()},methods:{_initialize:function(){this.getTreeCate(),this.getSpus()},getTreeCate:function(){var e=h(s.a.mark(function e(){var t,n,a=arguments;return s.a.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return t=a.length>0&&void 0!==a[0]?a[0]:0,n=a.length>1&&void 0!==a[1]?a[1]:2,e.prev=2,e.next=5,o["default"].getTreeCate(t,n);case 5:this.cateData=e.sent,e.next=11;break;case 8:e.prev=8,e.t0=e["catch"](2),this.cateData={};case 11:case"end":return e.stop()}},e,this,[[2,8]])}));function t(){return e.apply(this,arguments)}return t}(),getSpus:function(){var e=h(s.a.mark(function e(){var t;return s.a.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,l["default"].getSpus(0,80);case 2:t=e.sent,this.spuData=t.collection,console.log(t);case 5:case"end":return e.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}(),getSpuSpec:function(){var e=h(s.a.mark(function e(t){var n;return s.a.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return n=[],e.prev=1,e.next=4,l["default"].getSpuSpec(t);case 4:n=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e["catch"](1);case 9:this.sloveResSpec(n);case 10:case"end":return e.stop()}},e,this,[[1,7]])}));function t(t){return e.apply(this,arguments)}return t}(),spuChange:function(){var e=h(s.a.mark(function e(t){return s.a.wrap(function(e){while(1)switch(e.prev=e.next){case 0:this.getSpuSpec(t);case 1:case"end":return e.stop()}},e,this)}));function t(t){return e.apply(this,arguments)}return t}(),sloveResSpec:function(e){if(e&&0!==e.length&&0!==e.specs.length){var t=e.specs,n={},a=[];t.forEach(function(e){n.id=e.id,n.name=e.name,n.items=e.items,a.push(n),n={}}),this.spuSpecData=a}else this.spuSpecData=[]},handlePriceChange:function(e){if(this.discountPrice){var t=this.discountPrice;this.getDiscountPrice(parseFloat(t))}},handleDiscountInput:function(e){var t=parseFloat(e);Number.isNaN(t)?this.discountPrice="":(this.discountPrice=e,this.getDiscountPrice(t))},getDiscountPrice:function(e){var t=this.discountRadio,n=0;switch(t){case 1:break;case 2:n=e;break;case 3:n=parseFloat(100*this.form.price*e*100/1e4);break}this.form.discount_price=n},submitForm:function(e){var t=this;this.$refs[e].validate(function(){var n=h(s.a.mark(function n(a){var i,r,o;return s.a.wrap(function(n){while(1)switch(n.prev=n.next){case 0:if(!a){n.next=27;break}return t.loading=!0,n.prev=2,n.next=5,t.solveAllImgs();case 5:return t.form["specs"]=t.solveReqSpec(),n.next=8,c["default"].addSku(t.form);case 8:i=n.sent,0===i.error_code&&(t.$message.success("".concat(i.msg)),t.resetForm(e),t.back()),n.next=24;break;case 12:if(n.prev=12,n.t0=n["catch"](2),r=n.t0.data.msg,!r||"object"!==f(r)){n.next=24;break}n.t1=s.a.keys(r);case 17:if((n.t2=n.t1()).done){n.next=24;break}return o=n.t2.value,t.$message.error(r[o]),n.next=22,setTimeout(function(){},1e3);case 22:n.next=17;break;case 24:t.loading=!1,n.next=29;break;case 27:return t.$message.error("请填写正确的信息"),n.abrupt("return",!1);case 29:case"end":return n.stop()}},n,null,[[2,12]])}));return function(e){return n.apply(this,arguments)}}())},solveAllImgs:function(){var e=h(s.a.mark(function e(){var t;return s.a.wrap(function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,this.$refs.uploadEleMain.getValue();case 2:t=e.sent,this.form["img"]=u["default"].solveUploadImg(t);case 4:case"end":return e.stop()}},e,this)}));function t(){return e.apply(this,arguments)}return t}(),solveReqSpec:function(){var e=this.spuSpecData,t=this.selSpecValue;e.length>0&&e.length!=Object.values(t).length&&this.$message.error("请确认规格是否全部选择");var n={},a=[],i=function(i){var r=e.find(function(e){return e.id===Number(i)});if(n.key_id=r.id,n.key=r.name,r.items.length>0){var s=r.items.find(function(e){return e.id===t[i]});n.value_id=s.id,n.value=s.name}a.push(n),n={}};for(var r in t)i(r);return a},resetForm:function(e){this.$refs[e].resetFields()},back:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.$emit("close",e)}},watch:{discountRadio:{handler:function(){this.discountPrice="",this.form.discount_price=0}}}},b=v,g=(n("4c57"),n("2877")),k=Object(g["a"])(b,a,i,!1,null,"ec266a1a",null);t["default"]=k.exports},"4c57":function(e,t,n){"use strict";n("cbea")},a4e1:function(e,t,n){"use strict";n("eb89")},cbea:function(e,t,n){},eb89:function(e,t,n){}}]);