<template>
  <div style="height:500px;overflow-y:auto;">
    <el-form :model="modalForm" ref="modalForm" label-width="110px" disabled>
      <el-row>
        <el-col :span="12">
          <el-form-item label="学员联系方式" prop="phone">
            <el-input v-model="modalForm.phone" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="学员姓名" prop="name">
            <el-input v-model="modalForm.name" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="线索来源" prop="source">
            <el-select v-model="modalForm.source" placeholder="请选择" size="small" disabled>
              <el-option v-for="dict in sourceOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="是否全款" prop="state">
            <el-radio-group v-model="modalForm.state" disabled>
              <el-radio :label="true">全款</el-radio>
              <el-radio :label="false">非全款</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="成交日期" prop="dealDate">
            <el-date-picker v-model="modalForm.dealDate" size="small" disabled value-format="yyyy-MM-dd" format="yyyy-MM-dd" type="date"></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="报名价格(元)" prop="signPrice">
            <el-input v-model="modalForm.signPrice" placeholder="学员报名时需要交纳总共的钱" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="报名驾校" prop="signSchool">
            <el-select v-model="modalForm.signSchool" filterable placeholder="请选择" clearable size="small" disabled>
              <el-option v-for="dict in schoolOptions" :key="dict.schoolId" :label="dict.schoolName" :value="dict.schoolId" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="报名场地" prop="signPlace">
            <el-select v-model="modalForm.signPlace" filterable placeholder="请选择" clearable size="small" disabled>
              <el-option v-for="dict in placeOptions" :key="dict.placeId" :label="dict.name" :value="dict.placeId" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="报名班型" prop="signClass">
            <el-select v-model="modalForm.signClass" filterable placeholder="请选择" clearable size="small" disabled>
              <el-option v-for="dict in classTypeOptions" :key="dict.typeId" :label="dict.typeName" :value="dict.typeId" />
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="对接人" prop="schoolPeople">
            <el-input v-model="modalForm.schoolPeople" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="驾校支付" prop="schoolPay">
            <el-input type="number" v-model="modalForm.schoolPay" placeholder="请输入驾校支付金额" disabled></el-input>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="驾考宝典款" prop="alipay">
            <el-input v-model="modalForm.alipay" placeholder="请输入驾考宝典款金额" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="额外支出" prop="extraPayType">
            <el-select v-model="modalForm.extraPayType" filterable placeholder="请选择" clearable size="small" disabled>
              <el-option v-for="dict in extraPayTypeOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item label="额外支出金额" prop="extraPay">
            <el-input placeholder="请输入额外支出金额" v-model="modalForm.extraPay" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="归属人员" prop="followUser">
            <el-select v-model="modalForm.followUser" multiple placeholder="请选择" clearable size="small" disabled>
              <el-option v-for="dict in userOptions" :key="dict.id" :label="dict.name" :value="dict.id" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属区域" prop="area">
            <el-select v-model="modalForm.area" placeholder="请选择" clearable size="small" disabled>
              <el-option v-for="dict in areaOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
            </el-select>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="12">
                <el-form-item label="线下接待人员" prop="offlineReceiver">
                  <el-select v-model="modalForm.offlineReceiver" multiple placeholder="请选择" clearable size="small" :disabled="!modalForm.signEdit || modalForm.clueId != undefined">
                    <el-option v-for="dict in userOptions" :key="dict.id" :label="dict.name" :value="dict.id" />
                  </el-select>
                </el-form-item>
              </el-col>-->
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="佣金明细" prop="commission">
            <el-select v-model="modalForm.commission" placeholder="请选择" clearable size="small" disabled>
              <el-option v-for="dict in commissionOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="备注" prop="memo">
            <el-input type="textarea" :rows="2" v-model="modalForm.memo" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="凭据" prop="memo">
            <div class="demo-image__preview">
              <div v-for="(item, index) in modalForm.fileList" :key="index" class="demo-image__item">
                <el-image class="image-list-item" fit="contain" :src="item.url" :preview-src-list="modalForm.fileList.map(file => file.url)" lazy />
              </div>
            </div>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="修改记录">
            <el-timeline style="max-height:260px;overflow-y:auto;">
              <el-timeline-item v-for="info in updateRecord" :key="info.record" :timestamp="info.operateTime" placement="top" style="padding:5px !important;">
                <el-card>
                  <span style="display:block;font-weight: bold; font-size:13px;">用户 {{info.operateUserName}}</span>
                  <span v-html="info.centent" style="display:block;padding-left: 10px; font-size:13px;" />
                </el-card>
              </el-timeline-item>
            </el-timeline>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import empApi from '@/api/system/employee'
import schoolAPi from '@/api/sch/school'
import { getAllPlaces } from '@/api/sch/place'
import { getAllList } from '@/api/sch/classType'
import { getCheckRecord } from '@/api/zs/sign'

export default {
  props: {
    modalForm: {
      type: Object,
      default: () => ({})
    },
  },
  data() {
    return {
      userOptions: [],
      clueOptions: [],
      schoolOptions: [],
      placeOptions: [],
      classTypeOptions: [],
      sourceOptions: [],
      commissionOptions: [],
      extraPayTypeOptions: [],
      areaOptions: [],
      moneyStateOptions: [],
      updateRecord: [],
    }
  },
  created() {
    this.initData()
  },
  methods: {
    initData() {
      //线索来源
      this.getDicts('dm_source').then((response) => {
        this.sourceOptions = response.data
      })
      //佣金明细
      this.getDicts('dm_commission').then((response) => {
        this.commissionOptions = response.data
      })
      //额外支出类型
      this.getDicts('dm_extra_pay').then((response) => {
        this.extraPayTypeOptions = response.data
      })
      //s所属区域
      this.getDicts('dm_area').then((response) => {
        this.areaOptions = response.data
      })

      this.getSchools()
      this.getPlaces()
      this.getClassTypes()
      this.getEmployee()
      this.getUpdateRecord(this.modalForm.signId)
    },
    //查询驾校
    getSchools() {
      schoolAPi.allList().then((resp) => {
        this.schoolOptions = resp.data
      })
    },
    //查询场地
    getPlaces() {
      getAllPlaces({ schoolId: this.modalForm.signSchool, status: '0' }).then(
        (resp) => {
          this.placeOptions = resp.data
        }
      )
    },
    //查询班型
    getClassTypes() {
      getAllList({
        schoolId: this.modalForm.signSchool,
        placeId: this.modalForm.signPlace,
        status: '0',
      }).then((resp) => {
        this.classTypeOptions = resp.data
      })
    },
    //查询员工
    getEmployee() {
      empApi.getEmployee().then((resp) => {
        if (resp.code == 200) {
          this.userOptions = resp.data
        }
      })
    },
    getUpdateRecord(signId) {
      getCheckRecord({ signId: signId, type: 0 }).then((resp) => {
        this.updateRecord = resp.data
      })
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },

  },
}
</script>
<style scoped>
.demo-image__item {
  width: 100px;
  height: 100px;
  display: inline-block;
  margin: 5px;
}
.image-list-item {
  width: 100%;
  height: 100%;
}
</style>