index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="page-container column-container">
  3. <el-row :gutter="24">
  4. <el-col :span="8">
  5. <!-- <div class="dashboard-total-item">
  6. <img :src="totalIcon2" />
  7. <div class="dashboard-total-item-label">
  8. <span>员工总数</span>
  9. <span>
  10. <span>本月新入职</span>
  11. <span>{{ monthTotalCompanies }} 人</span>
  12. </span>
  13. </div>
  14. <div class="number-label">{{ totalCompanies }} 人</div>
  15. </div> -->
  16. </el-col>
  17. <el-col :span="8">
  18. <!-- <div class="dashboard-total-item">
  19. <img :src="totalIcon3" />
  20. <div class="dashboard-total-item-label">
  21. <span>设备总数</span>
  22. <span>
  23. <span>本月新购量</span>
  24. <span>{{ identityMonthTotal }} 台</span>
  25. </span>
  26. </div>
  27. <div class="number-label">{{ identityTotal }} 台</div>
  28. </div> -->
  29. </el-col>
  30. </el-row>
  31. <div class="statistic-container">
  32. <el-row :gutter="16">
  33. <el-col :span="12">
  34. <div class="item-statistic-container" id="information-statistic"></div>
  35. </el-col>
  36. <el-col :span="12">
  37. <div class="item-statistic-container" id="appointment-statistic"></div>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup>
  44. import totalIcon2 from '@/assets/images/dashboard-total-icon-2.png'
  45. import totalIcon3 from '@/assets/images/dashboard-total-icon-3.png'
  46. import { parseTime } from '@/utils/tools.js'
  47. let totalCompanies = ref(0)
  48. let monthTotalCompanies = ref(0)
  49. let identityTotal = ref(0)
  50. let identityMonthTotal = ref(0)
  51. let currentMonth = ref('')
  52. let statisticDom, statistic
  53. onMounted(() => {
  54. currentMonth.value = parseTime(new Date(), '{y}-{m}')
  55. //statisticDom = document.getElementById('information-statistic')
  56. //statistic = echarts.init(statisticDom)
  57. //getCurrentMonthDayArr()
  58. })
  59. const getCurrentMonthDayArr = (dateStr) => {
  60. // 获取当前日期
  61. var currentDate = dateStr ? new Date(dateStr) : new Date()
  62. // 获取当前月份
  63. var currentMonth = currentDate.getMonth()
  64. // 获取下个月的第一天
  65. var nextMonth = new Date(currentDate.getFullYear(), currentMonth + 1, 1)
  66. // 设置日期为当前月份的最后一天
  67. nextMonth.setDate(nextMonth.getDate() - 1)
  68. // 根据当前月最后一天的日期,判断每个月有多少天
  69. var days = nextMonth.getDate()
  70. // 创建一个空数组来存储日期
  71. const dateArray = []
  72. // 循环遍历天数
  73. for (var day = 1; day <= days; ++day) {
  74. // 使用padStart函数将日期补齐到两位数,不足的地方用0填充
  75. var formattedDay = String(day).padStart(2, '0')
  76. // 将格式化后的日期添加到数组中
  77. dateArray.push(formattedDay)
  78. }
  79. statisticOption.xAxis.data = dateArray
  80. totalCompanies.value = 523
  81. monthTotalCompanies.value = 276
  82. identityTotal.value = 5133
  83. identityMonthTotal.value = 3015
  84. statisticOption && statistic.setOption(statisticOption)
  85. }
  86. const handleChangeMonth = (val) => {
  87. getCurrentMonthDayArr(val)
  88. }
  89. </script>
  90. <style scoped>
  91. .dashboard-total-item {
  92. display: flex;
  93. align-items: center;
  94. padding: 0 24px;
  95. height: 152px;
  96. background-color: #fff;
  97. font-size: 16px;
  98. justify-content: space-between;
  99. }
  100. .dashboard-total-item > .dashboard-total-item-label {
  101. flex: 1;
  102. display: flex;
  103. flex-direction: column;
  104. line-height: 32px;
  105. padding: 0 16px;
  106. }
  107. .dashboard-total-item > .dashboard-total-item-label > span:first-child {
  108. font-weight: bold;
  109. font-size: 18px;
  110. }
  111. .dashboard-total-item > .dashboard-total-item-label > span:last-child {
  112. color: #6b6b6b;
  113. }
  114. .dashboard-total-item > .dashboard-total-item-label > span:last-child > span:first-child {
  115. margin-right: 8px;
  116. }
  117. .dashboard-total-item > .dashboard-total-item-label > span:last-child > span:last-child {
  118. color: #4367df;
  119. }
  120. .dashboard-total-item > .number-label {
  121. font-size: 40px;
  122. margin-left: 16px;
  123. font-weight: bold;
  124. color: #5a6ac3;
  125. }
  126. .statistic-container {
  127. position: relative;
  128. margin-top: 24px;
  129. background-color: #fff;
  130. padding-top: 16px;
  131. padding-right: 12px;
  132. padding-bottom: 8px;
  133. padding-left: 4px;
  134. }
  135. .statistic-container > .month-picker {
  136. position: absolute;
  137. top: 16px;
  138. left: 240px;
  139. line-height: 24px;
  140. }
  141. .item-statistic-container {
  142. height: 560px;
  143. }
  144. </style>