|
|
webpackJsonp([1],{10:function(e,t){e.exports=Vue},139:function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=a(140),r=a(18);Object(r.a)(o.a)},140:function(e,t,a){"use strict";function o(e){n||a(141)}var r=a(63),i=a(214),n=!1,s=a(0),l=o,u=s(r.a,i.a,!1,l,null,null);u.options.__file="src/views/coupon/index.vue",t.a=u.exports},141:function(e,t){},210:function(e,t,a){"use strict";function o(e){n||a(211)}var r=a(91),i=a(213),n=!1,s=a(0),l=o,u=s(r.a,i.a,!1,l,"data-v-35ed785d",null);u.options.__file="src/views/coupon/components/modal-create-coupon.vue",t.a=u.exports},211:function(e,t){},212:function(e,t){e.exports=XLSX},213:function(e,t,a){"use strict";var o=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("Modal",{attrs:{loading:e.posting,title:e.allreadonly?"查看优惠券":"创建/编辑优惠券",width:"600"},on:{"on-ok":e.onOk},model:{value:e.visiable,callback:function(t){e.visiable=t},expression:"visiable"}},[e.loading?a("Spin"):a("Form",{ref:"formCoupon",attrs:{rules:e.ruleValidate,model:e.formData,"label-width":80}},[a("FormItem",{staticClass:"form-group",attrs:{label:"优惠券类型"}}),e._v(" "),a("FormItem",{attrs:{label:"优惠券类型",prop:"couponType"}},[a("Select",{staticStyle:{width:"100px"},attrs:{disabled:e.readonly},model:{value:e.formData.couponType,callback:function(t){e.$set(e.formData,"couponType",t)},expression:"formData.couponType"}},[a("Option",{attrs:{value:0}},[e._v("请选择")]),e._v(" "),a("Option",{attrs:{value:100}},[e._v("活动券")]),e._v(" "),a("Option",{attrs:{value:110}},[e._v("运费券")])],1)],1),e._v(" "),a("FormItem",{staticClass:"form-group",attrs:{label:"基本信息"}}),e._v(" "),e.couponToken?a("FormItem",{attrs:{label:"Token"}},[e._v(e._s(e.couponToken))]):e._e(),e._v(" "),a("FormItem",{attrs:{label:"名称",prop:"couponName"}},[a("Input",{staticStyle:{width:"200px"},attrs:{placeholder:"名称建议30字以内",disabled:e.allreadonly},model:{value:e.formData.couponName,callback:function(t){e.$set(e.formData,"couponName",t)},expression:"formData.couponName"}})],1),e._v(" "),a("FormItem",{attrs:{label:"数量",prop:"couponNum"}},[a("InputNumber",{staticStyle:{width:"100px"},attrs:{placeholder:"数量",disabled:e.allreadonly},model:{value:e.formData.couponNum,callback:function(t){e.$set(e.formData,"couponNum",t)},expression:"formData.couponNum"}})],1),e._v(" "),a("FormItem",{attrs:{label:"使用次数",prop:"useNum"}},[a("Input",{staticStyle:{width:"100px"},attrs:{placeholder:"使用次数",disabled:""},model:{value:e.formData.useNum,callback:function(t){e.$set(e.formData,"useNum",t)},expression:"formData.useNum"}})],1),e._v(" "),a("FormItem",{attrs:{label:"使用期限",prop:"time"}},[a("DatePicker",{staticStyle:{width:"250px"},attrs:{type:"datetimerange",disabled:e.allreadonly,placeholder:"使用期限",format:"yyyy-MM-dd HH:mm:ss"},model:{value:e.formData.time,callback:function(t){e.$set(e.formData,"time",t)},expression:"formData.time"}})],1),e._v(" "),a("FormItem",{attrs:{label:"领券期限",prop:"receiveTime"}},[a("DatePicker",{staticStyle:{width:"250px"},attrs:{type:"datetimerange",disabled:e.readonly,placeholder:"领券期限",format:"yyyy-MM-dd HH:mm:ss"},model:{value:e.formData.receiveTime,callback:function(t){e.$set(e.formData,"receiveTime",t)},expression:"formData.receiveTime"}})],1),e._v(" "),a("FormItem",{attrs:{label:"优惠券说明",prop:"remark"}},[a("Input",{attrs:{type:"textarea",placeholder:"优惠券使用条件简介",disabled:e.allreadonly},model:{value:e.formData.remark,callback:function(t){e.$set(e.formData,"remark",t)},expression:"formData.remark"}})],1),e._v(" "),a("FormItem",{staticClass:"form-group",attrs:{label:"使用条件"}}),e._v(" "),a("FormItem",{staticStyle:{display:"inline-block",width:"100%"},attrs:{label:"优惠条件",prop:"useLimitType"}},[a("Select",{staticStyle:{width:"100px"},attrs:{disabled:e.readonly},model:{value:e.formData.useLimitType,callback:function(t){e.$set(e.formData,"useLimitType",t)},expression:"formData.useLimitType"}},[a("Option",{attrs:{value:0}},[e._v("无限制")]),e._v(" "),a("Option",{attrs:{value:2}},[e._v("金额")])],1),e._v(" "),2===e.formData.useLimitType?a("div",{staticStyle:{display:"inline-block"}},[e._v("\n \n 金额满:\n "),a("InputNumber",{staticStyle:{width:"100px"},attrs:{disabled:e.readonly,placeholder:"限制金额"},model:{value:e.formData.useLimitValue,callback:function(t){e.$set(e.formData,"useLimitValue",t)},expression:"formData.useLimitValue"}})],1):e._e()],1),e._v(" "),a("FormItem",{attrs:{label:"优惠金额",prop:"couponAmount"}},[a("InputNumber",{staticStyle:{width:"100px"},attrs:{placeholder:"优惠金额",disabled:e.readonly},model:{value:e.formData.couponAmount,callback:function(t){e.$set(e.formData,"couponAmount",t)},expression:"formData.couponAmount"}})],1),e._v(" "),a("FormItem",{attrs:{label:"适用范围",prop:"productLimitType"}},[a("Select",{staticStyle:{width:"100px"},attrs:{disabled:e.readonly},model:{value:e.formData.productLimitType,callback:function(t){e.$set(e.formData,"productLimitType",t)},expression:"formData.productLimitType"}},[a("Option",{attrs:{value:1}},[e._v("指定商品")]),e._v(" "),a("Option",{attrs:{value:2}},[e._v("全部商品")]),e._v(" "),a("Option",{attrs:{value:3}},[e._v("排除商品")])],1)],1),e._v(" "),1===e.formData.productLimitType||3===e.formData.productLimitType?a("FormItem",{attrs:{prop:"productLimitValue"}},[a("Input",{attrs:{type:"textarea",disabled:e.readonly,placeholder:"填写商品编码,多个商品编码用英文逗号分隔"},model:{value:e.formData.productLimitValue,callback:function(t){e.$set(e.formData,"productLimitValue",t)},expression:"formData.productLimitValue"}}),e._v(" "),a("Poptip",{attrs:{trigger:"hover"}},[a("div",{attrs:{slot:"content"},slot:"content"},[a("p",[e._v("1.上传文件必须是xlsx文件")]),e._v(" "),a("p",[e._v("2.第一行标题栏:商品编码")]),e._v(" "),a("p",[e._v("\n 3.\n "),a("a",{attrs:{href:"javascript:;"},on:{click:e.onExample}},[e._v("下载样例")])])]),e._v(" "),a("Upload",{attrs:{action:"",format:["xlsx"],"max-size":1024,"before-upload":e.onBeforeUpload}},[a("Button",{attrs:{type:"success",size:"small",disabled:e.readonly}},[e._v("导入")]),e._v(" "),a("p",[e._v(e._s(e.uploadTxt))])],1)],1)],1):e._e(),e._v(" "),a("FormItem",{attrs:{label:"可用商品类型"}},[a("checkbox-group",{on:{"on-change":e.getCheckBox},model:{value:e.formData.skupAllowTypeLabel,callback:function(t){e.$set(e.formData,"skupAllowTypeLabel",t)},expression:"formData.skupAllowTypeLabel"}},[a("checkbox",{attrs:{label:"极速发货",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"极速寄存",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"预售",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"瑕疵",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"二手",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"海外直邮",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"现货发货",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"现货寄存",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"闪购发货",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"闪购寄存",disabled:e.readonly}})],1)],1),e._v(" "),a("FormItem",{attrs:{label:"购买渠道",prop:"useLimitType"}},[a("checkbox-group",{on:{"on-change":e.getChannelCheckBox},model:{value:e.formData.businessClientLabel,callback:function(t){e.$set(e.formData,"businessClientLabel",t)},expression:"formData.businessClientLabel"}},[a("checkbox",{attrs:{label:"UFO",disabled:e.readonly}}),e._v(" "),a("checkbox",{attrs:{label:"闲鱼",disabled:e.readonly}})],1)],1),e._v(" "),a("FormItem",{attrs:{label:"需要校验",prop:"checkRequired"}},[a("checkbox",{attrs:{disabled:e.allreadonly},on:{"on-change":e.getCheckRequired},model:{value:e.formData.isCheckRequired,callback:function(t){e.$set(e.formData,"isCheckRequired",t)},expression:"formData.isCheckRequired"}})],1)],1)],1)},r=[];o._withStripped=!0;var i={render:o,staticRenderFns:r};t.a=i},214:function(e,t,a){"use strict";var o=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("LayoutContent",{attrs:{breads:[{title:"优惠券列表"}]}},[a("LayoutFilter",{on:{"on-filter":e.onFilter,"on-clear":e.onClear}},[a("Form",{ref:"filterForm",attrs:{inline:"",model:e.filter}},[a("FormItem",{attrs:{prop:"id"}},[a("Input",{attrs:{placeholder:"输入ID"},model:{value:e.filter.id,callback:function(t){e.$set(e.filter,"id",t)},expression:"filter.id"}})],1),e._v(" "),a("FormItem",{attrs:{prop:"name"}},[a("Input",{attrs:{placeholder:"输入券名称"},model:{value:e.filter.name,callback:function(t){e.$set(e.filter,"name",t)},expression:"filter.name"}})],1),e._v(" "),a("FormItem",{attrs:{prop:"status"}},[a("Select",{staticStyle:{width:"100px"},attrs:{placeholder:"选择状态"},model:{value:e.filter.status,callback:function(t){e.$set(e.filter,"status",t)},expression:"filter.status"}},[a("Option",{attrs:{value:0}},[e._v("未生效")]),e._v(" "),a("Option",{attrs:{value:1}},[e._v("生效中")]),e._v(" "),a("Option",{attrs:{value:2}},[e._v("已过期")]),e._v(" "),a("Option",{attrs:{value:3}},[e._v("已作废")])],1)],1),e._v(" "),a("FormItem",{attrs:{prop:"time"}},[a("DatePicker",{staticStyle:{width:"250px"},attrs:{type:"datetimerange",placeholder:"开始-结束时间",format:"yyyy-MM-dd HH:mm"},model:{value:e.filter.time,callback:function(t){e.$set(e.filter,"time",t)},expression:"filter.time"}})],1)],1)],1),e._v(" "),a("LayoutTools",[a("Button",{attrs:{type:"success",icon:"md-add"},on:{click:e.onCreateCoupon}},[e._v("新增优惠券")])],1),e._v(" "),a("LayoutTable",{attrs:{page:e.page,total:e.total,columns:e.columns,data:e.data},on:{"on-page-change":e.onPageChange}},[a("template",{staticClass:"btns",slot:"footer"},[a("Button",{attrs:{type:"primary",icon:"ios-cloud-download"},on:{click:e.onExport}},[e._v("导出")])],1)],2),e._v(" "),a("ModalCreateCoupon",{ref:"modalCreateCoupon",on:{"on-created":e.onCreated}})],1)},r=[];o._withStripped=!0;var i={render:o,staticRenderFns:r};t.a=i},5:function(e,t){e.exports=iview},63:function(e,t,a){"use strict";var o=a(13),r=a.n(o),i=a(21),n=a.n(i),s=a(22),l=a.n(s),u=a(5),c=(a.n(u),a(16)),m=a(17),p=a.n(m),d=a(44),f=a(27),v=a.n(f),h=a(210),y=new c.a;t.a={name:"CouponPage",data:function(){var e=this;this.$createElement;return{filter:{id:"",name:"",status:"",time:["",""]},page:1,total:0,data:[],columns:[{title:"ID",key:"id",width:80},{title:"券名称",key:"name",width:180},{title:"token",key:"token",width:180},{title:"数量",key:"couponNum",width:90},{title:"已发放",key:"sendNum",width:90},{title:"已使用",key:"useNum",width:90},{title:"使用期限",key:"useTime",width:165},{title:"优惠券说明",key:"remark",align:"center",width:150},{title:"状态",align:"center",key:"status"},{title:"操作",align:"center",width:200,render:function(t,a){var o=a.row;return t("div",[t(u.Button,{attrs:{type:"success",size:"small"},on:{click:function(){return e.onEditCoupon(o,!0,!0)}}},["查看详情"]),"未生效"===o.status||"生效中"===o.status?t(u.Button,{attrs:{type:"primary",size:"small"},on:{click:function(){return e.onEditCoupon(o)}}},["修改"]):void 0,t(u.Button,{attrs:{type:"warning",size:"small"},on:{click:function(){return e.onToRecord(o)}}},["发放记录"]),"未生效"===o.status||"生效中"===o.status?t(u.Button,{attrs:{type:"success",size:"small"},on:{click:function(){return e.onSendCoupon(o)}}},["发券"]):void 0])}}]}},created:function(){var e=this;this.$nextTick(function(){var t=v.a.parse(location.search?location.search.slice(1):""),a=t.page,o=t.id,r=t.name,i=t.status,n=t.startTime,s=t.endTime;e.filter.id=o||e.filter.id,e.filter.name=r?decodeURIComponent(r):e.filter.name,e.filter.status=i?parseInt(i):e.filter.status,e.filter.time=n&&s?[p()(n),p()(s)]:e.filter.time,e.page=a?parseInt(a):1,e.fetchData(e.filter,e.page)})},methods:{onToRecord:function(e){var t=e.id;location.href="send-record.html?"+v.a.stringify({id:t,param:{id:this.filter.id||void 0,name:this.filter.name||void 0,status:this.filter.status||void 0,startTime:this.filter.time[0]||void 0,endTime:this.filter.time[1]||void 0,page:this.page||void 0}})},onSendCoupon:function(e){var t=e.id,a=e.token;t&&a&&(location.href="send-coupon.html?"+v.a.stringify({id:t,token:a}))},onCreated:function(){this.fetchData(this.filter)},onFilter:function(){this.fetchData(this.filter)},onClear:function(){this.$refs.filterForm.resetFields(),this.fetchData(this.filter)},onPageChange:function(e){this.fetchData(this.filter,e)},onCreateCoupon:function(){this.$refs.modalCreateCoupon.show()},onEditCoupon:function(e,t,a){var o=e.id;e.sendNum>0&&(t=!0),this.$refs.modalCreateCoupon.show(o,t,a)},onExport:function(){var e=this;return l()(n.a.mark(function t(){var a;return n.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e.$Loading.start(),t.next=3,y._get("/ufoPlatform/coupon/export",{param:{method:"coupon",param:y._2params(e.getParams(e.filter))}},{responseType:"blob"});case 3:a=t.sent,a instanceof Blob?(d.a.downloadBlob(a,"优惠券导出_"+p()().format("YYYY-MM-DD")+".xlsx"),e.$Loading.finish()):a&&(a.message&&e.$Message.warning(a.message),e.$Loading.error());case 5:case"end":return t.stop()}},t,e)}))()},fetchData:function(e){var t=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return l()(n.a.mark(function o(){var i;return n.a.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return t.page=a,t.$Loading.start(),o.next=4,y._get("/ufoPlatform/coupon/queryCoupons",r()({page:a},t.getParams(e)));case 4:i=o.sent,200===i.code?(t.total=i.data.total,t.data=i.data.coupons,t.$Loading.finish()):(i.message&&t.$Message.warning(i.message),t.$Loading.error());case 6:case"end":return o.stop()}},o,t)}))()},getParams:function(e){var t=e.time[0]?p()(e.time[0]).unix():void 0,a=e.time[1]?p()(e.time[1]).unix():void 0,o=parseInt(e.status)>=0?e.status:void 0,r=p()().unix();return{id:e.id,name:e.name,status:o,startTime:t,endTime:a,curTime:r}}},components:{ModalCreateCoupon:h.a}}},91:function(e,t,a){"use strict";var o=a(21),r=a.n(o),i=a(22),n=a.n(i),s=a(16),l=a(17),u=a.n(l),c=a(212),m=a.n(c),p=new s.a,d={"极速发货":"9-N","极速寄存":"9-Y","预售":"4","瑕疵":"5","二手":"6","海外直邮":"17","现货发货":"1-N","现货寄存":"1-Y","闪购发货":"3-N","闪购寄存":"3-Y"},f={"9-N":"极速发货","9-Y":"极速寄存",4:"预售",5:"瑕疵",6:"二手",17:"海外直邮","1-N":"现货发货","1-Y":"现货寄存","3-N":"闪购发货","3-Y":"闪购寄存"},v={UFO:"ufo","闲鱼":"h5/xianyu"},h={ufo:"UFO","h5/xianyu":"闲鱼"};t.a={components:{},name:"ModalCreateCoupon",data:function(){var e=this;return{readonly:!1,allreadonly:!1,visiable:!1,loading:!1,posting:!0,uploadTxt:"",couponToken:"",formData:{id:0,couponName:"",couponType:0,couponNum:0,useNum:1,couponAmount:0,useLimitType:0,remark:"",productLimitType:2,productLimitValue:"",useLimitValue:0,time:["",""],receiveTime:["",""],skupAllowTypeLabel:[],skupAllowType:"",businessClient:"",checkRequired:0,isCheckRequired:!0},ruleValidate:{couponType:{required:!0,validator:function(e,t,a){0===t||"0"===t?a(new Error("请选择优惠券类型")):a()}},couponName:{required:!0,max:30,message:"请输入名称"},couponNum:{type:"number",required:!0,min:1,message:"请输入数量"},couponAmount:{type:"number",required:!0,min:1,message:"请输入优惠金额"},time:{required:!0,validator:function(e,t,a){t.some(function(e){return!e})?a(new Error("请选择使用期限")):a()}},receiveTime:{required:!0,validator:function(t,a,o){if(a.some(function(e){return!e}))o(new Error("请选择领券期限"));else{(e.formData.time[1]?u()(e.formData.time[1]).unix():void 0)<(a[1]?u()(a[1]).unix():void 0)?o(new Error("请选择领券结束时间小于使用结束时间")):o()}}},remark:{required:!0,message:"请输入优惠券说明"},useLimitType:{required:!0,validator:function(t,a,o){a>=0?2===a?parseInt(e.formData.useLimitValue)>0?o():o(new Error("请输入限制金额")):o():o(new Error("请选择优惠条件"))}},productLimitValue:{required:!1,validator:function(e,t,a){var o=(t||"").split(",");t&&o.length?o.some(function(e){return!!e&&!parseInt(e)})?a(new Error("适用范围格式错误")):a():a(new Error("请输入适用范围"))}},productLimitType:{required:!0,validator:function(e,t,a){1===t||2===t||3===t?a():a(new Error("请选择类型"))}}}}},methods:{show:function(e,t,a){var o=this;return n()(r.a.mark(function i(){var n,s,l,c,m,d,v,y,b,k,x;return r.a.wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(o.readonly=t,o.allreadonly=a,o.posting=o.visiable=!0,o.$refs.formCoupon.resetFields(),o.couponToken="",n={id:0,couponName:"",couponNum:0,couponType:0,useNum:1,couponAmount:0,useLimitType:0,remark:"",productLimitValue:"",productLimitType:2,useLimitValue:0,time:["",""],skupAllowTypeLabel:[],skupAllowType:"",businessClientLabel:[],businessClient:"",checkRequired:0},!e){r.next=13;break}return o.loading=!0,r.next=10,p._get("/ufoPlatform/coupon/getCouponInfo",{id:e});case 10:if(s=r.sent,o.loading=!1,200===s.code){if(l=s.data.coupon,c=s.data.productLimits,o.couponToken=l.couponToken,m=[],l.skupAllowType)for(d=l.skupAllowType.split(","),v=0;v<d.length;v++)m.push(f[d[v]]);if(y=[],l.businessClient)for(b=l.businessClient.split(","),k=0;k<b.length;k++)y.push(h[b[k]]);x=1===l.checkRequired,console.log("=====:"+x),n={id:e,couponName:l.couponName,couponNum:l.couponNum,couponType:l.couponType||0,useNum:l.useNum,couponAmount:l.couponAmount,useLimitType:l.useLimitType,remark:l.remark,productLimitType:l.productLimitType,productLimitValue:(c||[]).map(function(e){return e.productId}).join(","),useLimitValue:l.useLimitValue,time:[u.a.unix(l.startTime).format("YYYY-MM-DD HH:mm:ss"),u.a.unix(l.endTime).format("YYYY-MM-DD HH:mm:ss")],receiveTime:[u.a.unix(l.receiveStartTime).format("YYYY-MM-DD HH:mm:ss"),u.a.unix(l.receiveEndTime).format("YYYY-MM-DD HH:mm:ss")],skupAllowTypeLabel:m,skupAllowType:l.skupAllowType,businessClientLabel:y,businessClient:l.businessClient,checkRequired:l.checkRequired,isCheckRequired:x}}else s.message&&o.$Message.warning(s.message);case 13:o.formData=n;case 14:case"end":return r.stop()}},i,o)}))()},onOk:function(){var e=this;this.$refs.formCoupon.validate(function(t){t?e.saveData(e.formData):(e.posting=!1,e.$nextTick(function(){e.posting=!0}))})},getCheckRequired:function(e){this.formData.checkRequired=e?1:0},getCheckBox:function(){for(var e=[],t=0;t<this.formData.skupAllowTypeLabel.length;t++){var a=this.formData.skupAllowTypeLabel[t];e.push(d[a])}this.formData.skupAllowType=e.join(",")},getChannelCheckBox:function(){for(var e=[],t=0;t<this.formData.businessClientLabel.length;t++){var a=this.formData.businessClientLabel[t];e.push(v[a])}this.formData.businessClient=e.join(",")},saveData:function(e){var t=this;return n()(r.a.mark(function a(){var o;return r.a.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!t.allreadonly){a.next=3;break}return t.visiable=!1,a.abrupt("return");case 3:return a.next=5,p._post("/ufoPlatform/coupon/saveOrUpdateCoupon",{id:e.id||void 0,couponName:e.couponName,couponAmount:e.couponAmount,couponNum:e.couponNum,couponType:e.couponType,useNum:e.useNum,useLimitValue:e.useLimitValue,productLimitType:e.productLimitType,productLimitValue:e.productLimitValue,remark:e.remark,useLimitType:parseInt(e.useLimitType)>=0?e.useLimitType:void 0,startTime:e.time[0]?u()(e.time[0]).unix():void 0,endTime:e.time[1]?u()(e.time[1]).unix():void 0,skupAllowType:e.skupAllowType,businessClient:e.businessClient,receiveStartTime:e.receiveTime[0]?u()(e.receiveTime[0]).unix():void 0,receiveEndTime:e.receiveTime[1]?u()(e.receiveTime[1]).unix():void 0,checkRequired:e.checkRequired});case 5:o=a.sent,200===o.code?(t.$Message.success("保存成功"),t.visiable=!1,t.$emit("on-created")):(o.message&&t.$Message.warning(o.message),t.posting=!1,t.$nextTick(function(){t.posting=!0}));case 7:case"end":return a.stop()}},a,t)}))()},onBeforeUpload:function(e){var t=this;if("xlsx"!==e.name.split(".").pop().toLocaleLowerCase())return this.$Message.warning("文件格式错误"),!1;if(e.size>1048576)return this.$Message.warning("文件大小超过1M"),!1;var a=new FileReader;return a.readAsArrayBuffer(e),a.onloadstart=function(){t.uploadTxt="开始读取"},a.onprogress=function(e){t.uploadTxt="进度:"+Math.round(e.loaded/e.total*100)+"..."},a.onerror=function(){t.uploadTxt="文件读取出错"},a.onload=function(e){t.uploadTxt="";try{var a=e.target.result,o=m.a.read(a,{type:"array"}),r=o.SheetNames[0],i=o.Sheets[r],n=m.a.utils.sheet_to_json(i);t.formData.productLimitValue=n.map(function(e){return e["商品编码"]}).filter(function(e){return e}).join(",")}catch(e){t.uploadTxt="文件解析失败,请按照格式上传"}},!1},onExample:function(){var e=m.a.utils.book_new(),t=m.a.utils.json_to_sheet([{"商品编码":"123456"}]);m.a.utils.book_append_sheet(e,t,"优惠券适用范围示例"),m.a.writeFile(e,"优惠券适用范围示例.xlsx")}}}}},[139]); |