East 3 yıl önce
ebeveyn
işleme
eefb190588

+ 17 - 17
src/views/BioSafety/carAdmin/queryCondition.config.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-09-18 15:19:29
- * @LastEditTime: 2021-11-18 16:28:11
+ * @LastEditTime: 2021-12-02 09:28:03
  * @LastEditors: Please set LastEditors
  * @Description: 筛选条件的 formItems 和 propFormData
  * @FilePath: \hyyfClient\src\views\BioSafety\personAdmin\queryCondition.config.js
@@ -22,13 +22,13 @@ const propFormData1 = {
 }
 
 const formItems2 = [
-  {
-    type: 'select',
-    label: '位置:',
-    placeholder: '请选择位置',
-    field: 'region',
-    options: []
-  },
+  // {
+  //   type: 'select',
+  //   label: '位置:',
+  //   placeholder: '请选择位置',
+  //   field: 'region',
+  //   options: []
+  // },
   {
     type: 'datepicker',
     label: '时间:',
@@ -38,18 +38,18 @@ const formItems2 = [
 ]
 
 const propFormData2 = {
-  region: '',
+  // region: '',
   time: [timeDate(new Date().getTime() - 1000*60*60*24), timeDate(new Date().getTime())]
 }
 
 const formItems3 = [
-  {
-    type: 'select',
-    label: '输入搜索:',
-    placeholder: '请选择地点',
-    field: 'place',
-    options: []
-  },
+  // {
+  //   type: 'select',
+  //   label: '输入搜索:',
+  //   placeholder: '请选择地点',
+  //   field: 'place',
+  //   options: []
+  // },
   {
     type: 'datepicker',
     label: '时间:',
@@ -59,7 +59,7 @@ const formItems3 = [
 ]
 
 const propFormData3 = {
-  place: '',
+  // place: '',
   time: [timeDate(new Date().getTime() - 1000*60*60*24), timeDate(new Date().getTime())]
 }
 

+ 9 - 9
src/views/BioSafety/deadPig/queryCondition.config.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-09-18 15:19:29
- * @LastEditTime: 2021-11-19 14:54:38
+ * @LastEditTime: 2021-12-02 09:28:23
  * @LastEditors: Please set LastEditors
  * @Description: 筛选条件的 formItems 和 propFormData
  * @FilePath: \hyyfClient\src\views\BioSafety\personAdmin\queryCondition.config.js
@@ -9,13 +9,13 @@
 import { timeDate } from '../../../utils/index'
 
 export const formItems = [
-  {
-    type: 'select',
-    label: '位置:',
-    placeholder: '请选择位置',
-    field: 'place',
-    options: []
-  },
+  // {
+  //   type: 'select',
+  //   label: '位置:',
+  //   placeholder: '请选择位置',
+  //   field: 'place',
+  //   options: []
+  // },
   {
     type: 'datepicker',
     label: '时间:',
@@ -25,6 +25,6 @@ export const formItems = [
 ]
 
 export const propFormData = {
-  place: '',
+  // place: '',
   time: [timeDate(new Date().getTime() - 1000*60*60*24), timeDate(new Date().getTime())]
 }

+ 27 - 31
src/views/PdcData/Analysis.vue

@@ -27,9 +27,8 @@
           <!-- 存栏结构 -->
           <chart-inventory-pie :data="inventoryPieData"></chart-inventory-pie>
           <!-- 存栏变动 -->
-          <chart-inventory-lines
-            :data="inventoryLinesData"
-          ></chart-inventory-lines>
+          <chart-inventory-lines :data="inventoryLinesData">
+          </chart-inventory-lines>
         </div>
         <div>
           <!-- 存栏计数 -->
@@ -452,23 +451,14 @@ export default {
       this.pageNum = val;
       this.init();
     },
-    init() {
-      let params = {
-        pageNum: this.pageNum,
-        pageSize: this.size,
-        searchStr: this.keyword,
-      };
-      console.log(params);
-      // 获取后端数据
-    },
     // 销售额选中日期
     salesSetDay(data) {
       this.salesDay = data;
-      console.log(this.salesDay);
+      // console.log(this.salesDay);
     },
     // 销售额选中日周月
     salesOnClickType(data) {
-      console.log(data);
+      // console.log(data);
     },
     // 工作看板
     initWorkBoard() {
@@ -500,22 +490,28 @@ export default {
       getInventoryAndProduct({}).then((res) => {
         if (res.code === 10000) {
           // this.inventoryLinesData = res.data
-          console.log(res.data);
+          // console.log(res.data);
+          const undefinedData = {
+            stockQuantity: 0,
+          };
           // this.inventoryPieData = res.data.slice(0, 6)
           this.inventoryPieData = [
-            res.data["sow_stock"],
-            res.data["boar_stock"],
-            res.data["grice_stock"],
-            res.data["piglet_stock"],
-            res.data["fatpig_stock"],
+            res.data["sow_stock"] || undefinedData,
+            res.data["boar_stock"] || undefinedData,
+            res.data["grice_stock"] || undefinedData,
+            res.data["piglet_stock"] || undefinedData,
+            res.data["fatpig_stock"] || undefinedData,
           ];
+          // console.log("object", this.inventoryPieData);
           this.inventoryItemsData = [
-            res.data["sow_stock"].stockQuantity,
-            res.data["sow_stock_1"].stockQuantity,
-            res.data["sow_stock_2"].stockQuantity,
-            res.data["sow_stock_3"].stockQuantity,
-            res.data["boar_stock"].stockQuantity,
-            res.data["business_stock"].stockQuantity,
+            res.data["sow_stock"] ? res.data["sow_stock"].stockQuantity : 0,
+            res.data["sow_stock_1"] ? res.data["sow_stock_1"].stockQuantity : 0,
+            res.data["sow_stock_2"] ? res.data["sow_stock_2"].stockQuantity : 0,
+            res.data["sow_stock_3"] ? res.data["sow_stock_3"].stockQuantity : 0,
+            res.data["boar_stock"] ? res.data["boar_stock"].stockQuantity : 0,
+            res.data["business_stock"]
+              ? res.data["business_stock"].stockQuantity
+              : 0,
           ];
           // this.productionPercents = [
           //   res.data[12].rate * 100,
@@ -575,7 +571,7 @@ export default {
     // 经营分析 - 成本分析
     initCostData() {
       getCostData({}).then((res) => {
-        console.log(res);
+        // console.log(res);
         if (res.code === 10000) {
           this.costHisData = [
             res.data["total"],
@@ -600,7 +596,7 @@ export default {
     // 应付排名
     initYingFu() {
       getYingFu({}).then((res) => {
-        console.log("应付", res);
+        // console.log("应付", res);
         if (res.code === 10000) {
           this.yingfuTableData = res.data;
         }
@@ -612,13 +608,13 @@ export default {
         current: this.size,
         size: this.pageNum,
       }).then((res) => {
-        console.log(res);
+        // console.log(res);
       });
     },
     // 生产情况
     initProductionCondition() {
       getProductionCondition({}).then((res) => {
-        console.log(res.data);
+        // console.log(res.data);
         if (res.code === 10000) {
           this.productionPercents = [
             { ...res.data["grice_rate"], color: "rgb(112,249,250)" },
@@ -662,7 +658,7 @@ export default {
           isWeight: res.data["isWeight"],
           isHead: res.data["isHead"],
         };
-        console.log("重要指标数据----------------", this.importantTitle);
+        // console.log("重要指标数据----------------", this.importantTitle);
       });
     },
     // 重要指标的 type 改变

+ 114 - 104
src/views/PdcData/analysis/ChartInventoryLines.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-10-08 17:24:29
- * @LastEditTime: 2021-10-21 15:48:04
+ * @LastEditTime: 2021-12-02 10:18:24
  * @LastEditors: Please set LastEditors
  * @Description: 存栏结构 - 存栏变动折线图
  * @FilePath: \hyyfClient\src\views\PdcData\analysis\ChartInventoryLines.vue
@@ -16,165 +16,172 @@
 export default {
   data() {
     return {
-      myChart: null
-    }
+      myChart: null,
+    };
   },
   props: {
     data: {
       type: Object,
-      required: true
-    }
+      required: true,
+      default: () => ({}),
+    },
   },
   methods: {
     init() {
+      let flag = "";
+      if (this.data.month.length === 0) {
+        flag = "暂无数据";
+      }
+      console.log("日期为-------------", this.data.month);
       let options = {
         title: {
-          text: '存栏变动',
+          text: "存栏变动",
           x: 10,
-          y: 0
+          y: 0,
+          subtext: flag,
         },
         tooltip: {
-          trigger: 'axis',
+          trigger: "axis",
         },
         // legend: {
         //   data: ['头']
         // },
-        color: ['#3aa0ff', '#4dcb73', '#fad337', '#f2637b', '#975fe4'],
+        color: ["#3aa0ff", "#4dcb73", "#fad337", "#f2637b", "#975fe4"],
         grid: {
-          top: '20%',
-          left: '10%',
-          bottom: '10%',
-          right: '10%'
+          top: "20%",
+          left: "10%",
+          bottom: "10%",
+          right: "10%",
         },
         xAxis: [
           {
-            type: 'category',
-            name: '月',
+            type: "category",
+            name: "月",
             data: this.data.month,
             axisPointer: {
-              type: 'shadow'
+              type: "shadow",
             },
             axisLine: {
               show: true,
               lineStyle: {
-                color: '#6e7079',
-              }
-            },
-            axisTick:{
-              show: true
+                color: "#6e7079",
+              },
             },
-          }
-        ],
-        yAxis: //[
-          {
-            type: 'value',
-            name: '头',
-            // axisLabel: {
-            //   formatter: '{value} °C'
-            // },
-            axisLine: {
+            axisTick: {
               show: true,
-              lineStyle: {
-                color: '#6e7079',
-              }
             },
-            axisTick:{
-              show:false
+          },
+        ],
+        //[
+        yAxis: {
+          type: "value",
+          name: "头",
+          // axisLabel: {
+          //   formatter: '{value} °C'
+          // },
+          axisLine: {
+            show: true,
+            lineStyle: {
+              color: "#6e7079",
             },
-            splitLine:{
-              show:false
-            }
           },
-          // {
-          //   type: 'value',
-          //   name: '湿度',
-          //   axisLabel: {
-          //     formatter: '{value} RH'
-          //   },
-          //   axisLine: {
-          //     show: false,
-          //     lineStyle: {
-          //       color: '#6e7079',
-          //     }
-          //   },
-          //   axisTick:{
-          //     show:false
-          //   },
-          //   // splitLine:{
-          //   //   show:false
-          //   // }
-          // }
+          axisTick: {
+            show: false,
+          },
+          splitLine: {
+            show: false,
+          },
+        },
+        // {
+        //   type: 'value',
+        //   name: '湿度',
+        //   axisLabel: {
+        //     formatter: '{value} RH'
+        //   },
+        //   axisLine: {
+        //     show: false,
+        //     lineStyle: {
+        //       color: '#6e7079',
+        //     }
+        //   },
+        //   axisTick:{
+        //     show:false
+        //   },
+        //   // splitLine:{
+        //   //   show:false
+        //   // }
+        // }
         //],
         series: [
           {
-            name: '头',
-            type: 'line',
+            name: "头",
+            type: "line",
             smooth: false,
             data: this.data.sowStock,
             itemStyle: {
               normal: {
-                color: '#3aa0ff',
+                color: "#3aa0ff",
                 lineStyle: {
-                  color: '#3aa0ff'
-                }
-              }
-            }
+                  color: "#3aa0ff",
+                },
+              },
+            },
           },
           {
-            name: '头',
-            type: 'line',
+            name: "头",
+            type: "line",
             smooth: false,
             data: this.data.boarStock,
             itemStyle: {
               normal: {
-                color: '#4dcb73',
+                color: "#4dcb73",
                 lineStyle: {
-                  color: '#4dcb73'
-                }
-              }
-            }
+                  color: "#4dcb73",
+                },
+              },
+            },
           },
           {
-            name: '头',
-            type: 'line',
+            name: "头",
+            type: "line",
             smooth: false,
             data: this.data.griceStock,
             itemStyle: {
               normal: {
-                color: '#fad337',
+                color: "#fad337",
                 lineStyle: {
-                  color: '#fad337'
-                }
-              }
-            }
+                  color: "#fad337",
+                },
+              },
+            },
           },
           {
-            name: '头',
-            type: 'line',
+            name: "头",
+            type: "line",
             smooth: false,
             data: this.data.pigletStock,
             itemStyle: {
               normal: {
-                color: '#f2637b',
+                color: "#f2637b",
                 lineStyle: {
-                  color: '#f2637b'
-                }
-              }
-            }
+                  color: "#f2637b",
+                },
+              },
+            },
           },
           {
-            name: '头',
-            type: 'line',
+            name: "头",
+            type: "line",
             smooth: false,
             data: this.data.fatpigStock,
             itemStyle: {
               normal: {
-                color: '#975fe4',
+                color: "#975fe4",
                 lineStyle: {
-                  color: '#975fe4'
-                }
-              }
-            }
+                  color: "#975fe4",
+                },
+              },
+            },
           },
           // {
           //   name: '湿度',
@@ -183,22 +190,25 @@ export default {
           //   yAxisIndex: 1,
           //   data: [20, 22, 33, 45, 63, 102, 23, 24, 23, 65, 50, 62]
           // }
-        ]
-      }
+        ],
+      };
       this.myChart.setOption(options);
-    }
+    },
   },
   mounted() {
-    this.myChart = this.$echarts.init(document.getElementById('chartLines'));
-    this.init();
+    this.myChart = this.$echarts.init(document.getElementById("chartLines"));
+    // this.init();
   },
   watch: {
-    data(newValue) {
-      console.log(newValue)
-      this.init()
-    }
-  }
-}
+    data: {
+      handler(newValue) {
+        console.log(newValue);
+        this.init();
+      },
+      deep: true,
+    },
+  },
+};
 </script>
 
 <style scoped>

