rk
2026-03-13 0e997dbbfeacaf72e91380d035265836b8df8a7d
admin/src/views/index.vue
@@ -1,104 +1,101 @@
<template>
  <div class="home">
    <div class="home_total">
      <div class="home_total_head">在园人员总览</div>
      <div class="home_total_list">
        <div class="home_total_list_item a">
          <span>{{ head && head.workerCount ? head.workerCount : 0 }}</span>
          <span>内部员工</span>
        </div>
        <div class="home_total_list_item b">
          <span>{{ head && head.visitorCount ? head.visitorCount : 0 }}</span>
          <span>访客</span>
        </div>
        <div class="home_total_list_item c">
          <span>{{ head && head.lwCount ? head.lwCount : 0 }}</span>
          <span>劳务人员</span>
        </div>
        <div class="home_total_list_item d">
          <span>{{
            head && head.presenceCarCount ? head.presenceCarCount : 0
          }}</span>
          <span>在场车辆</span>
        </div>
        <div class="home_total_list_item e">
          <span>{{ head && head.longCarCount ? head.longCarCount : 0 }}</span>
          <span>长期车辆</span>
        </div>
        <div class="home_total_list_item f">
          <span>{{
            head && head.visitorCarCount ? head.visitorCarCount : 0
          }}</span>
          <span>预约车辆</span>
        </div>
        <div class="home_total_list_item g">
          <span>{{ head && head.supplierCount ? head.supplierCount : 0 }}</span>
          <span>供应商</span>
  <div class="main_app1">
    <div class="main_home">
      <div class="home_header">
        <div class="mb10 fs17">下午好,{{ userInfo.realname }}</div>
        <div class="fs13">
          今天是 {{ nowDate }} {{ nowWeek }},欢迎访公务车钥匙智能柜管理系统
        </div>
      </div>
    </div>
    <div class="home_charts">
      <div class="home_charts_item">
        <div class="home_charts_item_label">在园人员占比</div>
        <div class="home_charts_item_charts" id="chart1"></div>
    <div class="main_head">
      <div class="main_head_title" >
        <span>车辆派单统计总览(次)</span>
      </div>
      <div class="home_charts_item">
        <div class="home_charts_item_label">劳务人员分布总览</div>
        <div class="home_charts_item_charts" id="chart2"></div>
      <div class="main_head_bottom">
        <div class="main_head_item blue">
          <span>{{info.todayTotal || 0}}</span>
          <span>今日</span>
        </div>
        <div class="main_head_item red">
          <span>{{info.yesterdayTotal  || 0}}</span>
          <span>昨日</span>
        </div>
        <div class="main_head_item yellow">
          <span>{{info.weekTotal || 0}}</span>
          <span>本周</span>
        </div>
        <div class="main_head_item orange">
          <span>{{info.monthTotal || 0}}</span>
          <span>本月</span>
        </div>
        <div class="main_head_item darkBlue">
          <span>{{info.yearTotal || 0}}</span>
          <span>本年</span>
        </div>
      </div>
    </div>
    <div class="home_table">
      <div class="home_table_head">超时预警人员({{ total }})</div>
      <div class="home_table_box">
        <el-table
          :data="list"
          :header-cell-style="{
            background: '#dcdde2',
            color: 'rgb(51, 51, 51)',
          }"
          border
          style="width: 100%"
        >
          <el-table-column prop="name" label="访客姓名"> </el-table-column>
          <el-table-column prop="phone" label="访客电话"> </el-table-column>
          <el-table-column prop="companyName" label="访客组织">
          </el-table-column>
          <el-table-column label="人员类型">
            <template slot-scope="{ row }">
              <span v-if="row.type === 0">劳务访客</span>
              <span v-if="row.type === 1">普通访客</span>
              <span v-if="row.type === 2">内部人员</span>
            </template>
          </el-table-column>
          <el-table-column prop="outDate" label="授权到期时间">
          </el-table-column>
          <el-table-column label="状态">
            <template slot-scope="{ row }">
              <span v-if="row.outStatus === 0">未超时</span>
              <span style="color: red" v-if="row.outStatus === 1">已超时</span>
              <span v-if="row.outStatus === 2">即将超时</span>
            </template>
          </el-table-column>
          <el-table-column prop="address" label="处理" width="80">
            <template slot-scope="scope">
              <el-button
                type="text"
                @click="departure(scope.row.id)"
                v-if="scope.row.outStatus === 1"
                >离厂</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          style="margin-top: 20px"
          @current-change="handleCurrentChange"
          :current-page="page"
          :page-size="10"
          layout="total, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
    <div class="main_content">
      <div class="type_wrap">
        <div class="title" style="display: flex; align-items: center; justify-content: space-between;">
          <div style="display: flex; align-items: center;">
            <span>全年派车申请趋势(次)</span>
          </div>
        </div>
        <div id="echart1"  ref="typeRef" v-show="info.cumulativeDataList && info.cumulativeDataList.length"></div>
        <div style="width: 100%;height: 100%;display: flex;align-items: center;justify-content: center;" v-show="!info.cumulativeDataList || !info.cumulativeDataList.length">
          <img style="width: 200px;" src="@/assets/images/default_homeimg.png" alt="">
        </div>
      </div>
    </div>
    <div class="main_table">
      <div class="main_table_list">
        <div class="title" style="display: flex; align-items: center; justify-content: space-between;">
          <div style="display: flex; align-items: center;">
            <span>入园车辆统计表</span>
            <el-radio-group style="margin-left: 20px;" v-model="radio" @change="changeBB">
              <el-radio-button label="month">月度</el-radio-button>
              <el-radio-button label="year">年度</el-radio-button>
            </el-radio-group>
            <el-date-picker
                v-model="date1"
                :type="radio"
                :clearable="false"
                @change="getReportLists()"
                :value-format="radio === 'month' ? 'yyyy-MM' : 'yyyy'"
                style="margin-left: 10px; width: 120px;"
                placeholder="请选择">
            </el-date-picker>
          </div>
          <el-button type="primary" style="margin-left: 20px;" icon="el-icon-upload2" @click="daochu">导出</el-button>
        </div>
        <div style="width: 100%;display: flex;margin: 20px">
          <span style="width: 100px;text-align: right;padding-right: 20px;">指定车辆</span>
          <el-select v-model="carCodeList" filterable multiple clearable style="margin-left: 10px;width: 100%;padding-right: 20px; "  @change="getReportLists" placeholder="指定车辆"  >
            <el-option v-for="item in carList" :key="item.code" :label="item.code" :value="item.code">
            </el-option>
          </el-select>
        </div>
        <div style="display: block;">
          <template v-if="column.length > 0">
            <el-table
                style="width: 100%; margin-top: 15px;"
                :data="list"
                :header-row-style="{'background-color': '#F7F7F7'}"
                border
            >
              <el-table-column :prop="item" :label="item" align="center" :fixed="index === 0 ? true : index === column.length - 1 ? 'right' : false" v-for="(item, index) in column" :key="index">
                <template slot-scope="{row}">
                  <span v-if="row[item] && row[item] >0" class="green"  style="font-weight: 600;">{{row[item]}}</span>
                  <span v-else   >{{row[item]}}</span>
                </template>
              </el-table-column>
            </el-table>
          </template>
          <div style="width: 100%;margin-top: 100px;height: 100px;display: flex;align-items: center;justify-content: center;" v-else>
            <img style="width: 200px;" src="@/assets/images/default_homeimg.png" alt="">
          </div>
        </div>
      </div>
    </div>
  </div>
