jiangping
2023-10-24 349bcef9a96391d22522a3409adf5a89e7e70a95
screen_standard/src/views/process.vue
@@ -17,13 +17,13 @@
            <div ref="planContainer" class="scroll_container">
              <div v-for="(item, index) in listData" :key="item.id" class="scroll_item"
                :class="index % 2 == 0 ? 'scroll_item scroll_item_bg1' : 'scroll_item scroll_item_bg2'">
                <div class="scroll_item_row">{{ item.name }}</div>
                <div class="scroll_item_row">1</div>
                <div class="scroll_item_row">2</div>
                <div class="scroll_item_row">3</div>
                <div class="scroll_item_row">4</div>
                <div class="scroll_item_row">4</div>
                <div class="scroll_item_row">4</div>
                <div class="scroll_item_row">{{ item.materialName }}</div>
                <div class="scroll_item_row">{{ item.materialCode }}</div>
                <div class="scroll_item_row">{{ item.num }}</div>
                <div class="scroll_item_row">{{ item.qualifiedNum }}</div>
                <div class="scroll_item_row">{{ item.unqualifiedNum }}</div>
                <div class="scroll_item_row">{{ item.undoneNum }}</div>
                <div class="scroll_item_row">{{ (item.unqualifiedRate||0).toFixed(2) }}%</div>
              </div>
            </div>
          </div>
@@ -34,31 +34,31 @@
        <div class="yield-content">
          <div class="yield-content-left">
            <div class="content_left_item1_content">
              <div class="content_left_item1_content_row" v-for="(item, index) in 5" :key="index">
              <div class="content_left_item1_content_row" v-for="(item, index) in top1" :key="index">
                <div class="content_left_item1_content_row_name">
                  <div :class="index > 2 ? 'num bg1' : 'num bg2'">{{ index + 1 }}</div>
                  <span>赵立{{ index }}</span>
                  <span>{{ item.userName }}</span>
                </div>
                <div class="content_left_item1_content_row_line">
                  <el-progress :show-text="false" :percentage="50">
                  <el-progress :show-text="false" :percentage="(item.doneNum||0) / baseNum * 100">
                  </el-progress>
                </div>
                <div class="content_left_item1_content_row_num">342</div>
                <div class="content_left_item1_content_row_num">{{ item.doneNum||0 }}</div>
              </div>
            </div>
          </div>
          <div class="yield-content-left">
            <div class="content_left_item1_content">
              <div class="content_left_item1_content_row" v-for="(item, index) in 5" :key="index">
              <div class="content_left_item1_content_row" v-for="(item, index) in top2" :key="index">
                <div class="content_left_item1_content_row_name">
                  <div class="num bg1">{{ index + 6 }}</div>
                  <span>赵立{{ index }}</span>
                  <span>{{ item.userName }}</span>
                </div>
                <div class="content_left_item1_content_row_line">
                  <el-progress :show-text="false" :percentage="50">
                  <el-progress :show-text="false" :percentage="item.doneNum / baseNum * 100">
                  </el-progress>
                </div>
                <div class="content_left_item1_content_row_num">342</div>
                <div class="content_left_item1_content_row_num">{{ item.doneNum }}</div>
              </div>
            </div>
          </div>
@@ -81,15 +81,15 @@
          </div>
          <div @mouseenter="handleMouseEnterReport" @mouseleave="handleMouseLeaveReport" class="tablel_container">
            <div ref="reportLogContainer" class="scroll_container">
              <div v-for="(item, index) in listData" :key="item.id" class="scroll_item"
              <div v-for="(item, index) in reportListData" :key="item.id" class="scroll_item"
                :class="index % 2 == 0 ? 'scroll_item scroll_item_bg1' : 'scroll_item scroll_item_bg2'">
                <div class="scroll_item_row">{{ item.name }}</div>
                <div class="scroll_item_row">1</div>
                <div class="scroll_item_row">2</div>
                <div class="scroll_item_row">3</div>
                <div class="scroll_item_row">4</div>
                <div class="scroll_item_row">4</div>
                <div class="scroll_item_row">4</div>
                <div class="scroll_item_row">{{ item.userName }}</div>
                <div class="scroll_item_row">{{ item.materialName }}</div>
                <div class="scroll_item_row">{{ item.materialCode }}</div>
                <div class="scroll_item_row">{{ dateToSub(item.createTime) }}</div>
                <div class="scroll_item_row">{{ item.qualifiedNum }}</div>
                <div class="scroll_item_row">{{ item.unqualifiedNum }}</div>
                <div class="scroll_item_row">{{ (item.unqualifiedRate||0).toFixed(2) }}%</div>
              </div>
            </div>
          </div>
