<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"  style="padding-top: 20px"> <span  class="">{{$t('traceMgr.powerOfAttorney')}}</span></el-row>
      <el-row>
        <!--        <el-col :span="12">&nbsp;</el-col>-->
        <el-col :span="10">
          <el-form-item  label-width="100px" :label="$t('traceMgr.authorizedUnit')">
            <el-input size="mini" v-model="form.authorizedUnitOne" :placeholder="$t('traceMgr.inTheUnitName')" ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row >
        <el-col  :span="10">
          <el-form-item  label-width="100px" :label="$t('traceMgr.toAuthorizedUnit')"  >
            <el-input  size="mini" v-model="form.authorizedUnitTwo" :placeholder="$t('traceMgr.inTheUnitName')"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row  class="input-size-textarea">
        <el-col  >
          <label  class="lineHeight">{{$t('traceMgr.authorizationMatters')}}</label>
        </el-col>
      </el-row>
      <el-row  class="input-size-textarea-rg">
        <el-col  >
          <label  class="lineHeight">{{$t('traceMgr.taskTable_taskManageMent_emd_msg1')}}</label>
        </el-col>
      </el-row>
      <el-row  class="input-size-textarea-rg">
        <el-col  >
          <label  class="lineHeight">{{$t('traceMgr.taskTable_taskManageMent_emd_msg2')}}</label>
        </el-col>
      </el-row>
      <el-row  >
        <el-col class="input-size-textarea-rg" :span="14.5">
          <label  class="lineHeight">{{$t('traceMgr.taskTable_taskManageMent_emd_msg3')}}</label>
        </el-col>
        <el-col  :span="5">
          <el-form-item class="el-form-item-size" label-width="0"  >
            <el-input  size="mini" v-model="form.factoring"  :placeholder="$t('traceMgr.enterFactor')"></el-input>
          </el-form-item>
        </el-col >
        <el-col :span="3"><label  class="lineHeight">{{$t('traceMgr.taskTable_taskManageMent_emd_msg4')}}</label></el-col>
      </el-row>
      <el-row class="input-size-textarea">
        <el-col :span="24">
          <label  class="lineHeight">{{$t('traceMgr.taskTable_taskManageMent_emd_msg5')}}</label>
        </el-col>
      </el-row>
      <el-row  class="input-size-textarea-rg">
        <el-col  >
          <label  class="lineHeight">{{$t('traceMgr.taskTable_taskManageMent_emd_msg6')}}</label>
        </el-col>
      </el-row>
      <el-row  >
        <el-col class="textArea-container el-form-item-lable-left-row" :span="11">
          <el-form-item label-width="53%" :label="$t('traceMgr.authorizedUnit_Stamp')">
          </el-form-item>
        </el-col>
      </el-row>
      <el-row  >
        <el-col class="el-form-item-lable-left-row" :span="11">
          <el-form-item :label="$t('traceMgr.confirmLetterorDate')" label-width="53%">
            <el-date-picker
              disabled
              readonly
              type="date"
              size="mini"
              v-model="form.date"
              :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: {
        // 授权单位
        authorizedUnitOne: '',
        //    被授权单位
        authorizedUnitTwo: '',
        //    保理商
        factoring: '',
        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) {
          if (this.getFormDataForchange) {

          } else {
            $this.form.authorizedUnitOne = $this.item.assetInfos.authorizedUnitOne
            $this.form.authorizedUnitTwo = $this.item.assetInfos.authorizedUnitTwo
            $this.form.factoring = $this.item.assetInfos.factoring
            $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>
