Browse Source

feat: 添加红包使用选项并优化输入验证逻辑

lihuilin/feature-20251212182509-多语言二期
zhangrenyuan 1 month ago
parent
commit
8390e117c3
  1. 51
      src/views/consume/gold/addCoinConsume.vue

51
src/views/consume/gold/addCoinConsume.vue

@ -64,7 +64,8 @@ const addConsume = ref({
taskGold: null, // taskGold: null, //
remark: "",// remark: "",//
adminId: null,// id adminId: null,// id
adminName: adminData.value.adminName
adminName: adminData.value.adminName,
redMoney: 1 // 使1-使0-使
}) })
const Ref = ref(null) const Ref = ref(null)
const rules = reactive({ const rules = reactive({
@ -163,11 +164,16 @@ function validateInput() {
// //
const totalAvailableGold = (user.value.nowSumGold) const totalAvailableGold = (user.value.nowSumGold)
// 使
if (user.value.jwcode && sumGold > totalAvailableGold) { if (user.value.jwcode && sumGold > totalAvailableGold) {
ElMessage.error(t('elmessage.limitExceeded'));
// sumGoldnull
addConsume.value.sumGold = null;
return false;
// 使
if (addConsume.value.redMoney == 0) {
ElMessage.error(t('elmessage.limitExceeded'));
// sumGoldnull
addConsume.value.sumGold = null;
return false;
}
// 使validateRedLimit
} }
return true; return true;
@ -183,9 +189,12 @@ function validateRedLimit() {
ElMessage.error(t('elmessage.noEmptySumGold')); ElMessage.error(t('elmessage.noEmptySumGold'));
return false; return false;
} }
if (sumGold + redMax < price) {
ElMessage.error(t('elmessage.limitRedAmount'));
return false;
// 使 +
if (addConsume.value.redMoney == 1) {
if (sumGold + redMax < price) {
ElMessage.error(t('elmessage.limitRedAmount'));
return false;
}
} }
} }
return true; return true;
@ -267,14 +276,15 @@ const add = async function () {
permanentGold: addConsume.value.permanentGold * 100, permanentGold: addConsume.value.permanentGold * 100,
goodsName: addConsume.value.goodsName.value, goodsName: addConsume.value.goodsName.value,
remark: addConsume.value.remark, remark: addConsume.value.remark,
adminName: adminData.value.adminName
adminName: adminData.value.adminName,
redMoney: Number(addConsume.value.redMoney) // 1-使0-使
} }
}) })
addDisabled.value = false addDisabled.value = false
console.log("add请求", result); console.log("add请求", result);
// //
handleResponse(result); handleResponse(result);
//
//
resetForm(); resetForm();
} catch (error) { } catch (error) {
@ -319,6 +329,7 @@ function resetForm() {
remark: "", remark: "",
adminId: adminData.value.id, adminId: adminData.value.id,
adminName: adminData.value.adminName, adminName: adminData.value.adminName,
redMoney: 1 // 使
} }
console.log("重置表单") console.log("重置表单")
@ -592,9 +603,14 @@ onMounted(async function () {
<el-input v-model="addConsume.price" style="width: 120px" disabled /> <el-input v-model="addConsume.price" style="width: 120px" disabled />
</el-form-item> </el-form-item>
<el-form-item prop="sumGold" :label="t('common_add.consumeTotalGold')">
<!-- <el-form-item prop="sumGold" :label="t('common_add.consumeTotalGold')">
<el-input v-model="addConsume.sumGold" style="width: 120px" <el-input v-model="addConsume.sumGold" style="width: 120px"
@blur="validateRedLimit()" /> @blur="validateRedLimit()" />
</el-form-item> -->
<el-form-item prop="sumGold" :label="t('common_add.consumeTotalGold')">
<el-input v-model="addConsume.sumGold" style="width: 120px" @blur="validateRedLimit()" />
<el-radio v-model="addConsume.redMoney" :label="1" style="margin-left: 10px;">使用红包</el-radio>
<el-radio v-model="addConsume.redMoney" :label="0">不使用红包</el-radio>
</el-form-item> </el-form-item>
@ -623,10 +639,10 @@ onMounted(async function () {
</el-form-item> </el-form-item>
<el-button type="success" @click="resetForm()" style="margin-left: 200px;margin-top:10px">{{ t('common.reset') <el-button type="success" @click="resetForm()" style="margin-left: 200px;margin-top:10px">{{ t('common.reset')
}}</el-button>
}}</el-button>
<el-button type="primary" :disabled="addDisabled" @click="addBefore" style="margin-top:10px">{{ <el-button type="primary" :disabled="addDisabled" @click="addBefore" style="margin-top:10px">{{
t('common.submit') t('common.submit')
}}</el-button>
}}</el-button>
</el-form> </el-form>
</div> </div>
@ -674,7 +690,7 @@ onMounted(async function () {
</el-form-item> </el-form-item>
<el-form-item style="margin-top: -23px"> <!-- 负边距减少间距 --> <el-form-item style="margin-top: -23px"> <!-- 负边距减少间距 -->
<p style="font-size: small; color: #b1b1b1">({{ $t('common_add_user.onlyStatisticsDataAfter20250101') <p style="font-size: small; color: #b1b1b1">({{ $t('common_add_user.onlyStatisticsDataAfter20250101')
}})
}})
</p> </p>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -767,8 +783,8 @@ onMounted(async function () {
</el-dialog> </el-dialog>
<el-dialog v-model="ConsumeDialogVisible" :title="$t('common_add.operationConfirm')" :before-close="ConsumeDialogVisiblehandleClose"
:close-on-click-modal="false" width="480px">
<el-dialog v-model="ConsumeDialogVisible" :title="$t('common_add.operationConfirm')"
:before-close="ConsumeDialogVisiblehandleClose" :close-on-click-modal="false" width="480px">
<!-- 内容整体居中且收窄 --> <!-- 内容整体居中且收窄 -->
<div class="confirm-body"> <div class="confirm-body">
<!-- 用户信息 --> <!-- 用户信息 -->
@ -819,7 +835,8 @@ onMounted(async function () {
<div> <div>
<el-divider border-style="dashed" /> <el-divider border-style="dashed" />
<p>{{ $t('common_add.similarRechargeRecords') }}</p> <p>{{ $t('common_add.similarRechargeRecords') }}</p>
· {{ ReadCookiesTime }} {{ $t('common_add.buy') }} {{ addConsume.goodsName.value }}({{ $t('common_add.operator') }}: {{ adminData.adminName }})
· {{ ReadCookiesTime }} {{ $t('common_add.buy') }} {{ addConsume.goodsName.value }}({{
$t('common_add.operator') }}: {{ adminData.adminName }})
</div> </div>
<div style="margin-top: 10px"> <div style="margin-top: 10px">
<p>{{ $t('common_add.continueOperation') }}</p> <p>{{ $t('common_add.continueOperation') }}</p>

Loading…
Cancel
Save