diff --git a/src/views/equipmentDowntimeRate/index.vue b/src/views/equipmentDowntimeRate/index.vue index 433084a..4f46150 100644 --- a/src/views/equipmentDowntimeRate/index.vue +++ b/src/views/equipmentDowntimeRate/index.vue @@ -1,6 +1,6 @@ @@ -32,25 +62,96 @@ import { ref, computed, onMounted } from 'vue' import { Vue3SeamlessScroll } from 'vue3-seamless-scroll' import { getProductdatatable } from "@/api/equipmentDowntimeRate/index.js" -const allLines = ref([]) -const getProductdatatableData = () => { - getProductdatatable().then(res => { - if (res.code === 200) { - allLines.value = res.data.map(item => { - return { - lineName: item.lineName, - lineCode: item.lineCode, - planHours: item.planHours, - downtimeHours: item.downtimeHours, - downtimeRate: item.downtimeRate, - } - }) - } - }) +const loading = ref(false) +const rawDataList = ref([]) +// 查询参数 +const queryParams = reactive({ + pageNum: 1, + pageSize: 10, + DateTimeRange: [ + new Date(), + new Date() + ] +}) + +// 计算总条数 +const total = computed(() => rawDataList.value.length) + +const tableData = computed(() => { + const start = (queryParams.pageNum - 1) * queryParams.pageSize + const end = start + queryParams.pageSize + return rawDataList.value.slice(start, end) +}) + +const formatDateToYYYYMMDD = (date) => { + if (!date) return '' + const d = new Date(date) + const year = d.getFullYear() + const month = String(d.getMonth() + 1).padStart(2, '0') + const day = String(d.getDate()).padStart(2, '0') + return `${year}-${month}-${day}` +} +// 获取数据列表 +const getProductdatatableData = () => { + let data = { + startTime: formatDateToYYYYMMDD(queryParams.DateTimeRange[0]), + endTime: formatDateToYYYYMMDD(queryParams.DateTimeRange[1]) + } + console.log('c', data); + loading.value = true, + getProductdatatable(data).then(res => { + loading.value = false + if (res.code === 200) { + console.log('设备开机率', res); + // 保存原始完整数据 + rawDataList.value = res.data || [] + } + }).catch(() => { + loading.value = false + rawDataList.value = [] + }) } -getProductdatatableData() +// 每页条数改变时触发 +const handleSizeChange = (val) => { + queryParams.pageSize = val + // 条数变化后重置页码为1 + queryParams.pageNum = 1 +} + +// 当前页码改变时触发 +const handleCurrentChange = (val) => { + queryParams.pageNum = val +} +const sortChange = (params) => { + console.log('排序参数', params); + const { prop, order } = params + if (prop && order) { + const sortType = order === 'ascending' ? 1 : -1 + rawDataList.value.sort((a, b) => { + if (!isNaN(Number(a[prop])) && !isNaN(Number(b[prop]))) { + return (Number(a[prop]) - Number(b[prop])) * sortType + } + return a[prop].localeCompare(b[prop]) * sortType + }) + } +} + +const resetQuery = () => { + queryParams.DateTimeRange = [ + new Date(), + new Date() + ] + getProductdatatableData() +} + +const handleQuery = () => { + getProductdatatableData() +} +onMounted(() => { + getProductdatatableData() +}) \ No newline at end of file diff --git a/src/views/monthlyProductionDataStatistics/index.vue b/src/views/monthlyProductionDataStatistics/index.vue index a160eb1..9a838c1 100644 --- a/src/views/monthlyProductionDataStatistics/index.vue +++ b/src/views/monthlyProductionDataStatistics/index.vue @@ -116,7 +116,7 @@ - + @@ -225,8 +225,8 @@ const getList = debounce(async () => { try { const params = { - // SearchYearMonth: selectedMonth.value, - SearchYearMonth: '2025-11', + SearchYearMonth: selectedMonth.value, + // SearchYearMonth: '2025-11', pageNum: queryParams.pageNum, pageSize: queryParams.pageSize, }; diff --git a/src/views/productManagement/ProWorkorder/index.vue b/src/views/productManagement/ProWorkorder/index.vue index 125d3ec..205c980 100644 --- a/src/views/productManagement/ProWorkorder/index.vue +++ b/src/views/productManagement/ProWorkorder/index.vue @@ -1,8 +1,3 @@ -