This commit is contained in:
shijing 2024-03-19 14:10:08 +08:00
commit b74e71b659
5 changed files with 477 additions and 475 deletions

View File

@ -17,7 +17,7 @@
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe> <scTable ref="table" :apiObj="apiObj" row-key="id" stripe>
<el-table-column label="#" type="index" width="50"></el-table-column> <el-table-column label="#" type="index" width="50"></el-table-column>
<el-table-column label="名称" prop="name" width="200" :show-overflow-tooltip="true"></el-table-column> <el-table-column label="名称" prop="name" width="200" :show-overflow-tooltip="true"></el-table-column>
<el-table-column label="sql语句" prop="sql_query" :show-overflow-tooltip="true"></el-table-column> <el-table-column label="代号" prop="code" :show-overflow-tooltip="true"></el-table-column>
<el-table-column label="操作" fixed="right" align="left" width="200"> <el-table-column label="操作" fixed="right" align="left" width="200">
<template #default="scope"> <template #default="scope">
<el-button type="primary" plain size="small" @click="handleShow(scope.row)" <el-button type="primary" plain size="small" @click="handleShow(scope.row)"

View File

@ -25,14 +25,18 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :md="24" :sm="24" :xs="24"> <el-col :md="24" :sm="24" :xs="24">
<el-form-item label="图表配置"> <el-form-item label="默认参数">
<el-input v-model="form.echart_options" clearable type="textarea" :rows="8"></el-input> <JsonEditorVue class="vueJsonEditor" v-model="form.default_param" @blur="validate" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :md="24" :sm="24" :xs="24"> <el-col :md="24" :sm="24" :xs="24">
<el-form-item label="默认参数"> <el-form-item label="测试参数">
<JsonEditorVue class="vueJsonEditor" v-model="form.default_param" @blur="validate" /> <JsonEditorVue class="vueJsonEditor" v-model="form.test_param" @blur="validate" />
<!-- <el-input v-model="form.default_param" clearable type="textarea" :rows="8"></el-input> --> </el-form-item>
</el-col>
<el-col :md="24" :sm="24" :xs="24">
<el-form-item label="图表配置">
<el-input v-model="form.echart_options" clearable type="textarea" :rows="8"></el-input>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -66,7 +70,6 @@ export default {
}, },
visible: false, visible: false,
isSaveing: false, isSaveing: false,
default_param:{},
selectionFilters: [], selectionFilters: [],
setFiltersVisible: false, setFiltersVisible: false,
belong_dept_options: [] belong_dept_options: []
@ -133,6 +136,7 @@ export default {
</script> </script>
<style> <style>
.vueJsonEditor{ .vueJsonEditor {
width: 100%; width: 100%;
}</style> }
</style>

View File

@ -3,30 +3,14 @@
<el-header> <el-header>
<div class="right-panel"> <div class="right-panel">
<el-select v-model="queryType" @change="queryTypeChange"> <el-select v-model="queryType" @change="queryTypeChange">
<el-option v-for="item in typeOptions" <el-option v-for="item in typeOptions" :key="item" :label="item" :value="item">
:key="item"
:label="item"
:value="item"
>
</el-option> </el-option>
</el-select> </el-select>
<el-date-picker <el-date-picker v-if="queryType == ''" v-model="queryDate" type="month" placeholder="查询月期"
v-if="queryType=='月'" value-format="YYYY-MM" style="width:100%">
v-model="queryDate"
type="month"
placeholder="查询月期"
value-format="YYYY-MM"
style="width:100%"
>
</el-date-picker> </el-date-picker>
<el-date-picker <el-date-picker v-if="queryType == ''" v-model="queryDate" type="year" placeholder="查询年份"
v-if="queryType=='年'" value-format="YYYY" style="width:100%">
v-model="queryDate"
type="year"
placeholder="查询年份"
value-format="YYYY"
style="width:100%"
>
</el-date-picker> </el-date-picker>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div> </div>
@ -46,7 +30,7 @@
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="物料名"> <el-table-column label="物料名" prop="物料名">
</el-table-column> </el-table-column>
<el-table-column label="月份" prop="月" v-if="queryType=='年'"> <el-table-column label="月份" prop="月" v-if="queryType == '年'">
</el-table-column> </el-table-column>
<el-table-column label="周" prop="周" v-else> <el-table-column label="周" prop="周" v-else>
</el-table-column> </el-table-column>
@ -54,8 +38,14 @@
</el-table-column> </el-table-column>
<el-table-column label="型号" prop="型号"> <el-table-column label="型号" prop="型号">
</el-table-column> </el-table-column>
<el-table-column label="生产数" prop="生产数">
</el-table-column>
<el-table-column label="合格数" prop="合格数"> <el-table-column label="合格数" prop="合格数">
</el-table-column> </el-table-column>
<el-table-column label="不合格数" prop="不合格数">
</el-table-column>
<el-table-column label="合格率" prop="合格率">
</el-table-column>
</el-table> </el-table>
</el-card> </el-card>
</el-col> </el-col>
@ -75,7 +65,7 @@
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="物料名"> <el-table-column label="物料名" prop="物料名">
</el-table-column> </el-table-column>
<el-table-column label="月份" prop="月" v-if="queryType=='年'"> <el-table-column label="月份" prop="月" v-if="queryType == '年'">
</el-table-column> </el-table-column>
<el-table-column label="周" prop="周" v-else> <el-table-column label="周" prop="周" v-else>
</el-table-column> </el-table-column>
@ -83,8 +73,14 @@
</el-table-column> </el-table-column>
<el-table-column label="型号" prop="型号"> <el-table-column label="型号" prop="型号">
</el-table-column> </el-table-column>
<el-table-column label="生产数" prop="生产数">
</el-table-column>
<el-table-column label="合格数" prop="合格数"> <el-table-column label="合格数" prop="合格数">
</el-table-column> </el-table-column>
<el-table-column label="不合格数" prop="不合格数">
</el-table-column>
<el-table-column label="合格率" prop="合格率">
</el-table-column>
</el-table> </el-table>
</el-card> </el-card>
</el-col> </el-col>
@ -104,7 +100,7 @@
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="物料名"> <el-table-column label="物料名" prop="物料名">
</el-table-column> </el-table-column>
<el-table-column label="月份" prop="月" v-if="queryType=='年'"> <el-table-column label="月份" prop="月" v-if="queryType == '年'">
</el-table-column> </el-table-column>
<el-table-column label="周" prop="周" v-else> <el-table-column label="周" prop="周" v-else>
</el-table-column> </el-table-column>
@ -112,8 +108,14 @@
</el-table-column> </el-table-column>
<el-table-column label="型号" prop="型号"> <el-table-column label="型号" prop="型号">
</el-table-column> </el-table-column>
<el-table-column label="生产数" prop="生产数">
</el-table-column>
<el-table-column label="合格数" prop="合格数"> <el-table-column label="合格数" prop="合格数">
</el-table-column> </el-table-column>
<el-table-column label="不合格数" prop="不合格数">
</el-table-column>
<el-table-column label="合格率" prop="合格率">
</el-table-column>
</el-table> </el-table>
</el-card> </el-card>
</el-col> </el-col>
@ -133,7 +135,7 @@
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="物料名" prop="物料名"> <el-table-column label="物料名" prop="物料名">
</el-table-column> </el-table-column>
<el-table-column label="月份" prop="月" v-if="queryType=='年'"> <el-table-column label="月份" prop="月" v-if="queryType == '年'">
</el-table-column> </el-table-column>
<el-table-column label="周" prop="周" v-else> <el-table-column label="周" prop="周" v-else>
</el-table-column> </el-table-column>
@ -148,342 +150,341 @@
</el-container> </el-container>
</template> </template>
<script> <script>
import * as echarts from "echarts"; import * as echarts from "echarts";
import T from '@/components/scEcharts/echarts-theme-T.js'; import T from '@/components/scEcharts/echarts-theme-T.js';
echarts.registerTheme('T', T); echarts.registerTheme('T', T);
import scEcharts from '@/components/scEcharts'; import scEcharts from '@/components/scEcharts';
function deepCopy(obj) { function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj)); return JSON.parse(JSON.stringify(obj));
} }
export default { export default {
name: 'chart', name: 'chart',
components: { components: {
scEcharts scEcharts
}, },
data() { data() {
return { return {
queryType:'月', queryType: '月',
queryDate:'', queryDate: '',
start_date:'', start_date: '',
end_date:'', end_date: '',
currentYear:'', currentYear: '',
currentMonth:'', currentMonth: '',
xAxisOrigin:[], xAxisOrigin: [],
xAxisData:[], xAxisData: [],
typeOptions:['月','年'], typeOptions: ['月', '年'],
basicOption: { basicOption: {
backgroundColor: 'transparent', backgroundColor: 'transparent',
title: { title: {
text: '', text: '',
},
grid: {
top: '80px'
},
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
data: []
},
yAxis: {
type: 'value'
},
lenged:[],
series: [{
data: [0, 0, 0, 0, 0, 0, 0],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
}]
}, },
tableData6:[], grid: {
tableData7:[], top: '80px'
tableData10:[], },
tableDataAVG:[], tooltip: {
firstWeekNum:1, trigger: 'axis'
endWeekNum:4, },
monthList:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'] xAxis: {
type: 'category',
data: []
},
yAxis: {
type: 'value'
},
lenged: [],
series: [{
data: [0, 0, 0, 0, 0, 0, 0],
stack: 'Ad',
type: 'bar',
barWidth: '15px',
}]
},
tableData6: [],
tableData7: [],
tableData10: [],
tableDataAVG: [],
firstWeekNum: 1,
endWeekNum: 4,
monthList: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
}
},
mounted() {
let that = this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let days = new Date(year, month, 0).getDate();
that.currentYear = year;
that.currentMonth = month;
that.start_date = year + '-' + month + '-01';
that.end_date = year + '-' + month + '-' + new Date(year, month, 0).getDate();
let month1 = month;
if (month1 < 10) { month1 = '0' + month1 }
that.queryDate = year + '-' + month1;
that.firstWeekNum = that.getWeekOfYear(new Date(that.start_date));
that.endWeekNum = that.getWeekOfYear(new Date(that.end_date));
let duration = that.endWeekNum - that.firstWeekNum + 1;
for (let i = 1; i <= duration; i++) {
that.xAxisOrigin.push('第' + i + '周');
}
that.xAxisData = that.xAxisOrigin;
that.getData6();
that.getData7();
that.getData10();
that.getDataDAVG();
},
methods: {
setChart(name, option = null) {
// name , optionoption
var myChart = echarts.getInstanceByDom(document.getElementById(name));
if (myChart == undefined) {
myChart = echarts.init(document.getElementById(name), 'T');
} }
}, if (option == null) {
mounted(){ option = Object.assign({}, this.basicOption)
let that =this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth()+1;
let days = new Date(year, month, 0).getDate();
that.currentYear = year;
that.currentMonth = month;
that.start_date =year+'-'+month+'-01';
that.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
let month1=month;
if(month1<10){month1='0'+month1}
that.queryDate = year+'-'+month1;
that.firstWeekNum = that.getWeekOfYear(new Date(that.start_date));
that.endWeekNum = that.getWeekOfYear(new Date(that.end_date));
let duration = that.endWeekNum - that.firstWeekNum + 1;
for(let i =1;i<=duration;i++ ){
that.xAxisOrigin.push('第'+i+'周');
} }
that.xAxisData = that.xAxisOrigin; setTimeout(() => {
that.getData6(); try {
that.getData7(); myChart.setOption(option);
that.getData10(); } catch (error) { }
that.getDataDAVG(); }, 500)
}, },
methods:{ queryTypeChange(value) {
setChart(name, option = null) { console.log(value)
// name , optionoption this.queryDate = '';
var myChart = echarts.getInstanceByDom(document.getElementById(name)); },
if (myChart == undefined) { getWeekOfYear(date) {
myChart = echarts.init(document.getElementById(name), 'T'); var target = new Date(date.getFullYear(), date.getMonth(), date.getDate()); //
} var firstDayOfYear = new Date(target.getFullYear(), 0, 1); //
if (option == null) { if (target.getTime() == firstDayOfYear.getTime()) {
option = Object.assign({}, this.basicOption) return 1;
} } else {
setTimeout(() => { return Math.ceil((target - firstDayOfYear + 8 * (firstDayOfYear.getTimezoneOffset() / 480)) / 604800000);
try { }
myChart.setOption(option); //
} catch (error) { } },
}, 500) getData6() {
}, let that = this;
queryTypeChange(value){ let option = deepCopy(that.basicOption);
console.log(value) option.xAxis.data = that.xAxisData;
this.queryDate = ''; option.title.text = '6车间';
}, let exec = that.queryType == '月' ? 'lineWeek' : 'lineMonth';
getWeekOfYear(date) { let obj = {
var target = new Date(date.getFullYear(), date.getMonth(), date.getDate()); // query: { start_date: that.start_date, end_date: that.end_date, dept_name: "6车间" },
var firstDayOfYear = new Date(target.getFullYear(), 0, 1); // };
if(target.getTime()==firstDayOfYear.getTime()){ that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
return 1; // console.log('6:',res);
}else{ let tableData6 = res.data2.ds0 ? res.data2.ds0 : [];
return Math.ceil((target - firstDayOfYear + 8 * (firstDayOfYear.getTimezoneOffset() / 480)) / 604800000); that.tableData6 = tableData6;
} if (tableData6.length > 0) {
// option.series = [];
}, let seriesData = [], nameList = [];
getData6(){ tableData6.forEach(ite => {
let that = this; if (nameList.indexOf(ite.物料名) > -1) { } else {
let option = deepCopy(that.basicOption); nameList.push(ite.物料名);
option.xAxis.data = that.xAxisData; seriesData.push([])
option.title.text = '6车间';
let exec = that.queryType=='月'?'productStatisticWeek':'productStatisticYear';
let obj = {
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "6车间" },
};
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('6:',res);
let tableData6 = res.data2.ds0?res.data2.ds0:[];
that.tableData6 = tableData6;
if(tableData6.length>0){
option.series = [];
let seriesData = [],nameList = [];
tableData6.forEach(ite=>{
if(nameList.indexOf(ite.物料名)>-1){}else{
nameList.push(ite.物料名);
seriesData.push([])
}
})
if(that.queryType=='月'){
tableData6.forEach(item => {
let indexX = nameList.indexOf(item.物料名);
let indexY = item.-that.firstWeekNum;
seriesData[indexX][indexY]=item.合格数;
});
}else{
tableData6.forEach(item => {
let indexX = nameList.indexOf(item.物料名);
let indexY = item.month-1;
seriesData[indexX][indexY]=item.合格数;
});
} }
for(let n=0;n<seriesData.length;n++){ })
let obj = {}; if (that.queryType == '月') {
obj.name= nameList[n]; tableData6.forEach(item => {
obj.stack= 'Ad'; let indexX = nameList.indexOf(item.物料名);
obj.type= 'bar'; let indexY = item. - that.firstWeekNum;
obj.barWidth= '15px'; seriesData[indexX][indexY] = item.合格数;
obj.data= seriesData[n];
option.series.push(obj)
}
that.setChart("bachart3", option);
}else{
that.setChart("bachart3", option);
}
});
},
getData7(){
let that = this;
let obj = {
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "7车间" },
};
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = '预制棒7车间';
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
console.log('7生产车间统计:',res);
let tableData7 = res.data2.ds0?res.data2.ds0:[];
that.tableData7 = tableData7;
debugger;
if(tableData7.length>0){
debugger;
option.series = [];
let seriesData = [],nameList = [];
tableData7.forEach(ite=>{
if(nameList.indexOf(ite.物料名)>-1){}else{
nameList.push(ite.物料名);
seriesData.push([])
}
})
tableData7.forEach(item => {
let indexX=0,indexY=0;
if(that.queryType=='月'){
indexX = nameList.indexOf(item.物料名);
indexY = item.-that.firstWeekNum;
}else{
indexX = nameList.indexOf(item.物料名);
indexY = item.-1;
}
seriesData[indexX][indexY]=item.合格数;
}); });
for(let n=0;n<seriesData.length;n++){ } else {
let obj = {}; tableData6.forEach(item => {
obj.name= nameList[n]; let indexX = nameList.indexOf(item.物料名);
obj.stack= 'Ad'; let indexY = item.month - 1;
obj.type= 'bar'; seriesData[indexX][indexY] = item.合格数;
obj.barWidth= '15px';
obj.data= seriesData[n];
option.series.push(obj)
}
that.setChart("bachart1", option);
}else{
that.setChart("bachart1", option);
}
});
},
getData10(){
let that = this;
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = '预制管10车间';
let obj = {
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "10车间" },
};
let exec = that.queryType=='月'?'lineWeek':'lineMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('10:',res);
let tableData10 = res.data2.ds0?res.data2.ds0:[];
that.tableData10 = tableData10;
if(tableData10.length>0){
option.series = [];
let seriesData = [],nameList = [];
tableData10.forEach(ite=>{
if(nameList.indexOf(ite.物料名)>-1){}else{
nameList.push(ite.物料名);
seriesData.push([])
}
})
tableData10.forEach(item => {
let indexX=0,indexY=0;
if(that.queryType=='月'){
indexX = nameList.indexOf(item.物料名);
indexY = item.-that.firstWeekNum;
}else{
indexX = nameList.indexOf(item.物料名);
indexY = item.-1;
}
seriesData[indexX][indexY]=item.合格数;
}); });
for(let n=0;n<seriesData.length;n++){
let obj = {};
obj.name= nameList[n];
obj.stack= 'Ad';
obj.type= 'bar';
obj.barWidth= '15px';
obj.data= seriesData[n];
option.series.push(obj)
}
that.setChart("bachart2", option);
}else{
that.setChart("bachart2", option);
} }
}); for (let n = 0; n < seriesData.length; n++) {
},
getDataDAVG(){
let that = this;
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = 'AVG';
let obj = {
query: { start_date: that.start_date, end_date: that.end_date},
};
let exec = that.queryType=='月'?'AVGWeek':'AVGMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('AVG:',res);
let tableDataAVG = res.data2.ds0?res.data2.ds0:[];
let seriesData = [];
if(tableDataAVG.length>0){
tableDataAVG.forEach(item => {
let index=0;
if(that.queryType=='月'){
index = item.month-1;
}else{
index = item.-that.firstWeekNum;
}
seriesData[index]=item.合格数;
});
let obj = {}; let obj = {};
obj.name= 'AVG'; obj.name = nameList[n];
obj.type= 'bar'; obj.stack = 'Ad';
obj.barWidth= '15px'; obj.type = 'bar';
obj.data= seriesData; obj.barWidth = '15px';
obj.data = seriesData[n];
option.series.push(obj) option.series.push(obj)
that.setChart("bachart4", option);
}else{
that.setChart("bachart4", option);
} }
}); that.setChart("bachart3", option);
}, } else {
handleQuery(){ that.setChart("bachart3", option);
let that = this;
if(this.queryType=='月'){
if(this.queryDate!==''&&this.queryDate!==null){
this.start_date =this.queryDate+'-01';
let arr = this.queryDate.split('-');
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
this.firstWeekNum = this.getWeekOfYear(new Date(this.start_date));
this.endWeekNum = this.getWeekOfYear(new Date(this.end_date));
let duration = this.endWeekNum - this.firstWeekNum + 1;
let xAxisData = [];
for(let i =1;i<=duration;i++ ){
xAxisData.push('第'+i+'周');
}
that.xAxisData = xAxisData;
}else{
this.start_date =this.currentYear+'-'+this.currentMonth+'-01';
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate();
let date = new Date(this.start_date);
this.firstWeekNum = this.getWeekOfYear(date);
this.xAxisData = this.xAxisOrigin;
}
}else{
if(this.queryDate!==''&&this.queryDate!==null){
this.start_date = this.queryDate+'-01-01';
this.end_date = this.queryDate+'-12-31';
}else{
this.start_date = this.currentYear+'-01-01';
this.end_date = this.currentYear+'-12-31';
}
that.xAxisData = that.monthList;
} }
this.getData6(); });
this.getData7();
this.getData10();
this.getDataDAVG();
},
}, },
} getData7() {
let that = this;
let obj = {
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "7车间" },
};
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = '预制棒7车间';
let exec = that.queryType == '月' ? 'lineWeek' : 'lineMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
console.log('7生产车间统计:', res);
let tableData7 = res.data2.ds0 ? res.data2.ds0 : [];
that.tableData7 = tableData7;
debugger;
if (tableData7.length > 0) {
debugger;
option.series = [];
let seriesData = [], nameList = [];
tableData7.forEach(ite => {
if (nameList.indexOf(ite.物料名) > -1) { } else {
nameList.push(ite.物料名);
seriesData.push([])
}
})
tableData7.forEach(item => {
let indexX = 0, indexY = 0;
if (that.queryType == '月') {
indexX = nameList.indexOf(item.物料名);
indexY = item. - that.firstWeekNum;
} else {
indexX = nameList.indexOf(item.物料名);
indexY = item. - 1;
}
seriesData[indexX][indexY] = item.合格数;
});
for (let n = 0; n < seriesData.length; n++) {
let obj = {};
obj.name = nameList[n];
obj.stack = 'Ad';
obj.type = 'bar';
obj.barWidth = '15px';
obj.data = seriesData[n];
option.series.push(obj)
}
that.setChart("bachart1", option);
} else {
that.setChart("bachart1", option);
}
});
},
getData10() {
let that = this;
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = '预制管10车间';
let obj = {
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "10车间" },
};
let exec = that.queryType == '月' ? 'lineWeek' : 'lineMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('10:',res);
let tableData10 = res.data2.ds0 ? res.data2.ds0 : [];
that.tableData10 = tableData10;
if (tableData10.length > 0) {
option.series = [];
let seriesData = [], nameList = [];
tableData10.forEach(ite => {
if (nameList.indexOf(ite.物料名) > -1) { } else {
nameList.push(ite.物料名);
seriesData.push([])
}
})
tableData10.forEach(item => {
let indexX = 0, indexY = 0;
if (that.queryType == '月') {
indexX = nameList.indexOf(item.物料名);
indexY = item. - that.firstWeekNum;
} else {
indexX = nameList.indexOf(item.物料名);
indexY = item. - 1;
}
seriesData[indexX][indexY] = item.合格数;
});
for (let n = 0; n < seriesData.length; n++) {
let obj = {};
obj.name = nameList[n];
obj.stack = 'Ad';
obj.type = 'bar';
obj.barWidth = '15px';
obj.data = seriesData[n];
option.series.push(obj)
}
that.setChart("bachart2", option);
} else {
that.setChart("bachart2", option);
}
});
},
getDataDAVG() {
let that = this;
let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData;
option.title.text = 'AVG';
let obj = {
query: { start_date: that.start_date, end_date: that.end_date },
};
let exec = that.queryType == '月' ? 'AVGWeek' : 'AVGMonth';
that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('AVG:',res);
let tableDataAVG = res.data2.ds0 ? res.data2.ds0 : [];
let seriesData = [];
if (tableDataAVG.length > 0) {
tableDataAVG.forEach(item => {
let index = 0;
if (that.queryType == '月') {
index = item.month - 1;
} else {
index = item. - that.firstWeekNum;
}
seriesData[index] = item.合格数;
});
let obj = {};
obj.name = 'AVG';
obj.type = 'bar';
obj.barWidth = '15px';
obj.data = seriesData;
option.series.push(obj)
that.setChart("bachart4", option);
} else {
that.setChart("bachart4", option);
}
});
},
handleQuery() {
let that = this;
if (this.queryType == '月') {
if (this.queryDate !== '' && this.queryDate !== null) {
this.start_date = this.queryDate + '-01';
let arr = this.queryDate.split('-');
this.end_date = this.queryDate + '-' + new Date(arr[0], arr[1], 0).getDate();
this.firstWeekNum = this.getWeekOfYear(new Date(this.start_date));
this.endWeekNum = this.getWeekOfYear(new Date(this.end_date));
let duration = this.endWeekNum - this.firstWeekNum + 1;
let xAxisData = [];
for (let i = 1; i <= duration; i++) {
xAxisData.push('第' + i + '周');
}
that.xAxisData = xAxisData;
} else {
this.start_date = this.currentYear + '-' + this.currentMonth + '-01';
this.end_date = this.currentYear + '-' + this.currentMonth + '-' + new Date(this.currentYear, this.currentMonth, 0).getDate();
let date = new Date(this.start_date);
this.firstWeekNum = this.getWeekOfYear(date);
this.xAxisData = this.xAxisOrigin;
}
} else {
if (this.queryDate !== '' && this.queryDate !== null) {
this.start_date = this.queryDate + '-01-01';
this.end_date = this.queryDate + '-12-31';
} else {
this.start_date = this.currentYear + '-01-01';
this.end_date = this.currentYear + '-12-31';
}
that.xAxisData = that.monthList;
}
this.getData6();
this.getData7();
this.getData10();
this.getDataDAVG();
},
},
}
</script> </script>
<style> <style></style>
</style>

