update:补充骰子个数参数,以及一些规则检验

This commit is contained in:
lihaoyuan 2025-12-24 16:16:59 +08:00
parent 2978c6a201
commit 4320e5c9f9

View File

@ -57,15 +57,19 @@
<el-row :gutter="20">
<el-col :span="12">
<div class="grid-content bg-purple">
<el-form-item :label="__('砍价有效期')" prop="cut_hour">
<el-input v-model="form.cut_hour" placeholder="请输入有效期(小时)" clearable />
<el-form-item :label="__('砍价有效期(小时)')" prop="cut_hour">
<el-input v-model="form.cut_hour" type="number" placeholder="请输入有效期(小时)" clearable />
</el-form-item>
</div>
</el-col>
<el-col :span="12">
<div class="grid-content bg-purple"></div>
<el-form-item :label="__('活动商品总数')" prop="product_count">
<el-input v-model="form.product_count" placeholder="请输入参与活动商品总数" clearable />
<el-input v-model="form.product_count" type="number" placeholder="请输入参与活动商品总数" clearable
:max="form.item_quantity || ''"
@input="handleProductCountInput"
:disabled="!form.item_id"
/>
</el-form-item>
</el-col>
</el-row>
@ -112,7 +116,7 @@
:min="2"
/>
<el-tooltip
content="砍价成功的人数例如设置为3人一共要3个人砍价才能达到底价下单默认最少为2"
content="砍价成功的人数例如设置为3人底价为0.013个人砍价之后才能达到底价0.01,然后下单默认最少为2"
placement="top"
effect="dark"
style="margin-left: 8px;"
@ -134,7 +138,7 @@
style="width: 200px;"
/>
<el-tooltip
content="在活动期间每个人一共可以助力好友的人数默认最少为5"
content="在活动期间每个人一共可以助力好友的次数,即该活动你一共可以帮多少人砍价默认最少为5"
placement="top"
effect="dark"
style="margin-left: 8px;"
@ -145,7 +149,7 @@
</el-form-item>
<el-form-item :label="__('砍价第一刀')" prop="cut_first_type">
<el-radio-group v-model="form.cut_first_type">
<el-radio-group v-model="form.cut_first_type" @change="handleCutFirstTypeChange">
<el-radio :label="1" >
<span>{{ __('首刀比例') }}</span>
<el-tooltip
@ -171,19 +175,32 @@
</el-form-item>
<el-form-item label="首刀比例(单位-%" size="normal" v-if='form.cut_first_type == 1'>
<el-input v-model="form.cut_first_percent" placeholder="请输入首刀比例" clearable />
<el-input v-model="form.cut_first_percent" type="number" placeholder="请输入首刀比例" clearable />
</el-form-item>
<el-form-item label="首刀金额(单位/块)" size="normal" v-if='form.cut_first_type == 2'>
<el-input v-model="form.cut_first_price " placeholder="请输入首刀金额" clearable />
<el-input v-model="form.cut_first_price" type="number" placeholder="请输入首刀金额" clearable />
</el-form-item>
</el-form>
<el-form ref="touzi" label-width="250px" :model="touzi" :rules="touziRules">
<el-form-item label="砍价幸运骰子个数" label-width="150px">
<div style="display: flex; align-items: center;">
<el-input v-model="touzi.lottery_num" placeholder="请输入骰子的个数" clearable style="width: 200px;" type="number"/>
<el-tooltip
content="该活动一共可以投骰子用于翻倍砍价金额的次数"
placement="top"
effect="dark"
style="margin-left: 8px;"
>
<i class="el-icon-question" style="cursor: pointer; color: #909399; font-size: 14px;"></i>
</el-tooltip>
</div>
</el-form-item>
<!-- 总标签 + 问号提示 -->
<el-form-item label="砍价后投骰子的点数(单位-%" class="total-label-item">
<el-tooltip
content="设置骰子不同点数对应的中奖比例6个点数比例总和不能超过100%"
content="设置骰子不同点数对应的中奖比例6个点数比例总和不能超过100%,可以使用默认预设点数145%点数245%点数32%点数43%点数52%点数63%"
placement="top"
effect="dark"
style="margin-left: 8px;"
@ -231,6 +248,7 @@
form: {
product_item_name: '',
item_id: '',
item_quantity:0,
cut_down_type: 2,
cut_down_user_num: 0,
cut_down_fixed_price: '',
@ -254,7 +272,7 @@
{doubleValue:'5',probability:'2'},
{doubleValue:"6",probability:'3'},
],
lottery_num:1
lottery_num:3
},
touziErrorMsg: '', //
touziRules: {
@ -314,6 +332,32 @@
],
product_count: [
{ required: true, trigger: 'blur', message: this.__('参与活动商品总数') },
{
validator: (rule, value, callback) => {
// item_id
if (!this.form.item_id) {
callback(new Error(this.__('请先选择砍价商品')));
return;
}
// 00
if (Number(this.form.item_quantity) <= 0) {
callback(new Error(this.__('该商品库存为0无法设置活动商品总数')));
return;
}
const count = Number(value);
const max = Number(this.form.item_quantity);
if (isNaN(count)) {
callback(new Error(this.__('请输入有效的数字')));
} else if (count <= 0) {
callback(new Error(this.__('活动商品总数不能小于等于0')));
} else if (count > max) {
callback(new Error(this.__(`活动商品总数不能超过商品库存${max}`)));
} else {
callback();
}
},
trigger: ['blur', 'change', 'submit']
}
],
},
}
@ -332,6 +376,12 @@
getCheckItem(row) {
this.form.item_id = row.item_id
this.form.product_item_name = row.product_item_name
this.form.item_quantity = row.item_quantity;
//
if (this.form.product_count && Number(this.form.product_count) > Number(this.form.item_quantity)) {
this.form.product_count = this.form.item_quantity;
this.$baseMessage(`活动商品总数不能超过商品库存${this.form.item_quantity},已自动重置`, 'warning');
}
this.$refs['form'].validateField(
['product_item_name', 'item_id'],
(errorMsg) => {
@ -361,6 +411,7 @@
cut_down_user_num: row.activity_rule.cut_down_user_num,
cut_hour:row.cut_hour,
product_count:row.product_count,
//item_quantity: row.activity_rule.item_quantity
user_cutprice_num:row.activity_rule.user_cutprice_num,
cut_first_type:row.activity_rule.cut_first_type,//
cut_first_percent:row.activity_rule.cut_first_percent,
@ -374,12 +425,29 @@
},
tranformData(lucky_turn){
if(this.form.cut_first_percent){
this.form.cut_first_type=1
this.form.cut_first_type=1;
this.form.cut_first_price = ''
}else if(this.form.cut_first_price){
this.form.cut_first_type=2
this.form.cut_first_percent = ''
}
this.touzi=JSON.parse(lucky_turn)
},
// methods
handleProductCountInput() {
if (!this.form.item_quantity) return;
const count = Number(this.form.product_count);
const max = Number(this.form.item_quantity);
//
if (count > max) {
this.form.product_count = max;
this.$baseMessage(`活动商品总数最大为${max}`, 'warning');
}
// /
if (count <= 0 || isNaN(count)) {
this.form.product_count = '';
}
},
close() {
this.form = {
product_item_name: '',
@ -402,6 +470,16 @@
showItemTable() {
this.$refs['productItemTable'].showTable()
},
//
handleCutFirstTypeChange(type) {
if (type === 1) {
//
this.form.cut_first_price = '';
} else if (type === 2) {
//
this.form.cut_first_percent = '';
}
},
diceObjToStr(){
this.form.diceObj = JSON.stringify(this.touzi);
},