<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="1">与</el-col>-->
        <el-col :span="20">
          <el-form-item class="el-form-item-size" label-width="45.5%" :label="$t('traceMgr.jianYuEnterpriseName')+$t('traceMgr.confirmLetterorOr')" >
            <el-input  v-model="dataJson.enterpriseB" size="mini"  placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.confirmLetterorOrIn')}}</label>
        </el-col>
      </el-row>
      <el-row class="">
        <el-col :span="7">
          <el-form-item class="el-form-item-size" label-width="0px">
            <el-input v-model="dataJson.signDate" size="mini"  placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item class="el-form-item-size" label-width="22.5%" :label="$t('traceMgr.confirmLetterorText')">
            <el-input  size="mini" v-model="dataJson.agreementName"  placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <label class="lineHeight left">{{$t('traceMgr.confirmLetterorOrText')}}</label>
        </el-col>
      </el-row>
      <el-row >

        <el-col :span="12">
          <el-form-item class="el-form-item-size"  :label="$t('traceMgr.confirmLetterorTimeOut')" label-width="21%">
            <el-input v-model="dataJson.termOfValidity" size="mini"  placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <label class="lineHeight">。</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="7">
          <el-form-item class="el-form-item-size" label-width="0px">
            <el-input v-model="dataJson.purchaser"  size="mini"  placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item class="el-form-item-size" label-width="62%" :label="$t('traceMgr.confirmLetterorName')">
            <el-input  size="mini" v-model="dataJson.supplier"  placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <label class="lineHeight left">{{$t('traceMgr.confirmLetterorS')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col  :span="24">
          <label class="lineHeight">{{$t('traceMgr.confirmLetterorOrTexttwo')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <label  class="lineHeight lable-left-max">&nbsp;{{$t('traceMgr.confirmLetterorOrTextThere')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <label  class="lineHeight lable-left-max">&nbsp;{{$t('traceMgr.confirmLetterorOrTextFour')}}</label>
        </el-col>
      </el-row>

      <el-row>
        <el-col>
          <label  class="lineHeight lable-left-max">&nbsp;{{$t('traceMgr.confirmLetterorOrTextfive')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="7">
          <el-form-item class="el-form-item-size"  label-width="0px">
            <el-input v-model="dataJson.name"  size="mini"  placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item class="el-form-item-size" :label="$t('traceMgr.confirmLetterorNamble')" label-width="30%">
            <el-input  size="mini" v-model="dataJson.order"  placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.confirmLetterorTextSix')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.confirmLetterorTextSeven')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <label  class="lineHeight lable-left-max">&nbsp;{{$t('traceMgr.confirmLetterorTextEight')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item class="el-form-item-size"  label-width="0px">
            <el-input  size="mini" v-model="dataJson.orderagreementName" placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12.5">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.confirmLetterorTextNine')}}</label>
        </el-col>
        <el-col :span="6.5">
          <el-form-item class="el-form-item-size"  label-width="10px">
            <el-input v-model="dataJson.orderagreement"  size="mini"   placeholder=""></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.confirmLetterorTextTen')}}</label>
        </el-col>
      </el-row>
      <el-row class="left">
        <el-col :span="24">
          <label  class="lineHeight el-form-item-left3">{{$t('traceMgr.confirmLetterorTextEleven')}}</label>
        </el-col>
      </el-row>
      <el-row class="left">
        <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 v-model="dataJson.officialSeal" size="mini" placeholder="" ></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"
              size="mini"
              v-model="dataJson.date"
              :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 {
      dataJson: {
        //  企业A
        enterpriseA: '',
        //  企业B
        enterpriseB: '',
        // 签订时间
        signDate: '',
        //  协议名称
        agreementName: '',
        //  有效期
        termOfValidity: '',
        // 采集商
        purchaser: '',
        // 供应商
        supplier: '',
        name: '',
        //  订单
        order: '',
        //  订单协议
        orderagreementName: '',
        orderagreement: '',
        // 日期
        date: '',
        //  出具方 公章
        officialSeal: ''
      },
      buttonStatus: false,
      gradeIndexsArray: []
    }
  },
  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.dataJson.enterpriseA = $this.item.assetInfos.enterpriseA
            $this.dataJson.enterpriseB = $this.item.assetInfos.enterpriseB
            $this.dataJson.signDate = $this.item.assetInfos.signDate
            $this.dataJson.agreementName = $this.item.assetInfos.agreementName
            $this.dataJson.termOfValidity = $this.item.assetInfos.termOfValidity
            $this.dataJson.purchaser = $this.item.assetInfos.purchaser
            $this.dataJson.supplier = $this.item.assetInfos.supplier
            $this.dataJson.name = $this.item.assetInfos.name
            $this.dataJson.order = $this.item.assetInfos.order
            $this.dataJson.orderagreementName = $this.item.assetInfos.orderagreementName
            $this.dataJson.orderagreement = $this.item.assetInfos.orderagreement
            $this.dataJson.date = $this.item.assetInfos.date
            $this.dataJson.officialSeal = $this.item.assetInfos.officialSeal
          }
        }
      }
    }
  },
  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>
