Browse Source

1.3日修改见日报

Hongxilin
hongxilin 4 months ago
parent
commit
245d11576a
  1. 191
      vue/gold-system/src/views/recharge/addRecharge.vue
  2. 7
      vue/gold-system/src/views/usergold/index.vue

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

@ -8,7 +8,8 @@ import API from "../../api/index.js";
import moment from "moment";
import { range, re } from "mathjs";
import * as xlsx from 'xlsx';
import _ from 'lodash';
import _, { before } from 'lodash';
import { th } from "element-plus/es/locales.mjs";
//
const imageUrl = ref("");
@ -281,6 +282,7 @@ const deleteRecharge = function () {
//
// jwcode
const jwcodeList = ref([]);
let jwcodeSet;
// jwcode
const getJwcodeList = async function () {
try {
@ -294,16 +296,34 @@ const getJwcodeList = async function () {
console.log("请求成功", result);
//
jwcodeList.value = result.data;
jwcodeList.value = jwcodeList.value.map((item) => ({
value: item,
label: item,
}));
console.log("精网号", jwcodeList.value);
// set
jwcodeSet = new Set(jwcodeList.value);
console.log("精网号set", jwcodeSet);
} catch (error) {
console.log("请求失败", error);
//
}
};
//
//
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) {
row.isInputInvalid = true;
row.inputErrorMessage = '精网号不存在';
errorCount.value++;
return;
} else {
row.isInputInvalid = false;
row.inputErrorMessage = '';
errorCount.value--;
}
}
//
const batchRechargeVisible = ref(false);
const jwcodeSelectRef = ref(null);
@ -316,6 +336,11 @@ const batchData = ref([
{
line: 1,
showInput: true,
isInputInvalid: false,
inputErrorMessage: '',
freeGold: "0",
rechargeGold: "0",
paidGold: "0",
},
]);
@ -332,52 +357,6 @@ const batchInit = function () {
openBatchRechargeVisible();
};
//
const addScrollListener = () => {
const SELECTWRAP_DOM = document.querySelector(
".el-select-dropdown .el-select-dropdown__wrap"
);
if (SELECTWRAP_DOM) {
SELECTWRAP_DOM.addEventListener("scroll", function () {
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) binding.value();
});
}
};
//
const vJwcodeLoadmore = {
mounted(el, binding) {
nextTick(() => {
console.log("el===", el, "binding===", binding);
const SELECTWRAP_DOM = el.querySelector(
".el-select-dropdown .el-select-dropdown__wrap"
);
console.log("SELECTWRAP_DOM===", SELECTWRAP_DOM);
if (SELECTWRAP_DOM) {
SELECTWRAP_DOM.addEventListener("scroll", function () {
/**
* scrollHeight 获取元素内容高度(只读)
* scrollTop 获取或者设置元素的偏移值,
* 常用于:计算滚动条的位置, 当一个元素的容器没有产生垂直方向的滚动条, 那它的scrollTop的值默认为0.
* clientHeight 读取元素的可见高度(只读)
* 如果元素滚动到底, 下面等式返回true, 没有则返回false:
* ele.scrollHeight - ele.scrollTop === ele.clientHeight;
*/
const condition =
this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) binding.value();
});
}
});
},
};
//
// const jwcodeSelectScrollerListener = () => {
// console.log(jwcodeSelectRef.value, 'jwcodeSelectRef.value')
// if (jwcodeSelectRef.value) {
// directives.loadmore(jwcodeSelectRef.value, loadMore(rangeNumber.value));
// }
// };
//
const addLineObj = ref(0);
//
@ -385,6 +364,11 @@ const addLine = function () {
batchData.value.unshift({
line: ++i.value,
showInput: true,
isInputInvalid: false,
inputErrorMessage: '',
freeGold: "0",
rechargeGold: "0",
paidGold: "0",
});
};
const loading = ref(false);
@ -403,36 +387,34 @@ const loading = ref(false);
// ElMessage.error("");
// }
// }
//
const addLines = async function () {
try {
loading.value = true; // loadingtrue
await nextTick(); //
// loading.value = true; // loadingtrue
// console.log(loading.value, "loading.value");
const addLinesPromises = [];
for (let j = 0; j < addLineObj.value; j++) {
addLinesPromises.push(
new Promise((resolve) => {
batchData.value.unshift({
const newItems = Array.from({ length: addLineObj.value }, (_, index) => reactive({
line: ++i.value,
showInput: true,
});
resolve();
})
);
}
await Promise.all(addLinesPromises);
isInputInvalid: false,
inputErrorMessage: '',
freeGold: "0",
rechargeGold: "0",
paidGold: "0",
}));
batchData.value = [...newItems, ...batchData.value];
//
await nextTick(); //
loading.value = false; // loadingfalse
ElMessage.success("添加成功");
// loading.value = false; // loadingfalse
} catch (error) {
console.log("添加失败", error);
ElMessage.error("添加失败");
//
loading.value = false;
// loading.value = false;
}
};
// excelref
const uploadRefMap = ref({});
// excel
@ -634,6 +616,7 @@ const handleBatchAvatarSuccess = (response, uploadFile) => {
};
//
const batchAdd = async function () {
try {
console.log("batchData===", batchData.value);
let msg = '';
if (batchData.value.length == 0) {
@ -643,6 +626,14 @@ const batchAdd = async function () {
});
return;
}
if (errorCount.value > 0) {
console.log("errorCount.value", errorCount.value);
ElMessage({
type: "error",
message: "请检查输入的精网号是否正确!",
});
return;
}
for (let i = 0; i < batchData.value.length; i++) {
batchData.value[i].adminId = adminData.value.adminId;
batchData.value[i].area = adminData.value.area;
@ -663,6 +654,11 @@ const batchAdd = async function () {
msg += `充值金币不能为空! <br/>`;
}
if (
batchData.value[i].freeGold == "" ||
batchData.value[i].freeGold == null) {
msg += `免费金币不能为空! <br/>`;
}
if (
batchData.value[i].rechargeGold == "" ||
batchData.value[i].rechargeGold == null) {
msg += `充值金额不能为空! <br/>`;
@ -677,6 +673,8 @@ const batchAdd = async function () {
batchData.value[i].rechargeTime == null) {
msg += `交款时间不能为空! <br/>`;
}
if (msg != '' && msg != null) {
console.log(batchData.value[i]);
ElMessage({
dangerouslyUseHTMLString: true,
type: "error",
@ -684,7 +682,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",
@ -702,11 +701,20 @@ const batchAdd = async function () {
});
closeBatchRechargeVisible();
} catch (error) {
console.log("error===", error);
ElMessage.error("添加失败");
return;
};
}
// 使 _.throttle trailing false
const throttledBatchAdd = _.throttle(batchAdd, 5000, { trailing: false });
const throttledBatchAdd = _.throttle(batchAdd, 2000, { trailing: false });
//
const batchSettingObj = ref({});
const batchSettingObj = ref({
rechargeGold: "0",
paidGold: "0",
freeGold: "0",
});
//
const batchSettingVisible = ref(false);
//
@ -730,7 +738,11 @@ const batchSettingHandleAvatarSuccess = (response, uploadFile) => {
};
//
const cancelBatchSetting = function () {
batchSettingObj.value = {};
batchSettingObj.value = {
rechargeGold: "0",
paidGold: "0",
freeGold: "0",
};
closeBatchSettingVisible();
};
//
@ -804,7 +816,11 @@ const batchSettingConfirm = function () {
batchData.value[i].remark = batchSettingObj.value.remark;
}
}
batchSettingObj.value = {};
batchSettingObj.value = {
rechargeGold: "0",
paidGold: "0",
freeGold: "0",
};
closeBatchSettingVisible();
};
@ -949,9 +965,9 @@ 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 style="width: 60px" v-model="addLineObj"></el-input>
<el-input-number min="1" style="width: 100px;" controls-position="right" v-model="addLineObj"></el-input-number>
<span></span>
<el-button type="primary" @click="addLines()" style="margin-right: 10px">添加</el-button>
<el-button type="primary" @click="addLines" style="margin-right: 10px">添加</el-button>
</div>
<el-button type="warning" @click="batchSettingInit()" style="margin-right: 10px">批量设置</el-button>
<!-- <el-upload :ref="(el) => handleSetUploadRefMap(el)" action="" :http-request="httpExcelRequest" :limit="1" :show-file-list="false"
@ -961,7 +977,7 @@ onMounted(async function () {
<el-button type="danger" plain @click="batchDel()" style="margin-right: 10px; width: 130px">批量删除</el-button>
</el-row>
<el-row>
<el-table v-loading="loading" :data="batchData" border max-height="540px" style="height: 540px"
<el-table :data="batchData" border max-height="540px" style="height: 540px"
@selection-change="handleSelectionChangebatch">
<el-table-column type="selection" width="50px" />
<el-table-column property="index" label="序号" width="55px">
@ -970,16 +986,18 @@ onMounted(async function () {
</template>
</el-table-column>
<el-table-column property="jwcode" label="精网号" width="150px">
<!-- <template #default="scope">
<el-input v-if="scope.row.showInput" v-model="scope.row.jwcode" style="width: 110px" />
<span v-else>{{ scope.row.jwcode }}</span>
</template> -->
<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>
</template>
<!-- <template #default="scope">
<el-select-v2 v-if="scope.row.showInput" filterable clearable v-model="scope.row.jwcode"
placeholder="请选择精网号" style="widows: 110px;" :options="jwcodeList">
</el-select-v2>
<span v-else>{{ scope.row.jwcode }}</span>
</template>
</template> -->
</el-table-column>
<el-table-column property="activityName" label="活动名称" width="150px">
<template #default="scope">
@ -1002,7 +1020,7 @@ onMounted(async function () {
<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" />
<span v-else>{{ scope.row.paidGold }}</span>
<span v-else>{{ scope.row.freeGold }}</span>
</template>
</el-table-column>
<el-table-column property="rate" label="货币名称">
@ -1180,6 +1198,15 @@ p {
</style>
<style>
.error-message {
color: red;
font-size: 12px;
}
.is-invalid .el-input__inner {
border-color: red;
}
.avatar-uploader .el-upload {
border: 1px dashed var(--el-border-color);
border-radius: 6px;

7
vue/gold-system/src/views/usergold/index.vue

@ -47,6 +47,10 @@ const updateType = [
value: "2",
label: "退款",
},
{
value:"3",
label:"其他"
}
];
// //
@ -565,6 +569,9 @@ const get30 = function () {
<span v-if="scope.row.updateType == 2">
<span>退款</span>
</span>
<span v-if="scope.row.updateType == 3">
<span>其他</span>
</span>
</template>
</el-table-column>
<el-table-column prop="freeCoin" label="免费金币" width="130">

Loading…
Cancel
Save