|  |  |  | 
|---|
|  |  |  | </template> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <script setup> | 
|---|
|  |  |  | import { reactive, ref, toRefs, onMounted, onBeforeUnmount, onUnmounted } from 'vue' | 
|---|
|  |  |  | import { reactive, ref, toRefs, onMounted, onUnmounted, nextTick } from 'vue' | 
|---|
|  |  |  | import { getProcedurePlanData, getTop, getProcedurePlansList, getRecordLogPage, getUnqualified7DayData, getUnqualifiedCateData } from '@/utils/api.js' | 
|---|
|  |  |  | import { useCounterStore } from '@/stores/counter.js' | 
|---|
|  |  |  | import { useRoute } from 'vue-router' | 
|---|
|  |  |  | 
|---|
|  |  |  | const route = useRoute() | 
|---|
|  |  |  | const enterprise = useCounterStore() | 
|---|
|  |  |  | let mainTimer = ref(null) | 
|---|
|  |  |  | let planTimer = ref(null) | 
|---|
|  |  |  | let reportTimer = ref(null) | 
|---|
|  |  |  | let scrollTimer = ref(null) | 
|---|
|  |  |  | let planContainer = ref(null) | 
|---|
|  |  |  | let reportLogContainer = ref(null) | 
|---|
|  |  |  | const data = reactive({ | 
|---|
|  |  |  | 
|---|
|  |  |  | { categoryName: '尺寸不良', unqualifiedNum: 22 }, | 
|---|
|  |  |  | { categoryName: '有划痕', unqualifiedNum: 5 }, | 
|---|
|  |  |  | { categoryName: '其他', unqualifiedNum: 2 }, | 
|---|
|  |  |  | ] | 
|---|
|  |  |  | ], | 
|---|
|  |  |  | planScroll: false, | 
|---|
|  |  |  | reportScroll: false, | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let { listData, top1, top2, baseNum, allBad, reportListData } = toRefs(data) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // start() | 
|---|
|  |  |  | onBeforeUnmount(() => { | 
|---|
|  |  |  | clearTimeout(planTimer.value) | 
|---|
|  |  |  | clearTimeout(reportTimer.value) | 
|---|
|  |  |  | clearTimeout(mainTimer.value) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | onMounted(() => { | 
|---|
|  |  |  | window.addEventListener('resize', () => { | 
|---|
|  |  |  | console.log('resize'); | 
|---|
|  |  |  | nextTick(() => { | 
|---|
|  |  |  | setDayChart() | 
|---|
|  |  |  | setTypeChart() | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | initData() | 
|---|
|  |  |  | scrollTimer.value = setInterval(() => { | 
|---|
|  |  |  | ListScroll() | 
|---|
|  |  |  | reportScroll() | 
|---|
|  |  |  | }, 100) | 
|---|
|  |  |  | mainTimer.value = setInterval(() => { | 
|---|
|  |  |  | initData() | 
|---|
|  |  |  | }, 60000) | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | onUnmounted(() => { | 
|---|
|  |  |  | clearTimeout(planTimer.value) | 
|---|
|  |  |  | clearTimeout(reportTimer.value) | 
|---|
|  |  |  | clearTimeout(scrollTimer.value) | 
|---|
|  |  |  | clearTimeout(mainTimer.value) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | getTop(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId }) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | if (res.length) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | data.baseNum = res[0].doneNum | 
|---|
|  |  |  | data.top1 = [] | 
|---|
|  |  |  | data.top2 = [] | 
|---|
|  |  |  | 
|---|
|  |  |  | getProcedurePlansList(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId }) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | data.listData = res | 
|---|
|  |  |  | start() | 
|---|
|  |  |  | data.planScroll = true | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | // 报工日志分页查询 | 
|---|
|  |  |  | getRecordLogPage(enterprise.companyId, enterprise.departId, { capacity: 20, page: 1, model: { procedureId: route.query.procedureId } }) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | data.reportListData = res.records | 
|---|
|  |  |  | reportStart() | 
|---|
|  |  |  | data.reportScroll = true | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | getUnqualified7DayData(enterprise.companyId, enterprise.departId, route.query.procedureId) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | data.dayDistribution = res | 
|---|
|  |  |  | data.allBad = res.reduce((accumulator, currentValue) => accumulator + currentValue.unqualifiedNum, 0) | 
|---|
|  |  |  | setDayChart() | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | getUnqualifiedCateData(enterprise.companyId, enterprise.departId, route.query.procedureId) | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | data.typeDistribution = res | 
|---|
|  |  |  | data.allBad = res.reduce((accumulator, currentValue) => accumulator + currentValue.unqualifiedNum, 0) | 
|---|
|  |  |  | setTypeChart() | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 鼠标移入 | 
|---|
|  |  |  | function handleMouseEnter() { | 
|---|
|  |  |  | clearTimeout(planTimer.value) | 
|---|
|  |  |  | data.planScroll = false | 
|---|
|  |  |  | } | 
|---|
|  |  |  | function handleMouseLeave() { | 
|---|
|  |  |  | start() | 
|---|
|  |  |  | data.planScroll = true | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 鼠标移除 | 
|---|
|  |  |  | function handleMouseEnterReport() { | 
|---|
|  |  |  | clearTimeout(reportTimer.value) | 
|---|
|  |  |  | data.reportScroll = false | 
|---|
|  |  |  | } | 
|---|
|  |  |  | function handleMouseLeaveReport() { | 
|---|
|  |  |  | reportStart() | 
|---|
|  |  |  | data.reportScroll = true | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 工序计划 | 
|---|
|  |  |  | * 工序计划滚动方法 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | // 开启定时器 | 
|---|
|  |  |  | function start() { | 
|---|
|  |  |  | clearTimeout(planTimer.value) | 
|---|
|  |  |  | // 定时器触发周期 | 
|---|
|  |  |  | // let speed = ref(100) | 
|---|
|  |  |  | planTimer.value = setInterval(ListScroll, 100) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | function ListScroll() { | 
|---|
|  |  |  | if (!data.planScroll) return | 
|---|
|  |  |  | let scrollDom = planContainer.value | 
|---|
|  |  |  | if (!scrollDom) return | 
|---|
|  |  |  | // 判读组件是否渲染完成 | 
|---|
|  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 如果列表数量过少不进行滚动 | 
|---|
|  |  |  | if (scrollDom.children.length < 11) { | 
|---|
|  |  |  | clearTimeout(planTimer.value) | 
|---|
|  |  |  | data.planScroll = false | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 组件进行滚动 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 报工日志 | 
|---|
|  |  |  | * 报工日志滚动方法 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | function reportStart() { | 
|---|
|  |  |  | clearTimeout(reportTimer.value) | 
|---|
|  |  |  | // 定时器触发周期 | 
|---|
|  |  |  | // let speed = ref(100) | 
|---|
|  |  |  | reportTimer.value = setInterval(reportScroll, 100) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | function reportScroll() { | 
|---|
|  |  |  | if (!data.reportScroll) return | 
|---|
|  |  |  | let scrollDom = reportLogContainer.value | 
|---|
|  |  |  | if (!scrollDom) return | 
|---|
|  |  |  | // 判读组件是否渲染完成 | 
|---|
|  |  |  | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | // 如果列表数量过少不进行滚动 | 
|---|
|  |  |  | if (scrollDom.children.length < 10) { | 
|---|
|  |  |  | clearTimeout(reportTimer.value) | 
|---|
|  |  |  | data.reportScroll = false | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 组件进行滚动 | 
|---|
|  |  |  | scrollDom.scrollTop += 1.5 | 
|---|
|  |  |  | scrollDom.scrollTop += 2 | 
|---|
|  |  |  | // 判断是否滚动到底部 | 
|---|
|  |  |  | if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight)) { | 
|---|
|  |  |  | if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight - 2)) { | 
|---|
|  |  |  | // 获取组件第一个节点 | 
|---|
|  |  |  | let first = scrollDom.children[0] | 
|---|
|  |  |  | // 删除节点 | 
|---|
|  |  |  | 
|---|
|  |  |  | color: '#fff', | 
|---|
|  |  |  | fontSize: 12 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | grid: { | 
|---|
|  |  |  | top: 40, | 
|---|
|  |  |  | bottom: 40 | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | xAxis: { | 
|---|
|  |  |  | type: 'category', | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | function setTypeChart() { | 
|---|
|  |  |  | let dayChartDom = document.getElementById('type-distribution'); | 
|---|
|  |  |  | console.log(dayChartDom); | 
|---|
|  |  |  | let myChart = echarts.init(dayChartDom); | 
|---|
|  |  |  | let legendData = [] | 
|---|
|  |  |  | let seriesData = [] | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .today-yield { | 
|---|
|  |  |  | height: calc(100vh - 690px);; | 
|---|
|  |  |  | height: calc(100vh - 725px); | 
|---|
|  |  |  | min-height: 226px; | 
|---|
|  |  |  | background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .yield-content { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .bad-diagram { | 
|---|
|  |  |  | height:calc(100vh - 690px);; | 
|---|
|  |  |  | height:calc(100vh - 725px);; | 
|---|
|  |  |  | min-height: 226px; | 
|---|
|  |  |  | background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | .bad-content { | 
|---|