|
@@ -1,8 +1,8 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div>
|
|
<div>
|
|
|
<div class="filters-container">
|
|
<div class="filters-container">
|
|
|
- <el-input placeholder="用户名" size="small" v-model="filter1" clearable class="filter-item"></el-input>
|
|
|
|
|
- <el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
|
|
|
|
|
|
|
+ <!-- <el-input placeholder="用户名" size="small" v-model="filter1" clearable class="filter-item"></el-input> -->
|
|
|
|
|
+ <!-- <el-select placeholder="性别" size="small" v-model="filter2" clearable class="filter-item">
|
|
|
<el-option
|
|
<el-option
|
|
|
label="女"
|
|
label="女"
|
|
|
value="item1">
|
|
value="item1">
|
|
@@ -11,15 +11,15 @@
|
|
|
label="男"
|
|
label="男"
|
|
|
value="item2">
|
|
value="item2">
|
|
|
</el-option>
|
|
</el-option>
|
|
|
- </el-select>
|
|
|
|
|
- <el-button @click="getData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
|
|
|
|
|
- </el-button>
|
|
|
|
|
- <el-button @click="$router.push('/user')" type="primary" size="small" icon="el-icon-edit"
|
|
|
|
|
- class="filter-item">添加
|
|
|
|
|
|
|
+ </el-select> -->
|
|
|
|
|
+ <!-- <el-button @click="getData" type="primary" size="small" icon="el-icon-search" class="filter-item">搜索
|
|
|
|
|
+ </el-button> -->
|
|
|
|
|
+ <el-button @click="$router.push('/user')" type="primary" size="small" icon="el-icon-edit" class="filter-item">添加
|
|
|
</el-button>
|
|
</el-button>
|
|
|
<el-dropdown trigger="click" size="medium" class="table-column-filter">
|
|
<el-dropdown trigger="click" size="medium" class="table-column-filter">
|
|
|
<span>
|
|
<span>
|
|
|
- 筛选数据<i class="el-icon-arrow-down el-icon--right"></i>
|
|
|
|
|
|
|
+ 筛选数据
|
|
|
|
|
+ <i class="el-icon-arrow-down el-icon--right"></i>
|
|
|
</span>
|
|
</span>
|
|
|
<el-dropdown-menu slot="dropdown" class="table-column-filter-wrapper">
|
|
<el-dropdown-menu slot="dropdown" class="table-column-filter-wrapper">
|
|
|
<el-checkbox v-for="item in tableColumns" :key="item.value" v-model="item.show">{{item.label}}
|
|
<el-checkbox v-for="item in tableColumns" :key="item.value" v-model="item.show">{{item.label}}
|
|
@@ -27,185 +27,160 @@
|
|
|
</el-dropdown-menu>
|
|
</el-dropdown-menu>
|
|
|
</el-dropdown>
|
|
</el-dropdown>
|
|
|
</div>
|
|
</div>
|
|
|
- <el-table
|
|
|
|
|
- :data="tableData"
|
|
|
|
|
- :height="tableHeight"
|
|
|
|
|
- row-key="id"
|
|
|
|
|
- ref="table">
|
|
|
|
|
- <el-table-column
|
|
|
|
|
- v-if="multipleMode"
|
|
|
|
|
- align="center"
|
|
|
|
|
- type="selection"
|
|
|
|
|
- width="50">
|
|
|
|
|
|
|
+ <el-table :data="tableData" :height="tableHeight" row-key="id" ref="table">
|
|
|
|
|
+ <el-table-column v-if="multipleMode" align="center" type="selection" width="50">
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
|
|
- type="index"
|
|
|
|
|
- min-width="50"
|
|
|
|
|
- align="center">
|
|
|
|
|
|
|
+ <el-table-column type="index" min-width="50" align="center">
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
|
|
- v-if="isColumnShow('username')"
|
|
|
|
|
- prop="username"
|
|
|
|
|
- label="用户名"
|
|
|
|
|
- min-width="300">
|
|
|
|
|
|
|
+ <el-table-column v-if="isColumnShow('username')" prop="username" label="用户名" min-width="300">
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
|
|
- v-if="isColumnShow('nickname')"
|
|
|
|
|
- prop="nickname"
|
|
|
|
|
- label="昵称"
|
|
|
|
|
- min-width="300">
|
|
|
|
|
|
|
+ <el-table-column v-if="isColumnShow('nickname')" prop="nickname" label="昵称" min-width="300">
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
|
|
- v-if="isColumnShow('icon')"
|
|
|
|
|
- label="头像"
|
|
|
|
|
- min-width="300">
|
|
|
|
|
|
|
+ <el-table-column v-if="isColumnShow('icon')" label="头像" min-width="300">
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
- <img :src="scope.row.icon"
|
|
|
|
|
- style="width: 32px;height: 32px;border-radius: 50%;vertical-align: middle;"/>
|
|
|
|
|
|
|
+ <img :src="scope.row.icon" style="width: 32px;height: 32px;border-radius: 50%;vertical-align: middle;" />
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
|
|
- v-if="isColumnShow('sex')"
|
|
|
|
|
- prop="sex"
|
|
|
|
|
- label="性别"
|
|
|
|
|
- min-width="300">
|
|
|
|
|
- </el-table-column>
|
|
|
|
|
- <el-table-column
|
|
|
|
|
- v-if="isColumnShow('openId')"
|
|
|
|
|
- prop="openId"
|
|
|
|
|
- label="openId"
|
|
|
|
|
- min-width="300">
|
|
|
|
|
|
|
+ <el-table-column v-if="isColumnShow('sex')" prop="sex" label="性别" min-width="300">
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column
|
|
|
|
|
- label="操作"
|
|
|
|
|
- align="center"
|
|
|
|
|
- fixed="right">
|
|
|
|
|
|
|
+ <!-- <el-table-column v-if="isColumnShow('openId')" prop="openId" label="openId" min-width="300">
|
|
|
|
|
+ </el-table-column> -->
|
|
|
|
|
+ <el-table-column label="操作" align="center" fixed="right" width="200">
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
<el-button @click="editRow(scope.row)" type="primary" size="mini" plain>编辑</el-button>
|
|
<el-button @click="editRow(scope.row)" type="primary" size="mini" plain>编辑</el-button>
|
|
|
|
|
+ <el-button @click="initPassword(scope.row)" type="primary" size="mini" plain>密码初始化</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
|
<div class="pagination-wrapper">
|
|
<div class="pagination-wrapper">
|
|
|
- <div class="multiple-mode-wrapper">
|
|
|
|
|
|
|
+ <!-- <div class="multiple-mode-wrapper">
|
|
|
<el-button size="small" v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
|
|
<el-button size="small" v-if="!multipleMode" @click="toggleMultipleMode(true)">批量编辑</el-button>
|
|
|
<el-button-group v-else>
|
|
<el-button-group v-else>
|
|
|
<el-button size="small" @click="operation1">批量操作1</el-button>
|
|
<el-button size="small" @click="operation1">批量操作1</el-button>
|
|
|
<el-button size="small" @click="operation2">批量操作2</el-button>
|
|
<el-button size="small" @click="operation2">批量操作2</el-button>
|
|
|
<el-button size="small" @click="toggleMultipleMode(false)">取消</el-button>
|
|
<el-button size="small" @click="toggleMultipleMode(false)">取消</el-button>
|
|
|
</el-button-group>
|
|
</el-button-group>
|
|
|
- </div>
|
|
|
|
|
- <el-pagination
|
|
|
|
|
- background
|
|
|
|
|
- @size-change="pageSizeChange"
|
|
|
|
|
- @current-change="currentPageChange"
|
|
|
|
|
- :current-page="currentPage"
|
|
|
|
|
- :page-sizes="[10, 20, 30, 40, 50]"
|
|
|
|
|
- :page-size="pageSize"
|
|
|
|
|
- layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
- :total="totalNumber">
|
|
|
|
|
|
|
+ </div> -->
|
|
|
|
|
+ <el-pagination background @size-change="pageSizeChange" @current-change="currentPageChange" :current-page="currentPage" :page-sizes="[10, 20, 30, 40, 50]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalNumber">
|
|
|
</el-pagination>
|
|
</el-pagination>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<script>
|
|
<script>
|
|
|
- import {mapState} from 'vuex'
|
|
|
|
|
|
|
+import { mapState } from 'vuex'
|
|
|
|
|
|
|
|
- export default {
|
|
|
|
|
- created() {
|
|
|
|
|
|
|
+export default {
|
|
|
|
|
+ created() {
|
|
|
|
|
+ this.getData();
|
|
|
|
|
+ },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ totalNumber: 0,
|
|
|
|
|
+ totalPage: 0,
|
|
|
|
|
+ currentPage: 1,
|
|
|
|
|
+ pageSize: 20,
|
|
|
|
|
+ tableData: [],
|
|
|
|
|
+ filter1: '',
|
|
|
|
|
+ filter2: '',
|
|
|
|
|
+ tableColumns: [{
|
|
|
|
|
+ label: '用户名',
|
|
|
|
|
+ value: 'username',
|
|
|
|
|
+ show: true
|
|
|
|
|
+ }, {
|
|
|
|
|
+ label: '昵称',
|
|
|
|
|
+ value: 'nickname',
|
|
|
|
|
+ show: true
|
|
|
|
|
+ }, {
|
|
|
|
|
+ label: '头像',
|
|
|
|
|
+ value: 'icon',
|
|
|
|
|
+ show: true
|
|
|
|
|
+ }, {
|
|
|
|
|
+ label: '性别',
|
|
|
|
|
+ value: 'sex',
|
|
|
|
|
+ show: true
|
|
|
|
|
+ }, {
|
|
|
|
|
+ label: 'openId',
|
|
|
|
|
+ value: 'openId',
|
|
|
|
|
+ show: true
|
|
|
|
|
+ }],
|
|
|
|
|
+ multipleMode: false
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ ...mapState(['tableHeight']),
|
|
|
|
|
+ selection() {
|
|
|
|
|
+ return this.$refs.table.selection.map(i => i.id);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ pageSizeChange(size) {
|
|
|
|
|
+ this.pageSize = size;
|
|
|
this.getData();
|
|
this.getData();
|
|
|
},
|
|
},
|
|
|
- data() {
|
|
|
|
|
- return {
|
|
|
|
|
- totalNumber: 0,
|
|
|
|
|
- totalPage: 0,
|
|
|
|
|
- currentPage: 1,
|
|
|
|
|
- pageSize: 20,
|
|
|
|
|
- tableData: [],
|
|
|
|
|
- filter1: '',
|
|
|
|
|
- filter2: '',
|
|
|
|
|
- tableColumns: [{
|
|
|
|
|
- label: '用户名',
|
|
|
|
|
- value: 'username',
|
|
|
|
|
- show: true
|
|
|
|
|
- }, {
|
|
|
|
|
- label: '昵称',
|
|
|
|
|
- value: 'nickname',
|
|
|
|
|
- show: true
|
|
|
|
|
- }, {
|
|
|
|
|
- label: '头像',
|
|
|
|
|
- value: 'icon',
|
|
|
|
|
- show: true
|
|
|
|
|
- }, {
|
|
|
|
|
- label: '性别',
|
|
|
|
|
- value: 'sex',
|
|
|
|
|
- show: true
|
|
|
|
|
- }, {
|
|
|
|
|
- label: 'openId',
|
|
|
|
|
- value: 'openId',
|
|
|
|
|
- show: true
|
|
|
|
|
- }],
|
|
|
|
|
- multipleMode: false
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ currentPageChange(page) {
|
|
|
|
|
+ this.currentPage = page;
|
|
|
|
|
+ this.getData();
|
|
|
|
|
+ },
|
|
|
|
|
+ getData() {
|
|
|
|
|
+ this.$http.get({
|
|
|
|
|
+ url: '/userInfo/page',
|
|
|
|
|
+ data: {
|
|
|
|
|
+ currentPage: this.currentPage,
|
|
|
|
|
+ pageNumber: this.pageSize
|
|
|
|
|
+ }
|
|
|
|
|
+ }).then(res => {
|
|
|
|
|
+ if (res.success) {
|
|
|
|
|
+ this.totalNumber = res.data.page.totalNumber;
|
|
|
|
|
+ this.tableData = res.data.pp;
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
- computed: {
|
|
|
|
|
- ...mapState(['tableHeight']),
|
|
|
|
|
- selection() {
|
|
|
|
|
- return this.$refs.table.selection.map(i => i.id);
|
|
|
|
|
|
|
+ isColumnShow(column) {
|
|
|
|
|
+ var row = this.tableColumns.find(i => i.value === column);
|
|
|
|
|
+ return row ? row.show : false;
|
|
|
|
|
+ },
|
|
|
|
|
+ toggleMultipleMode(multipleMode) {
|
|
|
|
|
+ this.multipleMode = multipleMode;
|
|
|
|
|
+ if (!multipleMode) {
|
|
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- methods: {
|
|
|
|
|
- pageSizeChange(size) {
|
|
|
|
|
- this.pageSize = size;
|
|
|
|
|
- this.getData();
|
|
|
|
|
- },
|
|
|
|
|
- currentPageChange(page) {
|
|
|
|
|
- this.currentPage = page;
|
|
|
|
|
- this.getData();
|
|
|
|
|
- },
|
|
|
|
|
- getData() {
|
|
|
|
|
- this.$http.get({
|
|
|
|
|
- url: '/userInfo/page',
|
|
|
|
|
- data: {
|
|
|
|
|
- currentPage: this.currentPage,
|
|
|
|
|
- pageNumber: this.pageSize
|
|
|
|
|
- }
|
|
|
|
|
- }).then(res => {
|
|
|
|
|
- if (res.success) {
|
|
|
|
|
- this.totalNumber = res.data.page.totalNumber;
|
|
|
|
|
- this.tableData = res.data.pp;
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- },
|
|
|
|
|
- isColumnShow(column) {
|
|
|
|
|
- var row = this.tableColumns.find(i => i.value === column);
|
|
|
|
|
- return row ? row.show : false;
|
|
|
|
|
- },
|
|
|
|
|
- toggleMultipleMode(multipleMode) {
|
|
|
|
|
- this.multipleMode = multipleMode;
|
|
|
|
|
- if (!multipleMode) {
|
|
|
|
|
- this.$refs.table.clearSelection();
|
|
|
|
|
|
|
+ editRow(row) {
|
|
|
|
|
+ this.$router.push({
|
|
|
|
|
+ path: '/user',
|
|
|
|
|
+ query: {
|
|
|
|
|
+ id: row.id
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- editRow(row) {
|
|
|
|
|
- this.$router.push({
|
|
|
|
|
- path: '/user',
|
|
|
|
|
- query: {
|
|
|
|
|
- id: row.id
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ initPassword(row) {
|
|
|
|
|
+
|
|
|
|
|
+ this.$alert('初始化密码将无法恢复,确认要初始化么?', '警告', { type: 'error' }).then(() => {
|
|
|
|
|
+ return this.$http.post({
|
|
|
|
|
+ url: '/userInfo/initPassword',
|
|
|
|
|
+ data: { id: row.id }
|
|
|
})
|
|
})
|
|
|
- },
|
|
|
|
|
- operation1() {
|
|
|
|
|
- this.$notify({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- message: this.selection
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- operation2() {
|
|
|
|
|
- this.$message('操作2');
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ this.$message.success('成功');
|
|
|
|
|
+ }).catch(action => {
|
|
|
|
|
+ if (action === 'cancel') {
|
|
|
|
|
+ this.$message.info('取消');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error('失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ operation1() {
|
|
|
|
|
+ this.$notify({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ message: this.selection
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ operation2() {
|
|
|
|
|
+ this.$message('操作2');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
|
-
|
|
|
|
|
</style>
|
|
</style>
|