Browse Source

task-3055检测看板检测任务月度完成量数据来源更改;
sql中关于年度由巨鼎当前时间年度更改完选择时间年度;

cyy 1 year ago
parent
commit
02ae77e411
1 changed files with 30 additions and 8 deletions
  1. 30 8
      src/views/system/jbdHome/board/checkBoard.vue

+ 30 - 8
src/views/system/jbdHome/board/checkBoard.vue

@@ -153,7 +153,7 @@
                 const sql = `select wt.month as month, wt.accepted as accepted, wt2.today as today, wt2.week as week, wt2.quarter as quarter, wt2.year as year, jc.total as jcTotal, jc.finished as jcFinish, rw.task as task, rw.finished as rwFinish, yp.task as yptask, yp.finished as ypFinish, bg.report as report, bg.process as process, bg.approval as approval, bg.finished as bgFinish, bg.uncompleted as uncompleted
                 from
                 (select count(id_) as month, count(zhuang_tai_ = '委托结束' or zhuang_tai_ = '已完成' or null) as accepted from t_mjwtsqb where create_time_ LIKE '${this.month}%') wt,
-                (select count(create_time_ like '${this.today}' or null) as today, count(create_time_ between '${week.start}' and '${week.end}' or null) as week, count(create_time_ between '${quarter.start}' and '${quarter.end}' or null) as quarter, count(create_time_ like '${this.year}%' or null) as year from t_mjwtsqb) wt2,
+                (select count(create_time_ like '${this.today}' or null) as today, count(create_time_ between '${week.start}' and '${week.end}' or null) as week, count(create_time_ between '${quarter.start}' and '${quarter.end}' or null) as quarter, count(create_time_ like '${this.month.slice(0,4)}%' or null) as year from t_mjwtsqb) wt2,
                 (select count(id_) as total, count(jian_ce_zhuang_ta = '已完成' or null) as finished from t_jchzb where create_time_ LIKE '${this.month}%') jc,
                 (select count(id_) as task, count(zhuang_tai_ = '已完成' or null) as finished from t_rwfpb where create_time_ LIKE '${this.month}%') rw,
 								(select count(id_) as task, count(jie_yang_zhuang_t = '已完成' or null) as finished from t_mjypb where create_time_ LIKE '${this.month}%') yp,
@@ -266,23 +266,29 @@
                 this.acceptList.forEach((item, index) => {
                     sqlStr += `count(tm.jian_ce_lei_bie_ = '${item}' or null) as r${index}${index === this.acceptList.length - 1 ? '' : ', '}`
                 })
+                // console.log(this.month.slice(0,4),'yyyyyyyyyyy')
                 const sql2 = `select ${sqlStr} from t_mjwtsqb tj, t_mjjcnlfw tm where tj.jian_ce_xiang_mu_ = tm.id_ and tj.create_time_ like '${this.month}%'`
+                const sql4 = `select jie_yang_zhuang_t as state, DATE_FORMAT(create_time_, '%Y-%m-%d %H:%i:%s') as time from t_mjypb where create_time_ LIKE '${this.month.slice(0,4)}%' and jie_yang_zhuang_t='已完成'`
+          
                 // console.log(sqlStr, sql2)
                 // 获取检测月度年度任务完成情况数据
-                const sql3 = `select rw.zhuang_tai_ as state, DATE_FORMAT(rw.create_time_, '%Y-%m-%d %H:%i:%s') as time from t_mjwtsqb rw where rw.create_time_ like '${this.year}%'`
+                const sql3 = `select rw.zhuang_tai_ as state, DATE_FORMAT(rw.create_time_, '%Y-%m-%d %H:%i:%s') as time from t_mjwtsqb rw where rw.create_time_ like '${this.month.slice(0,4)}%'`
 
                 Promise.all([
                     curdPost('sql', sql1),
                     curdPost('sql', sql2),
-                    curdPost('sql', sql3)
-                ]).then(([res1, res2, res3]) => {
+                    curdPost('sql', sql3),
+                    curdPost('sql', sql4)
+                ]).then(([res1, res2, res3,res4]) => {
                     const data1 = res1.variables.data || []
                     const data2 = res2.variables.data || []
                     const data3 = res3.variables.data || []
+                    const data4 = res4.variables.data || []
+                    let reports = new Array(12).fill(this.baseNum)
                     // console.log(data1, data2)
 
                     this.tableData.data = []
-                    console.log(data1)
+                    // console.log(data1)
                     data1.forEach(item => {
                         item.startDate = item.startDate ? item.startDate.slice(0, 10) : ''
                         // item.endDate = item.endDate ? item.endDate.slice(0, 10) : ''
@@ -313,6 +319,21 @@
                         }
                         task[index]++
                     })
+                    data4.forEach(item => {
+                        const index = parseInt(item.time.slice(5,7)) - 1
+                        if (item.state && item.state.includes('完成')) {
+                            reports[index]++
+                        }
+                    })
+                    let nDate = new Date()
+                    let xDate = this.month.split('-')
+                    if(nDate.getFullYear()<=xDate[0]*1)(
+                        reports.forEach((item,i)=>{
+                            if(i>nDate.getMonth()){
+                                reports[i] = item-this.baseNum
+                            }
+                        })
+                    )
                     let taskCount = task.reduce((pre, cur) => pre + cur)
                     let completeCount = complete.reduce((pre, cur) => pre + cur)
                     let year = [
@@ -330,15 +351,17 @@
                     this.middleCardData.task = task
                     this.middleCardData.complete = complete
                     this.middleCardData.year = year
+                    this.$set(this.middleCardData,'reports',reports)
+
                     // this.middleCardData.flag = true
                 })
             },
             // 获取底部图表数据
             getBottomData() {
                 // 获取检测委托受理情况数据
-                const sql1 = `select tm.zhuang_tai_ as state, DATE_FORMAT(tm.create_time_, '%Y-%m-%d %H:%i:%s') as time from t_mjwtsqb tm where tm.create_time_ like '${this.year}%'`
+                const sql1 = `select tm.zhuang_tai_ as state, DATE_FORMAT(tm.create_time_, '%Y-%m-%d %H:%i:%s') as time from t_mjwtsqb tm where tm.create_time_ like '${this.month.slice(0,4)}%'`
                 // 获取报告发放数据
-                const sql2 = `select zhuang_tai_ as state, DATE_FORMAT(create_time_, '%Y-%m-%d %H:%i:%s') as time from t_mjjcbg where create_time_ LIKE '${this.year}%'`
+                const sql2 = `select zhuang_tai_ as state, DATE_FORMAT(create_time_, '%Y-%m-%d %H:%i:%s') as time from t_mjjcbg where create_time_ LIKE '${this.month.slice(0,4)}%'`
                 // 获取样品 收样/留样/不合格数量
                 const sql4 = `select count(a.id_) as receive, count(a.shi_fou_liu_yang_ = '是' or null) as keep, count(a.yan_shou_zhuang_t = '残缺' or null) as incomplete, count(a.jie_yang_zhuang_t = '待确认' or null) as unReceive from (select id_, shi_fou_liu_yang_, yan_shou_zhuang_t, jie_yang_zhuang_t from t_mjypdjb where create_time_ like '${this.month}%' group by yang_pin_bian_hao) as a`
                 const sql5 = `select count( CASE WHEN jie_yang_zhuang_t != '已确认' THEN 1 END ) AS unReceive FROM 	t_mjypb WHERE create_time_ LIKE '${this.month}%'`
@@ -407,7 +430,6 @@
                     this.$set(this.bottomCardData,'trust',trust)
                     this.$set(this.bottomCardData,'accepted',accepted)
                     this.$set(this.bottomCardData,'reports',reports)
-                    this.$set(this.middleCardData,'reports',reports)
                     this.$set(this.bottomCardData,'compile',compile)