fix:生产统计百分比保留整数加%

This commit is contained in:
shijing 2024-03-26 13:31:48 +08:00
parent 4b66cea211
commit dcecde3c11
3 changed files with 828 additions and 521 deletions

View File

@ -3,20 +3,41 @@
<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" :key="item" :label="item" :value="item"> <el-option
v-for="item in typeOptions"
:key="item"
:label="item"
:value="item"
>
</el-option> </el-option>
</el-select> </el-select>
<el-date-picker v-if="queryType == ''" v-model="queryDate" type="month" placeholder="查询月期" <el-date-picker
value-format="YYYY-MM" style="width:100%"> v-if="queryType == '月'"
v-model="queryDate"
type="month"
placeholder="查询月期"
value-format="YYYY-MM"
style="width: 100%"
>
</el-date-picker> </el-date-picker>
<el-date-picker v-if="queryType == ''" v-model="queryDate" type="year" placeholder="查询年份" <el-date-picker
value-format="YYYY" style="width:100%"> v-if="queryType == '年'"
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>
</el-header> </el-header>
<el-main> <el-main>
<el-card shadow="never" style="margin-bottom: 8px;"> <el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never"> <el-card shadow="never">
@ -24,15 +45,38 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport('7')" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableData7" id="exportDiv7" :height="300"> @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 type="index" width="50" />
<el-table-column label="物料名" prop="物料名"> <el-table-column
label="物料名"
prop="物料名"
min-width="100"
>
</el-table-column> </el-table-column>
<el-table-column label="月份" prop="月" v-if="queryType == '年'" width="50"> <el-table-column
label="月份"
prop="月"
v-if="queryType == '年'"
width="50"
>
</el-table-column> </el-table-column>
<el-table-column label="周" prop="周" v-else width="50"> <el-table-column
label="周"
prop="周"
v-else
width="50"
>
</el-table-column> </el-table-column>
<el-table-column label="型号" prop="型号"> <el-table-column label="型号" prop="型号">
</el-table-column> </el-table-column>
@ -44,7 +88,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
label="不合格数"
prop="不合格数"
>
</el-table-column> </el-table-column>
<el-table-column label="合格率" prop="合格率"> <el-table-column label="合格率" prop="合格率">
<template #default="scope"> <template #default="scope">
@ -56,7 +103,7 @@
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
<el-card shadow="never" style="margin-bottom: 8px;"> <el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never"> <el-card shadow="never">
@ -64,13 +111,30 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport('10')" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableData10" id="exportDiv10" :height="300"> @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 type="index" width="50" />
<el-table-column label="物料名" prop="物料名"> <el-table-column
label="物料名"
prop="物料名"
min-width="100"
>
</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>
@ -84,7 +148,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
label="不合格数"
prop="不合格数"
>
</el-table-column> </el-table-column>
<el-table-column label="合格率" prop="合格率"> <el-table-column label="合格率" prop="合格率">
<template #default="scope"> <template #default="scope">
@ -96,7 +163,7 @@
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
<el-card shadow="never" style="margin-bottom: 8px;"> <el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never"> <el-card shadow="never">
@ -104,13 +171,30 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport('6')" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableData6" id="exportDiv6" :height="300"> @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 type="index" width="50" />
<el-table-column label="物料名" prop="物料名"> <el-table-column
label="物料名"
prop="物料名"
min-width="100"
>
</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>
@ -124,7 +208,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
label="不合格数"
prop="不合格数"
>
</el-table-column> </el-table-column>
<el-table-column label="合格率" prop="合格率"> <el-table-column label="合格率" prop="合格率">
<template #default="scope"> <template #default="scope">
@ -136,7 +223,7 @@
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
<el-card shadow="never" style="margin-bottom: 8px;"> <el-card shadow="never" style="margin-bottom: 8px">
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never"> <el-card shadow="never">
@ -144,13 +231,26 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport('AVG')" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableDataAVG" id="exportDivAVG" :height="300"> @click="handleExport('AVG')"
class="tables"
type="primary"
>导出</el-button
>
<el-table
:data="tableDataAVG"
id="exportDivAVG"
:height="300"
>
<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>
@ -166,53 +266,55 @@
</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: { grid: {
top: '80px' top: "80px",
}, },
tooltip: { tooltip: {
trigger: 'axis' trigger: "axis",
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
data: [] data: [],
}, },
yAxis: { yAxis: {
type: 'value' type: "value",
}, },
lenged: [], lenged: [],
series: [{ series: [
{
data: [0, 0, 0, 0, 0, 0, 0], data: [0, 0, 0, 0, 0, 0, 0],
stack: 'Ad', stack: "Ad",
type: 'bar', type: "bar",
barWidth: '15px', barWidth: "15px",
}] },
],
}, },
tableData6: [], tableData6: [],
tableData7: [], tableData7: [],
@ -220,8 +322,21 @@ export default {
tableDataAVG: [], tableDataAVG: [],
firstWeekNum: 1, firstWeekNum: 1,
endWeekNum: 4, endWeekNum: 4,
monthList: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'] monthList: [
} "一月",
"二月",
"三月",
"四月",
"五月",
"六月",
"七月",
"八月",
"九月",
"十月",
"十一月",
"十二月",
],
};
}, },
mounted() { mounted() {
let that = this; let that = this;
@ -231,16 +346,19 @@ export default {
let days = new Date(year, month, 0).getDate(); let days = new Date(year, month, 0).getDate();
that.currentYear = year; that.currentYear = year;
that.currentMonth = month; that.currentMonth = month;
that.start_date = year + '-' + month + '-01'; that.start_date = year + "-" + month + "-01";
that.end_date = year + '-' + month + '-' + new Date(year, month, 0).getDate(); that.end_date =
year + "-" + month + "-" + new Date(year, month, 0).getDate();
let month1 = month; let month1 = month;
if (month1 < 10) { month1 = '0' + month1 } if (month1 < 10) {
that.queryDate = year + '-' + month1; month1 = "0" + month1;
}
that.queryDate = year + "-" + month1;
that.firstWeekNum = that.getWeekOfYear(new Date(that.start_date)); that.firstWeekNum = that.getWeekOfYear(new Date(that.start_date));
that.endWeekNum = that.getWeekOfYear(new Date(that.end_date)); that.endWeekNum = that.getWeekOfYear(new Date(that.end_date));
let duration = that.endWeekNum - that.firstWeekNum + 1; let duration = that.endWeekNum - that.firstWeekNum + 1;
for (let i = 1; i <= duration; i++) { for (let i = 1; i <= duration; i++) {
that.xAxisOrigin.push('第' + i + '周'); that.xAxisOrigin.push("第" + i + "周");
} }
that.xAxisData = that.xAxisOrigin; that.xAxisData = that.xAxisOrigin;
that.getData6(); that.getData6();
@ -251,30 +369,41 @@ export default {
methods: { methods: {
setChart(name, option = null) { setChart(name, option = null) {
// name , optionoption // name , optionoption
var myChart = echarts.getInstanceByDom(document.getElementById(name)); var myChart = echarts.getInstanceByDom(
document.getElementById(name)
);
if (myChart == undefined) { if (myChart == undefined) {
myChart = echarts.init(document.getElementById(name), 'T'); myChart = echarts.init(document.getElementById(name), "T");
} }
if (option == null) { if (option == null) {
option = Object.assign({}, this.basicOption) option = Object.assign({}, this.basicOption);
} }
setTimeout(() => { setTimeout(() => {
try { try {
myChart.setOption(option); myChart.setOption(option);
} catch (error) {} } catch (error) {}
}, 500) }, 500);
}, },
queryTypeChange(value) { queryTypeChange(value) {
console.log(value) console.log(value);
this.queryDate = ''; this.queryDate = "";
}, },
getWeekOfYear(date) { getWeekOfYear(date) {
var target = new Date(date.getFullYear(), date.getMonth(), date.getDate()); // var target = new Date(
date.getFullYear(),
date.getMonth(),
date.getDate()
); //
var firstDayOfYear = new Date(target.getFullYear(), 0, 1); // var firstDayOfYear = new Date(target.getFullYear(), 0, 1); //
if (target.getTime() == firstDayOfYear.getTime()) { if (target.getTime() == firstDayOfYear.getTime()) {
return 1; return 1;
} else { } else {
return Math.ceil((target - firstDayOfYear + 8 * (firstDayOfYear.getTimezoneOffset() / 480)) / 604800000); return Math.ceil(
(target -
firstDayOfYear +
8 * (firstDayOfYear.getTimezoneOffset() / 480)) /
604800000
);
} }
// //
}, },
@ -282,10 +411,14 @@ export default {
let that = this; let that = this;
let option = deepCopy(that.basicOption); let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData; option.xAxis.data = that.xAxisData;
option.title.text = '6车间'; option.title.text = "6车间";
let exec = that.queryType == '月' ? 'lineWeek' : 'lineMonth'; let exec = that.queryType == "月" ? "lineWeek" : "lineMonth";
let obj = { let obj = {
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "6车间" }, query: {
start_date: that.start_date,
end_date: that.end_date,
dept_name: "6车间",
},
}; };
that.$API.bi.dataset.exec.req(exec, obj).then((res) => { that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('6:',res); // console.log('6:',res);
@ -293,21 +426,23 @@ export default {
that.tableData6 = tableData6; that.tableData6 = tableData6;
if (tableData6.length > 0) { if (tableData6.length > 0) {
option.series = []; option.series = [];
let seriesData = [], nameList = []; let seriesData = [],
tableData6.forEach(ite => { nameList = [];
if (nameList.indexOf(ite.物料名) > -1) { } else { tableData6.forEach((ite) => {
if (nameList.indexOf(ite.物料名) > -1) {
} else {
nameList.push(ite.物料名); nameList.push(ite.物料名);
seriesData.push([]) seriesData.push([]);
} }
}) });
if (that.queryType == '月') { if (that.queryType == "月") {
tableData6.forEach(item => { tableData6.forEach((item) => {
let indexX = nameList.indexOf(item.物料名); let indexX = nameList.indexOf(item.物料名);
let indexY = item. - that.firstWeekNum; let indexY = item. - that.firstWeekNum;
seriesData[indexX][indexY] = item.合格数; seriesData[indexX][indexY] = item.合格数;
}); });
} else { } else {
tableData6.forEach(item => { tableData6.forEach((item) => {
let indexX = nameList.indexOf(item.物料名); let indexX = nameList.indexOf(item.物料名);
let indexY = item.month - 1; let indexY = item.month - 1;
seriesData[indexX][indexY] = item.合格数; seriesData[indexX][indexY] = item.合格数;
@ -316,11 +451,11 @@ export default {
for (let n = 0; n < seriesData.length; n++) { for (let n = 0; n < seriesData.length; n++) {
let obj = {}; let obj = {};
obj.name = nameList[n]; obj.name = nameList[n];
obj.stack = 'Ad'; obj.stack = "Ad";
obj.type = 'bar'; obj.type = "bar";
obj.barWidth = '15px'; obj.barWidth = "15px";
obj.data = seriesData[n]; obj.data = seriesData[n];
option.series.push(obj) option.series.push(obj);
} }
that.setChart("bachart3", option); that.setChart("bachart3", option);
} else { } else {
@ -331,30 +466,37 @@ export default {
getData7() { getData7() {
let that = this; let that = this;
let obj = { let obj = {
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "7车间" }, query: {
start_date: that.start_date,
end_date: that.end_date,
dept_name: "7车间",
},
}; };
let option = deepCopy(that.basicOption); let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData; option.xAxis.data = that.xAxisData;
option.title.text = '预制棒7车间'; option.title.text = "预制棒7车间";
let exec = that.queryType == '月' ? 'lineWeek' : 'lineMonth'; let exec = that.queryType == "月" ? "lineWeek" : "lineMonth";
that.$API.bi.dataset.exec.req(exec, obj).then((res) => { that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
console.log('7生产车间统计:', res); console.log("7生产车间统计:", res);
let tableData7 = res.data2.ds0 ? res.data2.ds0 : []; let tableData7 = res.data2.ds0 ? res.data2.ds0 : [];
that.tableData7 = tableData7; that.tableData7 = tableData7;
debugger; debugger;
if (tableData7.length > 0) { if (tableData7.length > 0) {
debugger; debugger;
option.series = []; option.series = [];
let seriesData = [], nameList = []; let seriesData = [],
tableData7.forEach(ite => { nameList = [];
if (nameList.indexOf(ite.物料名) > -1) { } else { tableData7.forEach((ite) => {
if (nameList.indexOf(ite.物料名) > -1) {
} else {
nameList.push(ite.物料名); nameList.push(ite.物料名);
seriesData.push([]) seriesData.push([]);
} }
}) });
tableData7.forEach(item => { tableData7.forEach((item) => {
let indexX = 0, indexY = 0; let indexX = 0,
if (that.queryType == '月') { indexY = 0;
if (that.queryType == "月") {
indexX = nameList.indexOf(item.物料名); indexX = nameList.indexOf(item.物料名);
indexY = item. - that.firstWeekNum; indexY = item. - that.firstWeekNum;
} else { } else {
@ -366,11 +508,11 @@ export default {
for (let n = 0; n < seriesData.length; n++) { for (let n = 0; n < seriesData.length; n++) {
let obj = {}; let obj = {};
obj.name = nameList[n]; obj.name = nameList[n];
obj.stack = 'Ad'; obj.stack = "Ad";
obj.type = 'bar'; obj.type = "bar";
obj.barWidth = '15px'; obj.barWidth = "15px";
obj.data = seriesData[n]; obj.data = seriesData[n];
option.series.push(obj) option.series.push(obj);
} }
that.setChart("bachart1", option); that.setChart("bachart1", option);
} else { } else {
@ -382,27 +524,34 @@ export default {
let that = this; let that = this;
let option = deepCopy(that.basicOption); let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData; option.xAxis.data = that.xAxisData;
option.title.text = '预制管10车间'; option.title.text = "预制管10车间";
let obj = { let obj = {
query: { start_date: that.start_date, end_date: that.end_date, dept_name: "10车间" }, query: {
start_date: that.start_date,
end_date: that.end_date,
dept_name: "10车间",
},
}; };
let exec = that.queryType == '月' ? 'lineWeek' : 'lineMonth'; let exec = that.queryType == "月" ? "lineWeek" : "lineMonth";
that.$API.bi.dataset.exec.req(exec, obj).then((res) => { that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('10:',res); // console.log('10:',res);
let tableData10 = res.data2.ds0 ? res.data2.ds0 : []; let tableData10 = res.data2.ds0 ? res.data2.ds0 : [];
that.tableData10 = tableData10; that.tableData10 = tableData10;
if (tableData10.length > 0) { if (tableData10.length > 0) {
option.series = []; option.series = [];
let seriesData = [], nameList = []; let seriesData = [],
tableData10.forEach(ite => { nameList = [];
if (nameList.indexOf(ite.物料名) > -1) { } else { tableData10.forEach((ite) => {
if (nameList.indexOf(ite.物料名) > -1) {
} else {
nameList.push(ite.物料名); nameList.push(ite.物料名);
seriesData.push([]) seriesData.push([]);
} }
}) });
tableData10.forEach(item => { tableData10.forEach((item) => {
let indexX = 0, indexY = 0; let indexX = 0,
if (that.queryType == '月') { indexY = 0;
if (that.queryType == "月") {
indexX = nameList.indexOf(item.物料名); indexX = nameList.indexOf(item.物料名);
indexY = item. - that.firstWeekNum; indexY = item. - that.firstWeekNum;
} else { } else {
@ -414,11 +563,11 @@ export default {
for (let n = 0; n < seriesData.length; n++) { for (let n = 0; n < seriesData.length; n++) {
let obj = {}; let obj = {};
obj.name = nameList[n]; obj.name = nameList[n];
obj.stack = 'Ad'; obj.stack = "Ad";
obj.type = 'bar'; obj.type = "bar";
obj.barWidth = '15px'; obj.barWidth = "15px";
obj.data = seriesData[n]; obj.data = seriesData[n];
option.series.push(obj) option.series.push(obj);
} }
that.setChart("bachart2", option); that.setChart("bachart2", option);
} else { } else {
@ -430,19 +579,19 @@ export default {
let that = this; let that = this;
let option = deepCopy(that.basicOption); let option = deepCopy(that.basicOption);
option.xAxis.data = that.xAxisData; option.xAxis.data = that.xAxisData;
option.title.text = 'AVG'; option.title.text = "AVG";
let obj = { let obj = {
query: { start_date: that.start_date, end_date: that.end_date }, query: { start_date: that.start_date, end_date: that.end_date },
}; };
let exec = that.queryType == '月' ? 'AVGWeek' : 'AVGMonth'; let exec = that.queryType == "月" ? "AVGWeek" : "AVGMonth";
that.$API.bi.dataset.exec.req(exec, obj).then((res) => { that.$API.bi.dataset.exec.req(exec, obj).then((res) => {
// console.log('AVG:',res); // console.log('AVG:',res);
let tableDataAVG = res.data2.ds0 ? res.data2.ds0 : []; let tableDataAVG = res.data2.ds0 ? res.data2.ds0 : [];
let seriesData = []; let seriesData = [];
if (tableDataAVG.length > 0) { if (tableDataAVG.length > 0) {
tableDataAVG.forEach(item => { tableDataAVG.forEach((item) => {
let index = 0; let index = 0;
if (that.queryType == '月') { if (that.queryType == "月") {
index = item.month - 1; index = item.month - 1;
} else { } else {
index = item. - that.firstWeekNum; index = item. - that.firstWeekNum;
@ -450,11 +599,11 @@ export default {
seriesData[index] = item.合格数; seriesData[index] = item.合格数;
}); });
let obj = {}; let obj = {};
obj.name = 'AVG'; obj.name = "AVG";
obj.type = 'bar'; obj.type = "bar";
obj.barWidth = '15px'; obj.barWidth = "15px";
obj.data = seriesData; obj.data = seriesData;
option.series.push(obj) option.series.push(obj);
that.setChart("bachart4", option); that.setChart("bachart4", option);
} else { } else {
that.setChart("bachart4", option); that.setChart("bachart4", option);
@ -463,33 +612,50 @@ export default {
}, },
handleQuery() { handleQuery() {
let that = this; let that = this;
if (this.queryType == '月') { if (this.queryType == "月") {
if (this.queryDate !== '' && this.queryDate !== null) { if (this.queryDate !== "" && this.queryDate !== null) {
this.start_date = this.queryDate + '-01'; this.start_date = this.queryDate + "-01";
let arr = this.queryDate.split('-'); let arr = this.queryDate.split("-");
this.end_date = this.queryDate + '-' + new Date(arr[0], arr[1], 0).getDate(); this.end_date =
this.firstWeekNum = this.getWeekOfYear(new Date(this.start_date)); this.queryDate +
this.endWeekNum = this.getWeekOfYear(new Date(this.end_date)); "-" +
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 duration = this.endWeekNum - this.firstWeekNum + 1;
let xAxisData = []; let xAxisData = [];
for (let i = 1; i <= duration; i++) { for (let i = 1; i <= duration; i++) {
xAxisData.push('第' + i + '周'); xAxisData.push("第" + i + "周");
} }
that.xAxisData = xAxisData; that.xAxisData = xAxisData;
} else { } else {
this.start_date = this.currentYear + '-' + this.currentMonth + '-01'; this.start_date =
this.end_date = this.currentYear + '-' + this.currentMonth + '-' + new Date(this.currentYear, this.currentMonth, 0).getDate(); 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); let date = new Date(this.start_date);
this.firstWeekNum = this.getWeekOfYear(date); this.firstWeekNum = this.getWeekOfYear(date);
this.xAxisData = this.xAxisOrigin; this.xAxisData = this.xAxisOrigin;
} }
} else { } else {
if (this.queryDate !== '' && this.queryDate !== null) { if (this.queryDate !== "" && this.queryDate !== null) {
this.start_date = this.queryDate + '-01-01'; this.start_date = this.queryDate + "-01-01";
this.end_date = this.queryDate + '-12-31'; this.end_date = this.queryDate + "-12-31";
} else { } else {
this.start_date = this.currentYear + '-01-01'; this.start_date = this.currentYear + "-01-01";
this.end_date = this.currentYear + '-12-31'; this.end_date = this.currentYear + "-12-31";
} }
that.xAxisData = that.monthList; that.xAxisData = that.monthList;
} }
@ -500,18 +666,21 @@ export default {
}, },
handleExport(val) { handleExport(val) {
this.exportLoading = true; this.exportLoading = true;
let id = '#exportDiv' + val; let id = "#exportDiv" + val;
let name = val == 'AVG' ? val + '合格数统计' : val+'车间合格数统计'; let name =
val == "AVG" ? val + "合格数统计" : val + "车间合格数统计";
this.$XLSX(id, name); this.$XLSX(id, name);
this.exportLoading = false; this.exportLoading = false;
}, },
}, },
} };
</script> </script>
<style scoped> <style scoped>
#bachart1,#bachart2, #bachart1,
#bachart3,#bachart4{ #bachart2,
#bachart3,
#bachart4 {
width: 100%; width: 100%;
height: 300px; height: 300px;
} }

View File

@ -3,16 +3,37 @@
<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" :key="item" :label="item" :value="item"> <el-option
v-for="item in typeOptions"
:key="item"
:label="item"
:value="item"
>
</el-option> </el-option>
</el-select> </el-select>
<el-date-picker v-if="queryType == ''" v-model="queryDate" type="month" placeholder="查询月期" <el-date-picker
value-format="YYYY-MM" style="width:100%"> v-if="queryType == '月'"
v-model="queryDate"
type="month"
placeholder="查询月期"
value-format="YYYY-MM"
style="width: 100%"
>
</el-date-picker> </el-date-picker>
<el-date-picker v-if="queryType == ''" v-model="queryDate" type="year" placeholder="查询年份" <el-date-picker
value-format="YYYY" style="width:100%"> v-if="queryType == '年'"
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>
</el-header> </el-header>
<el-main id="elMain"> <el-main id="elMain">
@ -23,13 +44,26 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableData" :height="tableHeight" id="exportDiv"> @click="handleExport"
class="tables"
type="primary"
>导出</el-button
>
<el-table
:data="tableData"
:height="tableHeight"
id="exportDiv"
>
<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="物料名"> <el-table-column
label="物料名"
prop="物料名"
min-width="100"
>
</el-table-column> </el-table-column>
<el-table-column label="任务数" prop="任务数"> <el-table-column label="任务数" prop="任务数">
</el-table-column> </el-table-column>
@ -40,8 +74,14 @@
<el-table-column label="不合格数" prop="不合格数"> <el-table-column label="不合格数" prop="不合格数">
</el-table-column> </el-table-column>
<el-table-column label="完成进度" prop="完成进度"> <el-table-column label="完成进度" prop="完成进度">
<template slot-scope="scope">
{{ Math.round(scope.row.完成进度 * 100) }}%
</template>
</el-table-column> </el-table-column>
<el-table-column label="合格率" prop="合格率"> <el-table-column label="合格率" prop="合格率">
<template slot-scope="scope">
{{ Math.round(scope.row.合格率 * 100) }}%
</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-card> </el-card>
@ -52,146 +92,181 @@
</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 {
tableHeight: 0, tableHeight: 0,
queryType: '月', queryType: "月",
queryDate: '', queryDate: "",
start_date: '', start_date: "",
end_date: '', end_date: "",
currentYear: '', currentYear: "",
currentMonth: '', currentMonth: "",
typeOptions: ['月', '年'], typeOptions: ["月", "年"],
option: { option: {
title: { title: {
text: '生产数量', text: "生产数量",
}, },
grid: { grid: {
top: '80px' top: "80px",
}, },
tooltip: { tooltip: {
trigger: 'axis' trigger: "axis",
}, },
xAxis: { xAxis: {
type: 'category', type: "category",
data: [] data: [],
}, },
yAxis: { yAxis: {
type: 'value' type: "value",
}, },
series: [ series: [
{ {
name: '光纤预制棒', name: "光纤预制棒",
data: [0, 0, 0, 0, 0, 0, 0, 0], data: [0, 0, 0, 0, 0, 0, 0, 0],
type: 'bar', type: "bar",
barWidth: '15px', label: {
}, { show: true,
name: '光纤预制管', position: "top",
formatter: "{c}",
color: "rgb(64,158,255)",
},
barWidth: "15px",
},
{
name: "光纤预制管",
data: [0, 0, 0, 0, 0, 0, 0, 0], data: [0, 0, 0, 0, 0, 0, 0, 0],
type: 'bar', type: "bar",
barWidth: '15px', label: {
} show: true,
] position: "top",
formatter: "{c}",
color: "rgb(64,158,255)",
},
barWidth: "15px",
},
],
}, },
processData: [], processData: [],
xAxisData: [], xAxisData: [],
tableData: [], tableData: [],
} };
}, },
mounted() { mounted() {
let that = this; let that = this;
let date = new Date(); let date = new Date();
let year = date.getFullYear(); let year = date.getFullYear();
let month = date.getMonth() + 1; let month = date.getMonth() + 1;
let days = new Date(year, month, 0).getDate(); let days = new Date(year, month, 0).getDate();
that.currentYear = year; that.currentYear = year;
that.currentMonth = month > 9 ? month : '0' + month; that.currentMonth = month > 9 ? month : "0" + month;
that.start_date = year + '-' + month + '-01'; that.start_date = year + "-" + month + "-01";
that.end_date = year + '-' + month + '-' + new Date(year, month, 0).getDate(); that.end_date =
let month1 = month > 9 ? month : '0' + month; year + "-" + month + "-" + new Date(year, month, 0).getDate();
that.queryDate = year + '-' + month1; let month1 = month > 9 ? month : "0" + month;
that.tableHeight = document.getElementById('elMain').clientHeight - 40; that.queryDate = year + "-" + month1;
that.tableHeight = document.getElementById("elMain").clientHeight - 40;
that.getData6(); that.getData6();
}, },
methods: { methods: {
queryTypeChange(value) { queryTypeChange(value) {
console.log(value) console.log(value);
this.queryDate = ''; this.queryDate = "";
}, },
getData6() { getData6() {
let that = this; let that = this;
let obj = { let obj = {
query: { query: {
start_date: this.start_date, end_date: this.end_date, dept_name: "6车间", start_date: this.start_date,
select_cols_material: "", group_bys_material: "", order_bys_material: "", end_date: this.end_date,
is_count_utask:-1,select_cols_mgroup: ", mgroup.name AS 工段", dept_name: "6车间",
group_bys_mgroup: ", mgroup.name" select_cols_material: "",
group_bys_material: "",
order_bys_material: "",
is_count_utask: -1,
select_cols_mgroup: ", mgroup.name AS 工段",
group_bys_mgroup: ", mgroup.name",
}, },
raise_exception: true raise_exception: true,
}; };
if (that.queryType == '月') { if (that.queryType == "月") {
obj.query.select_cols_date = ",EXTRACT ( MONTH FROM mlog.handle_date ) AS 月" obj.query.select_cols_date =
obj.query.group_bys_date = ",EXTRACT ( MONTH FROM mlog.handle_date )" ",EXTRACT ( MONTH FROM mlog.handle_date ) AS 月";
obj.query.order_bys_date = ", 月" obj.query.group_bys_date =
",EXTRACT ( MONTH FROM mlog.handle_date )";
obj.query.order_bys_date = ", 月";
} }
let xAxisData = [], data1 = [], data0 = []; let xAxisData = [],
that.$API.bi.dataset.exec.req('lineWeek', obj).then((res) => { data1 = [],
data0 = [];
that.$API.bi.dataset.exec.req("lineWeek", obj).then((res) => {
let data = res.data2.ds0; let data = res.data2.ds0;
that.tableData = data; that.tableData = data;
data.forEach(item => { data.forEach((item) => {
if (xAxisData.indexOf(item.工段) > -1) { } else { if (xAxisData.indexOf(item.工段) > -1) {
} else {
xAxisData.push(item.工段); xAxisData.push(item.工段);
} }
console.log('xAxisData:', xAxisData); console.log("xAxisData:", xAxisData);
let index = xAxisData.indexOf(item.工段); let index = xAxisData.indexOf(item.工段);
if (item.物料名.indexOf('棒') > -1) { if (item.物料名.indexOf("棒") > -1) {
data0[index] = item.合格数; data0[index] = item.合格数;
} else { } else {
data1[index] = item.合格数; data1[index] = item.合格数;
} }
}) });
that.xAxisData = xAxisData; that.xAxisData = xAxisData;
that.option.xAxis.data = that.xAxisData; that.option.xAxis.data = that.xAxisData;
that.option.series[0].data = data0; that.option.series[0].data = data0;
that.option.series[1].data = data1; that.option.series[1].data = data1;
}) });
}, },
handleQuery() { handleQuery() {
if (this.queryDate !== '' && this.queryDate !== null) { if (this.queryDate !== "" && this.queryDate !== null) {
if (this.queryType == '月') { if (this.queryType == "月") {
this.start_date = this.queryDate + '-01'; this.start_date = this.queryDate + "-01";
let arr = this.queryDate.split('-'); let arr = this.queryDate.split("-");
this.end_date = this.queryDate + '-' + new Date(arr[0], arr[1], 0).getDate(); this.end_date =
this.queryDate +
"-" +
new Date(arr[0], arr[1], 0).getDate();
} else { } else {
this.start_date = this.queryDate + '-01-01'; this.start_date = this.queryDate + "-01-01";
this.end_date = this.queryDate + '-12-31'; this.end_date = this.queryDate + "-12-31";
} }
} else { } else {
if (this.queryType == '月') { if (this.queryType == "月") {
this.start_date = this.currentYear + '-' + this.currentMonth + '-01'; this.start_date =
this.end_date = this.currentYear + '-' + this.currentMonth + '-' + new Date(this.currentYear, this.currentMonth, 0).getDate(); this.currentYear + "-" + this.currentMonth + "-01";
this.end_date =
this.currentYear +
"-" +
this.currentMonth +
"-" +
new Date(
this.currentYear,
this.currentMonth,
0
).getDate();
} else { } else {
this.start_date = this.currentYear + '-01-01'; this.start_date = this.currentYear + "-01-01";
this.end_date = this.currentYear + '-12-31'; this.end_date = this.currentYear + "-12-31";
} }
} }
this.getData6(); this.getData6();
}, },
handleExport() { handleExport() {
this.exportLoading = true; this.exportLoading = true;
this.$XLSX('#exportDiv', '工序合格数'); this.$XLSX("#exportDiv", "工序合格数");
this.exportLoading = false; this.exportLoading = false;
}, },
}, },
} };
</script> </script>
<style scoped> <style scoped>

View File

@ -3,7 +3,8 @@
<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" :key="item"
:label="item" :label="item"
:value="item" :value="item"
@ -28,7 +29,11 @@
style="width: 100%" 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>
</el-header> </el-header>
<el-main id="elMain"> <el-main id="elMain">
@ -51,11 +56,24 @@
</el-row> </el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :lg="8"> <el-col :lg="8">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport('7')" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableData1" id="exportDiv7" :height="tableHeight"> @click="handleExport('7')"
class="tables"
type="primary"
>导出</el-button
>
<el-table
:data="tableData1"
id="exportDiv7"
:height="tableHeight"
>
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number"> <el-table-column
label="任务编号"
prop="number"
min-width="100px"
>
</el-table-column> </el-table-column>
<el-table-column label="计划数" prop="count"> <el-table-column label="计划数" prop="count">
</el-table-column> </el-table-column>
@ -67,11 +85,24 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="8"> <el-col :lg="8">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport('10')" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableData2" id="exportDiv10" :height="tableHeight"> @click="handleExport('10')"
class="tables"
type="primary"
>导出</el-button
>
<el-table
:data="tableData2"
id="exportDiv10"
:height="tableHeight"
>
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number"> <el-table-column
label="任务编号"
prop="number"
min-width="100px"
>
</el-table-column> </el-table-column>
<el-table-column label="计划数" prop="count"> <el-table-column label="计划数" prop="count">
</el-table-column> </el-table-column>
@ -83,11 +114,24 @@
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="8"> <el-col :lg="8">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport('6')" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableData3" id="exportDiv6" :height="tableHeight"> @click="handleExport('6')"
class="tables"
type="primary"
>导出</el-button
>
<el-table
:data="tableData3"
id="exportDiv6"
:height="tableHeight"
>
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="任务编号" prop="number"> <el-table-column
label="任务编号"
prop="number"
min-width="100px"
>
</el-table-column> </el-table-column>
<el-table-column label="计划数" prop="count"> <el-table-column label="计划数" prop="count">
</el-table-column> </el-table-column>
@ -103,100 +147,100 @@
</el-container> </el-container>
</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 {
tableHeight: 0, tableHeight: 0,
queryType:'月', queryType: "月",
queryDate:'', queryDate: "",
start_date:'', start_date: "",
end_date:'', end_date: "",
currentYear:'', currentYear: "",
currentMonth:'', currentMonth: "",
typeOptions:['月','年'], typeOptions: ["月", "年"],
option1: { option1: {
title: { title: {
text: '7车间完成率', text: "7车间完成率",
}, },
tooltip: { tooltip: {
trigger: 'item' trigger: "item",
}, },
legend: { legend: {
top: '3', top: "3",
right:'3%', right: "3%",
}, },
color:['rgb(64,158,255)','orange'], color: ["rgb(64,158,255)", "orange"],
series: { series: {
name: '7车间完成率', name: "7车间完成率",
type: 'pie', type: "pie",
radius: ['40%', '70%'], radius: ["40%", "70%"],
center: ['50%', '60%'], center: ["50%", "60%"],
label: { label: {
show: true, show: true,
position: 'outside', position: "outside",
formatter: '{b} : {c} ({d}%)', formatter: "{b} : {c} ({d}%)",
}, },
data: [ data: [
{value: 0, name: '已完成'}, { value: 0, name: "已完成" },
{value: 0, name: '未完成'}, { value: 0, name: "未完成" },
] ],
} },
}, },
option2: { option2: {
title: { title: {
text: '10车间完成率', text: "10车间完成率",
// subtext: '', // subtext: '',
}, },
tooltip: { tooltip: {
trigger: 'item' trigger: "item",
}, },
legend: { legend: {
top: '3', top: "3",
right:'3%', right: "3%",
}, },
color:['rgb(64,158,255)','orange'], color: ["rgb(64,158,255)", "orange"],
series: { series: {
name: '10车间完成率', name: "10车间完成率",
type: 'pie', type: "pie",
radius: ['40%', '70%'], radius: ["40%", "70%"],
center: ['50%', '60%'], center: ["50%", "60%"],
label: { label: {
show: true, show: true,
position: 'outside', position: "outside",
formatter: '{b} : {c} ({d}%)', formatter: "{b} : {c} ({d}%)",
}, },
data: [ data: [
{value: 0, name: '已完成'}, { value: 0, name: "已完成" },
{value: 0, name: '未完成'}, { value: 0, name: "未完成" },
] ],
} },
}, },
option3: { option3: {
title: { title: {
text: '6车间完成率', text: "6车间完成率",
}, },
tooltip: { tooltip: {
trigger: 'item' trigger: "item",
}, },
legend: { legend: {
top: '3', top: "3",
right:'3%', right: "3%",
}, },
color:['rgb(64,158,255)','orange'], color: ["rgb(64,158,255)", "orange"],
series: { series: {
name: '6车间完成率', name: "6车间完成率",
type: 'pie', type: "pie",
radius: ['40%', '70%'], radius: ["40%", "70%"],
center: ['50%', '60%'], center: ["50%", "60%"],
label: { label: {
show: true, show: true,
position: 'outside', position: "outside",
formatter: '{b} : {c} ({d}%)', formatter: "{b} : {c} ({d}%)",
}, },
// labelLayout: { // labelLayout: {
// verticalAlign: "bottom", // verticalAlign: "bottom",
@ -213,15 +257,15 @@
// }, // },
// }, // },
data: [ data: [
{value: 0, name: '已完成'}, { value: 0, name: "已完成" },
{value: 0, name: '未完成'}, { value: 0, name: "未完成" },
] ],
} },
}, },
tableData1: [], tableData1: [],
tableData2: [], tableData2: [],
tableData3: [], tableData3: [],
} };
}, },
mounted() { mounted() {
let that = this; let that = this;
@ -230,13 +274,14 @@
let month = date.getMonth() + 1; let month = date.getMonth() + 1;
let days = new Date(year, month, 0).getDate(); let days = new Date(year, month, 0).getDate();
this.currentYear = year; this.currentYear = year;
this.currentMonth = month>9?month:'0'+month; this.currentMonth = month > 9 ? month : "0" + month;
this.start_date =year+'-'+month+'-01'; this.start_date = year + "-" + month + "-01";
this.end_date = year+'-'+month+'-'+new Date(year, month, 0).getDate(); this.end_date =
let month1 = month>9?month:'0'+month; year + "-" + month + "-" + new Date(year, month, 0).getDate();
this.queryDate = year+'-'+month1; let month1 = month > 9 ? month : "0" + month;
let height= document.getElementById('elMain').clientHeight-40; this.queryDate = year + "-" + month1;
let chartheight= document.getElementById('elCol').clientHeight; let height = document.getElementById("elMain").clientHeight - 40;
let chartheight = document.getElementById("elCol").clientHeight;
that.tableHeight = height - chartheight; that.tableHeight = height - chartheight;
this.getData6(); this.getData6();
this.getData7(); this.getData7();
@ -244,7 +289,7 @@
}, },
methods: { methods: {
queryTypeChange() { queryTypeChange() {
this.queryDate = ''; this.queryDate = "";
}, },
getData7() { getData7() {
let that = this; let that = this;
@ -253,18 +298,20 @@
that.option1.series.data[1].value = 0; that.option1.series.data[1].value = 0;
let obj = {}; let obj = {};
obj.page = 0; obj.page = 0;
obj.mgroup__belong_dept__name = '7车间'; obj.mgroup__belong_dept__name = "7车间";
obj.start_date__gte = this.start_date; obj.start_date__gte = this.start_date;
obj.end_date__lte = this.end_date; obj.end_date__lte = this.end_date;
that.$API.pm.utask.list.req(obj).then((res) => { that.$API.pm.utask.list.req(obj).then((res) => {
console.log('utask:',res); console.log("utask:", res);
let data = []; let data = [];
let count_ok1 = 0; let count_ok1 = 0;
let count_notok1 = 0; let count_notok1 = 0;
if (res.length > 0) { if (res.length > 0) {
res.forEach(item => { res.forEach((item) => {
let obj = item; let obj = item;
obj.rate = (item.count_ok/item.count*100).toFixed(2)+'%'; obj.rate =
Math.round((item.count_ok / item.count) * 100) +
"%";
if (item.count_ok >= item.count) { if (item.count_ok >= item.count) {
count_ok1++; count_ok1++;
} else { } else {
@ -272,12 +319,11 @@
} }
data.push(obj); data.push(obj);
}); });
that.tableData1 = data that.tableData1 = data;
that.option1.series.data[0].value = count_ok1; that.option1.series.data[0].value = count_ok1;
} }
this.option1.series.data[0].value = count_ok1; this.option1.series.data[0].value = count_ok1;
this.option1.series.data[1].value = count_notok1; this.option1.series.data[1].value = count_notok1;
}); });
}, },
async getData10() { async getData10() {
@ -287,18 +333,20 @@
that.option2.series.data[1].value = 0; that.option2.series.data[1].value = 0;
let obj = {}; let obj = {};
obj.page = 0; obj.page = 0;
obj.mgroup__belong_dept__name = '10车间'; obj.mgroup__belong_dept__name = "10车间";
obj.start_date__gte = this.start_date; obj.start_date__gte = this.start_date;
obj.end_date__lte = this.end_date; obj.end_date__lte = this.end_date;
await that.$API.pm.utask.list.req(obj).then((res) => { await that.$API.pm.utask.list.req(obj).then((res) => {
console.log('utask:',res); console.log("utask:", res);
let data = []; let data = [];
let count_ok2 = 0; let count_ok2 = 0;
let count_notok2 = 0; let count_notok2 = 0;
if (res.length > 0) { if (res.length > 0) {
res.forEach(item => { res.forEach((item) => {
let obj = item; let obj = item;
obj.rate = (item.count_ok/item.count*100).toFixed(2)+'%'; obj.rate =
Math.round((item.count_ok / item.count) * 100) +
"%";
if (item.count_ok >= item.count) { if (item.count_ok >= item.count) {
count_ok2++; count_ok2++;
} else { } else {
@ -319,18 +367,20 @@
that.option3.series.data[1].value = 0; that.option3.series.data[1].value = 0;
let obj = {}; let obj = {};
obj.page = 0; obj.page = 0;
obj.mtask_utask__mgroup__belong_dept__name = '6车间'; obj.mtask_utask__mgroup__belong_dept__name = "6车间";
obj.start_date__gte = this.start_date; obj.start_date__gte = this.start_date;
obj.end_date__lte = this.end_date; obj.end_date__lte = this.end_date;
await that.$API.pm.utask.list.req(obj).then((res) => { await that.$API.pm.utask.list.req(obj).then((res) => {
console.log('utask:',res); console.log("utask:", res);
let data = []; let data = [];
let count_ok3 = 0; let count_ok3 = 0;
let count_notok3 = 0; let count_notok3 = 0;
if (res.length > 0) { if (res.length > 0) {
res.forEach(item => { res.forEach((item) => {
let obj = item; let obj = item;
obj.rate = (item.count_ok/item.count*100).toFixed(2)+'%'; obj.rate =
Math.round((item.count_ok / item.count) * 100) +
"%";
if (item.count_ok >= item.count) { if (item.count_ok >= item.count) {
count_ok3++; count_ok3++;
} else { } else {
@ -338,29 +388,42 @@
} }
data.push(obj); data.push(obj);
}); });
that.tableData3= data that.tableData3 = data;
that.option3.series.data[0].value = count_ok3; that.option3.series.data[0].value = count_ok3;
that.option3.series.data[1].value = count_notok3; that.option3.series.data[1].value = count_notok3;
} }
}); });
}, },
handleQuery() { handleQuery() {
if(this.queryDate!==''&&this.queryDate!==null){ if (this.queryDate !== "" && this.queryDate !== null) {
if(this.queryType=='月'){ if (this.queryType == "月") {
this.start_date =this.queryDate+'-01'; this.start_date = this.queryDate + "-01";
let arr = this.queryDate.split('-'); let arr = this.queryDate.split("-");
this.end_date = this.queryDate+'-'+new Date(arr[0], arr[1], 0).getDate(); this.end_date =
this.queryDate +
"-" +
new Date(arr[0], arr[1], 0).getDate();
} else { } else {
this.start_date = this.queryDate+'-01-01'; this.start_date = this.queryDate + "-01-01";
this.end_date = this.queryDate+'-12-31'; this.end_date = this.queryDate + "-12-31";
} }
} else { } else {
if(this.queryType=='月'){ if (this.queryType == "月") {
this.start_date =this.currentYear+'-'+this.currentMonth+'-01'; this.start_date =
this.end_date = this.currentYear+'-'+this.currentMonth+'-'+new Date(this.currentYear, this.currentMonth, 0).getDate(); this.currentYear + "-" + this.currentMonth + "-01";
this.end_date =
this.currentYear +
"-" +
this.currentMonth +
"-" +
new Date(
this.currentYear,
this.currentMonth,
0
).getDate();
} else { } else {
this.start_date = this.currentYear+'-01-01'; this.start_date = this.currentYear + "-01-01";
this.end_date = this.currentYear+'-12-31'; this.end_date = this.currentYear + "-12-31";
} }
} }
this.getData6(); this.getData6();
@ -369,13 +432,13 @@
}, },
handleExport(val) { handleExport(val) {
this.exportLoading = true; this.exportLoading = true;
let id = '#exportDiv' + val; let id = "#exportDiv" + val;
let name = val+'车间完成率'; let name = val + "车间完成率";
this.$XLSX(id, name); this.$XLSX(id, name);
this.exportLoading = false; this.exportLoading = false;
}, },
}, },
} };
</script> </script>
<style scoped> <style scoped>