<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="'50%'" 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.accountProoftheme')}}</span></el-row>

      <el-row class="madding-task-management">
        <el-col :span="8" >
          <el-form-item   class="el-form-item-size" label-width="26%" :label="$t('traceMgr.preposedProblemOpeningRemarks')">
            <el-input size="mini" v-model="form.factor" :placeholder="$t('traceMgr.GSMC')" ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <label class="lineHeight"></label>
        </el-col>
      </el-row>
      <el-row class="madding-task-management">
        <el-col :span="24">
          <label  class="lineHeight lable-left ">{{$t('traceMgr.accountProofOne')}}</label>
        </el-col>
      </el-row>
      <el-row class="input-left">
        <el-col :span="14" >
          <el-form-item   class="el-form-item-size lable-left"  :label="$t('traceMgr.accountProofCompanyName')">
            <el-input size="mini" v-model="form.companyName" :placeholder="$t('traceMgr.accountProofCompanyLable')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row class="input-left">
        <el-col :span="14" >
          <el-form-item   class="el-form-item-size lable-left"  :label="$t('traceMgr.accountProofBankLable')">
            <el-input size="mini" v-model="form.bank" :placeholder="$t('traceMgr.accountProofBank')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row class="input-left">
        <el-col :span="14" >
          <el-form-item   class="el-form-item-size lable-left"  :label="$t('traceMgr.accountProofUsername')">
            <el-input size="mini" v-model="form.username" :placeholder="$t('traceMgr.accountProofInputUsername')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row class="madding-task-management">
        <el-col :span="24">
          <label  class="lineHeight lable-left ">{{$t('traceMgr.accountProofTwo')}}</label>
        </el-col>
      </el-row>
      <el-row  >
        <el-col :span="10" class="el-form-item-rowCen">
          <el-form-item  label-width="43%" class="el-form-item-size" :label="$t('traceMgr.accountProofEnterpriseName')">
            <el-input size="mini" v-model="form.receivablesCompanyName" :placeholder="$t('traceMgr.accountProofEnterpriseInputInfo')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col  class="el-form-item-rowCen" :span="10">
          <el-form-item label-width="43%" :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 { BaseSelect } from 'newepoch-components'
import tracemgrApi from '@/api/tracemgrApi'
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: {
        // 保理商
        factor: '',
        // 单位名称
        companyName: '',
        // 开户银行
        bank: '',
        // 账户
        username: '',
        // 收款单位
        receivablesCompanyName: '',
        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.bank = $this.item.assetInfos.assetPaymentPoolOperDTO.receiverBank
              $this.form.username = $this.item.assetInfos.assetPaymentPoolOperDTO.receiverBankAccount
              $this.form.companyName = $this.item.assetInfos.assetPaymentInfoDTO.debtor
            } else {
              $this.form.factor = $this.item.assetInfos.factor
              $this.form.companyName = $this.item.assetInfos.companyName
              $this.form.bank = $this.item.assetInfos.bank
              $this.form.username = $this.item.assetInfos.username
              $this.form.receivablesCompanyName = $this.item.assetInfos.receivablesCompanyName
              $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>
