dev2 #1
@ -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.01,3个人砍价之后才能达到底价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-form-item label="首刀金额(单位/块)" size="normal" v-if='form.cut_first_type == 2'>
|
||||
<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%,可以使用默认预设,点数1:45%,点数2:45%,点数3:2%,点数4:3%,点数5:2%,点数6:3%"
|
||||
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;
|
||||
}
|
||||
// 库存为0时提示“商品库存为0,无法设置活动总数”
|
||||
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);
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user