ZengTao
2025-03-28 f68d3c71819feb59e7a227a5d992b059b900916c
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<template>
  <div style="height: 600px;">
    <div style="display: flex; flex-direction: row; align-items: center; margin-top: 20px;">
      <span style="margin-left: 10px;" class="demonstration">{{ $t('reportmanage.productiontime') }}</span>
      <el-date-picker style="margin-left: 10px;" v-model="timeRange" type="daterange" format="YYYY/MM/DD"
        value-format="YYYY-MM-DD" :start-placeholder="$t('reportmanage.starttime')"
        :end-placeholder="$t('reportmanage.endtime')" :default-time="defaultTime" />
      <el-input v-model="report.targetSlot" style="margin-left: 15px;width: 150px" placeholder="请输入格子号" />
      <!-- <el-input v-model="report.width" style="margin-left: 15px;width: 150px" placeholder="请输入宽" />
      <el-input v-model="report.height" style="margin-left: 15px;width: 150px" placeholder="请输入高" /> -->
      <el-select v-model="report.taskType" :placeholder="$t('reportmanage.ctype')" style="margin-left: 10px;">
        <el-option :label="$t('reportmanage.all')" value="-1"></el-option>
        <el-option :label="$t('reportmanage.incomplete')" value="0"></el-option>
        <el-option :label="$t('reportmanage.complete')" value="1"></el-option>
      </el-select>
      <el-select v-model="report.taskState" :placeholder="$t('reportmanage.cstate')" style="margin-left: 10px;">
        <el-option :label="$t('reportmanage.all')" value="-1"></el-option>
        <el-option :label="$t('reportmanage.feed')" value="1"></el-option>
        <el-option :label="$t('reportmanage.out')" value="2"></el-option>
        <el-option :label="$t('reportmanage.straightthrough')" value="3"></el-option>
      </el-select>
      <el-select v-model="report.line" :placeholder="$t('reportmanage.cprocess')" style="margin-left: 10px;">
        <el-option :label="$t('reportmanage.all')" value="0"></el-option>
        <el-option :label="$t('reportmanage.oneline')" value="2001"></el-option>
        <el-option :label="$t('reportmanage.twoline')" value="2002"></el-option>
      </el-select>
      <el-button type="primary" style="margin-left: 10px;" @click="selectReportData()">{{ $t('reportmanage.inquire')
      }}</el-button>
    </div>
    <el-card style="flex: 1;margin-left: 10px;" v-loading="loading">
      <!-- <div style="margin-bottom: 20px">
        <el-row style="margin-top: -15px;margin-bottom: -2px;">
          <el-col :span="3">
            <div id="dta" style="font-size: 15px;">
              <el-form-item :label="$t('reportmanage.totalCounts')" style="width: 14vw">
                {{ totalCounts }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="3">
            <div id="dt" style="font-size: 15px;">
              <el-form-item :label="$t('reportmanage.totalAreas')" style="width: 14vw">
                {{ totalAreas }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="3">
            <div id="dt" style="font-size: 15px;">
              <el-form-item :label="$t('reportmanage.totalDamages')" style="width: 14vw">
                {{ totalDamages }}
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="3">
            <div id="dt" style="font-size: 15px;">
              <el-form-item :label="$t('reportmanage.totalTakes')" style="width: 14vw">
                {{ totalTakes }}
              </el-form-item>
            </div>
          </el-col>
        </el-row>
      </div> -->
      <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
        <el-table height="750" ref="table" :data="reportData"
          :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }">
          <el-table-column prop="glassId" align="center" :label="$t('reportmanage.glassID')" min-width="130" />
          <el-table-column prop="startCell" align="center" :label="$t('reportmanage.targetSlot')" min-width="120" />
          <el-table-column prop="endCell" align="center" :label="$t('reportmanage.line')" min-width="120" />
          <el-table-column prop="taskStatus" align="center" :label="$t('reportmanage.state')" min-width="120">
            <template #default="scope">
              <span v-if="scope.row.taskStatus == 0">{{ $t('reportmanage.incomplete') }}</span>
              <span v-if="scope.row.taskStatus == 1">{{ $t('reportmanage.complete') }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="taskType" align="center" :label="$t('reportmanage.type')" min-width="120">
            <template #default="scope">
              <span v-if="scope.row.taskType == 1">{{ $t('reportmanage.cage') }}</span>
              <span v-if="scope.row.taskType == 2">{{ $t('reportmanage.out') }}</span>
              <span v-if="scope.row.taskType == 3">{{ $t('reportmanage.straightthrough') }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="createTime" align="center" :label="$t('reportmanage.createTime')" min-width="230" />
        </el-table>
      </div>
    </el-card>
  </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({
  targetSlot: '',
  taskType: '-1',
  taskState: '-1',
  line: '0',
  width: '',
  height: ''
});
const reportData = ref([])
const endDate = new Date();
const startDate = new Date();
startDate.setDate(endDate.getDate() - 100);  // 获取一个星期前的时间
// 格式化为 "YYYY-MM-DD" 格式
const formatDate = (date) => {
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0');
  const day = String(date.getDate()).padStart(2, '0');
  return `${year}-${month}-${day}`;
};
 
const timeRange = ref([formatDate(startDate), formatDate(endDate)]);
const totalCounts = ref(0);
const totalAreas = ref(0);
const totalDamages = ref(0);
const totalTakes = ref(0);
 
// 查询数据
const selectReportData = async () => {
  const response = await request.post("/cacheGlass/taskCache/selectTaskCache?startTime=" + timeRange.value[0] + "&&endTime=" + timeRange.value[1] + "", {
    startTime: timeRange.value[0],
    endTime: timeRange.value[1],
    startCell: report.value.targetSlot,
    width: report.value.width,
    height: report.value.height,
    taskType: report.value.taskType,
    taskStatus: report.value.taskState,
    endCell: report.value.line
  })
  if (response.code === 200) {
    reportData.value = response.data;
    let totalCount = 0;
    let totalArea = 0;
    let totalDamage = 0;
    let totalTake = 0;
    // response.data.forEach(item => {
    //   if (item.taskState == 3) {
    //     totalCount += 1;
    //     totalArea += item.width * item.height / 100000000;
    //   }
    //   if (item.taskState == 8) {
    //     totalDamage += 1;
    //   }
    //   if (item.taskState == 9) {
    //     totalTake += 1;
    //   }
    // });
    totalCounts.value = totalCount;
    totalAreas.value = totalArea.toFixed(2);
    totalDamages.value = totalDamage;
    totalTakes.value = totalTake;
    ElMessage.success(response.message);
  } else {
    ElMessage.error(response.message);
  }
 
};
 
</script>