factory_web/src/views/bigScreen/gxerp/index_jingdiao.vue

715 lines
17 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<el-container class="dashboard">
<el-header class="header">
<div class="title">精雕车间生产数据看板</div>
<div class="timer">{{ currentDay }} {{ currentTime }}</div>
</el-header>
<el-main>
<!-- 精雕 -->
<el-row style="height: 60%" :gutter="10">
<el-col :span="12" style="height: 100%">
<!-- 设备状态 -->
<el-col style="height: 50%">
<div class="box">
<div class="boxtitle">
<div class="boxlabel">
设备状态
</div>
<div class="boxlabel">
<span class="stateIcon yxicon"></span>
<span>运行中</span>
<span class="eqNum">{{hh.yx}}</span>
</div>
<div class="boxlabel">
<span class="stateIcon wyxIcon"></span>
<span>未运行</span>
<span class="eqNum">{{hh.wyx}}</span>
</div>
<div class="boxlabel">
<span class="stateIcon gzIcon"></span>
<span>故障</span>
<span class="eqNum">{{hh.gz}}</span>
</div>
</div>
<div style="height: 2px"></div>
<div class="boxmain" id="scrollContainer">
<dv-scroll-board :config="configDataEq" style="width:98%;margin:auto" />
</div>
</div>
</el-col>
<!-- 库存 -->
<el-col style="height: 50%">
<div class="box">
<div class="boxtitle">
<div class="boxlabel">
精雕车间库存
</div>
</div>
<div style="height: 2px"></div>
<div class="boxmain" id="scrollContainer">
<dv-scroll-board :config="configDataInm" style="width:98%;margin:auto" />
</div>
</div>
</el-col>
</el-col>
<el-col :span="12" style="height: 100%">
<div class="box">
<div class="boxtitle">
<div class="boxlabel">生产数统计</div>
</div>
<div class="totalStatic">
<span class="totalStaticItem">日投产量</span>
<span class="totalStaticItem">日加工数</span>
<span class="totalStaticItem">日加工前不良</span>
<span class="totalStaticItem">日合格数</span>
<span class="totalStaticItem">日不合格数</span>
</div>
<div class="totalStatic">
<span class="totalStaticItem totalStaticItemNum">{{ sctj.rtcs }}</span>
<span class="totalStaticItem totalStaticItemNum">{{ sctj.rjgs }}</span>
<span class="totalStaticItem totalStaticItemNum">{{ sctj.rjgqbls }}</span>
<span class="totalStaticItem totalStaticItemNum">{{ sctj.rhgs }}</span>
<span class="totalStaticItem totalStaticItemNum">{{ sctj.rbhgs }}</span>
</div>
<dv-scroll-board :config="configDatas" class="boxmain boxmainTopRight" style="width:98%;margin:auto" />
</div>
</el-col>
</el-row>
<div style="height: 0.3%"></div>
<!-- 生产统计 分析 -->
<div style="height: 0.3%"></div>
<el-row style="height: 39%" :gutter="10">
<!-- 折线图 日加工数日合格数日合格率近七天数据 -->
<el-col :span="12" style="height: 100%;">
<div class="box">
<div class="boxtitle">
<div class="boxlabel">合格数统计</div>
</div>
<div class="boxmain boxmainbottom" id="chart1"></div>
</div>
</el-col>
<!-- 饼状图 各不合格品 原因占比 -->
<el-col :span="12" style="height: 100%;">
<div class="box">
<div class="boxtitle">
<div class="boxlabel">不合格占比统计</div>
</div>
<div class="boxmain boxmainbottom" id="chart2"></div>
</div>
</el-col>
</el-row>
</el-main>
</el-container>
</template>
<script>
import * as echarts from "echarts";
import scScrollTavle from "@/components/scScrollTable.vue";
function deepCopy(obj) {
return JSON.parse(JSON.stringify(obj));
}
export default {
components: { scScrollTavle },
data() {
return {
barOption: {
backgroundColor: "",
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
label: {
backgroundColor: "#6a7985",
},
},
},
legend: {
icon: "stack",
right: 0,
},
grid: {
left: "3%",
right: "2%",
bottom: "3%",
containLabel: true,
},
xAxis: {
type: "category",
boundaryGap: true,
data: [],
nameTextStyle: {
color: "#ffffff",
},
axisLabel: {
color: "#ffffff",
},
},
yAxis: {
name: "",
type: "value",
nameTextStyle: {
color: "#ffffff",
},
axisLabel: {
color: "#ffffff",
},
splitLine: {
show: false,
lineStyle: {
type: "dashed", //y轴分割线类型
color: "rgba(102,102,102,0.9)",
width: 1,
},
},
},
series: [
{
name: "加工数",
type: "bar",
barWidth: 10,
emphasis: {
focus: "series",
},
label: {
show: true,
position: "top",
color: "#fff",
},
data: [],
},
{
name: "合格数",
type: "bar",
barWidth: 10,
emphasis: {
focus: "series",
},
label: {
show: true,
position: "top",
color: "#fff",
},
data: [],
},
{
name: "合格率",
type: "bar",
barWidth: 10,
emphasis: {
focus: "series",
},
label: {
show: true,
position: "top",
color: "#fff",
},
data: [],
},
],
},
pieOption: {
backgroundColor: "",
tooltip: {
trigger: 'item'
},
legend: {
icon: "stack",
right: 0,
orient: 'vertical',
itemWidth: 12,
itemHeight: 12,
textStyle: {
color: '#fff',
fontSize: 11,
},
},
series: {
name: '不合格占比',
type: 'pie',
radius: ['1%', '60%'],
center: ['35%', '50%'],
label: false,
data: []
}
},
tableHeight: 100,
speed: 2000,
time: null,
hh:{
yx:0,
wyx:0,
gz:0,
},
sctj:{
rtcs:0,
rjgs:0,
rjgqbls:0,
rhgs:0,
rbhgs:0,
},
dayInterval: null,
chartInterval1: null,
chartInterval2: null,
//库存
configDataInm:{
header:['物料名称','批次号','数量','生产中'],
headerBGC:'#0a3f44',
headerHeight:40,
align:'center',
data:[],
waitTime:1000,
},
//设备
configDataEq:{
headerBGC:'#0a3f44',
header:['设备名称','设备编号','设备状态','生产进度','物料数量'],
headerHeight:40,
data:[]
},
//生产统计
configDatas :{
headerBGC:'#0a3f44',
header:['日期','加工数','合格数','不合格数'],
headerHeight:40,
data:[]
},
page:1,
currentTime: "",
currentDay: "",
today: "",
end_time:'',
start_time:'',
mgroups:[],
daysList:[],
};
},
mounted() {
let that = this;
that.page = 1;
that.configDataInm.data = [];
//表格table的高度
this.tableHeight = document.getElementById("scrollContainer").clientHeight;
this.showTime();
this.dayInterval = setInterval(() => {
this.showTime();
}, 1000);
//近七天的日期数组
let daysArr = this.getMondayOfCurrentWeek();
this.daysArr = daysArr;
let xAxisData = [];
daysArr.forEach((item)=>{
let dates = item.split('-');
let obj = dates[1]+'-'+dates[2];
xAxisData.push(obj);
let dayitem = Number(dates[2]);
that.daysList.push(dayitem);
})
that.today = new Date().toISOString().split('T')[0]
this.xAxisData = xAxisData;
let startDate = new Date(daysArr[0]).getTime()-(1000*60*60*24);
let endDate = new Date(daysArr[6]).getTime()+(1000*60*60*24);
let start_time = this.$TOOL.dateFormat(new Date(startDate), "yyyy-MM-dd");
let end_time = this.$TOOL.dateFormat(new Date(endDate), "yyyy-MM-dd");
this.start_time = start_time;
this.end_time = end_time;
this.$nextTick(() => {
this.$API.mtm.mgroup.list.req({page:0,belong_dept__name:'精雕车间'}).then((res) => {
that.mgroups = res;
that.configDataEq.data = [];
res.forEach((item)=>{
//设备数据
that.getEqState(item.id);
})
})
this.getMaterials(that.page);
//投产/生产分析
this.getProductLine();
this.getCountnotok();
})
},
methods: {
getMondayOfCurrentWeek() {
let today = new Date();
let days = [];
for (let i = 6; i >= 0; i--) {
let date = new Date(today);
date.setDate(today.getDate() - i);
days.push(date.toISOString().split('T')[0]); // 格式化为 YYYY-MM-DD
}
return days;
},
//时间
showTime() {
this.currentTime = this.$TOOL.dateFormat(new Date(), "hh:mm:ss");
this.currentDay = this.$TOOL.dateFormat(
new Date(),
"yyyy年MM月dd日"
);
},
setChart(name, option = null) {
var myChart = echarts.getInstanceByDom(document.getElementById(name));
if (myChart == undefined) {
myChart = echarts.init(document.getElementById(name), "dark", {
renderer: "svg",
});
}
if (option == null) {
option = Object.assign({}, this.barOption);
}
setTimeout(() => {
try {
myChart.setOption(option);
} catch (error) {}
}, 500);
return myChart;
},
//生产统计
getProductLine() {
let that = this;
let obj = {
query: {start_date: that.start_time,end_date: that.end_time,dept_name:'精雕车间'},
};
that.$API.bi.dataset.exec.req("lineDay", obj).then((res) => {
let list = res.data2.ds0;
let seriesData0 = [],seriesData1 = [],seriesData2 = [];
for (let i = 0; i < that.xAxisData.length; i++) {
seriesData0[i] = 0;seriesData1[i] = 0;seriesData2[i] = 0;
}
if (list.length > 0) {
list.forEach((item) => {
let dateNow = new Date().getDate();
if(item. == dateNow){
that.sctj.rtcs = item.总重量;
that.sctj.rjgs = item.生产数;
that.sctj.rjgqbls = item.生产数-item.不合格数-item.合格数;
that.sctj.rhgs = item.合格数;
that.sctj.rbhgs = item.不合格数;
}
let arr = [];
arr[0] = item.+'-'+item.+'-'+item.;
arr[1] = item.生产数;
arr[2] = item.合格数;
arr[3] = item.不合格数;
that.configDatas.data.push(arr);
let indexs = that.daysList.indexOf(item.);
seriesData0[indexs] = item.生产数;
seriesData1[indexs] = item.合格数;
seriesData2[indexs] = item.合格率;
});
}
that.barOption.xAxis.data = that.xAxisData;
that.barOption.series[0].data = seriesData0;
that.barOption.series[1].data = seriesData1;
that.barOption.series[2].data = seriesData2;
let chart1 = this.setChart("chart1", that.barOption);
let index1 = 0;
this.chartInterval1 = setInterval(function () {
if (index1 < that.barOption.series[0].data.length) {
chart1.dispatchAction({
type: "downplay",
seriesIndex: 0,
});
chart1.dispatchAction({
type: "highlight",
seriesIndex: 0,
dataIndex: index1,
});
chart1.dispatchAction({
type: "showTip",
seriesIndex: 0,
dataIndex: index1,
});
index1++;
} else {
index1 = 0;
}
}, 3000);
});
},
//不合格分布
getCountnotok(){
let that = this;
let obj = {query:{start_date:that.start_time,end_date:that.end_time}};
that.$API.bi.dataset.exec.req('notok_dis', obj).then((res) => {
let seriesData = [];
if(res.data2.ds0){
res.data2.ds0.forEach((item) => {
let obj = {};
obj.name = item.不合格项;
obj.value = item.数量;
seriesData.push(obj);
})
}
that.pieOption.series.data = seriesData;
let index2 = 0;
let chart2 = this.setChart("chart2", that.pieOption);
this.chartInterval2 = setInterval(function () {
if (index2 < that.barOption.series[0].data.length) {
chart2.dispatchAction({
type: "downplay",
seriesIndex: 0,
});
chart2.dispatchAction({
type: "highlight",
seriesIndex: 0,
dataIndex: index2,
});
chart2.dispatchAction({
type: "showTip",
seriesIndex: 0,
dataIndex: index2,
});
index2++;
} else {
index2 = 0;
}
}, 3000);
})
},
//设备状态
getEqState(id) {
let that = this;
that.$API.wpm.ana.equipLastMlog.req({mgroup:id}).then((res) => {
that.hh.bw = res.保温;
that.hh.lq = res.冷却;
that.hh.yx = res.运行;
that.hh.wyx = res.未运行;
that.hh.gz = res.故障;
let nowTime = new Date(res.now).getTime();
if(res.rows.length>0){
res.rows.forEach((item) => {
let arr = [];
arr[0] = item.name;
arr[1] = item.number;
if(item.mstate=='冷却'){
arr[2] = '<span style="color:rgb(0,163,245)">运行中</span>';
}else if(item.mstate=='未运行'){
arr[2] = '<span style="color:rgb(69,176,118)">未运行</span>';
}else if(item.mstate=='故障'){
arr[2] = '<span style="color:rgb(222,60,54)">故障</span>';
}
let process = null, workTime =0,saveTime=null,sumTime=0;
if(item.reminder_interval_list&&item.reminder_interval_list.length>0){
item.reminder_interval_list.forEach(item=>{
sumTime += item;
})
let startTime = new Date(item.work_start_time).getTime();
workTime = (nowTime-startTime)/60000;//已工作时间
process = Math.round((workTime/sumTime)*100);
process = process>100?'100%':process+'%';
let bwSaveTime = Math.round(item.reminder_interval_list[0]-workTime);
if(bwSaveTime>0){
saveTime = bwSaveTime;
}else{
saveTime = 0;
}
}else{
process = '';
saveTime = '';
}
arr[3] = process;
arr[4] = item.t_count_use?item.t_count_use:0;
that.configDataEq.data.push(arr);
});
}
});
},
//库存统计列表
getMaterials(page) {
let that = this;
that.$API.wpm.wmaterial.list.req({ page: page,page_size:500,mgroup__name__in:'精雕' }).then((res) => {
if(res.results.length>0){
res.results.forEach((item) => {
let arr = [];
arr[0] = item.material_name;
arr[1] = item.batch;
arr[2] = item.count;
arr[3] = item.count_working;
that.configDataInm.data.push(arr);
})
if(res.count>that.configDataInm.data.length){
that.page++;
that.getMaterials(that.page);
}
}
})
},
},
};
</script>
<style scoped>
@font-face {
font-family: "myfont";
src: url("../../../utils/youShe.ttf");
}
.dashboard {
background-image: url("/public/img/photon_bg.png");
color: #fff;
font-family: "Microsoft Yahei" !important;
background-size: cover;
}
.header {
background: url("/public/img/photon_header.png");
border-bottom: none;
background-size: 100% 100%;
font-size: 26px;
display: block;
height: 80px;
color: rgb(149, 255, 255);
font-family: "Microsoft Yahei";
text-align: center;
padding: 12px 0px;
}
.header > .title {
font-weight: bold;
font-family: "myfont";
font-size: 32px;
}
.header > .timer {
font-size: 14px;
margin-top: 18px;
}
.box {
background: rgba(10, 63, 68, 0.5);
height: 100%;
}
.boxtitle {
color: #fff;
font-size: 16px;
display: flex;
height: 36px;
line-height: 36px;
background: linear-gradient(
40deg,
rgba(11, 101, 140, 0.451),
rgba(0, 34, 48, 0.335),
rgba(11, 101, 140, 0.451)
);
}
.bgimg {
background-image: url("https://cdn-upload.datav.aliyun.com/upload/download/1678762309227-E6RP8z2R.png");
background-size: 140% 100%;
}
.boxlabel {
margin-left: 6px;
font-size: 18px;
/* margin-top: 6px; */
}
.stateIcon{
width:16px;
height: 16px;
margin: 0 5px;
border-radius: 8px;
display: inline-block;
}
.bwIcon{
background-color: rgb(245, 196, 0);
}
.lqIcon,.yxicon{
background-color: rgb(0,163,245);
}
.wyxIcon{
background-color: rgb(69,176,118);
}
.gzIcon{
background-color: rgb(222,60,54);
}
.eqNum{
margin: 0 10px;
}
.boxmain {
height: calc(100% - 50px);
}
.boxmain.boxmainbottom{
height: calc(100% - 38px);
}
.boxmain.boxmainTopRight{
height: calc(100% - 120px);
}
.lineDiv {
height: 40px;
line-height: 40px;
padding-left: 0.5em;
}
.boxmainItemNumber {
color: rgb(42,234,200);
margin-left: 10px;
font-weight: bold;
font-face:24px;
font-family: electronicFont;
}
@media screen and (max-width: 800px) {
.boxmain {
height: 200px;
}
}
.flex_center {
display: flex;
align-items: center;
justify-content: center;
}
.border {
border: 1px dashed #49bcf7;
}
.bigdata {
font-size: 20px;
}
.title {
height: 40px;
line-height: 40px;
text-align: center;
}
.marquee_top {
transition: all 0.5s ease-in-out;
margin-top: -26px;
}
.totall {
color: #fff;
background-color: rgb(10, 63, 68);
}
.rollData {
background-color: rgb(10, 39, 50);
}
.rollData:nth-of-type(2n + 1) {
background-color: rgb(0, 59, 81);
}
.halfBox {
height: 50%;
}
.totalStatic{
display: flex;
}
.totalStaticItem{
flex: 1;
height: 25px;
text-align: center;
line-height: 25px;
font-size: 14px;
margin-top: 5px;
}
.totalStaticItemNum{
font-size: 24px;
height: 40px;
line-height: 40px;
font-family: "myfont";
text-align: center;
margin-top: 0;
color: rgb(149, 255, 255);
}
</style>