<template>
|
<!--
|
作者 luoyiming
|
时间:2020-06-09
|
描述:会员-等级管理-编辑等级
|
-->
|
<el-dialog title="编辑等级" :visible.sync="dialogVisible" @close='dialogFormVisible' :close-on-click-modal="false"
|
:close-on-press-escape="false" width="800px">
|
<el-form size="small" :model="form" ref="form">
|
<el-form-item label="等级名称" :label-width="formLabelWidth" prop="name" :rules="[{required: true,message: ' '}]">
|
<el-input v-model="form.name" autocomplete="off"></el-input>
|
</el-form-item>
|
<el-form-item label="等级权重" :label-width="formLabelWidth" prop="weight" :rules="[{required: true,message: '请输入等级权重'}]" v-if="form.is_default == 0">
|
<el-input v-model="form.weight" type="number" placeholder="请输入等级权重"></el-input>
|
<div class="gray9">权重越大,等级越高</div>
|
</el-form-item>
|
<el-form-item label="分红比例" :label-width="formLabelWidth" prop="equity" :rules="[{required: true,message: '请输入分红比例'}]">
|
<el-input type="number" :min="0" :max="100" placeholder="请输入分红比例" v-model="form.equity">
|
<template slot="append">%</template>
|
</el-input>
|
<div class="gray9">队长分红=(实际付款金额 + 余额抵扣 - 运费)* 分红比例</div>
|
</el-form-item>
|
<el-form-item label="平级奖比例" :label-width="formLabelWidth" prop="pjaward_percent" :rules="[{required: true,message: '请输入平级奖比例'}]">
|
<el-input type="number" :min="0" :max="100" placeholder="请输入平级奖比例" v-model="form.pjaward_percent">
|
<template slot="append">%</template>
|
</el-input>
|
</el-form-item>
|
<template v-if="form.is_default == 0">
|
<el-form-item label="自动升级" :label-width="formLabelWidth" prop="auto_upgrade">
|
<el-radio-group v-model="form.auto_upgrade">
|
<el-radio :label="1">允许自动升级</el-radio>
|
<el-radio :label="0">禁止自动升级</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
<el-form-item label="升级条件" :label-width="formLabelWidth">
|
<div>
|
<el-radio-group v-model="form.condition_type">
|
<el-radio label="and">满足勾选的所有条件</el-radio>
|
<el-radio label="or">满足勾选的任意条件</el-radio>
|
</el-radio-group>
|
</div>
|
<div class="d-s-c mt16">
|
<div class="mr10">
|
<el-checkbox v-model="form.open_agent_money">累计佣金</el-checkbox>
|
<el-input v-model="form.agent_money" type="number" :disabled="form.open_agent_money==0" style="width: 160px; margin-left: 10px;" >
|
<template slot="append">元</template>
|
</el-input>
|
</div>
|
<div>
|
<el-checkbox v-model="form.open_agent_user">直推分销商</el-checkbox>
|
<el-input v-model="form.agent_user" type="number" :disabled="form.open_agent_user==0" style="width: 160px;margin-left: 10px;">
|
<template slot="append">人</template>
|
</el-input>
|
</div>
|
</div>
|
<div class="d-s-c mt16">
|
<div class="mr10">
|
<el-checkbox v-model="form.open_team_user">团队人数</el-checkbox>
|
<el-input v-model="form.team_user" type="number" :disabled="form.open_team_user==0" style="width: 160px;margin-left: 10px;">
|
<template slot="append">人</template>
|
</el-input>
|
</div>
|
<div class="d-s-c">
|
<el-checkbox v-model="form.open_team_money">团队业绩</el-checkbox>
|
<el-input v-model="form.team_money" type="number" :disabled="form.open_team_money==0" style="width: 160px;margin-left: 10px;">
|
<template slot="append">元</template>
|
</el-input>
|
<div><el-checkbox v-model="form.self_buy_money" class="pl10">包含个人业绩</el-checkbox></div>
|
</div>
|
</div>
|
<div class="d-s-c mt16">
|
<el-checkbox v-model="form.open_buy_product">购买指定商品</el-checkbox>
|
<el-button type="primary" :disabled="form.open_buy_product==0" @click="openProduct">选择商品</el-button>
|
<el-checkbox style="margin-left: 10px;" v-model="form.open_type_product">购买商品就升级</el-checkbox>
|
</div>
|
<div v-if="form.product_image && form.product_image.length > 0" class="d-s-c f-w product-team-image">
|
<div v-for="(item, index) in form.product_image" :key="index" class="img pr">
|
<a href="javascript:void(0)" class="delete-btn" @click="deleteFunc(index)"><i
|
class="el-icon-error"></i></a>
|
<img :src="item.image" height="100" />
|
<p class="text-ellipsis">{{ item.product_name }}</p>
|
</div>
|
</div>
|
</el-form-item>
|
<el-form-item label="提现条件" :label-width="formLabelWidth">
|
<div>
|
<el-radio-group v-model="form.cash_condition">
|
<el-radio :label="10">不限制</el-radio>
|
<el-radio :label="20">当月自购+直推订单数</el-radio>
|
<el-radio :label="30">当月自购+直推订单金额</el-radio>
|
</el-radio-group>
|
</div>
|
<div class="d-s-c mt16" v-if="form.cash_condition==20">
|
<label>当月自购+直推订单数达到</label>
|
<el-input v-model="form.cash_order_num" type="number" style="width: 260px; margin-left: 10px;" >
|
<template slot="append">单</template>
|
</el-input>
|
</div>
|
<div class="d-s-c mt16" v-if="form.cash_condition==30">
|
<label>当月自购+直推订单金额达到</label>
|
<el-input v-model="form.cash_order_money" type="number" style="width: 260px; margin-left: 10px;" >
|
<template slot="append">元</template>
|
</el-input>
|
</div>
|
</el-form-item>
|
</template>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="dialogFormVisible">取 消</el-button>
|
<el-button type="primary" @click="editGrade" :disabled="submit_loading">确 定</el-button>
|
</div>
|
<!--产品列表弹出层组件-->
|
<Product :isproduct="isproduct" append-to-body @closeDialog="closeDialogFunc($event)">产品列表弹出层</Product>
|
</el-dialog>
|
</template>
|
|
<script>
|
import GradeApi from '@/api/plus/team/grade.js';
|
import Product from '@/components/product/Product';
|
export default {
|
components: {
|
Product
|
},
|
data() {
|
return {
|
/*左边长度*/
|
formLabelWidth: '120px',
|
/*是否显示*/
|
dialogVisible: false,
|
/*是否正在提交*/
|
submit_loading: false,
|
/*是否显示产品列表弹出层*/
|
isproduct: false
|
};
|
},
|
props: ['open_edit', 'form'],
|
created() {
|
console.log(this.form);
|
this.form.open_agent_money=this.form.open_agent_money==1?true:false;
|
this.form.open_agent_user=this.form.open_agent_user==1?true:false;
|
this.form.open_team_money=this.form.open_team_money==1?true:false;
|
this.form.open_team_user=this.form.open_team_user==1?true:false;
|
this.form.self_buy_money=this.form.self_buy_money==1?true:false;
|
this.form.open_buy_product=this.form.open_buy_product==1?true:false;
|
this.form.open_type_product=this.form.open_type_product==1?true:false;
|
// 等级id转换成数组
|
if (this.form.product_ids && this.form.product_ids.length) {
|
for (let i = 0; i < this.form.product_ids.length; i++) {
|
this.form.product_ids[i] = parseInt(this.form.product_ids[i]);
|
}
|
}
|
this.dialogVisible = this.open_edit;
|
//this.getData();
|
},
|
methods: {
|
getData(){
|
let self = this;
|
GradeApi.toEditgrade({}, true).then(res => {
|
|
})
|
.catch(error => {
|
|
});
|
},
|
/*修改用户*/
|
editGrade() {
|
let self = this;
|
let params = this.form;
|
self.$refs.form.validate((valid) => {
|
if (valid) {
|
self.submit_loading = true;
|
if(params.is_default==0){
|
params.open_agent_money=params.open_agent_money==true?1:0;
|
params.open_agent_user=params.open_agent_user==true?1:0;
|
params.open_team_money=params.open_team_money==true?1:0;
|
params.open_team_user=params.open_team_user==true?1:0;
|
params.self_buy_money=params.self_buy_money==true?1:0;
|
params.open_buy_product=params.open_buy_product==true?1:0;
|
params.open_type_product=params.open_type_product==true?1:0;
|
}else{
|
delete params.open_agent_money;
|
delete params.open_agent_user;
|
delete params.agent_money;
|
delete params.agent_user;
|
delete params.open_team_money;
|
delete params.open_team_user;
|
delete params.team_money;
|
delete params.team_user;
|
delete params.self_buy_money;
|
delete params.open_buy_product;
|
delete params.product_ids;
|
delete params.product_image;
|
delete params.open_type_product;
|
}
|
GradeApi.editGrade(params, true)
|
.then(data => {
|
self.submit_loading = false;
|
self.$message({
|
message: '恭喜你,等级修改成功',
|
type: 'success'
|
});
|
self.dialogFormVisible(true);
|
|
})
|
.catch(error => {
|
self.submit_loading = false;
|
});
|
|
}
|
});
|
},
|
|
/*关闭弹窗*/
|
dialogFormVisible(e) {
|
if (e) {
|
this.$emit('closeDialog', {
|
type: 'success',
|
openDialog: false
|
})
|
} else {
|
this.$emit('closeDialog', {
|
type: 'error',
|
openDialog: false
|
})
|
}
|
},
|
/*删除商品*/
|
deleteFunc(i) {
|
this.form.product_ids.splice(i, 1);
|
this.form.product_image.splice(i, 1);
|
},
|
/*产品列表弹出层*/
|
openProduct() {
|
this.isproduct = true;
|
this.$nextTick(() => {
|
setTimeout(() => {
|
// 强制提升所有弹窗和遮罩层的z-index
|
const dialogWrappers = document.querySelectorAll('.el-dialog__wrapper');
|
const modals = document.querySelectorAll('.v-modal');
|
|
// 为每个弹窗设置递增的z-index
|
dialogWrappers.forEach((dialog, index) => {
|
dialog.style.zIndex = 2000 + (index * 10) + 5;
|
});
|
|
// 为每个遮罩层设置递增的z-index(略低于对应弹窗)
|
modals.forEach((modal, index) => {
|
modal.style.zIndex = 2000 + (index * 10);
|
});
|
}, 50);
|
});
|
},
|
/*关闭弹窗*/
|
closeDialogFunc(e) {
|
this.isproduct = e.openDialog;
|
if (e.type == 'success') {
|
if (this.form.product_ids == '') {
|
this.form.product_ids = [];
|
this.form.product_image = [];
|
}
|
if (this.form.product_ids.indexOf(e.params.product_id) == -1) {
|
this.form.product_ids.push(e.params.product_id);
|
this.form.product_image.push({
|
product_id: e.params.product_id,
|
image: e.params.image,
|
product_name: e.params.product_name
|
});
|
} else {
|
this.$message({
|
message: '已选择该商品',
|
type: 'warning'
|
});
|
}
|
}
|
}
|
|
}
|
};
|
</script>
|
|
<style>
|
.product-team-image p{
|
width: 100px;
|
}
|
.product-team-image{
|
margin-top: 10px;
|
.delete-btn {
|
position: absolute;
|
display: block;
|
width: 20px;
|
height: 20px;
|
line-height: 20px;
|
right: -8px;
|
top: -8px;
|
color: red;
|
}
|
}
|
</style>
|