zhoushihao
2025-03-10 976cee4892eec261f6c2927e788e476e5cc5028e
UI-Project/src/views/Caching/cachingun.vue
@@ -2,10 +2,13 @@
import {onBeforeUnmount, onMounted, onUnmounted, ref, reactive} from "vue";
import {useRouter} from "vue-router"
import {host, WebSocketHost} from '@/utils/constants'
import dayjs from 'dayjs';
import request from "@/utils/request"
import {closeWebSocket, initializeWebSocket} from '@/utils/WebSocketService';
import {ElMessage, ElMessageBox} from 'element-plus'
import {useI18n} from 'vue-i18n'
import { inject } from 'vue';
const globalDate = inject('globalDate');
const {t} = useI18n()
let language = ref(localStorage.getItem('lang') || 'zh')
const tableDataa = ref([])
@@ -36,9 +39,19 @@
  //     id: rect.id * 10,
  //   })); 
};
// 初始化 WebSocket,并传递消息处理函数
onMounted(() => {
// 格式化后端时间并计算一周前的时间
const defaultTime = ref<[Date, Date]>([new Date(), new Date()]);
function parseAndSetTime() {
  const backendTime = new Date(globalDate);
  const oneWeekAgo = new Date(backendTime.getTime() - 7 * 24 * 60 * 60 * 1000); // 减去7天
  console.log(formatTimestamp(oneWeekAgo));
  console.log(oneWeekAgo);
  timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)];
  window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo))
}
  onMounted(() => {
  socket = initializeWebSocket(socketUrl, handleMessage);
  parseAndSetTime();
});
// 历史任务
const handlehistorical = (row) => {
@@ -48,7 +61,8 @@
// 历史任务
const historical = async () => {
  try { 
  var url="/cacheGlass/edgStorageDeviceTaskHistory?deviceId="+2 + "&startTime=" + '' + "&endTime=" + '' + "&glassId=" + '' + "&taskState=" + '' + "&taskType=" + '';
  let startTime = window.localStorage.getItem('startTime')
  var url="/cacheGlass/edgStorageDeviceTaskHistory?deviceId="+2 + "&startTime=" + startTime + "&endTime=" + globalDate + "&glassId=" + '' + "&taskState=" + '' + "&taskType=" + '';
      const response = await request.get(url) 
      if (response.code == 200) {
        ElMessage.success(response.message);
@@ -65,8 +79,8 @@
  try { 
    const params = {
      deviceId: 2,
      startTime: timeRange.value[0] || '',
      endTime: timeRange.value[1] || '',
      startTime: (timeRange.value && timeRange.value[0]) || '',
      endTime: (timeRange.value && timeRange.value[1]) || '',
      glassId: glassId.value || '',
      taskState: taskState.value,
      taskType: taskType.value || ''
@@ -148,7 +162,7 @@
const handleptask = async() => { 
  try {
    const confirmResult = await ElMessageBox.confirm(  
      t('workOrder.partasks'),
      t('searchOrder.partasks'),
      t('workOrder.prompt'),  
      {  
        confirmButtonText: t('workOrder.yes'), 
@@ -182,9 +196,7 @@
      } 
    ); 
    if (confirmResult === 'confirm') {
      const response = await request.post("/cacheGlass/edgStorageCageDetails/removeEdgDetails",{
        glassId: row.glassId
      })
      const response = await request.post("/cacheGlass/edgStorageCageDetails/removeEdgDetails?glassId="+encodeURIComponent(row.glassId))
    if (response.code === 200) {
     ElMessage.success(response.message);
      } else {
@@ -279,8 +291,7 @@
  const hours = String(date.getHours()).padStart(2, '0'); // 补零(如果需要显示时间)
  const minutes = String(date.getMinutes()).padStart(2, '0'); // 补零(如果需要显示时间)
  const seconds = String(date.getSeconds()).padStart(2, '0'); // 补零(如果需要显示时间)
  // 只显示年月日,如果需要显示时间,则拼接 hours + ':' + minutes + ':' + seconds
  return `${year}-${month}-${day}`;
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
  onUnmounted(() => {
    if (socket) {
@@ -296,12 +307,21 @@
  <div style="height: 500px;">
    <el-card style="flex: 1;margin-left: 10px;margin-top: 10px;" v-loading="loading">
    <el-button style="margin-bottom: 15px;margin-left: 20px;" @click="handlehistorical" type="primary">{{ $t('searchOrder.historicaltasks') }}</el-button>
    <div style="position: relative; width: 100%; height: 100%;"> <!-- 添加相对定位 -->
  <div style="position: absolute; margin-top: 28px; left: 430px; display: flex; z-index: 10;"> <!-- 添加绝对定位 -->
    <div>{{ $t('searchOrder.projectnumber') }}</div>
    <div style="margin-left: 155px;">{{ $t('hellow.flowCardId') }}</div>
    <div style="margin-left: 152px;">{{ $t('searchOrder.glassID') }}</div>
    <div style="margin-left: 165px;">{{ $t('searchOrder.width') }}</div>
    <div style="margin-left: 185px;">{{ $t('searchOrder.height') }}</div>
    <div style="margin-left: 172px;">{{ $t('searchOrder.thickness') }}</div>
    <div style="margin-left: 145px;">{{ $t('hellow.operate') }}</div>
  </div>
    <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
      <el-table
      ref="table"
      style="margin-top: 20px; height: 360px;"
      :data="tableDataa"
      :row-class-name="rowClassName"
      :header-cell-style="{ background: '#F2F3F5', color: '#1D2129' }"
      row-key="id"
  >
@@ -324,14 +344,14 @@
    <template #default="props">
      <el-table 
      :header-cell-style="{ background: '#F2F3F5', color: '#1D2129' }"
      :data="props.row.details" style="width: 100%;height: 200px;">
        <el-table-column prop="engineerId" align="center" :label="$t('searchOrder.projectnumber')" min-width="80" />
          <el-table-column prop="flowCardId" align="center" :label="$t('hellow.flowCardId')" min-width="80" />
          <el-table-column prop="glassId" align="center" :label="$t('searchOrder.glassID')" min-width="80" />
          <el-table-column prop="width" align="center" :label="$t('searchOrder.width')" min-width="80" />
          <el-table-column prop="height" align="center" :label="$t('searchOrder.height')" min-width="80" />
          <el-table-column prop="thickness" align="center" :label="$t('searchOrder.thickness')" min-width="80" />
    <el-table-column fixed="right" :label="$t('hellow.operate')" align="center" width="150">
      :data="props.row.details" style="width: 100%;height: 70px;">
        <el-table-column prop="engineerId" align="center" min-width="80" />
          <el-table-column prop="flowCardId" align="center" min-width="80" />
          <el-table-column prop="glassId" align="center" min-width="80" />
          <el-table-column prop="width" align="center" min-width="80" />
          <el-table-column prop="height" align="center" min-width="80" />
          <el-table-column prop="thickness" align="center" min-width="80" />
    <el-table-column fixed="right" align="center" width="150">
        <template #default="scope">
          <el-button size="mini" type="text" plain @click="handletake(scope.row)">{{ $t('searchOrder.breakage') }}</el-button>
          <el-button size="mini" type="text" plain @click="handleBindRack(scope.row)">{{ $t('searchOrder.takeout')}} </el-button>
@@ -343,6 +363,7 @@
    </el-table-column>
  </el-table>
 </div>
 </div>
      <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;margin-top: 15px;">
        <el-table height="90" ref="table" 
        @selection-change="handleSelectionChange"