分销等级配置商品券

main
ztt 8 months ago
parent cc5cc8cf61
commit a4a1fd8ce4
  1. 4
      application/admin/controller/shopro/commission/Level.php
  2. 210
      application/admin/view/shopro/commission/level/add.html
  3. 31
      application/admin/view/shopro/commission/level/index.html
  4. 43
      public/assets/js/backend/shopro/commission/level.js

@ -54,7 +54,7 @@ class Level extends Common
return $this->view->fetch(); return $this->view->fetch();
} }
$params = $this->request->only(['name', 'level', 'image', 'commission_rules', 'upgrade_type', 'upgrade_rules']); $params = $this->request->only(['name', 'level', 'image', 'commission_rules', 'upgrade_type', 'upgrade_rules', 'coupon_rules', 'total_consume']);
$this->model->save($params); $this->model->save($params);
@ -72,7 +72,7 @@ class Level extends Common
return $this->view->fetch('add'); return $this->view->fetch('add');
} }
$params = $this->request->only(['level', 'name', 'image', 'commission_rules', 'upgrade_type', 'upgrade_rules']); $params = $this->request->only(['level', 'name', 'image', 'commission_rules', 'upgrade_type', 'upgrade_rules', 'coupon_rules', 'total_consume']);
$result = Db::transaction(function () use ($id, $params) { $result = Db::transaction(function () use ($id, $params) {

@ -89,94 +89,138 @@
<el-form-item label="等级名称" prop="name"> <el-form-item label="等级名称" prop="name">
<el-input class="sa-w-360" v-model="form.model.name" placeholder="请输入等级名称"></el-input> <el-input class="sa-w-360" v-model="form.model.name" placeholder="请输入等级名称"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="等级徽章" prop="image"> <!-- <el-form-item label="等级徽章" prop="image">-->
<sa-uploader v-model="form.model.image"></sa-uploader> <!-- <sa-uploader v-model="form.model.image"></sa-uploader>-->
<!-- </el-form-item>-->
<el-form-item label="消费门槛" prop="total_consume">
<el-input class="sa-w-360" v-model="form.model.total_consume" placeholder="请输入消费门槛"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="一级(自购)佣金比例" prop="commission_rules.commission_1" <el-form-item label="方案一" prop="coupon_rules">
:rules="form.rules.commission_rules.commission"> <el-button type="primary" link @click="onSelectCoupon1">选择商品券
<el-input class="sa-w-360" v-model="form.model.commission_rules.commission_1" type="number"> </el-button>
<template #append>%</template> <template v-if="form.model.coupon_rules.programme_1.length > 0">
</el-input> <div class="header sa-flex">
</el-form-item> <div class="key">券名称</div>
<el-form-item label="二级佣金比例" prop="commission_rules.commission_2" <div class="oper">操作</div>
:rules="form.rules.commission_rules.commission"> </div>
<el-input class="sa-w-360" v-model="form.model.commission_rules.commission_2" type="number"> <div class="item" v-for="(element, index) in form.model.coupon_rules.programme_1" :key="element">
<template #append>%</template> <div class="key">
</el-input> <div class="goods-title sa-m-b-6">{{ element.name }}</div>
</el-form-item> </div>
<el-form-item label="三级佣金比例" prop="commission_rules.commission_3" <div class="oper">
:rules="form.rules.commission_rules.commission"> <el-button type="danger" link @click="onDeleteCoupon1(index)">
<el-input class="sa-w-360" v-model="form.model.commission_rules.commission_3" type="number"> 移除
<template #append>%</template> </el-button>
</el-input> </div>
</div>
</template>
</el-form-item> </el-form-item>
<template v-if="form.model.level != 1"> <el-form-item label="方案二" prop="form.model.coupon_rules.programme_2">
<div class="sa-title is-line">添加升级条件</div> <el-button type="primary" link @click="onSelectCoupon2">选择商品券
<el-form-item label="升级方式" prop="upgrade_rules"> </el-button>
<div> <template v-if="form.model.coupon_rules.programme_2.length > 0">
<el-radio-group class="mb-2" v-model="form.model.upgrade_type"> <div class="header sa-flex">
<el-radio :label="0">满足以下任意条件</el-radio> <div class="key">券名称</div>
<el-radio :label="1">满足以下全部条件</el-radio> <div class="oper">操作</div>
</el-radio-group> </div>
<div> <div class="item" v-for="(element, index) in form.model.coupon_rules.programme_2" :key="element">
<div class="sa-flex sa-flex-wrap condition-group" v-for="group in upgradeCondition" <div class="key">
:key="group"> <div class="goods-title sa-m-b-6">{{ element.name }}</div>
<div :class="[ </div>
'item', <div class="oper">
'condition-item', <el-button type="danger" link @click="onDeleteCoupon2(index)">
Object.keys(form.model.upgrade_rules).includes(key) ? 'is-active' : '', 移除
]" v-for="(item, key) in group" :key="item" </el-button>
@click="onSelectUpgradeCondition(key)">
{{ item.name }}
</div>
</div>
</div> </div>
</div> </div>
</el-form-item>
<template v-for="(group, gkey) in upgradeCondition" :key="group">
<template v-for="(item, key) in group" :key="item">
<el-form-item :label="item.name"
v-if="Object.keys(form.model.upgrade_rules).includes(key)"
:prop="`upgrade_rules.${key}`" :rules="form.rules.upgrade_rules_inner.rules">
<template v-if="gkey != 'agent_level'">
<el-input class="w-120" v-model="form.model.upgrade_rules[key]" type="number">
<template #append> {{ initUnit(key) }}</template>
</el-input>
<el-button class="delete" type="danger" link @click="onDeleteRules(key)">
删除
</el-button>
</template>
<div v-if="gkey == 'agent_level'">
<div class="sa-flex sa-flex-wrap mb-4"
v-for="(al, index) in form.model.upgrade_rules[key]" :key="al">
<el-form-item :prop="`upgrade_rules.${key}.${index}.level`"
:rules="form.rules.upgrade_rules_inner.level">
<el-select class="w-120" v-model="al.level" placeholder="请选择分销商等级">
<template v-for="item in level.select" :key="item">
<el-option v-if="item.level < form.model.level"
:label="item.name" :value="item.level+''"></el-option>
</template>
</el-select>
<span class="ml-2 mr-2"></span>
</el-form-item>
<el-form-item :prop="`upgrade_rules.${key}.${index}.count`"
:rules="form.rules.upgrade_rules_inner.rules">
<el-input class="w-120" v-model="al.count" type="number">
<template #append></template>
</el-input>
<el-button class="delete" type="danger" link
@click="onDeleteRules(key, index)">
删除
</el-button>
</el-form-item>
</div>
<el-button type="primary" link size="small" @click="onAddUpgradeRules(key)">
+ 添加</el-button>
</div>
</el-form-item>
</template>
</template> </template>
</template> </el-form-item>
<!-- <el-form-item label="一级(自购)佣金比例" prop="commission_rules.commission_1"-->
<!-- :rules="form.rules.commission_rules.commission">-->
<!-- <el-input class="sa-w-360" v-model="form.model.commission_rules.commission_1" type="number">-->
<!-- <template #append>%</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="二级佣金比例" prop="commission_rules.commission_2"-->
<!-- :rules="form.rules.commission_rules.commission">-->
<!-- <el-input class="sa-w-360" v-model="form.model.commission_rules.commission_2" type="number">-->
<!-- <template #append>%</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="三级佣金比例" prop="commission_rules.commission_3"-->
<!-- :rules="form.rules.commission_rules.commission">-->
<!-- <el-input class="sa-w-360" v-model="form.model.commission_rules.commission_3" type="number">-->
<!-- <template #append>%</template>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
<!-- <template v-if="form.model.level != 1">-->
<!-- <div class="sa-title is-line">添加升级条件</div>-->
<!-- <el-form-item label="升级方式" prop="upgrade_rules">-->
<!-- <div>-->
<!-- <el-radio-group class="mb-2" v-model="form.model.upgrade_type">-->
<!-- <el-radio :label="0">满足以下任意条件</el-radio>-->
<!-- <el-radio :label="1">满足以下全部条件</el-radio>-->
<!-- </el-radio-group>-->
<!-- <div>-->
<!-- <div class="sa-flex sa-flex-wrap condition-group" v-for="group in upgradeCondition"-->
<!-- :key="group">-->
<!-- <div :class="[-->
<!-- 'item',-->
<!-- 'condition-item',-->
<!-- Object.keys(form.model.upgrade_rules).includes(key) ? 'is-active' : '',-->
<!-- ]" v-for="(item, key) in group" :key="item"-->
<!-- @click="onSelectUpgradeCondition(key)">-->
<!-- {{ item.name }}-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </el-form-item>-->
<!-- <template v-for="(group, gkey) in upgradeCondition" :key="group">-->
<!-- <template v-for="(item, key) in group" :key="item">-->
<!-- <el-form-item :label="item.name"-->
<!-- v-if="Object.keys(form.model.upgrade_rules).includes(key)"-->
<!-- :prop="`upgrade_rules.${key}`" :rules="form.rules.upgrade_rules_inner.rules">-->
<!-- <template v-if="gkey != 'agent_level'">-->
<!-- <el-input class="w-120" v-model="form.model.upgrade_rules[key]" type="number">-->
<!-- <template #append> {{ initUnit(key) }}</template>-->
<!-- </el-input>-->
<!-- <el-button class="delete" type="danger" link @click="onDeleteRules(key)">-->
<!-- 删除-->
<!-- </el-button>-->
<!-- </template>-->
<!-- <div v-if="gkey == 'agent_level'">-->
<!-- <div class="sa-flex sa-flex-wrap mb-4"-->
<!-- v-for="(al, index) in form.model.upgrade_rules[key]" :key="al">-->
<!-- <el-form-item :prop="`upgrade_rules.${key}.${index}.level`"-->
<!-- :rules="form.rules.upgrade_rules_inner.level">-->
<!-- <el-select class="w-120" v-model="al.level" placeholder="请选择分销商等级">-->
<!-- <template v-for="item in level.select" :key="item">-->
<!-- <el-option v-if="item.level < form.model.level"-->
<!-- :label="item.name" :value="item.level+''"></el-option>-->
<!-- </template>-->
<!-- </el-select>-->
<!-- <span class="ml-2 mr-2">满</span>-->
<!-- </el-form-item>-->
<!-- <el-form-item :prop="`upgrade_rules.${key}.${index}.count`"-->
<!-- :rules="form.rules.upgrade_rules_inner.rules">-->
<!-- <el-input class="w-120" v-model="al.count" type="number">-->
<!-- <template #append>人</template>-->
<!-- </el-input>-->
<!-- <el-button class="delete" type="danger" link-->
<!-- @click="onDeleteRules(key, index)">-->
<!-- 删除-->
<!-- </el-button>-->
<!-- </el-form-item>-->
<!-- </div>-->
<!-- <el-button type="primary" link size="small" @click="onAddUpgradeRules(key)">-->
<!-- + 添加</el-button>-->
<!-- </div>-->
<!-- </el-form-item>-->
<!-- </template>-->
<!-- </template>-->
<!-- </template>-->
</el-form> </el-form>
</el-scrollbar> </el-scrollbar>
</el-main> </el-main>

@ -25,20 +25,31 @@
{{ scope.row.name }} {{ scope.row.name }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="等级徽章" min-width="120"> <el-table-column label="消费门槛" min-width="150">
<template #default="scope"> <template #default="scope">
<sa-image :url="scope.row.image" size="24"></sa-image> {{ scope.row.total_consume }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="一级(自购)佣金比例" min-width="160"> <el-table-column label="创建时间" min-width="150">
<template #default="scope"> {{ scope.row.commission_rules?.commission_1 }}% </template> <template #default="scope">
</el-table-column> {{ scope.row.createtime }}
<el-table-column label="二级佣金比例" min-width="120"> </template>
<template #default="scope"> {{ scope.row.commission_rules?.commission_2 }}% </template>
</el-table-column>
<el-table-column label="三级佣金比例" min-width="120">
<template #default="scope"> {{ scope.row.commission_rules?.commission_3 }}% </template>
</el-table-column> </el-table-column>
<!-- <el-table-column label="等级徽章" min-width="120">-->
<!-- <template #default="scope">-->
<!-- <sa-image :url="scope.row.image" size="24"></sa-image>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="一级(自购)佣金比例" min-width="160">-->
<!-- <template #default="scope"> {{ scope.row.commission_rules?.commission_1 }}% </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="二级佣金比例" min-width="120">-->
<!-- <template #default="scope"> {{ scope.row.commission_rules?.commission_2 }}% </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="三级佣金比例" min-width="120">-->
<!-- <template #default="scope"> {{ scope.row.commission_rules?.commission_3 }}% </template>-->
<!-- </el-table-column>-->
<el-table-column label="操作" min-width="120" fixed="right"> <el-table-column label="操作" min-width="120" fixed="right">
<template #default="scope"> <template #default="scope">
{if $auth->check('shopro/commission/level/edit')} {if $auth->check('shopro/commission/level/edit')}

@ -79,6 +79,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
level: null, level: null,
name: '', name: '',
image: '', image: '',
total_consume: '0.00',//消费门槛
commission_rules: { commission_rules: {
commission_1: '0.00', commission_1: '0.00',
commission_2: '0.00', commission_2: '0.00',
@ -86,6 +87,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}, },
upgrade_type: 0, upgrade_type: 0,
upgrade_rules: {}, upgrade_rules: {},
coupon_rules:{
programme_1:{},
programme_2:{}
},
}, },
rules: { rules: {
level: [{ required: true, message: '请选择等级权重', trigger: 'blur' }], level: [{ required: true, message: '请选择等级权重', trigger: 'blur' }],
@ -328,6 +334,37 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}); });
} }
function onSelectCoupon1() {
let ids = [];
form.model.coupon_rules.programme_1.forEach((i) => {
ids.push(i.id);
});
Fast.api.open(`shopro/coupon/select?multiple=true&status=normal`, "选择商品", {
callback(data) {
form.model.coupon_rules.programme_1 = data;
}
})
}
function onSelectCoupon2() {
let ids = [];
form.model.coupon_rules.programme_2.forEach((i) => {
ids.push(i.id);
});
Fast.api.open(`shopro/coupon/select?multiple=true&status=normal`, "选择商品", {
callback(data) {
form.model.coupon_rules.programme_2 = data;
}
})
}
function onDeleteCoupon1(index) {
form.model.coupon_rules.programme_1.splice(index, 1);
}
function onDeleteCoupon2(index) {
form.model.coupon_rules.programme_2.splice(index, 1);
}
onMounted(() => { onMounted(() => {
getLevelSelect() getLevelSelect()
if (state.type == 'add') { if (state.type == 'add') {
@ -349,7 +386,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
onAddUpgradeRules, onAddUpgradeRules,
onDeleteRules, onDeleteRules,
initUnit, initUnit,
onConfirm onConfirm,
onSelectCoupon1,
onSelectCoupon2,
onDeleteCoupon1,
onDeleteCoupon2
} }
} }
} }

Loading…
Cancel
Save