chunk-1dcd1af8.b5945c2c.js 14 KB

1
  1. (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-1dcd1af8","chunk-2d22e146"],{"6f18":function(e,t,o){"use strict";o("8734")},8734:function(e,t,o){},dc9e:function(e,t,o){"use strict";o.r(t);var r=function(){var e=this,t=e._self._c;return t("div",{staticClass:"app-content"},[t("div",{staticClass:"form-wrap"},[t("el-form",{ref:"ruleForm",attrs:{model:e.ruleForm,rules:e.rules,"label-width":"120px"}},[t("el-form-item",{attrs:{label:"名称",prop:"goodsName"}},[t("el-input",{model:{value:e.ruleForm.goodsName,callback:function(t){e.$set(e.ruleForm,"goodsName",t)},expression:"ruleForm.goodsName"}})],1),t("el-form-item",{attrs:{label:"已售",prop:"sold"}},[t("el-input",{model:{value:e.ruleForm.sold,callback:function(t){e.$set(e.ruleForm,"sold",t)},expression:"ruleForm.sold"}})],1),t("el-form-item",{attrs:{label:"库存",prop:"stock"}},[t("el-input",{model:{value:e.ruleForm.stock,callback:function(t){e.$set(e.ruleForm,"stock",t)},expression:"ruleForm.stock"}})],1),t("el-form-item",{attrs:{label:"分类",prop:"categoryIdList"}},[t("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(o,r){return t("el-checkbox",{key:r,attrs:{border:"",label:o.id,size:"small"},on:{change:function(t){return e.selChangeDialogFn(t,o)}}},[e._v(e._s(o.categoryName))])})),1)],1),t("el-form-item",{attrs:{label:"款式",prop:"goodsStyle"}},[t("el-checkbox-group",{on:{change:e.changeStyleFn},model:{value:e.ruleForm.goodsStyle,callback:function(t){e.$set(e.ruleForm,"goodsStyle",t)},expression:"ruleForm.goodsStyle"}},[t("el-checkbox",{attrs:{label:"1",name:"goodsStyle","true-label":"1","false-label":"0"}},[t("span",[e._v("多款式")])])],1),1==e.ruleForm.goodsStyle?t("div",{staticClass:"style-modal-content"},[e.actionOption?t("el-form",{staticClass:"demo-form-inline",attrs:{inline:!0,model:e.styleForm}},e._l(e.styleStoreData,(function(o,r){return t("div",{key:r,staticClass:"flex-center-between"},["delete"!=o.action?[t("el-form-item",{attrs:{label:"款式名称"}},[t("el-input",{attrs:{placeholder:"款式名称"},model:{value:o.styleName,callback:function(t){e.$set(o,"styleName",t)},expression:"item.styleName"}})],1),t("el-form-item",{attrs:{label:"价格"}},[t("el-input",{attrs:{placeholder:"价格"},model:{value:o.price,callback:function(t){e.$set(o,"price",t)},expression:"item.price"}})],1),t("el-form-item",{staticClass:"flex-center",attrs:{label:"图片"}},[t("cl-upload",{attrs:{props:{multiple:!0}},model:{value:o.picture,callback:function(t){e.$set(o,"picture",t)},expression:"item.picture"}})],1),t("el-form-item",[t("el-button",{attrs:{type:"primary",size:"small"},on:{click:function(t){return e.styleDelFn(r)}}},[e._v("删除")])],1)]:e._e()],2)})),0):e._e(),t("el-button",{attrs:{type:"primary",size:"small"},on:{click:e.styleFormAddFn}},[e._v("新增")])],1):e._e()],1),0==e.ruleForm.goodsStyle?t("el-form-item",{attrs:{label:"价格",prop:"price"}},[t("el-input",{model:{value:e.ruleForm.price,callback:function(t){e.$set(e.ruleForm,"price",t)},expression:"ruleForm.price"}})],1):e._e(),t("el-form-item",{attrs:{label:"图片",prop:"shopImg"}},[t("div",{staticClass:"list-wrap"},[t("elxUpload",{attrs:{limit:4,fileList:e.fileList_show,disabled:0==e.ruleForm.categoryIdList.length,category:e.ruleForm.categoryIdList},on:{"update:fileList":function(t){e.fileList_show=t},"update:file-list":function(t){e.fileList_show=t},success:e.fromToData,handleRemove:e.fromToData}}),t("p",{directives:[{name:"show",rawName:"v-show",value:0==e.ruleForm.categoryIdList.length,expression:"ruleForm.categoryIdList.length == 0"}],staticStyle:{color:"red"}},[e._v(" 请先选择分类 ")])],1),t("div",[t("el-button",{attrs:{type:"primary",size:"small"},on:{click:e.openStore}},[e._v("从图库选择")])],1),t("el-dialog",{attrs:{visible:e.dialogVisible},on:{"update:visible":function(t){e.dialogVisible=t}}},[t("img",{attrs:{width:"100%",src:e.dialogImageUrl,alt:""}})])],1),t("el-form-item",{attrs:{label:"商品简介",prop:"content"}},[t("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),t("el-form-item",{attrs:{label:"自动涨价 "}},[t("el-checkbox-group",{model:{value:e.ruleForm.autoRise,callback:function(t){e.$set(e.ruleForm,"autoRise",t)},expression:"ruleForm.autoRise"}},[t("el-checkbox",{attrs:{label:"1",name:"autoRise","true-label":"1","false-label":"0"}},[t("span",[e._v("需要")])]),t("el-popover",{attrs:{placement:"top",width:"100",trigger:"hover"},model:{value:e.autoPricePopover,callback:function(t){e.autoPricePopover=t},expression:"autoPricePopover"}},[t("p",[e._v("节日当天和前一天,商品会自动根据设置统一涨价")]),t("div",{staticStyle:{"text-align":"right","margin-top":"10px"}},[t("el-button",{attrs:{size:"mini",type:"primary"},on:{click:function(t){e.autoPricePopover=!1}}},[e._v("涨价设置")])],1),t("el-button",{attrs:{slot:"reference",type:"text",icon:"el-icon-question"},slot:"reference"})],1)],1)],1),t("el-form-item",{attrs:{label:"配送方式"}},[t("el-checkbox-group",{model:{value:e.ruleForm.needSend,callback:function(t){e.$set(e.ruleForm,"needSend",t)},expression:"ruleForm.needSend"}},[t("el-checkbox",{attrs:{label:"1",name:"type","true-label":"1","false-label":"0"}},[t("span",[e._v("到店自提")])])],1)],1),t("el-form-item",{attrs:{label:"运费"}},[t("el-radio-group",{model:{value:e.ruleForm.freightType,callback:function(t){e.$set(e.ruleForm,"freightType",t)},expression:"ruleForm.freightType"}},[t("el-radio",{attrs:{label:"0"}},[t("span",[e._v("按距离收费")])]),t("el-popover",{attrs:{placement:"top",width:"100",trigger:"hover"},model:{value:e.chargePopover,callback:function(t){e.chargePopover=t},expression:"chargePopover"}},[t("p",[e._v(" "+e._s(e.shopInfo.extend.freeDistance)+"公里内免运费,超过每增加"+e._s(e.shopInfo.extend.freight)+"公里运费增加2元 ")]),t("div",{staticStyle:{"text-align":"right","margin-top":"10px"}},[t("el-button",{attrs:{size:"mini",type:"primary"},on:{click:function(t){e.chargePopover=!1}}},[e._v("修改")])],1),t("el-button",{staticClass:"question-btn",attrs:{slot:"reference",type:"text",icon:"el-icon-question"},slot:"reference"})],1),t("el-radio",{attrs:{label:"1"}},[t("span",[e._v("免运费")])])],1)],1),t("el-form-item",[t("el-button",{attrs:{type:"primary"},on:{click:function(t){return e.submitForm("ruleForm",1)}}},[e._v("上架出售")]),t("el-button",{on:{click:function(t){return e.submitForm("ruleForm",0)}}},[e._v("加入仓库")])],1)],1)],1),t("el-dialog",{attrs:{title:"从图库选择",visible:e.imgStoreModal,width:"600px"},on:{"update:visible":function(t){e.imgStoreModal=t}}},[t("div",{staticClass:"store-modal-content"},[t("div",{staticClass:"select-wrap flex-center-start"},[t("div",{staticStyle:{width:"80px"}},[e._v("选择分类")]),t("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(o,r){return t("el-option",{key:r,attrs:{label:o.categoryName,value:o.id}},[e._v(e._s(o.categoryName))])})),1)],1),t("div",{staticClass:"img-store-wrap"},[t("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,o){return t("div",{key:o,staticClass:"list-checkbox"},[t("el-checkbox",{attrs:{label:e.imgUrl+""}},[t("div",{staticClass:"list-img"},[t("img",{attrs:{src:e.imgUrl,alt:"图库图片"}})])])],1)})),0)],1)]),t("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[t("el-button",{attrs:{size:"small"},on:{click:function(t){e.imgStoreModal=!1}}},[e._v("取 消")]),t("el-button",{attrs:{type:"primary",size:"small"},on:{click:e.checkImage}},[e._v("确 定")])],1)])],1)},i=[],l=o("1f77"),s=(o("10dc"),o("d6d8"),o("f16c"),o("7464"),o("45d2"),o("9052"),o("b144"),o("5f45"),o("dc93"),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(l["a"])(Object(l["a"])({},Object(s["mapGetters"])({categoryData:"category"})),Object(s["mapGetters"])(["token","shopInfo"])),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)),r="add";"2"==this.pageParams.editType&&(r="update",delete o.shortImgList,delete o.imgList,delete o.smallImgList),1==o.goodsStyle&&(delete o.price,o.goodsStyleList=this.styleStoreData),this.$service.goods[r](Object(l["a"])(Object(l["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,r=e.shortImgList,i=[],l=0;l<t.length;l++)i.push({url:t[l],showBBGG:o[l]});if(this.ruleForm.shopImg=r,this.fileList_show=i,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=[],r=0;r<t.length;r++)t[r].response&&o.push(t[r].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,this.fileList_show=this.fileList_show.concat(this.imgStoreArr.map((function(e){return{url:e,status:"success"}})))},setCheckImg:function(e){this.$set(this.ruleForm,"shopImg",this.ruleForm.shopImg.concat(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){var t=this.getStyleNum();if(console.log("num",t),1==t)return this.$message.error("最少保留一个款式!"),!1;this.actionOption=!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)},openStore:function(){if(0==this.ruleForm.categoryIdList.length)return this.$message.error("请先选择分类");this.imgStoreModal=!0}}},c=n,u=(o("6f18"),o("1805")),m=Object(u["a"])(c,r,i,!1,null,"1212faa6",null);t["default"]=m.exports},f9da:function(e,t,o){"use strict";o.r(t);var r=function(){var e=this,t=e._self._c;return t("div",[t("el-upload",{attrs:{action:e.action,"list-type":"picture-card","http-request":e.httpRequest,limit:e.limit,"file-list":e.fileList,disabled:e.disabled,"on-exceed":e.exceed,"on-success":e.success,headers:{token:e.token},multiple:e.multiple,"on-preview":e.handlePictureCardPreview,"on-remove":e.handleRemove,"before-upload":e.beforeUpload}},[t("i",{staticClass:"el-icon-plus"})]),t("el-dialog",{attrs:{visible:e.dialogVisible},on:{"update:visible":function(t){e.dialogVisible=t}}},[t("img",{attrs:{width:"100%",src:e.dialogImageUrl,alt:""}})])],1)},i=[],l=o("1f77"),s=(o("dc93"),o("5880")),a={name:"elx-upload",props:{limit:null,multiple:{type:Boolean,default:!0},fileList:{type:Array,default:[]},value:[Array,String],beforeUpload:Function,disabled:Boolean,category:Array},data:function(){var e=this.$service.common.upload();return{action:e.url,list:[],index:0,dialogImageUrl:"",dialogVisible:!1}},computed:Object(l["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,categoryId:t.category}).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.warning("最多只能上传".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 r=new FileReader,i="";r.readAsDataURL(e),r.onload=function(){i=r.result},r.onerror=function(e){o(e)},r.onloadend=function(){t(i)}}))}}},n=a,c=o("1805"),u=Object(c["a"])(n,r,i,!1,null,"49d9d616",null);t["default"]=u.exports}}]);