Blame view

src/views/system/information/base-set.vue 4.34 KB
xiaomiao committed
1 2 3 4 5
<!--
 * @Description  :更新信息
 * @Autor        : miaofang
 * @LastEditTime : 2023-05-18 13:36:30
-->
xiaomiao committed
6
<template>
xiaomiao committed
7
    <div class="informationbase">
xiaomiao committed
8 9 10 11 12
      <el-form
        ref="form"
        label-width="100px"
        :model="form"
        class="form-wrapper"
xiaomiao committed
13
        :rules="rules">
xiaomiao committed
14 15 16 17 18 19 20 21 22 23 24
        <el-form-item label="用户名:" required>
          <el-input v-model="form.loginName" clearable disabled />
        </el-form-item>
        <el-form-item label="姓名:">
          <el-input v-model="form.name" clearable />
        </el-form-item>
        <el-form-item label="性别:">
          <el-radio-group v-model="form.sex">
            <el-radio
              v-for="(item, index) in sexList"
              :key="index"
xiaomiao committed
25
              :label="item.value">{{ item.name }}</el-radio>
xiaomiao committed
26 27 28 29 30 31
          </el-radio-group>
        </el-form-item>
        <el-form-item label="身份证号:" prop="idCard">
          <el-input v-model="form.idCard" clearable />
        </el-form-item>
        <el-form-item label="手机号码:" prop="mobilePhone">
32
          <el-input v-model="form.mobilePhone" clearable />
xiaomiao committed
33
        </el-form-item>
xiaomiao committed
34
        <el-form-item label="办公电话:">
xiaomiao committed
35 36 37 38 39 40 41
          <el-input v-model="form.telephone" clearable />
        </el-form-item>
        <el-form-item label="办公地址:">
          <el-input v-model="form.address" clearable />
        </el-form-item>
      </el-form>
      <div class="bottom-wrapper">
xiaomiao committed
42
        <btn nativeType="cx" type="primary" @click="updateInfo">更新信息</btn>
xiaomiao committed
43 44 45 46 47
      </div>
    </div>
</template>

<script>
xiaomiao committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  import { api, getAction, putAction, getDictItems } from '@/api/manageApi'
  export default {
    props: {
      userInfo: {
        type: Object,
        default: null
      }
    },
    data () {
      return {
        form: {},
        sexList: [],
        rules: {
          mobilePhone: [
            {
              pattern:
                /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
              message: '手机号码格式有误',
              trigger: 'blur'
            }
          ],
          idCard: [
            {
              pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
              message: '身份证号格式有误',
              trigger: 'blur'
            }
          ]
        }
      }
    },
    watch: {
      userInfo: {
        handler: function (val) {
          if (val) {
xiaomiao committed
83
            this.getUserdata(val.id)
xiaomiao committed
84 85 86 87 88
          }
        }
      }
    },
    mounted () {
xiaomiao committed
89
      if (this.userInfo) {
90
        this.getUserdata(this.userInfo.id)
xiaomiao committed
91
      }
xiaomiao committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105
      this.sexList = [
        {
          "name": "男",
          "value": "0",
        },
        {

          "name": "女",
          "value": "1",
        },

        {
          "name": "保密",
          "value": "2",
xiaomiao committed
106

xiaomiao committed
107 108
        }
      ]
109
    },
xiaomiao committed
110
    methods: {
yuanbo committed
111 112 113 114 115
      /**
       * @description: getUserdata
       * @param {*} id
       * @author: renchao
       */
116 117
      getUserdata (id) {
        getAction(`${api.users}/${id}`).then((res) => {
xiaomiao committed
118 119 120 121 122 123 124
          if (res.status === 1) {
            this.form = res.content
          } else {
            this.$message.error({ message: res.message, showClose: true })
          }
        })
      },
yuanbo committed
125 126 127 128
      /**
       * @description: updateInfo
       * @author: renchao
       */
xiaomiao committed
129 130 131 132 133 134
      updateInfo () {
        this.$refs.form.validate((valid) => {
          if (valid) {
            putAction(`${api.users}/${this.form.id}`, this.form).then((res) => {
              if (res.status === 1) {
                this.$message.success({ message: res.message, showClose: true })
xiaomiao committed
135
                this.getUserdata(this.form.id)
xiaomiao committed
136 137 138 139 140 141 142 143 144
              } else {
                this.$message.error({ message: res.message, showClose: true })
              }
            })
          }
        })
      }
    }
  }
xiaomiao committed
145 146 147
</script>

<style scoped lang="scss">
xiaomiao committed
148 149 150 151
  .user-info {
    margin: 0.1875rem 1.0417rem;
    overflow-y: auto;
    .form-wrapper {
xiaomiao committed
152
      padding: 0px 120px 0px;
xiaomiao committed
153
      .el-form-item {
154 155
        /deep/.el-form-item__label {
          color: #ffffff;
xiaomiao committed
156 157 158 159 160 161 162
        }
        ::v-deep .el-input .el-input__inner {
          padding: 0 8px;
          height: 40px;
          line-height: 40px;
          border: 1px solid #6bc1fc;
        }
xiaomiao committed
163
      }
xiaomiao committed
164 165 166
      .el-form-item--small.el-form-item {
        margin-bottom: 16px;
      }
xiaomiao committed
167
    }
xiaomiao committed
168
    .bottom-wrapper {
xiaomiao committed
169
      padding: 0px 120px 0px;
170
      text-align: center;
xiaomiao committed
171
    }
xiaomiao committed
172 173
  }
</style>