| 1 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4f0a7d14","chunk-2d22e146"],{"066b":function(e,t,r){"use strict";var i=r("04c2"),s=r("f5ed").trim,a=r("d6c5");i({target:"String",proto:!0,forced:a("trim")},{trim:function(){return s(this)}})},2116:function(e,t,r){"use strict";r.r(t);r("7212"),r("4786");var i=function(){var e=this,t=e._self._c;return t("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticClass:"app-content bouquet-edit-page"},[t("div",{staticClass:"page-head"},[t("div",{staticClass:"crumb"},[e._v("商品 / "+e._s(e.isEdit?"编辑花束":"添加花束"))]),t("div",{staticClass:"page-title"},[e._v(e._s(e.isEdit?"编辑花束":"添加花束"))])]),t("el-form",{ref:"formRef",attrs:{model:e.form,rules:e.rules,"label-width":"110px",size:"small"}},[t("div",{staticClass:"card"},[t("div",{staticClass:"card-title"},[e._v("基础信息")]),t("el-row",{attrs:{gutter:24}},[t("el-col",{attrs:{span:14}},[e.isEdit?t("el-form-item",{attrs:{label:"商品编号"}},[t("span",{staticClass:"sn-text"},[e._v(e._s(e.form.sn||"生成中…"))])]):e._e(),t("el-form-item",{attrs:{label:"花束名称",prop:"name"}},[t("el-input",{attrs:{maxlength:"60","show-word-limit":"",placeholder:"请输入花束名称"},model:{value:e.form.name,callback:function(t){e.$set(e.form,"name",t)},expression:"form.name"}})],1),t("el-form-item",{attrs:{label:"花束分类",prop:"categoryIdList"}},[t("el-select",{staticStyle:{width:"100%"},attrs:{multiple:"","collapse-tags":"",filterable:"",placeholder:"请选择花束分类(可多选)"},model:{value:e.form.categoryIdList,callback:function(t){e.$set(e.form,"categoryIdList",t)},expression:"form.categoryIdList"}},e._l(e.categoryData,(function(e){return t("el-option",{key:e.id,attrs:{label:e.categoryName,value:Number(e.id)}})})),1)],1),t("el-form-item",{attrs:{label:"使用场景"}},[t("el-checkbox-group",{model:{value:e.form.useCaseIdList,callback:function(t){e.$set(e.form,"useCaseIdList",t)},expression:"form.useCaseIdList"}},e._l(e.useCaseData,(function(r){return t("el-checkbox",{key:r.id,attrs:{label:Number(r.id),border:""}},[e._v(e._s(r.useCaseName||r.name))])})),1)],1)],1),t("el-col",{attrs:{span:10}},[t("el-form-item",{attrs:{label:"商品主图",required:""}},[t("elx-upload",{attrs:{limit:5,sortable:!0,fileList:e.fileListShow,category:e.form.categoryIdList},on:{"update:fileList":function(t){e.fileListShow=t},"update:file-list":function(t){e.fileListShow=t},success:e.onUploadChange,handleRemove:e.onUploadChange,reorder:e.onUploadChange}}),t("div",{staticClass:"tip"},[e._v("建议 800×800,最多 5 张;可拖动排序,第一张为主图")])],1)],1)],1)],1),t("div",{staticClass:"card"},[t("div",{staticClass:"card-title row-between"},[t("span",[e._v("规格与价格")]),t("div",[t("span",{staticClass:"switch-lab"},[e._v("启用多规格")]),t("el-switch",{attrs:{"active-value":1,"inactive-value":0},on:{change:e.onToggleSpecs},model:{value:e.form.specEnabled,callback:function(t){e.$set(e.form,"specEnabled",t)},expression:"form.specEnabled"}}),1==e.form.specEnabled?t("el-button",{staticStyle:{"margin-left":"12px"},attrs:{type:"text"},on:{click:e.openBatchSpec}},[e._v("批量设置")]):e._e()],1)]),1==e.form.specEnabled?[e._l(e.form.specList,(function(r,i){return t("div",{key:"spec-"+i,staticClass:"spec-block"},[t("div",{staticClass:"spec-head"},[t("span",[e._v("规格组 "+e._s(i+1))]),t("el-button",{staticStyle:{color:"#f5222d"},attrs:{type:"text"},on:{click:function(t){return e.removeSpec(i)}}},[e._v("删除")])],1),t("el-form-item",{attrs:{label:"规格名称",required:""}},[t("el-input",{staticStyle:{width:"280px"},attrs:{placeholder:"如:红玫瑰 / 大号"},model:{value:r.specName,callback:function(t){e.$set(r,"specName",t)},expression:"spec.specName"}})],1),t("el-form-item",{attrs:{label:"价格类型"}},[t("el-radio-group",{on:{change:function(t){return e.onSpecPriceType(i,t)}},model:{value:r.priceType,callback:function(t){e.$set(r,"priceType",t)},expression:"spec.priceType"}},[t("el-radio",{attrs:{label:"1"}},[e._v("有价格")]),t("el-radio",{attrs:{label:"0"}},[e._v("无价格")])],1)],1),"1"===r.priceType?t("el-form-item",{attrs:{label:"销售价"}},[t("el-input",{staticStyle:{width:"160px"},attrs:{placeholder:"元"},model:{value:r.price,callback:function(t){e.$set(r,"price",t)},expression:"spec.price"}})],1):e._e(),t("el-form-item",{attrs:{label:"库存"}},[t("el-radio-group",{on:{change:function(t){return e.onSpecStockSet(i,t)}},model:{value:r.stockSet,callback:function(t){e.$set(r,"stockSet",t)},expression:"spec.stockSet"}},[t("el-radio",{attrs:{label:"0"}},[e._v("管够")]),t("el-radio",{attrs:{label:"1"}},[e._v("自定义")])],1),"1"===r.stockSet?t("el-input",{staticStyle:{width:"120px","margin-left":"12px"},attrs:{placeholder:"库存"},model:{value:r.stock,callback:function(t){e.$set(r,"stock",t)},expression:"spec.stock"}}):e._e()],1),t("el-form-item",{attrs:{label:"花支数"}},[t("el-input",{staticStyle:{width:"120px"},model:{value:r.flowerNum,callback:function(t){e.$set(r,"flowerNum",t)},expression:"spec.flowerNum"}})],1),t("el-form-item",{attrs:{label:"重量(kg)"}},[t("el-input",{staticStyle:{width:"120px"},model:{value:r.weight,callback:function(t){e.$set(r,"weight",t)},expression:"spec.weight"}})],1),t("el-form-item",{attrs:{label:"规格图片",required:""}},[t("elx-upload",{attrs:{limit:5,sortable:!0,fileList:r.fileListShow,category:e.form.categoryIdList},on:{"update:fileList":function(t){return e.$set(r,"fileListShow",t)},"update:file-list":function(t){return e.$set(r,"fileListShow",t)},success:function(t){return e.onSpecUploadChange(i,t)},handleRemove:function(t){return e.onSpecUploadChange(i,t)},reorder:function(t){return e.onSpecUploadChange(i,t)}}}),t("div",{staticClass:"tip"},[e._v("每个规格需单独设置图片;可拖动,第一张为该规格封面")])],1)],1)})),t("el-button",{attrs:{type:"primary",plain:"",size:"small"},on:{click:e.addSpec}},[e._v("新增规格组")])]:[t("el-form-item",{attrs:{label:"价格类型"}},[t("el-radio-group",{on:{change:e.onPriceTypeChange},model:{value:e.form.priceType,callback:function(t){e.$set(e.form,"priceType",t)},expression:"form.priceType"}},[t("el-radio",{attrs:{label:"1"}},[e._v("有价格")]),t("el-radio",{attrs:{label:"0"}},[e._v("无价格")])],1)],1),"1"===e.form.priceType?t("el-form-item",{attrs:{label:"销售价",prop:"price"}},[t("el-input",{staticStyle:{width:"200px"},attrs:{placeholder:"请输入销售价"},model:{value:e.form.price,callback:function(t){e.$set(e.form,"price",t)},expression:"form.price"}})],1):e._e(),t("el-form-item",{attrs:{label:"库存"}},[t("el-radio-group",{on:{change:e.onStockSetChange},model:{value:e.form.stockSet,callback:function(t){e.$set(e.form,"stockSet",t)},expression:"form.stockSet"}},[t("el-radio",{attrs:{label:"0"}},[e._v("管够")]),t("el-radio",{attrs:{label:"1"}},[e._v("自定义")])],1),"1"===e.form.stockSet?t("el-input",{staticStyle:{width:"160px","margin-left":"12px"},attrs:{placeholder:"库存数量"},model:{value:e.form.stock,callback:function(t){e.$set(e.form,"stock",t)},expression:"form.stock"}}):e._e()],1),t("el-form-item",{attrs:{label:"花支数"}},[t("el-input",{staticStyle:{width:"160px"},model:{value:e.form.flowerNum,callback:function(t){e.$set(e.form,"flowerNum",t)},expression:"form.flowerNum"}})],1),t("el-form-item",{attrs:{label:"重量(kg)"}},[t("el-input",{staticStyle:{width:"160px"},model:{value:e.form.weight,callback:function(t){e.$set(e.form,"weight",t)},expression:"form.weight"}})],1),t("el-form-item",{attrs:{label:"已售数量"}},[t("el-input",{staticStyle:{width:"160px"},model:{value:e.form.sold,callback:function(t){e.$set(e.form,"sold",t)},expression:"form.sold"}})],1)]],2),t("div",{staticClass:"card"},[t("div",{staticClass:"card-title"},[e._v("销售设置")]),t("el-form-item",{attrs:{label:"上架状态"}},[t("el-select",{staticStyle:{width:"200px"},model:{value:e.form.status,callback:function(t){e.$set(e.form,"status",t)},expression:"form.status"}},[t("el-option",{attrs:{label:"立即上架",value:"1"}}),t("el-option",{attrs:{label:"下架/隐藏",value:"0"}})],1)],1),t("el-form-item",{attrs:{label:"排序"}},[t("el-input",{staticStyle:{width:"160px"},attrs:{placeholder:"数字越大越靠前"},model:{value:e.form.inTurn,callback:function(t){e.$set(e.form,"inTurn",t)},expression:"form.inTurn"}})],1),t("el-form-item",{attrs:{label:"节日涨价"}},[t("el-radio-group",{model:{value:e.form.autoRise,callback:function(t){e.$set(e.form,"autoRise",t)},expression:"form.autoRise"}},[t("el-radio",{attrs:{label:"1"}},[e._v("参与")]),t("el-radio",{attrs:{label:"0"}},[e._v("不参与")])],1)],1),t("el-form-item",{attrs:{label:"运费"}},[t("el-radio-group",{model:{value:e.form.freightType,callback:function(t){e.$set(e.form,"freightType",t)},expression:"form.freightType"}},[t("el-radio",{attrs:{label:"1"}},[e._v("包运费")]),t("el-radio",{attrs:{label:"0"}},[e._v("不包运费")])],1)],1),t("el-form-item",{attrs:{label:"配送"}},[t("el-radio-group",{model:{value:e.form.needSend,callback:function(t){e.$set(e.form,"needSend",t)},expression:"form.needSend"}},[t("el-radio",{attrs:{label:"0"}},[e._v("支持送上门")]),t("el-radio",{attrs:{label:"1"}},[e._v("只能到店取")])],1)],1)],1)]),t("div",{staticClass:"footer-bar"},[t("el-button",{attrs:{size:"small"},on:{click:e.onCancel}},[e._v("取消")]),t("el-button",{attrs:{type:"primary",size:"small",loading:e.saving},on:{click:function(t){return e.submit(!1)}}},[e._v("保存")]),t("el-button",{attrs:{type:"primary",size:"small",loading:e.saving},on:{click:function(t){return e.submit(!0)}}},[e._v("保存并上架")])],1),t("el-dialog",{attrs:{title:"批量设置",visible:e.batchVisible,width:"420px","append-to-body":""},on:{"update:visible":function(t){e.batchVisible=t}}},[t("el-form",{attrs:{size:"small","label-width":"90px"}},[t("el-form-item",{attrs:{label:"销售价"}},[t("el-input",{attrs:{placeholder:"留空则不改"},model:{value:e.batchForm.price,callback:function(t){e.$set(e.batchForm,"price",t)},expression:"batchForm.price"}})],1),t("el-form-item",{attrs:{label:"库存"}},[t("el-input",{attrs:{placeholder:"留空则不改;填了即自定义库存"},model:{value:e.batchForm.stock,callback:function(t){e.$set(e.batchForm,"stock",t)},expression:"batchForm.stock"}})],1)],1),t("span",{attrs:{slot:"footer"},slot:"footer"},[t("el-button",{attrs:{size:"small"},on:{click:function(t){e.batchVisible=!1}}},[e._v("取消")]),t("el-button",{attrs:{type:"primary",size:"small"},on:{click:e.applyBatchSpec}},[e._v("确定")])],1)],1)],1)},s=[],a=r("ecc5"),o=r("f2ed"),l=r("c91c"),n=(r("e491"),r("0da6"),r("b138"),r("2153"),r("8f26"),r("d9d9"),r("666b"),r("963e"),r("209c"),r("f803"),r("6d35"),r("0401"),r("d27c"),r("b3c4"),r("adb4"),r("86d6"),r("2e12"),r("066b"),r("fddf"),r("e7bb"),r("f9da")),c={name:"bouquet-edit",components:{elxUpload:n["default"]},data:function(){return{loading:!1,saving:!1,isEdit:!1,categoryData:[],useCaseData:[],fileListShow:[],batchVisible:!1,batchForm:{price:"",stock:""},form:this.createEmptyForm(),rules:{name:[{required:!0,message:"请输入花束名称",trigger:"blur"}],categoryIdList:[{type:"array",required:!0,message:"请选择花束分类",trigger:"change"}]}}},created:function(){this.init()},methods:{createEmptyForm:function(){return{id:0,name:"",sn:"",price:"",sold:"0",priceType:"1",stockSet:"0",stock:999,categoryIdList:[],useCaseIdList:[],autoRise:"1",needSend:"0",freightType:"1",shopImg:[],status:"1",flower:1,flowerNum:0,weight:"1",cover:"",shortCover:"",specEnabled:0,specList:[],inTurn:0}},createSpecData:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=Array.isArray(t.shortImgList)?t.shortImgList:Array.isArray(t.shopImg)?t.shopImg:[],i=r.map((function(t){return e.normalizeImgPath(t)})).filter(Boolean),s=Array.isArray(t.smallImgList)?t.smallImgList:Array.isArray(t.currentImgData)?t.currentImgData:[],a=i[0]||"",o=i.map((function(e,t){return{url:s[t]||e,response:{shortUrl:e}}}));return{id:t.id||0,specName:t.specName||"",price:void 0!==t.price&&null!==t.price?t.price:"",priceType:String(void 0!==t.priceType&&null!==t.priceType?t.priceType:"1"),stock:void 0!==t.stock&&null!==t.stock?t.stock:999,stockSet:String(void 0!==t.stockSet&&null!==t.stockSet?t.stockSet:"0"),flowerNum:void 0!==t.flowerNum&&null!==t.flowerNum?t.flowerNum:0,weight:void 0!==t.weight&&null!==t.weight&&""!==t.weight?t.weight:1,sold:0,shopImg:i,cover:a,shortCover:a,fileListShow:o}},init:function(){var e=this;return Object(l["a"])(Object(o["a"])().m((function t(){var r;return Object(o["a"])().w((function(t){while(1)switch(t.p=t.n){case 0:return e.loading=!0,r=e.$route.query.id,e.isEdit=!!r,t.p=1,t.n=2,Promise.all([e.loadCategories(),e.loadUseCases()]);case 2:if(!e.isEdit){t.n=3;break}return t.n=3,e.loadDetail(r);case 3:return t.p=3,e.loading=!1,t.f(3);case 4:return t.a(2)}}),t,null,[[1,,3,4]])})))()},loadCategories:function(){var e=this;return this.$service.category.list({}).then((function(t){var r=Array.isArray(t)?t:t&&t.list||[];e.categoryData=r}))},loadUseCases:function(){var e=this;return this.$service.useCase.listAll({}).then((function(t){var r=Array.isArray(t)?t:t&&t.list||[];e.useCaseData=r}))},loadDetail:function(e){var t=this;return Object(l["a"])(Object(o["a"])().m((function r(){var i,s,a;return Object(o["a"])().w((function(r){while(1)switch(r.p=r.n){case 0:return r.n=1,t.$service.goods.info({id:e});case 1:if(i=r.v,i){r.n=2;break}return t.$message.error("商品信息不存在"),r.a(2);case 2:if(t.applyDetail(i),s=null!=i.sn?i.sn:0,!(Number(s)<=0)){r.n=7;break}return r.p=3,r.n=4,t.$service.goods.createSn({id:e});case 4:return r.n=5,t.$service.goods.info({id:e});case 5:a=r.v,a&&(t.form.sn=a.sn||""),r.n=7;break;case 6:r.p=6,r.v;case 7:return r.a(2)}}),r,null,[[3,6]])})))()},applyDetail:function(e){var t=this,r=this.createEmptyForm();Object.keys(r).forEach((function(t){void 0!==e[t]&&null!==e[t]&&(r[t]=e[t])})),r.id=e.id,r.sn=e.sn||"",r.categoryIdList=Array.isArray(e.categoryIdList)?e.categoryIdList.map(Number).filter((function(e){return e>0})):[],r.useCaseIdList=Array.isArray(e.useCaseIdList)?e.useCaseIdList.map(Number).filter((function(e){return e>0})):[],r.specEnabled=Number(e.specEnabled||0),r.specList=(e.specList||[]).map((function(e){return t.createSpecData(e)})),r.priceType=String("0"==e.priceType?"0":"1"),"0"===String(e.stockSet)?(r.stockSet="0",r.stock=999):(r.stockSet="1",r.stock=e.stock||""),r.status=String(null!=e.status?e.status:"1"),r.autoRise=String(null!=e.autoRise?e.autoRise:"1"),r.needSend=String(null!=e.needSend?e.needSend:"0"),r.freightType=String(null!=e.freightType?e.freightType:"1");var i=(e.shortImgList||[]).map((function(e){return t.normalizeImgPath(e)})).filter(Boolean);r.shopImg=i,r.shortCover=this.normalizeImgPath(e.shortCover||i[0]||""),r.cover=r.shortCover,r.inTurn=null!=e.inTurn?e.inTurn:0,this.form=r;var s=e.smallImgList||[],a=e.imgList||[];this.fileListShow=i.map((function(e,t){return{url:s[t]||a[t]||e,showBBGG:a[t],response:{shortUrl:e}}}))},normalizeImgPath:function(e){if(!e||"string"!==typeof e)return"";try{var t=e.indexOf("?"),r=t>=0?e.substring(0,t):e,i=r.match(/:\/\/[\w.-]+(:\d+)?(\/[^?#]+)$/),s="";if(i&&i[2])s=i[2];else if(r.startsWith("/"))s=r;else if(r.startsWith("//")){var a=r.indexOf("/",2);s=a>0?r.substring(a):""}else s=r;return s.replace(/^\//,"")}catch(o){return""}},onUploadChange:function(e){var t=e.fileList,r=this.extractShortUrls(t);this.form.shopImg=r,this.form.shortCover=r[0]||"",this.form.cover=r[0]||""},extractShortUrls:function(e){var t=this,r=[];return(e||[]).forEach((function(e){var i=e.response&&(e.response.shortUrl||e.response.smallShortUrl)||e.shortUrl||"",s=t.normalizeImgPath(i);s&&r.push(s)})),r},onSpecUploadChange:function(e,t){var r=t.fileList,i=this.extractShortUrls(r),s=Object(a["a"])(Object(a["a"])({},this.form.specList[e]),{},{shopImg:i,shortCover:i[0]||"",cover:i[0]||"",fileListShow:r||[]});this.$set(this.form.specList,e,s)},onPriceTypeChange:function(e){"0"===e?this.form.price="0":"0"===this.form.price&&(this.form.price="")},onStockSetChange:function(e){this.form.stock="0"===e?999:""},onToggleSpecs:function(e){1!=e||this.form.specList.length||this.form.specList.push(this.createSpecData())},addSpec:function(){this.form.specList.push(this.createSpecData())},removeSpec:function(e){this.form.specList.splice(e,1)},onSpecPriceType:function(e,t){var r=Object(a["a"])(Object(a["a"])({},this.form.specList[e]),{},{priceType:t});"0"===t?r.price=0:"0"===String(r.price)&&(r.price=""),this.$set(this.form.specList,e,r)},onSpecStockSet:function(e,t){var r=Object(a["a"])(Object(a["a"])({},this.form.specList[e]),{},{stockSet:t,stock:"0"===t?9999:""});this.$set(this.form.specList,e,r)},openBatchSpec:function(){this.batchForm={price:"",stock:""},this.batchVisible=!0},applyBatchSpec:function(){var e=this;this.form.specList=this.form.specList.map((function(t){var r=Object(a["a"])({},t);return""!==e.batchForm.price&&(r.priceType="1",r.price=e.batchForm.price),""!==e.batchForm.stock&&(r.stockSet="1",r.stock=e.batchForm.stock),r})),this.batchVisible=!1},validateSpecList:function(){if(1!=this.form.specEnabled)return!0;if(!this.form.specList.length)return this.$message.warning("请至少添加一个规格组"),!1;for(var e=0;e<this.form.specList.length;e++){var t=this.form.specList[e],r="规格组".concat(e+1);if(!t.specName||!String(t.specName).trim())return this.$message.warning("请输入".concat(r,"名称")),!1;if("1"===String(t.priceType)){var i=parseFloat(t.price);if(""===t.price||isNaN(i)||i<=0)return this.$message.warning("".concat(r,"价格必须是大于0的数字")),!1}if("1"===String(t.stockSet)){var s=parseFloat(t.stock);if(""===t.stock||isNaN(s)||s<0)return this.$message.warning("".concat(r,"库存数量必须是大于等于0的数字")),!1}if(!t.shopImg||!t.shopImg.length)return this.$message.warning("请为".concat(r,"上传商品图片")),!1}return!0},normalizeSpecSubmitData:function(e){var t=this;if(1!=e.specEnabled)return e.specList=[],e;e.specList=e.specList.map((function(e){var r=t.createSpecData(e);return r.priceType=parseInt(r.priceType),r.price=1===r.priceType?parseFloat(r.price||0):0,r.stockSet=parseInt(r.stockSet),r.stock=1===r.stockSet?parseInt(r.stock||0):9999,r.flowerNum=parseInt(r.flowerNum||0),r.weight=parseFloat(r.weight||0),r.sold=0,r.shopImg=(Array.isArray(r.shopImg)?r.shopImg:[]).map((function(e){return t.normalizeImgPath(e)})).filter(Boolean),r.cover=r.shopImg[0]||"",delete r.shortCover,delete r.fileListShow,r}));var r=e.specList[0];return e.priceType=String(r.priceType),e.price=r.price,e.stockSet=String(r.stockSet),e.stock=r.stock,e.flowerNum=r.flowerNum,e.weight=r.weight,e.sold=0,e},onCancel:function(){this.$router.push("/goods/bouquet")},submit:function(e){var t=this;this.$refs.formRef.validate((function(r){if(r&&t.validateSpecList())if(t.form.categoryIdList.length)if(t.form.shopImg&&t.form.shopImg.length){if(1!=t.form.specEnabled&&"1"===t.form.priceType){var i=parseFloat(t.form.price);if(""===t.form.price||isNaN(i)||i<=0)return void t.$message.warning("价格必须是大于0的数字")}var s,a=JSON.parse(JSON.stringify(t.form));e&&(a.status="1"),a.shopImg=(a.shopImg||[]).map((function(e){return t.normalizeImgPath(e)})).filter(Boolean),a.cover=t.normalizeImgPath(a.shortCover||a.shopImg[0]||""),a.shortCover=a.cover,a.specEnabled=Number(a.specEnabled)?1:0,a=t.normalizeSpecSubmitData(a),a.priceType=parseInt(a.priceType),a.stockSet=parseInt(a.stockSet),a.stock=1===a.stockSet?parseInt(a.stock||0):0===a.stockSet?9999:a.stock,a.sold=parseInt(a.sold||0),a.flowerNum=parseInt(a.flowerNum||0),a.weight=parseFloat(a.weight||1),a.status=parseInt(a.status),a.autoRise=parseInt(a.autoRise),a.needSend=parseInt(a.needSend),a.freightType=parseInt(a.freightType),delete a.sn,delete a.shortCover,t.saving=!0,t.isEdit?s=t.$service.goods.update(a):(a.catIds=a.categoryIdList,delete a.categoryIdList,delete a.id,s=t.$service.goods.add(a)),s.then((function(){t.$message.success("保存成功"),t.$router.push("/goods/bouquet")})).catch((function(){})).finally((function(){t.saving=!1}))}else t.$message.warning("请上传图片");else t.$message.warning("请选择分类")}))}}},p=c,u=(r("4ba4"),r("1805")),m=Object(u["a"])(p,i,s,!1,null,"3e988798",null);t["default"]=m.exports},"2e12":function(e,t,r){"use strict";var i=r("04c2"),s=r("4622"),a=r("5994").f,o=r("c26a"),l=r("bd47"),n=r("f03d"),c=r("5635"),p=r("94ee"),u=r("7d73"),m=s("".slice),f=Math.min,d=p("startsWith"),h=!u&&!d&&!!function(){var e=a(String.prototype,"startsWith");return e&&!e.writable}();i({target:"String",proto:!0,forced:!h&&!d},{startsWith:function(e){var t=l(c(this));n(e);var r=l(e),i=o(f(arguments.length>1?arguments[1]:void 0,t.length));return m(t,i,i+r.length)===r}})},"4ba4":function(e,t,r){"use strict";r("ec84")},d6c5:function(e,t,r){"use strict";var i=r("d240").PROPER,s=r("56ce"),a=r("2e27"),o="
";e.exports=function(e){return s((function(){return!!a[e]()||o[e]()!==o||i&&a[e].name!==e}))}},ec84:function(e,t,r){},f9da:function(e,t,r){"use strict";r.r(t);var i=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)},s=[],a=r("ecc5"),o=(r("0401"),r("5880")),l={name:"elx-upload",props:{limit:null,multiple:{type:Boolean,default:!0},fileList:{type:Array,default:[]},value:[Array,String],disabled:Boolean,category:Array},data:function(){var e=this.$service.common.upload();return{action:e.url,list:[],index:0,dialogImageUrl:"",dialogVisible:!1}},computed:Object(a["a"])({},Object(o["mapGetters"])(["token"])),mounted:function(){this.init()},methods:{init:function(){},httpRequest:function(e){var t=this,r=e.file;this.getBase64(r).then((function(r){t.$service.common.uploadImg({content:r,categoryId:t.category}).then((function(t){e.onSuccess(t)}))}))},beforeUpload:function(e){if(e.size/1024/1024>1)return this.$message.warning("上传的图片不能超过1M"),!1},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,r){this.$emit("update:fileList",r),this.$emit("success",{response:e,file:t,fileList:r})},getBase64:function(e){return new Promise((function(t,r){var i=new FileReader,s="";i.readAsDataURL(e),i.onload=function(){s=i.result},i.onerror=function(e){r(e)},i.onloadend=function(){t(s)}}))}}},n=l,c=r("1805"),p=Object(c["a"])(n,i,s,!1,null,"34293a5c",null);t["default"]=p.exports}}]);
|