wenhongquan 9 месяцев назад
Родитель
Сommit
6a51d7cbc0
3 измененных файлов с 125 добавлено и 113 удалено
  1. 9 0
      src/api/data.ts
  2. 57 55
      src/components/HomeComponents/lineEcharts.vue
  3. 59 58
      src/components/HomeStatics/lineEcharts.vue

+ 9 - 0
src/api/data.ts

@@ -70,6 +70,15 @@ export const bagCount = (query) => {
     params: query
     params: query
   });
   });
 };
 };
+
+export const bagCount1 = (query) => {
+  return request({
+    url: 'http://cyd.ruihuadt.com/admin/CYD/station/getMeta',
+    method: 'get',
+    params: query
+  });
+};
+
 // export const openall = (code) =>{
 // export const openall = (code) =>{
 //   return request({
 //   return request({
 //     url: '/system/common/cabinet/{code}/box/{boxuuid}/clear',
 //     url: '/system/common/cabinet/{code}/box/{boxuuid}/clear',

+ 57 - 55
src/components/HomeComponents/lineEcharts.vue

@@ -21,29 +21,30 @@ import * as echarts from "echarts";
 import moment from "moment";
 import moment from "moment";
 
 
 const linechart = ref();
 const linechart = ref();
-import { bagCount } from "@/api/data";
+import { bagCount1 } from "@/api/data";
 
 
 const drawEchart = (arryData, total) => {
 const drawEchart = (arryData, total) => {
   let echartsObj = echarts.init(linechart.value, "macarons");
   let echartsObj = echarts.init(linechart.value, "macarons");
-  var dateArray = getRecentDays();
+  // var dateArray = getRecentDays();
   var option = (option = {
   var option = (option = {
-    title: [
-      {
-        text: "总数",
-        subtext: total + "",
-        textStyle: {
-          fontSize: 15,
-          color: "#fff",
-        },
-        subtextStyle: {
-          fontSize: 20,
-          color: "#fff",
-        },
-        textAlign: "center",
-        x: "48%",
-        y: "35%",
-      },
-    ],
+    // title: [
+    //   {
+    //     text: "总数",
+    //     subtext: total + "",
+    //     textStyle: {
+    //       fontSize: 15,
+    //       color: "#fff",
+    //     },
+    //     subtextStyle: {
+    //       fontSize: 20,
+    //       color: "#fff",
+    //     },
+    //     textAlign: "center",
+    //     x: "48%",
+    //     y: "35%",
+    //   },
+    // ],
+    title:"",
     series: [
     series: [
       {
       {
         name: "Access From",
         name: "Access From",
@@ -92,53 +93,54 @@ const drawEchart = (arryData, total) => {
   echartsObj.setOption(option);
   echartsObj.setOption(option);
 };
 };
 
 
-const getRecentDays = () => {
-  const oneDay = 24 * 60 * 60 * 1000; // 这里定义一天的毫秒数
-  const resultArray = [];
-  for (let i = 6; i >= 0; i--) {
-    const currentDate = new Date(Date.now() - i * oneDay); // 计算出每天的日期
-    const year = currentDate.getFullYear();
-    const month = String(currentDate.getMonth() + 1).padStart(2, "0"); // 月份需要补零
-    const day = String(currentDate.getDate()).padStart(2, "0"); // 日期也需要补零
-    const formattedDate = `${month}-${day}`; // 格式化日期为 yyyy-mm-dd 的形式
-    resultArray.push(formattedDate);
-  }
-  return resultArray;
-};
+// const getRecentDays = () => {
+//   const oneDay = 24 * 60 * 60 * 1000; // 这里定义一天的毫秒数
+//   const resultArray = [];
+//   for (let i = 6; i >= 0; i--) {
+//     const currentDate = new Date(Date.now() - i * oneDay); // 计算出每天的日期
+//     const year = currentDate.getFullYear();
+//     const month = String(currentDate.getMonth() + 1).padStart(2, "0"); // 月份需要补零
+//     const day = String(currentDate.getDate()).padStart(2, "0"); // 日期也需要补零
+//     const formattedDate = `${month}-${day}`; // 格式化日期为 yyyy-mm-dd 的形式
+//     resultArray.push(formattedDate);
+//   }
+//   return resultArray;
+// };
 
 
 const getbagCountData = () => {
 const getbagCountData = () => {
-  var param = {
-    // beginCreatedAt: moment().format("YYYY-MM-DD 00:00:00"),
-  };
+  // var param = {
+  //   // beginCreatedAt: moment().format("YYYY-MM-DD 00:00:00"),
+  // };
   var obj = {
   var obj = {
-    params: param,
-    pageSize: 1000,
+    // params: param,
+    // pageSize: 1000,
   };
   };
-  bagCount(obj).then((res) => {
+  bagCount1(obj).then((res) => {
     console.log(res);
     console.log(res);
     var rkCount = 0;
     var rkCount = 0;
     var ckCount = 0;
     var ckCount = 0;
     var ycCount = 0;
     var ycCount = 0;
     var clCount = 0;
     var clCount = 0;
-    var total = res.total;
-    for (var index in res.rows) {
-      if (res.rows[index].bagStatus == 0) {
-        rkCount++;
-      } else if (res.rows[index].bagStatus == 1) {
-        ckCount++;
-      } else if (res.rows[index].bagStatus == 2) {
-        ycCount++;
-      } else if (res.rows[index].bagStatus == 3) {
-        clCount++;
-      }
-    }
+    // var total = res.total;
+    // for (var index in res.rows) {
+    //   if (res.rows[index].bagStatus == 0) {
+    //     rkCount++;
+    //   } else if (res.rows[index].bagStatus == 1) {
+    //     ckCount++;
+    //   } else if (res.rows[index].bagStatus == 2) {
+    //     ycCount++;
+    //   } else if (res.rows[index].bagStatus == 3) {
+    //     clCount++;
+    //   }
+    // }
+
     var arryData = [
     var arryData = [
-      { value: rkCount, name: "入库" },
-      { value: ckCount, name: "出库" },
-      { value: ycCount, name: "异常" },
-      { value: clCount, name: "已处理" },
+      { value: res.data.TodayInbound, name: "今日入库" },
+      { value: res.data.TodayOutbound, name: "今日出库" },
+      { value: res.data.LastMonthTodayInbound, name: "上月今日入库" },
+      { value: res.data.LastMonthTodayOutbound, name: "上月今日出库" },
     ];
     ];
-    drawEchart(arryData, total);
+    drawEchart(arryData, 0);
   });
   });
 };
 };
 
 

+ 59 - 58
src/components/HomeStatics/lineEcharts.vue

@@ -9,29 +9,30 @@ import * as echarts from "echarts";
 import moment from "moment";
 import moment from "moment";
 
 
 const linechart = ref();
 const linechart = ref();
-import { bagCount } from "@/api/data";
+import { bagCount1 } from "@/api/data";
 
 
 const drawEchart = (arryData, total) => {
 const drawEchart = (arryData, total) => {
   let echartsObj = echarts.init(linechart.value, "macarons");
   let echartsObj = echarts.init(linechart.value, "macarons");
-  var dateArray = getRecentDays();
+  // var dateArray = getRecentDays();
   var option = (option = {
   var option = (option = {
-    title: [
-      {
-        text: "总数",
-        subtext: total + "",
-        textStyle: {
-          fontSize: 15,
-          color: "black",
-        },
-        subtextStyle: {
-          fontSize: 20,
-          color: "black",
-        },
-        textAlign: "center",
-        x: "48%",
-        y: "35%",
-      },
-    ],
+    // title: [
+    //   {
+    //     text: "总数",
+    //     subtext: total + "",
+    //     textStyle: {
+    //       fontSize: 15,
+    //       color: "black",
+    //     },
+    //     subtextStyle: {
+    //       fontSize: 20,
+    //       color: "black",
+    //     },
+    //     textAlign: "center",
+    //     x: "48%",
+    //     y: "35%",
+    //   },
+    // ],
+    title:"",
     series: [
     series: [
       {
       {
         name: "Access From",
         name: "Access From",
@@ -79,19 +80,19 @@ const drawEchart = (arryData, total) => {
   echartsObj.setOption(option);
   echartsObj.setOption(option);
 };
 };
 
 
-const getRecentDays = () => {
-  const oneDay = 24 * 60 * 60 * 1000; // 这里定义一天的毫秒数
-  const resultArray = [];
-  for (let i = 6; i >= 0; i--) {
-    const currentDate = new Date(Date.now() - i * oneDay); // 计算出每天的日期
-    const year = currentDate.getFullYear();
-    const month = String(currentDate.getMonth() + 1).padStart(2, "0"); // 月份需要补零
-    const day = String(currentDate.getDate()).padStart(2, "0"); // 日期也需要补零
-    const formattedDate = `${month}-${day}`; // 格式化日期为 yyyy-mm-dd 的形式
-    resultArray.push(formattedDate);
-  }
-  return resultArray;
-};
+// const getRecentDays = () => {
+//   const oneDay = 24 * 60 * 60 * 1000; // 这里定义一天的毫秒数
+//   const resultArray = [];
+//   for (let i = 6; i >= 0; i--) {
+//     const currentDate = new Date(Date.now() - i * oneDay); // 计算出每天的日期
+//     const year = currentDate.getFullYear();
+//     const month = String(currentDate.getMonth() + 1).padStart(2, "0"); // 月份需要补零
+//     const day = String(currentDate.getDate()).padStart(2, "0"); // 日期也需要补零
+//     const formattedDate = `${month}-${day}`; // 格式化日期为 yyyy-mm-dd 的形式
+//     resultArray.push(formattedDate);
+//   }
+//   return resultArray;
+// };
 
 
 const isToday = (date) => {
 const isToday = (date) => {
   // console.log(date)
   // console.log(date)
@@ -108,34 +109,34 @@ const getbagCountData = () => {
     params: param,
     params: param,
     pageSize: 1000,
     pageSize: 1000,
   };
   };
-  bagCount(obj).then((res) => {
-    var rkCount = 0;
-    var ckCount = 0;
-    var ycCount = 0;
-    var clCount = 0;
-    // var total = res.total;
-    for (var index in res.rows) {
-      if(isToday(new Date(res.rows[index].createdAt))){
-        console.log(res.rows[index]);
-        if (res.rows[index].bagStatus == 0) {
-        rkCount++;
-      } else if (res.rows[index].bagStatus == 1) {
-        ckCount++;
-      } else if (res.rows[index].bagStatus == 2) {
-        ycCount++;
-      } else if (res.rows[index].bagStatus == 3) {
-        clCount++;
-      }
-      }
-    }
-    var total = rkCount+ckCount+ycCount+clCount
+  bagCount1(obj).then((res) => {
+    // var rkCount = 0;
+    // var ckCount = 0;
+    // var ycCount = 0;
+    // var clCount = 0;
+    // // var total = res.total;
+    // for (var index in res.rows) {
+    //   if(isToday(new Date(res.rows[index].createdAt))){
+    //     console.log(res.rows[index]);
+    //     if (res.rows[index].bagStatus == 0) {
+    //     rkCount++;
+    //   } else if (res.rows[index].bagStatus == 1) {
+    //     ckCount++;
+    //   } else if (res.rows[index].bagStatus == 2) {
+    //     ycCount++;
+    //   } else if (res.rows[index].bagStatus == 3) {
+    //     clCount++;
+    //   }
+    //   }
+    // }
+    // var total = rkCount+ckCount+ycCount+clCount
     var arryData = [
     var arryData = [
-      { value: rkCount, name: "入库" },
-      { value: ckCount, name: "出库" },
-      { value: ycCount, name: "异常" },
-      { value: clCount, name: "已处理" },
+      { value: res.data.TodayInbound, name: "今日入库" },
+      { value: res.data.TodayOutbound, name: "今日出库" },
+      { value: res.data.LastMonthTodayInbound, name: "上月今日入库" },
+      { value: res.data.LastMonthTodayOutbound, name: "上月今日出库" },
     ];
     ];
-    drawEchart(arryData, total);
+    drawEchart(arryData, 0);
   });
   });
 };
 };