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