diff --git a/src/views/productionSchedulingPlan/schedulingDashboard/container.vue b/src/views/productionSchedulingPlan/schedulingDashboard/container.vue index a76e0be..0f0176a 100644 --- a/src/views/productionSchedulingPlan/schedulingDashboard/container.vue +++ b/src/views/productionSchedulingPlan/schedulingDashboard/container.vue @@ -74,7 +74,7 @@ start-placeholder="开始日期" end-placeholder="结束日期" size="medium" - :clearable="false" + :clearable="true" :shortcuts="pickerOptions.shortcuts" > @@ -463,6 +463,8 @@ export default { name: 'GanttChart', data() { return { + latestPlanEndTime: null, //新增:用于存储最晚计划结束时间 + earliestPlanStartTime: null, // 新增:用于存储最早计划开始时间 valuerrr: '铜合金化学镀镍', // loading: false, formLabelAlign: { @@ -561,6 +563,12 @@ export default { start.setHours(0, 0, 0, 0); return start; } + if (this.earliestPlanStartTime) { + const base = new Date(this.earliestPlanStartTime); + base.setHours(0, 0, 0, 0); // 这就是“年月日 00:00:00” + return base; + } + // 默认显示当前日期 const now = new Date(); const base = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0); @@ -573,6 +581,12 @@ export default { end.setHours(23, 59, 59, 999); return end; } + // 如果没有时间范围,但有数据,则用最晚计划结束时间 + if (this.latestPlanEndTime) { + const end = new Date(this.latestPlanEndTime); + end.setHours(23, 59, 59, 999); + return end; + } // 默认显示当前日期+2天 const now = new Date(); const base = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 2, 23, 59, 59, 999); @@ -828,7 +842,7 @@ export default { // 参数变化时的处理逻辑 // this.formLabelAlign.teamId = this.tsId; // this.formLabelAlign.teamName = this.tsName; - + this.updateTime(); // 根据参数加载数据 // this.getData(); @@ -949,8 +963,8 @@ export default { if (this.legendStatus.pending) { this.formLabelAlign.planStatusList.push('1'); } - if(type=='reset'){ - sessionStorage.setItem('formLabelAlign',JSON.stringify(this.formLabelAlign)) + if (type == 'reset') { + } this.getData(); @@ -1051,17 +1065,17 @@ export default { // 数据获取 async getData(params) { - if (this.formLabelAlign.timeRange.length > 0) { - this.formLabelAlign.startTime = this.formLabelAlign.timeRange[0]; - this.formLabelAlign.endTime = this.formLabelAlign.timeRange[1]; - } // if (this.formLabelAlign.planStatusList.length <= 0) { // this.formLabelAlign.planStatusList = []; // } - let seeData = sessionStorage.getItem('formLabelAlign'); + let seeData = sessionStorage.getItem('formLabelAlign'); if (seeData) { this.formLabelAlign = JSON.parse(seeData); } + if (this.formLabelAlign.timeRange && this.formLabelAlign.timeRange.length > 0) { + this.formLabelAlign.startTime = this.formLabelAlign.timeRange[0]; + this.formLabelAlign.endTime = this.formLabelAlign.timeRange[1]; + } this.loading = true; await getData(this.formLabelAlign).then(res => { this.processData(res.data.data); @@ -1167,7 +1181,7 @@ export default { woReleaseMap[order.woCode] = order.receiveTime; }); - // 3. 对 tasks 按其所属订单的 receiveTime 升序 + // 3. 对 tasks 按其所属订单的 receiveTime tasks.sort((a, b) => { const dateA = new Date(woReleaseMap[a.woCode] || '1970-01-01'); const dateB = new Date(woReleaseMap[b.woCode] || '1970-01-01'); @@ -1178,7 +1192,28 @@ export default { this.allOrders = orders; this.totalOrders = orders.length; this.taskData = tasks; + let earliest = null; + let latest = null; + tasks.forEach(task => { + if (task.planStartTime) { + const taskTime = new Date(task.planStartTime).getTime(); + + if (earliest === null || taskTime < earliest) { + earliest = taskTime; + } + } + if (task.planEndTime) { + const taskTime = new Date(task.planEndTime).getTime(); + if (latest === null || taskTime > latest) { + latest = taskTime; + } + } + }); + + this.earliestPlanStartTime = earliest ? new Date(earliest) : null; + this.latestPlanEndTime = latest ? new Date(latest) : null; + console.log(new Date(earliest), this.earliestPlanStartTime, 'earliest'); this.updateCurrentPageOrders(); this.loading = false; }, @@ -1232,13 +1267,18 @@ export default { // 事件处理 handleSubmit() { if (!this.formLabelAlign.timeRange || this.formLabelAlign.timeRange.length !== 2) { - this.$message.warning('请选择时间范围'); - return; + // this.$message.warning('请选择时间范围'); + // 将时间范围设置到请求参数中 + this.formLabelAlign.startTime = ''; + this.formLabelAlign.endTime = ''; + // return; + } else { + // 将时间范围设置到请求参数中 + this.formLabelAlign.startTime = this.formLabelAlign.timeRange[0]; + this.formLabelAlign.endTime = this.formLabelAlign.timeRange[1]; } - // 将时间范围设置到请求参数中 - this.formLabelAlign.startTime = this.formLabelAlign.timeRange[0]; - this.formLabelAlign.endTime = this.formLabelAlign.timeRange[1]; - console.log(this.formLabelAlign,'99999'); + + console.log(this.formLabelAlign, '99999'); sessionStorage.setItem('formLabelAlign', JSON.stringify(this.formLabelAlign)); this.getData(); @@ -1258,16 +1298,16 @@ export default { receiveTime: '', //接收时间 partCode: '', //订单号 batchNo: '', //批次号 - planStatusList:[] + planStatusList: ['1','2','3'], }; this.legendStatus.completed = false; this.legendStatus.processing = true; this.legendStatus.pending = true; - - this.updateTime('reset'); - - this.getData(); + // this.updateTime('reset'); + sessionStorage.setItem('formLabelAlign', JSON.stringify(this.formLabelAlign)); + + this.getData(); }, // 任务数据过滤 @@ -1516,6 +1556,15 @@ export default { this.scrollToCurrentTime(); }); }, + + formatDate(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}`; + }, }, };