From 30463ba47d661d49d88ee8e43b2dcdb41d2e6090 Mon Sep 17 00:00:00 2001
From: wangfei <3597712270@qq.com>
Date: 星期四, 20 三月 2025 15:28:35 +0800
Subject: [PATCH] 历史任务样式更改

---
 UI-Project/src/views/ReportWork/reportWork.vue |   72 +++++++++++++++++++-----------------
 1 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/UI-Project/src/views/ReportWork/reportWork.vue b/UI-Project/src/views/ReportWork/reportWork.vue
index 1c043a5..f20b55e 100644
--- a/UI-Project/src/views/ReportWork/reportWork.vue
+++ b/UI-Project/src/views/ReportWork/reportWork.vue
@@ -2,12 +2,11 @@
   <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-date-picker v-model="timeRange" type="datetimerange" range-separator="鑷�" :start-placeholder="$t('reportmanage.starttime')" 
+             style="margin-left: 15px;" value-format = "YYYY-MM-DD hh:mm:ss"
+              :end-placeholder="$t('reportmanage.endtime')">
+            </el-date-picker>
       <el-select v-model="report.type" :placeholder="$t('reportmanage.ctype')" style="margin-left: 10px;">
-        <!-- <el-option :label="$t('reportmanage.all')" value="0"></el-option> -->
-        <!-- <el-option :label="$t('reportmanage.completed')" value="1"></el-option> -->
         <el-option :label="$t('reportmanage.broke')" value="8"></el-option>
         <el-option :label="$t('reportmanage.takeout')" value="9"></el-option>
       </el-select>
@@ -45,8 +44,8 @@
           <el-table-column prop="engineerId" align="center" :label="$t('reportmanage.projectnumber')" min-width="120" />
           <el-table-column prop="temperingLayoutId" align="center" :label="$t('reportmanage.layoutID')"
             min-width="120" />
-          <el-table-column prop="damageTime" align="center" :label="$t('reportmanage.productiontime')"
-            min-width="230" />
+          <el-table-column prop="formattedCreateTime" align="center" :label="$t('reportmanage.productiontime')"
+            min-width="230" />damageTime
           <el-table-column prop="type" align="center" :label="$t('reportmanage.type')" min-width="120" />
           <el-table-column prop="status" align="center" :label="$t('reportmanage.state')" min-width="120" />
           <el-table-column prop="processId" align="center" :label="$t('reportmanage.processcards')" min-width="140" />
@@ -127,6 +126,9 @@
 import { WebSocketHost, host } from '@/utils/constants'
 import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
 import { useI18n } from 'vue-i18n'
+import { inject } from 'vue';
+const globalDate = inject('globalDate');
+const timeRange = ref([])
 const { t } = useI18n()
 const report = ref({
   type: '8',
@@ -134,18 +136,28 @@
   workingProcedure: '0',
 });
 const reportData = ref([])
-const endDate = new Date();
-const startDate = new Date();
-startDate.setDate(endDate.getDate() - 7);  // 鑾峰彇涓�涓槦鏈熷墠鐨勬椂闂�
-// 鏍煎紡鍖栦负 "YYYY-MM-DD" 鏍煎紡
-const formatDate = (date) => {
+function formatTimestamp(timestamp) {
+  const date = new Date(timestamp);
   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 month = String(date.getMonth() + 1).padStart(2, '0'); // 鏈堜唤浠�0寮�濮嬶紝闇�瑕佸姞1锛屽苟琛ラ浂
+  const day = String(date.getDate()).padStart(2, '0'); // 琛ラ浂
+  const hours = String(date.getHours()).padStart(2, '0'); // 琛ラ浂锛堝鏋滈渶瑕佹樉绀烘椂闂达級
+  const minutes = String(date.getMinutes()).padStart(2, '0'); // 琛ラ浂锛堝鏋滈渶瑕佹樉绀烘椂闂达級
+  const seconds = String(date.getSeconds()).padStart(2, '0'); // 琛ラ浂锛堝鏋滈渶瑕佹樉绀烘椂闂达級
+  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+}
+// 鏍煎紡鍖栧悗绔椂闂村苟璁$畻涓�鍛ㄥ墠鐨勬椂闂�
+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澶�
+  oneWeekAgo.setHours(0, 0, 0, 0);
+  console.log(formatTimestamp(oneWeekAgo));
+  console.log(oneWeekAgo);
+  timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)];
+  window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo))
+}
+// const timeRange = ref([formatTimestamp(startDate), formatTimestamp(globalDate)]);
 const selectOptionsa = ref([]);
 const selectOptionsb = ref([]);
 const selectOptionsc = ref([]);
@@ -157,16 +169,13 @@
 const selectValuese = reactive({});
 const inputValuesa = reactive({});
 const inputValuesb = reactive({});
-
 const selectedType = ref(true);
 const selectedStatus = ref(false);
-
-
 // 鏌ヨ鏁版嵁
 const selectReportData = async () => {
   const response = await request.post("/cacheVerticalGlass/damage/selectDamage", {
-    startTime: timeRange.value[0],
-    endTime: timeRange.value[1]+" 23:59:59",
+    startTime: (timeRange.value && timeRange.value[0]) || '',
+    endTime: (timeRange.value && timeRange.value[1]) || '',
     type: report.value.type,
     status: report.value.status,
     workingProcedure: report.value.workingProcedure
@@ -182,13 +191,16 @@
     selectedStatus.value = false;
   }
   if (response.code === 200) {
-    reportData.value = response.data;
+    const formattedData = response.data.map(record => ({
+        ...record,
+        formattedCreateTime: formatTimestamp(record.createTime),
+      }));
+    reportData.value = formattedData;
     ElMessage.success(response.message);
 
   } else {
     ElMessage.error(response.message);
   }
-
   // const responses = await request.post("/cacheVerticalGlass/damage/insertDamage", {
   //   glassId:"P24081502|1|1",
   //   line:"1001",
@@ -260,20 +272,12 @@
 //     })); 
 // };
 // let socket;
-onMounted(() => {
-  // socket = new WebSocket(socketUrl);
-  // socket.onmessage = (event) => {
-  //   const data = JSON.parse(event.data);
-
-  //   // updateCharts();
-  // };
-  // };  
-});
 onUnmounted(() => {
   socket.close();
 });
 onMounted(() => {
   fetchTableData();
+  parseAndSetTime();
   // socket = initializeWebSocket(socketUrl, handleMessage);
 });
 onUnmounted(() => {

--
Gitblit v1.8.0