list.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <!-- 引入样式 -->
  9. <link rel="stylesheet" href="../../plugins/element-ui/index.css" />
  10. <link rel="stylesheet" href="../../styles/common.css" />
  11. <link rel="stylesheet" href="../../styles/page.css" />
  12. <style>
  13. #member-app .notAdmin::after{
  14. border: 0 !important;
  15. }
  16. </style>
  17. </head>
  18. <body>
  19. <div class="dashboard-container" id="member-app">
  20. <div class="container">
  21. <div class="tableBar">
  22. <el-input
  23. v-model="input"
  24. placeholder="请输入员工姓名"
  25. style="width: 250px"
  26. clearable
  27. @keyup.enter.native="handleQuery"
  28. >
  29. <i
  30. slot="prefix"
  31. class="el-input__icon el-icon-search"
  32. style="cursor: pointer"
  33. @click="handleQuery"
  34. ></i>
  35. </el-input>
  36. <el-button
  37. type="primary"
  38. @click="addMemberHandle('add')"
  39. >
  40. + 添加员工
  41. </el-button>
  42. </div>
  43. <el-table
  44. :data="tableData"
  45. stripe
  46. class="tableBox"
  47. >
  48. <el-table-column
  49. prop="name"
  50. label="员工姓名"
  51. ></el-table-column>
  52. <el-table-column
  53. prop="username"
  54. label="账号"
  55. ></el-table-column>
  56. <el-table-column
  57. prop="phone"
  58. label="手机号"
  59. ></el-table-column>
  60. <el-table-column label="账号状态">
  61. <template slot-scope="scope">
  62. {{ String(scope.row.status) === '0' ? '已禁用' : '正常' }}
  63. </template>
  64. </el-table-column>
  65. <el-table-column
  66. label="操作"
  67. width="160"
  68. align="center"
  69. >
  70. <template slot-scope="scope">
  71. <el-button
  72. type="text"
  73. size="small"
  74. class="blueBug"
  75. @click="addMemberHandle(scope.row.id)"
  76. :class="{notAdmin:user !== 'admin'}"
  77. >
  78. 编辑
  79. </el-button>
  80. <el-button
  81. type="text"
  82. size="small"
  83. class="delBut non"
  84. @click="statusHandle(scope.row)"
  85. v-if="user === 'admin'"
  86. >
  87. {{ scope.row.status == '1' ? '禁用' : '启用' }}
  88. </el-button>
  89. </template>
  90. </el-table-column>
  91. </el-table>
  92. <el-pagination
  93. class="pageList"
  94. :page-sizes="[10, 20, 30, 40]"
  95. :page-size="pageSize"
  96. layout="total, sizes, prev, pager, next, jumper"
  97. :total="counts"
  98. :current-page.sync="page"
  99. @size-change="handleSizeChange"
  100. @current-change="handleCurrentChange"
  101. ></el-pagination>
  102. </div>
  103. </div>
  104. <!-- 开发环境版本,包含了有帮助的命令行警告 -->
  105. <script src="../../plugins/vue/vue.js"></script>
  106. <!-- 引入组件库 -->
  107. <script src="../../plugins/element-ui/index.js"></script>
  108. <!-- 引入axios -->
  109. <script src="../../plugins/axios/axios.min.js"></script>
  110. <script src="../../js/request.js"></script>
  111. <script src="../../api/member.js"></script>
  112. <script>
  113. new Vue({
  114. el: '#member-app',
  115. data() {
  116. return {
  117. input: '',
  118. counts: 0,
  119. page: 1,
  120. pageSize: 10,
  121. tableData : [],
  122. id : '',
  123. status : '',
  124. }
  125. },
  126. computed: {},
  127. created() {
  128. this.init()
  129. this.user = JSON.parse(localStorage.getItem('userInfo')).username
  130. },
  131. mounted() {
  132. },
  133. methods: {
  134. async init () {
  135. const params = {
  136. page: this.page,
  137. pageSize: this.pageSize,
  138. name: this.input ? this.input : undefined
  139. }
  140. await getMemberList(params).then(res => {
  141. if (String(res.code) === '1') {
  142. this.tableData = res.data.records || []
  143. this.counts = res.data.total
  144. }
  145. }).catch(err => {
  146. this.$message.error('请求出错了:' + err)
  147. })
  148. },
  149. handleQuery() {
  150. this.page = 1;
  151. this.init();
  152. },
  153. // 添加
  154. addMemberHandle (st) {
  155. if (st === 'add'){
  156. window.parent.menuHandle({
  157. id: '2',
  158. url: '/backend/page/member/add.html',
  159. name: '添加员工'
  160. },true)
  161. } else {
  162. window.parent.menuHandle({
  163. id: '2',
  164. url: '/backend/page/member/add.html?id='+st,
  165. name: '修改员工'
  166. },true)
  167. }
  168. },
  169. //状态修改
  170. statusHandle (row) {
  171. this.id = row.id
  172. this.status = row.status
  173. this.$confirm('确认调整该账号的状态?', '提示', {
  174. 'confirmButtonText': '确定',
  175. 'cancelButtonText': '取消',
  176. 'type': 'warning'
  177. }).then(() => {
  178. enableOrDisableEmployee({ 'id': this.id, 'status': !this.status ? 1 : 0 }).then(res => {
  179. console.log('enableOrDisableEmployee',res)
  180. if (String(res.code) === '1') {
  181. this.$message.success('账号状态更改成功!')
  182. this.handleQuery()
  183. }
  184. }).catch(err => {
  185. this.$message.error('请求出错了:' + err)
  186. })
  187. })
  188. },
  189. handleSizeChange (val) {
  190. this.pageSize = val
  191. this.init()
  192. },
  193. handleCurrentChange (val) {
  194. this.page = val
  195. this.init()
  196. }
  197. }
  198. })
  199. </script>
  200. </body>
  201. </html>