wangfei
2025-10-22 0f8bbbb24b04968cf0c5f3e9cb3ff2efde14b10f
UI-Project/src/views/ReportWork/reportWork.vue
@@ -27,13 +27,13 @@
      </el-select>
      <el-button type="primary" style="margin-left: 10px;" @click="selectReportData()">{{ $t('reportmanage.inquire')
        }}</el-button>
      <el-button type="success" style="margin-left: 10px;" :disabled="(!selectedStatus)" @click="handleConfirm">{{
      <el-button type="success" style="margin-left: 10px;" :disabled="isConfirmDisabled" @click="handleConfirm">{{
        $t('reportmanage.signingwork')
        }}</el-button>
    </div>
    <el-card style="flex: 1;margin-left: 10px;margin-top: 20px;" >
      <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
        <el-table height="740" ref="table" :data="reportData"
        <el-table height="700" ref="table" :data="reportData"
          :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }">
          <el-table-column prop="teamsGroupsName" align="center" :label="$t('reportmanage.reporteam')"
            min-width="135" />
@@ -137,6 +137,18 @@
            </template>
          </el-table-column>
        </el-table>
      <div style="margin-top: 20px;margin-left: 40%;">
      <el-pagination
        v-model:current-page="currentPage"
        :page-size="pageSize"
        :size="large"
        :disabled="disabled"
        layout="prev, pager, next, jumper"
        :total="totalRecords"
        @current-change="handlePageChange"
        style="margin-top: 10px;"
    />
    </div>
      </div>
    </el-card>
  </div>
@@ -151,33 +163,12 @@
import { useI18n } from 'vue-i18n'
import { inject } from 'vue';
const globalDate = inject('globalDate');
const timeRange = ref([])
const totalRecords = ref(0)
const pageSize = ref(20)
const currentPage = ref(1)
const { t } = useI18n()
const report = ref({
  type: '8',
  status: '1',
  workingProcedure: '0',
});
const timeRange = ref([])
const reportData = ref([])
function formatTimestamp(timestamp) {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  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);
  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([]);
@@ -192,9 +183,19 @@
const inputValuesb = reactive({});
const selectedType = ref(true);
const selectedStatus = ref(false);
const report = ref({
  type: '8',
  status: '1',
  workingProcedure: '0',
});
const isConfirmDisabled = computed(() => {
  return report.value.type === '1' || !selectedStatus.value;
});
// 查询数据
const selectReportData = async () => {
  const response = await request.post("/cacheVerticalGlass/damage/selectDamage", {
    pageNo: currentPage.value,
    pageSize: pageSize.value,
    startTime: (timeRange.value && timeRange.value[0]) || '',
    endTime: (timeRange.value && timeRange.value[1]) || '',
    type: report.value.type,
@@ -212,23 +213,16 @@
    selectedStatus.value = false;
  }
  if (response.code === 200) {
    const formattedData = response.data.map(record => ({
    const formattedData = response.data.records.map(record => ({
        ...record,
        formattedCreateTime: formatTimestamp(record.damageTime),
      }));
    reportData.value = formattedData;
    ElMessage.success(response.message);
    totalRecords.value = response.data.total || 0
  } else {
    ElMessage.error(response.message);
  }
  // const responses = await request.post("/cacheVerticalGlass/damage/insertDamage", {
  //   glassId:"P24081502|1|1",
  //   line:"1001",
  //   workingProcedure:"切割",
  //   remark:"",
  //   status:"0"
  // })
};
// 报工
const handleConfirm = async () => {
@@ -271,6 +265,10 @@
    console.error('Error fetching options:', error);
  }
};
const handlePageChange = (newPage) => {
  currentPage.value = newPage;
  selectReportData();
};
const handleInputChangea = (value, rowId) => {
  // 更新对应行的 select 值  
  selectValuesa[rowId] = value;
@@ -281,17 +279,21 @@
  inputValuesa[rowId] = value;
  inputValuesb[rowId] = value;
};
fetchTableData();
// fetchTableData();
function gettypeType(type: number) {  
  switch (type) {
    case 9:
    case 1:
      return 'success';  
    case 8:
    case 9:
      return 'danger';  
    case 8:
      return 'warning';
  }
}  
function gettypeText(type: number) {
  switch (type) {
    case 1:
      return t('reportmanage.completed');
    case 9:  
      return t('reportmanage.takeout'); 
    case 8:  
@@ -333,12 +335,32 @@
//     })); 
// };
// let socket;
function formatTimestamp(timestamp) {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  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);
  timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)];
  window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo))
}
onUnmounted(() => {
  socket.close();
});
onMounted(() => {
  fetchTableData();
  parseAndSetTime();
  selectReportData()
  // socket = initializeWebSocket(socketUrl, handleMessage);
});
onUnmounted(() => {