金币系统前端
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.

386 lines
10 KiB

  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 axios from "axios";
  6. import moment from "moment";
  7. import { ta } from "element-plus/es/locales.mjs";
  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. const tableAllData = ref([]);
  29. // 各金币总数
  30. const rechargeCoin = ref(0);
  31. const freeCoin = ref(0);
  32. const taskCoin = ref(0);
  33. // 搜索===========================================
  34. //分页总条目
  35. const total = ref(100);
  36. // 搜索对象时间
  37. const getTime = ref([]);
  38. // 搜索detailY
  39. const detailY = ref({});
  40. // 不分页的搜索对象
  41. const getAllObj = ref({});
  42. // 搜索对象
  43. const getObj = ref({
  44. pageNum: 1,
  45. pageSize: 50,
  46. });
  47. // 支付方式选项
  48. const updateType = [
  49. {
  50. value: "0",
  51. label: "充值",
  52. },
  53. {
  54. value: "1",
  55. label: "消费",
  56. },
  57. {
  58. value: "2",
  59. label: "退款",
  60. },
  61. ];
  62. // //表格高度
  63. // const tableHeight = computed(function () {
  64. // return (getObj.value.pageSize + 2) * 38 + "px";
  65. // });
  66. // 方法
  67. // 搜索===========================================================================
  68. // 搜索方法
  69. const get = async function (val) {
  70. try {
  71. // 地区赋值
  72. if (adminData.value.area != "总部") {
  73. detailY.value.area = adminData.value.area;
  74. }
  75. // 搜索参数页码赋值
  76. if (typeof val === "number") {
  77. getObj.value.pageNum = val;
  78. }
  79. // 搜索参数时间赋值
  80. if (getTime.value != null) {
  81. if (getTime.value.startDate != "" && getTime.value.endDate != "") {
  82. detailY.value.startDate = getTime.value[0];
  83. detailY.value.endDate = getTime.value[1];
  84. }
  85. } else {
  86. detailY.value.startDate = "";
  87. detailY.value.endDate = "";
  88. }
  89. console.log("搜索参数", getObj.value);
  90. // 发送POST请求
  91. const result = await API.post(
  92. "http://54.251.137.151:10702/detailY/select",
  93. {
  94. ...getObj.value,
  95. detailYgold: { ...detailY.value },
  96. }
  97. );
  98. // const result2 = await API.post("http://54.251.137.151:10702/detailY/select", {
  99. // ...getAllObj.value,
  100. // detailY: { ...detailY.value },
  101. // });
  102. // 将响应结果存储到响应式数据中
  103. console.log("请求成功", result);
  104. // console.log("请求成功2", result2);
  105. // 存储表格数据
  106. tableData.value = result.data.list;
  107. console.log("tableData", tableData.value);
  108. // tableAllData.value = result2.data;
  109. // console.log("tableAllData", tableAllData.value);
  110. // 存储分页总数
  111. total.value = result.data.total;
  112. console.log("total", total.value);
  113. } catch (error) {
  114. console.log("请求失败", error);
  115. // 在这里可以处理错误逻辑,比如显示错误提示等
  116. }
  117. };
  118. // 搜索
  119. const search = function () {
  120. getObj.value.pageNum = 1;
  121. get();
  122. };
  123. // 重置
  124. const reset = function () {
  125. detailY.value = {};
  126. };
  127. // 验证跳转输入框的数字是否合法
  128. const checkNumber = function () {
  129. if (typeof parseInt(getObj.value.pageNum) === "number") {
  130. console.log(
  131. "总共有多少页" + Math.ceil(total.value / getObj.value.pageSize)
  132. );
  133. if (
  134. getObj.value.pageNum > 0 &&
  135. getObj.value.pageNum <= Math.ceil(total.value / getObj.value.pageSize)
  136. ) {
  137. getObj.value.pageNum = parseInt(getObj.value.pageNum);
  138. console.log("输入的数字合法");
  139. get();
  140. } else {
  141. //提示
  142. ElMessage({
  143. type: "error",
  144. message: "请检查输入内容",
  145. });
  146. }
  147. } else {
  148. //提示
  149. ElMessage({
  150. type: "error",
  151. message: "请检查输入内容",
  152. });
  153. }
  154. };
  155. //选地区
  156. const area = [
  157. {
  158. value: "马来西亚",
  159. label: "马来西亚",
  160. },
  161. {
  162. value: "新加坡",
  163. label: "新加坡",
  164. },
  165. {
  166. value: "香港",
  167. label: "香港",
  168. },
  169. {
  170. value: "泰国",
  171. label: "泰国",
  172. },
  173. {
  174. value: "加拿大",
  175. label: "加拿大",
  176. },
  177. {
  178. value: "越南HCM",
  179. label: "越南HCM",
  180. },
  181. ];
  182. // 挂载
  183. onMounted(async function () {
  184. await getAdminData();
  185. await get();
  186. });
  187. </script>
  188. <template>
  189. <el-row>
  190. <el-col>
  191. <el-card style="margin-bottom: 20px">
  192. <div class="head-card">
  193. <div class="head-card-element">
  194. <el-text class="mx-1" size="large">精网号</el-text>
  195. <el-input
  196. v-model="detailY.jwcode"
  197. style="width: 240px"
  198. placeholder="请输入精网号"
  199. clearable
  200. />
  201. </div>
  202. <div
  203. class="head-card-element"
  204. style="margin-left: 50px"
  205. v-if="adminData.area == '总部'"
  206. >
  207. <el-text class="mx-1" size="large">所属地区</el-text>
  208. <el-select
  209. v-model="detailY.area"
  210. placeholder="请选择所属地区"
  211. style="width: 240px"
  212. clearable
  213. >
  214. <el-option
  215. v-for="item in area"
  216. :key="item.value"
  217. :label="item.label"
  218. :value="item.value"
  219. />
  220. </el-select>
  221. </div>
  222. <div class="head-card-btn">
  223. <el-button @click="reset()">重置</el-button>
  224. <el-button type="primary" @click="search()">查询</el-button>
  225. </div>
  226. </div>
  227. </el-card>
  228. </el-col>
  229. </el-row>
  230. <el-row>
  231. <el-col>
  232. <el-card>
  233. <!-- 设置表格容器的高度和滚动样式 -->
  234. <div style="height: 750px; overflow-y: auto">
  235. <el-table :data="tableData" style="width: 100%" height="750px">
  236. <el-table-column
  237. type="index"
  238. label="序号"
  239. width="100px"
  240. fixed="left"
  241. >
  242. <template #default="scope">
  243. <span>{{
  244. scope.$index + 1 + (getObj.pageNum - 1) * getObj.pageSize
  245. }}</span>
  246. </template>
  247. </el-table-column>
  248. <el-table-column prop="name" label="姓名" width="200" />
  249. <el-table-column prop="jwcode" label="精网号" width="170" />
  250. <el-table-column prop="area" label="所属地区" width="200" />
  251. <el-table-column prop="allJb" label="总金币" width="130">
  252. <template #default="scope">
  253. <span>{{
  254. (scope.row.free12 +
  255. scope.row.free6 +
  256. scope.row.coreJb +
  257. scope.row.buyJb) /
  258. 100
  259. }}</span>
  260. </template>
  261. </el-table-column>
  262. <el-table-column prop="buyJb" label="永久金币" width="110">
  263. <template #default="scope">
  264. <span>{{ Math.abs(scope.row.buyJb) / 100 }}</span>
  265. </template>
  266. </el-table-column>
  267. <el-table-column prop="freeJb" label="免费金币" width="110">
  268. <template #default="scope">
  269. <el-dropdown>
  270. <span class="el-dropdown-link">
  271. <span>{{
  272. Math.abs(scope.row.free6 + scope.row.free12) / 100
  273. }}</span>
  274. <i class="el-icon-arrow-down el-icon--right"></i>
  275. </span>
  276. <template #dropdown>
  277. <el-dropdown-menu>
  278. <el-dropdown-item
  279. >6月份到期金币:
  280. {{ scope.row.free6 / 100 }}</el-dropdown-item
  281. >
  282. <el-dropdown-item
  283. >12月份到期金币:
  284. {{ scope.row.free12 / 100 }}</el-dropdown-item
  285. >
  286. </el-dropdown-menu>
  287. </template>
  288. </el-dropdown>
  289. </template>
  290. </el-table-column>
  291. <el-table-column prop="coreJb" label="任务金币" width="160">
  292. <template #default="scope">
  293. <span>{{ Math.abs(scope.row.coreJb) / 100 }}</span>
  294. </template>
  295. </el-table-column>
  296. <el-table-column prop="rcoin" label="历史充值" width="150">
  297. <template #default="scope">
  298. <span>{{ scope.row.rcoin / 100 }}</span>
  299. </template>
  300. </el-table-column>
  301. <el-table-column prop="scoin" label="历史消费" width="150">
  302. <template #default="scope">
  303. <span>{{ Math.abs(scope.row.scoin) / 100 }}</span>
  304. </template>
  305. </el-table-column>
  306. </el-table>
  307. </div>
  308. <!-- 分页 -->
  309. <!-- 分页 -->
  310. <div class="pagination" style="margin-top: 20px">
  311. <el-pagination
  312. background
  313. :page-size="getObj.pageSize"
  314. layout="slot"
  315. :total="total"
  316. >
  317. <div>{{ total }},每页</div>
  318. <el-select
  319. v-model="getObj.pageSize"
  320. class="page-size"
  321. @change="get()"
  322. style="width: 80px"
  323. >
  324. <el-option
  325. v-for="item in [5, 10, 20, 50, 100]"
  326. :key="item"
  327. :label="item"
  328. :value="item"
  329. ></el-option>
  330. </el-select>
  331. <div></div>
  332. </el-pagination>
  333. <el-pagination
  334. background
  335. layout="prev, pager, next,slot"
  336. :page-size="getObj.pageSize"
  337. :total="total"
  338. :current-page="getObj.pageNum"
  339. @current-change="get"
  340. >
  341. <div>跳至</div>
  342. <el-input
  343. v-model="getObj.pageNum"
  344. style="width: 40px"
  345. @change="checkNumber"
  346. />
  347. <div></div>
  348. </el-pagination>
  349. </div>
  350. </el-card>
  351. </el-col>
  352. </el-row>
  353. </template>
  354. <style scoped>
  355. .pagination {
  356. display: flex;
  357. }
  358. .status {
  359. display: flex;
  360. }
  361. .head-card {
  362. display: flex;
  363. }
  364. .head-card-element {
  365. margin-right: 20px;
  366. }
  367. .head-card-btn {
  368. margin-left: auto;
  369. }
  370. </style>