<!--个人信息-->
<template>
  <div>
    <div v-loading.fullscreen.lock="loadingFull" />

    <div class="card">
      <div class="title">
        <div class="title-left">
          <img
            src="@/assets/image/avator.jpg"
            alt=""
            srcset=""
            class="card-img"
          >
        </div>
        <div class="title-right">
          <div class="user_name">姓名：{{myMessage.true_name}}</div>
          <div
            class="edit1"
            @click="changeMineMessage"
          >编辑</div>

          <img
            class="edit"
            src="@/assets/image/edit.png"
            alt=""
            @click="changeMineMessage"
          />
          <div class="user_no">政治面貌：<span>{{myMessage.politics_status_text}}</span></div>
        </div>
      </div>
      <div class="content">
        <div>学号：{{myMessage.no}}</div>
        <div>班级：{{myMessage.class}}</div>
        <div>身份证号：{{myMessage.id_card}}</div>

        <div>性别：{{myMessage.sex_text}}</div>
        <div>出生日期：{{myMessage.birthday}}</div>
        <div>籍贯（省、县）：{{myMessage.native_place}}</div>
        <div>家庭住址：{{myMessage.address}}</div>
        <div>户口所在地派出所：{{myMessage.local_police_station}}</div>
        <div>入学日期：{{myMessage.enrol_date}}</div>
        <div>手机号：{{myMessage.mobile}}</div>
        <div>邮箱地址：{{myMessage.email}}</div>

      </div>
      <hr class="line">
      <div class="organization">
        <div class="org-title">
          所属支部：{{myMessage.organization.name}}
        </div>

        <div class="child">
          <div>申请入党日期：{{myMessage.join_party_date}}</div>
          <div>确定为积极分子日期：{{myMessage.join_activist_date}}</div>
          <div>列为积极分子日期：{{myMessage.join_activist_date}}</div>
          <div>确定为预备党员日期：{{myMessage.join_group_date}}</div>
          <div>党课结业日期：{{myMessage.complete_party_date}}</div>
        </div>
      </div>

    </div>

    <!--修改-->
    <el-dialog
      title="修改信息"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
      center
    >
      <el-form
        class="mobile-form"
        label-width="100px"
      >
        <el-form-item label="电话号码：">
          <el-input v-model="mobile"></el-input>
        </el-form-item>

      </el-form>
      <span
        slot="footer"
        class="dialog-footer"
      >
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button
          type="primary"
          @click="editMobile"
        >确 定</el-button>
      </span>
    </el-dialog>

  </div>
</template>
<script>
import { message } from "@/api/users/index";
import { editPersonnel } from "@/api/personnel/index";
export default {
  data() {
    return {
      myMessage: {
        no:''
      },
      loadingFull: false,
      formInline: {
        user: "",
        region: ""
      },
      dialogVisible: false,
      mobile: ""
    };
  },
  created() {
    this.message();
  },
  methods: {
    async message() {
      this.loadingFull = true;
      await message()
        .then(res => {
          console.log(res, "当前登录个人信息");
          this.myMessage = res.data;
          this.loadingFull = false;
        })
        .catch(err => {
          this.loadingFull = false;
        });
    },
    //完善个人信息
    changeMineMessage() {
      this.$router.push({
        name: "changemessage",
        query: { id: this.myMessage.id }
      });
    },
    async editMobile() {
      const data = {
        mobile: this.mobile,
        id: this.myMessage.id
      };
      await editPersonnel(data)
        .then(res => {
          this.$message.success("修改成功");
          this.dialogVisible = false;
          this.message();
        })
        .catch(err => {
          this.$message.error("修改失败");
        });
    }
  }
};
</script>
<style lang="scss" scoped>
.mobile-form {
  width: 70%;
  margin: 0 auto;
}
.card {
  margin: 50px;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 4px 4px 40px rgb(0 0 0 / 15%);
  .title {
    display: flex;
    .title-left {
      flex: 0 0 100px;
      height: 100px;
      overflow: hidden;
      border-radius: 50%;
      img {
        height: 100px;
        width: 100px;
      }
    }
    .title-right {
      flex: 1;
      margin-left: 30px;
      .user_name {
        margin-top: 10px;
        line-height: 50px;
        font-size: 18px;
        display: inline-block;
      }
      .user_no {
        font-size: 18px;
        span {
          color: #fe1a1a;
          font-weight: bold;
          font-size: 18px;
        }
      }
      .edit {
        display: inline-block;
        margin-left: 10px;
        height: 20px;
      }
      .edit1 {
        display: inline-block;
        margin-left: 20px;
        line-height: 20px;
        color: cornflowerblue;
        font-size: 14px;
        margin-left: 20px;
      }
    }
  }
  .content {
    margin-top: 30px;
    margin-left: 130px;
    div {
      height: 40px;
      width: 50%;
      line-height: 40px;
      display: inline-block;
    }
  }
  .line {
    margin: 50px 0;
  }
  .organization {
    margin-left: 130px;
    margin-bottom: 30px;
    .org-title {
      height: 50px;
      font-size: 20px;
      color: rgb(102, 101, 101);
      font-weight: bold;
    }

    .child {
      div {
        display: inline-block;
        width: 30%;
        height: 40px;
        line-height: 40px;
      }
    }
  }
}
.bt {
  margin: 0 auto;
  text-align: center;
}
</style>