index.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div id="detail">
  3. <el-row>
  4. <el-col :span="24" class="debt">
  5. <el-col :span="24" class="top">
  6. <!-- <topInfo :topTitle="topTitle" :display="display"></topInfo> -->
  7. <detailTopInfo :topTitle="topTitle" :display="display"></detailTopInfo>
  8. </el-col>
  9. <el-col :span="24" class="main">
  10. <userInfoForm :ruleForm="ruleForm" :formTitle="formTitle" @submitForm="submitForm" @resetForm="resetForm"></userInfoForm>
  11. </el-col>
  12. </el-col>
  13. </el-row>
  14. </div>
  15. </template>
  16. <script>
  17. import topInfo from '@/layout/common/topInfo.vue';
  18. import detailTopInfo from '@/layout/common/detailTopInfo.vue';
  19. import userInfoForm from '@/layout/userInfo/userInfoForm.vue';
  20. import { mapState, mapMutations, createNamespacedHelpers, mapGetters } from 'vuex';
  21. const { mapActions: otheruser } = createNamespacedHelpers('otheruser');
  22. export default {
  23. name: 'detail',
  24. props: {},
  25. components: {
  26. detailTopInfo, //头部导航
  27. userInfoForm, //头部返回
  28. },
  29. data: () => ({
  30. topTitle: '账号设置',
  31. display: 'block',
  32. formTitle: '个人信息管理',
  33. ruleForm: {},
  34. }),
  35. created() {
  36. this.searchInfo();
  37. },
  38. computed: {
  39. id() {
  40. return this.user.uid;
  41. },
  42. ...mapState(['user']),
  43. },
  44. methods: {
  45. ...otheruser(['query', 'fetch', 'update', 'create']),
  46. async searchInfo() {
  47. if (this.id) {
  48. const res = await this.fetch(this.id);
  49. this.$set(this, `ruleForm`, res.data);
  50. }
  51. },
  52. // 提交
  53. async submitForm({ data }) {
  54. let res;
  55. if (this.id) {
  56. res = await this.update(data);
  57. if (res.errcode === 0) {
  58. this.$router.push({ name: 'login' });
  59. this.$message({
  60. message: '信息修改成功',
  61. type: 'success',
  62. });
  63. }
  64. }
  65. console.log(res.data);
  66. },
  67. // 取消
  68. resetForm() {
  69. this.$router.push({ path: '/index' });
  70. },
  71. // 返回
  72. goBack() {
  73. this.$router.go(-1);
  74. },
  75. },
  76. };
  77. </script>
  78. <style lang="less" scoped>
  79. .top {
  80. height: 50px;
  81. margin: 0 0 10px 0;
  82. }
  83. .main {
  84. min-height: 765px;
  85. background: #ffffff;
  86. padding: 20px;
  87. }
  88. </style>