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.

211 lines
4.0 KiB

2 months ago
2 months ago
2 months ago
2 months ago
  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. },
  51. series: [
  52. {
  53. label: {show: false},
  54. type: 'pie',
  55. radius: ['40%', '70%'],
  56. data: cashData.value.markets,
  57. center: ['60%', '45%'] //图表靠右一点
  58. }
  59. ]
  60. }
  61. chartInstance.setOption(option)
  62. }
  63. onMounted(() => {
  64. renderChart()
  65. })
  66. </script>
  67. <style scoped>
  68. /* 背景卡片大小 */
  69. .cash-management {
  70. margin: 10px 5px;
  71. width: 100%;
  72. height: 550px;
  73. flex-shrink: 0;
  74. border-radius: 8px;
  75. background: #E7F4FD;
  76. box-shadow: 0 2px 2px 0 #00000040;
  77. display: flex;
  78. flex-direction: column;
  79. align-items: center;
  80. }
  81. /*
  82. .cash-card {
  83. width: 100%;
  84. }
  85. .chart {
  86. width: 100%;
  87. height: 200px;
  88. } */
  89. .cash-title {
  90. width: 100%;
  91. height: 5vh;
  92. flex-shrink: 0;
  93. border-radius: 8px;
  94. background: linear-gradient(90deg, #E4F0FC 0%, #C6ADFF 50%, #E4F0FC 100%);
  95. box-shadow: 0 2px 2px 0 #00152940;
  96. display: flex;
  97. align-items: center;
  98. justify-content: center;
  99. }
  100. .text1 {
  101. color: #040a2d;
  102. font-family: "PingFang SC";
  103. font-size: 28px;
  104. font-style: normal;
  105. font-weight: 900;
  106. line-height: 31.79px;
  107. }
  108. .text1-update-time {
  109. width: 100%;
  110. height: 26px;
  111. flex-shrink: 0;
  112. color: #040a2d;
  113. font-family: "PingFang SC";
  114. font-size: 20px;
  115. font-style: normal;
  116. font-weight: 700;
  117. line-height: 31.79px;
  118. }
  119. /* 总收入的渐变框 */
  120. .text2 {
  121. margin: 13px;
  122. width: 95%;
  123. height: 48px;
  124. flex-shrink: 0;
  125. border-radius: 8px;
  126. background: linear-gradient(90deg, #E4F0FC 0%, #C1DCF8 50%, #E4F0FC 100%);
  127. box-shadow: 0 2px 2px 0 #00152940;
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. }
  132. /* 总收入字体 */
  133. .text2-income {
  134. width: 215px;
  135. height: 26px;
  136. flex-shrink: 0;
  137. color: #040a2d;
  138. font-family: "PingFang SC";
  139. font-size: 20px;
  140. font-style: normal;
  141. font-weight: 900;
  142. line-height: 31.79px;
  143. }
  144. /* 图表容器 */
  145. .chart-container {
  146. display: flex;
  147. align-items: center;
  148. width: 100%;
  149. height: 100%;
  150. padding: 10px;
  151. }
  152. /* 左侧数据列表,使用指定的样式 */
  153. .market-data {
  154. display: flex;
  155. width: 180px;
  156. flex-direction: column;
  157. align-items: flex-start;
  158. gap: 20px;
  159. padding: 10px;
  160. margin-left: 40px;
  161. }
  162. .market-item {
  163. display: flex;
  164. justify-content: space-between;
  165. width: 100%;
  166. font-family: "PingFang SC";
  167. font-size: 16px;
  168. color: #040a2d;
  169. }
  170. .market-name {
  171. white-space: nowrap;
  172. font-weight: 700;
  173. }
  174. .market-value {
  175. font-weight: 500;
  176. }
  177. /* 图表样式 */
  178. .chart {
  179. flex: 1;
  180. height: 300px;
  181. margin-top: 10px;
  182. }
  183. </style>