Browse Source

pull/2/head
donghaolin 4 months ago
parent
commit
93966cafda
  1. 108
      gold-system/src/views/recharge/addRecharge.vue

108
gold-system/src/views/recharge/addRecharge.vue

@ -7,7 +7,7 @@ import { ElMessageBox } from "element-plus";
import API from "../../api/index.js";
import moment from "moment";
import { range, re } from "mathjs";
import * as xlsx from 'xlsx';
import * as xlsx from "xlsx";
import _ from "lodash";
//
@ -256,7 +256,9 @@ function handleActivityChange(value) {
// paidGold
const calculatedFree = computed(() => {
if (
Math.trunc(addRecharge.value.paidGold / addRecharge.value.rechargeRatio) < 1
Math.trunc(addRecharge.value.paidGold / addRecharge.value.rechargeRatio) <
1 ||
addRecharge.value.rechargeRatio == 0
) {
return 0;
} else {
@ -322,17 +324,17 @@ const errorCount = ref(0);
//
const validateInput = function (row, index) {
console.log(jwcodeSet.has(row.jwcode), "has");
if (!jwcodeSet.has(row.jwcode) && row.jwcode != '' && row.jwcode != null) {
if (!jwcodeSet.has(row.jwcode) && row.jwcode != "" && row.jwcode != null) {
row.isInputInvalid = true;
row.inputErrorMessage = '精网号不存在';
row.inputErrorMessage = "精网号不存在";
errorCount.value++;
return;
} else {
row.isInputInvalid = false;
row.inputErrorMessage = '';
row.inputErrorMessage = "";
errorCount.value--;
}
}
};
//
const batchRechargeVisible = ref(false);
@ -347,7 +349,7 @@ const batchData = ref([
line: 1,
showInput: true,
isInputInvalid: false,
inputErrorMessage: '',
inputErrorMessage: "",
freeGold: "0",
rechargeGold: "0",
paidGold: "0",
@ -375,7 +377,7 @@ const addLine = function () {
line: ++i.value,
showInput: true,
isInputInvalid: false,
inputErrorMessage: '',
inputErrorMessage: "",
freeGold: "0",
rechargeGold: "0",
paidGold: "0",
@ -387,9 +389,9 @@ const addLines = async function () {
loading.value = true;
try {
loading.value = true; // loadingtrue
console.log(loading.value, "loading.value")
console.log(loading.value, "loading.value");
await new Promise(resolve => setTimeout(resolve, 100)); //
await new Promise((resolve) => setTimeout(resolve, 100)); //
// loadingtrue
await nextTick(); //
@ -398,7 +400,7 @@ const addLines = async function () {
line: ++i.value,
showInput: true,
isInputInvalid: false,
inputErrorMessage: '',
inputErrorMessage: "",
freeGold: "0",
rechargeGold: "0",
paidGold: "0",
@ -415,9 +417,9 @@ const addLines = async function () {
ElMessage.error("添加失败");
} finally {
loading.value = false;
console.log(loading.value, "loading.value")
console.log(loading.value, "loading.value");
}
}
};
//
// const addLines = async function () {
// try {
@ -451,7 +453,7 @@ const addLines = async function () {
// }
// };
// 使 _.throttle trailing false
const throttledAddLines = _.throttle(addLines, 500, { trailing: false });
const throttledAddLines = _.throttle(addLines, 500, { trailing: false });
// excelref
const uploadRefMap = ref({});
// excel
@ -655,7 +657,7 @@ const handleBatchAvatarSuccess = (response, uploadFile) => {
const batchAdd = async function () {
try {
console.log("batchData===", batchData.value);
let msg = '';
let msg = "";
if (batchData.value.length == 0) {
ElMessage({
type: "error",
@ -677,40 +679,47 @@ const batchAdd = async function () {
batchData.value[i].rechargeWay = "客服充值";
if (
batchData.value[i].jwcode == "" ||
batchData.value[i].jwcode == null) {
batchData.value[i].jwcode == null
) {
msg += `精网号不能为空! <br/>`;
}
if (
batchData.value[i].activityId == "" ||
batchData.value[i].activityId == null) {
batchData.value[i].activityId == null
) {
msg += `活动不能为空! <br/>`;
}
if (
batchData.value[i].paidGold == "" ||
batchData.value[i].paidGold == null) {
batchData.value[i].paidGold == null
) {
msg += `永久金币不能为空! <br/>`;
}
if (
batchData.value[i].freeGold == "" ||
batchData.value[i].freeGold == null) {
batchData.value[i].freeGold == null
) {
msg += `免费金币不能为空! <br/>`;
}
if (
batchData.value[i].rechargeGold == "" ||
batchData.value[i].rechargeGold == null) {
batchData.value[i].rechargeGold == null
) {
msg += `充值金额不能为空! <br/>`;
}
if (
batchData.value[i].payWay == "" ||
batchData.value[i].payWay == null) {
batchData.value[i].payWay == null
) {
msg += `收款方式不能为空! <br/>`;
}
if (
batchData.value[i].rechargeTime == "" ||
batchData.value[i].rechargeTime == null) {
batchData.value[i].rechargeTime == null
) {
msg += `交款时间不能为空! <br/>`;
}
if (msg != '' && msg != null) {
if (msg != "" && msg != null) {
console.log(batchData.value[i]);
ElMessage({
dangerouslyUseHTMLString: true,
@ -720,8 +729,8 @@ const batchAdd = async function () {
return;
}
}
console.log("batchData===", batchData.value);
console.log("batchData===", batchData.value);
const result = await API.post(
"http://192.168.8.93:10010/recharge/recharge/addmore",
@ -743,8 +752,8 @@ const batchAdd = async function () {
console.log("error===", error);
ElMessage.error("添加失败");
return;
};
}
}
};
// 使 _.throttle trailing false
const throttledBatchAdd = _.throttle(batchAdd, 2000, { trailing: false });
//
@ -1039,8 +1048,10 @@ onMounted(async function () {
<span style="color: #2fa1ff; margin-right: 5px" v-if="user.buyJb">{{
user.buyJb + user.free6 + user.free12 + user.coreJb
}}</span>
<span style="display: inline; white-space: nowrap; color: #b1b1b1" v-if="user.buyJb">(永久金币:{{ user.buyJb
}};免费金币:{{
<span
style="display: inline; white-space: nowrap; color: #b1b1b1"
v-if="user.buyJb"
>(永久金币:{{ user.buyJb }};免费金币:{{
user.free6 + user.free12
}};任务金币:{{ user.coreJb }})</span
>
@ -1095,9 +1106,19 @@ onMounted(async function () {
<!-- <el-button type="primary" @click="addLine()" style="margin-right: 10px">新增一行</el-button> -->
<div style="font-weight: bold; font-size: 20px">
<span>添加</span>
<el-input-number min="1" style="width: 100px;" controls-position="right" v-model="addLineObj"></el-input-number>
<el-input-number
min="1"
style="width: 100px"
controls-position="right"
v-model="addLineObj"
></el-input-number>
<span></span>
<el-button type="primary" @click="throttledAddLines" style="margin-right: 10px">添加</el-button>
<el-button
type="primary"
@click="throttledAddLines"
style="margin-right: 10px"
>添加</el-button
>
</div>
<el-button
type="warning"
@ -1133,10 +1154,16 @@ onMounted(async function () {
</el-table-column>
<el-table-column property="jwcode" label="精网号" width="150px">
<template #default="scope">
<el-input v-if="scope.row.showInput" :class="{ 'is-invalid': scope.row.isInputInvalid }"
@blur="validateInput(scope.row)" v-model="scope.row.jwcode" style="width: 110px" />
<p v-if="scope.row.isInputInvalid" class="error-message">{{
scope.row.inputErrorMessage }}</p>
<el-input
v-if="scope.row.showInput"
:class="{ 'is-invalid': scope.row.isInputInvalid }"
@blur="validateInput(scope.row)"
v-model="scope.row.jwcode"
style="width: 110px"
/>
<p v-if="scope.row.isInputInvalid" class="error-message">
{{ scope.row.inputErrorMessage }}
</p>
</template>
<!-- <template #default="scope">
<el-select-v2 v-if="scope.row.showInput" filterable clearable v-model="scope.row.jwcode"
@ -1188,7 +1215,11 @@ onMounted(async function () {
</el-table-column>
<el-table-column property="freeGold" label="免费金币" width="110px">
<template #default="scope">
<el-input v-if="scope.row.showInput" v-model="scope.row.freeGold" style="width: 70px" />
<el-input
v-if="scope.row.showInput"
v-model="scope.row.freeGold"
style="width: 70px"
/>
<span v-else>{{ scope.row.freeGold }}</span>
</template>
</el-table-column>
@ -1369,7 +1400,10 @@ onMounted(async function () {
</el-select>
</el-form-item>
<el-form-item label="永久金币">
<el-input v-model="batchSettingObj.paidGold" placeholder="请输入永久金币"></el-input>
<el-input
v-model="batchSettingObj.paidGold"
placeholder="请输入永久金币"
></el-input>
</el-form-item>
<el-form-item label="免费金币">
<el-input v-model="batchSettingObj.freeGold"></el-input>

Loading…
Cancel
Save