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.

246 lines
7.8 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
2 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <el-card class="card1" style="margin-bottom: 1vh;">
  3. <el-text size="large">精网号</el-text>
  4. <el-input v-model="searchObj.jwcode" placeholder="请输入精网号" style="width: 240px" clearable />
  5. <el-text size="large" style="margin-left:20px">地区</el-text>
  6. <el-select v-model="searchObj.dept" placeholder="请选择地区" style="width: 240px" clearable>
  7. <el-option v-for="item in marketOptions" :key="item" :label="item" :value="item" />
  8. </el-select>
  9. <div style="float: right;">
  10. <el-button type="primary" @click="search">查询</el-button>
  11. <el-button type="success" @click="reset">重置</el-button>
  12. </div>
  13. </el-card>
  14. <el-card class="card2">
  15. <div class="goldStatistics">
  16. 现有金豆数{{ format3(stats.sumBean) }}金豆&nbsp;&nbsp;&nbsp;&nbsp;
  17. 付费金豆数{{ format3(stats.permanentBean) }}金豆&nbsp;&nbsp;&nbsp;&nbsp;
  18. 免费金豆数{{ format3(stats.freeBean) }}金豆&nbsp;&nbsp;&nbsp;&nbsp;
  19. 消费金豆总数{{ format3(stats.consumeSum) }}金豆&nbsp;&nbsp;&nbsp;&nbsp;
  20. </div>
  21. <el-table :data="tableData" height="65vh" @sort-change="handleSortChange" :row-style="{ height: '50px' }">
  22. <el-table-column type="index" label="序号" width="80px" fixed="left">
  23. <template #default="scope">
  24. <span>{{
  25. scope.$index + 1 + (pagination.pageNum - 1) * pagination.pageSize
  26. }}</span>
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="姓名" style="width: 120px;" prop="name" show-overflow-tooltip />
  30. <el-table-column label="精网号" style="width: 110px;" prop="jwcode" />
  31. <el-table-column label="所属地区" style="width: 120px;" prop="dept" />
  32. <el-table-column label="现有金豆" style="width: 120px;" prop="beanNum" sortable="custom" />
  33. <el-table-column label="免费金豆" style="width: 120px;" prop="freeBean" sortable="custom" />
  34. <el-table-column label="付费金豆" style="width: 120px;" prop="buyBean" sortable="custom" />
  35. <el-table-column label="历史消费" style="width: 120px;" prop="totalCostBean" sortable="custom" />
  36. </el-table>
  37. <div class="pagination">
  38. <el-pagination background v-model:current-page="pagination.pageNum"
  39. v-model:page-size="pagination.pageSize" layout="total, sizes, prev, pager, next, jumper"
  40. :total="pagination.total" @size-change="handlePageSizeChange"
  41. @current-change="handleCurrentChange"></el-pagination>
  42. </div>
  43. </el-card>
  44. </template>
  45. <script setup>
  46. import { ref, onMounted } from 'vue'
  47. import API from '@/util/http.js'
  48. import { useAdminStore } from "@/store/index.js";
  49. import { storeToRefs } from "pinia";
  50. const adminStore = useAdminStore();
  51. const { adminData, menuTree } = storeToRefs(adminStore);
  52. import { permissionMapping, findMenuById } from "@/utils/menuTreePermission.js"
  53. import { ElMessage } from 'element-plus';
  54. const canLook = ref(findMenuById(menuTree.value, permissionMapping.gold_bean_customer_details))
  55. const tableData = ref([])
  56. const marketOptions = ref([])
  57. const searchObj = ref({
  58. jwcode: '',
  59. dept: '',
  60. sortField: '',
  61. sortOrder: ''
  62. })
  63. const stats = ref({
  64. sumBean: 0,
  65. permanentBean: 0,
  66. freeBean: 0,
  67. consumeSum: 0
  68. })
  69. const pagination = ref({
  70. pageNum: 1,
  71. pageSize: 50,
  72. total: 0
  73. })
  74. const get = async function () {
  75. try {
  76. if(!canLook.value){
  77. ElMessage.error('无此权限')
  78. return
  79. }
  80. trim()
  81. if (searchObj.value.jwcode) {
  82. const numRef = /^\d{1,9}$/;
  83. if (!numRef.test(searchObj.value.jwcode)) {
  84. ElMessage.error('请检查精网号格式')
  85. return
  86. }
  87. }
  88. const params = {
  89. beanUser: { //金豆客户列表
  90. jwcode: searchObj.value.jwcode, //精网号
  91. dept: searchObj.value.dept, //地区
  92. sortField: searchObj.value.sortField,//排序字段
  93. sortOrder: searchObj.value.sortOrder//正序倒序
  94. },
  95. pageNum: pagination.value.pageNum,
  96. pageSize: pagination.value.pageSize
  97. }
  98. const res = await API({
  99. url: '/beanUser/userBean',
  100. data: params
  101. })
  102. if (res.code === 200) {
  103. tableData.value = res.data.list
  104. pagination.value.total = res.data.total
  105. }
  106. } catch (error) {
  107. console.log(error)
  108. }
  109. }
  110. const getStats = async () => {
  111. try {
  112. const params = {
  113. beanUser: {
  114. jwcode: searchObj.value.jwcode,
  115. dept: searchObj.value.dept
  116. }
  117. }
  118. const res = await API({
  119. url: '/beanUser/userBeanSum',
  120. data: params
  121. })
  122. stats.value.sumBean = res.data.sumBean
  123. stats.value.permanentBean = res.data.permanentBean
  124. stats.value.freeBean = res.data.freeBean
  125. stats.value.consumeSum = res.data.consumeSum
  126. console.log('see see stats和搜索对象', stats.value, params)
  127. } catch (error) {
  128. console.log('请求失败', error)
  129. }
  130. }
  131. const handleSortChange = (column) => {
  132. if (column.prop === 'beanNum') {
  133. searchObj.value.sortField = 'jinbi'
  134. } else if (column.prop === 'freeBean') {
  135. searchObj.value.sortField = 'jinbi_free'
  136. } else if (column.prop === 'buyBean') {
  137. searchObj.value.sortField = 'jinbi_buy'
  138. } else if (column.prop === 'totalCostBean') {
  139. searchObj.value.sortField = 'jinbi_cost_total'
  140. } else {
  141. searchObj.value.sortField = ''
  142. }
  143. searchObj.value.sortOrder = column.order === 'ascending' ? 'asc' : 'desc'
  144. console.log('排序字段:', searchObj.value.sortField, '排序方式:', searchObj.value.sortOrder)
  145. search()
  146. }
  147. const getmarkets = async () => {
  148. try {
  149. const result = await API({ url: '/beanUser/getDept', data: {} })
  150. marketOptions.value = result.data || []
  151. } catch (error) {
  152. console.error('获取地区列表失败', error)
  153. }
  154. }
  155. // 精网号去空格
  156. const trim = () => {
  157. if (searchObj.value.jwcode) {
  158. searchObj.value.jwcode = searchObj.value.jwcode.replace(/\s/g, '');
  159. }
  160. }
  161. const reset = function () {
  162. searchObj.value.jwcode = ''
  163. searchObj.value.dept = ''
  164. // 重置页码
  165. pagination.value.pageNum = 1
  166. search()
  167. }
  168. const handlePageSizeChange = function (val) {
  169. pagination.value.pageSize = val
  170. search()
  171. }
  172. const handleCurrentChange = function (val) {
  173. pagination.value.pageNum = val
  174. search()
  175. }
  176. const format3 = (num) => {
  177. // 每三位添加逗号
  178. return num.toLocaleString('en-US')
  179. }
  180. const search = () => {
  181. get()
  182. getStats()
  183. }
  184. onMounted(() => {
  185. search()
  186. getmarkets()
  187. getStats()
  188. console.log('页面接收到的adminData:', adminData.value)
  189. })
  190. </script>
  191. <style scoped lang="scss">
  192. .pagination {
  193. display: flex;
  194. margin-top: 1vh;
  195. }
  196. // 搜索的卡片样式
  197. .card1 {
  198. background: #F3FAFE;
  199. }
  200. // 表单的卡片样式
  201. .card2 {
  202. background: #E7F4FD;
  203. }
  204. // 新币总数等等
  205. .goldStatistics {
  206. margin-left: 1vw;
  207. margin-bottom: 1vh;
  208. color: #000000;
  209. font-family: "PingFang SC";
  210. font-size: 16px;
  211. font-style: normal;
  212. font-weight: 700;
  213. line-height: 20px;
  214. }
  215. // 表头背景等
  216. :deep(.el-table__header-wrapper),
  217. :deep(.el-table__body-wrapper),
  218. :deep(.el-table__cell),
  219. /* 表格 */
  220. :deep(.el-table__body td) {
  221. background-color: #F3FAFE !important;
  222. }
  223. /* 表头 */
  224. :deep(.el-table__header th) {
  225. background-color: #F3FAFE !important;
  226. }
  227. /* 鼠标悬停 */
  228. :deep(.el-table__row:hover > .el-table__cell) {
  229. background-color: #E5EBFE !important;
  230. }
  231. </style>