Przeglądaj źródła

feat:修改revenue查询

AmandaG 1 rok temu
rodzic
commit
1e428b7f51

+ 14 - 0
src/api/module/common.ts

@@ -255,3 +255,17 @@ export const getDashboardFilters = (config: any) => {
     config
   )
 }
+
+/**
+ * 获取首页筛选条件
+ */
+export const RevenueDownload = (config: any) => {
+  return HttpAxios.get(
+    `${baseUrl}`,
+    {
+      action: 'ocean_order',
+      operate: 'revenue'
+    },
+    config
+  )
+}

+ 10 - 5
src/views/Dashboard/src/DashboardView.vue

@@ -90,7 +90,7 @@ const GetDashboardData = () => {
         GetTop10ODEcharts(Top10DefaultData.value)
         GetCo2EmissionEcharts(Co2OriginDefaultData.value)
         GetCo2DestinationEcharts(Co2DestinationDefaultData.value)
-        // GetRevenueEcharts(RevenueDefaultData.value)
+        GetRevenueEcharts(RevenueDefaultData.value)
       })
     })
 }
@@ -1006,6 +1006,7 @@ const ClickParams = (val: any) => {
                   :BarData="containerObj"
                   v-vloading="containerLoading"
                   style="height: 300px"
+                  :isRevenue="true"
                   :barHeight="{ height: '300px' }"
                 ></BarChart>
               </template>
@@ -1093,6 +1094,7 @@ const ClickParams = (val: any) => {
                   @clickParams="ClickParams(item.title)"
                   v-vloading="EmissionLoading"
                   style="height: 250px"
+                  :isRevenue="true"
                   :barHeight="{ height: '250px' }"
                 ></BarChart>
               </template>
@@ -1119,13 +1121,13 @@ const ClickParams = (val: any) => {
                   :BarData="DestinationObj"
                   v-vloading="DestinationLoading"
                   style="height: 250px"
+                  :isRevenue="true"
                   @clickParams="ClickParams(item.title)"
                   :barHeight="{ height: '250px' }"
                 ></BarChart>
               </template>
             </VBox_Dashboard>
           </div>
-          <!-- Revenue -->
           <!-- <div
             v-else-if="item.title === 'Revenue' && item.switchValue"
             class="KPI_Pending"
@@ -1166,7 +1168,8 @@ const ClickParams = (val: any) => {
               </template>
             </VBox_Dashboard>
           </div>
-          <!-- <div v-else-if="item.title === 'Revenue Spent' && item.switchValue" class="KPI_Pending">
+          <!-- Revenue -->
+          <div v-else-if="item.title === 'Revenue Spent' && item.switchValue" class="KPI_Pending">
             <VBox_Dashboard @changeCancel="changeCancel(item.id)" style="width: 100%">
               <template #header>
                 <div class="Title_flex">
@@ -1181,15 +1184,17 @@ const ClickParams = (val: any) => {
               </template>
               <template #content>
                 <BarChart
-                  ref="seller_chart_CO2_destination"
                   :BarData="RevenueObj"
+                  :isRevenue="false"
                   v-vloading="RevenueLoading"
+                  :RevenueStartDate="dashboardObj.RevenueDefaultData.date_start"
+                  :RevenueEndDate="dashboardObj.RevenueDefaultData.date_end"
                   style="height: 300px"
                   :barHeight="{ height: '300px' }"
                 ></BarChart>
               </template>
             </VBox_Dashboard>
-          </div> -->
+          </div>
         </template>
       </VueDraggable>
     </div>

+ 23 - 5
src/views/Dashboard/src/components/BarChart.vue

@@ -6,7 +6,10 @@ import updateIcon from '../image/xiazai.png'
 import * as XLSX from 'xlsx'
 const props = defineProps({
   BarData: Object,
-  barHeight: Object
+  barHeight: Object,
+  isRevenue: Boolean,
+  RevenueStartDate: String,
+  RevenueEndDate: String
 })
 const bar_data = ref(props.BarData)
 const bar_ref = ref()
@@ -14,7 +17,6 @@ watch(
   () => props.BarData,
   (current) => {
     bar_data.value = current
-    initOption.title.text = bar_title.value
     initOption.xAxis.data = barName.value
     initOption.series = bar_series.value
     initOption.legend.data = Name.value
@@ -23,6 +25,9 @@ watch(
     initOption.toolbox.feature.saveAsImage.name = downloadName.value
     initOption.toolbox.show = isShowTooltips.value
     initChart()
+    if (props.isRevenue) {
+      initOption.title.text = bar_title.value
+    }
   },
   {
     deep: true
@@ -154,6 +159,17 @@ for (var i in result) {
   data.push(formatJson(result[i].filterVal, result[i].tableDatas))
 }
 const exportData = ({ header, data, sheetname, filename }: any) => {
+  $api
+    .RevenueDownload({
+      date_start: props.RevenueStartDate,
+      date_end: props.RevenueEndDate
+    })
+    .then((res: any) => {
+      if (res.code === 200) {
+        console.log(res)
+      }
+    })
+    .finally(() => {})
   // 将表头插入数据数组中
   for (let i = 0; i < header.length; i++) {
     data[i].unshift(header[i])
@@ -178,7 +194,7 @@ const exportData = ({ header, data, sheetname, filename }: any) => {
     wb.SheetNames.push(ws_name[k])
     wb.Sheets[ws_name[k]] = ws[k]
   }
-  XLSX.writeFile(wb, filename + '.xlsx') // 导出文件
+  // XLSX.writeFile(wb, filename + '.xlsx') // 导出文件
   // const data = XLSX.utils.json_to_sheet(tableData) //此处tableData.value为表格的数据
   // const wb = XLSX.utils.book_new()
   // XLSX.utils.book_append_sheet(wb, data, 'test-data') //test-data为自定义的sheet表名
@@ -189,7 +205,7 @@ const exportData = ({ header, data, sheetname, filename }: any) => {
 const initOption = reactive({
   //标题
   title: {
-    text: bar_title.value || '', //主标题
+    text: bar_title.value || 'Total:', //主标题
     left: 19,
     top: 9.5,
     textStyle: {
@@ -341,7 +357,6 @@ const clickParams = () => {
 }
 const initChart = () => {
   const bar_chart = echarts.init(bar_ref.value)
-  bar_chart.setOption(initOption)
   //图表响应式
   window.addEventListener('resize', () => {
     bar_chart.resize()
@@ -360,14 +375,17 @@ const initChart = () => {
       initOption.series.forEach((item: any, index: any) => {
         if (item.name == Object.keys(trueObj)) {
           initOption.series[index].label.show = true
+          initOption.title.text = `Total: ${initOption.series[index].total}`
         }
       })
     } else {
       initOption.series.forEach((item: any, index: any) => {
         initOption.series[index].label.show = false
+        initOption.title.text = `Total: `
       })
     }
   })
+  bar_chart.setOption(initOption)
 }
 
 defineExpose({

+ 5 - 0
src/views/Dashboard/src/components/DashFiters.vue

@@ -384,4 +384,9 @@ const DateRangeSearch = () => {
   display: flex;
   align-items: center;
 }
+:deep(.el-radio-button__inner) {
+  display: flex;
+  align-items: center;
+  height: 40px;
+}
 </style>