<template>
  <!--  委托收款函-->
  <!--  <situationDescriptionDialog :visible.sync="fileListShow" :needComplete="true"  :item="item"  :editModel="editModel"> </situationDescriptionDialog>-->
  <!--  import situationDescriptionDialog from '@/components/tracemgr/factoringCommissioner/taskTable/taskManagement/situationDescriptionDialog.vue'-->
  <el-dialog :visible.sync="dialogVisible"    :title="item.name"  :width="'60%'" 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.entrustReceivablesTheme')}}</span></el-row>
      <!--        <el-col :span="12">&nbsp;</el-col>-->
      <el-row class="madding-task-management">
        <!--        <el-col :span="12">&nbsp;</el-col>-->
        <el-col :span="10" class="margin-left">
          <el-form-item  :label="$t('traceMgr.paymentCode')">
            <el-input v-model="form.assetCode" size="mini"  ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10" >
          <el-form-item  class="el-form-item-size"  label-width="16%" :label="$t('traceMgr.preposedProblemOpeningRemarks')">
            <el-input size="mini" v-model="form.authorizedCompanyOne" :placeholder="$t('traceMgr.entrustReceivablesInputLicensingCompanies')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col  :span="12">
          <el-form-item  class="el-form-item-size" label-width="33.5%" :label="$t('traceMgr.entrustReceivablesContext')">
            <el-input size="mini" v-model="form.myCompany" :placeholder="$t('traceMgr.GSMC')" ></el-input>
          </el-form-item>
        </el-col>
        <!--        <el-col  :span="10">-->
        <!--          <label  class="lineHeight"></label>-->
        <!--        </el-col>-->
        <el-col  :span="12">
          <el-form-item class="el-form-item-size" label-width="162px" :label="$t('traceMgr.entrustReceivablesNumber')">
            <el-input size="mini" v-model="form.signingCode" :placeholder="$t('traceMgr.entrustReceivablesInputNumberCode')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row  class="input-size-text-row">
        <el-col  >
          <label  class="lineHeight">{{$t('traceMgr.entrustReceivablesMainBody')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="9">
          <el-form-item class="el-form-item-size" label-width="8%">
            <el-input size="mini" v-model="form.projectCompany" :placeholder="$t('traceMgr.entrustReceivablesCompany')" ></el-input>
          </el-form-item>
        </el-col >
        <el-col :span="12">
          <el-form-item class="el-form-item-size" :label="$t('traceMgr.entrustReceivablesMainBodyOne')" label-width="40%">
            <el-input size="mini" v-model="form.contractNo" :placeholder="$t('traceMgr.entrustReceivablesInputNumber')" ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.entrustReceivablesde')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="8">
          <el-form-item class="el-form-item-size" label-width="9% ">
            <el-input size="mini" v-model="form.agreement" :placeholder="$t('traceMgr.entrustReceivablesBasicContractAgreement')" ></el-input>
          </el-form-item>
        </el-col >
        <el-col :span="8" >
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.entrustReceivablesMainBodyThere')}}</label>
        </el-col>
        <el-col :span="8">
          <el-form-item class="el-form-item-size" label-width="0px">
            <el-input size="mini" v-model="form.invoice" :placeholder="$t('traceMgr.entrustReceivablesInvoice')" ></el-input>
          </el-form-item>
        </el-col >
      </el-row>
      <el-row  class="input-size-text">
        <el-col  :span="24">
          <label   class="lineHeight el-form-item-size">&nbsp;{{$t('traceMgr.entrustReceivablesMainBodyFrou')}} </label>
        </el-col>
      </el-row>
      <el-row >
        <el-col  :span="24">
          <el-col>
            <label  class="lineHeight lable-left-row-margin">&nbsp;{{$t('traceMgr.entrustReceivablesMainBodyFive')}}</label>
          </el-col>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="3">
          <label  class="lineHeight el-form-item-lable-left-row">&nbsp;{{$t('traceMgr.entrustReceivablesHandContext')}}</label>
        </el-col>
        <el-col :span="5">
          <el-form-item class="el-form-item-size" label-width="0px">
            <el-input size="mini" v-model="form.authorizedCompanyTwo" :placeholder="$t('traceMgr.entrustReceivablesInputEnterperise')" ></el-input>
          </el-form-item>
        </el-col >
        <el-col  :span="11.5">
          <label  class="lineHeight" >{{$t('traceMgr.entrustReceivablesMainBodySix')}}</label>
        </el-col>
        <el-col :span="4">
          <el-form-item class="el-form-item-size" label-width="0px">
            <el-input size="mini" v-model="form.authorizedCompanyThere" :placeholder="$t('traceMgr.entrustReceivablesInputEnterperise')" ></el-input>
          </el-form-item>
        </el-col >
      </el-row>
      <el-row class="input-size-text">
        <el-col :span="24">
          <label  class="lineHeight ">{{$t('traceMgr.entrustReceivablesbody')}}</label>
        </el-col>
      </el-row>

      <el-row  >
        <el-col class="textArea-container el-form-item-ml" :span="10">
          <label  class="lineHeight">{{$t('traceMgr.entrustReceivablesInput')}}</label>
        </el-col>
        <el-col class="textArea-container " :span="10">
          <label  class="lineHeight lable-left-max">{{$t('traceMgr.entrustReceivablesInputBei')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col class="input-rigth-auth" :span="8">
          <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: {
        // 授权单位
        authorizedCompanyOne: '',
        // 被授权单位
        authorizedCompanyTwo: '',
        // 第三个被授权公司
        authorizedCompanyThere: '',
        //    付款确认书编号
        assetCode: '',
        // 我公司
        myCompany: '',
        // 签约编号
        signingCode: '',
        //    项目公司名称
        projectCompany: '',
        //    合同编号
        contractNo: '',
        //    协议名称
        agreement: '',
        // 发票号码
        invoice: '',
        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) {
          $this.$nextTick(function () {
            if (this.getFormDataForchange) {
              $this.form.assetCode = $this.item.data
              $this.form.projectCompany = $this.item.assetInfos.assetPaymentInfoDTO.debtor
              $this.form.myCompany = $this.item.assetInfos.assetPaymentInfoDTO.creditor
              $this.form.invoice = $this.item.assetInfos.assetInvoiceInfoDtos[0].invoiceNo
              $this.form.contractNo = $this.item.assetInfos.assetPaymentInfoDTO.bussContractCode
            } else {
              $this.form.authorizedUnitOne = $this.item.assetInfos.authorizedUnitOne
              $this.form.authorizedCompanyOne = $this.item.assetInfos.authorizedCompanyOne
              $this.form.authorizedCompanyTwo = $this.item.assetInfos.authorizedCompanyTwo
              $this.form.authorizedCompanyThere = $this.item.assetInfos.authorizedCompanyThere
              $this.form.assetCode = $this.item.assetInfos.assetCode
              $this.form.myCompany = $this.item.assetInfos.myCompany
              $this.form.signingCode = $this.item.assetInfos.signingCode
              $this.form.projectCompany = $this.item.assetInfos.projectCompany
              $this.form.contractNo = $this.item.assetInfos.contractNo
              $this.form.agreement = $this.item.assetInfos.agreement
              $this.form.invoice = $this.item.assetInfos.invoice
              $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>
