添加:商品编辑添加权重值设置

This commit is contained in:
wuhui_zzw 2023-09-26 14:06:26 +08:00
parent 819d549907
commit 6c0161cbd0
5 changed files with 111 additions and 34 deletions

View File

@ -13,12 +13,20 @@ use Illuminate\Database\Eloquent\Model;
class SaleObserver extends \app\common\observers\BaseObserver
{
public function saving( $model)
{
public function saving( $model){
// if (!empty($model->id) &&$model->isDirty()) {
// (new \app\common\services\operation\SaleLog($model, 'update'));
// }
// 处理阶梯价信息
$weightValueLadder = $model->weight_value_ladder ?? [];
foreach($weightValueLadder as $weightValueLadderIndex => $weightValueLadderItem){
if((float)$weightValueLadderItem['where'] <= 0 || (float)$weightValueLadderItem['num'] <= 0) unset($weightValueLadder[$weightValueLadderIndex]);
}
$model->weight_value_ladder = $weightValueLadder ?? [];
}
public function updating( $model)

View File

@ -19,32 +19,32 @@ use app\backend\modules\goods\observers\SaleObserver;
class Sale extends BaseModel
{
public $table = 'yz_goods_sale';
public $attributes = [
'max_point_deduct' => '',
'min_point_deduct' => '',
'max_balance_deduct' => '',
'min_balance_deduct' => '',
'max_point_deduct' => '',
'min_point_deduct' => '',
'max_balance_deduct' => '',
'min_balance_deduct' => '',
'has_all_point_deduct' => 0,
'all_point_deduct' => 0,
'is_sendfree' => 0,
'ed_num' => '',
'ed_full' => 0,
'ed_reduction' => 0,
'ed_money' => '',
'point' => '',
'bonus' => 0,
'award_balance' => 0,
'pay_reward_balance' => 0,
'point_type' => 0,
'max_once_point' => 0,
'ed_areas' => '',
'all_point_deduct' => 0,
'is_sendfree' => 0,
'ed_num' => '',
'ed_full' => 0,
'ed_reduction' => 0,
'ed_money' => '',
'point' => '',
'bonus' => 0,
'award_balance' => 0,
'pay_reward_balance' => 0,
'point_type' => 0,
'max_once_point' => 0,
'ed_areas' => '',
'push_goods_ids' => 0,
'is_push' => 0,
'is_push' => 0,
'weight_value_type' => 0,
'weight_value_num' => 0,
'weight_value_ladder' => [],
];
protected $appends = ['point_deduct_type'];
protected $guarded = [''];

BIN
min_img/bc_eweima.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -3,11 +3,11 @@ define({
template: `
<div class="promotion">
<el-form ref="promotion" :model="json" :rules="rules">
<!--单品优惠-->
<div class="vue-main-title">
<div class="vue-main-title-left"></div>
<div class="vue-main-title-content">单品优惠</div>
</div>
<div style="margin:0 auto;width:80%;">
<el-form-item label="单品满件包邮" label-width="155px" prop="ed_num">
<el-input v-model.trim="json.ed_num" maxlength="300">
@ -49,12 +49,49 @@ define({
</el-form-item>
</div>
<!--权重值设置-->
<div class="vue-main-title">
<div class="vue-main-title-left"></div>
<div class="vue-main-title-content">权重值设置</div>
</div>
<div style="margin:0 auto;width:80%;">
<el-form-item label="赠送方式" label-width="155px">
<el-radio v-model="json.weight_value_type" :label="0">普通赠送</el-radio>
<el-radio v-model="json.weight_value_type" :label="1">阶梯赠送</el-radio>
<div class="form-item_tips">普通赠送购买人购买人上级购买人上级的上级赠送指定的权重值</div>
<div class="form-item_tips">阶梯赠送购买人购买人上级分别获取对应顺序的权重值顺序为用户成为经销商的先后顺序如果经销商身份为黑名单则不赠送权重值</div>
</el-form-item>
<el-form-item label="赠送数量" v-if="json.weight_value_type != 1" label-width="155px" prop="weight_value_num">
<el-input v-model.trim="json.weight_value_num" maxlength="300">
<template slot="append">权重值</template>
</el-input>
<div class="form-item_tips">如果设置为空或者0则不赠送权重值</div>
</el-form-item>
<el-form-item label="阶梯赠送" v-else label-width="155px">
<div class="ladder-content">
<div class="ladder-row" v-for="(item,index) in json.weight_value_ladder" :key="index">
<el-form-item>
<el-input v-model="json.weight_value_ladder[index]['where']" placeholder="名次" class="ladder-input" maxlength="300">
<template slot="prepend">小于等于</template>
<template slot="append"></template>
</el-input>
<el-input class="ladder-input" v-model="json.weight_value_ladder[index]['num']" placeholder="权重值" maxlength="300">
<template slot="prepend">赠送</template>
<template slot="append">权重值</template>
</el-input>
<el-button type="danger" size="medium" @click="delLadder(index)">删除</el-button>
</el-form-item>
</div>
<el-button type="primary" @click="addLadder">增加阶梯</el-button>
<div class="form-item_tips">例如设置小于等于10赠送100权重值小于等于32赠送120权重值则第1~10位经销商赠送100权重值第11~32位经销商赠送120权重值第33位及之后所有经销商均不赠送权重值</div>
</div>
</el-form-item>
</div>
<!--余额设置-->
<div class="vue-main-title">
<div class="vue-main-title-left"></div>
<div class="vue-main-title-content">余额设置</div>
</div>
<div style="margin:0 auto;width:80%;">
<el-form-item label="赠送余额" label-width="155px" prop="award_balance">
<el-input v-model.trim="json.award_balance" maxlength="300">
@ -99,12 +136,11 @@ define({
<div class="form-item_tips">如果设置为空为0则采用余额统一设置</div>
</el-form-item>
</div>
<!--积分设置-->
<div class="vue-main-title">
<div class="vue-main-title-left"></div>
<div class="vue-main-title-content">积分设置</div>
</div>
<div style="margin:0 auto;width:80%;">
<el-form-item label="赠送积分" label-width="155px" prop="point">
<el-input v-model.trim="json.point" maxlength="300">
@ -183,12 +219,11 @@ define({
</el-form-item>
</el-form-item>
</div>
<!--其他设置-->
<div class="vue-main-title">
<div class="vue-main-title-left"></div>
<div class="vue-main-title-content">其他设置</div>
</div>
<div style="margin:0 auto;width:80%;">
<el-form-item label="推广相关商品显示设置" label-width="155px">
<el-switch
@ -197,7 +232,6 @@ define({
:inactive-value="0">
</el-switch>
</el-form-item>
<el-form-item v-if="json.is_push">
<div class="choose" style="margin: 0 0 10px 155px;display:flex;">
<div class="choose-item" v-for="(item,index) in json.push_goods_ids" :key="index">
@ -421,6 +455,18 @@ define({
height: 80%;
overflow-y: scroll;
}
.ladder-content{
min-width: 550px!important;
}
.ladder-content .ladder-row{
margin-bottom: 5px!important;;
}
.ladder-content .ladder-row .ladder-input{
width: 200px!important;;
}
`,
props: {
form: {
@ -497,6 +543,7 @@ define({
all_point_deduct: { validator: floatNum },
max_balance_deduct: { validator: floatNum },
min_balance_deduct: { validator: floatNum },
weight_value_num: { validator: floatNum },
},
goodsDialog: false,
areaDialog: false,
@ -542,7 +589,11 @@ define({
min_balance_deduct:'',
is_push: 0,
push_goods_ids: [],
is_store:0
is_store:0,
// 权重值设置
weight_value_type: 0,
weight_value_num: 0,
weight_value_ladder: {},
},
};
},
@ -573,6 +624,10 @@ define({
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 : [];
// 权重值
this.json.weight_value_type = sale.weight_value_type ? sale.weight_value_type : 0;
this.json.weight_value_num = sale.weight_value_num ? sale.weight_value_num : 0;
this.json.weight_value_ladder = sale.weight_value_ladder ? JSON.parse(sale.weight_value_ladder) : {};
}
},
methods: {
@ -668,7 +723,6 @@ define({
this.json.ed_areaids = area_ids.join(",");
this.areaDialog = false
},
// 商品
searchGoods (page=this.paginationOpt.page) {
if (this.goodsKey === "") {
@ -710,5 +764,20 @@ define({
}
});
},
// 权重值相关处理
addLadder(){
this.json.weight_value_ladder = Object.values(this.json.weight_value_ladder).concat({where: '', num: ''});
},
delLadder(index){
let weightValueLadder = Object.assign({},this.json.weight_value_ladder);
delete weightValueLadder[index];
this.json.weight_value_ladder = Object.values(weightValueLadder);
}
},
});