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.

205 lines
4.0 KiB

  1. <template>
  2. <div class="cash-management">
  3. <div class="cash-title">
  4. <div class="text1"> 现金管理
  5. <span class="text1-update-time">最后更新时间{{
  6. workDataUpdateTime && workDataUpdateTime !== '1970-01-01 08:00:00' ? workDataUpdateTime : '该地区暂无数据'
  7. }}</span>
  8. </div>
  9. </div>
  10. <div class="text2"><span class="text2-income">总营收{{ cashData.totalIncome }}</span></div>
  11. <div class="chart-container">
  12. <!-- 左侧数据列表 -->
  13. <div class="market-data">
  14. <div v-for="market in cashData.markets" :key="market.name" class="market-item">
  15. <span class="market-name">{{ market.name }}:</span>
  16. <span class="market-value">{{ market.value.toLocaleString() }}</span>
  17. </div>
  18. </div>
  19. <!-- 图表区域 -->
  20. <div ref="chartRef" class="chart"></div>
  21. </div>
  22. </div>
  23. </template>
  24. <script setup>
  25. import * as echarts from 'echarts'
  26. import { ref, onMounted } from 'vue'
  27. // 模拟数据
  28. const cashData = ref({
  29. updateTime: '2025-09-24 12:00:00',
  30. totalIncome: 1200000,
  31. markets: [
  32. { name: '北京', value: 450000 },
  33. { name: '上海', value: 300000 },
  34. { name: '广州', value: 200000 },
  35. { name: '深圳', value: 150000 },
  36. { name: '其他', value: 100000 }
  37. ]
  38. })
  39. const chartRef = ref(null)
  40. let chartInstance = null
  41. const renderChart = () => {
  42. if (!chartInstance && chartRef.value) {
  43. chartInstance = echarts.init(chartRef.value)
  44. }
  45. const option = {
  46. tooltip: { trigger: 'item' },
  47. legend: {
  48. bottom: 5, // 增加底部距离的
  49. left: 'center' },
  50. series: [
  51. {
  52. type: 'pie',
  53. radius: ['40%', '70%'],
  54. data: cashData.value.markets,
  55. center: [ '60%', '45%'] //图表靠右一点
  56. }
  57. ]
  58. }
  59. chartInstance.setOption(option)
  60. }
  61. onMounted(() => {
  62. renderChart()
  63. })
  64. </script>
  65. <style scoped>
  66. /* 背景卡片大小 */
  67. .cash-management {
  68. margin: 10px 5px;
  69. width: 100%;
  70. height: 55vh;
  71. flex-shrink: 0;
  72. border-radius: 8px;
  73. background: #E7F4FD;
  74. box-shadow: 0 2px 2px 0 #00000040;
  75. display: flex;
  76. flex-direction: column;
  77. align-items: center;
  78. }
  79. /*
  80. .cash-card {
  81. width: 100%;
  82. }
  83. .chart {
  84. width: 100%;
  85. height: 200px;
  86. } */
  87. .cash-title {
  88. width: 100%;
  89. height: 5vh;
  90. flex-shrink: 0;
  91. border-radius: 8px;
  92. background: linear-gradient(90deg, #E4F0FC 0%, #C6ADFF 50%, #E4F0FC 100%);
  93. box-shadow: 0 2px 2px 0 #00152940;
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. }
  98. .text1 {
  99. color: #040a2d;
  100. font-family: "PingFang SC";
  101. font-size: 28px;
  102. font-style: normal;
  103. font-weight: 900;
  104. line-height: 31.79px;
  105. }
  106. .text1-update-time {
  107. width: 100%;
  108. height: 26px;
  109. flex-shrink: 0;
  110. color: #040a2d;
  111. font-family: "PingFang SC";
  112. font-size: 20px;
  113. font-style: normal;
  114. font-weight: 700;
  115. line-height: 31.79px;
  116. }
  117. /* 总收入的渐变框 */
  118. .text2 {
  119. margin: 13px;
  120. width: 95%;
  121. height: 48px;
  122. flex-shrink: 0;
  123. border-radius: 8px;
  124. background: linear-gradient(90deg, #E4F0FC 0%, #C1DCF8 50%, #E4F0FC 100%);
  125. box-shadow: 0 2px 2px 0 #00152940;
  126. display: flex;
  127. align-items: center;
  128. justify-content: center;
  129. }
  130. /* 总收入字体 */
  131. .text2-income {
  132. width: 215px;
  133. height: 26px;
  134. flex-shrink: 0;
  135. color: #040a2d;
  136. font-family: "PingFang SC";
  137. font-size: 20px;
  138. font-style: normal;
  139. font-weight: 900;
  140. line-height: 31.79px;
  141. }
  142. /* 图表容器 */
  143. .chart-container {
  144. display: flex;
  145. align-items: center;
  146. width: 100%;
  147. height: 100%;
  148. padding: 10px;
  149. }
  150. /* 左侧数据列表,使用您指定的样式 */
  151. .market-data {
  152. display: flex;
  153. width: 179px;
  154. flex-direction: column;
  155. align-items: flex-start;
  156. gap: 12px;
  157. padding: 10px;
  158. margin-left: 80px;
  159. }
  160. .market-item {
  161. display: flex;
  162. justify-content: space-between;
  163. width: 100%;
  164. font-family: "PingFang SC";
  165. font-size: 16px;
  166. color: #040a2d;
  167. }
  168. .market-name {
  169. font-weight: 700;
  170. }
  171. .market-value {
  172. font-weight: 500;
  173. }
  174. /* 图表样式 */
  175. /* .chart {
  176. flex: 1;
  177. height: 300px;
  178. margin-top: 10px;
  179. } */
  180. </style>