accountDetail.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div>
  3. <div class="label-box rig-margin">
  4. <span class="label-title right">基本信息</span>
  5. </div>
  6. <div class="top-buttons">
  7. <el-button size="small" @click="goBack">返回</el-button>
  8. <el-button size="small" type="primary" @click="editAccount">编辑</el-button>
  9. <el-button size="small" v-if="basicForm.enabled !== 1" @click="enableAccount">启用</el-button>
  10. <el-button size="small" v-if="basicForm.enabled === 1" @click="disableAccount">禁用</el-button>
  11. <el-button size="small" @click="removeAccount">删除</el-button>
  12. </div>
  13. <div class="detail-item">
  14. <span class="name">姓名</span>
  15. <span class="content">{{ basicForm.operatorName | empty }}</span>
  16. </div>
  17. <div class="detail-item">
  18. <span class="name">手机</span>
  19. <span class="content">{{ basicForm.operatorMobilePhone | empty }}</span>
  20. </div>
  21. <div class="detail-item">
  22. <span class="name">密码</span>
  23. <span class="content">{{ basicForm.loginPassword | empty }}</span>
  24. </div>
  25. <div class="detail-item">
  26. <span class="name">部门</span>
  27. <span class="content">{{ basicForm.departmentName | empty }}</span>
  28. </div>
  29. <div class="detail-item">
  30. <span class="name">职位</span>
  31. <span class="content">{{ basicForm.positionName | empty }}</span>
  32. </div>
  33. </div>
  34. </template>
  35. <script>
  36. import { staffInfo, enable, disable, remove } from '../../api/account'
  37. export default {
  38. filters: {
  39. empty(value) {
  40. let empt = '';
  41. if (!value) {
  42. empt = '--';
  43. } else {
  44. empt = value
  45. }
  46. return empt
  47. }
  48. },
  49. data() {
  50. return {
  51. stateName: '',
  52. operatorId: '',
  53. basicForm: {
  54. operatorName: '',
  55. operatorMobilePhone: '',
  56. loginPassword: '',
  57. departmentName: '',
  58. positionName: '',
  59. enabled: '0', // 当前的启用禁用状态
  60. }
  61. }
  62. },
  63. mounted() {
  64. this.operatorId = JSON.parse(localStorage.getItem('row')).operatorId
  65. this.getAccountDetail()
  66. },
  67. methods: {
  68. getAccountDetail() {
  69. staffInfo({ operatorId: this.operatorId })
  70. .then(res => {
  71. this.basicForm = res.data
  72. })
  73. },
  74. goBack() {
  75. this.$router.go(-1)
  76. },
  77. editAccount() {
  78. this.$router.push('accountEdit')
  79. },
  80. // 启用账户方法
  81. enableAccount() {
  82. enable({ operatorId: this.operatorId })
  83. .then(() => {
  84. this.$message({
  85. type: 'success',
  86. message: '启用成功!',
  87. showClose: true
  88. });
  89. this.getAccountDetail()
  90. })
  91. },
  92. // 禁用账户方法
  93. disableAccount() {
  94. this.$confirm(`禁用后,${this.basicForm.operatorName}将无法登录后台`, '提示', {
  95. confirmButtonText: '确定',
  96. cancelButtonText: '取消',
  97. type: 'warning'
  98. }).then(() => {
  99. disable({ operatorId: this.operatorId })
  100. .then(() => {
  101. this.$message({
  102. type: 'success',
  103. message: '禁用成功!',
  104. showClose: true
  105. });
  106. this.getAccountDetail()
  107. })
  108. }).catch(() => {
  109. this.$message({
  110. type: 'info',
  111. message: '已取消删除',
  112. showClose: true
  113. });
  114. });
  115. },
  116. removeAccount() {
  117. this.$confirm('删除后,账号数据将被清空', '提示', {
  118. confirmButtonText: '确定',
  119. cancelButtonText: '取消',
  120. type: 'warning'
  121. }).then(() => {
  122. remove({ operatorId: this.operatorId })
  123. .then(() => {
  124. this.$router.go(-1)
  125. })
  126. }).catch(() => {
  127. this.$message({
  128. type: 'info',
  129. message: '已取消删除',
  130. showClose: true
  131. });
  132. });
  133. }
  134. },
  135. }
  136. </script>
  137. <style scoped lang="scss">
  138. .rig-margin {
  139. padding: 15px 0 0 20px;
  140. }
  141. .inp {
  142. width: 275px;
  143. }
  144. .form {
  145. margin: 30px 0 0 0;
  146. }
  147. .table {
  148. margin-top: 40px;
  149. }
  150. .detail-item {
  151. margin-bottom: 20px;
  152. }
  153. .name {
  154. width: 120px;
  155. text-align: right;
  156. display: inline-block;
  157. color: #666666;
  158. }
  159. .content {
  160. margin-left: 20px;
  161. display: inline-block;
  162. color: #333333;
  163. }
  164. .head2 {
  165. margin-top: 40px;
  166. }
  167. </style>