personal.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div class="personal">
  3. <!-- 头部细节部分 -->
  4. <div class="title">
  5. <el-row>
  6. <el-col :span="24">
  7. <div class="top">
  8. <div class="geren">个人中心</div>
  9. <div class="line"></div>
  10. <div class="from">
  11. <table>
  12. <tr>
  13. <td><span>用户名</span></td>
  14. <td><span>{{formUserList.userName}}</span></td>
  15. </tr>
  16. <tr>
  17. <td><span>姓名</span></td>
  18. <td><span>{{formUserList.name}}</span></td>
  19. </tr>
  20. <tr>
  21. <td><span>企业名称</span></td>
  22. <td><span>{{formUserList.company}}</span></td>
  23. </tr>
  24. <tr>
  25. <td><span>手机号</span></td>
  26. <td><span>{{formUserList.phone}}</span></td>
  27. </tr>
  28. <tr>
  29. <td><span>余额</span></td>
  30. <td><span>{{formUserList.fee | rounding}}</span></td>
  31. </tr>
  32. <tr>
  33. <td><span>密码</span></td>
  34. <td><span style="color: blue; cursor:pointer;" @click="ChangeThePassword">修改密码</span></td>
  35. </tr>
  36. </table>
  37. </div>
  38. </div>
  39. </el-col>
  40. </el-row>
  41. </div>
  42. <!-- 重置密码 -->
  43. <el-dialog
  44. @close="handleEditDialogClose"
  45. :visible.sync="changepassword"
  46. style="font-size: 0px;">
  47. <div class="tou">用户--重置密码</div>
  48. <div class="line"></div>
  49. <el-form
  50. label-position="right"
  51. label-width="80px"
  52. :model="formList">
  53. <el-form-item label="用户名">
  54. <el-input v-model="formList.userName" auto-complete="off" placeholder="请输入用户"></el-input>
  55. </el-form-item>
  56. <el-form-item label="新密码">
  57. <el-input v-model="formList.password" type="password" auto-complete="off" placeholder="请输入新密码"></el-input>
  58. </el-form-item>
  59. </el-form>
  60. <div slot="footer" class="dialog-footer">
  61. <el-button @click="changepassword = false" type="info">取 消</el-button>
  62. <el-button type="primary" @click="resetPassword">修 改</el-button>
  63. </div>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. export default{
  69. data() {
  70. return {
  71. formUserList: {
  72. 'userName': ``,
  73. 'password': ``,
  74. 'price': ``,
  75. 'id': ``,
  76. 'name': ``,
  77. 'phone': ``,
  78. 'roleId': ``,
  79. 'money': ``,
  80. 'isLock': ``,
  81. 'dutyParagraph': ``,
  82. 'company': ``,
  83. 'threshold': ``,
  84. 'autoUpdate': ``
  85. },
  86. // autoUpdate: 1,
  87. formupdateList: {
  88. 'id': ``,
  89. 'autoUpdate': ``
  90. },
  91. formList: {
  92. 'id': ``,
  93. 'userName': ``,
  94. 'password': ``
  95. },
  96. formthresholdList: {
  97. 'id': ``,
  98. 'threshold': ``
  99. },
  100. changepassword: false
  101. }
  102. },
  103. created() {
  104. this.loadData()
  105. },
  106. filters: {
  107. rounding(value) {
  108. return value.toFixed(2)
  109. }
  110. },
  111. methods: {
  112. async loadData() {
  113. this.formUserList.userId = sessionStorage.getItem(`userId`)
  114. this.formupdateList.id = sessionStorage.getItem(`userId`)
  115. this.formthresholdList.id = sessionStorage.getItem(`userId`)
  116. const response = await this.$http.get(`user/${this.formUserList.userId}`)
  117. if (response.data.code === 0) {
  118. this.formUserList = response.data.data
  119. this.formupdateList.autoUpdate = response.data.data.autoUpdate
  120. };
  121. },
  122. // 打开修改密码的弹框
  123. ChangeThePassword() {
  124. this.changepassword = true
  125. this.formList.userName = this.formUserList.userName
  126. this.formList.id = this.formUserList.id
  127. },
  128. // 修改是否自动更新开票中的发票信息
  129. async updateInvoiceMessage() {
  130. this.formupdateList.autoUpdate = this.formupdateList.autoUpdate
  131. const response = await this.$http.put(`user/auto`, this.formupdateList)
  132. if (response.data.code === 0) {
  133. this.loadData()
  134. this.$message({
  135. type: `success`,
  136. message: `修改成功`
  137. })
  138. } else {
  139. this.$message({
  140. type: `error`,
  141. message: `修改失败`
  142. })
  143. }
  144. },
  145. // 修改密码
  146. async resetPassword() {
  147. const response = await this.$http.put(`user/restPassword`, this.formList)
  148. if (response.data.code === 0) {
  149. this.loadData()
  150. this.changepassword = false
  151. this.$router.push(`/login`)
  152. this.$message({
  153. type: `success`,
  154. message: `修改成功`
  155. })
  156. } else {
  157. this.$message({
  158. type: `error`,
  159. message: `修改失败`
  160. })
  161. }
  162. },
  163. // 更改阈值
  164. async changeThreshold() {
  165. this.formthresholdList.id = this.formUserList.id
  166. this.formthresholdList.threshold = this.formUserList.threshold
  167. const response = await this.$http.put(`user`, this.formthresholdList)
  168. if (response.data.code === 0) {
  169. this.$message({
  170. type: `success`,
  171. message: `修改成功`
  172. })
  173. } else {
  174. this.$message({
  175. type: `error`,
  176. message: `修改失败`
  177. })
  178. }
  179. },
  180. handleEditDialogClose() {
  181. for (var key in this.formList) {
  182. this.formList[key] = ``
  183. };
  184. }
  185. }
  186. }
  187. </script>
  188. <style>
  189. .personal {
  190. border: 1px solid #d9d9d9;
  191. border-radius: 10px;
  192. }
  193. .personal .top {
  194. padding: 20px;
  195. }
  196. .personal .geren {
  197. font-size: 25px;
  198. text-align: center;
  199. padding-top: 15px;
  200. }
  201. .personal .line {
  202. margin-top: 20px;
  203. margin-bottom: 20px;
  204. width: 100%;
  205. height: 2px;
  206. background-color: #d9d9d9;
  207. }
  208. .personal .tou {
  209. font-size: 20px;
  210. height: 30px;
  211. line-height: 30px;
  212. padding-top: 15px;
  213. }
  214. .personal .el-dialog__header, .el-dialog__body {
  215. padding: 0 20px;
  216. }
  217. .personal table {
  218. width: 100%;
  219. border-collapse:collapse;
  220. }
  221. .personal table th {
  222. border: 1px solid #96989f;
  223. text-align: center;
  224. height: 40px;
  225. line-height: 40px;
  226. }
  227. .personal table td {
  228. width: 50%;
  229. border: 1px solid #96989f;
  230. text-align: left;
  231. margin-left: 20px;
  232. height: 40px;
  233. line-height: 40px;
  234. }
  235. .personal table span {
  236. margin-left: 30px;
  237. font-size: 18px;
  238. }
  239. .personal .el-input__inner {
  240. height: 30px !important;
  241. line-height: 30px !important;
  242. }
  243. </style>