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

444 lines
12 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month 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 axios from 'axios'
  6. import moment from 'moment'
  7. import { ta } from 'element-plus/es/locales.mjs'
  8. import API from '@/util/http'
  9. // 变量
  10. //这是获取用户信息的接口
  11. const adminData = ref({})
  12. const getAdminData = async function () {
  13. try {
  14. const result = await API({ url: '/admin/userinfo', data: {} })
  15. adminData.value = result
  16. console.log('请求成功', result)
  17. console.log('用户信息', adminData.value)
  18. } catch (error) {
  19. console.log('请求失败', error)
  20. }
  21. }
  22. // 充值明细表格
  23. const tableData = ref([])
  24. // 计算用户各金币总数的不分页对象
  25. const tableAllData = ref([])
  26. // 各金币总数 合计数
  27. const rechargeCoin = ref(0)
  28. const freeCoin = ref(0)
  29. const taskCoin = ref(0)
  30. // 搜索===========================================
  31. //分页总条目
  32. const total = ref(100)
  33. // 搜索对象时间
  34. const getTime = ref([])
  35. // 搜索detailY
  36. const detailY = ref({})
  37. // 不分页的搜索对象
  38. const getAllObj = ref({})
  39. // 搜索对象
  40. const getObj = ref({
  41. pageNum: 1,
  42. pageSize: 50
  43. })
  44. // 新增排序字段和排序方式
  45. const sortField = ref('')
  46. const sortOrder = ref('')
  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. // 地区赋值
  73. if (adminData.value.area === '泰国') {
  74. detailY.value.areas = ['泰国', '越南']
  75. } else if (adminData.value.area !== '总部') {
  76. detailY.value.area = adminData.value.area
  77. }
  78. // 搜索参数页码赋值
  79. if (typeof val === 'number') {
  80. getObj.value.pageNum = val
  81. }
  82. // 搜索参数时间赋值
  83. if (getTime.value != null) {
  84. if (getTime.value.startDate != '' && getTime.value.endDate != '') {
  85. detailY.value.startDate = getTime.value[0]
  86. detailY.value.endDate = getTime.value[1]
  87. }
  88. } else {
  89. detailY.value.startDate = ''
  90. detailY.value.endDate = ''
  91. }
  92. // 添加排序字段和排序方式到请求参数
  93. detailY.value.sortField = sortField.value
  94. detailY.value.sortOrder = sortOrder.value
  95. console.log('搜索参数', getObj.value)
  96. // 发送POST请求
  97. const result = await API({
  98. url: '/detailY/select',
  99. data: { ...getObj.value, detailYgold: { ...detailY.value } }
  100. })
  101. // 获取合计数
  102. const result2 = await API({
  103. url: '/detailY',
  104. data: {
  105. ...getAllObj.value,
  106. detailY: { ...detailY.value }
  107. }
  108. })
  109. // 将响应结果存储到响应式数据中
  110. console.log('请求成功', result)
  111. // console.log("请求成功2", result2);
  112. // 存储表格数据
  113. tableData.value = result.data.list
  114. console.log('tableData', tableData.value)
  115. tableAllData.value = result2.data
  116. // 下列各数除以100
  117. // 修改为保留两位小数
  118. rechargeCoin.value = parseFloat((tableAllData.value.sumR / 100).toFixed(2))
  119. freeCoin.value = parseFloat((tableAllData.value.sumF / 100).toFixed(2))
  120. taskCoin.value = parseFloat((tableAllData.value.sumT / 100).toFixed(2))
  121. // console.log("tableAllData", tableAllData.value);
  122. // 存储分页总数
  123. total.value = result.data.total
  124. console.log('total', total.value)
  125. } catch (error) {
  126. console.log('请求失败', error)
  127. // 在这里可以处理错误逻辑,比如显示错误提示等
  128. }
  129. }
  130. // 搜索
  131. const search = function () {
  132. getObj.value.pageNum = 1
  133. get()
  134. }
  135. // 重置
  136. const reset = function () {
  137. detailY.value = {}
  138. sortField.value = ''
  139. sortOrder.value = ''
  140. get()
  141. }
  142. // 验证跳转输入框的数字是否合法
  143. const checkNumber = function () {
  144. if (typeof parseInt(getObj.value.pageNum) === 'number') {
  145. console.log('总共有多少页' + Math.ceil(total.value / getObj.value.pageSize))
  146. if (
  147. getObj.value.pageNum > 0 &&
  148. getObj.value.pageNum <= Math.ceil(total.value / getObj.value.pageSize)
  149. ) {
  150. getObj.value.pageNum = parseInt(getObj.value.pageNum)
  151. console.log('输入的数字合法')
  152. get()
  153. } else {
  154. //提示
  155. ElMessage({
  156. type: 'error',
  157. message: '请检查输入内容'
  158. })
  159. }
  160. } else {
  161. //提示
  162. ElMessage({
  163. type: 'error',
  164. message: '请检查输入内容'
  165. })
  166. }
  167. }
  168. // 处理排序事件
  169. const handleSortChange = (column) => {
  170. console.log('排序字段:', column.prop)
  171. console.log('排序方式:', column.order)
  172. if (column.prop === 'buyJb') {
  173. sortField.value = 'buy_jb'
  174. } else if (column.prop === 'taskJb') {
  175. sortField.value = 'core_jb'
  176. } else if (column.prop === 'free6') {
  177. sortField.value = 'free_6'
  178. } else if (column.prop === 'free12') {
  179. sortField.value = 'free_12'
  180. }
  181. sortOrder.value = column.order === 'ascending' ? 'ASC' : 'DESC'
  182. get()
  183. }
  184. //选地区
  185. const area = [
  186. {
  187. value: '马来西亚',
  188. label: '马来西亚'
  189. },
  190. {
  191. value: '新加坡',
  192. label: '新加坡'
  193. },
  194. {
  195. value: '香港',
  196. label: '香港'
  197. },
  198. {
  199. value: '泰国',
  200. label: '泰国'
  201. },
  202. {
  203. value: '加拿大',
  204. label: '加拿大'
  205. },
  206. {
  207. value: '越南HCM',
  208. label: '越南HCM'
  209. }
  210. ]
  211. // 挂载
  212. onMounted(async function () {
  213. await getAdminData()
  214. await get()
  215. })
  216. </script>
  217. <template>
  218. <el-row>
  219. <el-col>
  220. <el-card style="margin-bottom: 20px">
  221. <div class="head-card">
  222. <div class="head-card-element">
  223. <el-text class="mx-1" size="large">精网号</el-text>
  224. <el-input
  225. v-model="detailY.jwcode"
  226. style="width: 240px"
  227. placeholder="请输入精网号"
  228. clearable
  229. />
  230. </div>
  231. <div
  232. class="head-card-element"
  233. style="margin-left: 50px"
  234. v-if="adminData.area == '总部'"
  235. >
  236. <el-text class="mx-1" size="large">所属地区</el-text>
  237. <el-select
  238. v-model="detailY.area"
  239. placeholder="请选择所属地区"
  240. style="width: 240px"
  241. clearable
  242. >
  243. <el-option
  244. v-for="item in area"
  245. :key="item.value"
  246. :label="item.label"
  247. :value="item.value"
  248. />
  249. </el-select>
  250. </div>
  251. <div class="head-card-btn">
  252. <el-button @click="reset()">重置</el-button>
  253. <el-button type="primary" @click="search()">查询</el-button>
  254. </div>
  255. </div>
  256. </el-card>
  257. </el-col>
  258. </el-row>
  259. <el-row>
  260. <el-col>
  261. <el-card>
  262. <div>
  263. 现有金币永久金币{{ Math.abs(rechargeCoin) }}免费金币{{
  264. Math.abs(freeCoin)
  265. }}任务金币{{ Math.abs(taskCoin) }}
  266. </div>
  267. <!-- 设置表格容器的高度和滚动样式 -->
  268. <div style="height: 626px; overflow-y: auto">
  269. <el-table
  270. :data="tableData"
  271. style="width: 100%"
  272. height="715px"
  273. @sort-change="handleSortChange"
  274. >
  275. <el-table-column
  276. type="index"
  277. label="序号"
  278. width="100px"
  279. fixed="left"
  280. >
  281. <template #default="scope">
  282. <span>{{
  283. scope.$index + 1 + (getObj.pageNum - 1) * getObj.pageSize
  284. }}</span>
  285. </template>
  286. </el-table-column>
  287. <el-table-column prop="name" label="姓名" width="200" />
  288. <el-table-column prop="jwcode" label="精网号" width="120" />
  289. <el-table-column prop="area" label="所属地区" width="120" />
  290. <el-table-column
  291. prop="allJb"
  292. label="总金币"
  293. width="120"
  294. aligh="center"
  295. >
  296. <template #default="scope">
  297. <span>{{
  298. (scope.row.free12 +
  299. scope.row.free6 +
  300. scope.row.coreJb +
  301. scope.row.buyJb) /
  302. 100
  303. }}</span>
  304. </template>
  305. </el-table-column>
  306. <el-table-column
  307. prop="buyJb"
  308. label="永久金币"
  309. sortable="“custom”"
  310. width="110"
  311. >
  312. <template #default="scope">
  313. <span>{{ Math.abs(scope.row.buyJb) / 100 }}</span>
  314. </template>
  315. </el-table-column>
  316. <el-table-column prop="freeJb" label="免费金币" width="110">
  317. <template #default="scope">
  318. <span>{{
  319. Math.abs(scope.row.free6 + scope.row.free12) / 100
  320. }}</span>
  321. </template>
  322. </el-table-column>
  323. <el-table-column
  324. prop="free6"
  325. label=" 6月份到期免费金币"
  326. sortable="“custom”"
  327. width="110"
  328. >
  329. <template #default="scope">
  330. <span>{{ scope.row.free6 / 100 }}</span>
  331. </template>
  332. </el-table-column>
  333. <el-table-column
  334. prop="free12"
  335. label="12月份到期免费金币"
  336. sortable="“custom”"
  337. width="110"
  338. >
  339. <template #default="scope">
  340. <span>{{ scope.row.free12 / 100 }}</span>
  341. </template>
  342. </el-table-column>
  343. <el-table-column
  344. prop="coreJb"
  345. label="任务金币"
  346. sortable="“custom”"
  347. width="130"
  348. >
  349. <template #default="scope">
  350. <span>{{ Math.abs(scope.row.coreJb) / 100 }}</span>
  351. </template>
  352. </el-table-column>
  353. <el-table-column prop="rcoin" label="历史充值" width="150">
  354. <template #default="scope">
  355. <span>{{ scope.row.rcoin / 100 }}</span>
  356. </template>
  357. </el-table-column>
  358. <el-table-column prop="scoin" label="历史消费" width="150">
  359. <template #default="scope">
  360. <span>{{ Math.abs(scope.row.scoin) / 100 }}</span>
  361. </template>
  362. </el-table-column>
  363. </el-table>
  364. </div>
  365. <!-- 分页 -->
  366. <!-- 分页 -->
  367. <div class="pagination" style="margin-top: 20px">
  368. <el-pagination
  369. background
  370. :page-size="getObj.pageSize"
  371. layout="slot"
  372. :total="total"
  373. >
  374. <div>{{ total }},每页</div>
  375. <el-select
  376. v-model="getObj.pageSize"
  377. class="page-size"
  378. @change="get()"
  379. style="width: 80px"
  380. >
  381. <el-option
  382. v-for="item in [5, 10, 20, 50, 100]"
  383. :key="item"
  384. :label="item"
  385. :value="item"
  386. ></el-option>
  387. </el-select>
  388. <div></div>
  389. </el-pagination>
  390. <el-pagination
  391. background
  392. layout="prev, pager, next,slot"
  393. :page-size="getObj.pageSize"
  394. :total="total"
  395. :current-page="getObj.pageNum"
  396. @current-change="get"
  397. >
  398. <div>跳至</div>
  399. <el-input
  400. v-model="getObj.pageNum"
  401. style="width: 40px"
  402. @change="checkNumber"
  403. />
  404. <div></div>
  405. </el-pagination>
  406. </div>
  407. </el-card>
  408. </el-col>
  409. </el-row>
  410. </template>
  411. <style scoped>
  412. .pagination {
  413. display: flex;
  414. }
  415. .status {
  416. display: flex;
  417. }
  418. .head-card {
  419. display: flex;
  420. }
  421. .head-card-element {
  422. margin-right: 20px;
  423. }
  424. .head-card-btn {
  425. margin-left: auto;
  426. }
  427. </style>