分销等级配置商品券

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();
}
$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);
@ -72,7 +72,7 @@ class Level extends Common
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) {

@ -89,94 +89,138 @@
<el-form-item label="等级名称" prop="name">
<el-input class="sa-w-360" v-model="form.model.name" placeholder="请输入等级名称"></el-input>
</el-form-item>
<el-form-item label="等级徽章" prop="image">
<sa-uploader v-model="form.model.image"></sa-uploader>
<!-- <el-form-item label="等级徽章" prop="image">-->
<!-- <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 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 label="方案一" prop="coupon_rules">
<el-button type="primary" link @click="onSelectCoupon1">选择商品券
</el-button>
<template v-if="form.model.coupon_rules.programme_1.length > 0">
<div class="header sa-flex">
<div class="key">券名称</div>
<div class="oper">操作</div>
</div>
<div class="item" v-for="(element, index) in form.model.coupon_rules.programme_1" :key="element">
<div class="key">
<div class="goods-title sa-m-b-6">{{ element.name }}</div>
</div>
<div class="oper">
<el-button type="danger" link @click="onDeleteCoupon1(index)">
移除
</el-button>
</div>
</div>
</template>
</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>
<el-form-item label="方案二" prop="form.model.coupon_rules.programme_2">
<el-button type="primary" link @click="onSelectCoupon2">选择商品券
</el-button>
<template v-if="form.model.coupon_rules.programme_2.length > 0">
<div class="header sa-flex">
<div class="key">券名称</div>
<div class="oper">操作</div>
</div>
<div class="item" v-for="(element, index) in form.model.coupon_rules.programme_2" :key="element">
<div class="key">
<div class="goods-title sa-m-b-6">{{ element.name }}</div>
</div>
<div class="oper">
<el-button type="danger" link @click="onDeleteCoupon2(index)">
移除
</el-button>
</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-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-scrollbar>
</el-main>

@ -25,20 +25,31 @@
{{ scope.row.name }}
</template>
</el-table-column>
<el-table-column label="等级徽章" min-width="120">
<el-table-column label="消费门槛" min-width="150">
<template #default="scope">
<sa-image :url="scope.row.image" size="24"></sa-image>
{{ scope.row.total_consume }}
</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 label="创建时间" min-width="150">
<template #default="scope">
{{ scope.row.createtime }}
</template>
</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">
<template #default="scope">
{if $auth->check('shopro/commission/level/edit')}

@ -79,6 +79,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
level: null,
name: '',
image: '',
total_consume: '0.00',//消费门槛
commission_rules: {
commission_1: '0.00',
commission_2: '0.00',
@ -86,6 +87,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
},
upgrade_type: 0,
upgrade_rules: {},
coupon_rules:{
programme_1:{},
programme_2:{}
},
},
rules: {
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(() => {
getLevelSelect()
if (state.type == 'add') {
@ -349,7 +386,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
onAddUpgradeRules,
onDeleteRules,
initUnit,
onConfirm
onConfirm,
onSelectCoupon1,
onSelectCoupon2,
onDeleteCoupon1,
onDeleteCoupon2
}
}
}

Loading…
Cancel
Save