activeUser.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div>
  3. <div class="batch_button">
  4. <el-button class="export" @click="exportData">导出数据</el-button>
  5. <el-button class="activate" @click="batchActivate">批量激活</el-button>
  6. <el-button class="delete" @click="batchDelete">批量删除</el-button>
  7. </div>
  8. <el-table ref="multipleTable" :data="tableData" tooltip-effect="dark" :header-cell-style="{ textAlign: 'center' }"
  9. :cell-style="{ textAlign: 'center' }" height="405" style="width: 100%" @selection-change="handleSelectionChange">
  10. <el-table-column type="selection" width="50">
  11. </el-table-column>
  12. <el-table-column prop="username" label="用户名">
  13. </el-table-column>
  14. <el-table-column prop="phone_num" label="手机号">
  15. </el-table-column>
  16. <el-table-column prop="email" label="邮箱">
  17. </el-table-column>
  18. <el-table-column prop="role" label="角色">
  19. </el-table-column>
  20. <el-table-column prop="permission" label="权限">
  21. </el-table-column>
  22. <el-table-column prop="working_address" label="单位">
  23. </el-table-column>
  24. <el-table-column prop="register_time" label="注册时间">
  25. </el-table-column>
  26. <el-table-column prop="status" label="状态">
  27. <template slot-scope="scope">
  28. <el-tag :color="scope.row.status == true ? '#06f77e' : '#757776'"></el-tag>
  29. </template>
  30. </el-table-column>
  31. <el-table-column prop="operation" label="操作">
  32. <template slot-scope="scope">
  33. <el-button size="mini" type="text" style="color: #2ea8e6" @click="userDetail(scope.row)">查看</el-button>
  34. <el-button size="mini" type="text" style="color: #2ea8e6"
  35. @click="userInfoEdit(scope.row)">编辑</el-button>
  36. <el-button size="mini" type="text" style="color: #2ea8e6" @click="deleteUser(scope.row)">删除</el-button>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <div class="bottom">
  41. <page class="page" :paginationData="paginationData"></page>
  42. </div>
  43. <!--弹窗-->
  44. <user-detail ref="userDetail"></user-detail>
  45. <userInfoEdit ref="userInfoEdit"></userInfoEdit>
  46. </div>
  47. </template>
  48. <script>
  49. import page from '@/components/pagination/index';
  50. import { getUserList, deleteSingleUser, updateUserDetail } from '@/api/user/user';
  51. import UserDetail from '../messageDialog/userInfoDetail';
  52. import userInfoEdit from '../messageDialog/userInfoEdit';
  53. export default {
  54. components: { page, UserDetail, userInfoEdit },
  55. data() {
  56. return {
  57. tableData: [],
  58. multipleSelection: [],
  59. currentPageSize: 10,
  60. currentPage: 1,
  61. paginationData: {
  62. pageSize: 10,
  63. pagerCount: 5,
  64. currentPage: 1,
  65. pageSizes: [5, 10, 20, 30],
  66. total: 0,
  67. currentChange: (val) => {
  68. this.getTableData(val);
  69. },
  70. handleSizeChange: (val) => {
  71. this.handleSizeChange(val);
  72. },
  73. },
  74. }
  75. },
  76. mounted() {
  77. this.initData();
  78. },
  79. methods: {
  80. initData() {
  81. this.getTableData(1);
  82. },
  83. handleSelectionChange(val) {
  84. this.multipleSelection = val;
  85. },
  86. handleClick() {
  87. //
  88. },
  89. getTableData(page) {
  90. this.tableData = [];
  91. getUserList(
  92. 0,
  93. page,
  94. this.currentPageSize
  95. ).then((res) => {
  96. if (res.data.code === 0 && res.data.data.length > 0) {
  97. this.paginationData.total = res.data.total;
  98. this.tableData = res.data.data.map((e) => {
  99. return {
  100. username: e.name,
  101. phone: e.phone,
  102. email: e.email,
  103. role: e.role,
  104. permission: e.permission,
  105. working_address: e.company,
  106. register_time: e.register_time,
  107. status: e.on_job_status
  108. }
  109. })
  110. }
  111. })
  112. },
  113. handleSizeChange(val) {
  114. this.currentPageSize = val;
  115. this.getTableData(this.currentPage);
  116. },
  117. userDetail() {
  118. this.$refs.userDetail.dialogVisible = true;
  119. },
  120. userInfoEdit() {
  121. this.$refs.userInfoEdit.dialogVisible = true;
  122. },
  123. deleteUser(data) {
  124. let options = {
  125. id: data.id,
  126. username: data.username,
  127. password: data.password
  128. };
  129. deleteSingleUser(options).then((res) => {
  130. if (res.data.code === 0) {
  131. this.$message.success('删除成功');
  132. this.getTableData(1);
  133. }
  134. })
  135. },
  136. userDetail(data) {
  137. },
  138. userInfoEdit(data) {
  139. let options = {
  140. id: data.id,
  141. };
  142. updateUserDetail(options).then((res) => {
  143. })
  144. },
  145. batchActivate() {
  146. },
  147. batchDelete() {
  148. },
  149. exportData() {
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="less" scoped>
  155. .el-tag {
  156. width: 12px;
  157. height: 12px;
  158. border-radius: 100px;
  159. padding: 0;
  160. }
  161. .el-table {
  162. position: relative;
  163. top: 50px;
  164. left: 0;
  165. border: 1px solid #f0f2f2;
  166. font-size: 0.95rem;
  167. font-family: PingFang SC;
  168. font-weight: 500;
  169. color: #b2b2b2;
  170. background: rgba(255, 255, 255, 0.8);
  171. /deep/th {
  172. background: #f7fbff;
  173. }
  174. /deep/.el-checkbox {
  175. color: #b2b2b2;
  176. .el-checkbox__input.is-checked+.el-checkbox__label {
  177. color: #2ea8e6;
  178. }
  179. .el-checkbox__input.is-checked .el-checkbox__inner::after {
  180. width: 70%;
  181. height: 70%;
  182. background: #2ea8e6;
  183. border-radius: 0;
  184. transform: rotate(0deg) scaleY(1);
  185. position: static;
  186. // border: 1px solid #8DD9FF;
  187. }
  188. .el-checkbox__inner {
  189. border: 1px solid #8dd9ff;
  190. background: rgba(0, 170, 255, 0);
  191. display: flex;
  192. align-items: center;
  193. justify-content: center;
  194. position: static;
  195. &::after {
  196. transition: 0ms;
  197. }
  198. }
  199. .el-checkbox__label {
  200. padding-left: 0;
  201. font-size: 15px;
  202. position: absolute;
  203. top: 1px;
  204. left: 25px;
  205. }
  206. }
  207. }
  208. .batch_button {
  209. position: relative;
  210. top: 50px;
  211. float: left;
  212. left: 280px;
  213. .export {
  214. padding: 3px;
  215. width: 80px;
  216. height: 30px;
  217. bottom: 15px;
  218. position: absolute;
  219. color: #fff;
  220. border-radius: 4px;
  221. right: 190px;
  222. background-color: #2ea8e6;
  223. }
  224. .activate {
  225. padding: 3px;
  226. width: 80px;
  227. height: 30px;
  228. bottom: 15px;
  229. position: absolute;
  230. color: #fff;
  231. border-radius: 4px;
  232. right: 100px;
  233. background-color: #2ea8e6;
  234. }
  235. .delete {
  236. padding: 3px;
  237. width: 80px;
  238. height: 30px;
  239. bottom: 15px;
  240. position: absolute;
  241. color: #fff;
  242. border-radius: 4px;
  243. right: 10px;
  244. background-color: #b3b3b3;
  245. }
  246. }
  247. .bottom {
  248. position: absolute;
  249. left: 20px;
  250. right: 16px;
  251. bottom: 20px;
  252. height: 50px;
  253. line-height: 20px;
  254. background-color: #ffffff;
  255. text-align: center;
  256. }
  257. </style>