chunk-4fec70c4.5b84a429.js 13 KB

1
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4fec70c4","chunk-2d22e146"],{"218d":function(e,t,o){"use strict";var l=o("442f"),r=o.n(l);r.a},"442f":function(e,t,o){},dc9e:function(e,t,o){"use strict";o.r(t);var l=function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("div",{staticClass:"app-content"},[o("div",{staticClass:"form-wrap"},[o("el-form",{ref:"ruleForm",attrs:{model:e.ruleForm,rules:e.rules,"label-width":"120px"}},[o("el-form-item",{attrs:{label:"名称",prop:"goodsName"}},[o("el-input",{model:{value:e.ruleForm.goodsName,callback:function(t){e.$set(e.ruleForm,"goodsName",t)},expression:"ruleForm.goodsName"}})],1),o("el-form-item",{attrs:{label:"已售",prop:"sold"}},[o("el-input",{model:{value:e.ruleForm.sold,callback:function(t){e.$set(e.ruleForm,"sold",t)},expression:"ruleForm.sold"}})],1),o("el-form-item",{attrs:{label:"库存",prop:"stock"}},[o("el-input",{model:{value:e.ruleForm.stock,callback:function(t){e.$set(e.ruleForm,"stock",t)},expression:"ruleForm.stock"}})],1),o("el-form-item",{attrs:{label:"分类",prop:"categoryIdList"}},[o("el-checkbox-group",{model:{value:e.ruleForm.categoryIdList,callback:function(t){e.$set(e.ruleForm,"categoryIdList",t)},expression:"ruleForm.categoryIdList"}},e._l(e.categoryData,(function(t,l){return o("el-checkbox",{key:l,attrs:{border:"",label:t.id,size:"small"},on:{change:function(o){return e.selChangeDialogFn(o,t)}}},[e._v(e._s(t.categoryName))])})),1)],1),o("el-form-item",{attrs:{label:"款式",prop:"goodsStyle"}},[o("el-checkbox-group",{on:{change:e.changeStyleFn},model:{value:e.ruleForm.goodsStyle,callback:function(t){e.$set(e.ruleForm,"goodsStyle",t)},expression:"ruleForm.goodsStyle"}},[o("el-checkbox",{attrs:{label:"1",name:"goodsStyle","true-label":"1","false-label":"0"}},[o("span",[e._v("多款式")])])],1),1==e.ruleForm.goodsStyle?o("div",{staticClass:"style-modal-content"},[e.actionOption?o("el-form",{staticClass:"demo-form-inline",attrs:{inline:!0,model:e.styleForm}},e._l(e.styleStoreData,(function(t,l){return o("div",{key:l,staticClass:"flex-center-between"},["delete"!=t.action?[o("el-form-item",{attrs:{label:"款式名称"}},[o("el-input",{attrs:{placeholder:"款式名称"},model:{value:t.styleName,callback:function(o){e.$set(t,"styleName",o)},expression:"item.styleName"}})],1),o("el-form-item",{attrs:{label:"价格"}},[o("el-input",{attrs:{placeholder:"价格"},model:{value:t.price,callback:function(o){e.$set(t,"price",o)},expression:"item.price"}})],1),o("el-form-item",{staticClass:"flex-center",attrs:{label:"图片"}},[o("cl-upload",{attrs:{props:{multiple:!0}},model:{value:t.picture,callback:function(o){e.$set(t,"picture",o)},expression:"item.picture"}})],1),o("el-form-item",[o("el-button",{attrs:{type:"primary",size:"small"},on:{click:function(t){return e.styleDelFn(l)}}},[e._v("删除")])],1)]:e._e()],2)})),0):e._e(),o("el-button",{attrs:{type:"primary",size:"small"},on:{click:e.styleFormAddFn}},[e._v("新增")])],1):e._e()],1),0==e.ruleForm.goodsStyle?o("el-form-item",{attrs:{label:"价格",prop:"price"}},[o("el-input",{model:{value:e.ruleForm.price,callback:function(t){e.$set(e.ruleForm,"price",t)},expression:"ruleForm.price"}})],1):e._e(),o("el-form-item",{attrs:{label:"图片",prop:"shopImg"}},[o("div",{staticClass:"list-wrap"},[o("elxUpload",{attrs:{limit:4,fileList:e.fileList_show},on:{"update:fileList":function(t){e.fileList_show=t},"update:file-list":function(t){e.fileList_show=t},success:e.fromToData,handleRemove:e.fromToData}})],1),o("div",[o("el-button",{attrs:{type:"primary",size:"small"},on:{click:function(t){e.imgStoreModal=!0}}},[e._v("从图库选择")])],1),o("el-dialog",{attrs:{visible:e.dialogVisible},on:{"update:visible":function(t){e.dialogVisible=t}}},[o("img",{attrs:{width:"100%",src:e.dialogImageUrl,alt:""}})])],1),o("el-form-item",{attrs:{label:"商品简介",prop:"content"}},[o("cl-editor-quill",{on:{load:e.editor},model:{value:e.ruleForm.content,callback:function(t){e.$set(e.ruleForm,"content",t)},expression:"ruleForm.content"}})],1),o("el-form-item",{attrs:{label:"节日自动涨价 "}},[o("el-checkbox-group",{model:{value:e.ruleForm.autoRise,callback:function(t){e.$set(e.ruleForm,"autoRise",t)},expression:"ruleForm.autoRise"}},[o("el-checkbox",{attrs:{label:"1",name:"autoRise","true-label":"1","false-label":"0"}},[o("span",[e._v("需要")])]),o("el-popover",{attrs:{placement:"top",width:"100",trigger:"hover"},model:{value:e.autoPricePopover,callback:function(t){e.autoPricePopover=t},expression:"autoPricePopover"}},[o("p",[e._v("特定节日商品会自动进行涨价 无需手动调价")]),o("div",{staticStyle:{"text-align":"right","margin-top":"10px"}},[o("el-button",{attrs:{size:"mini",type:"primary"},on:{click:function(t){e.autoPricePopover=!1}}},[e._v("涨价设置")])],1),o("el-button",{attrs:{slot:"reference",type:"text",icon:"el-icon-question"},slot:"reference"})],1)],1)],1),o("el-form-item",{attrs:{label:"配送方式"}},[o("el-checkbox-group",{model:{value:e.ruleForm.needSend,callback:function(t){e.$set(e.ruleForm,"needSend",t)},expression:"ruleForm.needSend"}},[o("el-checkbox",{attrs:{label:"1",name:"type","true-label":"1","false-label":"0"}},[o("span",[e._v("到店自提")])])],1)],1),o("el-form-item",{attrs:{label:"运费"}},[o("el-radio-group",{model:{value:e.ruleForm.freightType,callback:function(t){e.$set(e.ruleForm,"freightType",t)},expression:"ruleForm.freightType"}},[o("el-radio",{attrs:{label:"0"}},[o("span",[e._v("按距离收费")])]),o("el-popover",{attrs:{placement:"top",width:"100",trigger:"hover"},model:{value:e.chargePopover,callback:function(t){e.chargePopover=t},expression:"chargePopover"}},[o("p",[e._v("5公里内免运费,超过5公里每增加1公里运费增加2元")]),o("div",{staticStyle:{"text-align":"right","margin-top":"10px"}},[o("el-button",{attrs:{size:"mini",type:"primary"},on:{click:function(t){e.chargePopover=!1}}},[e._v("修改")])],1),o("el-button",{staticClass:"question-btn",attrs:{slot:"reference",type:"text",icon:"el-icon-question"},slot:"reference"})],1),o("el-radio",{attrs:{label:"1"}},[o("span",[e._v("免运费")])])],1)],1),o("el-form-item",[o("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.submitForm("ruleForm",1)}}},[e._v("上架出售")]),o("el-button",{on:{click:function(t){return e.submitForm("ruleForm",0)}}},[e._v("加入仓库")])],1)],1)],1),o("el-dialog",{attrs:{title:"从图库选择",visible:e.imgStoreModal,width:"600px"},on:{"update:visible":function(t){e.imgStoreModal=t}}},[o("div",{staticClass:"store-modal-content"},[o("div",{staticClass:"select-wrap flex-center-start"},[o("div",{staticStyle:{width:"80px"}},[e._v("选择分类")]),o("el-select",{staticStyle:{width:"200px"},attrs:{placeholder:"选择分类",size:"mini",clearable:!0},on:{change:e.selChangeFn},model:{value:e.imgStoreVal,callback:function(t){e.imgStoreVal=t},expression:"imgStoreVal"}},e._l(e.categoryData,(function(t,l){return o("el-option",{key:l,attrs:{label:t.categoryName,value:t.id}},[e._v(e._s(t.categoryName))])})),1)],1),o("div",{staticClass:"img-store-wrap"},[o("el-checkbox-group",{staticClass:"list-store",on:{change:e.setCheckImg},model:{value:e.imgStoreArr,callback:function(t){e.imgStoreArr=t},expression:"imgStoreArr"}},e._l(e.imgStoreData,(function(e,t){return o("div",{key:t,staticClass:"list-checkbox"},[o("el-checkbox",{attrs:{label:e.imgUrl+""}},[o("div",{staticClass:"list-img"},[o("img",{attrs:{src:e.imgUrl,alt:"图库图片"}})])])],1)})),0)],1)]),o("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[o("el-button",{attrs:{size:"small"},on:{click:function(t){e.imgStoreModal=!1}}},[e._v("取 消")]),o("el-button",{attrs:{type:"primary",size:"small"},on:{click:e.checkImage}},[e._v("确 定")])],1)])],1)},r=[],i=(o("99af"),o("d81d"),o("a434"),o("5530")),s=o("5880"),a=o("f9da"),n={name:"goods-add",data:function(){return{ruleForm:{goodsName:"",sold:"",stock:"",categoryIdList:[],goodsStyle:"0",price:"",autoRise:"1",needSend:"0",shopImg:[],freightType:"0"},rules:{goodsName:[{required:!0,message:"请输入名称",trigger:"blur"}],categoryIdList:[{required:!0,message:"请选择分类",trigger:"blur"}],stock:[{required:!0,message:"必填",trigger:"blur"}],price:[{required:!0,message:"必填",trigger:"blur"}],sold:[{required:!0,message:"必填",trigger:"blur"}],goodsStyle:[{required:!0,message:"必填",trigger:"blur"}],shopImg:[{required:!0,message:"必填",trigger:"blur"}],content:[{required:!0,message:"必填",trigger:"blur"}]},fileList_show:[],dialogImageUrl:"",dialogVisible:!1,autoPricePopover:!1,chargePopover:!1,imgStoreData:[],imgStoreModal:!1,imgStoreVal:"",imgStoreOpt:[],imgStoreArr:[],currentPage:1,actionOption:!0,styleStoreData:[],styleForm:{id:0,styleName:"",price:"",picture:"",action:"add"}}},components:{elxUpload:a["default"]},computed:Object(i["a"])({},Object(s["mapGetters"])({categoryData:"category"}),{},Object(s["mapGetters"])(["token"])),created:function(){this.init()},methods:{init:function(){var e=this;this.pageParams=this.$route.query,"2"==this.pageParams.editType&&this.$service.goods.info({id:this.pageParams.id}).then((function(t){e.ruleForm=t,e.fliterData(t),console.log(e.ruleForm)})),this.$store.dispatch("getCategory"),this._getImgStore()},_getImgStore:function(){var e=this;return this.$service.imgStore.list({page:1,categoryId:this.imgStoreVal}).then((function(t){e.imgStoreData=t.list}))},addFn:function(e){var t=this,o=JSON.parse(JSON.stringify(this.ruleForm)),l="add";"2"==this.pageParams.editType&&(l="update",delete o.shortImgList,delete o.imgList,delete o.smallImgList),1==o.goodsStyle&&(delete o.price,o.goodsStyleList=this.styleStoreData),this.$service.goods[l](Object(i["a"])({},o,{status:e})).then((function(e){t.resetForm("ruleForm"),t.$message.success("添加成功!"),t.$router.push("/goods/list")}))},fliterData:function(e){for(var t=e.smallImgList,o=e.imgList,l=e.shortImgList,r=[],i=0;i<t.length;i++)r.push({url:t[i],showBBGG:o[i]});if(this.ruleForm.shopImg=l,this.fileList_show=r,console.log(this.fileList_show,this.ruleForm.shopImg),!this.$util.isEmpty(e.goodsStyleList))for(var s in e.goodsStyleList)e.goodsStyleList[s].action="update",this.styleStoreData.push(e.goodsStyleList[s]);this.ruleForm.categoryIdList=e.categoryIdList.map(String)},fromToData:function(e){e.file;for(var t=e.fileList,o=[],l=0;l<t.length;l++)t[l].response&&o.push(t[l].response.shortUrl);this.$set(this.ruleForm,"shopImg",o),console.log(this.ruleForm.shopImg)},changeStyleFn:function(e){console.log(e),this.styleStoreData=[],e&&(this.styleFormAddFn(),this.styleStoreModal=!0)},selChangeDialogFn:function(e,t){console.log(e,t)},submitForm:function(e,t){var o=this;this.$refs[e].validate((function(e){if(console.log(e),!e)return console.log("error submit!!"),!1;o.addFn(t)}))},resetForm:function(e){this.$refs[e].resetFields()},checkImage:function(){this.imgStoreModal=!1},setCheckImg:function(e){this.$set(this.ruleForm,"shopImg",this.ruleForm.shopImg.concat(e)),console.log(this.ruleForm.shopImg,e)},editor:function(e){console.log(e)},handleSizeChange:function(e){console.log("每页 ".concat(e," 条"))},handleCurrentChange:function(e){console.log("当前页: ".concat(e))},selChangeFn:function(e){this.imgStoreVal=e},getStyleNum:function(){var e=0;for(var t in this.styleStoreData)"delete"!=this.styleStoreData[t].action&&e++;return e},styleDelFn:function(e){this.actionOption=!1;var t=this.getStyleNum();if(console.log("num",t),1==t)return this.$message.error("最少保留一个款式!"),!1;"update"==this.styleStoreData[e].action?this.$set(this.styleStoreData[e],"action","delete"):this.styleStoreData.splice(e,1),this.actionOption=!0,console.log("this.styleStoreData",this.styleStoreData)},styleFormAddFn:function(){var e=this.getStyleNum();if(e>5)return this.$message.error("最多选择六个款式!"),!1;var t=JSON.parse(JSON.stringify(this.styleForm));this.styleStoreData.push(t)}}},c=n,u=(o("218d"),o("2877")),m=Object(u["a"])(c,l,r,!1,null,"91aaaeb6",null);t["default"]=m.exports},f9da:function(e,t,o){"use strict";o.r(t);var l=function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("div",[o("el-upload",{attrs:{action:e.action,"list-type":"picture-card","http-request":e.httpRequest,limit:e.limit,"file-list":e.fileList,"on-exceed":e.exceed,"on-success":e.success,headers:{token:e.token},multiple:e.multiple,"on-preview":e.handlePictureCardPreview,"on-remove":e.handleRemove}},[o("i",{staticClass:"el-icon-plus"})]),o("el-dialog",{attrs:{visible:e.dialogVisible},on:{"update:visible":function(t){e.dialogVisible=t}}},[o("img",{attrs:{width:"100%",src:e.dialogImageUrl,alt:""}})])],1)},r=[],i=(o("d3b7"),o("5530")),s=o("5880"),a={name:"elx-upload",props:{limit:null,multiple:{type:Boolean,default:!0},fileList:{type:Array,default:[]},value:[Array,String]},data:function(){var e=this.$service.common.upload();return{action:e.url,list:[],index:0,dialogImageUrl:"",dialogVisible:!1}},computed:Object(i["a"])({},Object(s["mapGetters"])(["token"])),mounted:function(){this.init()},methods:{init:function(){},httpRequest:function(e){var t=this,o=e.file;this.getBase64(o).then((function(o){t.$service.common.uploadImg({content:o}).then((function(t){e.onSuccess(t)}))}))},handleRemove:function(e,t){this.$emit("handleRemove",{file:e,fileList:t})},handlePictureCardPreview:function(e){this.dialogImageUrl=e.showBBGG||e.url,this.dialogVisible=!0},exceed:function(){this.$message("不能超过".concat(this.limit))},success:function(e,t,o){this.$emit("update:fileList",o),this.$emit("success",{response:e,file:t,fileList:o})},getBase64:function(e){return new Promise((function(t,o){var l=new FileReader,r="";l.readAsDataURL(e),l.onload=function(){r=l.result},l.onerror=function(e){o(e)},l.onloadend=function(){t(r)}}))}}},n=a,c=o("2877"),u=Object(c["a"])(n,l,r,!1,null,"4c462b97",null);t["default"]=u.exports}}]);