fix:统计分析—任务进度

This commit is contained in:
shijing 2024-09-12 10:03:05 +08:00
parent 1cb2c30d3e
commit 4382057684
1 changed files with 589 additions and 57 deletions

View File

@ -2,7 +2,7 @@
<el-container>
<el-header>
<div class="right-panel">
<el-select v-model="mgroupId"
<!-- <el-select v-model="mgroupId"
placeholder="请选择工段"
@change="mgroupChange">
<el-option
@ -12,7 +12,7 @@
:value="item.id"
>
</el-option>
</el-select>
</el-select> -->
<el-date-picker
v-model="searchDate"
type="month"
@ -29,31 +29,25 @@
</div>
</el-header>
<el-main id="elMain">
<el-row :gutter="10" id="elCol">
<el-col :lg="10">
<el-card shadow="never">
<scEcharts height="500px" :option="option"></scEcharts>
</el-card>
</el-col>
<el-col :lg="14">
<el-card shadow="never" style="position: relative">
<!-- 0 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart0"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport('7')"
@click="handleExport(0)"
class="tables"
type="primary"
>导出</el-button
>
<el-table
:data="tableData1"
id="exportDiv7"
height="500px"
>
<el-table :data="tableData0" id="exportDiv0" :height="300">
<el-table-column type="index" width="50" />
<el-table-column
label="任务编号"
prop="number"
min-width="100px"
>
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
@ -63,13 +57,490 @@
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-col>
</el-row>
</el-card>
<!-- 1 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart1"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(1)"
class="tables"
type="primary"
>导出</el-button
>
<el-table
:data="tableData1"
id="exportDiv1"
:height="300"
>
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 2 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart2"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(2)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData2" id="exportDiv2" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 3 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart3"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(3)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData3" id="exportDiv3" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 4 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart4"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(4)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData4" id="exportDiv4" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 5 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart5"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(5)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData5" id="exportDiv5" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 6 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart6"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(6)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData6" id="exportDiv6" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 7 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart7"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(7)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData7" id="exportDiv7" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 8 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart8"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(8)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData8" id="exportDiv8" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 9 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart9"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(9)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData9" id="exportDiv9" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 10 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart10"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(10)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData10" id="exportDiv10" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 11 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart11"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(11)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData11" id="exportDiv11" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 12 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart12"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(12)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData12" id="exportDiv12" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 13 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart13"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(13)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData13" id="exportDiv13" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 14 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart14"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(14)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData14" id="exportDiv14" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
<!-- 15 -->
<el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10">
<el-col :lg="12">
<el-card shadow="never">
<div id="linechart15"></div>
</el-card>
</el-col>
<el-col :lg="12">
<el-card shadow="never" style="position: relative">
<el-button
@click="handleExport(15)"
class="tables"
type="primary"
>导出</el-button
>
<el-table :data="tableData15" id="exportDiv15" :height="300">
<el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number" min-width="100px">
</el-table-column>
<el-table-column label="计划数" prop="count">
</el-table-column>
<el-table-column label="完成数" prop="count_ok">
</el-table-column>
<el-table-column label="完成率" prop="rate">
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
</el-main>
</el-container>
</template>
<script>
import * as echarts from "echarts";
import T from "@/components/scEcharts/echarts-theme-T.js";
echarts.registerTheme("T", T);
import scEcharts from "@/components/scEcharts";
function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj));
}
const ondDayTime = 86400000;
export default {
name: "chart",
components: {
@ -90,8 +561,7 @@ export default {
currentDate: "",
searchDate:'',
options:[],
tableData1: [],
option: {
basicOption: {
title: {
text: "",
},
@ -104,7 +574,7 @@ export default {
},
color: ["rgb(64,158,255)", "orange"],
series: {
name: "7车间完成率",
name: "任务进度",
type: "pie",
radius: ["40%", "70%"],
center: ["50%", "60%"],
@ -119,63 +589,119 @@ export default {
],
},
},
tableData0: [],
tableData1: [],
tableData2: [],
tableData3: [],
tableData4: [],
tableData5: [],
tableData6: [],
tableData7: [],
tableData8: [],
tableData9: [],
tableData10: [],
tableData11: [],
tableData12: [],
tableData13: [],
tableData14: [],
tableData15: [],
};
},
mounted() {
let that = this;
let date = new Date();
let year = date.getFullYear();
let month = date.getMonth() + 1;
month = month < 10 ? "0" + month : month;
that.currentDate = that.searchDate = year + "-" + month;
let days = new Date(year, month, 0).getDate();
let start_date = year + "-" + month + "-01";
let end_date = year + "-" + month + "-"+days;
that.start_date = that.query.querys[0][0].value = start_date;
that.end_date = that.query.querys[1][0].value = end_date;
let height = document.getElementById("elCol").clientHeight;
let chartheight = height+'px';
that.tableHeight = height-20;
let nowDate = new Date();
that.getMgroup();
},
methods: {
getWeekDate(dates){
let that = this;
dates = new Date(dates);
let week =dates.getDay(); //week
let weekFirst = 0, weekLast = 0;
if (week == 0) {
weekFirst = 6;
weekLast = 0; //
} else {
weekFirst = week - 1;
weekLast = 7 - week;
}
let first = new Date(dates.getTime() - weekFirst * ondDayTime); //
let last = new Date(new Date(dates.getTime() + weekLast * ondDayTime)); //
let dateArr = [];
for (let i = 0; i < 7; i++) {
let itemDate = new Date(first.getTime() + i * ondDayTime);
let item = itemDate.getDate();
dateArr.push(item);
}
that.weekDateList = dateArr;
that.query.start_date = that.query.querys[0][0].value = first.toISOString().split('T')[0];
that.query.end_date = that.query.querys[1][0].value = last.toISOString().split('T')[0];
that.options.forEach((item,index)=>{
that.getData(item.id,item.name,index);
})
},
getMgroup(){
let that = this;
that.$API.mtm.mgroup.list.req({ page: 0}).then((res) => {
that.options = res;
let nowDate = new Date();
that.getWeekDate(nowDate);
});
},
getData() {
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) {
option = Object.assign({}, this.basicOption);
}
setTimeout(() => {
try {
myChart.setOption(option);
} catch (error) {}
}, 500);
},
getData(mgroup_id,mgroup_name,mgroup_index) {
let that = this;
that.tableData1 = [];
that.option.series.data[0].value = 0;
that.option.series.data[1].value = 0;
let option = deepCopy(that.basicOption);
option.title.text = mgroup_name+"任务进度";
option.series.data[0].value = 0;
option.series.data[1].value = 0;
that.query.querys[0][1].value = mgroup_id;
that.query.querys[1][1].value = mgroup_id;
that.$API.pm.mtask.cquery.req(that.query).then((res) => {
let data = [];
let names = 'tableData'+mgroup_index;
that[names] = res;
console.log('names',names);
console.log('that[names]',that[names]);
let count_ok1 = 0;
let count_notok1 = 0;
if (res.length > 0) {
res.forEach((item) => {
let obj = item;
obj.rate = Math.round((item.count_ok / item.count) * 100).toFixed(2) + "%";
if (item.count_ok >= item.count) {
count_ok1++;
} else {
count_notok1++;
}
data.push(obj);
});
that.tableData1 = data;
option.series.data[0].value = count_ok1;
option.series.data[1].value = count_notok1;
let chartId = 'linechart'+mgroup_index;
that.setChart(chartId, option);
}else{
let chartId = 'linechart'+mgroup_index;
that.setChart(chartId, option);
}
that.option.series.data[0].value = count_ok1;
that.option.series.data[1].value = count_notok1;
});
},
mgroupChange(){
let that = this;
that.query.querys[0][1].value = that.mgroupId;
that.query.querys[1][1].value = that.mgroupId;
},
handleQuery(){
let that = this;
if(this.searchDate!==''&&this.searchDate!==null){
@ -191,7 +717,9 @@ export default {
that.query.querys[0][0].value = that.start_date;
that.query.querys[1][0].value = that.end_date;
}
that.getData();
that.options.forEach((item,index)=>{
that.getData(item.id,item.name,index);
})
},
handleExport(val) {
this.exportLoading = true;
@ -205,8 +733,12 @@ export default {
</script>
<style scoped>
#elCol{
height:100%;
#linechart1,#linechart2,#linechart3,#linechart4,
#linechart5,#linechart6,#linechart7,#linechart8,
#linechart9,#linechart10,#linechart11,#linechart12,
#linechart13,#linechart14,#linechart15,#linechart0{
width: 100%;
height: 300px;
}
.tables {
position: absolute;