chunk-4d5f.e0e144b0.js 20 KB

1
  1. (window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-4d5f"],{"1Qci":function(t,e,a){"use strict";var o=a("M/DC");a.n(o).a},"M/DC":function(t,e,a){},uGXJ:function(t,e,a){"use strict";a.r(e);var o=a("P2sY"),i=a.n(o),r=a("QbLZ"),s=a.n(r),l=a("t3Un"),n=a("Qyje"),d=a.n(n);var u=a("xAVR"),m=a("iXUw"),c={name:"Coupon",components:{Pagination:a("Mz3J").a},filters:{formatGmt:function(t){return null==t||""===t?"无":Object(m.formatDateAndTime)(t)},formatStatus:function(t){return 0===t?"下架":1===t?"正常":t<0?"已过期":"错误状态"},formatStatusBtn:function(t){return 1===t?"冻结":0===t?"激活":t<0?"已过期":"错误状态"}},data:function(){return{couponTypeMap:[{value:1,name:"满减卷"},{value:"",name:"全部"}],couponStatusMap:[{value:0,name:"下架"},{value:1,name:"正常"},{value:-1,name:"已过期"},{value:"",name:"全部"}],couponStatusOptions:[{value:1,name:"正常"},{value:0,name:"下架"}],couponTypeOptions:[{value:1,name:"满减卷"}],list:void 0,total:0,listLoading:!0,listQuery:{pageNo:1,limit:20,type:void 0,status:void 0,title:void 0},options:[],dataForm:{id:void 0,title:void 0,type:1,description:void 0,total:0,discount:0,limit:0,min:0,status:1,tag:void 0,categoryId:void 0,categoryTitle:void 0,goodsType:0,goodsValue:void 0,timeType:1,days:void 0,gmtStart:null,gmtEnd:null},dialogFormVisible:!1,dialogStatus:"",textMap:{update:"编辑",create:"创建"},rules:{title:[{required:!0,message:"优惠券标题不能为空",trigger:"blur"}],type:[{required:!0,message:"优惠券类型不能为空",trigger:"blur"}],total:[{required:!0,message:"优惠券总量不能为空",trigger:"blur"},{pattern:/^[0-9]*$/,message:"请输入整数"},{min:1,max:9,message:"大于1,小于1亿"}],limit:[{required:!0,message:"优惠券限领不能为空",trigger:"blur"},{pattern:/^[0-9]*$/,message:"请输入整数"},{min:1,max:9,message:"大于1,小于1亿"}],discount:[{required:!0,message:"优惠券折扣金额不能为空",trigger:"blur"},{pattern:/^[0-9]*$/,message:"请输入整数"},{min:1,max:9,message:"大于1,小于1亿"}],min:[{required:!0,message:"优惠券使用门栏不能为空",trigger:"blur"},{pattern:/^[0-9]*$/,message:"请输入整数"},{min:1,max:9,message:"大于1,小于1亿"}],status:[{required:!0,message:"优惠券状态不能为空",trigger:"blur"}]},downloadLoading:!1}},created:function(){this.getList()},methods:{getList:function(){var t=this;this.listLoading=!0,function(t){return Object(l.a)({method:"get",params:s()({_gp:"admin.coupon",_mt:"queryCouponByTitle"},t)})}(this.listQuery).then(function(e){e.data.data.items.forEach(function(t){var e=new Date;t.gmtEnd<e&&(t.status=-1),t.discount=t.discount/100,t.min=t.min/100}),t.list=e.data.data.items,t.total=e.data.data.total,t.listLoading=!1}).catch(function(){t.list=[],t.total=0,t.listLoading=!1})},handleFilter:function(){this.listQuery.pageNo=1,this.getList()},resetForm:function(){this.dataForm={id:void 0,title:void 0,desc:void 0,tag:void 0,total:0,discount:0,min:0,limit:0,type:1,status:1,goodsType:0,goodsValue:void 0,timeType:0,days:void 0,categoryId:void 0,categoryTitle:void 0,gmtStart:null,gmtEnd:null}},refreshOptions:function(){var t=this;0===this.options.length&&Object(u.b)().then(function(e){t.options=e.data.data})},handleLink:function(t){if(void 0!==t){var e=t[t.length-1];this.dataForm.categoryId=e}},handleCreate:function(){var t=this;this.resetForm(),this.dialogStatus="create",this.dialogFormVisible=!0,this.refreshOptions(),this.$nextTick(function(){t.$refs.dataForm.clearValidate()})},createData:function(){var t=this;if(null==this.dataForm.days&&(null==this.dataForm.gmtStart||null==this.dataForm.gmtEnd))return this.$notify.error({title:"失败",message:"请填写优惠卷使用区间"}),!1;if(1===this.dataForm.timeType){if(this.dataForm.days=void 0,this.dataForm.gmtEnd<this.dataForm.gmtStart||null==this.dataForm.gmtStart||null==this.dataForm.gmtEnd)return this.$notify.error({title:"失败",message:"请正确选择日期"}),!1;var e=new Date(this.dataForm.gmtStart),a=new Date(this.dataForm.gmtEnd);this.dataForm.gmtStart=e.getTime(),this.dataForm.gmtEnd=a.getTime()}else{if(null==this.dataForm.days||"0"===this.dataForm.days)return this.$notify.error({title:"失败",message:"请正确填写时长,不能为空或为0"}),!1;this.dataForm.gmtStart=void 0,this.dataForm.gmtEnd=void 0}if(0===parseInt(this.dataForm.goodsType)&&(this.dataForm.categoryId=void 0),parseInt(this.dataForm.discount)>parseInt(this.dataForm.min))return this.$notify.error({title:"失败",message:"满减门栏不能低于折扣金额,但是可以等于"}),!1;this.$refs.dataForm.validate(function(e){e&&(t.dataForm.discount=100*t.dataForm.discount,t.dataForm.min=100*t.dataForm.min,function(t){return Object(l.a)({method:"post",data:d.a.stringify(s()({_gp:"admin.coupon",_mt:"addCoupon"},t))})}(t.dataForm).then(function(e){t.getList(),t.dialogFormVisible=!1,t.$notify.success({title:"成功",message:"创建优惠券成功"})}).catch(function(e){t.$notify.error({title:"失败",message:e.data.errmsg})}))})},handleRead:function(t){var e=this;this.dataForm=i()({},t),this.dialogStatus="update",this.dialogFormVisible=!0,this.refreshOptions(),0===this.dataForm.days||null==this.dataForm.days?this.dataForm.timeType=1:this.dataForm.timeType=0,""===this.dataForm.categoryId||null==this.dataForm.categoryId?this.dataForm.goodsType=0:this.dataForm.goodsType=1,this.$nextTick(function(){e.$refs.dataForm.clearValidate()})},handleDelete:function(t){var e=this;this.$confirm("此操作将永久删除该优惠卷"+t.title+", 是否继续?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(function(){(function(t){return Object(l.a)({method:"get",params:s()({_gp:"admin.coupon",_mt:"deleteCoupon"},t)})})(t).then(function(a){e.$notify.success({title:"成功",message:"删除优惠券成功"});var o=e.list.indexOf(t);e.list.splice(o,1)}).catch(function(t){e.$notify.error({title:"失败",message:t.data.errmsg})})}).catch(function(){return!1})},handleStatus:function(t){var e=this;if(t.status<0)return this.$notify.error({title:"失败",message:"过期优惠卷,建议删除"}),!1;this.dataForm=i()({},t),this.dataForm.status=1===this.dataForm.status?0:1,function(t){return Object(l.a)({method:"post",data:d.a.stringify(s()({_gp:"admin.coupon",_mt:"updateCouponStatus"},t))})}(this.dataForm).then(function(a){e.$notify.success({title:"成功",message:"修改优惠券成功"}),t.status=1===t.status?0:1}).catch(function(t){e.$notify.error({title:"失败",message:t.data.errmsg})})},handleDownload:function(){var t=this,e=new Date,o=e.getFullYear()+"-"+e.getMonth()+"-"+e.getDate();this.downloadLoading=!0,Promise.all([a.e("chunk-04d5"),a.e("chunk-17d0")]).then(a.bind(null,"S/jZ")).then(function(e){e.export_json_to_excel2(["优惠券ID","名称","介绍","类型","最低消费","减免金额","每人限领","优惠券数量","剩余数量","状态","使用类目"],t.list,["id","title","description","type","min","discount","limit","total","surplus","status","cateotry"],o+" 优惠券信息"),t.downloadLoading=!1})}}},p=(a("1Qci"),a("KHd+")),g=Object(p.a)(c,function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"app-container"},[a("div",{staticClass:"filter-container"},[a("el-input",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{clearable:"",placeholder:"请输入优惠券标题"},model:{value:t.listQuery.title,callback:function(e){t.$set(t.listQuery,"title",e)},expression:"listQuery.title"}}),t._v(" "),a("el-select",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{clearable:"",placeholder:"请选择优惠券类型"},model:{value:t.listQuery.type,callback:function(e){t.$set(t.listQuery,"type",e)},expression:"listQuery.type"}},t._l(t.couponTypeMap,function(t,e){return a("el-option",{key:e,attrs:{label:t.name,value:t.value}})})),t._v(" "),a("el-select",{staticClass:"filter-item",staticStyle:{width:"200px"},attrs:{clearable:"",placeholder:"请选择优惠券状态"},model:{value:t.listQuery.status,callback:function(e){t.$set(t.listQuery,"status",e)},expression:"listQuery.status"}},t._l(t.couponStatusMap,function(t,e){return a("el-option",{key:e,attrs:{label:t.name,value:t.value}})})),t._v(" "),a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:coupon:query"],expression:"['promote:coupon:query']"}],staticClass:"filter-item",attrs:{type:"primary",icon:"el-icon-search"},on:{click:t.handleFilter}},[t._v("查找")]),t._v(" "),a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:coupon:create"],expression:"['promote:coupon:create']"}],staticClass:"filter-item",attrs:{type:"primary",icon:"el-icon-edit"},on:{click:t.handleCreate}},[t._v("添加")])],1),t._v(" "),a("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{"white-space":"pre-line"},attrs:{data:t.list,size:"small","element-loading-text":"正在查询中。。。",border:"",fit:"","highlight-current-row":""}},[a("el-table-column",{attrs:{align:"center",label:"优惠券ID",prop:"id",sortable:""}}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"优惠券名称",prop:"title"}}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"优惠券类型",prop:"type"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(t._s(t.couponTypeMap[e.row.type-1]?t.couponTypeMap[e.row.type-1].name:"错误类型"))]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"介绍",prop:"description"}}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"优惠券数量",prop:"total"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(t._s(e.row.total>=0?e.row.total:"不限"))]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"剩余数量",prop:"surplus"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(t._s(e.row.surplus>=0?e.row.surplus:"不限"))]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"每人限领",prop:"limit"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(t._s(e.row.limit>=0?e.row.limit:"不限"))]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"满减金额",prop:"discount"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v("减免"+t._s(e.row.discount)+"元")]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"最低消费",prop:"min"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v("满"+t._s(e.row.min)+"元可用")]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"状态",prop:"status"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-tag",[t._v(" "+t._s(t._f("formatStatus")(e.row.status))+" ")])]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"使用类目名称",prop:"categoryTitle",width:"100"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-tag",[t._v(" "+t._s(null!=e.row.categoryTitle?e.row.categoryTitle:"全部类目")+" ")])]}}])}),t._v(" "),a("el-table-column",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],attrs:{align:"center",label:"使用类目ID",prop:"categoryId",width:"100"}}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"领券相对天数",prop:"days"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(t._s(null!=e.row.days?e.row.days:"无"))]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"领券开始时间",prop:"gmtStart"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(t._s(t._f("formatGmt")(e.row.gmtStart)))]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"领券结束时间",prop:"gmtEnd"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(t._s(t._f("formatGmt")(e.row.gmtEnd)))]}}])}),t._v(" "),a("el-table-column",{attrs:{align:"center",label:"操作",width:"300","class-name":"small-padding fixed-width"},scopedSlots:t._u([{key:"default",fn:function(e){return[a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:coupon:update"],expression:"['promote:coupon:update']"}],attrs:{type:"primary",size:"mini"},on:{click:function(a){t.handleStatus(e.row)}}},[t._v(t._s(t._f("formatStatusBtn")(e.row.status)))]),t._v(" "),a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:coupon:update"],expression:"['promote:coupon:update']"}],attrs:{type:"info",size:"mini"},on:{click:function(a){t.handleRead(e.row)}}},[t._v("查看")]),t._v(" "),a("el-button",{directives:[{name:"permission",rawName:"v-permission",value:["promote:coupon:delete"],expression:"['promote:coupon:delete']"}],attrs:{type:"danger",size:"mini"},on:{click:function(a){t.handleDelete(e.row)}}},[t._v("删除")])]}}])})],1),t._v(" "),a("pagination",{directives:[{name:"show",rawName:"v-show",value:t.total>0,expression:"total>0"}],attrs:{total:t.total,page:t.listQuery.pageNo,limit:t.listQuery.limit},on:{"update:page":function(e){t.$set(t.listQuery,"pageNo",e)},"update:limit":function(e){t.$set(t.listQuery,"limit",e)},pagination:t.getList}}),t._v(" "),a("el-dialog",{attrs:{title:t.textMap[t.dialogStatus],visible:t.dialogFormVisible},on:{"update:visible":function(e){t.dialogFormVisible=e}}},[a("el-form",{ref:"dataForm",staticStyle:{width:"400px","margin-left":"50px"},attrs:{rules:t.rules,model:t.dataForm,"status-icon":"","label-position":"left","label-width":"100px"}},[a("el-form-item",{attrs:{label:"优惠券名称",prop:"title"}},[a("el-input",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.title,callback:function(e){t.$set(t.dataForm,"title",e)},expression:"dataForm.title"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"优惠卷类型",prop:"type"}},[a("el-select",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.type,callback:function(e){t.$set(t.dataForm,"type",e)},expression:"dataForm.type"}},t._l(t.couponTypeOptions,function(t,e){return a("el-option",{key:e,attrs:{label:t.name,value:t.value}})}))],1),t._v(" "),a("el-form-item",{attrs:{label:"介绍",prop:"description"}},[a("el-input",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.description,callback:function(e){t.$set(t.dataForm,"description",e)},expression:"dataForm.description"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"优惠券数量",prop:"total"}},[a("el-input",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.total,callback:function(e){t.$set(t.dataForm,"total",e)},expression:"dataForm.total"}},[a("template",{slot:"append"},[t._v("张")])],2)],1),t._v(" "),a("el-form-item",{attrs:{label:"每人限领",prop:"limit"}},[a("el-input",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.limit,callback:function(e){t.$set(t.dataForm,"limit",e)},expression:"dataForm.limit"}},[a("template",{slot:"append"},[t._v("张")])],2)],1),t._v(" "),a("el-form-item",{attrs:{label:"满减金额",prop:"discount"}},[a("el-input",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.discount,callback:function(e){t.$set(t.dataForm,"discount",e)},expression:"dataForm.discount"}},[a("template",{slot:"append"},[t._v("元")])],2)],1),t._v(" "),a("el-form-item",{attrs:{label:"最低消费",prop:"min"}},[a("el-input",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.min,callback:function(e){t.$set(t.dataForm,"min",e)},expression:"dataForm.min"}},[a("template",{slot:"append"},[t._v("元")])],2)],1),t._v(" "),a("el-form-item",{attrs:{label:"优惠卷状态",prop:"status"}},[a("el-select",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.status,callback:function(e){t.$set(t.dataForm,"status",e)},expression:"dataForm.status"}},t._l(t.couponStatusOptions,function(t,e){return a("el-option",{key:e,attrs:{label:t.name,value:t.value}})}))],1),t._v(" "),a("el-form-item",{attrs:{label:"有效期"}},[a("el-radio-group",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.timeType,callback:function(e){t.$set(t.dataForm,"timeType",e)},expression:"dataForm.timeType"}},[a("el-radio-button",{attrs:{label:0}},[t._v("领券相对天数")]),t._v(" "),a("el-radio-button",{attrs:{label:1}},[t._v("指定绝对时间")])],1)],1),t._v(" "),a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:0===t.dataForm.timeType,expression:"dataForm.timeType === 0"}],attrs:{prop:"days"}},[a("el-input",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.days,callback:function(e){t.$set(t.dataForm,"days",e)},expression:"dataForm.days"}},[a("template",{slot:"append"},[t._v("天")])],2)],1),t._v(" "),a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:1===t.dataForm.timeType,expression:"dataForm.timeType === 1"}],attrs:{prop:"time"}},[a("el-col",{attrs:{span:11}},[a("el-date-picker",{staticStyle:{width:"100%"},attrs:{disabled:"update"===t.dialogStatus,type:"datetime",placeholder:"选择日期"},model:{value:t.dataForm.gmtStart,callback:function(e){t.$set(t.dataForm,"gmtStart",e)},expression:"dataForm.gmtStart"}})],1),t._v(" "),a("el-col",{staticClass:"line",attrs:{span:2}},[t._v("至")]),t._v(" "),a("el-col",{attrs:{span:11}},[a("el-date-picker",{staticStyle:{width:"100%"},attrs:{disabled:"update"===t.dialogStatus,type:"datetime",placeholder:"选择日期"},model:{value:t.dataForm.gmtEnd,callback:function(e){t.$set(t.dataForm,"gmtEnd",e)},expression:"dataForm.gmtEnd"}})],1)],1),t._v(" "),a("el-form-item",{attrs:{label:"商品限制范围"}},[a("el-radio-group",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.goodsType,callback:function(e){t.$set(t.dataForm,"goodsType",e)},expression:"dataForm.goodsType"}},[a("el-radio-button",{attrs:{label:0}},[t._v("全场通用")]),t._v(" "),a("el-radio-button",{attrs:{label:1}},[t._v("指定分类")])],1)],1),t._v(" "),"update"===t.dialogStatus?a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:1===t.dataForm.goodsType,expression:"dataForm.goodsType === 1"}],attrs:{label:"优惠类目"}},[a("el-input",{attrs:{disabled:"update"===t.dialogStatus},model:{value:t.dataForm.categoryTitle,callback:function(e){t.$set(t.dataForm,"categoryTitle",e)},expression:"dataForm.categoryTitle"}})],1):t._e(),t._v(" "),"create"===t.dialogStatus?a("el-form-item",{directives:[{name:"show",rawName:"v-show",value:1===t.dataForm.goodsType,expression:"dataForm.goodsType === 1"}],attrs:{label:"优惠类目"}},[a("el-cascader",{attrs:{options:t.options,props:{checkStrictly:!0},placeholder:"优惠类目",filterable:""},on:{change:t.handleLink},model:{value:t.dataForm.categoryTitle,callback:function(e){t.$set(t.dataForm,"categoryTitle",e)},expression:"dataForm.categoryTitle"}})],1):t._e()],1),t._v(" "),a("div",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(e){t.dialogFormVisible=!1}}},[t._v("取消")]),t._v(" "),"create"==t.dialogStatus?a("el-button",{attrs:{type:"primary"},on:{click:t.createData}},[t._v("确定")]):t._e()],1)],1)],1)},[],!1,null,null,null);g.options.__file="coupon.vue";e.default=g.exports},xAVR:function(t,e,a){"use strict";a.d(e,"a",function(){return n}),a.d(e,"b",function(){return d}),a.d(e,"e",function(){return u}),a.d(e,"c",function(){return m}),a.d(e,"f",function(){return c}),a.d(e,"d",function(){return p});var o=a("QbLZ"),i=a.n(o),r=a("t3Un"),s=a("Qyje"),l=a.n(s);function n(){return Object(r.a)({method:"get",params:{_gp:"admin.category",_mt:"categorySecondLevelTree"}})}function d(){return Object(r.a)({method:"get",params:{_gp:"admin.category",_mt:"categoryTree"}})}function u(t){return Object(r.a)({method:"get",params:i()({_gp:"admin.category",_mt:"queryCategory"},t)})}function m(t){return Object(r.a)({method:"post",data:l.a.stringify(i()({_gp:"admin.category",_mt:"addCategory"},t))})}function c(t){return Object(r.a)({method:"post",data:l.a.stringify(i()({_gp:"admin.category",_mt:"updateCategory"},t))})}function p(t){return Object(r.a)({method:"post",params:{_gp:"admin.category",_mt:"deleteCategory",id:t}})}}}]);