<template>
  <!--  电子章过期的情况说明-->
  <el-dialog :visible.sync="dialogVisible"    :title="item.name"  :width="'56%'" append-to-body close-on-press-escape :close-on-click-modal="false">
    <el-form :size="'small'"     ref="form" label-width="120px">
      <el-row class="text-center el-dialog__title madding-task-management"  style="padding-top: 20px"> <span  class=""> {{$t('traceMgr.theme')}}</span></el-row>
      <el-row class="madding-task-management">
        <el-col :span="11">
          <el-form-item class="el-form-item-size"  :label="$t('traceMgr.confirmLetterorHandInfo')"  >
            <el-input  size="mini" v-model="form.overduePartyOne" :placeholder="$t('traceMgr.electronicChapterExpiredPartyName')"></el-input>
          </el-form-item>
        </el-col>
        <!--        <el-col :span="1">与</el-col>-->
        <el-col :span="9">
          <el-form-item class="el-form-item-size" label-width="12%" :label="$t('traceMgr.confirmLetterorOr')" >
            <el-input   size="mini" v-model="form.theOtherParty" :placeholder="$t('traceMgr.electronicChapterContractName')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.electronicChapterSignContractContext')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="7">
          <el-form-item class="el-form-item-size" label-width="0px">
            <el-input  size="mini" v-model="form.contractOrPerformanceOne" :placeholder="$t('traceMgr.electronicChapterInputContractAndPerformancedocument')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="9">
          <el-form-item class="el-form-item-size" label-width="27%" :label="$t('traceMgr.electronicChapterContext')">
            <el-input  size="mini" v-model="form.overduePartyTwo" :placeholder="$t('traceMgr.electronicChapterExpiredPartyName')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <label class="lineHeight left">{{$t('traceMgr.electronicChapterBodyContext')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="8">
          <label class="lineHeight">{{$t('traceMgr.electronicChapterBodyExplain')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="15">
          <el-form-item class="el-form-item-size" label-width="63%"  :label="$t('traceMgr.electronicChapterMainBodyContext')"  >
            <el-input  size="mini" v-model="form.nowValidityOfCertificate" :placeholder="$t('traceMgr.electronicChapterInputTermOfValidity')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="9">
          <el-form-item class="el-form-item-size" label-width="36%"  :label="$t('traceMgr.electronicChapterExpiredCertificate')"  >
            <el-input  size="mini" v-model="form.obsoleteValidityOfCertificate"  :placeholder="$t('traceMgr.electronicChapterInputExpiredCertificate')"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="12">
          <label class="lineHeight">{{$t('traceMgr.electronicChapterMainBodyText')}}</label>
        </el-col>
        <el-col :span="6">
          <el-form-item  class="el-form-item-size" label-width="0px"  >
            <el-input disabled v-model="form.time" readonly size="mini" ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <label class="lineHeight">{{$t('traceMgr.electronicChapter')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="24">
          <label class="lineHeight">{{$t('traceMgr.electronicChapterMainText')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item class="el-form-item-size" label-width="52.8%" :label="$t('traceMgr.electronicChapterMainTextOne')"  >
            <el-input  size="mini" v-model="form.contractOrPerformanceTow" :placeholder="$t('traceMgr.electronicChapterContractAndPerformanceDocuments')"></el-input>
          </el-form-item>
        </el-col>
        <!--        <el-col :span="1">与</el-col>-->
        <el-col :span="10">
          <el-form-item class="el-form-item-size" label-width="61%" :label="$t('traceMgr.electronicChapterMainTextTwo')" >
            <el-input   size="mini" v-model="form.contractOrPerformanceThere"  :placeholder="$t('traceMgr.electronicChapterContractAndPerformanceDocuments')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.electronicChapterMainTextThere')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.electronicChapterMainTextFrou')}}</label>
        </el-col>
      </el-row>
      <el-row  >
        <el-col :span="9" class="el-form-item-rg">
          <el-form-item   class="el-form-item-size" :label="$t('traceMgr.electronicChapterInputExpiredParty')">
            <el-input size="mini" v-model="form.overduePartyThere" :placeholder="$t('traceMgr.electronicChapterExpiredPartyName')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col class="el-form-item-rg" :span="9">
          <el-form-item :label="$t('traceMgr.confirmLetterorDate')">
            <el-date-picker
              readonly
              disabled
              type="date"
              v-model="form.date"
              size="mini"
              :placeholder="$t('traceMgr.confirmLetterorDateChoice')">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button   type="button" size="mini"  @click="dialogVisible=false">{{$t('approval.cancel')}}</el-button>
      <el-button type="primary"  size="mini"  @click="submitFormToHomePage">{{$t('common.complete')}}</el-button>
    </div>
  </el-dialog>
</template>
<script>
// import detailView from '@/components/crm/businessMaintainGroup/detailView.vue'
import tracemgrApi from '@/api/tracemgrApi'
import { BaseSelect } from 'newepoch-components'
export default {
  components: {
    BaseSelect
  },
  props: {
    item: {
      type: Object
    },
    processParas: {
      type: Object
    },
    visible: {
      type: Boolean
    },
    title: {
      type: String
    },
    url: {
      type: String
    },
    needComplete: {
      type: Boolean
    },
    resetHomePageDataTable: {
      type: Function },
    gradeId: { type: String },
    getFormDataForchange: {
      type: Boolean
    },
    submitParams: {
      type: Object
    }
  },
  data () {
    return {
      buttonStatus: false,
      gradeIndexsArray: [],
      form: {
        // 第一个过期方名称
        overduePartyOne: '',
        // 第二个过期方名称
        overduePartyTwo: '',
        // 第三个过期方名称
        overduePartyThere: '',
        //    签署合同的另一方
        theOtherParty: '',
        // 第一个合同名称或履约文件
        contractOrPerformanceOne: '',
        // 新证书有效期时间
        nowValidityOfCertificate: '',
        // 旧证书有效期时间
        obsoleteValidityOfCertificate: '',
        // 第二个合同名称或履约文件
        contractOrPerformanceTow: '',
        // 第三个合同名称或履约文件
        contractOrPerformanceThere: '',
        date: ''
        //
      }
    }
  },
  computed: {
    dialogVisible: {
      get: function () {
        this.getComp()
        return this.visible
      },
      set: function (val) {
        this.$emit('update:visible', val)
      }
    },
    getTitle: {
      get: function () {
        return this.title
      },
      set: function (val) {
        this.$emit('update:title', val)
      }
    },
    xhr () {
      return this.$xhr
    }
  },
  watch: {
    visible: {
      handler: function (newValue) {
        let $this = this
        if (newValue) {
          if (this.getFormDataForchange) {

          } else {
            $this.form.overduePartyOne = $this.item.assetInfos.overduePartyOne
            $this.form.overduePartyTwo = $this.item.assetInfos.overduePartyTwo
            $this.form.overduePartyThere = $this.item.assetInfos.overduePartyThere
            $this.form.theOtherParty = $this.item.assetInfos.theOtherParty
            $this.form.contractOrPerformanceOne = $this.item.assetInfos.contractOrPerformanceOne
            $this.form.nowValidityOfCertificate = $this.item.assetInfos.nowValidityOfCertificate
            $this.form.obsoleteValidityOfCertificate = $this.item.assetInfos.obsoleteValidityOfCertificate
            $this.form.contractOrPerformanceTow = $this.item.assetInfos.contractOrPerformanceTow
            $this.form.contractOrPerformanceThere = $this.item.assetInfos.contractOrPerformanceThere
            $this.form.date = $this.item.assetInfos.date
          }
        }
      }
    }
  },
  methods: {
    getComp: function () {
      if (!this.visible) {
      }
    },
    completed: function () {
      // 业务界面完成成功时回调，关闭dialog
      this.dialogVisible = false
      // 刷新列表数据
      this.$parent.handleFilter()
    },
    submitFormToHomePage () {
      let $this = this
      let params = {
        'descriptionContent': JSON.stringify(this.form),
        'taskId': this.submitParams.taskId,
        'assetId': this.submitParams.assetId,
        'descriptionCode': this.submitParams.descriptionCode
      }
      tracemgrApi['descriptionOfGenerationDialog'].saveDescriptionContent(params).then(res => {
        if (res.data) {
          this.success(this.$i18n.messages[this.$i18n.locale].feedBackMain.submitSuccess)
          $this.dialogVisible = false
          $this.resetHomePageDataTable(this.form)
        } else {
          this.error(this.$i18n.messages[this.$i18n.locale].feedBackMain.submitError)
        }
      }, res => {
        this.error(this.$i18n.messages[this.$i18n.locale].feedBackMain.submitError)
      })
    }
  }
}
</script>
<style scoped lang="scss">
  @import '~@/styles/tracemgr/factoringCommissioner/taskManagement/taskManagement.scss';
</style>
