<!-- 用户编辑弹窗 -->
<template>
  <ele-modal
    width="800px"
    :visible="visible"
    :append-to-body="true"
    :close-on-click-modal="true"
    custom-class="ele-dialog-form"
    title="详情"
    @update:visible="updateVisible"
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item label="姓名:" prop="title">
        {{ form.name }}
      </el-form-item>
      <el-form-item label="手机号:" prop="title">
        {{ form.mobile }}
      </el-form-item>
      <el-form-item label="身份证号:" prop="title">
        {{ form.cardId }}
      </el-form-item>
      <el-form-item label="身份证照片:" prop="title">
        <el-image
          style="width: 200px; height: 200px"
          :src="form.cardida"
          :preview-src-list="[form.cardida]"
        />
        <el-image
          style="width: 200px; height: 200px; margin-left: 20px"
          :src="form.cardidb"
          :preview-src-list="[form.cardidb]"
        />
      </el-form-item>
      <el-form-item label="银行卡号:" prop="title">
        {{ form.bankCardNum }}
      </el-form-item>
      <el-form-item label="开户行名称:" prop="title">
        {{ form.bankName }}
      </el-form-item>
      <el-form-item label="银行卡照片:">
        <el-image
          style="width: 200px; height: 200px"
          :src="form.bankImg"
          :preview-src-list="[form.bankImg]"
        />
      </el-form-item>
    </el-form>
  </ele-modal>
</template>

<script>
  export default {
    components: {},
    props: {
      // 弹窗是否打开
      visible: Boolean,
      // 修改回显的数据
      data: Object
    },
    data() {
      const defaultForm = {
        id: null,
        name: '',
        mobile: '',
        cardId: '',
        cardida: '',
        cardidb: '',
        bankCardNum: '',
        bankName: '',
        bankImg: ''
      };
      return {
        editVersion: false,
        defaultForm,
        // 表单数据
        form: { ...defaultForm },
        // 表单验证规则
        rules: {},
        // 提交状态
        loading: false,
        // 是否是修改
        isUpdate: false
      };
    },
    computed: {
      // 是否开启响应式布局
      styleResponsive() {
        return this.$store.state.theme.styleResponsive;
      }
    },
    created() {},
    methods: {
      handleCarChange(carInfo) {
        this.form.selectedCar = carInfo;
      },
      /* 更新visible */
      updateVisible(value) {
        this.$emit('update:visible', value);
      },
      /* 添加海报描述 */
      addShareTitle() {
        this.form.promotion_text.push('');
      }
    },
    watch: {
      visible(visible) {
        this.editVersion = false;
        if (visible) {
          this.editVersion = true;
          if (this.data) {
            this.$util.assignObject(this.form, {
              ...this.data
            });
            this.isUpdate = true;
          } else {
            this.form.imgs = [];
            this.isUpdate = false;
          }
        } else {
          this.$refs.form.clearValidate();
          this.form = { ...this.defaultForm };
        }
      }
    }
  };
</script>
<style lang="scss" scoped>
  .ele-image-upload-list .ele-image-upload-item {
    margin-top: 2px;
    margin-bottom: 2px;
  }
</style>
