|
|
@@ -1,108 +1,128 @@
|
|
|
<template>
|
|
|
- <div class="container">
|
|
|
- <div class="content">
|
|
|
- <el-form ref="form" :model="form" class="form">
|
|
|
- <el-row :gutter="12">
|
|
|
- <el-col :span="8">
|
|
|
+ <div class="app-container">
|
|
|
+ <div class="filter-container">
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ :model="form">
|
|
|
+ <div class="filter-view">
|
|
|
+ <el-form-item
|
|
|
+ label=""
|
|
|
+ class="flex-item flex1"
|
|
|
+ style="min-width: 200px; max-width: 400px;">
|
|
|
<el-input
|
|
|
v-model="form.criteria"
|
|
|
placeholder="Search by Email, Phone or Fleet Company Name"
|
|
|
- clearable
|
|
|
- ></el-input>
|
|
|
- </el-col>
|
|
|
- <el-col :span="3">
|
|
|
- <el-button
|
|
|
- @click="onClickSearch"
|
|
|
- icon="el-icon-search"
|
|
|
- type="primary"
|
|
|
- >
|
|
|
- Search
|
|
|
- </el-button>
|
|
|
- </el-col>
|
|
|
- <el-col :offset="10" :span="3" >
|
|
|
+ clearable/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-button
|
|
|
+ @click="onClickSearch"
|
|
|
+ icon="el-icon-search"
|
|
|
+ type="primary">
|
|
|
+ Search
|
|
|
+ </el-button>
|
|
|
+ <div class="flex1"></div>
|
|
|
+ <my-upload
|
|
|
+ accept=".xls,.xlsx,.csv"
|
|
|
+ :limit="1"
|
|
|
+ :is-blob="true"
|
|
|
+ :action="action"
|
|
|
+ :headers="headers"
|
|
|
+ :file-list="fileList"
|
|
|
+ :show-file-list="false"
|
|
|
+ :before-upload="onImportStart"
|
|
|
+ :on-success="onImportExcel"
|
|
|
+ :on-error="onImportExcelErr">
|
|
|
<el-button
|
|
|
- icon="el-icon-plus"
|
|
|
+ icon="el-icon-upload2"
|
|
|
type="primary"
|
|
|
- @click="onClickAdd"
|
|
|
- >
|
|
|
- Add PH Driver
|
|
|
+ :loading="loading.upload">
|
|
|
+ Import Excel
|
|
|
</el-button>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
+ </my-upload>
|
|
|
+ <el-button
|
|
|
+ icon="el-icon-download"
|
|
|
+ type="primary"
|
|
|
+ :loading="loading.download"
|
|
|
+ @click="onDownloadTmp">
|
|
|
+ Download Template
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ icon="el-icon-plus"
|
|
|
+ type="primary"
|
|
|
+ @click="onClickAdd">
|
|
|
+ Add PH Driver
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
</el-form>
|
|
|
- <el-table :data="table.list">
|
|
|
- <el-table-column
|
|
|
- align="center"
|
|
|
- label="User ID"
|
|
|
- prop="userPk"
|
|
|
- width="100"
|
|
|
- >
|
|
|
- <template
|
|
|
- v-slot="{ row }"
|
|
|
- >
|
|
|
- <router-link
|
|
|
- class="table-link"
|
|
|
- :to="{
|
|
|
- name: 'DriverDetail',
|
|
|
- query: {
|
|
|
- id: row.userPk,
|
|
|
- dispatch: true,
|
|
|
- },
|
|
|
- }"
|
|
|
- >
|
|
|
- {{ row.userPk }}
|
|
|
- </router-link>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column
|
|
|
- width="200"
|
|
|
- align="center"
|
|
|
- label="Name"
|
|
|
- prop="nickName"
|
|
|
- ></el-table-column>
|
|
|
- <el-table-column
|
|
|
- align="center"
|
|
|
- label="Email"
|
|
|
- prop="email"
|
|
|
- ></el-table-column>
|
|
|
- <el-table-column
|
|
|
- width="150"
|
|
|
- align="center"
|
|
|
- label="Phone"
|
|
|
- prop="phone"
|
|
|
- ></el-table-column>
|
|
|
- <el-table-column
|
|
|
- align="center"
|
|
|
- label="Fleet Company"
|
|
|
- prop="fleetCompanyName"
|
|
|
- ></el-table-column>
|
|
|
- <el-table-column
|
|
|
- align="center"
|
|
|
- label="Status"
|
|
|
- prop="driverStatus"
|
|
|
- width="150"
|
|
|
- ></el-table-column>
|
|
|
- <el-table-column
|
|
|
- align="center"
|
|
|
- label="Action"
|
|
|
- width="210"
|
|
|
- >
|
|
|
- <template slot-scope="{ row }">
|
|
|
- <TableAction
|
|
|
- :showEdit="isDriverOperation(row)"
|
|
|
- @edit="onClickEditButton(row)"
|
|
|
- @delete="onClickDeleteButton(row)"/>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- <div class="right">
|
|
|
- <pagination
|
|
|
- v-show="table.total > 0"
|
|
|
- :total="table.total"
|
|
|
- :page.sync="table.pageNo"
|
|
|
- :limit.sync="table.pageSize"
|
|
|
- @pagination="handlePageChange" />
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
+ <el-table :data="table.list" v-loading="loading.table">
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="User ID"
|
|
|
+ prop="userPk"
|
|
|
+ width="100">
|
|
|
+ <template slot-scope="{row}" >
|
|
|
+ <router-link
|
|
|
+ class="table-link"
|
|
|
+ :to="{
|
|
|
+ name: 'DriverDetail',
|
|
|
+ query: {
|
|
|
+ id: row.userPk,
|
|
|
+ dispatch: true,
|
|
|
+ },
|
|
|
+ }">
|
|
|
+ {{ row.userPk }}
|
|
|
+ </router-link>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ width="200"
|
|
|
+ align="center"
|
|
|
+ label="Name"
|
|
|
+ prop="nickName"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="Email"
|
|
|
+ prop="email"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ width="150"
|
|
|
+ align="center"
|
|
|
+ label="Phone"
|
|
|
+ prop="phone"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="Fleet Company"
|
|
|
+ prop="fleetCompanyName"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="Status"
|
|
|
+ prop="driverStatus"
|
|
|
+ width="150"
|
|
|
+ ></el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ align="center"
|
|
|
+ label="Action"
|
|
|
+ width="210"
|
|
|
+ >
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <TableAction
|
|
|
+ :showEdit="isDriverOperation(row)"
|
|
|
+ @edit="onClickEditButton(row)"
|
|
|
+ @delete="onClickDeleteButton(row)"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <div class="right">
|
|
|
+ <pagination
|
|
|
+ v-show="table.total > 0"
|
|
|
+ :total="table.total"
|
|
|
+ :page.sync="table.pageNo"
|
|
|
+ :limit.sync="table.pageSize"
|
|
|
+ @pagination="handlePageChange" />
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -110,11 +130,13 @@
|
|
|
<script>
|
|
|
import Pagination from '@/components/Pagination'
|
|
|
import TableAction from '@/components/TableAction'
|
|
|
-import { deleteDriver, fetchDriverPages } from '@/http/api/driver'
|
|
|
-
|
|
|
+import api from '@/http/api/driver'
|
|
|
+import { baseURL } from '@/http/http'
|
|
|
+import { getToken } from '@/utils/auth'
|
|
|
+import MyUpload from '@/components/MyUpload'
|
|
|
export default {
|
|
|
name: "FleetCompanyList",
|
|
|
- components: { Pagination, TableAction },
|
|
|
+ components: { Pagination, TableAction,MyUpload },
|
|
|
data() {
|
|
|
return {
|
|
|
form: {
|
|
|
@@ -126,6 +148,22 @@ export default {
|
|
|
pageNo: 1,
|
|
|
pageSize: 10,
|
|
|
},
|
|
|
+ loading: {
|
|
|
+ table: false,
|
|
|
+ upload: false,
|
|
|
+ download: false
|
|
|
+ },
|
|
|
+ fileList: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ action() {
|
|
|
+ return baseURL + process.env.VUE_APP_API_PREFIX + '/driver/batch/create'
|
|
|
+ },
|
|
|
+ headers() {
|
|
|
+ return {
|
|
|
+ accessToken: getToken()
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -140,13 +178,65 @@ export default {
|
|
|
criteria: this.form.criteria,
|
|
|
},
|
|
|
}
|
|
|
- const { success, data, total } = await fetchDriverPages(params)
|
|
|
+ const { success, data, total } = await api.fetchDriverPages(params)
|
|
|
if (success) {
|
|
|
this.table.list = data
|
|
|
this.table.total = total
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+ onImportStart() {
|
|
|
+ this.loading.upload = true;
|
|
|
+ },
|
|
|
+ onImportExcel(res, file, fileList) {
|
|
|
+ fileList = [];
|
|
|
+ this.fileList = [];
|
|
|
+ if (res.success == undefined) {
|
|
|
+ this.downloadExcel(res, "batch_create_result.xls");
|
|
|
+ this.loading.upload = false;
|
|
|
+ } else {
|
|
|
+ this.onImportExcelErr(res.msg, file, fileList);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onImportExcelErr(err, file, fileList) {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ })
|
|
|
+ this.loading.upload = false;
|
|
|
+ },
|
|
|
+ onDownloadTmp() {
|
|
|
+ this.loading.download = true;
|
|
|
+ api.downloadTemplate().then(res => {
|
|
|
+ this.downloadExcel(res, "driver-template.xlsx")
|
|
|
+ }).catch(err => {
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: err
|
|
|
+ })
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading.download = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ downloadExcel(res, fileName) {
|
|
|
+ const blob = new Blob([res], {
|
|
|
+ type: 'application/vnd.ms-excel;charset=utf-8'
|
|
|
+ })
|
|
|
+ // let href = window.URL.createObjectURL(blob)
|
|
|
+ if ('download' in document.createElement('a')) {
|
|
|
+ // 非IE下载
|
|
|
+ const elink = document.createElement('a')
|
|
|
+ elink.download = fileName
|
|
|
+ elink.style.display = 'none'
|
|
|
+ elink.href = URL.createObjectURL(blob)
|
|
|
+ document.body.appendChild(elink)
|
|
|
+ elink.click()
|
|
|
+ URL.revokeObjectURL(elink.href) // 释放URL 对象
|
|
|
+ document.body.removeChild(elink)
|
|
|
+ } else {
|
|
|
+ // IE10+下载
|
|
|
+ navigator.msSaveBlob(blob, fileName)
|
|
|
+ }
|
|
|
+ },
|
|
|
onClickSearch() {
|
|
|
this.table.pageNo = 1
|
|
|
this.getDriverPages()
|
|
|
@@ -165,7 +255,7 @@ export default {
|
|
|
},
|
|
|
async deleteUser(driver) {
|
|
|
try {
|
|
|
- const { success, msg } = await deleteDriver({
|
|
|
+ const { success, msg } = await api.deleteDriver({
|
|
|
userPk: driver.userPk
|
|
|
})
|
|
|
if (success) {
|
|
|
@@ -194,44 +284,5 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-@import '../../styles/variables.scss';
|
|
|
- .container {
|
|
|
- width: 100%;
|
|
|
- padding: 20px 50px;
|
|
|
- background-color: #F0F5FC;
|
|
|
- .content {
|
|
|
- padding: 45px 45px;
|
|
|
- border-radius: 6px;
|
|
|
- min-height: calc(#{$mainAppMinHeight} - (2 * 20px));
|
|
|
- background-color: white;
|
|
|
- .form {
|
|
|
- margin-bottom: 30px;
|
|
|
- }
|
|
|
- .table-link {
|
|
|
- color: #333;
|
|
|
- display: inline-block;
|
|
|
- cursor: pointer;
|
|
|
- white-space: nowrap;
|
|
|
- text-decoration: underline;
|
|
|
- }
|
|
|
- .table-link:hover {
|
|
|
- color: #1290BF;
|
|
|
- text-decoration: none;
|
|
|
- }
|
|
|
- .action {
|
|
|
- .editButton {
|
|
|
- color: #3179E4;
|
|
|
- }
|
|
|
- .deleteButton {
|
|
|
- color: #ED3F3F;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- .el-button {
|
|
|
- width: 100%;
|
|
|
- }
|
|
|
- .el-input {
|
|
|
- width: 100%;
|
|
|
- }
|
|
|
+
|
|
|
</style>
|