define({ name:"weight_value", template:`
关闭 开启
仅存在经销商身份的用户可以获得权重值
代理商:仅距离最近的第一个代理商有奖励
`, style:` .ladder-content{ min-width: 550px!important; } .ladder-content .ladder-row{ margin-bottom: 5px!important; } .ladder-content .ladder-row .ladder-input{ width: 230px!important; } `, props: { form: { default() { return {} } } }, data() { return { json: { is_open: 0,// 是否开启购买商品赠送权重值:0=未开启,1=开启 is_self_purchase: 0,// 是否开启自购:0=不开启,1=开启 gift_type: 0,// 赠送方式:0=赠送固定值,1=阶梯值赠送 lv_type: 0,// 赠送方式:0=二级,1=三级 calculation_type: 0,// 计算类型:0=固定值,1=支付比例 quantity: 0,// 赠送数量 ladder: {},// 阶梯赠送信息 agent_gift_type: 0,// 赠送方式:0=赠送固定值,1=阶梯值赠送 agent_calculation_type: 0,// 计算类型:0=固定值,1=支付比例 agent_quantity: 0,// 赠送数量 agent_ladder: {},// 阶梯赠送信息 province_gift_type: 0,// 赠送方式:0=赠送固定值,1=阶梯值赠送 province_calculation_type: 0,// 计算类型:0=固定值,1=支付比例 province_quantity: 0,// 赠送数量 province_ladder: {},// 阶梯赠送信息 } } }, watch: { }, mounted() { if (this.form) { let weight_value = this.form || {}; console.log('商品权重值设置信息'); console.log(weight_value); this.json.is_open = weight_value.is_open ? weight_value.is_open : 0; this.json.is_self_purchase = weight_value.is_self_purchase ? weight_value.is_self_purchase : 0; this.json.gift_type = weight_value.gift_type ? weight_value.gift_type : 0; this.json.lv_type = weight_value.lv_type ? weight_value.lv_type : 0; this.json.calculation_type = weight_value.calculation_type ? weight_value.calculation_type : 0; this.json.quantity = weight_value.quantity ? weight_value.quantity : 0; this.json.ladder = weight_value.ladder ? JSON.parse(weight_value.ladder) : {}; this.json.agent_gift_type = weight_value.agent_gift_type ? weight_value.agent_gift_type : 0; this.json.agent_calculation_type = weight_value.agent_calculation_type ? weight_value.agent_calculation_type : 0; this.json.agent_quantity = weight_value.agent_quantity ? weight_value.agent_quantity : 0; this.json.agent_ladder = weight_value.agent_ladder ? JSON.parse(weight_value.agent_ladder) : {}; this.json.province_gift_type = weight_value.province_gift_type ? weight_value.province_gift_type : 0; this.json.province_calculation_type = weight_value.province_calculation_type ? weight_value.province_calculation_type : 0; this.json.province_quantity = weight_value.province_quantity ? weight_value.province_quantity : 0; this.json.province_ladder = weight_value.province_ladder ? JSON.parse(weight_value.province_ladder) : {}; } }, methods:{ addLadder(type = ''){ if(type === 'agent') this.json.agent_ladder = Object.values(this.json.agent_ladder).concat({where: '', num: ''}); else if(type === 'province') this.json.province_ladder = Object.values(this.json.province_ladder).concat({where: '', num: ''}); else this.json.ladder = Object.values(this.json.ladder).concat({where: '', num: ''}); }, delLadder(index,type = ''){ let ladder = {}; if(type === 'agent') ladder = Object.assign({},this.json.agent_ladder); else if(type === 'province') ladder = Object.assign({},this.json.province_ladder); else ladder = Object.assign({},this.json.ladder); delete ladder[index]; if(type === 'agent') this.json.agent_ladder = Object.values(ladder); else if(type === 'province') this.json.province_ladder = Object.values(ladder); else this.json.ladder = Object.values(ladder); }, validate(){ let json = this.json; // console.log("权重值信息处理 - validate:"); // console.log(json); if(parseInt(json.calculation_type) === 1){ if(json.gift_type == 1){ let isPass = false; Object.values(json.ladder).forEach((item,index)=>{ if(item.num <= 0 || item.num > 100) isPass = true; }); if(isPass) { this.$message.error('经纪人设置-赠送数量比例不能小于等于0或者大于100') return false } }else{ if(json.quantity <= 0 || json.quantity > 100){ this.$message.error('经纪人设置-赠送数量比例不能小于等于0或者大于100') return false } } } if(parseInt(json.agent_calculation_type) === 1){ if(json.agent_gift_type == 1){ let isPass = false; Object.values(json.agent_ladder).forEach((item,index)=>{ if(item.num <= 0 || item.num > 100) isPass = true; }); if(isPass) { this.$message.error('代理商设置-赠送数量比例不能小于等于0或者大于100') return false } }else{ if(json.agent_quantity <= 0 || json.agent_quantity > 100){ this.$message.error('代理商设置-赠送数量比例不能小于等于0或者大于100') return false } } } if(parseInt(json.province_calculation_type) === 1){ if(json.province_gift_type == 1){ let isPass = false; Object.values(json.province_ladder).forEach((item,index)=>{ if(item.num <= 0 || item.num > 100) isPass = true; }); if(isPass) { this.$message.error('省公司设置-赠送数量比例不能小于等于0或者大于100') return false } }else{ if(json.province_quantity <= 0 || json.province_quantity > 100){ this.$message.error('省公司设置-赠送数量比例不能小于等于0或者大于100') return false } } } return this.json; } } })