monitor.vue 5.54 KB
<template>
  <Card>
    <div class="search">
      <el-form
        class="count-form"
        ref="ruleForm"
        size="mini"
        inline
        :model="ruleForm"
      >
        <el-form-item label="营销员姓名" prop="username">
          <el-input
            v-model.trim="ruleForm.username"
            placeholder="请输入营销员姓名"
            :maxlength="inputMaxLength"
          >
            <i slot="prefix" class="el-icon-search"></i
          ></el-input>
        </el-form-item>
        <el-form-item label="营销员工号" prop="userId">
          <el-input
            v-model.trim="ruleForm.userId"
            placeholder="请输入营销员工号"
            :maxlength="inputMaxLength"
          >
            <i slot="prefix" class="el-icon-search"></i
          ></el-input>
        </el-form-item>
        <el-form-item label="展业开始时间" prop="times">
          <el-date-picker
            v-model="ruleForm.times"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          ></el-date-picker>
        </el-form-item>
      </el-form>
    </div>
    <div class="flex-end mb10">
      <el-button type="primary" size="mini" @click="submit">查询</el-button>
      <el-button size="mini" @click="onReset">重置</el-button>
    </div>
    <el-table
      class="mb10"
      :data="tableData"
      border
      style="width: 100%"
      v-loading="loading"
    >
      <el-table-column
        type="index"
        align="center"
        label="序号"
        fixed
        :index="pagination && (pagination.page - 1) * pagination.size + 1"
        width="50"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="recordId"
        label="recordId"
        width="80"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="custName"
        label="客户姓名"
        width="160"
      >
      </el-table-column>
      <el-table-column
        align="center"
        prop="custTel"
        label="客户手机号"
        width="160"
      >
      </el-table-column>
      <el-table-column align="center" prop="userName" label="营销员姓名">
      </el-table-column>
      <el-table-column align="center" prop="userId" label="营销员工号">
      </el-table-column>
      <el-table-column align="center" label="展业时长" width="80">
        <template v-slot="scope">
          {{ parseTimeSecond(scope.row.communicationTime * 1000 - 0) }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="展业开始时间">
        <template v-slot="scope">
          {{ parseTime(scope.row.startTime) }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" fixed="right">
        <template v-slot="scope">
          <div>
            <el-button type="text" size="small" @click="handleDetail(scope.row)"
              >查看</el-button
            >
          </div>
        </template>
      </el-table-column>
    </el-table>
    <FooterPaginationfrom :pagination="pagination"></FooterPaginationfrom>
  </Card>
</template>

<script>
import FooterPaginationfrom from './components/FooterPagination'
import { parseTime, parseTimeSecond } from '@/utils/util'
import { getResourceMonitorList } from '@/api/monitor'
import { inputMaxLength } from '@/utils/mappingData'

export default {
  components: {
    FooterPaginationfrom
  },
  data() {
    return {
      inputMaxLength,
      parseTime,
      parseTimeSecond,
      ruleForm: {
        username: '',
        userId: '',
        times: ['', '']
      },
      tableData: [],
      pagination: { size: 10, total: 0, page: 1 },
      loading: false
    }
  },
  watch: {
    'pagination.size'() {
      this.handleGetResourceMonitorList()
    },
    'pagination.page'() {
      this.handleGetResourceMonitorList()
    }
  },
  mounted() {
    this.handleGetResourceMonitorList()
  },
  methods: {
    async handleGetResourceMonitorList() {
      try {
        this.loading = true
        const {
          result: { list, total }
        } = await getResourceMonitorList({
          username: this.ruleForm.username,
          userId: this.ruleForm.userId,
          startTime: this.ruleForm.times ? this.ruleForm.times[0] : '',
          endTime: this.ruleForm.times ? this.ruleForm.times[1] : '',
          pageNo: this.pagination.page,
          row: this.pagination.size
        })
        this.tableData = list
        this.pagination.total = total
      } catch (error) {
        console.log(error)
      } finally {
        this.loading = false
      }
    },
    submit() {
      if (this.pagination.page === 1) {
        this.handleGetResourceMonitorList()
      } else {
        this.pagination.page = 1
      }
    },
    onReset() {
      this.ruleForm = {
        username: '',
        userId: '',
        times: ['', '']
      }
      this.submit()
    },
    handleDetail(row) {
      this.$router.push({
        path: 'monitor-details',
        query: { ...row }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.search {
  .count-form {
    margin-top: 20px;
    margin-left: 20px;
  }
}
.status {
  display: flex;
  justify-content: center;
  align-items: center;
  .dot {
    margin-right: 6px;
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #34c780;
  }
  .yellow {
    background-color: #ffaa00;
  }
}
.flex-end {
  display: flex;
  justify-content: flex-end;
}
</style>