define({ name: "promotion", template: `
单品优惠
设置为空或0,则不支持单品满件包邮
设置为空或0,则不支持单品满额包邮
{{json.ed_areas}}
添加不参加包邮的地区
余额设置
如果设置为0,则不赠送
如:购买两件,设置10余额,不管成交价格是多少,则购买后获得20余额
如:购买两件,设置10%余额,成交价格2*200=400,则购买后获得40余额(400*10%)
如果设置为0,则不赠送
如:购买两件,设置10余额,不管成交价格是多少,则购买后获得20余额
如:购买两件,设置10%余额,成交价格2*200=400,则购买后获得40余额(400*10%)
开启余额抵扣,订单使用余额抵扣则不能使用余额支付。关闭则不支持余额抵扣
抵扣金额不能大于商品现价
如果设置为空为0,则采用余额统一设置
积分设置
如果设置为空,则走积分统一设置
如果设置为0,则不赠送
如:购买2件,设置10积分,不管成交价格是多少,则购买后获得20积分
如:购买2件,设置10%积分,成交价格2*200=400,则购买后获得40积分(400*10%)

如果设置为空,则走积分统一设置
如果设置为0,则不赠送
如:购买2件,一级/二级设置10积分,不管成交价格是多少,则购买后一级/二级各获得20积分
如:购买2件,一级/二级设置10%积分,成交价格2*200=400,则购买后一级/二级各获得40积分(400*10%)
订单完成立即赠送 每月一号赠送 订单支付后赠送
固定金额 支付金额比例抵扣
按固定金额:抵扣金额不能大于商品现价
按比例抵扣:比例值为0-100的整数,设置最少抵扣不能大于最多抵扣
比例抵扣说明:例如商品原价100元填写5,即为抵扣5%的商品价格,积分可以抵扣5元
如果设置为空,则采用积分统一设置
如果设置为0,则不支持积分抵扣
其他设置
{{item.title}}
[ID:{{item.id}}]
选择商品
确 定 取 消
选择商品
搜索
`, style: ` .promotion .two-input { display:flex; } .promotion .overflow-2 { display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; } .promotion p { height:10px; } .promotion .el-radio { margin: 0px 30px 10px 0; } .promotion .el-input-group { width:300px; } .promotion .el-autocomplete{ width:90%; } .promotion .goods-item { display: flex; margin: 10px 0 0 10px; } .promotion .goods-item-left { display: flex; justify-content: center; } .promotion .goods-name { display: flex; align-items: center; } .promotion .goods-item-left span { display:block; margin-left:5px; } .promotion .goods-item-left img { width:30px; height:30px; } .promotion .goods-item-right { margin: 5px 0 0 200px; cursor: pointer; } .promotion .choose { width:600px; display:flex; flex-wrap: wrap; } .promotion .choose-item { position: relative; width:120px; margin: 10px; cursor: pointer; } .promotion .choose-item .close-item{ position: absolute; top:-7px; right:-7px; width:20px; height:20px; background-color: #ccc; border-radius:50%; text-align: center; } .promotion .choose-item .close-item .el-icon-close{ position: absolute; top: 3px; right: 3px; } .promotion .choose-item img { width:120px; height:120px; } .promotion .choose-item .goods-title { width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .promotion .add-goods { width:120px; height:120px; text-align: center; margin: 10px; cursor: pointer; border:1px dashed #a59f9f; } .promotion .add-goods i{ font-size:30px; margin-top:25px; } .promotion .area-dialog { width: 60%; height: 80%; overflow-y: scroll; } `, props: { form: { default() { return {}; }, }, http_url:{ type:String, default() { return ""; }, } }, data() { let intReg = /^[0-9]*$/; let floatReg = /^\d+(\.\d+)?$/; let rateReg = /^([0-9.]+)[ ]*%$/; // 整数校验 let intNum = (rule,value,callback)=>{ let regular = intReg.test(value); if(!value){ callback(); }else{ if (regular) { callback(); }else{ callback(new Error("请输入正整数")); } } }; // 浮点数校验 let floatNum = (rule,value,callback)=>{ let regular = floatReg.test(value); if(!value){ callback(); }else{ if (regular) { callback(); }else{ callback(new Error("请输入大于零或等于零的数字")); } } }; // 百分比校验 let rateNum = (rule, value, callback) => { let regular = floatReg.test(value); let regular2 = rateReg.test(value); if(!value){ callback(); }else{ if (regular || regular2) { callback(); }else{ callback(new Error("请输入大于零等于零的数字,或百分比")); } } }; return { rules: { ed_num: { validator: intNum }, ed_money: { validator: floatNum }, ed_full: { validator: floatNum }, ed_reduction: { validator: floatNum }, award_balance: { validator: rateNum }, pay_reward_balance: { validator: rateNum }, point: { validator: rateNum }, first_parent_point: { validator: rateNum }, second_parent_point: { validator: rateNum }, max_once_point: { validator: rateNum }, max_point_deduct: { validator: floatNum }, min_point_deduct: { validator: floatNum }, all_point_deduct: { validator: floatNum }, max_balance_deduct: { validator: floatNum }, min_balance_deduct: { validator: floatNum }, }, goodsDialog: false, areaDialog: false, areas: [], area_ids: [], province_ids: [], areaData: [], treeProps: { label: 'areaname', children: 'children', isLeaf: 'isLeaf' }, loading: false, goodsKey: "", goodsList: [], paginationOpt: { total: 0, pageSize: 1, page: 1, }, json: { ed_num: '', ed_money: '', ed_full: '', ed_areas: '', ed_areaids: '', ed_reduction: '', award_balance: '', pay_reward_balance: '', point: '', first_parent_point: '', second_parent_point: '', point_type: 0, max_once_point: '', point_deduct_type: 0, max_point_deduct: '', min_point_deduct: '', has_all_point_deduct: 0, all_point_deduct: '', balance_deduct: 0, max_balance_deduct:'', min_balance_deduct:'', is_push: 0, push_goods_ids: [], is_store:0 }, }; }, mounted() { if (this.form && this.form.sale) { let sale = this.form.sale; this.json.ed_num = sale.ed_num; this.json.ed_money = sale.ed_money; this.json.ed_full = sale.ed_full; this.json.ed_areas = sale.ed_areas; this.json.ed_areaids = sale.ed_areaids; this.json.ed_reduction = sale.ed_reduction; this.json.award_balance = sale.award_balance; this.json.is_store = sale.is_store; this.json.pay_reward_balance = sale.pay_reward_balance; this.json.point = sale.point; this.json.first_parent_point = sale.first_parent_point; this.json.second_parent_point = sale.second_parent_point; this.json.point_type = sale.point_type ? sale.point_type : 0; this.json.max_once_point = sale.max_once_point; this.json.point_deduct_type = sale.point_deduct_type; this.json.max_point_deduct = sale.max_point_deduct; this.json.min_point_deduct = sale.min_point_deduct; this.json.has_all_point_deduct = sale.has_all_point_deduct ? sale.has_all_point_deduct : 0; this.json.all_point_deduct = sale.all_point_deduct; this.json.balance_deduct = sale.balance_deduct ? sale.balance_deduct : 0; this.json.max_balance_deduct = sale.max_balance_deduct ? sale.max_balance_deduct : ''; this.json.min_balance_deduct = sale.min_balance_deduct ? sale.min_balance_deduct : ''; this.json.is_push = sale.is_push ? sale.is_push : 0; this.json.push_goods_ids = sale.push_goods_ids ? sale.push_goods_ids : []; } }, methods: { extraDate(){ }, async validate() { try { this.validateResult = await this.$refs['promotion'].validate(); } catch (err) { this.validateResult = false; } return this.validateResult ? this.json : false; }, openGoodsDialog() { this.goodsDialog = true; }, handleGoodsClose() { this.goodsDialog = false; }, // 地区 openAreaDialog() { this.areaDialog = true; if(this.area_ids){ this.area_ids.forEach((item, index) => { this.area_ids[index] = Number(item) }); } }, handleAreaClose() { this.areaDialog = false; }, loadNode(node, resolve) { this.loading = true; if (!node.data.id) { //省份 node.data.id = 0; this.$http.get(this.http_url + "area.list&parent_id=0").then(response => { response.data.data.forEach(function (province) { province.isLeaf = false; }); resolve(response.data.data); this.loading = false; }, response => { console.log(response); }); } else { //城市 this.$http.get(this.http_url + "area.list&parent_id=" + node.data.id).then(response => { //城市没有子节点 response.data.data.forEach(function (city) { city.isLeaf = true; }) resolve(response.data.data); // 载入数据后,刷新已选中 this.loading = false; }, response => { console.log(response); }); } }, checkAreas(node, checked, children) { if (node.isLeaf) { return; } if (checked) { if (!this.province_ids) { this.province_ids = []; } this.province_ids.push(node.id) } }, saveAreas() { let areas = []; let area_ids = []; let province_ids = []; this.$refs.addressTree.getCheckedNodes().forEach(function (node) { if (node.level == 1) { province_ids.push(node.id); } else if (node.level == 2) { area_ids.push(node.id); areas.push(node.areaname) } }); this.$refs.addressTree.getHalfCheckedNodes().forEach(function (node) { if (node.level == 1) { province_ids.push(node.id); } }); this.province_ids = province_ids; this.area_ids = area_ids; this.json.ed_areas = areas.join(";"); this.json.ed_areaids = area_ids.join(","); this.areaDialog = false }, // 商品 searchGoods (page=this.paginationOpt.page) { if (this.goodsKey === "") { return; } let params = "goods.goods.get-search-goods-json&keyword=" + this.goodsKey; if (typeof page === "number") { params = params + "&page=" + page; } this.$http.get(this.http_url + params).then(response => { if (response.data.result != 1) { return this.$message.error(response.data.msg); } let resultData = response.data.data.goods; this.goodsList = resultData ? resultData.data : []; this.paginationOpt.page = resultData.current_page; this.paginationOpt.total = resultData.total; this.paginationOpt.pageSize = resultData.per_page; }) .catch((err) => { this.$message.error(err); }) }, selectGoods(index) { let list = this.goodsList.slice(index, index + 1); let check = this.json.push_goods_ids.some(item=>item.id === list[0].id); if (check) { this.$message.error("已选择改商品,请勿重复选择"); } else { this.json.push_goods_ids.push(...list); this.goodsDialog = false; } }, deleteGoods(id) { this.json.push_goods_ids.some((item, i) => { if (item.id == id) { this.json.push_goods_ids.splice(i, 1); return true; } }); }, }, });