@@ -99,7 +99,13 @@
        <div class="header-title">近7天不良品分布</div>
        <div class="bad-content">
          <div id="day-distribution"></div>
          <div id="type-distribution"></div>
          <div class="pie">
            <div class="content_right_top_nr_bottom_yuan">
              <span>{{ allBad }}</span>
              <span>不良项分布</span>
            </div>
            <div id="type-distribution"></div>
          </div>
        </div>
      </div>
    </div>
@@ -107,98 +113,152 @@
</template>
<script setup>
import { reactive, ref, onMounted, onBeforeUnmount, onUnmounted, nextTick } 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'
import { dateToSub } from '@/utils'
import * as echarts from 'echarts'
let planTimer = ref(null)
let reportTimer = ref(null)
const route = useRoute()
const enterprise = useCounterStore()
let mainTimer = ref(null)
let scrollTimer = ref(null)
let planContainer = ref(null)
let reportLogContainer = ref(null)
let listData = reactive([
  { name: 'dom第一个' },
  { name: 'dom第二个' },
  { name: 'dom第三个' },
  { name: 'dom第四个' },
  { name: 'dom第五个' },
  { name: 'dom第六个' },
  { name: 'dom第七个' },
  { name: 'dom第八个' },
  { name: 'dom第九个' },
  { name: 'dom第十个' },
  { name: 'dom第十个' },
  { name: 'dom第十个' },
  { name: 'dom第十个' },
  { name: 'dom第十个' },
  { name: 'dom第十个' },
  { name: 'dom第十个' },
  { name: 'dom第十个' },
])
let dayDistribution = reactive([
  { date: '8/1', num: '20' },
  { date: '8/2', num: '10' },
  { date: '8/3', num: '20' },
  { date: '8/4', num: '40' },
  { date: '8/5', num: '30' },
  { date: '8/6', num: '10' },
  { date: '8/7', num: '20' },
])
// start()
onBeforeUnmount(() => {
  clearTimeout(planTimer.value)
  clearTimeout(reportTimer.value)
const data = reactive({
  listData: [],
  reportListData: [],
  top1: [],
  top2: [],
  baseNum: 0,
  allBad: 0,
  dayDistribution: [],
  typeDistribution: [
    { categoryName: '外观不良', unqualifiedNum: 15 },
    { categoryName: '有毛刺', unqualifiedNum: 12 },
    { categoryName: '尺寸不良', unqualifiedNum: 22 },
    { categoryName: '有划痕', unqualifiedNum: 5 },
    { categoryName: '其他', unqualifiedNum: 2 },
  ],
  planScroll: false,
  reportScroll: false,
})
let { listData, top1, top2, baseNum, allBad, reportListData } = toRefs(data)
onMounted(() => {
  nextTick(() => {
    // start()
    // reportStart()
    setDayChart()
  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)
})
function initData() {
  // 计划数
  getProcedurePlanData(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId })
    .then(res => {
      enterprise.setNum(res)
    })
  // top10
  getTop(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId })
    .then(res => {
      if (res.length) {
        data.baseNum = res[0].doneNum
        data.top1 = []
        data.top2 = []
        if (res.length <= 5) {
          data.top1 = res
        } else {
          res.forEach((item, index) => {
            if (index < 5) {
              data.top1.push(item)
            } else {
              data.top2.push(item)
            }
          })
        }
      }
    })
  // 工序计划进度查询
  getProcedurePlansList(enterprise.companyId, enterprise.departId, { procedureId: route.query.procedureId })
    .then(res => {
      data.listData = res
      data.planScroll = true
    })
  // 报工日志分页查询
  getRecordLogPage(enterprise.companyId, enterprise.departId, { capacity: 20, page: 1, model: { procedureId: route.query.procedureId } })
    .then(res => {
      data.reportListData = res.records
      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
      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
  // 判读组件是否渲染完成
  if (scrollDom.offsetHeight == 0) {
    scrollDom = planContainer.value
  } else {
    // 如果列表数量过少不进行滚动
    if (scrollDom.children.length < 4) {
      clearTimeout(planTimer.value)
    if (scrollDom.children.length < 11) {
      data.planScroll = false
      return
    }
    // scrollTop指的是“元素中的内容”超出“元素上边界”的那部分的高度
    // scrollHeight指整个元素的高度,与元素本身有关,是元素本身的高度与你所设置的style属性相加的结果,但与overflow:hidden等属性无关,与是否在可视范围内无关
    // clientHeight含义:元素的像素高度,包含元素的高度+内边距,不包含水平滚动条,边框和外边距
    // 组件进行滚动
    scrollDom.scrollTop += 2
    scrollDom.scrollTop += 2
    console.log(scrollDom.scrollTop);
    // 判断是否滚动到底部
    if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight)) {
    if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight - 2)) {
      // 获取组件第一个节点
      let first = scrollDom.children[0]
      // 删除节点
@@ -209,29 +269,26 @@
  }
}
/**
 * 报工日志
 * 报工日志滚动方法
 */
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
  // 判读组件是否渲染完成
  if (scrollDom.offsetHeight == 0) {
    scrollDom = reportLogContainer.value
  } else {
    // 如果列表数量过少不进行滚动
    if (scrollDom.children.length < 4) {
      clearTimeout(reportTimer.value)
    if (scrollDom.children.length <= 10) {
      data.reportScroll = false
      return
    }
    // 组件进行滚动
    scrollDom.scrollTop += 2
    scrollDom.scrollTop += 1
    console.log(scrollDom.scrollTop);
    // 判断是否滚动到底部
    if (scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight)) {
    if (scrollDom.scrollTop && scrollDom.scrollTop >= (scrollDom.scrollHeight - scrollDom.clientHeight)) {
      // 获取组件第一个节点
      let first = scrollDom.children[0]
      // 删除节点
@@ -241,25 +298,31 @@
    }
  }
}
/** */
/**
 * 七日折线图
 */
function setDayChart() {
  let dayChartDom = document.getElementById('day-distribution');
  let myChart = echarts.init(dayChartDom);
  let dateList = []
  let numList = []
  dayDistribution.forEach(item => {
    dateList.push(item.date)
    numList.push(item.num)
  data.dayDistribution.forEach(item => {
    dateList.push(item.createTime)
    numList.push(item.unqualifiedNum || 0)
  })
  let option;
  option = {
    title: {
      text: '         近七日不良品总数:67',
      text: `        近七日不良品总数:${data.allBad}`,
      textStyle: {
        color: '#fff',
        fontSize: 12
      }
    },
    grid: {
      top: 40,
      bottom: 40
    },
    xAxis: {
      type: 'category',
@@ -270,6 +333,15 @@
          color: ['#fff']
        }
      },
      axisLine: {
        show: true,
        onZero: true,
        lineStyle: {
          width: 1,
          color: '#fff',
          opacity: .5
        }
      },
      axisLabel: {
        textStyle: {
          color: '#fff'
@@ -277,13 +349,22 @@
      },
      data: dateList
    },
    yAxis: {
      type: 'value',
      splitLine: {
        lineStyle: {
          width: 0.5,
          color: ['#fff']
        }
      },
      axisLine: {
        show: true,
        onZero: true,
        lineStyle: {
          width: 1,
          color: '#fff',
          opacity: .5
        }
      },
      axisLabel: {
@@ -326,69 +407,88 @@
      textStyle: {
        color: '#fff'
      }
    },
    // xAxis: {
    //   type: 'category',
    //   boundaryGap: false,
    //   axisLabel: {
    //     textStyle: {
    //       color: '#fff'
    //     }
    //   },
    //   axisLine: {
    //     lineStyle: {
    //       color: '#fff'
    //     }
    //   }
    // },
    // yAxis: {
    //   type: 'value',
    //   boundaryGap: [0, '30%'],
    //   splitLine: {
    //     lineStyle: {
    //       width: 0.5,
    //       color: ['#fff']
    //     }
    //   },
    //   axisLabel: {
    //     textStyle: {
    //       color: '#fff'
    //     }
    //   }
    // },
    // visualMap: {
    //   type: 'piecewise',
    //   show: false,
    //   dimension: 0,
    //   seriesIndex: 0,
    // },
    // series: [
    //   {
    //     type: 'line',
    //     smooth: 0.6,
    //     symbol: 'none',
    //     lineStyle: {
    //       color: '#03D2B5',
    //       width: 1
    //     },
    //     areaStyle: {
    //       color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    //         {
    //           offset: 0,
    //           color: 'rgba(3, 210, 181, .9)',
    //         },
    //         {
    //           offset: 1,
    //           color: 'rgba(3, 210, 181, 0)',
    //         }
    //       ])
    //     },
    //     data: dateList
    //   }
    // ]
    }
  }
  option && myChart.setOption(option);
}
/**
 * 不良类型分布
 */
function setTypeChart() {
  let dayChartDom = document.getElementById('type-distribution');
  let myChart = echarts.init(dayChartDom);
  let legendData = []
  let seriesData = []
  data.typeDistribution.forEach(item => {
    legendData.push(item.categoryName)
    seriesData.push({ name: item.categoryName, value: item.unqualifiedNum })
  })
  let option = {
    legend: {
      show: false,
      type: 'scroll',
      orient: 'vertical',
      right: 10,
      top: 20,
      bottom: 20,
      data: legendData
    },
    series: [
      {
        // name: '姓名',
        type: 'pie',
        radius: ['60%', '70%'],
        // avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 4,
          borderColor: 'rgba(52, 88, 159, 0.4)',
          borderWidth: 4
        },
        center: ['50%', '50%'],
        labelLine: {
          show: false
        },
        label: {
          formatter: '{dot| } {title|{b} {c}}\n{per|{d}%}',
          rich: {
            title: {
              color: '#fff',
              lineHeight: 13,
              fontSize: 10
            },
            per: {
              color: '#01D9FE',
              fontSize: 10
            },
            dot: {
              backgroundColor: 'inherit',
              width: 8,
              height: 8,
              borderRadius: 4
            }
          }
        },
        // labelLayout: {
        //   hideOverlap: true
        // },
        endLabel: {
          show: true,
          distance: 5,
          color: "red"
        },
        data: seriesData,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 1)'
          }
        }
      }
    ]
  }
  option && myChart.setOption(option);
}
</script>
@@ -396,7 +496,7 @@
<style lang="scss" scoped>
.proccess-content {
  display: flex;
  flex: 1;
  .header-title {
    background-image: url('@/assets/img/gongxu_title@2x.png');
    height: 28px;
@@ -414,15 +514,15 @@
  .process-left {
    flex: 1;
    margin-right: 20px;
    .proccess-plan {
      height: 460px;
      height: 464px;
      background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%);
      margin-bottom: 20px;
    }
    .today-yield {
      height: 222px;
      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 {
@@ -458,6 +558,11 @@
                  font-weight: 400;
                  color: #D2E0FF;
                  margin-left: 9px;
                  width: 50px;
                  white-space: nowrap;
                  text-overflow: ellipsis;
                  -webkit-text-overflow: ellipsis;
                  overflow: hidden;
                }
                .num {
@@ -517,26 +622,68 @@
    flex: 1;
    .report-log {
      height: 460px;
      height: 464px;
      background: linear-gradient(180deg, rgba(52, 88, 159, 0) 0%, rgba(0, 86, 255, 0.4) 100%);
      margin-bottom: 20px;
    }
    .bad-diagram {
      height: 222px;
      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 {
        display: flex;
        margin-top: 20px;
        #day-distribution {
          // padding: 20px;
          box-sizing: border-box;
          flex: 0.5;
          height: 190px;
        }
        #type-distribution {
        .pie {
          flex: 0.4;
          position: relative;
          #type-distribution {
            width: 100%;
            height: 100%;
          }
          .content_right_top_nr_bottom_yuan {
            position: absolute;
            top: calc(50% - 50px);
            left: calc(50% - 50px);;
            z-index: 999;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            border: 2px dashed #01D9FE;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            span {
              &:first-child {
                font-size: 26px;
                font-family: SourceHanSansSC-Medium, SourceHanSansSC;
                font-weight: 500;
                color: #FFFFFF;
              }
              &:last-child {
                font-size: 13px;
                font-family: SourceHanSansSC-Regular, SourceHanSansSC;
                font-weight: 400;
                color: rgba(255, 255, 255, 0.8);
              }
            }
          }
        }
      }
    }
  }
@@ -605,9 +752,9 @@
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 13px;
        }
      }
    }
  }
}
</style>
}</style>