<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.nameOfIssuer" :placeholder="$t('traceMgr.changeClauseSituationDescription')"></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="17%" :label="$t('traceMgr.preposedProblemText')" >
            <el-input   size="mini" v-model="form.nameOfTheOtherParty"  :placeholder="$t('traceMgr.changeClauseInputContractName')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.de')}}</label>
        </el-col>
      </el-row>
      <el-row class="">
        <el-col :span="8">
          <el-form-item class="el-form-item-size" label-width="0px">
            <el-input  size="mini" v-model="form.basicContract"  :placeholder="$t('traceMgr.changeClauseInputBasicsContractName')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="16">
          <el-form-item class="el-form-item-size" label-width="54%" :label="$t('traceMgr.changeClauseBasicsContractText')">
            <el-input  size="mini" v-model="form.basicContractClause" :placeholder="$t('traceMgr.changeClauseInputBasicsContract')"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="24">
          <label class="lineHeight left">{{$t('traceMgr.changeClauseContext')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="24">
          <label  class="lineHeight el-form-item-left3">{{$t('traceMgr.changeClausePromiseExplain')}} </label>
        </el-col>
      </el-row>
      <el-row >
        <el-col class="el-form-item-left4"  :span="24">
          <label   >{{$t('traceMgr.herebyExplain')}}</label>
        </el-col>
      </el-row>
      <el-row  >
        <el-col :span="11" class="el-form-item-lable-left-row">
          <el-form-item label-width="53%"  class="el-form-item-size" :label="$t('traceMgr.confirmLetterorSituation')">
            <el-input size="mini" v-model="form.payeeName" :placeholder="$t('traceMgr.accountProofEnterpriseInputInfo')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col class="el-form-item-lable-left-row" :span="11">
          <el-form-item label-width="53%" :label="$t('traceMgr.confirmLetterorDate')">
            <el-date-picker
              disabled
              readonly
              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: {
        // 出具方名称
        nameOfIssuer: '',
        // 合同另一方名称
        nameOfTheOtherParty: '',
        // 基础合同名称
        basicContract: '',
        // 基础合同条款
        basicContractClause: '',
        // 收款单位名称
        payeeName: '',
        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.nameOfIssuer = $this.item.assetInfos.nameOfIssuer
            $this.form.nameOfTheOtherParty = $this.item.assetInfos.nameOfTheOtherParty
            $this.form.basicContract = $this.item.assetInfos.basicContract
            $this.form.basicContractClause = $this.item.assetInfos.basicContractClause
            $this.form.payeeName = $this.item.assetInfos.payeeName
            $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>