+ 98 - 73
src/views/PdcData/analysis/ChartInventoryPie.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-09-30 15:46:57
- * @LastEditTime: 2021-11-28 16:50:48
+ * @LastEditTime: 2021-12-02 09:37:17
  * @LastEditors: Please set LastEditors
  * @Description: 存栏结构图
  * @FilePath: \hyyfClient\src\views\PdcData\analysis\ChartInventoryPie.vue
@@ -15,92 +15,110 @@
 export default {
   data() {
     return {
-      myChart: null
-    }
+      myChart: null,
+    };
   },
   props: {
     data: {
       type: Array,
-      required: true
-    }
+      required: true,
+    },
   },
   methods: {
     init() {
-      const _this = this
-      let total = this.data.reduce((prev, item) => prev + item.stockQuantity, 0)
+      const _this = this;
+      let total = this.data.reduce(
+        (prev, item) => prev + item.stockQuantity,
+        0
+      );
       let options = {
         title: {
-          text: '存栏结构',
+          text: "存栏结构",
           x: 20,
-          y: 20
+          y: 20,
         },
         grid: {
-          x: 100
+          x: 100,
         },
         tooltip: {
-          trigger: 'item',
-          formatter: function ({name, value, percent}) {
-            return name + ':' + value + '头&nbsp;&nbsp;&nbsp;&nbsp;' + percent + '%'
-          }
+          trigger: "item",
+          formatter: function({ name, value, percent }) {
+            return (
+              name + ":" + value + "头&nbsp;&nbsp;&nbsp;&nbsp;" + percent + "%"
+            );
+          },
         },
         legend: {
-          top: '25%',
-          left: '55%',
-          orient: 'vertical',
+          top: "25%",
+          left: "55%",
+          orient: "vertical",
           icon: "circle",
           selectedMode: false, // 取消右侧项选中
           itemGap: 20, // 各项间隔
           textStyle: {
             fontSize: 15,
-            color: '#666'
+            color: "#666",
           },
-          formatter: function (name) {
+          formatter: function(name) {
             var legendIndex = 0;
-            const clientLabels = []
+            const clientLabels = [];
             // 将右侧文字备注放上去
-            _this.data.forEach(item => {
+            _this.data.forEach((item) => {
+              let percentStr = "";
+              if (item.stockQuantity !== 0) {
+                percentStr =
+                  (parseFloat(item.stockQuantity / total) * 100).toFixed(2) +
+                  "%, ";
+              }
               clientLabels.push({
                 name: item.stockName,
-                percent: (parseFloat(item.stockQuantity / total) * 100).toFixed(2) + '%',
-                number: item.stockQuantity
-              })
-            })
-            clientLabels.forEach(function (value, i) {
-                if (value.name == name) {
-                    legendIndex = i;
-                }
+                percent: percentStr,
+                number: item.stockQuantity,
+              });
+            });
+            clientLabels.forEach(function(value, i) {
+              if (value.name == name) {
+                legendIndex = i;
+              }
             });
-            return name + " (" + clientLabels[legendIndex].percent + ', ' + clientLabels[legendIndex].number + '头' + ") ";
-          }
+            return (
+              name +
+              " (" +
+              clientLabels[legendIndex].percent +
+              clientLabels[legendIndex].number +
+              "头" +
+              ") "
+            );
+          },
         },
         graphic: [
           {
-            type: 'text',
-            left: '27%',
-            top: '43%',
+            type: "text",
+            left: "27%",
+            top: "43%",
             style: {
-              text: '总存栏',
+              text: "总存栏",
               fontSize: 15,
-              fill: 'rgb(192, 188, 189)'
-            }
+              fill: "rgb(192, 188, 189)",
+            },
           },
           {
-            type: 'text',
-            left: '25%',
-            top: '53%',
+            type: "text",
+            left: "25%",
+            top: "53%",
             style: {
-              text: total + '头',
+              text: total + "头",
               fontSize: 22,
-              fontWeight: 700
-            }
-          }
+              fontWeight: 700,
+            },
+          },
         ],
         series: [
           {
-            name: 'Access From',
-            type: 'pie',
-            radius: ['60%', '80%'], // 半径
-            center: ['30%', '55%'],
+            name: "Access From",
+            type: "pie",
+            radius: ["60%", "80%"], // 半径
+            center: ["30%", "55%"],
             avoidLabelOverlap: false,
             label: {
               show: false,
@@ -109,48 +127,55 @@ export default {
             emphasis: {
               label: {
                 show: false,
-                fontSize: '40',
-                fontWeight: 'bold'
-              }
+                fontSize: "40",
+                fontWeight: "bold",
+              },
             },
             labelLine: {
-              show: false
+              show: false,
             },
             itemStyle: {
               normal: {
-                color: function (colors) { // 颜色设置
-                  var colorList = ['#3aa0ff', '#4dcb73', '#fad337', '#f2637b', '#975fe4']
-                  return colorList[colors.dataIndex]
+                color: function(colors) {
+                  // 颜色设置
+                  var colorList = [
+                    "#3aa0ff",
+                    "#4dcb73",
+                    "#fad337",
+                    "#f2637b",
+                    "#975fe4",
+                  ];
+                  return colorList[colors.dataIndex];
                 },
                 borderWidth: 5, // 设置各项空隙
-                borderColor: '#fff'
-              }
+                borderColor: "#fff",
+              },
             },
             data: [
-              { value: this.data[0].stockQuantity, name: '母猪存栏' },
-              { value: this.data[1].stockQuantity, name: '公猪存栏' },
-              { value: this.data[2].stockQuantity, name: '哺乳仔猪存栏' },
-              { value: this.data[3].stockQuantity, name: '保育猪存栏' },
-              { value: this.data[4].stockQuantity, name: '育肥猪存栏' }
-            ]
-          }
-        ]
+              { value: this.data[0].stockQuantity, name: "母猪存栏" },
+              { value: this.data[1].stockQuantity, name: "公猪存栏" },
+              { value: this.data[2].stockQuantity, name: "哺乳仔猪存栏" },
+              { value: this.data[3].stockQuantity, name: "保育猪存栏" },
+              { value: this.data[4].stockQuantity, name: "育肥猪存栏" },
+            ],
+          },
+        ],
       };
 
