金币系统前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

693 lines
20 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. <script setup>
  2. import { ref, onMounted, reactive, computed } from "vue";
  3. import ElementPlus from "element-plus";
  4. import { ElMessage, ElMessageBox } from "element-plus";
  5. import { AiFillRead } from "vue-icons-plus/ai";
  6. import axios from "axios";
  7. import moment from "moment";
  8. import API from "../../api/index.js";
  9. // 变量
  10. //这是获取用户信息的接口
  11. const adminData = ref({});
  12. const getAdminData = async function () {
  13. try {
  14. const result = await API.post(
  15. "http://54.251.137.151:10702/admin/userinfo",
  16. {}
  17. );
  18. adminData.value = result;
  19. console.log("请求成功", result);
  20. console.log("用户信息", adminData.value);
  21. } catch (error) {
  22. console.log("请求失败", error);
  23. }
  24. };
  25. // 充值明细表格
  26. const tableData = ref([]);
  27. // 搜索======================================
  28. // 搜索rechargeVo
  29. const rechargeVo = ref({});
  30. // 搜索对象
  31. const getObj = ref({
  32. pageNum: 1,
  33. pageSize: 50,
  34. });
  35. //分页总条目
  36. const total = ref(100);
  37. // 搜索对象时间
  38. const getTime = ref([]);
  39. // 搜索活动列表
  40. const activity = ref([]);
  41. // 所有信息
  42. const allData = ref([]);
  43. // 搜索地区列表
  44. const area = ref([]);
  45. //标签页默认高亮选项
  46. const activeName = ref("all");
  47. // 充值方式选项
  48. const rechargeWay = ref([]);
  49. // 获取充值方式的数据的接口
  50. const getPayWay = async function () {
  51. try {
  52. const result = await API.post(
  53. "http://54.251.137.151:10702/recharge/recharge/getWay",
  54. {}
  55. );
  56. rechargeWay.value = result.data.filter((item) => item);
  57. console.log("请求成功", result);
  58. console.log("充值方式", rechargeWay.value);
  59. } catch (error) {
  60. console.log("请求失败", error);
  61. }
  62. };
  63. // //表格高度
  64. // const tableHeight = computed(function () {
  65. // return (getObj.value.pageSize + 2) * 60 + "px";
  66. // });
  67. // 方法
  68. // 合计数存储
  69. const totalData = ref({
  70. totalmoney: 0,
  71. totalRcoin: 0,
  72. totalFcoin: 0,
  73. });
  74. const totalmoney = ref(0);
  75. const totalRcoin = ref(0);
  76. const totalFcoin = ref(0);
  77. // 搜索==============================================================
  78. // 搜索方法
  79. const get = async function (val) {
  80. try {
  81. // 地区赋值
  82. if (adminData.value.area === "泰国") {
  83. rechargeVo.value.areas = ["泰国", "越南"];
  84. } else if (adminData.value.area !== "总部") {
  85. rechargeVo.value.area = adminData.value.area;
  86. }
  87. // 搜索参数页码赋值
  88. if (typeof val === "number") {
  89. getObj.value.pageNum = val;
  90. }
  91. // 搜索参数时间赋值
  92. if (getTime.value != null) {
  93. if (getTime.value.startDate != "" && getTime.value.endDate != "") {
  94. rechargeVo.value.startDate = getTime.value[0];
  95. rechargeVo.value.endDate = getTime.value[1];
  96. }
  97. } else {
  98. rechargeVo.value.startDate = "";
  99. rechargeVo.value.endDate = "";
  100. }
  101. // 搜索参数赋值
  102. rechargeVo.value.sortField = sortField.value;
  103. rechargeVo.value.sortOrder = sortOrder.value;
  104. console.log("搜索参数", getObj.value);
  105. // 发送POST请求
  106. const result = await API.post(
  107. "http://54.251.137.151:10702/recharge/recharge",
  108. {
  109. ...getObj.value,
  110. rechargeVo: { ...rechargeVo.value },
  111. }
  112. );
  113. // 复制一份 rechargeVo.value 并移除排序字段和排序方式
  114. const detailWithoutSort = ref({
  115. area: rechargeVo.value.area,
  116. adminId: rechargeVo.value.adminId,
  117. startDate: rechargeVo.value.startDate,
  118. endDate: rechargeVo.value.endDate,
  119. });
  120. const result2 = await API.post(
  121. "http://54.251.137.151:10702/recharge/recharge/RechargeA",
  122. {
  123. ...detailWithoutSort.value,
  124. }
  125. );
  126. // 检查 result2 是否为空
  127. if (!result2 || !result2.data || result2.data.length === 0) {
  128. totalmoney.value = 0;
  129. totalRcoin.value = 0;
  130. totalFcoin.value = 0;
  131. } else {
  132. // 做一个判断,如果result2.data[i].flag="待审核",那么 totalData.value = result2.data[i],否则就赋值为0
  133. for (let i = 0; i < result2.data.length; i++) {
  134. if (result2.data[i].flag == "已通过") {
  135. totalData.value = result2.data[i];
  136. totalmoney.value = totalData.value.sumRaudit1;
  137. totalRcoin.value = totalData.value.sumRaudit1;
  138. totalFcoin.value = totalData.value.sumRaudit2;
  139. break;
  140. }
  141. }
  142. }
  143. // 将响应结果存储到响应式数据中
  144. console.log("请求成功", result);
  145. // 存储表格数据
  146. tableData.value = result.data.list;
  147. console.log("tableData", tableData.value);
  148. // 存储分页总数
  149. total.value = result.data.total;
  150. console.log("total", total.value);
  151. } catch (error) {
  152. console.log("请求失败", error);
  153. // 在这里可以处理错误逻辑,比如显示错误提示等
  154. }
  155. };
  156. // 搜索
  157. const search = function () {
  158. getObj.value.pageNum = 1;
  159. get();
  160. };
  161. // 重置
  162. const reset = function () {
  163. rechargeVo.value.activityId = "";
  164. rechargeVo.value.rechargeWay = "";
  165. rechargeVo.value.area = "";
  166. rechargeVo.value.startDate = "";
  167. rechargeVo.value.endDate = "";
  168. sortField.value = "";
  169. sortOrder.value = "";
  170. getTime.value = {};
  171. };
  172. // 今天
  173. const getToday = function () {
  174. const today = new Date();
  175. const startDate = new Date(
  176. today.getFullYear(),
  177. today.getMonth(),
  178. today.getDate()
  179. );
  180. const endDate = new Date(
  181. today.getFullYear(),
  182. today.getMonth(),
  183. today.getDate() + 1
  184. );
  185. getTime.value = [startDate, endDate];
  186. console.log("getTime", getTime.value);
  187. get();
  188. };
  189. // 昨天
  190. const getYesterday = function () {
  191. const yesterday = new Date();
  192. yesterday.setDate(yesterday.getDate() - 1);
  193. const startDate = new Date(
  194. yesterday.getFullYear(),
  195. yesterday.getMonth(),
  196. yesterday.getDate()
  197. );
  198. const endDate = new Date(
  199. yesterday.getFullYear(),
  200. yesterday.getMonth(),
  201. yesterday.getDate() + 1
  202. );
  203. getTime.value = [startDate, endDate];
  204. console.log("getTime", getTime.value);
  205. get();
  206. };
  207. // 近7天
  208. const get7Days = function () {
  209. const today = new Date();
  210. const startDate = new Date(
  211. today.getFullYear(),
  212. today.getMonth(),
  213. today.getDate() - 6
  214. );
  215. const endDate = new Date(
  216. today.getFullYear(),
  217. today.getMonth(),
  218. today.getDate() + 1
  219. );
  220. getTime.value = [startDate, endDate];
  221. console.log("getTime", getTime.value);
  222. get();
  223. };
  224. //全部充值明细
  225. const adminAll = function () {
  226. console.log("adminAll");
  227. rechargeVo.value.status = "";
  228. getObj.value.pageNum = 1;
  229. get();
  230. };
  231. //待审核充值明细
  232. const adminWait = function () {
  233. rechargeVo.value.status = 0;
  234. getObj.value.pageNum = 1;
  235. get();
  236. console.log("adminWait");
  237. };
  238. //已通过充值明细
  239. const adminPass = function () {
  240. rechargeVo.value.status = 1;
  241. getObj.value.pageNum = 1;
  242. get();
  243. console.log("adminPass");
  244. };
  245. //已驳回充值明细
  246. const adminReject = function () {
  247. rechargeVo.value.status = 2;
  248. getObj.value.pageNum = 1;
  249. get();
  250. console.log("adminReject");
  251. };
  252. //点击标签页
  253. const handleClick = function (tab, event) {
  254. if (tab.props.name === "all") {
  255. adminAll();
  256. } else if (tab.props.name === "wait") {
  257. adminWait();
  258. } else if (tab.props.name === "pass") {
  259. adminPass();
  260. } else if (tab.props.name === "reject") {
  261. adminReject();
  262. }
  263. };
  264. // 获取活动名称
  265. const getActivity = async function () {
  266. try {
  267. // 发送POST请求
  268. const result = await API.post(
  269. "http://54.251.137.151:10702/recharge/activity/select",
  270. {}
  271. );
  272. // 将响应结果存储到响应式数据中
  273. console.log("请求成功", result);
  274. // 存储表格数据
  275. activity.value = result.data;
  276. console.log("activity", activity.value);
  277. } catch (error) {
  278. console.log("请求失败", error);
  279. // 在这里可以处理错误逻辑,比如显示错误提示等
  280. }
  281. };
  282. // 获取地区
  283. // 获取地区
  284. const getArea = async function () {
  285. try {
  286. // 发送POST请求
  287. const result = await API.post(
  288. "http://54.251.137.151:10702/recharge/user/search",
  289. {}
  290. );
  291. // 将响应结果存储到响应式数据中
  292. console.log("请求成功", result);
  293. // 存储地区信息
  294. area.value = result.data;
  295. console.log("地区", area.value);
  296. } catch (error) {
  297. console.log("请求失败", error);
  298. // 在这里可以处理错误逻辑,比如显示错误提示等
  299. }
  300. };
  301. // 验证跳转输入框的数字是否合法
  302. const checkNumber = function () {
  303. if (typeof parseInt(getObj.value.pageNum) === "number") {
  304. console.log(
  305. "总共有多少页" + Math.ceil(total.value / getObj.value.pageSize)
  306. );
  307. if (
  308. getObj.value.pageNum > 0 &&
  309. getObj.value.pageNum <= Math.ceil(total.value / getObj.value.pageSize)
  310. ) {
  311. getObj.value.pageNum = parseInt(getObj.value.pageNum);
  312. console.log("输入的数字合法");
  313. get();
  314. } else {
  315. //提示
  316. ElMessage({
  317. type: "error",
  318. message: "请检查输入内容",
  319. });
  320. }
  321. } else {
  322. //提示
  323. ElMessage({
  324. type: "error",
  325. message: "请检查输入内容",
  326. });
  327. }
  328. };
  329. // 挂载
  330. onMounted(async function () {
  331. await getAdminData();
  332. await get();
  333. await getActivity();
  334. await getArea();
  335. await getPayWay();
  336. });
  337. // 新增排序字段和排序方式
  338. const sortField = ref("");
  339. const sortOrder = ref("");
  340. // 处理排序事件
  341. const handleSortChange = (column) => {
  342. console.log("排序字段:", column.prop);
  343. console.log("排序方式:", column.order);
  344. if (column.prop === "paidGold") {
  345. sortField.value = "recharge_gold";
  346. } else if (column.prop === "freeGold") {
  347. sortField.value = "free_gold";
  348. } else if (column.prop === "rechargeTime") {
  349. sortField.value = "recharge_time";
  350. } else if (column.prop === "createTime") {
  351. sortField.value = "create_time";
  352. } else if (column.prop === "paidMoney") {
  353. sortField.value = "paid_gold";
  354. }
  355. sortOrder.value = column.order === "ascending" ? "ASC" : "DESC";
  356. get();
  357. };
  358. </script>
  359. <template>
  360. <el-row>
  361. <el-col>
  362. <el-card style="margin-bottom: 20px">
  363. <el-row style="margin-bottom: 10px">
  364. <el-col :span="8">
  365. <div class="head-card-element">
  366. <el-text class="mx-1" size="large">活动名称</el-text>
  367. <el-select
  368. v-model="rechargeVo.activityId"
  369. placeholder="请选择活动名称"
  370. size="large"
  371. style="width: 240px"
  372. clearable
  373. >
  374. <el-option
  375. v-for="item in activity"
  376. :key="item.activityId"
  377. :label="item.activityName"
  378. :value="item.activityId"
  379. />
  380. </el-select>
  381. </div>
  382. </el-col>
  383. <el-col :span="8">
  384. <!-- <div class="head-card-element">
  385. <el-text class="mx-1" size="large">充值方式</el-text>
  386. <el-select
  387. v-model="rechargeVo.rechargeWay"
  388. placeholder="请选择充值方式"
  389. size="large"
  390. style="width: 240px"
  391. clearable
  392. >
  393. <el-option
  394. v-for="item in rechargeWay"
  395. :key="item"
  396. :label="item"
  397. :value="item"
  398. />
  399. </el-select>
  400. </div> -->
  401. </el-col>
  402. <el-col :span="8">
  403. <div class="head-card-element" v-if="adminData.area == '总部'">
  404. <el-text class="mx-1" size="large">所属地区</el-text>
  405. <el-select
  406. v-model="rechargeVo.area"
  407. placeholder="请选择所属地区"
  408. size="large"
  409. style="width: 240px"
  410. clearable
  411. >
  412. <el-option
  413. v-for="item in area"
  414. :key="item"
  415. :label="item"
  416. :value="item"
  417. />
  418. </el-select>
  419. </div>
  420. </el-col>
  421. </el-row>
  422. <el-row>
  423. <el-col :span="21">
  424. <div class="head-card-element">
  425. <el-text class="mx-1" size="large">充值时间</el-text>
  426. <el-date-picker
  427. v-model="getTime"
  428. type="datetimerange"
  429. range-separator="至"
  430. start-placeholder="起始时间"
  431. end-placeholder="结束时间"
  432. />
  433. <el-button style="margin-left: 10px" @click="getToday()"
  434. ></el-button
  435. >
  436. <el-button @click="getYesterday()"></el-button>
  437. <el-button @click="get7Days()">近7天</el-button>
  438. </div>
  439. </el-col>
  440. <el-col :span="3">
  441. <div class="head-card-btn">
  442. <el-button @click="reset()">重置</el-button>
  443. <el-button type="primary" @click="search()">查询</el-button>
  444. </div>
  445. </el-col>
  446. </el-row>
  447. </el-card>
  448. </el-col>
  449. </el-row>
  450. <el-row>
  451. <el-col>
  452. <el-card>
  453. <el-tabs
  454. v-model="activeName"
  455. type="card"
  456. class="demo-tabs"
  457. @tab-click="handleClick"
  458. >
  459. <el-tab-pane label="全部" name="all"></el-tab-pane>
  460. <el-tab-pane label="待审核" name="wait"></el-tab-pane>
  461. <el-tab-pane label="已通过" name="pass"></el-tab-pane>
  462. <el-tab-pane label="已驳回" name="reject"></el-tab-pane>
  463. <div>
  464. 充值金额{{ totalmoney / 100 }}新币永久金币{{
  465. totalRcoin / 100
  466. }}金币免费金币{{ totalFcoin / 100 }}金币
  467. </div>
  468. </el-tabs>
  469. <!-- 设置表格容器的高度和滚动样式 -->
  470. <div style="height: 520px; overflow-y: auto">
  471. <el-table
  472. :data="tableData"
  473. style="width: 100%"
  474. height="520px"
  475. @sort-change="handleSortChange"
  476. >
  477. <el-table-column
  478. type="index"
  479. label="序号"
  480. width="70px"
  481. fixed="left"
  482. >
  483. <template #default="scope">
  484. <span>{{
  485. scope.$index + 1 + (getObj.pageNum - 1) * getObj.pageSize
  486. }}</span>
  487. </template>
  488. </el-table-column>
  489. <el-table-column
  490. fixed="left"
  491. prop="username"
  492. label="姓名"
  493. width="100px"
  494. />
  495. <el-table-column
  496. fixed="left"
  497. prop="jwcode"
  498. label="精网号"
  499. width="110px"
  500. />
  501. <el-table-column prop="area" label="所属地区" width="100px" />
  502. <el-table-column
  503. prop="activityName"
  504. label="活动名称"
  505. width="150px"
  506. />
  507. <el-table-column prop="" label="货币名称" width="120px" />
  508. <el-table-column
  509. prop="paidMoney"
  510. label="充值金额"
  511. width="120px"
  512. sortable=" custom"
  513. >
  514. <template #default="scope">
  515. <span>{{ scope.row.paidGold / 100 }}</span>
  516. </template>
  517. </el-table-column>
  518. <el-table-column
  519. prop="rechargeWay"
  520. label="充值方式"
  521. width="100px"
  522. />
  523. <el-table-column
  524. prop="paidGold"
  525. label="永久金币"
  526. sortable="“custom”"
  527. width="110px"
  528. >
  529. <template #default="scope">
  530. <span>{{ scope.row.paidGold / 100 }}</span>
  531. </template>
  532. </el-table-column>
  533. <el-table-column
  534. prop="freeGold"
  535. label="免费金币"
  536. sortable="“custom”"
  537. width="110px"
  538. >
  539. <template #default="scope">
  540. <span>{{ scope.row.freeGold / 100 }}</span>
  541. </template>
  542. </el-table-column>
  543. <el-table-column
  544. prop="remark"
  545. label="备注"
  546. width="200px"
  547. show-overflow-tooltip
  548. />
  549. <el-table-column prop="payWay" label="支付方式" width="100px" />
  550. <el-table-column
  551. prop="rechargeVoucher"
  552. label="支付凭证"
  553. width="150px"
  554. >
  555. <template #default="scope">
  556. <el-image
  557. :preview-src-list="[scope.row.rechargeVoucher]"
  558. preview-teleported="true"
  559. :src="scope.row.rechargeVoucher"
  560. alt="凭证"
  561. style="width: 50px; height: 50px"
  562. />
  563. </template>
  564. </el-table-column>
  565. <el-table-column prop="name" label="提交人" width="100px" />
  566. <el-table-column prop="status" label="状态" width="100px">
  567. <template #default="scope">
  568. <span v-if="scope.row.status === 1">
  569. <div class="status">
  570. <span class="green-dot"></span>
  571. <span>已通过</span>
  572. </div>
  573. </span>
  574. <span v-if="scope.row.status === 0">
  575. <div class="status">
  576. <span class="grey-dot"></span>
  577. <span>待审核</span>
  578. </div>
  579. </span>
  580. <span v-if="scope.row.status === 2">
  581. <div class="status">
  582. <span class="red-dot"></span>
  583. <span>已驳回</span>
  584. </div>
  585. </span>
  586. </template>
  587. </el-table-column>
  588. <el-table-column
  589. prop="reson"
  590. label="驳回理由"
  591. width="200px"
  592. show-overflow-tooltip
  593. />
  594. <el-table-column
  595. prop="rechargeTime"
  596. sortable="“custom”"
  597. label="交款时间"
  598. width="200px"
  599. >
  600. <template #default="scope">
  601. {{
  602. moment(scope.row.rechargeTime).format("YYYY-MM-DD HH:mm:ss")
  603. }}
  604. </template>
  605. </el-table-column>
  606. <el-table-column
  607. prop="createTime"
  608. sortable="“custom”"
  609. label="提交时间"
  610. width="200px"
  611. />
  612. </el-table>
  613. </div>
  614. <!-- 分页 -->
  615. <div class="pagination" style="margin-top: 20px">
  616. <el-pagination
  617. background
  618. :page-size="getObj.pageSize"
  619. layout="slot"
  620. :total="total"
  621. >
  622. <div>{{ total }},每页</div>
  623. <el-select
  624. v-model="getObj.pageSize"
  625. class="page-size"
  626. @change="get()"
  627. style="width: 80px"
  628. >
  629. <el-option
  630. v-for="item in [5, 10, 20, 50, 100]"
  631. :key="item"
  632. :label="item"
  633. :value="item"
  634. ></el-option>
  635. </el-select>
  636. <div></div>
  637. </el-pagination>
  638. <el-pagination
  639. background
  640. layout="prev, pager, next,slot"
  641. :page-size="getObj.pageSize"
  642. :total="total"
  643. :current-page="getObj.pageNum"
  644. @current-change="get"
  645. >
  646. <div>跳至</div>
  647. <el-input
  648. v-model="getObj.pageNum"
  649. style="width: 40px"
  650. @change="checkNumber"
  651. />
  652. <div></div>
  653. </el-pagination>
  654. </div>
  655. </el-card>
  656. </el-col>
  657. </el-row>
  658. </template>
  659. <style scoped>
  660. .pagination {
  661. display: flex;
  662. }
  663. .status {
  664. display: flex;
  665. }
  666. .head-card {
  667. display: flex;
  668. }
  669. .head-card-element {
  670. margin-right: 20px;
  671. }
  672. .head-card-btn {
  673. margin-left: auto;
  674. }
  675. </style>