<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"> <span  class="">{{$t('traceMgr.authorizedSupervisionAndAcceptanceTheme')}}</span></el-row>

      <el-row class="madding-task-management">
        <el-col :span="8">
          <el-form-item label-width="35%" class="el-form-item-size"  :label="$t('traceMgr.authorizedSupervisionAndAcceptancehandle')"  >
            <el-input  size="mini" v-model="form.projectCompanyOne" :placeholder="$t('traceMgr.authorizedSupervisionAndAcceptanceInputEnterpriseInfo')"></el-input>
          </el-form-item>
        </el-col>
        <!--        <el-col :span="1">与</el-col>-->
        <el-col :span="12">
          <el-form-item class="el-form-item-size" label-width="40%"  :label="$t('traceMgr.authorizedSupervisionAndAcceptanceEnterpriseandSupplier')" >
            <el-input   size="mini" v-model="form.supplierName" :placeholder="$t('traceMgr.authorizedSupervisionAndAcceptanceInputSupplierName')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.authorizedSupervisionAndAcceptanceEnterpriseandSupplierDetali')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="8">
          <el-form-item class="el-form-item-size" :label="$t('traceMgr.authorizedSupervisionAndAcceptanceText')" label-width="34.8%" >
            <el-input  size="mini" v-model="form.contractName"  :placeholder="$t('traceMgr.authorizedSupervisionAndAcceptanceInputContract')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item  class="el-form-item-size" label-width="41%" :label="$t('traceMgr.authorizedSupervisionAndAcceptanceContext')"  >
            <el-input  size="mini" v-model="form.authorizedCompany" :placeholder="$t('traceMgr.authorizedSupervisionAndAcceptanceInputContextLable')"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="5">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.authorizedSupervisionAndAcceptanceInputContextInfo')}}</label>
        </el-col>
      </el-row>
      <el-row  class="left">
        <el-col :span="24">
          <label  class="lineHeight el-form-item-size">{{$t('traceMgr.authorizedSupervisionAndAcceptanceMainBody')}}</label>
        </el-col>
      </el-row>
      <el-row class="left-row">
        <el-col>
          <label  class="lineHeight el-form-item-left3">{{$t('traceMgr.authorizedSupervisionAndAcceptancePromise')}}</label>
        </el-col>
      </el-row>
      <el-row class="left-row">
        <el-col :span="24">
          <label  class="lineHeight el-form-item-left3">{{$t('traceMgr.authorizedSupervisionAndAcceptance')}}</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="8" class="el-form-item-rg">
          <el-form-item   class="el-form-item-size" :label="$t('traceMgr.projectCompanyName')">
            <el-input  size="mini" v-model="form.projectCompanyTwo" :placeholder="$t('paymentConfirmationManage.inputprojectCompName')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col class="el-form-item-rg" :span="8">
          <el-form-item :label="$t('traceMgr.confirmLetterorDate')">
            <el-date-picker
              readonly
              disabled
              v-model="form.date"
              type="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 tracemgrApi from '@/api/tracemgrApi'
// import detailView from '@/components/crm/businessMaintainGroup/detailView.vue'
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 {
      form: {
        // 项目公司
        projectCompanyOne: '',
        // 供应商名称
        supplierName: '',
        // 合同名称
        contractName: '',
        // 被授权公司
        authorizedCompany: '',
        // 第二个项目公司
        projectCompanyTow: '',
        date: ''
      },
      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) {
          $this.$nextTick(function () {
            if (this.getFormDataForchange) {
              $this.form.contractName = $this.item.assetInfos.assetPaymentInfoDTO.bussContractName
              $this.form.supplierName = $this.item.assetInfos.assetPaymentInfoDTO.creditor
              $this.form.projectCompanyTow = $this.item.assetInfos.assetPaymentInfoDTO.debtor
              $this.form.projectCompanyOne = $this.item.assetInfos.assetPaymentInfoDTO.debtor
            } else {
              $this.form.projectCompanyOne = $this.item.assetInfos.projectCompanyOne
              $this.form.supplierName = $this.item.assetInfos.supplierName
              $this.form.contractName = $this.item.assetInfos.contractName
              $this.form.authorizedCompany = $this.item.assetInfos.authorizedCompany
              $this.form.projectCompanyTow = $this.item.assetInfos.projectCompanyTow
              $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>
