<template>
|
<view>
|
<view class="container" style="display: flex; flex-direction: row; flex-wrap: nowrap; align-content: flex-start; justify-content: flex-start;">
|
<!--主界面-->
|
<!-- 上部:工单选择和机台信息 -->
|
<view class="top-order" style="display:inline-block;">
|
<view class="form-row4">
|
<view class="form-row" style="display: flex; flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; align-items: center;">
|
<view class="form-item">
|
<label>工单编号:</label>
|
<input class="inp" type="text" v-model="order.daa001" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>刀具名称:</label>
|
<input class="inp" type="text" v-model="order.cutterName" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>工单数量:</label>
|
<input class="inp" type="text" v-model="order.daa008" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>开工数采:</label><!--开工数采-->
|
<input class="inp" type="text" v-model="order.startCjNum" disabled="true" /><!-- 修改为 startCjNum -->
|
</view>
|
</view>
|
<view class="form-row3">
|
<view class="form-item">
|
<label>产品名称:</label>
|
<!--<input class="inp" type="text" v-model="order.daa003" disabled="true" />-->
|
<superwei-combox :candidates="DAA003List" v-model="order.daa003" @select="onDaa003Change"
|
class="inp" style="font-size: 20px;"></superwei-combox>
|
</view>
|
<view class="form-item">
|
<label>刀具编号:</label><!--刀具编号???-->
|
<input class="inp" type="text" v-model="order.cutterId" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>刀具规格:</label><!--刀具规格???-->
|
<input class="inp" type="text" v-model="order.cutterModel" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>当前数采:</label><!--当前数采-->
|
<input class="inp" type="text" v-model="order.currentCjNum" disabled="true" /><!-- 修改为 currentCjNum -->
|
</view>
|
</view>
|
<view class="form-row3">
|
<view class="form-item">
|
<label>产品编码:</label>
|
<input class="inp" type="text" v-model="order.daa002" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>产品规格:</label>
|
<input class="inp" type="text" v-model="order.daa004" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>报工数量:</label>
|
<input class="inp" type="text" v-model="order.daa011" disabled="true" />
|
</view>
|
</view>
|
</view>
|
</view>
|
<view class="form-row1">
|
<view class="form-item" style="display:inline-block;">
|
<label>工单状态:</label>
|
<input class="inp1" type="text" v-model="order.daa018" disabled="true" />
|
<!-- 刷新按钮 -->
|
<button @click="handleRefresh" class="refresh-btn">刷新</button>
|
</view>
|
<view class="form-item">
|
<label>机台编号:</label>
|
<input class="inp2" type="text" v-model="order.machineNo" disabled="true" />
|
</view>
|
</view>
|
</view>
|
|
<!-- 中部:运行状态 -->
|
<view class="section card">
|
<view class="status-row">
|
<view class="form-item">
|
<label style="color: red;">日停机次数(时长超3分钟):</label>
|
<input class="inp" type="number" v-model="order.todayDowntimeCount" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>日停机时长(mi):</label>
|
<input class="inp" type="text" :value="downtimeDuration" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>设备稼动率:</label>
|
<input class="inp" type="text" v-model="utilizationRate" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>生产开始时间:</label>
|
<input class="inp" type="text" v-model="startTime" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>生产结束时间:</label>
|
<input class="inp" type="text" v-model="endTime" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>生产时长(mi):</label>
|
<input class="inp" type="text" v-model="productionDuration" disabled="true" />
|
</view>
|
</view>
|
</view>
|
|
<!-- 下部:品质检验 -->
|
<view class="section card">
|
<view class="quality-row">
|
<view class="form-item">
|
<label>最近首检时间:</label>
|
<input class="inp" type="text" v-model="lastInitialCheck" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>首检结论:</label>
|
<input class="inp" type="text" v-model="initialConclusion" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>首检人员:</label>
|
<input class="inp" type="text" v-model="initialInspector" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>首检次数:</label>
|
<input class="inp" type="number" v-model="initialCount" disabled="true" />
|
</view>
|
</view>
|
<view class="quality-row">
|
<view class="form-item">
|
<label>最近巡检时间:</label>
|
<input class="inp" type="text" v-model="lastPatrolCheck" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>巡检结论:</label>
|
<input class="inp" type="text" v-model="patrolConclusion" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>巡检人员:</label>
|
<input class="inp" type="text" v-model="patrolInspector" disabled="true" />
|
</view>
|
<view class="form-item">
|
<label>巡检次数:</label>
|
<input class="inp" type="number" v-model="patrolCount" disabled="true" />
|
</view>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
export default {
|
name: "WorkOrder",
|
props: {
|
orderNo: String,
|
orderId: Number,
|
deviceNumber: String,
|
machineNo: String,
|
},
|
data() {
|
return {
|
order: {},
|
orderStatus: '开工',
|
|
collectedAmount: 0,
|
todayFaultNum: 0,
|
todayRunTime: '',
|
utilizationRate: '',
|
startTime: '',
|
endTime: '',
|
productionDuration: '',
|
lastInitialCheck: '',
|
initialConclusion: '',
|
initialInspector: '',
|
initialCount: 0,
|
lastPatrolCheck: '',
|
patrolConclusion: '',
|
patrolInspector: '',
|
patrolCount: 0,
|
timer: null,
|
|
DAA003List: [],
|
lineList: [],
|
};
|
},
|
computed: {
|
// 日停机时长 = todayOnlineTime - todayRunTime
|
downtimeDuration() {
|
// 取order对象中的todayOnlineTime和todayRunTime,都为分钟
|
const online = Number(this.order.todayOnlineTime) || 0;
|
const run = Number(this.order.todayRunTime) || 0;
|
return online - run;
|
}
|
},
|
created() {
|
this.fetchData(true);
|
this.sumbit();
|
this.init();
|
},
|
mounted() {
|
this.fetchData(false);
|
this.timer = setInterval(this.fetchData, 120000);
|
},
|
beforeDestroy() {
|
clearInterval(this.timer);
|
},
|
methods: {
|
init() {
|
this.$post({
|
url: "/MesOrderSta/init",
|
data: {
|
orderId: this.orderId,
|
orderNo: this.orderNo,
|
machineNo: this.machineNo
|
}
|
}).then(res => {
|
this.findByOrderId();
|
});
|
|
this.$post({
|
url: "/MesOrderSelect/AddMesOrderSelect",
|
data: {
|
machineNo: this.machineNo,
|
}
|
}).then(res => {
|
|
})
|
},
|
// 添加刷新按钮的处理方法
|
handleRefresh() {
|
this.$sendPostRequest({
|
url: "http://192.168.0.94:9095/Numerical/RefreshDev",
|
data: {
|
machineNo: this.order.machineNo
|
},
|
contentType: "application/json"
|
}).then(res1 => {
|
if (res1.code == 200) {
|
this.fetchData(true); // 重新请求数据
|
this.sumbit(); // 重新提交相关数据
|
} else {
|
this.$showMessage("同步失败");
|
}
|
});
|
},
|
onDaa003Change(event) {
|
let orde = this.lineList[this.DAA003List.indexOf(event)];
|
this.orderId = orde.id;
|
this.orderNo = orde.daa001;
|
//切换为新的id
|
uni.setStorageSync('machine', this.machineNo);
|
uni.setStorageSync('orderId', this.orderId);
|
uni.setStorageSync('orderNo', this.orderNo);
|
this.fetchData(false);
|
this.sumbit();
|
},
|
sumbit() {
|
this.$post({
|
url: "/MesOrderSta/FindByOrderNo",
|
data: {
|
orderId: this.orderId,
|
orderNo: this.orderNo
|
}
|
}).then(res => {
|
let statusForm = res.data.tbBillList;
|
this.startTime = res.data.tbBillList.startTime;
|
this.endTime = res.data.tbBillList.endTime;
|
this.productionDuration = "0m";
|
if (this.startTime) {
|
let date1 = new Date(this.startTime);
|
let date2 = new Date();
|
if (this.endTime) {
|
date2 = new Date(this.endTime);
|
}
|
// 计算两个日期之间的差异(以毫秒为单位)
|
let differenceInMilliseconds = date2 - date1;
|
this.productionDuration = (differenceInMilliseconds / 60000).toFixed(2);
|
}
|
|
// this.$post({
|
// url: "/MesOrderSta/Binding",
|
// data: {
|
// id: statusForm.id,
|
// orderId: this.orderId,
|
// machineNo: this.machineNo
|
// }
|
// }).then(res1 => {
|
|
// })
|
});
|
},
|
fetchData(flag) {
|
//let machine = uni.getStorageSync('machine');
|
// let orderId = uni.getStorageSync('orderId');
|
// let orderNo = uni.getStorageSync('orderNo');
|
|
// if (orderId) {
|
// this.orderId = orderId;
|
// } else {
|
// if (!this.orderId) {
|
// this.orderId = uni.getStorageSync('id');
|
// }
|
|
// }
|
|
// if (orderNo) {
|
// this.orderNo = orderNo;
|
// } else {
|
// if (!this.orderNo) {
|
// this.orderNo = uni.getStorageSync('daa001');
|
// }
|
// }
|
|
// if (machine) {
|
// this.machineNo = machine;
|
// } else {
|
// if (!this.machineNo) {
|
// this.machineNo = uni.getStorageSync('machineNo');
|
// }
|
// }
|
|
if (!this.orderId && !this.orderNo) {
|
return;
|
}
|
this.getOrderById();
|
this.getSJByOrder();
|
this.getXJByOrder();
|
if (flag) {
|
this.$post({
|
url: "/Womdaa/GetWomdaasByShow",
|
data: {
|
machineNo: this.machineNo
|
}
|
}).then(res => {
|
this.lineList = res.data.tbBillList;
|
this.DAA003List = res.data.tbBillList.map(item => item.daa003);
|
})
|
}
|
},
|
formatDate(date) {
|
let year = date.getFullYear(); // 获取年份
|
let month = String(date.getMonth() + 1).padStart(2, '0'); // 获取月份并补零
|
let day = String(date.getDate()).padStart(2, '0'); // 获取日期并补零
|
return `${year}-${month}-${day}`; // 返回格式化后的字符串
|
},
|
getOrderById() {
|
this.$post({
|
url: "/Womdaa/GetWomdaaById",
|
data: {
|
orderId: this.orderId,
|
orderNo: this.orderNo
|
}
|
}).then(res => {
|
if (res.data.tbBillList == null) {
|
this.$showMessage("工单不存在或者未开工,请检查");
|
// 保证order为对象,避免模板报错
|
this.order = {
|
daa001: '',
|
moldId: '',
|
daa008: '',
|
daa004: '',
|
daa003: '',
|
daa002: '',
|
daa005: '',
|
daa011: '',
|
daa018: '',
|
machineNo: '',
|
engineeringNo: '',
|
todayOutput: 0,
|
todayRunTime: '',
|
todayFaultNum: 0,
|
cutterId, //刀具代码
|
cutterName, //刀具名称
|
cutterModel, //刀具规格
|
jdl: '',
|
startCjNum: 0, // 开工数采
|
currentCjNum: 0, // 当前数采
|
todayDowntimeCount //今日停机次数
|
};
|
return;
|
}
|
this.order = res.data.tbBillList;
|
// 兼容后端大小写(如果后端返回 StartCjNum/CurrentCjNum)
|
this.order.startCjNum = this.order.startCjNum ?? this.order.StartCjNum ?? 0; // 不删除原有注释行
|
this.order.currentCjNum = this.order.currentCjNum ?? this.order.CurrentCjNum ?? 0; // 不删除原有注释行
|
|
uni.setStorageSync('engineeringNo', this.order.engineeringNo);
|
this.orderStatus = this.order.daa018;
|
this.collectedAmount = this.order.todayOutput;
|
if (!this.order.todayOutput) {
|
this.collectedAmount = 0;
|
}
|
this.todayRunTime = this.order.todayRunTime;
|
if (!this.order.todayRunTime) {
|
this.todayRunTime = "0";
|
}
|
//this.productionDuration = (this.order.todayOnlineTime / 3600).toFixed(2) + "h";
|
this.todayFaultNum = this.order.todayFaultNum;
|
this.utilizationRate = this.order.jdl + '%';
|
let title = this.machineNo + '号机台 工单号' + this.order.daa001 + ',当前数采' + this.order.currentCjNum; // 标题中使用 currentCjNum
|
this.setTitle(title);
|
})
|
},
|
setTitle(title) {
|
// 修改页面标题的方法,uni-app中可以通过api直接设置当前页面的标题
|
uni.setNavigationBarTitle({
|
title: title
|
});
|
},
|
getSJByOrder() {
|
this.$post({
|
url: "/MesQaItemsDetect02/FindSJByOrderNo",
|
data: {
|
orderNo: this.orderNo
|
}
|
}).then(res => {
|
let sjList = res.data.tbBillList;
|
if (Array.isArray(sjList) && sjList.length > 0) {
|
let latest = sjList[0];
|
this.lastInitialCheck = latest.fcheckDate;
|
this.initialConclusion = latest.fcheckResu;
|
this.initialInspector = latest.fcheckBy; // 首检人员(工号-姓名)
|
this.initialCount = latest.xjCount ?? sjList.length; // 优先用xjCount字段
|
} else if (sjList) {
|
this.lastInitialCheck = sjList.fcheckDate;
|
this.initialConclusion = sjList.fcheckResu;
|
this.initialInspector = sjList.fcheckBy; // 首检人员(工号-姓名)
|
this.initialCount = sjList.xjCount ?? 1;
|
} else {
|
this.lastInitialCheck = '';
|
this.initialConclusion = '';
|
this.initialInspector = '';
|
this.initialCount = 0;
|
}
|
})
|
},
|
getXJByOrder() {
|
this.$post({
|
url: "/MesQaItemsDetect02/FindXJByOrderNo",
|
data: {
|
orderNo: this.orderNo
|
}
|
}).then(res => {
|
let xjList = res.data.tbBillList;
|
if (Array.isArray(xjList) && xjList.length > 0) {
|
let latest = xjList[0];
|
this.lastPatrolCheck = latest.fcheckDate;
|
this.patrolConclusion = latest.fcheckResu;
|
this.patrolInspector = latest.fcheckBy; // 巡检人员(工号-姓名)
|
this.patrolCount = latest.xjCount ?? xjList.length;
|
} else if (xjList) {
|
this.lastPatrolCheck = xjList.fcheckDate;
|
this.patrolConclusion = xjList.fcheckResu;
|
this.patrolInspector = xjList.fcheckBy; // 巡检人员(工号-姓名)
|
this.patrolCount = xjList.xjCount ?? 1;
|
} else {
|
this.lastPatrolCheck = '';
|
this.patrolConclusion = '';
|
this.patrolInspector = '';
|
this.patrolCount = 0;
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style>
|
.top-order {
|
margin-bottom: 1vh;
|
}
|
|
.refresh-btn {
|
position: absolute;
|
top: -11px;
|
right: 21px;
|
cursor: pointer;
|
float: right;
|
background-color: #00A2E9;
|
color: white;
|
border: none;
|
font-size: 29px;
|
border-radius: 15px;
|
margin-top: 9px;
|
margin-bottom: 20px;
|
padding-left: 25px;
|
padding-right: 25px;
|
}
|
|
.refresh-btn:hover {
|
background-color: #00A2E9;
|
}
|
|
.form-row {
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 1.5vh;
|
}
|
|
.form-item {
|
width: 100%;
|
padding: 4px;
|
margin: 10px 10px;
|
}
|
|
.inp {
|
float: left;
|
width: 63%;
|
padding: 0.5vh;
|
border: 1px solid #ccc;
|
border-radius: 0.5vw;
|
margin-top: 0.3vh;
|
font-size: 1.3vw;
|
}
|
|
.status-block p {
|
margin: 1vh 0;
|
font-size: 1.5vw;
|
font-weight: bold;
|
}
|
|
.card {
|
background-color: #fff;
|
border-radius: 0.8vw;
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
padding: 1.5vh;
|
border: 1px solid black;
|
margin-top: -1vh;
|
margin-bottom: 2vh;
|
font-size: 1.5vw;
|
}
|
|
.card-header {
|
position: absolute;
|
top: -1vh;
|
left: 2vw;
|
background-color: #ffffff;
|
padding: 0.5vh 1vw;
|
border-radius: 0.5vw;
|
font-weight: bold;
|
font-size: 1.8vw;
|
}
|
|
.form-item label {
|
float: left;
|
margin-top: 8px;
|
font-size: 1.5vw;
|
display: inline-block;
|
margin-bottom: 0.5vh;
|
color: #333;
|
}
|
|
.status-row label,
|
.check-row label {
|
width: 30%;
|
padding-right: 1vw;
|
text-align: right;
|
font-size: 1.5vw;
|
}
|
|
.status-row input,
|
.check-row input {
|
width: 65%;
|
font-size: 1.5vw;
|
}
|
|
.form-row2 {
|
display: flex;
|
float: left;
|
margin-left: -65px;
|
flex-direction: column;
|
margin-top: -13px;
|
line-height: 48px;
|
align-content: flex-start;
|
}
|
|
.form-row3 {
|
display: flex;
|
flex-direction: column;
|
flex-wrap: nowrap;
|
align-content: flex-start;
|
justify-content: flex-start;
|
align-items: flex-start;
|
margin-bottom: 2.5vh
|
}
|
|
.form-row4 {
|
display: flex;
|
flex-direction: row;
|
flex-wrap: nowrap;
|
}
|
|
.inp1 {
|
width: 42%;
|
height: 3.5em;
|
font-weight: bolder;
|
margin-top: -41px;
|
font-size: 39px;
|
text-align: center;
|
color: red;
|
}
|
|
.inp2 {
|
float: right;
|
width: 220px;
|
height: 220px;
|
border-radius: 100%;
|
text-align: center;
|
margin-top: -42px;
|
font-size: 96px;
|
background-color: #476ee1fc;
|
color: #ffffff;
|
margin-right: 172px;
|
}
|
|
.quality-row {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 1.5vh;
|
}
|
|
.quality-row .form-item {
|
flex: 1;
|
margin: 0 10px;
|
}
|
|
.quality-row .form-item label {
|
width: auto;
|
min-width: 110px;
|
margin-right: 8px;
|
}
|
|
.quality-row .inp {
|
width: 70%;
|
min-width: 120px;
|
}
|
|
.status-row {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 1.5vh;
|
flex-wrap: nowrap;
|
/* 保证不换行 */
|
}
|
|
.status-row .form-item {
|
flex: 1 1 0;
|
margin: 0 8px;
|
min-width: 0;
|
}
|
|
.status-row .form-item label {
|
min-width: 90px;
|
margin-right: 6px;
|
}
|
|
.status-row .inp {
|
width: 65%;
|
min-width: 80px;
|
}
|
</style>
|