<template>
  <div class="flow">
    <div class="content">
      <div class="left" v-if="customerInfo !== ''">
        <div class="title"><span class="point"></span>客户信息</div>
        <div class="info">
          <div class="item">
            <span class="label">姓名：</span>
            <a-input :value="customerInfo.name" disabled></a-input>
          </div>
          <div class="item">
            <span class="label">性别：</span>
            <a-input :value="customerInfo.sex == 'M' ? '女' : '男'" disabled />
          </div>
          <div class="item">
            <span class="label">婚姻状况</span>
            <a-radio-group v-model="customerInfo.maritalStatus">
              <a-radio value="01">未婚 </a-radio>
              <a-radio value="02">已婚</a-radio>
            </a-radio-group>
          </div>
          <div class="item">
            <span class="label">身份证：</span>
            <a-input :value="customerInfo.idNo" disabled />
          </div>
          <div class="item">
            <span class="label">手机号码：</span>
            <a-input :value="customerInfo.phone" />
          </div>
          <div class="item">
            <span class="label">出生日期：</span>
            <a-input :value="customerInfo.birthDate" disabled />
          </div>
        </div>
        <div class="reset">
          <a-button type="primary" @click="onSubmit">点击修改</a-button>
        </div>
      </div>

      <div class="right">
        <Combos :id="id" v-if="step1" />
        <SelectInstitution :id="id" v-if="step2" />
      </div>
    </div>
    <div class="btn">
      <a-button type="primary" @click="nextStep" v-if="next">下一步</a-button>
       <a-button type="primary" @click="previousStep" v-if="previous">上一步</a-button>
    </div>
  </div>
</template>

<script>
import SelectInstitution from './components/selectInstitution.vue'
import Combos from './components/combo.vue'
import api from '@/api/customer'
export default {
  name: 'componentName',
  components: {
    Combos,
    SelectInstitution,
  },
  props: {},
  data() {
    return {
      next: false,
      previous:false,
      id: '', //客户id
      customerInfo: {
        name: '',
        sex: '',
        idNo: '',
        phone: '',
        birthDate: '',
        maritalStatus: '',
      }, //客户信息
      step1: true,
      step2: false,
    }
  },
  created() {
    const { id } = this.$route.query
    this.id = id
    this.getCustomerDetail() //客户信息

  },
  methods: {
    nextStep() {
      this.previous = true
      this.next = false
      this.step1 = false
      this.step2 = true
    },

    previousStep(){
      this.next = true
      this.previous = false
      this.step1 = true
      this.step2 = false
    },

    // 获取客户信息
    getCustomerDetail() {
      api.getCustomerDetail({ id: parseInt(this.id) }).then((res) => {
        if (res.returnCode == '0000') {
          this.customerInfo = res.content
          console.table('客户信息customerInfo=', this.customerInfo)
        } else {
          this.$message.error(res.returnMsg)
        }
      })
    },
    // "立即修改"
    onSubmit() {
      const query = {
        // ...this.form,
      }
      api.improveInformation(query).then((res) => {
        if (res.returnCode == '0000') {
          // 提交成功之后,提示成功信息,关闭"个人信息填写弹窗",并刷新当前页面
          this.$message.success('修改信息成功')
          // setTimeout(() => {
          //   this.$emit('hideModal')
          //   // 刷新列表
          // }, 1500)
        } else {
          this.$message.error(res.returnMsg)
        }
      })
    },
  },
}
</script>

<style lang="less" scoped>
.flow {
  background: #fafafa;
  min-height: calc(100vh - 300px);
  .btn {
    text-align: center;
    position: relative;
    left: 360px;
    top: -72px;
  }
  .content {
    padding-top: 20px;
    .point {
      display: inline-block;
      border-radius: 5px;
      width: 6px;
      height: 6px;
      background-color: #3f7ffb;
      margin-right: 6px;
      position: relative;
      top: -1px;
    }
    display: flex;
    justify-content: center;
    .left {
      max-height: 480px;
      .reset {
        text-align: center;
        margin-top: 25px;
      }
      .info {
        margin-top: 24px;
        ::v-deep .ant-input {
          border: none;
          background-color: #fafafa;
          height: 42px;
        }
        .item {
          display: flex;
          margin-top: 14px;
          .label {
            display: inline-block;
            width: 120px;
            line-height: 42px;
            font-size: 14px;
            color: #aaaaaa;
            padding-left: 12px;
          }
        }
      }
    }
    .left,
    .right {
      background: white;
      box-shadow: 0px 7px 14px 1px rgba(223, 223, 219, 0.18);
      border-radius: 8px;
      padding: 19px 24px 30px 14px;
      margin-left: 24px;
    }
    .right {
      padding-left: 24px;
    }
    .right {
      margin-left: 30px;
    }
  }
}
</style>
