<!--问题详情-->
<template>
  <div class="trackScheduleQustDetailPop">
    <dialog-edit :visible.sync="dialogVisible"
                 :autoSave="false"
                 :editModel="editModel"
                 :form="submitForm"
                 :saveFlag="false"
                 :title="$t('effectDealFeedBackMain.proDetails')"
                 :appendToBody="appendToBody">
        <dym-form :componentList="componentList"
                  :formValue.sync="submitForm">
        </dym-form>
        <el-row :gutter="10">
          <el-col :xs="8" :sm="8" :md="8">
            <el-form-item :label="$t('factoringBusinessInfoQuery.contractName')" labelWidth="130px">
              <el-input v-model="submitForm.basicContractName" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="8" :sm="8" :md="8">
            <el-form-item :label="$t('coordManageMain.isRegister')" labelWidth="130px">
              <el-input v-model="submitForm.sampleFlagDTO.ifsToLoan" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
          <el-col :xs="8" :sm="8" :md="8">
             <el-form-item label="" labelWidth="130px">
              <auth-button size="medium" type="primary" :label="$t('enterpriseInfoManage.supplierInfoManage.contactBasicInfo')" class="iconfont iconjichuxinxi" @click="showPop('2')"></auth-button>
              <auth-button size="medium" type="primary" :label="$t('coordManageMain.dataDownload')" class="iconfont iconxiazai12" @click="showPop('3')"></auth-button>
             </el-form-item>
          </el-col>
          <el-col :xs="16" :sm="16" :md="16">
            <el-form-item :label="$t('coordManageMain.complianceNotes')" labelWidth="130px">
              <el-input v-model="submitForm.chargeUserMemo" type="textarea" :disabled="true"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <template v-for="item in sourceData">
          <track-schedule-qust-detail-form :key="item.qusetionNumber"
                                           :title="$t('coordManageMain.question')+item.qusetionNumber +getTableFormat(item.qusetionStatus)"
                                           :tableData="item.traceListHistoryDtos"
                                           :isFold="item.qusetionStatus==='已通过'"></track-schedule-qust-detail-form>
        </template>
      <effectBatchPop :popTitle="popTitle" v-if="effectBatcVisible" :visible.sync="effectBatcVisible" ref="effectBatchPop"
                      :assetInfoId="assetKeyId"
                      :editModel="newEditModel"
                      :form="updateForm"
                      :keyIdArray="keyIdArray"
                      :effApi="SingleImApi"></effectBatchPop>
    </dialog-edit>
  </div>
</template>
<script>
import * as format from '@/filters/index'
import coordManageApi from '@/api/assetoutfeedback/coordManage/coordManageApi'
import { DialogEdit, searchForm, DataTable, authButton, dymForm, amountInput } from 'newepoch-components'
import trackScheduleQustDetailForm from '@/components/element/assetoutfeedback/trackScheduleQustDetailForm'
import effectBatchPop from '@/pages/assetoutfeedback/effectDealFeedBack/effectBatchPop'
import effectDealFeedBackApi from '@/api/assetoutfeedback/effectDealFeedBack/effectDealFeedBackApi'
import BasePage from '@/pages/baseEditPage'
export default {
  name: 'trackScheduleQustDetailPop',
  extends: new BasePage(),
  components: {
    DialogEdit,
    searchForm,
    DataTable,
    authButton,
    dymForm,
    trackScheduleQustDetailForm,
    amountInput,
    effectBatchPop
  },
  props: {
    editModel: {
      type: [String],
      default () {
        return 'V'
      }
    },
    form: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  data () {
    return {
      appendToBody: true,
      submitForm: {},
      tableList: [],
      popTitle: '',
      effectBatcVisible: false,
      assetKeyId: '',
      keyIdArray: [],
      newEditModel: 'V',
      componentList: [
        {
          // 批次
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.feedbackFrequency,
          disabled: true,
          value: 'feedbackFrequency',
          labelWidth: '130px',
          cols: [8, 8, 8],
          componentName: 'el-input'
        },
        {
          // 序号
          label: this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.No,
          disabled: true,
          prop: 'No',
          value: 'No',
          labelWidth: '130px',
          cols: [8, 8, 8],
          componentName: 'el-input'
        },
        {
          // 付款确认书编号
          label: this.$i18n.messages[this.$i18n.locale].common.payCode,
          disabled: true,
          value: 'assetCode',
          labelWidth: '130px',
          cols: [8, 8, 8],
          componentName: 'el-input'
        },
        {
          // 供应商名称
          label: this.$i18n.messages[this.$i18n.locale].reviewPersonSetupIndex.gysName,
          disabled: true,
          value: 'suppliersName',
          labelWidth: '130px',
          cols: [8, 8, 8],
          componentName: 'el-input'
        },
        {
          // 项目公司名称
          label: this.$i18n.messages[this.$i18n.locale].reviewPersonSetupIndex.xmgsName,
          disabled: true,
          value: 'projectCompanyName',
          labelWidth: '130px',
          cols: [8, 8, 8],
          componentName: 'el-input'
        },
        {
          // 保理金额
          label: this.$i18n.messages[this.$i18n.locale].factoringBusinessInfoQuery.factorAmount,
          disabled: true,
          value: 'factoringMoney',
          labelWidth: '130px',
          cols: [8, 8, 8],
          componentName: 'el-input'
        }
      ],
      sourceData: []
    }
  },
  computed: {
    coordPageApi () {
      return coordManageApi.getTrclistQust
    },
    updateForm () {
      return this.form
    },
    SingleImApi () {
      return effectDealFeedBackApi.getSingleInfo
    }
  },
  mounted () {
    let param = {}
    this.coordPageApi.getDefaultInfo({ 'keyId': this.form.assetKeyId }).then(res => {
      if (res.code === '0' && res.data) {
        Object.assign(param, this.updateForm)
        Object.assign(param, res.data)
        this.submitForm = param
        this.submitForm.factoringMoney = format.thousandFilter(this.submitForm.factoringMoney, 2)
        this.submitForm.sampleFlagDTO.ifsToLoan = this.submitForm.sampleFlagDTO.ifsToLoan === '1' ? '是' : '否'
        this.sourceData = param.traceListHistoryByQuestionNumDtos
      }
    })
  },
  methods: {
    // 表格标题
    getTableFormat (row) {
      if (row && row.toString !== 'undefined') {
        return '- ' + row
      } else {
        return ''
      }
    },
    showPop (type) {
      this.popTitle = this.$i18n.messages[this.$i18n.locale].effectDealFeedBackMain.singleImplement
      this.keyIdArray = [{ 'keyId': this.submitForm.assetKeyId }]
      this.assetKeyId = this.form.assetKeyId
      this.newEditModel = 'I'
      this.effectBatcVisible = true
      this.$nextTick(() => {
        this.$refs.effectBatchPop.tabNumChange(type)
      })
    }
  }
}
</script>
<style lang="scss" scoped>
@import '~@/styles/assetoutfeedback/common.scss'
</style>
