| | |
| | | <el-button v-has-permission="['user:export']" class="filter-item" type="success" @click.native="exportExcel"> |
| | | {{ $t('table.export') }} |
| | | </el-button> |
| | | |
| | | <el-button class="filter-item" icon="el-icon-download" type="primary" plain @click="templateDownload"> |
| | | {{ $t('table.templateDownload') }} |
| | | </el-button> |
| | | <el-upload |
| | | class="upload" |
| | | :action="uploadAction" |
| | | :headers="headers" |
| | | list-type="picture" |
| | | :show-file-list="false" |
| | | :before-upload="beforeUpload" |
| | | :on-success="uploadSuccess" |
| | | :on-error="uploadError" |
| | | :on-progress="uploadProgress" |
| | | > |
| | | <el-button v-has-permission="['user:import']" class="filter-item" icon="el-icon-upload2" type="success" plain> |
| | | {{ $t('table.import') }} |
| | | </el-button> |
| | | </el-upload> |
| | | <!-- <el-dropdown v-has-any-permission="['user:add','user:delete','user:reset','user:export']" trigger="click" class="filter-item"> |
| | | <el-button> |
| | | {{ $t('table.more') }}<i class="el-icon-arrow-down el-icon--right" /> |
| | |
| | | import Pagination from '@/components/Pagination' |
| | | import UserEdit from './Edit' |
| | | import UserView from './View' |
| | | |
| | | import { getFileType } from '@/utils' |
| | | import { getToken } from '@/utils/auth' |
| | | import NProgress from 'nprogress' |
| | | export default { |
| | | name: 'UserManage', |
| | | components: { Pagination, UserEdit, UserView }, |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | uploadAction: `${process.env.VUE_APP_BASE_API}system/user/import`, |
| | | headers: { |
| | | Authorization: `bearer ${getToken()}` |
| | | }, |
| | | dialog: { |
| | | isVisible: false, |
| | | title: '' |
| | |
| | | this.fetch() |
| | | }, |
| | | methods: { |
| | | templateDownload() { |
| | | this.$download('system/user/template', {}, 'excel_import_user.xlsx') |
| | | }, |
| | | beforeUpload(file) { |
| | | const type = getFileType(file.name) |
| | | if (type !== 'xlsx') { |
| | | this.$message({ |
| | | message: this.$t('tips.onlySupportXlsx'), |
| | | type: 'error' |
| | | }) |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }, |
| | | uploadError() { |
| | | this.$message({ |
| | | message: this.$t('tips.uploadFailed'), |
| | | type: 'error' |
| | | }) |
| | | NProgress.done() |
| | | }, |
| | | uploadSuccess(response) { |
| | | const data = response.data |
| | | this.data = data.data |
| | | this.error = data.error |
| | | this.time = data.time |
| | | NProgress.done() |
| | | this.fetch() |
| | | this.dialogVisible = true |
| | | }, |
| | | uploadProgress() { |
| | | NProgress.start() |
| | | }, |
| | | transSex(sex) { |
| | | switch (sex) { |
| | | case '0': |