baseInfo.vue 2.07 KB
Newer Older
renhanxue's avatar
renhanxue committed
1 2
<template>
  <div>
renhanxue's avatar
renhanxue committed
3
    <div class="title">修改基本信息</div>
renhanxue's avatar
renhanxue committed
4
    <el-form ref="form" :model="form" label-width="100px" :rules="rules">
5 6
      <el-form-item label="用户名:" prop="userName">
        <el-input v-model="form.userName" />
renhanxue's avatar
renhanxue committed
7
      </el-form-item>
8 9 10 11 12 13 14 15 16
      <el-form-item label="所在部门:" prop="deptId">
        <el-select v-model="form.deptId" style="width:100%" placeholder="请选择">
          <el-option
            v-for="item in departList"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
renhanxue's avatar
renhanxue committed
17 18
      </el-form-item>
      <el-form-item label="电话号码:">
19
        <el-input v-model="form.phone" />
renhanxue's avatar
renhanxue committed
20 21 22 23 24
      </el-form-item>
      <el-form-item label="邮箱:">
        <el-input v-model="form.email" />
      </el-form-item>
    </el-form>
renhanxue's avatar
renhanxue committed
25 26 27
    <div class="btn">
      <el-button type="primary" @click="confirm">确认修改</el-button>
    </div>
renhanxue's avatar
renhanxue committed
28 29 30 31
  </div>
</template>

<script>
32 33 34
import { mapGetters } from 'vuex'
import { rules } from '../../const'
import { updateInfo } from '../../api'
renhanxue's avatar
renhanxue committed
35 36
export default {
  data() {
37
    let { deptId, email, phone, userId, userName } = this.$store.state.user.userBaseInfo
renhanxue's avatar
renhanxue committed
38 39
    return {
      form: {
40 41 42 43 44
        deptId: deptId,
        email: email,
        phone:  phone,
        userId: userId,
        userName: userName
renhanxue's avatar
renhanxue committed
45
      },
46
      rules
renhanxue's avatar
renhanxue committed
47 48
    }
  },
49 50 51
  computed: {
    ...mapGetters('depart', ['departList']),
  },
renhanxue's avatar
renhanxue committed
52 53 54 55
  methods: {
    confirm() {
      this.$refs.form.validate((valid) => {
        if (valid) {
56 57 58
          updateInfo(this.form).then(res => {
            this.$message.success('操作成功')
          })
renhanxue's avatar
renhanxue committed
59 60 61 62 63 64 65
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
renhanxue's avatar
renhanxue committed
66 67 68
}
</script>
<style lang="scss" scoped>
renhanxue's avatar
renhanxue committed
69 70 71
.btn {
  margin-top: 50px;
  text-align: center;
renhanxue's avatar
renhanxue committed
72
}
renhanxue's avatar
renhanxue committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
.title {
  width: 100%;
  height: 60px;
  background: rgba(226, 235, 255, 0.39);
  line-height: 60px;
  font-size: 18px;
  color: #333;
  font-weight: 500;
  text-align: center;
  margin-bottom: 30px;
}
.el-form {
  width: 500px;
  margin: 0 auto;
}
renhanxue's avatar
renhanxue committed
88
</style>