OperationDataCard.vue 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <el-card shadow="never">
  3. <template #header>
  4. <CardTitle title="运营数据" />
  5. </template>
  6. <div class="flex flex-row flex-wrap items-center gap-8 p-4">
  7. <div
  8. v-for="item in data"
  9. :key="item.name"
  10. class="h-20 w-20% flex flex-col cursor-pointer items-center justify-center gap-2"
  11. @click="handleClick(item.routerName)"
  12. >
  13. <CountTo
  14. :prefix="item.prefix"
  15. :end-val="item.value"
  16. :decimals="item.decimals"
  17. class="text-3xl"
  18. />
  19. <span class="text-center">{{ item.name }}</span>
  20. </div>
  21. </div>
  22. </el-card>
  23. </template>
  24. <script lang="ts" setup>
  25. import * as ProductSpuApi from '@/api/mall/product/spu'
  26. import * as TradeStatisticsApi from '@/api/mall/statistics/trade'
  27. import * as PayStatisticsApi from '@/api/mall/statistics/pay'
  28. import { CardTitle } from '@/components/Card'
  29. /** 运营数据卡片 */
  30. defineOptions({ name: 'OperationDataCard' })
  31. const router = useRouter() // 路由
  32. /** 数据 */
  33. const data = reactive({
  34. orderUndelivered: { name: '待发货订单', value: 9, routerName: 'TradeOrder' },
  35. orderAfterSaleApply: { name: '退款中订单', value: 4, routerName: 'TradeAfterSale' },
  36. orderWaitePickUp: { name: '待核销订单', value: 0, routerName: 'TradeOrder' },
  37. productAlertStock: { name: '库存预警', value: 0, routerName: 'ProductSpu' },
  38. productForSale: { name: '上架商品', value: 0, routerName: 'ProductSpu' },
  39. productInWarehouse: { name: '仓库商品', value: 0, routerName: 'ProductSpu' },
  40. withdrawAuditing: { name: '提现待审核', value: 0, routerName: 'TradeBrokerageWithdraw' },
  41. rechargePrice: {
  42. name: '账户充值',
  43. value: 0.0,
  44. prefix: '¥',
  45. decimals: 2,
  46. routerName: 'PayWalletRecharge'
  47. }
  48. })
  49. /** 查询订单数据 */
  50. const getOrderData = async () => {
  51. const orderCount = await TradeStatisticsApi.getOrderCount()
  52. data.orderUndelivered.value = orderCount.undelivered
  53. data.orderAfterSaleApply.value = orderCount.afterSaleApply
  54. data.orderWaitePickUp.value = orderCount.pickUp
  55. data.withdrawAuditing.value = orderCount.auditingWithdraw
  56. }
  57. /** 查询商品数据 */
  58. const getProductData = async () => {
  59. // TODO: @芋艿:这个接口的返回值,是不是用命名字段更好些?
  60. const productCount = await ProductSpuApi.getTabsCount()
  61. data.productForSale.value = productCount['0']
  62. data.productInWarehouse.value = productCount['1']
  63. data.productAlertStock.value = productCount['3']
  64. }
  65. /** 查询钱包充值数据 */
  66. const getWalletRechargeData = async () => {
  67. const paySummary = await PayStatisticsApi.getWalletRechargePrice()
  68. data.rechargePrice.value = paySummary.rechargePrice
  69. }
  70. /**
  71. * 跳转到对应页面
  72. *
  73. * @param routerName 路由页面组件的名称
  74. */
  75. const handleClick = (routerName: string) => {
  76. router.push({ name: routerName })
  77. }
  78. /** 初始化 **/
  79. onMounted(() => {
  80. getOrderData()
  81. getProductData()
  82. getWalletRechargeData()
  83. })
  84. </script>