rk
2026-04-15 c313a253b1fcdc75b6be5db575fc2b29fb407021
admin/src/views/business/driverList.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,155 @@
<template>
  <TableLayout :permissions="['business:driverInfo:query']">
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="司机信息" prop="keyword">
        <el-input v-model="searchForm.keyword" clearable placeholder="请输入司机姓名/手机号" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="车牌号" prop="carNo">
        <el-input v-model="searchForm.carNo" clearable placeholder="请输入车牌号" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="searchForm.status" clearable placeholder="请选择状态" @change="search">
          <el-option label="禁用" :value="1"></el-option>
          <el-option label="启用" :value="0"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="性别" prop="sex">
        <el-select v-model="searchForm.sex" clearable placeholder="请选择性别" @change="search">
          <el-option label="男" :value="1"></el-option>
          <el-option label="女" :value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="创建时间" prop="createTime">
        <el-date-picker type="daterange" v-model="searchForm.createTime" clearable value-format="yyyy-MM-dd"
                        range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="handleDateChange" />
      </el-form-item>
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
        <el-button :loading="isWorking.export" @click="exportExcel">导出</el-button>
      </section>
    </el-form>
    <template v-slot:table-wrap>
      <el-table
        :height="tableHeightNew"
        v-loading="isWorking.search"
        :data="tableData.list"
        stripe
      >
        <el-table-column prop="name" label="司机姓名" min-width="100px"></el-table-column>
        <el-table-column label="性别" min-width="60px">
          <template slot-scope="{row}">{{ row.gender === 1 ? '男' : row.gender === 2 ? '女' : '-' }}</template>
        </el-table-column>
        <el-table-column prop="telephone" label="注册手机号" min-width="120px"></el-table-column>
        <el-table-column prop="idcard" label="身份证号" min-width="160px"></el-table-column>
        <el-table-column label="账户余额" min-width="100px">
          <template slot-scope="{row}">Â¥{{ (row.memberAmount / 100).toFixed(2) }}</template>
        </el-table-column>
        <el-table-column prop="carCode" label="车牌号" min-width="100px"></el-table-column>
        <el-table-column prop="createTime" label="创建时间" min-width="160px"></el-table-column>
        <el-table-column label="状态" min-width="80px">
          <template slot-scope="{row}">
            <el-switch
              @change="handleStatusChange($event, row)"
              v-model="row.status"
              active-color="#13ce66"
              inactive-color="#ff4949"
              :active-value="0"
              :inactive-value="1"
            ></el-switch>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="100" fixed="right">
          <template slot-scope="{row}">
            <el-button type="text" @click="handleDetail(row)">详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        :pagination="tableData.pagination"
      ></pagination>
    </template>
    <OperaDriverDetail ref="operaDriverDetail" />
  </TableLayout>
</template>
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaDriverDetail from '@/components/business/OperaDriverDetail'
import { updateStatus, exportExcel } from '@/api/business/driver'
export default {
  name: 'DriverList',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaDriverDetail },
  data () {
    return {
      searchForm: {
        keyword: '',
        carNo: '',
        status: '',
        sex: '',
        createTime: '',
        startTime: '',
        endTime: '',
        auditStatus: 1
      }
    }
  },
  created () {
    this.config({
      api: '/business/driver',
      'field.id': 'id'
    })
    this.search()
  },
  methods: {
    handleDateChange (val) {
      this.searchForm.startTime = val ? val[0] : ''
      this.searchForm.endTime = val ? val[1] : ''
      this.search()
    },
    reset () {
      this.searchForm = {
        keyword: '',
        carNo: '',
        status: '',
        sex: '',
        createTime: '',
        startTime: '',
        endTime: ''
      }
      this.search()
    },
    handleDetail (row) {
      this.$refs.operaDriverDetail.open('司机详情', row)
    },
    handleStatusChange (val, row) {
      updateStatus({ id: row.id, status: val }).then(res => {
        this.$tip.apiSuccess(res || '修改成功')
      }).catch(e => {
        row.status = val === 1 ? 0 : 1
        this.$tip.apiFailed(e)
      })
    },
    handleExport () {
      this.isWorking.export = true
      exportExcel(this.getTableParams())
        .then(res => {
          this.download(res)
          this.$tip.apiSuccess('导出成功')
        })
        .catch(e => {
          this.$tip.apiFailed(e)
        })
        .finally(() => {
          this.isWorking.export = false
        })
    }
  }
}
</script>