searcheh<!-- 上片机 -->
|
<script setup>
|
import request from "@/utils/request";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
import { reactive, ref, onMounted, onBeforeUnmount, onUnmounted } from 'vue'
|
import { useI18n } from 'vue-i18n'
|
import { WebSocketHost, host } from '@/utils/constants'
|
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
|
import {gridDateFormatter,getDataSort} from '@/stores/tool';
|
let language = ref(localStorage.getItem('lang') || 'zh')
|
const { t } = useI18n()
|
const requestData = reactive({
|
account: '',
|
password: '',
|
});
|
const blind = ref(false)
|
const errorInfo = ref(true)
|
const loadData = ref([]);
|
const taskinggoruby = ref([]);
|
const findMachine = ref([]);
|
const sendRecords = ref([]);
|
const downLineTask = ref([]);
|
const scanCode = ref([]);
|
const scanCodeOld = ref([]);
|
const searcheh = ref();
|
|
const userInfo=JSON.parse(window.localStorage.getItem('userInfo'));
|
const pageParams=userInfo.user.menus[0].pages[4].params;
|
const pageParamsJson=JSON.parse(pageParams);
|
const machineId = pageParamsJson.machineId;//当前页面的设备ID
|
console.log(machineId);
|
var errorScanId;
|
var errorOpen=false;
|
//使用WebSocket方式展示数据
|
let socket = null;
|
let socketDownLineTask = null;
|
const socketUrl = `ws://${WebSocketHost}:${host}/api/deviceInteraction/api/talk/manualReporting`;
|
const socketDownLineTaskUrl = `ws://${WebSocketHost}:${host}/api/deviceInteraction/api/talk/downLineTask`;
|
// 定义消息处理函数,更新 receivedData 变量
|
const handleMessage = (data) => {
|
// 更新 tableData 的数据
|
//taskinggoruby.value = data.taskinggoruby[0];
|
//loadData.value =getDataSort(data.taskingList[0]);
|
let dataJson = data[""+machineId][0];
|
loadData.value = dataJson.taskingList[0];
|
findMachine.value = dataJson.machine[0];
|
|
if(findMachine.value.remark.toString()!=errorScanId&&findMachine.value.remark.toString()!=""&&findMachine.value.remark.toString()!=undefined){
|
//有数据就弹窗
|
if(errorOpen){
|
ElMessageBox.close();
|
}
|
errorScanId=findMachine.value.remark.toString();
|
errorInfoFuntion(findMachine.value.remark.toString());
|
errorOpen=true;
|
}else if(findMachine.value.remark.toString()==""&&errorOpen){
|
ElMessageBox.close();
|
errorOpen=false;
|
}
|
|
};
|
// 定义消息处理函数,更新 receivedData 变量
|
const handleMessage2 = (data) => {
|
let dataJson = data[""+machineId][0];
|
downLineTask.value = dataJson.downLineTask[0];
|
// console.log(data);
|
};
|
onUnmounted(() => {
|
if (socket) {
|
closeWebSocket(socket);
|
}
|
if (socketDownLineTask) {
|
closeWebSocket(socketDownLineTask);
|
}
|
});
|
onBeforeUnmount(() => {
|
console.log("关闭了")
|
closeWebSocket();
|
});
|
|
onMounted(async () => {
|
//使用WebSocket方式展示数据
|
socket = initializeWebSocket(socketUrl, handleMessage);// 初始化 WebSocket,并传递消息处理函数
|
//使用WebSocket方式展示数据
|
socketDownLineTask = initializeWebSocket(socketDownLineTaskUrl, handleMessage2);// 初始化 WebSocket,并传递消息处理函数
|
});
|
//报警提示
|
const errorInfoFuntion = async (info) => {
|
let infoScancode=info;
|
ElMessageBox.confirm(
|
infoScancode,
|
t('delivery.prompt'),
|
{
|
confirmButtonText: t('functionState.sureStart'),
|
cancelButtonText: t('functionState.cancel'),
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
})
|
.catch(() => {
|
ElMessage({
|
type: 'info',
|
message: t('functionState.cancel'),
|
})
|
})
|
}
|
//修改工作状态 【失败/正在工作/完工】
|
const workStatus = async (row, state) => {
|
let url;
|
if (state == "重发") {
|
url = "/deviceInteraction/tasking/loseMachineTask";
|
} else if (state == "正在工作") {
|
url = "/deviceInteraction/tasking/startMachineTask";
|
} else if (state == "完工") {
|
url = "/deviceInteraction/tasking/finishMachineTask";
|
} else {
|
return;
|
}
|
ElMessageBox.confirm(
|
t('functionState.tips'),
|
t('delivery.prompt'),
|
{
|
confirmButtonText: t('functionState.sure'),
|
cancelButtonText: t('functionState.cancel'),
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
//开始修改
|
request.post(url,
|
{
|
"id": machineId
|
}).then((res) => { // 替换为你的API端点
|
if (res.code === 200) {
|
ElMessage.success(res.message);
|
} else {
|
ElMessage.warning(res.message)
|
}
|
})
|
})
|
.catch(() => {
|
ElMessage({
|
type: 'info',
|
message: t('functionState.cancel'),
|
})
|
})
|
|
}
|
|
//开工/暂停
|
const machineStatus = async (state) => {
|
ElMessageBox.confirm(
|
t('functionState.tips'),
|
t('delivery.prompt'),
|
{
|
confirmButtonText: t('functionState.sure'),
|
cancelButtonText: t('functionState.cancel'),
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
//下线接口
|
request.post("/deviceInteraction/machine/updateMachineState",
|
{
|
"id": machineId,
|
"state": state
|
}).then((res) => { // 替换为你的API端点
|
if (res.code === 200) {
|
ElMessage.success(res.message);
|
} else {
|
ElMessage.warning(res.message)
|
}
|
})
|
})
|
.catch(() => {
|
ElMessage({
|
type: 'info',
|
message: t('functionState.cancel'),
|
})
|
})
|
}
|
//破损
|
const damagedTask = async (row) => {
|
ElMessageBox.confirm(
|
t('functionState.tips'),
|
t('delivery.prompt'),
|
{
|
confirmButtonText: t('functionState.sure'),
|
cancelButtonText: t('functionState.cancel'),
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
//下线接口
|
request.post("/deviceInteraction/tasking/damagedTask",
|
{
|
"glassId": row.glassId
|
}).then((res) => { // 替换为你的API端点
|
if (res.code === 200) {
|
ElMessage.success(res.message);
|
} else {
|
ElMessage.warning(res.message)
|
}
|
})
|
})
|
.catch(() => {
|
ElMessage({
|
type: 'info',
|
message: t('functionState.cancel'),
|
})
|
})
|
}
|
//下线(拿走)
|
const glassDownLine = async (row) => {
|
ElMessageBox.confirm(
|
t('functionState.tips'),
|
t('delivery.prompt'),
|
{
|
confirmButtonText: t('functionState.sure'),
|
cancelButtonText: t('functionState.cancel'),
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
//下线接口
|
request.post("/deviceInteraction/tasking/glassDownLine",
|
{
|
"glassId": row.glassId,
|
}).then((res) => { // 替换为你的API端点
|
if (res.code === 200) {
|
ElMessage.success(res.message);
|
} else {
|
ElMessage.warning(res.message)
|
}
|
})
|
})
|
.catch(() => {
|
ElMessage({
|
type: 'info',
|
message: t('functionState.cancel'),
|
})
|
})
|
}
|
const topLineShow = async () => {
|
blind.value = true;
|
}
|
const fetchData = async () => {
|
setTimeout(()=>{
|
//扫码回车后延迟一秒
|
//alert(searcheh.value);
|
//下线接口
|
let scanId= searcheh.value;
|
request.post("/deviceInteraction/tasking/scanMachineAdd",
|
{
|
"machineId": machineId,
|
"scanId": scanId
|
}).then((res) => { // 替换为你的API端点
|
if (res.code === 200) {
|
ElMessage.success(res.message);
|
} else {
|
ElMessage.warning(res.message)
|
}
|
})
|
searcheh.value="";
|
},1000);
|
|
//扫码回车提交
|
//searcheh.value="";
|
}
|
//上线
|
const topLine = async (row) => {
|
ElMessageBox.confirm(
|
t('functionState.tips'),
|
t('delivery.prompt'),
|
{
|
confirmButtonText: t('functionState.sure'),
|
cancelButtonText: t('functionState.cancel'),
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
//上线接口
|
request.post("/deviceInteraction/tasking/glassTopLine",
|
{
|
"glassId": row.glassId,
|
"lineConfigurationId": machineId
|
}).then((res) => { // 替换为你的API端点
|
if (res.code === 200) {
|
ElMessage.success(res.message);
|
} else {n
|
ElMessage.warning(res.message)
|
}
|
})
|
})
|
.catch(() => {
|
ElMessage({
|
type: 'info',
|
message: t('functionState.cancel'),
|
})
|
})
|
}
|
const handleDialogClose = () => {
|
|
}
|
//全部提交
|
const reportForWork = async () => {
|
let infoReport = "是否提交 "+loadData.value.length+" 片玻璃?";
|
ElMessageBox.confirm(
|
infoReport,
|
t('delivery.prompt'),
|
{
|
confirmButtonText: t('functionState.sure'),
|
cancelButtonText: t('functionState.cancel'),
|
type: 'warning',
|
}
|
)
|
.then(() => {
|
//下线接口
|
request.post("/deviceInteraction/tasking/reportForWork",
|
{
|
"id": machineId,
|
}).then((res) => { // 替换为你的API端点
|
if (res.code === 200) {
|
ElMessage.success(res.message);
|
} else {
|
ElMessage.warning(res.message)
|
}
|
})
|
})
|
.catch(() => {
|
ElMessage({
|
type: 'info',
|
message: t('functionState.cancel'),
|
})
|
})
|
}
|
|
|
</script>
|
<template>
|
<div ref="content" style="padding:0 20px;">
|
<div id="div-title" style="font-size: 20px; font-weight: bold; margin:10px 0 10px 0;padding-left: 20px;">
|
{{ $t('machine.manualReporting') }}
|
</div>
|
|
<el-dialog v-model="blind" top="30vh" style="text-align: center;" @close="handleDialogClose">
|
<!-- 已报工 -->
|
|
</el-dialog>
|
|
<hr />
|
<br>
|
<div id="search" style="height:35px;line-height: 35px;">
|
<!-- 功能 -->
|
<el-button type="primary" id="ButtonTopLine" @click="reportForWork">{{ $t('functionState.reporting') }}</el-button>
|
<!-- <el-button type="primary" id="ButtonTopLine" @click="topLineShow">{{ $t('functionState.reporting') }}</el-button> -->
|
|
<el-input v-model="searcheh" type="primary" id="ReportSubmission" @keyup.enter="fetchData"
|
style="width:1000px;height:35px;line-height: 35px;font-size: 35px;float: right;"></el-input>
|
|
</div>
|
|
<div id="main-body" style="min-height:240px;">
|
<!-- 表格内容 -->
|
<el-table :data="taskinggoruby" stripe
|
:header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129', textAlign: 'center' }"
|
:cell-style="{ textAlign: 'center' }">
|
<!-- <el-table-column type="selection" min-width="30" /> -->
|
<el-table-column type="index" :label="$t('glassInfo.number')" min-width="30" />
|
<el-table-column prop="batchNumber" :label="$t('glassInfo.batchNumber')" />
|
<el-table-column prop="taskType" :label="$t('glassInfo.taskType')" >
|
<template #header>
|
<div>
|
<div>{{ $t('glassInfo.taskType') }}
|
<el-icon @click="fetchData"><CaretTop /></el-icon>
|
<el-icon @click="fetchData"><CaretBottom /></el-icon>
|
<el-icon color="#409efc"><Filter /></el-icon>
|
</div>
|
<!-- <el-input size="small" placeholder="Type to search" /> -->
|
</div>
|
</template>
|
</el-table-column>
|
<el-table-column prop="scanId" :label="$t('glassInfo.scanId')" />
|
<el-table-column prop="taskQuantity" :label="$t('glassInfo.taskQuantity')" />
|
<el-table-column prop="reportCount" :label="$t('glassInfo.reportCount')" />
|
|
<el-table-column fixed="right" :label="$t('productStock.operate')" align="center" width="270">
|
<template #default="scope">
|
<el-button size="mini" link type="primary" plain @click="damagedTask(scope.row)">{{ $t('functionState.lose')
|
}}</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
|
<div id="main-body" style="width: 100%; height: 460px;min-width: 1200px;">
|
<!-- 表格内容详情 -->
|
<el-table :data="loadData" stripe
|
:header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129', textAlign: 'center' }"
|
:cell-style="{ textAlign: 'center' }">
|
<!-- <el-table-column type="selection" min-width="30" /> -->
|
<el-table-column type="index" :label="$t('glassInfo.number')" min-width="30" />
|
<el-table-column prop="taskType" :label="$t('glassInfo.taskType')" />
|
|
<el-table-column prop="length" :label="$t('glassInfo.length')" />
|
<el-table-column prop="width" :label="$t('glassInfo.width')" />
|
<el-table-column prop="thickness" :label="$t('glassInfo.thickness')" />
|
<el-table-column prop="operationRecordTime" :formatter="gridDateFormatter" :label="$t('glassInfo.operationRecordTime')" width="180"/>
|
<el-table-column prop="batchNumber" :label="$t('glassInfo.batchNumber')" />
|
<el-table-column prop="scanId" :label="$t('glassInfo.scanId')" />
|
<el-table-column prop="warehouse" :label="$t('glassInfo.warehouse')" />
|
<el-table-column fixed="right" :label="$t('productStock.operate')" align="center" width="270">
|
<template #default="scope">
|
<el-button size="mini" link type="primary" plain @click="damagedTask(scope.row)">{{ $t('functionState.lose')
|
}}</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
</div>
|
</template>
|
|
<style scoped>
|
table {
|
text-align: center;
|
width: 100%;
|
height: 100%;
|
border-collapse: collapse;
|
border-spacing: 0;
|
}
|
|
table td {
|
text-align: center;
|
}
|
|
#main-body {
|
width: 100%;
|
height: 100%;
|
border: 1px solid #ccc;
|
margin-top: 25px;
|
}
|
|
#searchButton {
|
width: 100px;
|
height: 40px;
|
font-size: 16px;
|
border-radius: 5px;
|
background-color: #409EFF;
|
color: #fff;
|
border: none;
|
cursor: pointer;
|
}
|
.dotClass {
|
width:10px;
|
height:10px;
|
border-radius: 50%;
|
display: block;
|
margin-left: 10px;
|
}
|
</style>
|