index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <script lang="ts" setup>
  2. import { monthCompareMetricsEnum } from '/src/views/reportManage/dataCenter/utils/enum';
  3. import {
  4. getCardDayData,
  5. getCardMonthData,
  6. getCardWeekData,
  7. getLineForDay,
  8. getLineForMonth,
  9. getLineForWeek,
  10. getLineData,
  11. } from '/src/views/reportManage/dataCenter/api';
  12. import chartDateTendency
  13. from '/src/views/reportManage/dataCenter/combinedDisplay/components/chartDateTendency/index.vue';
  14. import DateTendency from '/src/views/reportManage/dataCenter/normalDisplay/components/DateTendency/index.vue';
  15. import { computed, provide, ref, watch } from 'vue';
  16. import DateRangePicker from '/src/components/DateRangePicker/index.vue';
  17. import MonthlyDatePicker from '/src/views/reportManage/dataCenter/combinedDisplay/components/monthDatePicker/index.vue';
  18. import Selector from '/src/views/reportManage/dataCenter/normalDisplay/components/Selector/index.vue';
  19. import mainData from '/src/views/reportManage/dataCenter/combinedDisplay/components/tableData/mainData.vue';
  20. import monthlyComparativeData
  21. from '/src/views/reportManage/dataCenter/combinedDisplay/components/tableData/monthlyComparativeData.vue';
  22. import emitter from '/@/utils/emitter';
  23. import DataPicker from '/@/views/reportManage/dataCenter/combinedDisplay/components/DatePicker/index.vue';
  24. // 筛选查询
  25. const selectorRef = ref(null);
  26. const taskIds = ref({});
  27. const dayDate = ref(null);
  28. const weekDate = ref(null);
  29. const monthDate = ref(null);
  30. const monthCurrentDate = ref({});
  31. const processingDateChange = (date) => {
  32. // currentDate.value = date;
  33. dayDate.value = date.dayDate;
  34. weekDate.value = date.weekDate;
  35. monthDate.value = date.monthDate;
  36. };
  37. const monthQueryParams = ref({
  38. taskIds,
  39. monthCurrentDate,
  40. });
  41. // 表格
  42. const showTable = ref('mainData'); // 初始显示表格
  43. const currentTable: any = {
  44. mainData,
  45. monthlyComparativeData,
  46. };
  47. const panes = [
  48. {label: '主数据', name: 'mainData'},
  49. {label: '月度对比数据', name: 'monthlyComparativeData'},
  50. ];
  51. function updateDataChange(newId) {
  52. if (selectorRef.value) {
  53. taskIds.value = newId.value;
  54. }
  55. }
  56. const handelDateChange = (date) => {
  57. monthCurrentDate.value = date;
  58. };
  59. function handleButtonClick(tableName) {
  60. showTable.value = tableName;
  61. }
  62. </script>
  63. <template>
  64. <div>
  65. <div class="px-3.5">
  66. <el-card body-style="padding: 10px" class="mb-3.5 mt-3.5">
  67. <div class="custom-card-style flex gap-1.5 justify-between my-1.5 mx-2"
  68. style="display: flex; align-items: center;">
  69. <Selector ref="selectorRef" @update:updateData="updateDataChange" />
  70. <MonthlyDatePicker v-if="showTable === 'monthlyComparativeData'"
  71. @monthDateChange="handelDateChange"></MonthlyDatePicker>
  72. </div>
  73. <div v-if="showTable === 'mainData'">
  74. <DataPicker style="display: flex; align-items: center; gap: 16px" @changeDate="processingDateChange" />
  75. </div>
  76. </el-card>
  77. <el-card v-if="showTable === 'monthlyComparativeData'" class="mb-1.5">
  78. <chartDateTendency
  79. :fetch-line-month="getLineForMonth"
  80. :fetch-line-week="getLineForWeek"
  81. :fetchLine="getLineData"
  82. :metricEnum="monthCompareMetricsEnum"
  83. :query="monthQueryParams"
  84. >
  85. </chartDateTendency>
  86. </el-card>
  87. </div>
  88. <div class="px-3.5">
  89. <el-card class="mt-3">
  90. <div class="custom-button my">
  91. <el-button
  92. v-for="pane in panes"
  93. :key="pane.name"
  94. :type="showTable === pane.name ? 'primary' : 'default'"
  95. @click="handleButtonClick(pane.name)">
  96. {{ pane.label }}
  97. </el-button>
  98. </div>
  99. <component :is="currentTable[showTable]"
  100. :dayDate="dayDate"
  101. :monthCurrentDate="monthCurrentDate"
  102. :monthDate="monthDate"
  103. :taskIds="taskIds"
  104. :weekDate="weekDate">
  105. </component>
  106. </el-card>
  107. </div>
  108. </div>
  109. </template>
  110. <style scoped>
  111. .custom-card-style {
  112. z-index: 999;
  113. position: sticky;
  114. top: 0;
  115. }
  116. .demonstration {
  117. color: var(--el-text-color-secondary);
  118. font-size: 14px;
  119. margin: 10px;
  120. }
  121. .custom-button {
  122. z-index: 1000;
  123. position: absolute;
  124. color: #3a83f7 !important;
  125. }
  126. .my {
  127. margin: 0.8rem 0;
  128. }
  129. .el-card {
  130. border: none;
  131. border-radius: 12px;
  132. background-color: #fff;
  133. box-shadow: 0px 0px 12px rgba(51, 89, 181, 0.16);
  134. }
  135. </style>