View File

@ -34,6 +34,10 @@
</el-table-column> </el-table-column>
<el-table-column label="合格数" prop="合格数"> <el-table-column label="合格数" prop="合格数">
</el-table-column> </el-table-column>
<el-table-column label="完成进度" prop="完成进度">
</el-table-column>
<el-table-column label="合格率" prop="合格率">
</el-table-column>
</el-table> </el-table>
</el-card> </el-card>
</el-col> </el-col>

View File

@ -2,24 +2,12 @@
<el-container> <el-container>
<el-header> <el-header>
<div class="right-panel"> <div class="right-panel">
<el-select <el-select v-model="queryBelongDept" clearable style="width:200px" placeholder="请选择部门">
v-model="queryBelongDept" <el-option v-for="item in deptData" :key="item.id" :label="item.name" :value="item.name">
clearable
style="width:200px"
placeholder="请选择部门">
<el-option v-for="item in deptData"
:key="item.id"
:label="item.name"
:value="item.name">
</el-option> </el-option>
</el-select> </el-select>
<el-date-picker <el-date-picker v-model="queryDate" type="month" placeholder="查询月期" value-format="YYYY-MM"
v-model="queryDate" style="width:200px">
type="month"
placeholder="查询月期"
value-format="YYYY-MM"
style="width:200px"
>
</el-date-picker> </el-date-picker>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div> </div>
@ -46,8 +34,14 @@
<el-table-column label="车间"> <el-table-column label="车间">
{{ queryBelongDept }} {{ queryBelongDept }}
</el-table-column> </el-table-column>
<el-table-column label="生产数" prop="生产数">
</el-table-column>
<el-table-column label="合格数" prop="合格数"> <el-table-column label="合格数" prop="合格数">
</el-table-column> </el-table-column>
<el-table-column label="不合格数" prop="不合格数">
</el-table-column>
<el-table-column label="合格率" prop="合格率">
</el-table-column>
</el-table> </el-table>
</el-card> </el-card>
</el-col> </el-col>
@ -57,111 +51,110 @@
</template> </template>
<script> <script>
import scEcharts from '@/components/scEcharts'; import scEcharts from '@/components/scEcharts';
export default { export default {
name: 'chart', name: 'chart',
components: { components: {
scEcharts scEcharts
}, },
data() { data() {
return { return {
queryBelongDept:'', queryBelongDept: '',
queryDate:'', queryDate: '',
start_date:'', start_date: '',
end_date:'', end_date: '',
currentYear:'', currentYear: '',
currentMonth:'', currentMonth: '',
deptData:[], deptData: [],
tableData:[], tableData: [],
option: { option: {
title: { title: {
text: '人员统计', text: '人员统计',
// subtext: '', // subtext: '',
}, },
grid: { grid: {
top: '80px' top: '80px'
}, },
tooltip: { tooltip: {
trigger: 'axis' trigger: 'axis'
}, },
xAxis: { xAxis: {
type: 'value', type: 'value',
position:'top', position: 'top',
axisLine:{ axisLine: {
show:true show: true
}
},
yAxis: {
type: 'category',
data: []
},
series: {
data: [],
type: 'bar',
barWidth: '15px',
} }
}, },
} yAxis: {
}, type: 'category',
mounted(){ data: []
let date = new Date(); },
let year = date.getFullYear(); series: {
let month = date.getMonth()+1; data: [],
let days = new Date(year, month, 0).getDate(); type: 'bar',
this.currentYear = year; barWidth: '15px',
this.currentMonth = month;
this.start_date =year+'-'+month+'-01';
this.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate();
this.queryDate = year+'-'+month;
this.getData();
this.getDept();
},
methods:{
getDept() {
this.$API.system.dept.list.req({ page: 0,type:'dept'}).then(res=>{
this.deptData = res;
this.queryBelongDept = res[0].name;
});
},
queryTypeChange(value){
this.queryDate = '';
},
getData(){
let that = this;
let obj = {
query: { start_date: this.start_date, end_date: this.end_date, dept_name:this.queryBelongDept },
};
that.$API.bi.dataset.exec.req('performance', obj).then((res) => {
console.log('绩效统计:',res);
let data = res.data2.ds0;
let seriesData = [],yAxisData=[];
data.forEach(item=>{
seriesData.push(item.合格数);
yAxisData.push(item.操作人);
})
console.log(yAxisData)
console.log(seriesData)
console.log(data)
that.tableData = data;
that.option.yAxis.data = yAxisData;
that.option.series.data = seriesData;
});
},
handleQuery(){
if(this.queryDate!==''){
this.start_date =this.queryDate+'-01';
let arr = this.queryDate.split('-');
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate();
}else{
this.start_date =this.currentYear+'-'+this.currentMonth+'-01';
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate();
} }
console.log('查询query',this.start_date,this.end_date)
this.getData();
}, },
}
},
mounted() {
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
let days = new Date(year, month, 0).getDate();
this.currentYear = year;
this.currentMonth = month;
this.start_date = year + '-' + month + '-01';
this.end_date = year + '-' + month + '-' + new Date(year, month, 0).getDate();
this.queryDate = year + '-' + month;
this.getData();
this.getDept();
},
methods: {
getDept() {
this.$API.system.dept.list.req({ page: 0, type: 'dept' }).then(res => {
this.deptData = res;
this.queryBelongDept = res[0].name;
});
}, },
} queryTypeChange(value) {
this.queryDate = '';
},
getData() {
let that = this;
let obj = {
query: { start_date: this.start_date, end_date: this.end_date, dept_name: this.queryBelongDept },
};
that.$API.bi.dataset.exec.req('performance', obj).then((res) => {
console.log('绩效统计:', res);
let data = res.data2.ds0;
let seriesData = [], yAxisData = [];
data.forEach(item => {
seriesData.push(item.合格数);
yAxisData.push(item.操作人);
})
console.log(yAxisData)
console.log(seriesData)
console.log(data)
that.tableData = data;
that.option.yAxis.data = yAxisData;
that.option.series.data = seriesData;
});
},
handleQuery() {
if (this.queryDate !== '') {
this.start_date = this.queryDate + '-01';
let arr = this.queryDate.split('-');
this.end_date = this.queryDate + '-' + new Date(arr[0], arr[1], 0).getDate();
} else {
this.start_date = this.currentYear + '-' + this.currentMonth + '-01';
this.end_date = this.currentYear + '-' + this.currentMonth + '-' + new Date(this.currentYear, this.currentMonth, 0).getDate();
}
console.log('查询query', this.start_date, this.end_date)
this.getData();
},
},
}
</script> </script>
<style> <style></style>
</style>