|
|
|
|
@ -119,6 +119,7 @@
|
|
|
|
|
<script setup name="WmsImportResult">
|
|
|
|
|
import { ref, reactive, shallowRef, watch } from 'vue'
|
|
|
|
|
import { API_CONFIG } from "@/config/api"
|
|
|
|
|
import { getDateRangeByTimeRange } from "@/utils/dateFormat"
|
|
|
|
|
import ParetoAnalysis from './ParetoAnalysis.vue'
|
|
|
|
|
import ItemAnalysis from './ItemAnalysis.vue'
|
|
|
|
|
import EmptyContent from './EmptyContent.vue'
|
|
|
|
|
@ -156,30 +157,7 @@ const currentComponent = shallowRef(EmptyContent)
|
|
|
|
|
watch(() => queryForm.value.selectedTimeRange, (newTimeRange) => {
|
|
|
|
|
// 如果当前是维修汇总组件,则更新dateRange并刷新数据
|
|
|
|
|
if (currentComponent.value === RepairSummary) {
|
|
|
|
|
// 根据选择的时间范围计算开始和结束日期
|
|
|
|
|
const endDate = new Date();
|
|
|
|
|
const startDate = new Date();
|
|
|
|
|
|
|
|
|
|
if (newTimeRange === '近1年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 1);
|
|
|
|
|
} else if (newTimeRange === '近2年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 2);
|
|
|
|
|
} else if (newTimeRange === '近3年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 格式化日期为 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}`;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
dateRange.value = {
|
|
|
|
|
start_date: formatDate(startDate),
|
|
|
|
|
end_date: formatDate(endDate)
|
|
|
|
|
};
|
|
|
|
|
dateRange.value = getDateRangeByTimeRange(newTimeRange);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -203,27 +181,8 @@ const data = reactive({
|
|
|
|
|
|
|
|
|
|
function handlePareto() {
|
|
|
|
|
// 根据选择的时间范围计算开始和结束日期
|
|
|
|
|
const endDate = new Date();
|
|
|
|
|
const startDate = new Date();
|
|
|
|
|
|
|
|
|
|
if (queryForm.value.selectedTimeRange === '近1年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 1);
|
|
|
|
|
} else if (queryForm.value.selectedTimeRange === '近2年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 2);
|
|
|
|
|
} else if (queryForm.value.selectedTimeRange === '近3年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 格式化日期为 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 startDateStr = formatDate(startDate);
|
|
|
|
|
const endDateStr = formatDate(endDate);
|
|
|
|
|
const dateRange = getDateRangeByTimeRange(queryForm.value.selectedTimeRange);
|
|
|
|
|
const { start_date: startDateStr, end_date: endDateStr } = dateRange;
|
|
|
|
|
|
|
|
|
|
// console.log(startDateStr, endDateStr);
|
|
|
|
|
// 调用质检API并显示结果
|
|
|
|
|
@ -266,33 +225,7 @@ function handleRepairSummary() {
|
|
|
|
|
console.log('切换到维修汇总组件,设备类型:', queryForm.value.selectedEquipmentType);
|
|
|
|
|
|
|
|
|
|
// 根据选择的时间范围计算开始和结束日期
|
|
|
|
|
const endDate = new Date();
|
|
|
|
|
const startDate = new Date();
|
|
|
|
|
|
|
|
|
|
if (queryForm.value.selectedTimeRange === '近1年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 1);
|
|
|
|
|
} else if (queryForm.value.selectedTimeRange === '近2年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 2);
|
|
|
|
|
} else if (queryForm.value.selectedTimeRange === '近3年') {
|
|
|
|
|
startDate.setFullYear(endDate.getFullYear() - 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 格式化日期为 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 startDateStr = formatDate(startDate);
|
|
|
|
|
const endDateStr = formatDate(endDate);
|
|
|
|
|
|
|
|
|
|
// 更新dateRange
|
|
|
|
|
dateRange.value = {
|
|
|
|
|
start_date: startDateStr,
|
|
|
|
|
end_date: endDateStr
|
|
|
|
|
};
|
|
|
|
|
dateRange.value = getDateRangeByTimeRange(queryForm.value.selectedTimeRange);
|
|
|
|
|
|
|
|
|
|
// 切换到维修汇总组件
|
|
|
|
|
currentComponent.value = RepairSummary;
|
|
|
|
|
|