|
|
@@ -20,9 +20,17 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- 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 { resolve } from 'path';
|
|
|
export default {
|
|
|
+ props:{
|
|
|
+ NowTime1:{
|
|
|
+ type:String,
|
|
|
+ default:""
|
|
|
+ }
|
|
|
+ },
|
|
|
data(){
|
|
|
return{
|
|
|
NowTime: '',
|
|
|
@@ -33,6 +41,9 @@ export default {
|
|
|
day:0,
|
|
|
//填充数量的数组
|
|
|
filledNum:[],
|
|
|
+ yearA:'',
|
|
|
+ monthA:''
|
|
|
+
|
|
|
|
|
|
// //已收到要填充的数组
|
|
|
// ReceivedNum:[],
|
|
|
@@ -49,23 +60,33 @@ export default {
|
|
|
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ NowTime1(newValue, oldValue) {
|
|
|
+ this.days.length=0
|
|
|
+ this.getNowTime()
|
|
|
+ }
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.getNowTime()
|
|
|
},
|
|
|
methods:{
|
|
|
//样品相关数据时间控件 :页面进来显示当前时间
|
|
|
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.NowTime = this.yearA + '-' + this.monthA
|
|
|
// console.log('页面第一次进来显示时间',date.year,date.month)
|
|
|
//进来获取当前时间 之后获取当前月份天数 传给
|
|
|
// console.log('页面显示的时间',this.NowTime) //2022-11
|
|
|
//把页面第一次进来的 当前年度月份 传给该方法处理 得到day及days
|
|
|
- this.getDaysInMonth(date.year,date.month)
|
|
|
+ this.getDaysInMonth(this.yearA,this.monthA)
|
|
|
|
|
|
},
|
|
|
|
|
|
@@ -106,7 +127,7 @@ export default {
|
|
|
//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 sql3 = "select liu_yang_ri_qi_,liu_yang_shu_lian FROM (SELECT * FROM t_mjypdjb) a WHERE a.shi_fou_liu_yang_ != '否' AND shou_yang_ri_qi_ LIKE '"+this.NowTime+'%'+"'"
|
|
|
Promise.all([
|
|
|
curdPost('sql', sql1),
|
|
|
curdPost('sql', sql2),
|
|
|
@@ -117,9 +138,9 @@ export default {
|
|
|
let data3 = res3.variables.data
|
|
|
// console.log('返回的全部数据',data1,data2)
|
|
|
// console.log('返回的全部数据',data1,data2,data3)
|
|
|
- const receivedData = this.dealingData(data1,dayNum)
|
|
|
- const unqualifiedData = this.dealingData(data2,dayNum)
|
|
|
- const retentionData = this.dealingRetentionData(data3,dayNum)
|
|
|
+ let receivedData = this.dealingData(data1,dayNum)
|
|
|
+ let unqualifiedData = this.dealingData(data2,dayNum)
|
|
|
+ let retentionData = this.dealingRetentionData(data3,dayNum)
|
|
|
// console.log('xxxxxxxxx方法返回的数据1 -------',receivedData)
|
|
|
// console.log('xxxxxxxxx方法返回的数据2 -------',unqualifiedData)
|
|
|
// console.log('xxxxxxxxx方法返回的数据3 -------',retentionData)
|
|
|
@@ -128,13 +149,17 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
//处理sql查询出来的数据
|
|
|
+ // dealingData(data,dayNum){
|
|
|
+
|
|
|
+ // return data
|
|
|
+ // },
|
|
|
dealingData(data,dayNum){
|
|
|
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);
|
|
|
+ hasValue !== -1 && (total[hasValue].shou_yang_shu_lia = Number(total[hasValue].shou_yang_shu_lia) + Number(cur.shou_yang_shu_lia));
|
|
|
return total;
|
|
|
}, []);
|
|
|
//console.log('日期相同数量相加 处理结果',newArray);
|
|
|
@@ -143,7 +168,7 @@ export default {
|
|
|
//遍历拿到的数组,截取出月份对应的 // 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)
|
|
|
+ let value =Number(item.shou_yang_shu_lia)
|
|
|
this.filledNum.splice(key - 1,1,value)
|
|
|
})
|
|
|
//返回处理好的数量数组
|
|
|
@@ -156,7 +181,7 @@ export default {
|
|
|
return current.liu_yang_ri_qi_ === cur.liu_yang_ri_qi_;
|
|
|
});
|
|
|
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;
|
|
|
}, []);
|
|
|
//console.log('日期相同数量相加 处理结果',newArray);
|
|
|
@@ -165,146 +190,12 @@ export default {
|
|
|
//遍历拿到的数组,截取出月份对应的 // 2022-11-01
|
|
|
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 value =parseInt(item.liu_yang_shu_lian)
|
|
|
+ let value =Number(item.liu_yang_shu_lian)
|
|
|
this.filledNum.splice(key - 1,1,value)
|
|
|
})
|
|
|
//返回处理好的数量数组
|
|
|
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){
|
|
|
// console.log('拿到日期数组',dayArray)
|
|
|
@@ -456,6 +347,7 @@ export default {
|
|
|
font-weight:600;
|
|
|
}
|
|
|
.chooseMonth{
|
|
|
+ display: none;
|
|
|
width: 120px;
|
|
|
line-height: 50px;
|
|
|
margin-left: 10px;
|