Ver código fonte

样品大屏修改

cyy 3 anos atrás
pai
commit
a8985cafe7

+ 39 - 148
src/views/demo/yangPin/yangPinShuJu/EntrustNumber.vue

@@ -25,6 +25,12 @@ import echarts from 'echarts'
 
 
 import { resolve } from 'path';
 import { resolve } from 'path';
 export default {
 export default {
+  props:{
+    NowTime1:{
+      type:String,
+      default:""
+    }
+  },
   data(){ 
   data(){ 
     return{
     return{
       NowTime: '',
       NowTime: '',
@@ -35,6 +41,10 @@ export default {
       day:0,
       day:0,
       //填充数量的数组
       //填充数量的数组
       filledNum:[],
       filledNum:[],
+      yearA:'',
+      monthA:'',
+      monthB:''
+
 
 
       // //已收到要填充的数组
       // //已收到要填充的数组
       // ReceivedNum:[],
       // ReceivedNum:[],
@@ -51,23 +61,34 @@ export default {
       
       
     }
     }
   },
   },
+  watch: {  
+    NowTime1(newValue, oldValue) {  
+      this.days.length=0
+      this.getNowTime()
+    }  
+  },
   mounted() {
   mounted() {
     this.getNowTime()
     this.getNowTime()
   },
   },
   methods:{
   methods:{
     //样品相关数据时间控件 :页面进来显示当前时间
     //样品相关数据时间控件 :页面进来显示当前时间
     getNowTime(){
     getNowTime(){
-      const nowDate = new Date();
-      const date = {
-        year: nowDate.getFullYear(),
-        month: nowDate.getMonth() + 1,
-      }
-      this.NowTime = date.year + '-' + date.month
+      // const nowDate = new Date();
+      // const date = {
+      //   year: nowDate.getFullYear(),
+      //   month: nowDate.getMonth() + 1,
+      // }
+      this.yearA = ''
+      this.monthA = ''
+      this.yearA = this.NowTime1.split('-')[0]
+      this.monthA = this.NowTime1.split('-')[1]
+      this.monthB = Number(this.NowTime1.split('-')[1])>=10? this.monthA+"":"0"+this.monthA
+      this.NowTime = this.yearA + '-' + this.monthB
       // console.log('页面第一次进来显示时间',date.year,date.month)
       // console.log('页面第一次进来显示时间',date.year,date.month)
       //进来获取当前时间 之后获取当前月份天数 传给
       //进来获取当前时间 之后获取当前月份天数 传给
       // console.log('页面显示的时间',this.NowTime)  //2022-11
       // console.log('页面显示的时间',this.NowTime)  //2022-11
       //把页面第一次进来的 当前年度月份 传给该方法处理 得到day及days
       //把页面第一次进来的 当前年度月份 传给该方法处理 得到day及days
-      this.getDaysInMonth(date.year,date.month)
+      this.getDaysInMonth(this.yearA,this.monthA)
       
       
     },
     },
    
    
@@ -106,9 +127,9 @@ export default {
       // console.log('返回的全部数据 传日期到sql查询',this.NowTime,dayNum)
       // console.log('返回的全部数据 传日期到sql查询',this.NowTime,dayNum)
       //SELECT shou_yang_ri_qi_ FROM t_mjypdjb WHERE yan_shou_zhuang_t = '残缺'  AND shou_yang_ri_qi_ LIKE '2022-11%'   //不合格
       //SELECT shou_yang_ri_qi_ FROM t_mjypdjb WHERE yan_shou_zhuang_t = '残缺'  AND shou_yang_ri_qi_ LIKE '2022-11%'   //不合格
       //SELECT liu_yang_ri_qi_,liu_yang_shu_lian FROM (SELECT * FROM t_mjypdjb WHERE  liu_yang_ri_qi_ ='' ) a WHERE   a.shi_fou_liu_yang_ != '否' AND shou_yang_ri_qi_ LIKE '2022-11%'  //留样
       //SELECT liu_yang_ri_qi_,liu_yang_shu_lian FROM (SELECT * FROM t_mjypdjb WHERE  liu_yang_ri_qi_ ='' ) a WHERE   a.shi_fou_liu_yang_ != '否' AND shou_yang_ri_qi_ LIKE '2022-11%'  //留样
-      let sql1 = "select shou_yang_ri_qi_,shou_yang_shu_lia FROM t_mjypdjb WHERE shou_yang_ri_qi_ LIKE '"+this.NowTime+'%'+"'"
-      let sql2 ="select shou_yang_ri_qi_,shou_yang_shu_lia FROM t_mjypdjb WHERE yan_shou_zhuang_t = '残缺'  AND shou_yang_ri_qi_ LIKE '"+this.NowTime+'%'+"'"
-      let sql3 = "select liu_yang_ri_qi_,liu_yang_shu_lian FROM (SELECT * FROM t_mjypdjb WHERE  liu_yang_ri_qi_ ='' ) a WHERE   a.shi_fou_liu_yang_ != '否' AND shou_yang_ri_qi_ LIKE '"+this.NowTime+'%'+"'"
+      let sql1 = "select shou_yang_ri_qi_,yang_pin_shu_lian FROM t_lhypdjb WHERE YEAR(shou_yang_ri_qi_)='"+this.yearA+"' and MONTH(shou_yang_ri_qi_) = '"+this.monthA+"'"
+      let sql2 ="select shou_yang_ri_qi_,yang_pin_shu_lian FROM t_lhypdjb WHERE yan_shou_jie_guo_ = '残缺'  AND shou_yang_ri_qi_ LIKE '"+this.NowTime+'%'+"'"
+      let sql3 = "select liu_yang_ri_qi_,liu_yang_shu_lian FROM (SELECT * FROM t_lhypdjb ) a WHERE   a.shi_fou_liu_yang_ != '否' AND shou_yang_ri_qi_ LIKE '"+this.NowTime+'%'+"'"
       Promise.all([
       Promise.all([
         curdPost('sql', sql1),
         curdPost('sql', sql1),
         curdPost('sql', sql2),
         curdPost('sql', sql2),
@@ -118,7 +139,7 @@ export default {
         let data2 = res2.variables.data
         let data2 = res2.variables.data
         let data3 = res3.variables.data
         let data3 = res3.variables.data
         // console.log('返回的全部数据',data1,data2)
         // console.log('返回的全部数据',data1,data2)
-        // console.log('返回的全部数据',data1,data2,data3)
+        console.log('返回的全部数据',data1,data2,data3)
         const receivedData = this.dealingData(data1,dayNum)
         const receivedData = this.dealingData(data1,dayNum)
         const unqualifiedData = this.dealingData(data2,dayNum)
         const unqualifiedData = this.dealingData(data2,dayNum)
         const retentionData = this.dealingRetentionData(data3,dayNum)
         const retentionData = this.dealingRetentionData(data3,dayNum)
@@ -131,12 +152,13 @@ export default {
     },
     },
     //处理sql查询出来的数据
     //处理sql查询出来的数据
     dealingData(data,dayNum){
     dealingData(data,dayNum){
+      console.log(data,'data1')
       let newArray = data.reduce((total, cur, index) => {
       let newArray = data.reduce((total, cur, index) => {
           let hasValue = total.findIndex(current => {
           let hasValue = total.findIndex(current => {
             return current.shou_yang_ri_qi_ === cur.shou_yang_ri_qi_;
             return current.shou_yang_ri_qi_ === cur.shou_yang_ri_qi_;
           });
           });
           hasValue === -1 && total.push(cur);
           hasValue === -1 && total.push(cur);
-          hasValue !== -1 && (total[hasValue].shou_yang_shu_lia = total[hasValue].shou_yang_shu_lia + cur.shou_yang_shu_lia);
+          hasValue !== -1 && (total[hasValue].yang_pin_shu_lian = Number(total[hasValue].yang_pin_shu_lian) + Number(cur.yang_pin_shu_lian));
           return total;
           return total;
       }, []);
       }, []);
       //console.log('日期相同数量相加 处理结果',newArray);
       //console.log('日期相同数量相加 处理结果',newArray);
@@ -145,7 +167,7 @@ export default {
       //遍历拿到的数组,截取出月份对应的 // 2022-11-01
       //遍历拿到的数组,截取出月份对应的 // 2022-11-01
       newArray.forEach(item =>{
       newArray.forEach(item =>{
         let key = item.shou_yang_ri_qi_.slice(8,10) < 10 ?item.shou_yang_ri_qi_.slice(9,10) :item.shou_yang_ri_qi_.slice(8,10)
         let key = item.shou_yang_ri_qi_.slice(8,10) < 10 ?item.shou_yang_ri_qi_.slice(9,10) :item.shou_yang_ri_qi_.slice(8,10)
-        let value =parseInt(item.shou_yang_shu_lia)
+        let value =Number(item.yang_pin_shu_lian)
         this.filledNum.splice(key - 1,1,value)
         this.filledNum.splice(key - 1,1,value)
       })
       })
       //返回处理好的数量数组
       //返回处理好的数量数组
@@ -158,7 +180,7 @@ export default {
             return current.liu_yang_ri_qi_ === cur.liu_yang_ri_qi_;
             return current.liu_yang_ri_qi_ === cur.liu_yang_ri_qi_;
           });
           });
           hasValue === -1 && total.push(cur);
           hasValue === -1 && total.push(cur);
-          hasValue !== -1 && (total[hasValue].liu_yang_ri_qi_ = total[hasValue].liu_yang_ri_qi_ + cur.liu_yang_ri_qi_);
+          hasValue !== -1 && (total[hasValue].liu_yang_shu_lian = Number(total[hasValue].liu_yang_shu_lian) + Number(cur.liu_yang_shu_lian));
           return total;
           return total;
       }, []);
       }, []);
         //console.log('日期相同数量相加 处理结果',newArray);
         //console.log('日期相同数量相加 处理结果',newArray);
@@ -167,149 +189,17 @@ export default {
         //遍历拿到的数组,截取出月份对应的 // 2022-11-01
         //遍历拿到的数组,截取出月份对应的 // 2022-11-01
         newArray.forEach(item =>{
         newArray.forEach(item =>{
           let key = item.liu_yang_ri_qi_.slice(8,10) < 10 ?item.liu_yang_ri_qi_.slice(9,10) :item.liu_yang_ri_qi_.slice(8,10)
           let key = item.liu_yang_ri_qi_.slice(8,10) < 10 ?item.liu_yang_ri_qi_.slice(9,10) :item.liu_yang_ri_qi_.slice(8,10)
-          let value =parseInt(item.liu_yang_shu_lian)
+          let value =Number(item.liu_yang_shu_lian)
           this.filledNum.splice(key - 1,1,value)
           this.filledNum.splice(key - 1,1,value)
         })
         })
         //返回处理好的数量数组
         //返回处理好的数量数组
         return this.filledNum;
         return this.filledNum;
     },
     },
-    //1.已收到:样品登记表有数据
-    getReceivedData(dayNum){
-      // console.log('已收样品传日期到sql查询',this.NowTime)   //2022-11
-      // console.log('getReceivedData function ',dayNum)
-      //let sql2 = "select shou_yang_ri_qi_,shou_yang_shu_lia FROM t_mjypdjb"
-      let sql2 = "select shou_yang_ri_qi_,shou_yang_shu_lia FROM t_mjypdjb WHERE shou_yang_ri_qi_ LIKE '"+this.NowTime+'%'+"'" 
-        curdPost('sql',sql2).then(response => { 
-        let data = response.variables.data
-        // console.log('已收',data,data.length)
-
-        let newArray = data.reduce((total, cur, index) => {
-          let hasValue = total.findIndex(current => {
-            return current.shou_yang_ri_qi_ === cur.shou_yang_ri_qi_;
-          });
-          hasValue === -1 && total.push(cur);
-          hasValue !== -1 && (total[hasValue].shou_yang_shu_lia = total[hasValue].shou_yang_shu_lia + cur.shou_yang_shu_lia);
-          return total;
-        }, []);
-        //console.log('日期数量11111111',newArray);
-        //创建一个长度为当前月份天数的数组
-        this.ReceivedNum = Array(dayNum)
-        this.ReceivedNum = this.ReceivedNum.fill(0)
-        //console.log('创建对应月份的数组',this.ReceivedNum)
-        //遍历拿到的数组,截取出月份对应的 // 2022-11-01
-        newArray.forEach(item =>{
-          let key = item.shou_yang_ri_qi_.slice(8,10) < 10 ?item.shou_yang_ri_qi_.slice(9,10) :item.shou_yang_ri_qi_.slice(8,10)
-          let value =parseInt(item.shou_yang_shu_lia)
-          this.ReceivedNum.splice(key - 1,1,value)
-        })
-        //console.log('getReceivedData 处理好的数据',this.ReceivedNum)
-        //拿到月份数组和y轴数量数组
-        this.entrustNumberInit(this.days,this.ReceivedNum)
-      })
-    },
-  
-    //2.已经收到不合格 xx
-    getUnqualifiedData(dayNum){
-      //let sql3 = "select shou_yang_ri_qi_,shou_yang_shu_lia from t_mjypdjb where yan_shou_zhuang_t = '残缺'"
-      let sql3 ="select shou_yang_ri_qi_,shou_yang_shu_lia FROM t_mjypdjb WHERE yan_shou_zhuang_t = '残缺'  AND shou_yang_ri_qi_ LIKE '"+this.NowTime+'%'+"'"
-        curdPost('sql',sql3).then(response => { 
-        let data = response.variables.data
-        // console.log('不合格样品数据',data )
-        let newArray = data.reduce((total, cur, index) => {
-          let hasValue = total.findIndex(current => {
-            return current.shou_yang_ri_qi_ === cur.shou_yang_ri_qi_;
-          });
-          hasValue === -1 && total.push(cur);
-          hasValue !== -1 && (total[hasValue].shou_yang_shu_lia = total[hasValue].shou_yang_shu_lia + cur.shou_yang_shu_lia);
-          return total;
-        }, []);
-        //console.log('日期数量11111111',newArray);
-        //创建一个长度为当前月份天数的数组
-        //console.log("getUnqualifiedData function before this newArrayNew is ", this.newArrayNum);
-        this.UnqualifiedNum = Array(dayNum)
-        this.UnqualifiedNum = this.UnqualifiedNum.fill(0)
-        //console.log('创建对应月份的数组',this.UnqualifiedNum)
-        //遍历拿到的数组,截取出月份对应的 // 2022-11-01
-        newArray.forEach(item =>{
-          let key = item.shou_yang_ri_qi_.slice(8,10) < 10 ?item.shou_yang_ri_qi_.slice(9,10) :item.shou_yang_ri_qi_.slice(8,10)
-          let value =parseInt(item.shou_yang_shu_lia)
-          this.UnqualifiedNum.splice(key - 1,1,value)
-        })
-        // console.log('getUnqualifiedData 处理好的数据',this.UnqualifiedNum)
-        return this.UnqualifiedNum;
-        // 到这里说明上面的数据已经处理好了
-        // 可以写return语句将处理好的数据返回
-        //拿到月份数组和y轴数量数组
-        this.entrustNumberInit(this.days,this.UnqualifiedNum)
-        
-        })
-    },
-      
-    //3.留样样品数据xx
-    getRetentionData(dayNum){
-      let sql4 = "select  shou_yang_ri_qi_,shou_yang_shu_lia from (select * from t_mjypdjb where  liu_yang_ri_qi_ ='' ) a where   a.shi_fou_liu_yang_ != '否'"
-        curdPost('sql',sql4).then(response => { 
-        let data = response.variables.data
-        // console.log('已收',data)
-        let newArray = data.reduce((total, cur, index) => {
-          let hasValue = total.findIndex(current => {
-            return current.shou_yang_ri_qi_ === cur.shou_yang_ri_qi_;
-          });
-          hasValue === -1 && total.push(cur);
-          hasValue !== -1 && (total[hasValue].shou_yang_shu_lia = total[hasValue].shou_yang_shu_lia + cur.shou_yang_shu_lia);
-          return total;
-        }, []);
-        //console.log('日期数量11111111',newArray);
-        //创建一个长度为当前月份天数的数组
-        this.RetentionNum = Array(dayNum)
-        this.RetentionNum = this.RetentionNum.fill(0)
-        //console.log('创建对应月份的数组',this.RetentionNum)
-        //遍历拿到的数组,截取出月份对应的 // 2022-11-01
-        newArray.forEach(item =>{
-          let key = item.shou_yang_ri_qi_.slice(8,10) < 10 ?item.shou_yang_ri_qi_.slice(9,10) :item.shou_yang_ri_qi_.slice(8,10)
-          let value =parseInt(item.shou_yang_shu_lia)
-          this.RetentionNum.splice(key - 1,1,value)
-        })
-        // console.log('getRetentionData 处理好的数据',this.RetentionNum)
-        return this.RetentionNum;
-        })
-
-    },
-    //不合格
-    getUnqualifiedData(dayNum){
-      let sql3 = "select * from t_mjypdjb where yan_shou_zhuang_t = '残缺'"
-        curdPost('sql',sql3).then(response => {
-        this.unqualifiedData = response.variables.data
-        let data = response.variables.data
-        let newArray = data.reduce((total, cur, index) => {
-          let hasValue = total.findIndex(current => {
-            return current.shou_yang_ri_qi_ === cur.shou_yang_ri_qi_;
-          });
-          hasValue === -1 && total.push(cur);
-          hasValue !== -1 && (total[hasValue].shou_yang_shu_lia = total[hasValue].shou_yang_shu_lia + cur.shou_yang_shu_lia);
-          return total;
-        }, []);
-        //console.log('日期数量11111111',newArray);
-        //创建一个长度为当前月份天数的数组
-        this.newArrayNum = Array(dayNum)
-        this.newArrayNum = this.newArrayNum.fill(0)
-        //console.log('创建对应月份的数组',this.newArrayNum)
-        //遍历拿到的数组,截取出月份对应的 // 2022-11-01
-        newArray.forEach(item =>{
-          let key = item.shou_yang_ri_qi_.slice(8,10) < 10 ?item.shou_yang_ri_qi_.slice(9,10) :item.shou_yang_ri_qi_.slice(8,10)
-          let value =parseInt(item.shou_yang_shu_lia)
-          this.newArrayNum.splice(key - 1,1,value)
-        })
-        //console.log('处理好的数据',this.newArrayNum)
-        //拿到月份数组和y轴数量数组
-        this.entrustNumberInit(this.days,this.newArrayNum)
-
-        })
-    },
   
   
     //委托样品图表
     //委托样品图表
     entrustNumberInit(dayArray,receivedData,unqualifiedData,retentionData){
     entrustNumberInit(dayArray,receivedData,unqualifiedData,retentionData){
       // console.log('拿到日期数组',dayArray)
       // console.log('拿到日期数组',dayArray)
+      console.log(receivedData,unqualifiedData,retentionData,'we12e12312312312')
       this.entrustNumber = echarts.init(this.$refs.Number_refs);
       this.entrustNumber = echarts.init(this.$refs.Number_refs);
       var entrustNumberOption = {
       var entrustNumberOption = {
           xAxis:{
           xAxis:{
@@ -458,6 +348,7 @@ export default {
       font-weight:600;
       font-weight:600;
     }
     }
     .chooseMonth{
     .chooseMonth{
+      display: none;
       width: 120px;
       width: 120px;
       line-height: 50px;
       line-height: 50px;
       margin-left: 10px;
       margin-left: 10px;

+ 24 - 10
src/views/demo/yangPin/yangPinShuJu/MonthlyNumber.vue

@@ -25,6 +25,12 @@
  import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
  import echarts from 'echarts'
  import echarts from 'echarts'
  export default {
  export default {
+  props:{
+    NowTime1:{
+      type:String,
+      default:""
+    }
+  },
   data(){ 
   data(){ 
     return{
     return{
       NowTime: '',
       NowTime: '',
@@ -34,8 +40,16 @@
       day:0,
       day:0,
       //填充数量的数组
       //填充数量的数组
       filledNum:[],
       filledNum:[],
+      yearA:'',
+      monthA:''
     }
     }
   },
   },
+  watch: {  
+    NowTime1(newValue, oldValue) {  
+      this.days.length=0
+      this.getNowTime()
+    }  
+  },
   created(){
   created(){
   },
   },
   mounted() {
   mounted() {
@@ -44,17 +58,16 @@
   methods:{
   methods:{
     //样品相关数据时间控件 :页面进来显示当前时间
     //样品相关数据时间控件 :页面进来显示当前时间
     getNowTime(){
     getNowTime(){
-      const nowDate = new Date();
-      const date = {
-        year: nowDate.getFullYear(),
-        month: nowDate.getMonth() + 1,
-      }
-      this.NowTime = date.year + '-' + date.month
+      this.yearA = ''
+      this.monthA = ''
+      this.yearA = this.NowTime1.split('-')[0]
+      this.monthA = Number(this.NowTime1.split('-')[1])>=10? this.monthA+"":"0"+this.monthA
+      this.NowTime = this.yearA + '-' + this.monthA
       // console.log('页面第一次进来显示时间',date.year,date.month)
       // console.log('页面第一次进来显示时间',date.year,date.month)
       //进来获取当前时间 之后获取当前月份天数 传给
       //进来获取当前时间 之后获取当前月份天数 传给
       // console.log('页面显示的时间',this.NowTime)  //2022-11
       // console.log('页面显示的时间',this.NowTime)  //2022-11
       //把页面第一次进来的 当前年度月份 传给该方法处理 得到day及days
       //把页面第一次进来的 当前年度月份 传给该方法处理 得到day及days
-      this.getDaysInMonth(date.year,date.month)
+      this.getDaysInMonth(this.yearA,this.monthA)
       
       
     },
     },
     //手动操作时间控件改变时间
     //手动操作时间控件改变时间
@@ -90,7 +103,7 @@
     //当一个样品的编号对应的多条检测项目数据的“jian_ce_zhaung_ta”为 已完成,就表示该样品被归到已检的样品中
     //当一个样品的编号对应的多条检测项目数据的“jian_ce_zhaung_ta”为 已完成,就表示该样品被归到已检的样品中
     //(这样的话一个样品有多项检测,意味着一个样品有多个检测日期)
     //(这样的话一个样品有多项检测,意味着一个样品有多个检测日期)
     getCheckSampleData(dayNum){
     getCheckSampleData(dayNum){
-      let sql1 = "select yang_pin_bian_hao,DATE_FORMAT(create_time_,'%Y-%m-%d') AS detectionTime FROM t_mjjcbg WHERE yang_pin_bian_hao != ''  AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
+      let sql1 = "select yang_pin_bian_hao,DATE_FORMAT(create_time_,'%Y-%m-%d') AS detectionTime FROM t_lhjcbgb WHERE yang_pin_bian_hao != ''  AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
       let sql2="select yang_pin_bian_hao,DATE_FORMAT(MIN(create_time_),'%Y-%m-%d') AS detectionTime FROM t_jchzb WHERE jian_ce_zhuang_ta != '已完成' AND yang_pin_bian_hao !=''  AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
       let sql2="select yang_pin_bian_hao,DATE_FORMAT(MIN(create_time_),'%Y-%m-%d') AS detectionTime FROM t_jchzb WHERE jian_ce_zhuang_ta != '已完成' AND yang_pin_bian_hao !=''  AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
       Promise.all([
       Promise.all([
         curdPost('sql', sql1),
         curdPost('sql', sql1),
@@ -98,7 +111,7 @@
       ]).then(([ res1, res2]) => {
       ]).then(([ res1, res2]) => {
         let data1 = res1.variables.data
         let data1 = res1.variables.data
         let data2 = res2.variables.data
         let data2 = res2.variables.data
-        // console.log('已检测样品',data1)
+         console.log('已检测样品',data1)
         const detection = this.dealingData(data1,dayNum)    //dealingData()方法处理返回的数据 this.filledNum;
         const detection = this.dealingData(data1,dayNum)    //dealingData()方法处理返回的数据 this.filledNum;
         const undetected = this.dealingData(data2,dayNum)
         const undetected = this.dealingData(data2,dayNum)
         this.entrustNumberInit(this.days,detection,undetected)
         this.entrustNumberInit(this.days,detection,undetected)
@@ -117,7 +130,7 @@
           find ? find.count++ : obj.push(CheckedArray);
           find ? find.count++ : obj.push(CheckedArray);
           return obj;
           return obj;
         }, []);
         }, []);
-        // console.log('12345678',result);
+         console.log('12345678',result);
         this.filledNum = Array(dayNum).fill(0)
         this.filledNum = Array(dayNum).fill(0)
         //遍历拿到的数组,截取出月份对应的 // 2022-11-01
         //遍历拿到的数组,截取出月份对应的 // 2022-11-01
         result.forEach(item =>{
         result.forEach(item =>{
@@ -262,6 +275,7 @@
       font-weight:600;
       font-weight:600;
     }
     }
     .chooseMonth{
     .chooseMonth{
+      display: none;
       width: 120px;
       width: 120px;
       line-height: 50px;
       line-height: 50px;
       margin-left: 10px;
       margin-left: 10px;

+ 30 - 7
src/views/demo/yangPin/yangPinShuJu/MonthlyStatus.vue

@@ -23,6 +23,12 @@
 import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
 import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
 import echarts from 'echarts'
 import echarts from 'echarts'
 export default {
 export default {
+  props:{
+    NowTime1:{
+      type:String,
+      default:""
+    }
+  },
   data(){
   data(){
     return{
     return{
       monthlyStatus:null,
       monthlyStatus:null,
@@ -32,18 +38,34 @@ export default {
   created(){
   created(){
     this.getNowTime()
     this.getNowTime()
   },
   },
+  watch: {  
+    NowTime1(newValue, oldValue) {
+      // this.days.length=0
+      this.getNowTime()
+    }  
+  },
   mounted(){
   mounted(){
     this.getCheckSampleData()
     this.getCheckSampleData()
   },
   },
   methods:{
   methods:{
     //页面进来显示当前时间
     //页面进来显示当前时间
     getNowTime(){
     getNowTime(){
-      const nowDate = new Date();
-      const date = {
-        year: nowDate.getFullYear(),
-        month: nowDate.getMonth() + 1,
-      }
-      this.NowTime = date.year + '-' + date.month
+      // const nowDate = new Date();
+      // const date = {
+      //   year: nowDate.getFullYear(),
+      //   month: nowDate.getMonth() + 1,
+      // }
+      this.yearA = ''
+      this.monthA = ''
+      this.yearA = this.NowTime1.split('-')[0]
+      this.monthA = Number(this.NowTime1.split('-')[1])>=10? this.monthA+"":"0"+this.monthA
+      this.NowTime = this.yearA + '-' + this.monthA
+      // console.log('页面第一次进来显示时间',date.year,date.month)
+      //进来获取当前时间 之后获取当前月份天数 传给
+      console.log('页面显示的时间',typeof(this.monthA),this.NowTime)  //2022-11
+      //把页面第一次进来的 当前年度月份 传给该方法处理 得到day及days
+      // this.getDaysInMonth(this.yearA,this.monthA)
+      this.getCheckSampleData()
     },
     },
     //用户操作改变时间
     //用户操作改变时间
     changeTime(e){
     changeTime(e){
@@ -55,7 +77,7 @@ export default {
     },
     },
     //查询函数
     //查询函数
     getCheckSampleData(){
     getCheckSampleData(){
-      let sql1 = "select yang_pin_bian_hao,DATE_FORMAT(create_time_,'%Y-%m-%d') AS detectionTime FROM t_mjjcbg WHERE yang_pin_bian_hao != ''  AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
+      let sql1 = "select yang_pin_bian_hao,DATE_FORMAT(create_time_,'%Y-%m-%d') AS detectionTime FROM t_lhjcbgb WHERE yang_pin_bian_hao != ''  AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
       let sql2="select yang_pin_bian_hao,DATE_FORMAT(MIN(create_time_),'%Y-%m-%d') AS detectionTime FROM t_jchzb WHERE jian_ce_zhuang_ta != '已完成' AND yang_pin_bian_hao !=''  AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
       let sql2="select yang_pin_bian_hao,DATE_FORMAT(MIN(create_time_),'%Y-%m-%d') AS detectionTime FROM t_jchzb WHERE jian_ce_zhuang_ta != '已完成' AND yang_pin_bian_hao !=''  AND create_time_ LIKE '"+this.NowTime+'%'+"' GROUP BY yang_pin_bian_hao"
       Promise.all([
       Promise.all([
         curdPost('sql', sql1),
         curdPost('sql', sql1),
@@ -194,6 +216,7 @@ export default {
       font-weight:600;
       font-weight:600;
     }
     }
     .chooseMonth{
     .chooseMonth{
+      display: none;
       width: 120px;
       width: 120px;
       line-height: 50px;
       line-height: 50px;
       margin-left: 10px;
       margin-left: 10px;

+ 68 - 29
src/views/demo/yangPin/yangPinShuJu/headerContent.vue

@@ -38,6 +38,12 @@
 <script>
 <script>
 import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
 import curdPost from '@/business/platform/form/utils/custom/joinCURD.js'
 export default {
 export default {
+  props:{
+    NowTime1:{
+      type:String,
+      default:""
+    }
+  },
   data(){
   data(){
     return{
     return{
       timer:null,
       timer:null,
@@ -103,68 +109,101 @@ export default {
     },
     },
     //委托样品总数:样品表所有
     //委托样品总数:样品表所有
     getEntrustedTotalData(){
     getEntrustedTotalData(){
-      let sql1 = "select count(id_) as sum from t_lhypb" 
+      let sql1 = "select SUM(yang_pin_zong_shu) as sum from t_lhypb where YEAR(create_time_) = YEAR('"+this.NowTime1+"')" 
       curdPost('sql',sql1).then(response => { 
       curdPost('sql',sql1).then(response => { 
-      let data = response.variables.data
-      this.EntrustedTotal = data[0].sum
+        let data = response.variables.data
+        if(data[0]===null){
+          this.EntrustedTotal = 0
+        }else(
+          this.EntrustedTotal = data[0].sum
+        )
+        // this.EntrustedTotal = data[0].sum
       })
       })
       
       
     },
     },
     //待收样数量:已委托,未收到
     //待收样数量:已委托,未收到
     getNotReceivedData(){
     getNotReceivedData(){
-      let sql2= "select count(id_) as sum from  t_lhypb WHERE parent_id_ in(select id_ from t_lhwtsqb where wei_tuo_zhuang_ta = '待样品接收')" 
+      let sql2= "select SUM(yang_pin_zong_shu) as sum from  t_lhypb WHERE YEAR(song_jian_shi_jia)= YEAR('"+this.NowTime1+"') and parent_id_ in(select id_ from t_lhwtsqb where wei_tuo_zhuang_ta = '待样品接收')" 
       curdPost('sql',sql2).then(response => { 
       curdPost('sql',sql2).then(response => { 
-      let data = response.variables.data
-      this.NotReceiveNumber = data[0].sum
+        let data = response.variables.data
+        if(data[0]===null){
+          this.NotReceiveNumber = 0
+        }else(
+          this.NotReceiveNumber = data[0].sum
+        )
+        // this.NotReceiveNumber = data[0].sum
+        console.log(data,this.NowTime1,'dssadsdaad1221')
 
 
-    })
+      })
   },
   },
      //已经收样
      //已经收样
      getReceivedData(){
      getReceivedData(){
-      let sql3= "select count(id_) as sum from t_lhypdjb" 
+      let sql3= "select SUM(yang_pin_zong_shu) as sum from t_lhypb where jie_yang_zhuang_t='已接收' and YEAR(create_time_) = YEAR('"+this.NowTime1+"')" 
       curdPost('sql',sql3).then(response => { 
       curdPost('sql',sql3).then(response => { 
-      let data = response.variables.data
-      this.ReceiveNumber = data[0].sum
-    })
+        let data = response.variables.data
+        if(data[0]===null){
+          this.ReceiveNumber = 0
+        }else(
+          this.ReceiveNumber = data[0].sum
+        )
+      })
 
 
      },
      },
      //待检样品数量
      //待检样品数量
      getStagingNumberData(){
      getStagingNumberData(){
       // let sql6 = "select * from t_mjypdjb"
       // let sql6 = "select * from t_mjypdjb"
-      let sql6= "select count(id_) as sum from t_lhypdjb where liu_zhuan_zhuang_ = '待检' " 
+      let sql6= "select SUM(yang_pin_shu_lian) as sum from t_lhypdjb where liu_zhuan_zhuang_ = '待检' and YEAR(create_time_) = YEAR('"+this.NowTime1+"')" 
       curdPost('sql',sql6).then(response => { 
       curdPost('sql',sql6).then(response => { 
-      let data = response.variables.data
-      this.StagingNumber =data[0].sum
-      // console.log("样品登记表数据777",this.StagingNumber)
-
-    })
+        let data = response.variables.data
+        if(data[0]===null){
+          this.StagingNumber = 0
+        }else(
+          this.StagingNumber = data[0].sum
+        )
+        // this.StagingNumber =data[0].sum
+      })
       },
       },
      //不合格样品数量
      //不合格样品数量
      getUnqualifiedData(){
      getUnqualifiedData(){
-      let sql4= "select count(id_) as sum from t_lhypdjb where yan_shou_jie_guo_ = '残缺'" 
+      let sql4= "select SUM(yang_pin_shu_lian) as sum from t_lhypdjb where yan_shou_jie_guo_ = '残缺' and YEAR(create_time_) = YEAR('"+this.NowTime1+"')" 
       curdPost('sql',sql4).then(response => { 
       curdPost('sql',sql4).then(response => { 
-      let data = response.variables.data
-      this.UnqualifiedNumber =data[0].sum
+        let data = response.variables.data
+        if(data[0]===null){
+          this.UnqualifiedNumber = 0
+        }else(
+          this.UnqualifiedNumber = data[0].sum
+        )
+        // this.UnqualifiedNumber =data[0].sum
 
 
-    })
+      })
      },
      },
      //留样样品数量
      //留样样品数量
      getStayData(){
      getStayData(){
-      let sql5= "select  * from (select * from t_lhypdjb where  liu_yang_ri_qi_ ='' ) a where   a.shi_fou_liu_yang_ != '否'" 
+      let sql5= "select SUM(yang_pin_shu_lian) as sum from t_lhypdjb where shi_fou_liu_yang_!= '否' and YEAR(create_time_) = YEAR('"+this.NowTime1+"')" 
       curdPost('sql',sql5).then(response => { 
       curdPost('sql',sql5).then(response => { 
-      let data = response.variables.data
-      this.RetentionNumber = data.length 
+        let data = response.variables.data
+        if(data[0]===null){
+          this.RetentionNumber = 0
+        }else(
+          this.RetentionNumber = data[0].sum
+        )
+        // this.RetentionNumber = data[0].sum
 
 
-    })
+      })
      },
      },
      //样品完成检测数量
      //样品完成检测数量
      getSuccessData(){
      getSuccessData(){
-      let sql6= "select COUNT(t_lhypdjb.id_) as num from t_lhypdjb LEFT JOIN t_lhjcbgb on t_lhypdjb.yang_ben_bian_hao = t_lhjcbgb.yang_pin_bian_hao where t_lhjcbgb.zhuang_tai_ = '待发放'" 
+      let sql6= "select SUM(t_lhypdjb.yang_pin_shu_lian) as num from t_lhypdjb LEFT JOIN t_lhjcbgb on t_lhypdjb.yang_ben_bian_hao = t_lhjcbgb.yang_pin_bian_hao where t_lhjcbgb.zhuang_tai_ = '待发放' and YEAR(t_lhypdjb.create_time_) = YEAR('"+this.NowTime1+"')" 
       curdPost('sql',sql6).then(response => { 
       curdPost('sql',sql6).then(response => { 
-      let data = response.variables.data
-      this.SuccessNumber = data[0].num
+        let data = response.variables.data
+        if(data[0]===null){
+          this.SuccessNumber = 0
+        }else(
+          this.SuccessNumber = data[0].num
+        )
+        // this.SuccessNumber = data[0].num
 
 
-    })
+      })
      }
      }
 
 
   },
   },

+ 74 - 11
src/views/demo/yangPin/yangPinShuJu/index.vue

@@ -6,7 +6,27 @@
         <div class="headerContent">
         <div class="headerContent">
            <!-- 标题装饰组件 -->
            <!-- 标题装饰组件 -->
           <header-decoration :titleName="outputData.headerName"/> 
           <header-decoration :titleName="outputData.headerName"/> 
+          <div 
+            class="goBackButton" 
+            style="width: 12%;
+            height:2.825rem;
+            line-height: 2.825rem;
+            text-align:center;
+            position: absolute;
+            left: 20%;
+            top:3.8%;" >
+            <el-date-picker
+              class="chooseMonth"
+              v-model="NowTime1"
+              type="month"
+              @change="changeTime1"
+              format="yyyy-MM" 
+              value-format="yyyy-MM"
+              placeholder="请选择时间">
+            </el-date-picker>
+          </div>
           <!-- 返回按钮 -->
           <!-- 返回按钮 -->
+
           <div 
           <div 
             class="goBackButton" 
             class="goBackButton" 
             @click.prevent="goBack()" 
             @click.prevent="goBack()" 
@@ -15,7 +35,7 @@
             line-height: 2.825rem;
             line-height: 2.825rem;
             text-align:center;
             text-align:center;
             position: absolute;
             position: absolute;
-            left: 20%;
+            right: 3%;
             top:4%;" >
             top:4%;" >
             <dv-border-box-8>返回</dv-border-box-8>
             <dv-border-box-8>返回</dv-border-box-8>
           </div>
           </div>
@@ -28,14 +48,14 @@
             line-height: 2.825rem;
             line-height: 2.825rem;
             text-align:center;
             text-align:center;
             position: absolute;
             position: absolute;
-            left: 70%;
+            left: 63%;
             top:4%;
             top:4%;
             color: #FFFFFF;">
             color: #FFFFFF;">
               <dv-border-box-8 >上一次更新时间:{{this.sendTime}}</dv-border-box-8>
               <dv-border-box-8 >上一次更新时间:{{this.sendTime}}</dv-border-box-8>
           </div>
           </div>
           <!-- 样品头部数据总览 -->
           <!-- 样品头部数据总览 -->
           <div class="overView">
           <div class="overView">
-            <headerContent  @getUpdateTime="getTime"></headerContent>
+            <headerContent  @getUpdateTime="getTime" :NowTime1="NowTime1+'-01'"></headerContent>
             <dv-decoration-10 style="width:100%;height:5px;" />
             <dv-decoration-10 style="width:100%;height:5px;" />
           </div> 
           </div> 
 
 
@@ -45,13 +65,13 @@
         <!-- 主体内容(图表部分) -->
         <!-- 主体内容(图表部分) -->
         <div class="mainContent">
         <div class="mainContent">
           <div class="entrust">
           <div class="entrust">
-            <div class="Number" ref="Number_refs"><entrustNumber/> </div>
+            <div class="Number" ref="Number_refs"><entrustNumber :NowTime1="NowTime1"/> </div>
             <!-- <div class="Type" ><entrustType/></div> -->
             <!-- <div class="Type" ><entrustType/></div> -->
           </div>
           </div>
           <div class="detection">
           <div class="detection">
-            <div class="monthlyS" ref="MonthlyStatus_refs"><monthlyStatus/></div>
-            <div class="monthlyN" ref="MonthlyNumber_refs"><monthlyNumber/></div>
+            <div class="monthlyS" ref="MonthlyStatus_refs"><monthlyStatus  :NowTime1="NowTime1"/></div>
             <div class="annualS" ref="AnnualStatus_refs"><annualStatus/></div>
             <div class="annualS" ref="AnnualStatus_refs"><annualStatus/></div>
+            <div class="monthlyN" ref="MonthlyNumber_refs"><monthlyNumber  :NowTime1="NowTime1"/></div>
           </div>
           </div>
         </div>
         </div>
         
         
@@ -92,13 +112,14 @@ export default {
       sendTime:'',
       sendTime:'',
       outputData:{
       outputData:{
         headerName:"样品管理看板"
         headerName:"样品管理看板"
-      }
-
+      },
+      NowTime1:'',
+      value1:[]
     }
     }
     
     
   },
   },
-  mounted(){
-    // this.getTime()
+  mounted() {
+    this.getNowTime()
   },
   },
   created() {
   created() {
     //时间
     //时间
@@ -123,7 +144,49 @@ export default {
     },
     },
     goBack(){
     goBack(){
       this.$router.back(-1)
       this.$router.back(-1)
-    }
+    },
+    getNowTime(){
+      const nowDate = new Date();
+      const date = {
+        year: nowDate.getFullYear(),
+        month: nowDate.getMonth() + 1,
+      }
+      this.NowTime1 = date.year + '-' + date.month
+      // console.log('页面第一次进来显示时间',date.year,date.month)
+      //进来获取当前时间 之后获取当前月份天数 传给
+      // console.log('页面显示的时间',this.NowTime1+"-01")  //2022-11
+      //把页面第一次进来的 当前年度月份 传给该方法处理 得到day及days
+      // this.getDaysInMonth(date.year,date.month)
+      
+    },
+    changeTime1(e){
+      // console.log('改变时间',e) //2022-07
+      // debugger
+      let year = e.slice(0,4)
+      let month = e.slice(5,7)
+      this.NowTime1 = year + '-' + month
+      // this.$set(this.data_key[index], "key", value);
+      // console.log('用户操作之后 页面显示的时间',this.NowTime,year,month) //2022-11 2022 11
+      //把年度月份传给getDaysInMonth()之前,先清理上一次数据
+      // this.entrustNumber.diswpose()  //这个方法干嘛的?? 为啥清不掉entrustNumberInit()方法的数据
+      this.days=[]
+      //在这里打印一下this.days数组
+      // console.log('用户操作了时间控件之后打印this.days数组',this.days)
+      //把用户操作时间控件改变的时间 的年度月份 传给该方法处理 得到day及days
+      // this.getDaysInMonth(year,month)
+    },
+    // getDaysInMonth(year,month){
+    //   let temp = new Date(year,month,0);
+    //   this.day = temp.getDate(); 
+    //   // console.log('处理好的年 月 月份天数',year,month,this.day);   //2022 11 30
+    //   //把月份对应天数转化为数组
+    //   for( let i=1;i <= this.day ;i++){
+    //     this.days.push(i)
+    //   }
+    //   // console.log('月份每一天',this.days)
+    //   this.getCheckSampleData(this.day)
+
+    // }
   }
   }
 
 
 }
 }