123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <template>
- <div class="subPage">
- <div class="system-table-search">
- <div class="flex-h">
- <div class="flex-item flex-h">
- <el-button size="mini" type="success" @click="addUser">新增用户</el-button>
- </div>
- <tableSearch value='请输入用户名' @exportSearchKey="searchList"></tableSearch>
- </div>
- <div class="moreFilter"></div>
- </div>
- <div class="system-table-box">
- <el-table
- :data="tableData"
- stripe
- style="width: 100%">
- <el-table-column
- fixed
- prop="userName"
- label="用户名"
- width="150">
- </el-table-column>
- <el-table-column
- prop="realName"
- label="真实姓名"
- width="120">
- </el-table-column>
- <el-table-column
- prop="email"
- label="邮箱"
- width="150">
- </el-table-column>
- <el-table-column
- prop="workNum"
- label="工号"
- width="200">
- </el-table-column>
- <el-table-column
- prop="mobile"
- label="手机号"
- width="100">
- </el-table-column>
- <el-table-column
- prop="userType"
- label="用户类型"
- width="100">
- </el-table-column>
- <el-table-column
- prop="lock"
- label="是否锁定"
- width="100">
- </el-table-column>
- <el-table-column
- prop="creatTime"
- label="创建时间"
- width="200">
- </el-table-column>
- <el-table-column label="操作" fixed='right' width="300">
- <template slot-scope="scope">
- <el-button
- size="mini"
- type="warning"
- @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
- <el-button
- size="mini"
- type="danger"
- @click="handleDelete(scope.$index, scope.row)">删除</el-button>
- <el-button
- size="mini"
- type="success"
- @click="handleBind(scope.$index, scope.row)">绑定角色</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page.sync="currentPage"
- :page-size="10"
- layout="prev, pager, next, jumper"
- :total="100">
- </el-pagination>
- <el-dialog title='绑定角色' :visible.sync="dialogTableVisible">
- <form class="mainForm">
- <ul>
- <li class="flex-h">
- <span>输入搜索:</span>
- <div class="flex-item">
- <div>
- <el-input
- placeholder="请输入角色"
- v-model="postData.searchData"
- clearable>
- </el-input>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>搜索结果:</span>
- <div class="flex-item">
- <div>
- <el-button
- v-for="tag in searchTags"
- :key="tag.name"
- style="margin-right:1rem"
- @click='addTag(tag)'>
- {{tag.name}}
- </el-button>
- </div>
- </div>
- </li>
- <li class="flex-h">
- <span>当前角色:</span>
- <div class="flex-item">
- <div>
- <el-tag
- v-for="tag in tags"
- :key="tag.name"
- style="margin-right:1rem"
- @close="handleClose(tag)"
- closable>
- {{tag.name}}
- </el-tag>
- </div>
- </div>
- </li>
- </ul>
- </form>
- </el-dialog>
- </div>
- </template>
-
- <script>
- import tableSearch from '@/components/tableSearch/index'
- import { createNamespacedHelpers } from 'vuex'
- const { mapState: mapUserState, mapActions: mapUserActions } = createNamespacedHelpers('user')
- export default {
- name: '',
- data () {
- return {
- currentPage: 0, // 当前页码
- dialogTableVisible: false,
- tableSearch: { // 表格搜索条件
- key: '111', // 搜索关键字
- },
- tableData: [{
- userName: '赵日天',
- realName: '13446666666',
- email: '赵日地',
- workNum: '赵爸爸',
- mobile: '1376975175',
- userType: '1',
- lock: true,
- creatTime: '2018-08-08 10:00:00'
- }],
- postData: {
- searchData: ''
- },
- tags: [
- { name: '角色0' },
- { name: '角色1' },
- { name: '角色2' },
- { name: '角色3' },
- { name: '角色4' }
- ]
- }
- },
- components: {
- tableSearch,
- },
- computed: {
- ...mapUserState({
- searchTags: x => x.roleList,
- })
- },
- methods: {
- handleSizeChange (val) {
- console.log(`每页 ${val} 条`)
- },
- handleCurrentChange (val) {
- console.log(`当前页: ${val}`)
- },
- handleEdit (index, row) { // 编辑
- console.log(index, row)
- this.$router.push({ name: 'editUser', query: { realName: row.realName } })
- },
- handleDelete (index, row) { // 删除
- console.log(index, row)
- this.$confirm('确认删除此用户?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$message({
- type: 'success',
- message: '删除成功!'
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- })
- })
- },
- handleBind (index, row) {
- console.log(index, row)
- this.dialogTableVisible = true
- },
- searchList (key) { // 搜索列表
- console.log(key)
- },
- addUser () {
- this.$router.push({ name: 'addUser' })
- },
- handleClose (tag) {
- this.tags.splice(this.tags.indexOf(tag), 1)
- },
- ...mapUserActions(['upDateRoleList']),
- addTag (tag) {
- this.upDateRoleList(tag)
- }
- }
- }
- </script>
-
- <!-- Add "scoped" attribute to limit CSS to this component only -->
- <style lang="scss" scoped>
- </style>
|