liukangdong
2024-05-10 c58ada7f49aac20b06ea2ebda2cb5c006decf122
admin/src/views/meeting/userStatistics.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,245 @@
<template>
  <TableLayout :permissions="['business:rooms:query']">
    <!-- æœç´¢è¡¨å• -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="人员" prop="userId">
        <el-select
          v-model="searchForm.userId"
          clearable
          filterable
          placeholder="选择人员"
        >
          <el-option
            v-for="item in sysList"
            :key="item.id"
            :value="item.id"
            :label="item.department?`${item.department.name}-${item.realname}`:item.realname"
            ></el-option>
            <!-- :label="item.name" -->
        </el-select>
      </el-form-item>
      <el-form-item label="年份" prop="yearNum">
        <el-select
          v-model="searchForm.yearNum"
          clearable
          placeholder="选择年份"
        >
          <el-option
            v-for="item in years"
            :key="item"
            :value="item"
            :label="`${item}å¹´`"
          ></el-option>
        </el-select>
      </el-form-item>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- è¡¨æ ¼å’Œåˆ†é¡µ -->
    <template v-slot:table-wrap>
      <!-- v-permissions="['business:rooms:create', 'business:rooms:delete']" -->
      <ul class="toolbar" >
        <!-- v-permissions="['business:rooms:exportExcel']" -->
        <li><el-button :loading="isWorking.export" @click="exportExcel">导出</el-button></li>
      </ul>
      <el-table
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
        border
        @selection-change="handleSelectionChange"
      >
        <!-- <el-table-column prop="roomName" label="会议室" align="center" min-width="100px"></el-table-column> -->
        <el-table-column prop="realname" label="姓名" align="center" min-width="100px"></el-table-column>
        <el-table-column prop="januaryCount" label="一月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.januaryCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="二月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.februaryCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="三月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.marchCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="四月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.aprilCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="五月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.mayCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="六月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.juneCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="七月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.julyCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="八月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.augustCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="九月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.septemberCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="十月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.octoberCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="十一月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.novemberCount}H` }}
          </template>
        </el-table-column>
        <el-table-column prop="januaryCount" label="十二月" align="center" min-width="120px">
          <template slot-scope="{row}">
            {{ `${row.decemberCount}H` }}
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      ></pagination>
    </template>
  </TableLayout>
</template>
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import { getUserStatistics, exportUserStatistics } from '@/api/meeting/bookings'
import { fetchList as userList } from '@/api/system/user'
export default {
  name: 'Rooms',
  extends: BaseTable,
  components: { TableLayout, Pagination },
  data () {
    return {
      years: [
        '2021', '2022', '2023'
      ],
      sysList: [],
      // æœç´¢
      searchForm: {
        yearNum: '',
        userId: ''
      }
    }
  },
  created () {
    this.config({
      module: '会议室信息表',
      api: '/meeting/rooms',
      'field.id': 'id',
      'field.main': 'id'
    })
    let tempYear = new Date().getFullYear()
    this.searchForm.yearNum = tempYear
    this.years = [tempYear-2, tempYear-1, tempYear]
    // findList({})
    //   .then(res => {
    //     this.rooms = res
    //   })
    userList({
      page: 1,
      capacity: 9999,
      model: { realname: this.filterText },
    })
      .then(res => {
        console.log('userList', res);
        this.sysList = res.records
      })
    this.search()
  },
  methods: {
    // å¯¼å‡ºExcel
    exportExcel () {
      this.__checkApi()
      this.$dialog.exportConfirm('确认导出吗?')
        .then(() => {
          this.isWorking.export = true
          exportUserStatistics({
            page: this.tableData.pagination.pageIndex,
            capacity: 1000000,
            model: this.searchForm,
            sorts: this.tableData.sorts
          })
            .then(response => {
              this.download(response)
            })
            .catch(e => {
              this.$tip.apiFailed(e)
            })
            .finally(() => {
              this.isWorking.export = false
            })
        })
        .catch(() => {})
    },
    handlePageChange (pageIndex) {
      this.__checkApi()
      this.tableData.pagination.pageIndex = pageIndex || this.tableData.pagination.pageIndex
      this.isWorking.search = true
      getUserStatistics({
        page: this.tableData.pagination.pageIndex,
        capacity: this.tableData.pagination.pageSize,
        model: this.searchForm,
        sorts: this.tableData.sorts
      })
        .then(data => {
          this.tableData.list = data.records
          this.tableData.pagination.total = data.total
        })
        .catch(e => {
          this.$tip.apiFailed(e)
        })
        .finally(() => {
          this.isWorking.search = false
        })
    },
    // selectMemberAction() {
    //   console.log('21212');
    //   this.$refs.selectMember.open('选择管理员')
    // },
    changeStatus(item) {
      updateById({
        id: item.id,
        status: item.status
      }).then(res => {
        this.search()
      })
    }
  },
}
</script>
<style scoped>
::v-deep .el-input.is-disabled .el-input__inner {
  background-color: #fff !important;
  cursor: pointer;
}
</style>