@@ -106,280 +103,510 @@
<script>
import * as echarts from 'echarts'
import { body, head, timeoutPage, level } from '@/api/business/staging'
import { getCarUseData, getReportList, reportExportExcel } from '@/api/business/carUseBook'
import dayjs from 'dayjs'
import { weeks } from '@/utils/config'
import { allList as carList } from '@/api/business/cars'
export default {
  name: 'Index',
  data() {
  data () {
    return {
      head: null,
      info: { cumulativeDataList: [] },
      nowDate: '',
      nowWeek: '',
      isGroupBy: 0,
      radio: 'month',
      value: '',
      dateType: 'month',
      date: '',
      carids: [],
      carList: [],
      date1: '',
      column: [],
      list: [],
      total: 0,
      data1: [],
      data2: [[], []],
      page: 1
      carCodeList: []
    }
  },
  created() {
    this.getHeader()
    this.getData()
  computed: {
    userInfo () {
      return this.$store.state.userInfo
    }
  },
  mounted() {
    // this.getcharts2()
  mounted () {
    var now = new Date()
    var year = now.getFullYear()
    var month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`
    this.value = `${year}-${month}`
    this.date1 = `${year}-${month}`
    this.updateDate()
    this.getData()
    this.loadCars()
    this.getReportLists()
  },
  methods: {
    departure(id) {
      this.$confirm('确定离场吗, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        level(id)
          .then(res => {
            this.page = 1
            this.getData()
          })
      }).catch(() => {
    loadCars () {
      carList({
        type: 0 // 公务车
      })
    },
    getData() {
      timeoutPage({
        capacity: 10,
        page: this.page,
        model: {}
      }).then(res => {
        this.list = res.records
        this.total = res.total
      })
    },
    getHeader() {
      head().then(res => {
        this.head = res
      })
      body().then(res => {
        this.data1 = res.retentionUsers.map(item => {
          let name = ''
          if (item.memberType === 0) {
            name = '劳务访客'
          } else if (item.memberType === 1) {
            name = '普通访客'
          } else if (item.memberType === 2) {
            name = '内部员工'
          }
          return {
            value: item.memberCount,
            name
          }
        .then(res => {
          this.carList = res
        })
        let arr1 = res.companyUsers.map(item => item.companyName)
        let arr2 = res.companyUsers.map(item => item.memberCount)
        if (arr1.length > 0) {
          this.data2 = [arr1, arr2]
          this.getcharts2()
        }
        this.getcharts1()
        .catch(e => {
        })
        .finally(() => {
        })
    },
    updateDate () {
      this.nowDate = dayjs().format('YYYY年M月D日')
      this.nowWeek = weeks[new Date().getDay()]
    },
    daochu () {
      reportExportExcel({ dateStr: this.date1, carCodeList: this.carCodeList}).then(res => {
        this.download(res)
      })
    },
    handleCurrentChange(page) {
      this.page = page
      this.getData()
    getReportLists () {
      this.column=[]
      this.list=[]
      getReportList({ dateStr: this.date1, carCodeList: this.carCodeList, type: 0 })
        .then(res => {
          if (res && res.length) {
            this.column = res[0]
            this.list = res.slice(1).map(row => {
              const obj = {}
              this.column.forEach((header, index) => {
                obj[header] = row[index]
              })
              return obj
            })
          }
          console.log(this.list)
        })
    },
    getcharts1() {
      const myChart = echarts.init(document.getElementById('chart1'))
      // 绘制图表
      myChart.setOption({
    changeBB () {
      if (this.radio === 'month') {
        const now = new Date()
        const year = now.getFullYear()
        const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`
        this.date1 = `${year}-${month}`
      } else {
        const now = new Date()
        const year = now.getFullYear()
        this.date1 = `${year}`
      }
      this.getReportLists()
    },
    changeDateType () {
      if (this.dateType === 'month') {
        const now = new Date()
        const year = now.getFullYear()
        const month = now.getMonth() + 1 > 9 ? now.getMonth() + 1 : `0${now.getMonth() + 1}`
        this.value = `${year}-${month}`
      } else {
        const now = new Date()
        const year = now.getFullYear()
        this.value = `${year}`
      }
      this.getReportLists()
    },
    // 基础数据
    getData () {
      getCarUseData({ }).then(res => {
        this.info = res || {}
        setTimeout(() => {
          this.initType()
        }, 1000)
      })
    },
    // 全年入园车辆趋势
    initType () {
      if (!this.info.cumulativeDataList) return
      const myChart = echarts.init(document.querySelector('#echart1'))
      const names = this.info.cumulativeDataList.map(item => item.name)
      const datas = this.info.cumulativeDataList.map(item => item.total)
      const option = {
        tooltip: {
          trigger: 'item'
        },
        grid: {
          bottom: '5%',
          top: '5%'
          trigger: 'axis',
          axisPointer: {
            type: 'line'
          }
        },
        legend: {
          bottom: '0%',
          left: 'center',
          icon: 'circle'
          show: false,
          orient: 'vertical',
          left: 'left'
        },
        graphic: {
          elements: [
            {
              type: 'text',
              left: 'left',
              top: 'top',
              style: {
                text: '派车次数',
                textAlign: 'center',
                fill: '#333'
              }
            }
          ]
        },
        grid: {
          left: '0%',
          right: '5%',
          bottom: '10%',
          top: '20%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          data: names
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: true
          },
          axisLabel: {
            formatter: function (value) {
              // 四舍五入到最近的整数
              return Math.round(value)
            }
          }
        },
        series: [
          {
            type: 'pie',
            radius: ['40%', '70%'],
            label: {
              formatter: '{b} {d}%'
            },
            data: this.data1,
            itemStyle: {
            data: datas,
            name: '入园车辆',
            type: 'line',
            areaStyle: {
              normal: {
                color: function (colors) {
                  var colorList = [
                    '#fc8251',
                    '#5470c6',
                    '#91cd77'
                  ]
                  return colorList[colors.dataIndex]
                color: {
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  colorStops: [{
                    offset: 0,
                    color: '#207FF7' // 0% 处的颜色
                  }, {
                    offset: 1,
                    color: 'rgba(255,255,255,.2)' // 100% 处的颜色
                  }],
                  globalCoord: false // 缺省为 false
                }
              }
            },
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      })
    },
    getcharts2() {
      const myChart = echarts.init(document.getElementById('chart2'))
      myChart.setOption({
        tooltip: {
          trigger: 'item'
        },
        grid: {
          bottom: '5%',
          top: '5%'
        },
        xAxis: {
          max: 'dataMax'
        },
        yAxis: {
          type: 'category',
          data: this.data2[0]
        },
        series: [
          {
            realtimeSort: true,
            type: 'bar',
            data: this.data2[1],
            lineStyle: { // 线条样式
              color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [{
                  offset: 0, color: '#207FF7' // 0% 处的颜色
                }, {
                  offset: 1, color: '#207FF7' // 100% 处的颜色
                }]
              },
              width: 2 // 线条粗细
            },
            symbol: 'circle',
            symbolSize: 10,
            itemStyle: {
              normal: {
                color: '#fc8251'
              }
            }
              borderWidth: 1,
              borderColor: '#fff',
              color: '#207FF7'
            },
            smooth: false
          }
        ]
      }
      myChart.setOption(option)
      window.addEventListener('resize', function () { // 执行
        myChart.resize()
      })
      myChart.resize()
    }
  }
}
</script>
<style scoped lang="scss">
@import "@/assets/style/variables.scss";
.home {
<style lang="scss" scoped>
.main_app1 {
  width: 100%;
  .home_table {
  height: calc(100% - 44px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 15px;
  box-sizing: border-box;
  background-color: #F4F7FC;
  .main_home {
    background: #f4f7fc;
    position: relative;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    background: #ffffff;
    margin-top: 20px;
    .home_table_head {
      font-size: 16px;
      font-weight: 600;
      color: black;
    }
    .home_table_box {
    height: 120px;
    overflow: hidden;
    .home_header {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      margin-top: 15px;
      height: 80px;
      padding: 20px;
      color: #fff;
      background: linear-gradient(180deg, #076ae5 10%, rgba(32, 127, 247, 0) 100%);
    }
  }
  .home_charts {
  .main_head {
    width: 100%;
    margin-top: 20px;
    display: flex;
    align-items: center;
    flex-direction: column;
    margin-bottom: 10px;
    background-color: #ffffff;
    padding: 20px;
    box-sizing: border-box;
    .main_head_title {
      width: 100%;
      display: flex;
      align-items: center;
      margin-bottom: 20px;
      span {
        font-weight: 500;
        font-size: 18px;
        color: #222222;
        margin-right: 30px;
      }
    }
    .main_head_bottom {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .blue {
        border-left: 8px solid #12BB8B;
      }
      .red {
        border-left: 8px solid #F6CF46;
      }
      .yellow {
        border-left: 8px solid #5DC9FB;
      }
      .orange {
        border-left: 8px solid #FF9E56;
      }
      .darkBlue {
        border-left: 8px solid #6B6EFF;
      }
      .main_head_item {
        width: 19%;
        height: 112px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        border-radius: 5px;
        background-color: #F4F7FC;
        span {
          &:nth-child(1) {
            font-weight: 600;
            font-size: 30px;
            color: #222222;
          }
          &:nth-child(2) {
            font-weight: 400;
            font-size: 14px;
            color: #222222;
          }
        }
      }
    }
  }
  .main_table {
    display: flex;
    align-items: start;
    justify-content: space-between;
    margin-top: 10px;
    .main_table_list {
      background-color: #ffffff;
      padding: 20px;
      box-sizing: border-box;
      width: 100%;
      .title {
        display: flex;
        align-items: center;
        span {
          font-weight: 500;
          font-size: 18px;
          color: #222222;
        }
      }
      .list_wu {
        width: 100%;
        height: 100px;
        line-height: 100px;
        text-align: center;
        font-size: 16px;
        color: #222222;
      }
      .list_head {
        width: 100%;
        height: 50px;
        display: flex;
        align-items: center;
        background-color: #F7F7F7;
        border-left: 1px solid #DFE2E8;
        border-top: 1px solid #DFE2E8;
        margin-top: 15px;
        .list_head_item {
          flex: 1;
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 13px;
          color: #222222;
          font-weight: 500;
          border-right: 1px solid #DFE2E8;
        }
      }
      .table_box {
        width: 100%;
        border-bottom: 1px solid #DFE2E8;
        .list_content {
          width: 100%;
          height: 50px;
          display: flex;
          align-items: center;
          border-left: 1px solid #DFE2E8;
          border-top: 1px solid #DFE2E8;
          .list_head_item {
            flex: 1;
            height: 100%;
            display: flex;
            border-right: 1px solid #DFE2E8;
            align-items: center;
            justify-content: center;
            font-size: 13px;
            color: #222222;
          }
        }
      }
    }
    .main_table_list1 {
      width: 30%;
      padding: 20px;
      box-sizing: border-box;
      flex-shrink: 0;
      background-color: #ffffff;
      .title {
        font-weight: 500;
        font-size: 18px;
        color: #222222;
      }
      .list_wu {
        width: 100%;
        height: 100px;
        line-height: 100px;
        text-align: center;
        font-size: 16px;
        color: #222222;
      }
      .list_head {
        width: 100%;
        height: 50px;
        display: flex;
        align-items: center;
        background-color: #F7F7F7;
        border-left: 1px solid #DFE2E8;
        border-top: 1px solid #DFE2E8;
        margin-top: 15px;
        .list_head_item {
          flex: 1.8;
          height: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 13px;
          color: #222222;
          font-weight: 500;
          border-right: 1px solid #DFE2E8;
          &:last-child {
            flex: 1;
          }
        }
      }
      .table_box {
        width: 100%;
        border-bottom: 1px solid #DFE2E8;
        .list_content {
          width: 100%;
          height: 50px;
          display: flex;
          align-items: center;
          border-left: 1px solid #DFE2E8;
          border-top: 1px solid #DFE2E8;
          .list_head_item {
            flex: 1.8;
            height: 100%;
            display: flex;
            align-items: center;
            border-right: 1px solid #DFE2E8;
            justify-content: center;
            text-align: center;
            font-size: 13px;
            color: #222222;
            &:last-child {
              flex: 1;
            }
          }
        }
      }
    }
  }
  .main_content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .home_charts_item {
      padding: 20px;
      box-sizing: border-box;
    height: 350px;
    .title {
      font-weight: 500;
      font-size: 18px;
      color: #222222;
    }
    .type_wrap {
      flex: 1;
      display: flex;
      flex-direction: column;
      margin-right: 20px;
      background: #ffffff;
      .home_charts_item_label {
        font-size: 16px;
        font-weight: 600;
        color: black;
      }
      .home_charts_item_charts {
        width: 100%;
        height: 300px;
      }
      &:last-child {
        margin: 0 !important;
      }
    }
  }
  .home_total {
    width: 100%;
    background: #ffffff;
    margin-top: 20px;
    .home_total_head {
      width: 100%;
      font-size: 16px;
      font-weight: 600;
      color: black;
      padding: 10px 20px;
      box-sizing: border-box;
      border-bottom: 1px solid #ececec;
    }
    .home_total_list {
      width: 100%;
      height: 100%;
      background-color: #ffffff;
      padding: 20px;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      .a {
        border-left: 5px solid rgba(129, 211, 248, 1) !important;
      /*border-right: 12px solid #f7f7f7;*/
      #echart1 {
        width: 100%;
        height: 100%;
        margin-top: 18px;
      }
      .b {
        border-left: 5px solid rgba(236, 128, 141, 1) !important;
      }
      .c {
        border-left: 5px solid rgba(250, 205, 145, 1) !important;
      }
      .d {
        border-left: 5px solid rgba(245, 154, 35, 1) !important;
      }
      .e {
        border-left: 5px solid rgba(128, 128, 255, 1) !important;
      }
      .f {
        border-left: 5px solid rgba(202, 249, 130, 1) !important;
      }
      .g {
        border-left: 5px solid rgba(194, 128, 255, 1) !important;
      }
      .home_total_list_item {
        flex: 1;
        display: flex;
        align-items: center;
        flex-direction: column;
        justify-content: center;
        height: 80px;
        border-radius: 5px;
        border: 1px solid #ececec;
        margin-right: 15px;
        &:last-child {
          margin: 0 !important;
        }
        span {
          &:first-child {
            font-weight: 500;
            font-size: 24px;
            color: black;
          }
          &:last-child {
            font-weight: 400;
            font-size: 14px;
            color: #666666;
            margin-top: 2px;
          }
        }
    }
    .dept_wrap {
      width: 420px;
      flex-shrink: 0;
      height: 100%;
      background-color: #ffffff;
      padding: 20px;
      box-sizing: border-box;
      margin-left: 10px;
      #echart_2 {
        width: 100%;
        height: 100%;
      }
    }
  }