East 3 лет назад
Родитель
Сommit
c610bd9fed

+ 5 - 5
src/utils/chenApi.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-11-18 13:40:39
- * @LastEditTime: 2021-12-01 15:22:46
+ * @LastEditTime: 2021-12-02 16:14:15
  * @LastEditors: Please set LastEditors
  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  * @FilePath: \hyyfClient\src\utils\chenApi.js
@@ -77,8 +77,8 @@ export function getWorkTotal(params) {
 export function getWorkInfos(params) {
   return axios({
     url: '/produce/prodWarningMsg/listWarningMsg',
-    method: 'post',
-    data: params
+    method: 'get',
+    params: params
   })
 }
 
@@ -86,8 +86,8 @@ export function getWorkInfos(params) {
 export function getSafeInventory(params) {
   return axios({
     url: '/produce/prodGoodsWarning/listGoodsWarning',
-    method: 'get',
-    params: params
+    method: 'post',
+    data: params
   })
 }
 

+ 68 - 12
src/views/PdcData/Analysis.vue

@@ -96,10 +96,8 @@
           </el-date-picker>
         </div>
         <div class="important-chart">
-          <important-line
-            :listData="importantData"
-            v-bind="importantTitle"
-          ></important-line>
+          <important-line :listData="importantData" v-bind="importantTitle">
+          </important-line>
         </div>
       </div>
 
@@ -200,6 +198,14 @@
         :shows="safetyTableShows"
         :listData="safetyTableData"
       >
+        <template #isWarning="slotProps">
+          <el-tag
+            :type="slotProps.row.isWarning ? 'success' : 'warning'"
+            effect="dark"
+          >
+            {{ slotProps.row.isWarning ? "已报警" : "未报警" }}
+          </el-tag>
+        </template>
       </table-content>
       <table-footer
         :totals="total"
@@ -605,10 +611,14 @@ export default {
     // 安全库存报警
     initSafeInventory() {
       getSafeInventory({
-        current: this.size,
-        size: this.pageNum,
+        current: this.pageNum,
+        size: this.size,
       }).then((res) => {
         // console.log(res);
+        if (res.code === 10000) {
+          this.safetyTableData = res.data.records;
+          this.total = res.data.total;
+        }
       });
     },
     // 生产情况
@@ -644,14 +654,57 @@ export default {
         type: this.importantValue,
       }).then((res) => {
         const types = [
-          ["break_rate"],
-          ["avg_farrow_1", "avg_farrow_2", "avg_farrow_3"],
-          ["avg_weight", "break_grice"],
-          ["fatpig_rate", "grice_rate", "piglet_rate"],
+          [
+            {
+              type: "break_rate",
+              name: "七日断配率",
+            },
+          ],
+          [
+            {
+              type: "avg_farrow_1",
+              name: "平均窝产仔猪数",
+            },
+            {
+              type: "avg_farrow_2",
+              name: "平均窝产活仔数",
+            },
+            {
+              type: "avg_farrow_3",
+              name: "平均窝产正常仔数",
+            },
+          ],
+          [
+            {
+              type: "avg_weight",
+              name: "平均断奶窝重",
+            },
+            {
+              type: "break_grice",
+              name: "窝断奶仔猪数",
+            },
+          ],
+          [
+            {
+              type: "fatpig_rate",
+              name: "肥猪成活率",
+            },
+            {
+              type: "grice_rate",
+              name: "产房成活率",
+            },
+            {
+              type: "piglet_rate",
+              name: "保育成活率",
+            },
+          ],
         ];
         this.importantData = [];
-        types[this.importantValue - 1].forEach((type) => {
-          this.importantData.push(res.data[type]);
+        types[this.importantValue - 1].forEach((item) => {
+          this.importantData.push({
+            ...res.data[item.type],
+            name: item.name, // 各项名称
+          });
         });
         this.importantTitle = {
           isPercentage: res.data["isPercentage"],
@@ -686,11 +739,14 @@ export default {
           this.weekSalesChange = res.data.moneyPercent;
           this.weekSalesVolume = res.data.quantity;
           this.weekSalesVolumeChange = res.data.quantityPercent;
+          // console.log("救命");
           this.salesChartData = {
             moneyList: res.data.moneyList,
+            moneyList1: res.data.moneyList1,
             quantityList: res.data.quantityList,
             timeList: res.data.timeList,
           };
+          // console.log(this.salesChartData);
         }
       });
     },

+ 46 - 26
src/views/PdcData/analysis/CostPie.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-10-12 08:39:43
- * @LastEditTime: 2021-11-29 09:38:46
+ * @LastEditTime: 2021-12-02 19:25:50
  * @LastEditors: Please set LastEditors
  * @Description: 成本分析扇形图
  * @FilePath: \hyyfClient\src\views\PdcData\analysis\CostPie.vue
@@ -38,7 +38,7 @@ export default {
       let options = {
         title: {
           text: this.title,
-          x: "center",
+          x: "30%",
           y: "bottom",
           textAlign: " center",
           textStyle: {
@@ -51,7 +51,7 @@ export default {
         },
         legend: {
           top: "30%",
-          left: "70%",
+          left: "80%",
           orient: "vertical",
           icon: "circle",
           selectedMode: false, // 取消右侧项选中
@@ -66,8 +66,9 @@ export default {
             // name: 'Access From',
             type: "pie",
             radius: "70%", // 半径
-            center: ["35%", "45%"],
+            center: ["40%", "45%"],
             avoidLabelOverlap: false,
+            hoverAnimation: false,
             labelLine: {
               show: true,
             },
@@ -86,32 +87,51 @@ export default {
                   return colorList[colors.dataIndex];
                 },
                 label: {
-                  // formatter: (params) => {
-                  //   let percent = ((params.value / total) * 100).toFixed(2);
-                  //   return `${params.name}: ${params.value.toFixed(
-                  //     2
-                  //   )} ${percent}%`;
-                  // },
-                  formatter: "{b}: {c} {d}%",
+                  formatter: (params) => {
+                    // 这里简直完美好吗,解决了文字样式也解决了千分位
+                    let value = params.value.toLocaleString();
+                    let percent = ((params.value / total) * 100).toFixed(2);
+                    return `{b|${params.name}:}\n{c|${value}}元\n{d|${percent}%}`;
+                  },
+                  rich: {
+                    b: {
+                      align: "center",
+                      fontSize: 15,
+                      // lineHeight: 23,
+                    },
+                    c: {
+                      align: "center",
+                      lineHeight: 25,
+                      fontSize: 15,
+                    },
+                    d: {
+                      align: "center",
+                      fontSize: 15,
+                    },
+                  },
+                },
+                labelLine: {
+                  length: 22,
                 },
               },
+
               label: {
                 show: false,
               },
-              emphasis: {
-                label: {
-                  show: true,
-                  formatter: "{b}: {c}%",
-                  textStyle: {
-                    fontSize: "15",
-                  },
-                },
-                itemStyle: {
-                  shadowBlur: 10,
-                  shadowOffsetX: 5,
-                  shadowColor: "rgba(0, 0, 0, 0.5)",
-                },
-              },
+              // emphasis: {
+              //   label: {
+              //     show: true,
+              //     // formatter: "{b}: {c}%",
+              //     textStyle: {
+              //       fontSize: "15",
+              //     },
+              //   },
+              //   itemStyle: {
+              //     shadowBlur: 10,
+              //     shadowOffsetX: 5,
+              //     shadowColor: "rgba(0, 0, 0, 0.5)",
+              //   },
+              // },
             },
             data: [
               { value: gtValue, name: "公摊成本" },
@@ -127,7 +147,7 @@ export default {
   },
   mounted() {
     this.myChart = this.$echarts.init(document.getElementById("costPie"));
-    // this.init()
+    this.init();
   },
   watch: {
     data(value) {

+ 10 - 7
src/views/PdcData/analysis/ImportantLine.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-10-12 10:31:13
- * @LastEditTime: 2021-11-27 16:27:13
+ * @LastEditTime: 2021-12-02 13:47:35
  * @LastEditors: Please set LastEditors
  * @Description: 重要指标
  * @FilePath: \hyyfClient\src\views\PdcData\analysis\ImportantLine.vue
@@ -40,6 +40,7 @@ export default {
   methods: {
     init() {
       let seriesData = [];
+      let legendData = [];
       // [
       //     {
       //       name: "头",
@@ -60,9 +61,10 @@ export default {
       //     },
       //   ],
       this.listData.forEach((item) => {
-        let yName = ["头", "百分比", "千克"];
+        // let yName = ["头", "百分比", "千克"];
+        legendData.push(item.name);
         seriesData.push({
-          name: yName[item.isPercentage],
+          name: item.name,
           type: "line",
           smooth: false,
           data: item.value,
@@ -97,7 +99,7 @@ export default {
           name: "百分比",
           axisLabel: {
             show: true,
-            formatter: "{value} %",
+            formatter: "{value}",
           },
           axisLine: {
             show: true,
@@ -145,9 +147,10 @@ export default {
         tooltip: {
           trigger: "axis",
         },
-        // legend: {
-        //   data: ['头']
-        // },
+        legend: {
+          data: legendData,
+          padding: [20, 0, 0, 0],
+        },
         color: ["#3aa0ff", "#4dcb73", "#fad337", "#f2637b", "#975fe4"],
         grid: {
           top: "20%",

+ 12 - 26
src/views/PdcData/analysis/SalesChart.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-10-12 13:45:04
- * @LastEditTime: 2021-11-29 14:20:33
+ * @LastEditTime: 2021-12-02 17:42:09
  * @LastEditors: Please set LastEditors
  * @Description: 销售情况面积图
  * @FilePath: \hyyfClient\src\views\PdcData\analysis\SalesChart.vue
@@ -27,9 +27,7 @@ export default {
     // },
     data: {
       type: Object,
-      default: function() {
-        return  {}
-      },
+      default: () => {},
     },
     // dataValue: {
     //   type: Array,
@@ -45,6 +43,7 @@ export default {
       let start = dataAxis.length - 12;
       let end = dataAxis.length - 1;
       let quantityList = this.data.quantityList;
+      let moneyListTooltip = this.data.moneyList1;
       let options = {
         title: {
           x: 60,
@@ -66,7 +65,7 @@ export default {
                   <span style="display:inline-block;margin-right:5px;border-radius:5px;width:10px;height:10px;background-color:${[
                     params[i].color, // 默认是小圆点,我们将其修改成有圆角的正方形,这里用的是模板字符串。并拿到对应颜色、名字、数据
                   ]};"></span>
-                  ${params[i].data}元
+                  ${moneyListTooltip[i]}元
                 </div>` +
                 `<div style="color: #fff;font-size: 14px; padding:0 12px;"><span style="display:inline-block;margin-right:5px;border-radius:5px;width:10px;height:10px;background-color:${[
                   params[i].color,
@@ -82,23 +81,8 @@ export default {
             startValue: start,
             endValue: end,
             show: false,
-            // zoomOnMouseWheel: false,
-            // zoomLock: true,
           },
         ],
-        // dataZoom: [
-        //
-        //   {
-        //     type: 'slider',
-        //     startValue: start,
-        //     endValue:end,
-        //     zoomOnMouseWheel: false,
-        //     zoomLock: true,
-        //   },
-        //   {
-        //     type: 'inside'
-        //   },
-        // ],
         xAxis: [
           {
             type: "category",
@@ -151,7 +135,7 @@ export default {
               borderColor: this.color,
               normal: {
                 label: {
-                  show: true,
+                  show: false,
                   textStyle: {
                     fontSize: 14,
                   },
@@ -167,13 +151,15 @@ export default {
   },
   mounted() {
     this.myChart = this.$echarts.init(document.getElementById("salesChart"));
-    this.init()
+    // this.init();
   },
   watch: {
     data: {
-      handle(newVal) {
-        if(newVal) {
-          this.myChart.clear();
+      handler(newVal) {
+        // console.log("救命");
+        if (newVal) {
+          // console.log("我不理解究竟有什么问题", newVal);
+          // this.myChart.clear();
           this.init();
         }
       },
@@ -181,7 +167,7 @@ export default {
     },
     color(newVal) {
       if (newVal) {
-        this.myChart.clear();
+        // this.myChart.clear();
         this.init();
       }
     },