yusheng 4 天之前
父节点
当前提交
04f3018f47

+ 48 - 0
src/api/main/index.js

@@ -15,6 +15,14 @@ export async function queryFactory(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+// 工厂查询
+export async function queryFactoryYx(data) {
+  const res = await request.get(`/qms/quality_work_order/queryFactoryYx`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 // 班组查询
 export async function queryTeam(data) {
   const res = await request.post(`/qms/quality_work_order/queryTeam`, data);
@@ -135,3 +143,43 @@ export async function getProduceTreeByCode(type) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+export async function inspectionFrequencyYx(params) {
+  const res = await request.get(
+    `/qms/quality_work_order/inspectionFrequencyYx`,
+    { params }
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+export async function queryPassrateYx(params) {
+  const res = await request.get(
+    `/qms/quality_work_order/queryPassrateYx`,
+    { params }
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+export async function queryFrequencyAnnualYx(params) {
+  const res = await request.get(
+    `/pcs/recordrulesorder/queryFrequencyAnnualYx`,
+    { params }
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+export async function queryFrequencyMonthlyYx(params) {
+  const res = await request.get(
+    `/pcs/recordrulesorder/queryFrequencyMonthlyYx`,
+    { params }
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 76 - 4
src/views/home/data.js

@@ -201,9 +201,16 @@ export const preOptions = (
       top: '35%',
       itemGap: window.innerHeight * 0.018,
       formatter: function (name) {
-        let value = data.find(item => item.name === name);
-        console.log(value)
-        return `${name}  |  ${value.value}`;
+        let value = data.find((item) => item.name === name);
+        let total = (data || []).reduce(
+          (sum, item) => sum + (Number(item.value) || 0),
+          0
+        );
+        let percent = total
+          ? (((Number(value?.value) || 0) / total) * 100).toFixed(2)
+          : 0;
+        console.log(value);
+        return `${name}  |  ${value?.value || 0}  (${percent}%)`;
       },
       textStyle: {
         fontSize: window.innerHeight * 0.014
@@ -250,7 +257,10 @@ export const preOptions = (
         left: '27%',
         top: '55%',
         style: {
-          text: 55,
+          text: (data || []).reduce(
+            (sum, item) => sum + (Number(item.value) || 0),
+            0
+          ),
           textAlign: 'center',
           fill: '#000',
           fontSize: window.innerHeight * 0.013,
@@ -260,7 +270,62 @@ export const preOptions = (
     ]
   };
 };
+export const preOptions1 = (
+  data,
+  radius = ['55%', '70%'],
+  labelLineShow = true,
+  labelPosition = 'outside'
+) => {
+  return {
+    color: ['#398f4e', '#458ef7'],
+    tooltip: {
+      // formatter: function (params) {
+      //   return `${params.name}<br/>次数: ${params.value}<br/>占比: ${params.percent}%`;
+      // },
+      // formatter: '{d}%',
+      trigger: 'item'
+    },
+    legend: {
+      orient: 'vertical',
+      right: '10%',
+      top: '35%',
+      itemGap: window.innerHeight * 0.018,
+      formatter: function (name) {
+        let value = data.find((item) => item.name === name);
 
+        console.log(value);
+        return `${name}  |  ${value?.value || 0}  `;
+      },
+      textStyle: {
+        fontSize: window.innerHeight * 0.014
+      }
+    },
+    series: [
+      {
+        center: ['30%', '50%'],
+        label: {
+          position: labelPosition,
+          show: false,
+          formatter: (item) => {
+            return item.name + ':' + item.value;
+          },
+          fontSize: window.innerHeight * 0.014
+        },
+        labelLine: {
+          show: labelLineShow
+        },
+        type: 'pie',
+        radius,
+        itemStyle: {
+          borderWidth: 0,
+          shadowBlur: 10,
+          shadowColor: 'rgba(0, 0, 0, 0.5)'
+        },
+        data
+      }
+    ]
+  };
+};
 export const lineOption = (data, type) => {
   console.log(getDatesInMonth(), 'getDatesInMonth');
 
@@ -292,7 +357,14 @@ export const lineOption = (data, type) => {
       },
       trigger: 'item'
     },
+    legend: {
+      orient: 'vertical',
 
+      itemGap: window.innerHeight * 0.018,
+      textStyle: {
+        fontSize: window.innerHeight * 0.014
+      }
+    },
     xAxis: {
       type: 'category',
       axisLabel: {

+ 2 - 2
src/views/home/index.vue

@@ -1,8 +1,8 @@
 <template>
   <div>
-    <yuxin v-if="$store.state.user.info.clientEnvironmentId==10"></yuxin>
+    <yuxin v-if="$hasPermission('qms:yuxin:home')"></yuxin>
 
-    <common v-else></common>
+    <common ></common>
   </div>
 </template>
 

+ 83 - 121
src/views/home/yuxin.vue

@@ -15,7 +15,7 @@
             >
           </div>
           <v-chart
-            ref="pieRef2"
+            ref="option1"
             style="height: 100%"
             :option="teamQualifiedOption"
           />
@@ -32,14 +32,16 @@
             <span>质检次数</span>
             <div class="time">
               <el-date-picker
-                v-model="value2"
+                v-model="value1"
                 type="month"
                 placeholder="选择月"
+                value-format="yyyy-MM"
+                @change="handleValue1Change"
               >
               </el-date-picker>
             </div>
           </div>
-          <v-chart ref="pieRef4" style="height: 100%" :option="preOptions" />
+          <v-chart ref="pieRef1" style="height: 100%" :option="preOptions1" />
         </el-card>
       </el-col>
 
@@ -52,11 +54,7 @@
           >
             <span>时率</span>
           </div>
-          <v-chart
-            ref="pieRef2"
-            style="height: 100%"
-            :option="teamQualifiedOption"
-          />
+          <v-chart ref="pieRef2" style="height: 100%" :option="preOptions2" />
         </el-card>
       </el-col>
 
@@ -73,28 +71,36 @@
                 v-model="value2"
                 type="year"
                 placeholder="选择年"
+                value-format="yyyy"
+                @change="handleValue2Change"
               >
               </el-date-picker>
             </div>
           </div>
-          <v-chart ref="lineRef" style="height: 100%" :option="lineOption" />
+          <v-chart ref="lineRef1" style="height: 100%" :option="lineOption" />
         </el-card>
       </el-col>
 
       <el-col :span="12" style="margin-top: 15px; height: calc(60% - 15px)">
         <el-card class="box-card">
-          <div slot="header" class="clearfix"  style="display: flex; align-items: center">
+          <div
+            slot="header"
+            class="clearfix"
+            style="display: flex; align-items: center"
+          >
             <span>时率趋势图</span>
             <div class="time">
               <el-date-picker
-                v-model="value2"
+                v-model="value3"
                 type="year"
                 placeholder="选择年"
+                value-format="yyyy"
+                @change="handleValue3Change"
               >
               </el-date-picker>
             </div>
           </div>
-          <v-chart ref="lineRef" style="height: 100%" :option="lineOption" />
+          <v-chart ref="lineRef2" style="height: 100%" :option="lineOption1" />
         </el-card>
       </el-col>
     </el-row>
@@ -103,21 +109,14 @@
 
 <script>
   import {
-    queryHomePage,
-    queryFactory,
-    queryTeam,
-    queryProductionLine,
-    queryProportionDefectiveTypes
+    queryFactoryYx,
+    inspectionFrequencyYx,
+    queryPassrateYx,
+    queryFrequencyAnnualYx,
+    queryFrequencyMonthlyYx
   } from '@/api/main';
   import dictMixins from '@/mixins/dictMixins';
-  import {
-    userList,
-    unacceptedProduct,
-    lineOption,
-    preOption,
-    barOption,
-    preOptions
-  } from './data';
+  import { barOption, preOptions, lineOption, preOptions1 } from './data';
   import { use } from 'echarts/core';
   import { CanvasRenderer } from 'echarts/renderers';
   import { BarChart, PieChart, LineChart } from 'echarts/charts';
@@ -126,10 +125,9 @@
     TooltipComponent,
     LegendComponent
   } from 'echarts/components';
-  import EleChart from 'ele-admin/packages/ele-chart';
-
   import VChart from 'vue-echarts';
   import { echartsMixin } from '@/utils/echarts-mixin';
+  import dayjs from 'dayjs';
   // 按需加载 echarts
   use([
     CanvasRenderer,
@@ -143,7 +141,7 @@
   export default {
     mixins: [
       dictMixins,
-      echartsMixin(['pieRef1', 'pieRef2', 'pieRef3', 'pieRef4', 'lineRef'])
+      echartsMixin(['option1', 'pieRef2', 'lineRef1', 'lineRef2', 'pieRef1'])
     ],
     components: { VChart },
     data() {
@@ -151,15 +149,18 @@
         factoryTimeType: '3',
         teamTimeType: '3',
         lineTimeType: '3',
-
+        value1: dayjs().format('YYYY-MM'),
+        value4: dayjs().format('YYYY-MM'),
+        value2: dayjs().format('YYYY'),
+        value3: dayjs().format('YYYY'),
         // 图表配置
+        preOptions1: {},
+        preOptions2: {},
         teamQualifiedOption: {},
         factoryQualifiedOption: {},
-        lineQualifiedOption: {},
-        preOption: {},
-        barOption: {},
+        factoryQualifiedOption1: {},
         lineOption: {},
-        preOptions: {},
+        lineOption1: {},
 
         form: {
           finishTime: '',
@@ -167,138 +168,99 @@
         }
       };
     },
-    computed: {
-      userList: () => userList,
-      unacceptedProduct: () => unacceptedProduct
-    },
 
     mounted() {
-      this.queryHomePage();
       this.queryFactory();
-      this.queryTeam();
+      this.queryFactory1();
       this.queryProductionLine();
       this.proportion();
+      this.queryProductionLine1();
 
       setTimeout(() => {
-        this.$refs.pieRef1.resize();
+        this.$refs.option1.resize();
         this.$refs.pieRef2.resize();
-        this.$refs.pieRef3.resize();
-        this.$refs.pieRef4.resize();
-        this.$refs.lineRef.resize();
+        this.$refs.lineRef1.resize();
+        this.$refs.lineRef2.resize();
+        this.$refs.pieRef1.resize();
       }, 300);
     },
     methods: {
-      timeTypeChange() {
-        this.queryHomePage();
-      },
-
-      handleFactoryTimeChange() {
-        this.queryFactory();
+      handleValue1Change() {
+        // value1 改变时请求质检次数相关数据
+        this.proportion();
       },
 
-      handleTeamTimeChange() {
-        this.queryTeam();
+      handleValue2Change() {
+        // value2 改变时请求合格率趋势图
+        this.queryProductionLine();
       },
 
-      handleLineTimeChange() {
-        this.queryProductionLine();
+      handleValue3Change() {
+        // value3 改变时请求时率趋势图
+        this.queryProductionLine1();
       },
 
       async queryFactory() {
-        const data = await queryFactory({
-          timeType: this.factoryTimeType
-        });
-        this.factoryQualifiedOption = preOption(
+        const data = await queryFactoryYx();
+        this.teamQualifiedOption = barOption(
           data.map((item) => {
             return { value: item.qualificationRate, name: item.factoryName };
-          }),
-          '70%',
-          false,
-          'inside'
+          })
         );
       },
-
-      async proportion() {
-        const res = await queryProportionDefectiveTypes();
+      async queryFactory1() {
+        const res = await queryFrequencyMonthlyYx({ date: this.value4 });
         let list = res.map((el) => {
           return {
-            value: el.unQualifiedNumber,
-            name: el.categoryLevelClassName
+            value: el.data,
+            name: el.name
           };
         });
-        this.preOptions = preOptions(list);
+        this.preOptions2 = preOptions1(list);
       },
-
-      async queryTeam() {
-        console.log(this.teamTimeType);
-        const data = await queryTeam({
-          timeType: this.teamTimeType
+      async proportion() {
+        const res = await inspectionFrequencyYx({ date: this.value1 });
+        let list = res.map((el) => {
+          return {
+            value: el.value,
+            name: el.name
+          };
         });
-        this.teamQualifiedOption = barOption(
-          data.map((item) => {
-            return { value: item.qualificationRate, name: item.teamName };
-          })
-        );
+        this.preOptions1 = preOptions(list);
       },
 
       async queryProductionLine() {
-        const data = await queryProductionLine({
-          timeType: this.lineTimeType
+        const data = await queryPassrateYx({
+          date: this.value2
         });
-        this.lineQualifiedOption = barOption(
+        console.log(data, 'data');
+        this.lineOption = lineOption(
           data.map((item) => {
             return {
-              value: item.qualificationRate,
-              name: item.productionLineName
+              name: item.name,
+              data: item.data,
+              type: 'line',
+              smooth: true // 开启平滑曲线
             };
           }),
-          {
-            normal: {
-              barBorderRadius: 30,
-              color: EleChart.graphic.LinearGradient(0, 0, 0, 1, [
-                {
-                  offset: 0,
-                  color: '#00feff'
-                },
-                {
-                  offset: 0.5,
-                  color: '#027eff'
-                },
-                {
-                  offset: 1,
-                  color: '#0286ff'
-                }
-              ])
-            }
-          }
+          1
         );
       },
-
-      async queryHomePage() {
-        const data = await queryHomePage(this.form);
-        let values = [];
-        for (let key in data) {
-          values.push(data[key]);
-        }
-        this.lineOption = lineOption(
-          values.map((item) => {
+      async queryProductionLine1() {
+        const data = await queryFrequencyAnnualYx({
+          date: this.value3
+        });
+        this.lineOption1 = lineOption(
+          data.map((item) => {
             return {
-              name: item.productName,
-              data: item.listQualificationRate,
+              name: item.name,
+              data: item.data,
               type: 'line',
               smooth: true // 开启平滑曲线
             };
           }),
-          this.form.timeType
+          1
         );
-      },
-
-      datasource({ page, where, limit }) {
-        return getList({
-          ...where,
-          pageNum: page,
-          size: limit
-        });
       }
     }
   };

+ 2 - 2
src/views/inspectionWork/components/sampleListDialog.vue

@@ -399,10 +399,10 @@
       //宇信特殊处理
       newHandleInput(arr, index) {
         let num = arr.find(
-          (item) => item.inspectionName == '水电导率'
+          (item) => item.inspectionName == '水电导率'
         )?.qualityResultContent;
         let num1 = arr.find(
-          (item) => item.inspectionName == '炉水电导率'
+          (item) => item.inspectionName =='给水电导率'
         )?.qualityResultContent;
         console.log(num, num1);