minor fix

master
huangjinysf 3 months ago
parent 05952b4882
commit 18fb0719dd

@ -1,7 +1,7 @@
<template>
<div class="app-container">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<!-- <el-col :span="1.5">
<el-button
type="primary"
plain
@ -9,7 +9,7 @@
:loading="loading"
v-hasPermi="['warehouse:WmsImportResult:query']"
>获取维修汇总</el-button>
</el-col>
</el-col> -->
</el-row>
<el-table
@ -48,6 +48,13 @@ const props = defineProps({
selectedEquipmentType: {
type: String,
default: '漆包机'
},
dateRange: {
type: Object,
default: () => ({
start_date: '',
end_date: ''
})
}
})
@ -63,6 +70,15 @@ watch(() => props.selectedEquipmentType, (newVal, oldVal) => {
}
});
//
watch(() => props.dateRange, (newVal, oldVal) => {
console.log('日期范围从', oldVal, '变化为', newVal);
//
if (newVal && newVal.start_date && newVal.end_date) {
handleSummary();
}
}, { deep: true });
//
onMounted(() => {
console.log('组件加载,设备类型:', props.selectedEquipmentType);
@ -80,8 +96,18 @@ const getDaysTagType = (days) => {
//
function handleSummary() {
console.log('设备类型:', props.selectedEquipmentType);
console.log('日期范围:', props.dateRange);
loading.value = true
fetch(`${API_CONFIG.BASE_URL}/api/eq-repair/enamelling-repair-summary?equipment_type=${props.selectedEquipmentType}`)
// API URL
let apiUrl = `${API_CONFIG.BASE_URL}/api/eq-repair/enamelling-repair-summary?equipment_type=${props.selectedEquipmentType}`;
// URL
if (props.dateRange && props.dateRange.start_date && props.dateRange.end_date) {
apiUrl += `&start_date=${props.dateRange.start_date}&end_date=${props.dateRange.end_date}`;
}
fetch(apiUrl)
.then(response => response.json())
.then(data => {
if (data.code === 200 && data.data) {

@ -3,9 +3,9 @@
<el-row :gutter="10" class="mb8">
<el-col :span="2.5">
<el-col :span="3">
<el-form :model="queryForm" label-width="80px">
<el-form-item label="数据范围">
<el-form-item label="时间范围">
<el-select v-model="queryForm.selectedTimeRange" placeholder="选择时间范围" style="width: 100%">
<el-option
v-for="item in timeRangeOptions"
@ -18,16 +18,7 @@
</el-form>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
@click="handlePareto"
v-hasPermi="['warehouse:WmsImportResult:add']"
>帕累托分析</el-button>
</el-col>
<el-col :span="3.5">
<el-col :span="3">
<el-form :model="queryForm" label-width="80px">
<el-form-item label="机台机型">
<el-select v-model="queryForm.selectedEquipmentType" placeholder="选择设备类型" style="width: 100%">
@ -41,7 +32,16 @@
</el-form-item>
</el-form>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
@click="handlePareto"
v-hasPermi="['warehouse:WmsImportResult:add']"
>帕累托分析</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
@ -117,7 +117,7 @@
</template>
<script setup name="WmsImportResult">
import { ref, reactive, shallowRef } from 'vue'
import { ref, reactive, shallowRef, watch } from 'vue'
import { API_CONFIG } from "@/config/api"
import ParetoAnalysis from './ParetoAnalysis.vue'
import ItemAnalysis from './ItemAnalysis.vue'
@ -152,6 +152,37 @@ const dateRange = ref({
//
const currentComponent = shallowRef(EmptyContent)
// dateRange
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)
};
}
});
const data = reactive({
form: {},
queryParams: {
@ -233,6 +264,36 @@ function handleItemAnalysis() {
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
};
//
currentComponent.value = RepairSummary;
}

Loading…
Cancel
Save