-      this.myChart.setOption(options)
-    }
+      this.myChart.setOption(options);
+    },
   },
   mounted() {
-    this.myChart = this.$echarts.init(document.getElementById('chartPie'));
+    this.myChart = this.$echarts.init(document.getElementById("chartPie"));
     // this.init()
   },
   watch: {
     data(newValue) {
-      console.log(newValue)
-      this.init()
-    }
-  }
-}
+      console.log(newValue);
+      this.init();
+    },
+  },
+};
 </script>
 <style scoped>
 .chart-inventory-pie {

+ 11 - 8
src/views/PdcData/analysis/InventoryItems.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-10-11 10:10:26
- * @LastEditTime: 2021-11-26 14:04:57
+ * @LastEditTime: 2021-12-02 10:21:07
  * @LastEditors: Please set LastEditors
  * @Description: 存栏情况 - 下面 item 的数字
  * @FilePath: \hyyfClient\src\views\PdcData\analysis\InventoryItems.vue
@@ -109,7 +109,7 @@ export default {
   props: {
     data: {
       type: Array,
-      default: () => [1, 1, 1, 1, 1, 1],
+      default: () => [],
     },
   },
   data() {
@@ -121,14 +121,17 @@ export default {
     InventoryItem,
   },
   mounted() {
-    console.log("-----------------------");
-    console.log(this.data);
+    // console.log("-----------------------");
+    // console.log(this.data);
   },
   watch: {
-    data(newValue) {
-      this.getData = newValue;
-      console.log(this.getData, "-------------------------");
-      console.log("-------------------------", this.getData.length);
+    data: {
+      handler(newValue) {
+        this.getData = newValue;
+        console.log(this.getData, "-------------------------");
+        console.log("-------------------------", this.getData.length);
+      },
+      deep: true,
     },
   },
 };