zhoushihao
2024-07-16 353acdfceab45a94d9f5d71e353bd06bf7c2eba6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<template>
  <div style="height: 600px;">
    <span class="demonstration">生产时间</span>
    <el-date-picker v-model="timeRange" type="daterange" format="YYYY/MM/DD" value-format="YYYY-MM-DD"
      start-placeholder="开始时间" end-placeholder="结束时间" :default-time="defaultTime" />
    <el-select v-model="report.type" placeholder="清选择类型">
      <el-option label="全部" value="0"></el-option>
      <el-option label="完工" value="1"></el-option>
      <el-option label="破损" value="2"></el-option>
      <el-option label="拿走" value="3"></el-option>
    </el-select>
    <el-select v-model="report.status" placeholder="清选择状态">
      <el-option label="全部" value="0"></el-option>
      <el-option label="未报工" value="1"></el-option>
      <el-option label="待报工" value="2"></el-option>
      <el-option label="已报工" value="3"></el-option>
    </el-select>
    <el-select v-model="report.workProcedure" placeholder="清选择工序">
      <el-option label="全部" value="0"></el-option>
      <el-option label="切割" value="1"></el-option>
      <el-option label="磨边" value="2"></el-option>
      <el-option label="钢化" value="3"></el-option>
    </el-select>
    <el-button type="primary" @click="selectReportData()">查询</el-button>
    <el-button type="success">报工</el-button>
    <el-table height="100%" ref="table" :data="reportData"
      :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }">
      <el-table-column prop="reportData.line" align="center" label="线路" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="工序" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="玻璃id" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="工程号" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="钢化版图id" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="生产时间" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="备注" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="类型" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="状态" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="流程卡" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="序号" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="层" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="破损类型" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="破损原因" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="责任工序" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="责任人员" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="责任班组" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="责任设备" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="报工班组" min-width="120" />
      <el-table-column prop="reportData.line" align="center" label="报工设备" min-width="120" />
    </el-table>
  </div>
</template>
<script setup>
import { Delete, Upload } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, onMounted, onBeforeUnmount, reactive, computed, shallowRef, onUnmounted, watchEffect } from "vue";
import request from "@/utils/request"
import { WebSocketHost, host } from '@/utils/constants'
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const report = ref({
  type: '',
  status: '',
  workProcedure: '',
});
const reportData = ref([])
const timeRange = ref([new Date(2000, 10, 10), new Date(2200, 10, 11)])
 
 
// 查询数据
const selectReportData = async () => {
  console.log(timeRange.value[0])
  const response = await request.post("/loadGlass/damage/selectDamage", {
    startTime: timeRange.value[0],
    endTime: timeRange.value[1],
    type: report.value.type,
    status: report.value.status,
    workProcedure: report.value.workProcedure,
  })
  if (response.code === 200) {
    reportData.value = response.data;
    ElMessage.success(response.message);
  } else {
    ElMessage.error(response.message);
  }
};
 
const socketUrl = `ws://${WebSocketHost}:${host}/api/temperingGlass/api/talk/screen`;
const handleMessage = (data) => {
  // adjustedRects.value = data.device[0].map(rect => ({  
  //       ...rect, 
  //       completed: rect.completedQuantity,
  //       breakage: rect.breakageQuantity,
  //       thisProcess: rect.thisProcess,
  //     })); 
};
let socket;
onMounted(() => {
  socket = new WebSocket(socketUrl);
  socket.onmessage = (event) => {
    const data = JSON.parse(event.data);
 
    // updateCharts();
  };
  // };  
});
 
 
 
 
onUnmounted(() => {
  socket.close();
});
 
onMounted(() => {
  // fetchFlowCardId();
  // fetchTableData(); // 获取数据
  initializeWebSocket(socketUrl, handleMessage);
});
onBeforeUnmount(() => {
  console.log("关闭了")
  closeWebSocket();
});
</script>
 
<style scoped></style>