<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="'55%'" 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.theme')}}</span></el-row>
      <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 size="mini"  v-model="form.assetCode"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col  :span="8">
          <el-form-item   label-width="20px" :label="$t('traceMgr.preposedProblemOpeningRemarks')"  >
            <el-input  size="mini" v-model="form.factoring"  :placeholder="$t('traceMgr.GSMC')"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="11">
          <el-form-item   class="el-form-item-size"  :label="$t('traceMgr.confirmLetterorHandInfo')"  >
            <el-input  size="mini"  :placeholder="$t('traceMgr.situationDescriptionEnterpriseAndSupplier')" v-model="form.supplier"></el-input>
          </el-form-item>
        </el-col>
        <!--        <el-col :span="1">与</el-col>-->
        <el-col :span="10">
          <el-form-item  class="el-form-item-size" label-width="17px" :label="$t('traceMgr.confirmLetterorOr')" >
            <el-input  size="mini"  :placeholder="$t('traceMgr.GSMC')" v-model="form.creditor"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="2">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.situationDescription')}}</label>
        </el-col>
      </el-row>
      <el-row >
        <el-col :span="7">
          <el-form-item  class="el-form-item-size"  label-width="0px" >
            <el-input  size="mini"  :placeholder="$t('traceMgr.situationDescriptionNameOfTheContract')" v-model="form.projectCompanyName"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10.5">
          <el-form-item  class="el-form-item-size"  label-width="70px" :label="$t('traceMgr.situationDescriptionTextOne')"  >
            <el-input  size="mini"  :placeholder="$t('traceMgr.situationDescriptionTextTwo')" v-model="form.moneny"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
          <label  class="lineHeight">&nbsp;{{$t('traceMgr.situationDescriptionTextThere')}}</label>
        </el-col>
      </el-row>
      <el-row>
        <label  class="lineHeight">{{$t('traceMgr.situationDescriptionTextFive')}}</label>
      </el-row>
      <el-row class="margin-left-row">
        <base-select></base-select>
      </el-row>
      <el-row class="margin-left-row">
        <el-col :span="23">
          <el-input type="textarea"
                    :rows="5"
                    class="textArea-container"
                    v-model="form.explanationOne"
          >
          </el-input>
        </el-col>
      </el-row>
      <el-row  class="textArea-container">
        <el-col :span="23">
          <el-form-item  :label="$t('traceMgr.situationDescriptionTextSix')"  label-width="17px" >
            <el-input class="input-size-textarea" type="textarea"
                      :rows="2"
                      v-model="form.explanationTwo"
            >
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col> <label  class="lineHeight">{{$t('traceMgr.preposedProblemLableTwo')}}</label></el-col>
      </el-row>
      <el-row  class="textArea-container input-size-textarea">
        <el-col ></el-col>
        <label  class="lineHeight">{{$t('traceMgr.herebyExplain')}}</label>
      </el-row>
      <el-row >
        <el-col class="el-form-item-rg" :span="9">
          <el-form-item   >
            <el-input v-model="form.supplierOrprojectCompany"  size="mini"  :placeholder="$t('traceMgr.enterpriseInputInfo')"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row  >
        <el-col class="el-form-item-rg" :span="9">
          <el-form-item>
            <el-date-picker
              disabled
              readonly
              type="date"
              v-model="form.date"
              size="mini"
              :placeholder="$t('common.chooseDate')">
            </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: {
        // 付款确认书编号
        assetCode: '',
        // 保理商
        factoring: '',
        // 供应商
        supplier: '',
        //    债权人
        creditor: '',
        //    项目公司名称
        projectCompanyName: '',
        //    保理金额
        moneny: '',
        // 第一个多行编辑
        explanationOne: '',
        // 第二个多行编辑
        explanationTwo: '',
        //    供应商或项目公司
        supplierOrprojectCompany: '',
        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.projectCompanyName = $this.item.assetInfos.assetPaymentInfoDTO.debtor
              $this.form.supplier = $this.item.assetInfos.assetPaymentInfoDTO.creditor
              $this.form.moneny = $this.item.assetInfos.assetPaymentInfoDTO.factoringMoney
              $this.form.supplierOrprojectCompany = $this.item.assetInfos.assetPaymentInfoDTO.creditor
            } else {
              $this.form.assetCode = $this.item.assetInfos.assetCode
              $this.form.factoring = $this.item.assetInfos.factoring
              $this.form.supplier = $this.item.assetInfos.supplier
              $this.form.creditor = $this.item.assetInfos.creditor
              $this.form.projectCompanyName = $this.item.assetInfos.projectCompanyName
              $this.form.moneny = $this.item.assetInfos.moneny
              $this.form.explanationOne = $this.item.assetInfos.explanationOne
              $this.form.explanationTwo = $this.item.assetInfos.explanationTwo
              $this.form.supplierOrprojectCompany = $this.item.assetInfos.supplierOrprojectCompany
              $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>
