riku
2024-09-11 89ab2ec7f8790c5cc184de98682af032c69c2afc
src/views/management/TaskStats.vue
@@ -1,15 +1,16 @@
<template>
  <div class="border-r-small">
    <div class="font-large">任务监控</div>
    <el-row justify="space-evenly">
      <el-statistic title="今日完成" :value="10"> </el-statistic>
      <el-statistic title="本周完成" :value="10"> </el-statistic>
    </el-row>
    <!-- <el-row> -->
    <TaskItem v-for="item in tasks" :key="item.guid" v-bind="item"></TaskItem>
    <!-- </el-row> -->
  <BaseCard>
    <div>任务监控</div>
    <el-scrollbar ref="scrollbarRef" :height="height">
      <!-- <el-row justify="space-evenly">
        <el-statistic title="今日完成" :value="10"> </el-statistic>
        <el-statistic title="本周完成" :value="10"> </el-statistic>
      </el-row> -->
      <!-- <el-row> -->
      <TaskItem v-for="item in tasks" :key="item.guid" v-bind="item"></TaskItem>
      <!-- </el-row> -->
    <!-- <el-row>
      <!-- <el-row>
      <el-col :span="12">
        <SelfInspection></SelfInspection>
      </el-col>
@@ -17,62 +18,67 @@
        <JointEnforcement></JointEnforcement>
      </el-col>
    </el-row> -->
  </div>
    </el-scrollbar>
  </BaseCard>
</template>
<script>
<script setup>
import { inject, ref, onMounted, computed } from 'vue'
import { unCalc } from '@/utils/css-util'
import SelfInspection from '@/views/inspection/SelfInspection.vue'
import JointEnforcement from '@/views/inspection/JointEnforcement.vue'
import { useSubtaskStore } from '@/stores/subtask.js'
/**
 * 任务完成情况
 */
export default {
  components: { SelfInspection, JointEnforcement },
  props: {
    height: String
  },
  data() {
    return {
      tasks: []
    }
  },
  watch: {},
  methods: {},
  mounted() {
    let i = 0
    while (i < 1) {
      this.tasks.push({
        guid: 'SMuheEkjswioSn7A',
        name: '2024年6月上海市静安区巡查任务',
        district: '静安区',
        planTime: '2024-06',
        startTime: '2024-06-01 00:00:00',
        endTime: '2024-06-30 23:59:59',
        userName: '朱正强#邢子琦',
        status: '正在执行',
        count: [
          {
            sceneType: '工地',
            total: 90,
            finish: 45
          },
          {
            sceneType: '餐饮',
            total: 90,
            finish: 45
          },
          {
            sceneType: '汽修',
            total: 90,
            finish: 45
          }
        ]
const excludeMapHeight = inject('excludeMapHeight')
const height = ref(`calc(${unCalc(excludeMapHeight)} - 36px)`)
const subtaskStore = useSubtaskStore()
const tasks = ref([])
const sceneTaskMap = ref(new Map())
function onGetTaskInfo(tInfo) {
  const resList = []
  sceneTaskMap.value.clear()
  const total = tInfo.totaltask
  tInfo.subTaskSummary.forEach((s) => {
    if (!sceneTaskMap.value.has(s.scene.type)) {
      sceneTaskMap.value.set(s.scene.type, {
        sceneType: s.scene.type,
        total: total,
        finish: 0
      })
      i++
    }
    const st = sceneTaskMap.value.get(s.scene.type)
    st.finish++
  })
  const task = {
    name: tInfo.name,
    province: tInfo.provinceName,
    district: tInfo.districtName,
    totaltask: tInfo.totaltask,
    completetask: tInfo.completetask,
    count: []
  }
  for (const key of sceneTaskMap.value.keys()) {
    const value = sceneTaskMap.value.get(key)
    task.count.push(value)
  }
  resList.push(task)
  tasks.value = resList
}
function cal() {
  subtaskStore.getTaskInfo(onGetTaskInfo)
}
onMounted(() => {
  cal()
})
</script>
<style scoped>