<!-- 用户编辑弹窗 -->
<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.cSid }}
      </el-form-item>
      <el-form-item label="订单号:" prop="title">
        {{ form.sid }}
      </el-form-item>
      <el-form-item label="购车城市:" prop="title">
        {{ form.cityName }}
      </el-form-item>
      <el-form-item label="购车门店:" prop="title">
        {{ form.bizName }}
      </el-form-item>
      <el-form-item label="品牌车型:" prop="title">
        {{ form.brandName }}
      </el-form-item>
      <el-form-item label="入池时间:" prop="title">
        {{ form.cluesCtime }}
      </el-form-item>
      <el-form-item label="派单时间:" prop="title">
        {{ form.pTime }}
      </el-form-item>
      <el-form-item label="开票时间:" prop="title">
        {{ form.billTime }}
      </el-form-item>
      <el-form-item label="提交时间:" prop="title">
        {{ form.cTime }}
      </el-form-item>
      <el-form-item label="未通过原因:" v-if="form.ifcheck === 2">
        {{ form.reason }}
      </el-form-item>
      <el-form-item label="身份证:">
        <template v-if="form.idCardImg.length > 0">
          <div
            style="display: inline; padding: 10px"
            v-for="(item, index) in form.idCardImg"
            :key="index"
          >
            <el-image
              style="width: 200px; height: 200px"
              :src="item.img"
              :preview-src-list="[item.img]"
            >
            </el-image>
          </div>
        </template>
      </el-form-item>
      <el-form-item label="购车合同:">
        <el-image
          v-if="form.contractImg"
          style="width: 200px; height: 200px"
          :src="form.contractImg"
          :preview-src-list="[form.contractImg]"
        >
        </el-image>
      </el-form-item>
      <el-form-item label="发票:">
        <el-image
          style="width: 200px; height: 200px"
          :src="form.billImg"
          :preview-src-list="[form.billImg]"
        >
        </el-image>
      </el-form-item>
      <el-form-item label="商业保险单:">
        <el-image
          v-if="form.businessImg"
          style="width: 200px; height: 200px"
          :src="form.businessImg"
          :preview-src-list="[form.businessImg]"
        >
        </el-image>
      </el-form-item>
    </el-form>
  </ele-modal>
</template>

<script>
  export default {
    components: {},
    props: {
      // 弹窗是否打开
      visible: Boolean,
      // 修改回显的数据
      data: Object
    },
    data() {
      const defaultForm = {
        id: null,
        sid: '',
        name: '',
        mobile: '',
        cSid: '',
        cityName: '',
        bizName: '',
        brandName: '',
        statusCn: '',
        contractImg: '',
        billImg: '',
        businessImg: '',
        cTime: '',
        reason: '',
        ifcheck: 0,
        idCardImg: [],
        pTime: '',
        billTime: '',
        cluesCtime: ''
      };
      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>
