|
|
|
|
@ -27,7 +27,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { DevicePlanGanttRespVO, PlanApi } from '@/api/mes/plan'
|
|
|
|
|
import { PlanApi } from '@/api/mes/plan'
|
|
|
|
|
import ScheduleGanttPanel from '@/views/mes/components/ScheduleGanttPanel.vue'
|
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
|
|
|
|
|
@ -71,44 +71,6 @@ const queryParams = reactive({
|
|
|
|
|
endTime: queryRange.value[1]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const formatDetailDate = (value: string | number | null | undefined) => {
|
|
|
|
|
const date = dayjs(value)
|
|
|
|
|
if (!date.isValid()) return ''
|
|
|
|
|
return date.format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const calcScheduleDays = (start: string, end: string) => {
|
|
|
|
|
const startValue = dayjs(start)
|
|
|
|
|
const endValue = dayjs(end)
|
|
|
|
|
if (!startValue.isValid() || !endValue.isValid()) return 1
|
|
|
|
|
return Math.max(endValue.endOf('day').diff(startValue.startOf('day'), 'day') + 1, 1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapScheduleList = (list: DevicePlanGanttRespVO[]): UnifiedDevice[] =>
|
|
|
|
|
(Array.isArray(list) ? list : []).map((device) => ({
|
|
|
|
|
deviceId: device?.deviceId ?? '',
|
|
|
|
|
deviceName: device?.deviceName ?? '-',
|
|
|
|
|
plans: (device?.plans ?? []).map((plan, index) => {
|
|
|
|
|
const current = plan as any
|
|
|
|
|
const planStartTimeStr = formatDetailDate(current?.planStartTime)
|
|
|
|
|
const planEndTimeStr = formatDetailDate(current?.planEndTime)
|
|
|
|
|
return {
|
|
|
|
|
taskId: current?.taskId ?? current?.planId ?? index,
|
|
|
|
|
taskDetailId: current?.planId ?? index,
|
|
|
|
|
taskCode: String(current?.planId ?? '-'),
|
|
|
|
|
productCode: String(current?.productCode ?? '-'),
|
|
|
|
|
productName: String(current?.productName ?? '-'),
|
|
|
|
|
planNumber: Number(current?.planNumber ?? 0),
|
|
|
|
|
planStartTimeStr,
|
|
|
|
|
planEndTimeStr,
|
|
|
|
|
latestStartTimeStr: formatDetailDate(current?.latestStartTime),
|
|
|
|
|
deliveryDateStr: formatDetailDate(current?.deliveryDate),
|
|
|
|
|
scheduleDays: calcScheduleDays(planStartTimeStr, planEndTimeStr),
|
|
|
|
|
sourceType: 'HISTORY' as const
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
|
|
|
|
@ -116,7 +78,7 @@ const getList = async () => {
|
|
|
|
|
startTime: queryParams.startTime,
|
|
|
|
|
endTime: queryParams.endTime
|
|
|
|
|
})
|
|
|
|
|
scheduleList.value = mapScheduleList(data)
|
|
|
|
|
scheduleList.value = data
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
|