index.vue 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div class="subPage">
  3. <div class="system-table-search">
  4. <div class="flex-h">
  5. <div class="flex-item flex-h">
  6. <el-button size="mini" type="success" @click="addUser">新增用户</el-button>
  7. </div>
  8. <tableSearch value='请输入用户名' @exportSearchKey="searchList"></tableSearch>
  9. </div>
  10. <div class="moreFilter"></div>
  11. </div>
  12. <div class="system-table-box">
  13. <el-table
  14. :data="tableData"
  15. stripe
  16. style="width: 100%">
  17. <el-table-column
  18. fixed
  19. prop="userName"
  20. label="用户名"
  21. width="150">
  22. </el-table-column>
  23. <el-table-column
  24. prop="realName"
  25. label="真实姓名"
  26. width="120">
  27. </el-table-column>
  28. <el-table-column
  29. prop="email"
  30. label="邮箱"
  31. width="150">
  32. </el-table-column>
  33. <el-table-column
  34. prop="workNum"
  35. label="工号"
  36. width="200">
  37. </el-table-column>
  38. <el-table-column
  39. prop="mobile"
  40. label="手机号"
  41. width="100">
  42. </el-table-column>
  43. <el-table-column
  44. prop="userType"
  45. label="用户类型"
  46. width="100">
  47. </el-table-column>
  48. <el-table-column
  49. prop="lock"
  50. label="是否锁定"
  51. width="100">
  52. </el-table-column>
  53. <el-table-column
  54. prop="creatTime"
  55. label="创建时间"
  56. width="200">
  57. </el-table-column>
  58. <el-table-column label="操作" fixed='right' width="300">
  59. <template slot-scope="scope">
  60. <el-button
  61. size="mini"
  62. type="warning"
  63. @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  64. <el-button
  65. size="mini"
  66. type="danger"
  67. @click="handleDelete(scope.$index, scope.row)">删除</el-button>
  68. <el-button
  69. size="mini"
  70. type="success"
  71. @click="handleBind(scope.$index, scope.row)">绑定角色</el-button>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. </div>
  76. <el-pagination
  77. @size-change="handleSizeChange"
  78. @current-change="handleCurrentChange"
  79. :current-page.sync="currentPage"
  80. :page-size="10"
  81. layout="prev, pager, next, jumper"
  82. :total="100">
  83. </el-pagination>
  84. <el-dialog title='绑定角色' :visible.sync="dialogTableVisible">
  85. <form class="mainForm">
  86. <ul>
  87. <li class="flex-h">
  88. <span>输入搜索:</span>
  89. <div class="flex-item">
  90. <div>
  91. <el-input
  92. placeholder="请输入角色"
  93. v-model="postData.searchData"
  94. clearable>
  95. </el-input>
  96. </div>
  97. </div>
  98. </li>
  99. <li class="flex-h">
  100. <span>搜索结果:</span>
  101. <div class="flex-item">
  102. <div>
  103. <el-button
  104. v-for="tag in searchTags"
  105. :key="tag.name"
  106. style="margin-right:1rem"
  107. @click='addTag(tag)'>
  108. {{tag.name}}
  109. </el-button>
  110. </div>
  111. </div>
  112. </li>
  113. <li class="flex-h">
  114. <span>当前角色:</span>
  115. <div class="flex-item">
  116. <div>
  117. <el-tag
  118. v-for="tag in tags"
  119. :key="tag.name"
  120. style="margin-right:1rem"
  121. @close="handleClose(tag)"
  122. closable>
  123. {{tag.name}}
  124. </el-tag>
  125. </div>
  126. </div>
  127. </li>
  128. </ul>
  129. </form>
  130. </el-dialog>
  131. </div>
  132. </template>
  133. <script>
  134. import tableSearch from '@/components/tableSearch/index'
  135. import { createNamespacedHelpers } from 'vuex'
  136. const { mapState: mapUserState, mapActions: mapUserActions } = createNamespacedHelpers('user')
  137. export default {
  138. name: '',
  139. data () {
  140. return {
  141. currentPage: 0, // 当前页码
  142. dialogTableVisible: false,
  143. tableSearch: { // 表格搜索条件
  144. key: '111', // 搜索关键字
  145. },
  146. tableData: [{
  147. userName: '赵日天',
  148. realName: '13446666666',
  149. email: '赵日地',
  150. workNum: '赵爸爸',
  151. mobile: '1376975175',
  152. userType: '1',
  153. lock: true,
  154. creatTime: '2018-08-08 10:00:00'
  155. }],
  156. postData: {
  157. searchData: ''
  158. },
  159. tags: [
  160. { name: '角色0' },
  161. { name: '角色1' },
  162. { name: '角色2' },
  163. { name: '角色3' },
  164. { name: '角色4' }
  165. ]
  166. }
  167. },
  168. components: {
  169. tableSearch,
  170. },
  171. computed: {
  172. ...mapUserState({
  173. searchTags: x => x.roleList,
  174. })
  175. },
  176. methods: {
  177. handleSizeChange (val) {
  178. console.log(`每页 ${val} 条`)
  179. },
  180. handleCurrentChange (val) {
  181. console.log(`当前页: ${val}`)
  182. },
  183. handleEdit (index, row) { // 编辑
  184. console.log(index, row)
  185. this.$router.push({ name: 'editUser', query: { realName: row.realName } })
  186. },
  187. handleDelete (index, row) { // 删除
  188. console.log(index, row)
  189. this.$confirm('确认删除此用户?', '提示', {
  190. confirmButtonText: '确定',
  191. cancelButtonText: '取消',
  192. type: 'warning'
  193. }).then(() => {
  194. this.$message({
  195. type: 'success',
  196. message: '删除成功!'
  197. })
  198. }).catch(() => {
  199. this.$message({
  200. type: 'info',
  201. message: '已取消删除'
  202. })
  203. })
  204. },
  205. handleBind (index, row) {
  206. console.log(index, row)
  207. this.dialogTableVisible = true
  208. },
  209. searchList (key) { // 搜索列表
  210. console.log(key)
  211. },
  212. addUser () {
  213. this.$router.push({ name: 'addUser' })
  214. },
  215. handleClose (tag) {
  216. this.tags.splice(this.tags.indexOf(tag), 1)
  217. },
  218. ...mapUserActions(['upDateRoleList']),
  219. addTag (tag) {
  220. this.upDateRoleList(tag)
  221. }
  222. }
  223. }
  224. </script>
  225. <!-- Add "scoped" attribute to limit CSS to this component only -->
  226. <style lang="scss" scoped>
  227. </style>