accountList.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div>
  3. <div class="head">
  4. <span class="headicon">账号管理</span>
  5. </div>
  6. <div class="top-buttons">
  7. <el-button size="small" type="primary" @click="goAddAccount">新增</el-button>
  8. <div class="search">
  9. <el-input v-model="page.keyword" size="small" placeholder="请输入搜索内容" class="page-search" clearable @clear="getAccountList" @keyup.enter.native="getAccountList"></el-input>
  10. <svg-icon icon-class="gen" class="genIcon" @click="getAccountList" />
  11. </div>
  12. </div>
  13. <div class="table">
  14. <el-table style="width: 100%" :data="tableData" @row-click="handleRowClick" @cell-click="mouseEnter">
  15. <el-table-column prop="roleId" label="序号" width="50" align="center">
  16. <template slot-scope="scope">{{ scope.$index+1 }}</template>
  17. </el-table-column>
  18. <el-table-column prop="operatorName" label="姓名" />
  19. <el-table-column prop="operatorMobilePhone" label="手机号" maxlength="11" />
  20. <el-table-column prop="departmentName" label="部门" />
  21. <el-table-column prop="positionName" label="职位" />
  22. <el-table-column prop="createDate" label="添加时间" width="250" />
  23. <el-table-column prop="status" label="状态">
  24. <template slot-scope="scope">
  25. <template> {{ scope.row.enabled===1?'启用':'禁用' }} </template>
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="action" label="操作" align="center">
  29. <yh-operaction :lable="lable" @skip="skip" />
  30. </el-table-column>
  31. </el-table>
  32. </div>
  33. <pagination v-show="total>0" :total="total" :page.sync="page.currentPage" :limit.sync="page.pageSize" @pagination="pageChanged" />
  34. </div>
  35. </template>
  36. <script>
  37. import yhOperaction from "../../layout/components/common/operaction.vue";
  38. import Pagination from "../../components/Pagination";
  39. import { operators, disable, remove, enable } from "../../api/account";
  40. export default {
  41. components: {
  42. yhOperaction,
  43. Pagination
  44. },
  45. data() {
  46. return {
  47. rowMsg: "",
  48. // status:'',
  49. page: { currentPage: 1, pageSize: 10, keyword: "" },
  50. total: 10,
  51. lable: [
  52. { lab: "编辑", click: "edit" },
  53. { lab: "禁用", click: "forbidden" },
  54. { lab: "删除", click: "del" }
  55. ],
  56. tableData: []
  57. };
  58. },
  59. mounted() {
  60. this.getAccountList();
  61. },
  62. methods: {
  63. pageChanged(event, value) {
  64. if (event === "update:page") {
  65. this.page.currentPage = value;
  66. } else if (event === "update:limit") {
  67. this.page.pageSize = value;
  68. }
  69. this.getAccountList();
  70. },
  71. goAddAccount() {
  72. this.$router.push({ name: "accountNewly" });
  73. },
  74. handleDelete() {},
  75. skip(msg) {
  76. if (msg === "edit") {
  77. localStorage.setItem("row", JSON.stringify(this.rowMsg));
  78. this.$router.push({ name: "accountEdit" });
  79. } else if (msg === "forbidden") {
  80. disable({ operatorId: this.rowMsg.operatorId }).then(() => {
  81. this.getAccountList();
  82. this.$message({
  83. type: "success",
  84. message: "禁用成功!",
  85. showClose: true
  86. });
  87. // this.basicForm.status='禁用成功'
  88. });
  89. } else if (msg === "del") {
  90. remove({ operatorId: this.rowMsg.operatorId })
  91. .then(() => {
  92. this.getAccountList();
  93. this.$message({
  94. message: "删除成功",
  95. type: "success",
  96. showClose: true
  97. });
  98. })
  99. .catch(() => {
  100. this.$message({
  101. message: "删除失败",
  102. type: "error",
  103. showClose: true
  104. });
  105. });
  106. } else if (msg === "enable") {
  107. enable({ operatorId: this.rowMsg.operatorId })
  108. .then(() => {
  109. this.getAccountList();
  110. this.$message({
  111. type: "success",
  112. message: "启用成功!",
  113. showClose: true
  114. });
  115. })
  116. .catch(() => {
  117. this.$message({
  118. type: "info",
  119. message: "已取消删除",
  120. showClose: true
  121. });
  122. });
  123. }
  124. },
  125. mouseEnter(row) {
  126. this.state(row);
  127. this.rowMsg = row;
  128. },
  129. handleRowClick(row, column) {
  130. if (column.property !== "action") {
  131. localStorage.setItem("row", JSON.stringify(row));
  132. this.$router.push({ name: "accountDetail" });
  133. }
  134. },
  135. add() {
  136. this.$router.push({ name: "accountNewly", params: { id: "123" } });
  137. },
  138. getAccountList() {
  139. operators(this.page).then(response => {
  140. this.tableData = response.data.records;
  141. this.page.currentPage = response.data.current;
  142. this.total = response.data.total;
  143. });
  144. },
  145. state(response) {
  146. if (response.enabled === 1) {
  147. this.lable.splice(1, 1, { lab: "禁用", click: "forbidden" });
  148. } else {
  149. this.lable.splice(1, 1, { lab: "启用", click: "enable" });
  150. }
  151. }
  152. }
  153. };
  154. </script>
  155. <style scoped lang="scss">
  156. .search {
  157. float: right;
  158. position: relative;
  159. width: 232px;
  160. }
  161. .genIcon {
  162. font-size: 32px;
  163. position: absolute;
  164. top: 9px;
  165. right: 3px;
  166. }
  167. </style>