<template>
  <ele-modal
    custom-class="ele-dialog-form long-dialog-form"
    :centered="true"
    :visible.sync="detailDialogFlag"
    :title="title"
    :close-on-click-modal="false"
    width="60%"
    :maxable="true"
    :resizable="true"
    @close="cancel"

  >
    <div class="switch_left">
      <ul>
        <li
          v-for="item in tabOptions"
          :key="item.key"
          :class="{ active: activeComp == item.key }"
          @click="activeComp = item.key"
        >
          {{ item.name }}
        </li>
      </ul>
    </div>
    <div v-if="activeComp === 'main'">
      <el-form ref="form" class="el-form-box" :model="form" label-width="100px">
        <headerTitle title="基本信息"></headerTitle>
        <el-row >
          <el-col :span="8">
            <el-form-item
              label="单据类型"
              prop="documentType">
              <dict-selection dict-name="单据类型" v-model="form.documentType" disabled
              ></dict-selection>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="申请部门"
              prop="applyDeptId"
            >
             <el-input v-model="form.applyDeptName" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="申请人"
              prop="applyUserId"
            >
              <el-input v-model="form.applyUserName" disabled></el-input>

            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item
              label="收款名称"
            >
              <el-input v-model="form.collectionName" clearable disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="开户行"
            >
              <el-input v-model="form.bankAccount" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              label="账户"
            >
              <el-input v-model="form.bankName" disabled></el-input>
            </el-form-item>
          </el-col>
          <!--        <el-col :span="8">-->
          <!--          <el-form-item-->
          <!--            label="费用类型"-->
          <!--            prop="feeTypeId"-->
          <!--           -->
          <!--          >-->
          <!--            <ele-tree-select-->
          <!--              clearable-->
          <!--              filterable-->
          <!--              ref="feeTypeTree"-->
          <!--              :data="feeTypeList"-->
          <!--              v-model="form.feeTypeId"-->
          <!--              valueKey="id"-->
          <!--              labelKey="name"-->
          <!--              placeholder="请选择"-->
          <!--              @change="changeFeeTypeInfo"-->
          <!--              default-expand-all-->
          <!--            />-->
          <!--          </el-form-item>-->
          <!--        </el-col>-->
          <!--        <el-col :span="8">-->
          <!--          <el-form-item-->
          <!--            label="金额"-->
          <!--            prop="amount"-->
          <!--           >-->
          <!--            <el-input-number v-model="form.amount" :precision="2" :controls="false" style="width: 100%"-->
          <!--                             :min="0"></el-input-number>-->
          <!--          </el-form-item>-->
          <!--        </el-col>-->
        </el-row>
        <!--        <el-col :span="12">-->
        <!--          <el-form-item-->
        <!--            label="会计科目"-->
        <!--            prop="accountingSubjectId"-->
        <!--           -->
        <!--          >-->
        <!--            <ele-tree-select-->
        <!--              clearable-->
        <!--              filterable-->
        <!--              ref="treeSelect"-->
        <!--              :data="accountingSubjectList"-->
        <!--              v-model="form.accountingSubjectId"-->
        <!--              valueKey="id"-->
        <!--              labelKey="name"-->
        <!--              placeholder="请选择"-->
        <!--              @change="changeSubjectInfo"-->
        <!--              default-expand-all-->
        <!--            />-->
        <!--          </el-form-item>-->
        <!--        </el-col>-->

        <el-row>
          <el-col :span="8">
            <el-row style="display: flex;flex-direction: column">
              <el-col :span="24">
                <el-form-item
                  label="金额"
                >
                  <el-input v-model="form.amount" disabled></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item prop="repliedFiles" label="附件">
                  <fileMain v-model="form.repliedFiles"></fileMain>
<!--                  <el-link-->
<!--                    v-if="form.files.length"-->
<!--                    v-for="item in form.files"-->
<!--                    type="primary"-->
<!--                    :underline="false"-->
<!--                    @click="downloadFile(item)">-->
<!--                    {{ item.name }}-->
<!--                  </el-link>-->
                </el-form-item>
              </el-col>
<!--              <el-col :span="24">-->
<!--                <el-form-item-->
<!--                  label="会计科目：">-->
<!--                  <el-input v-model="form.accountingSubjectName" disabled></el-input>-->

<!--                </el-form-item>-->
<!--              </el-col>-->

            </el-row>
          </el-col>
          <el-col :span="16">
            <el-form-item
              label="备注"
            >
              <el-input :rows="3" v-model="form.remark" type="textarea" disabled></el-input>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>

        </el-row>
      </el-form>
      <headerTitle title="关联信息"></headerTitle>
      <fee-related-info-table ref="feeRelatedInfoTable" :dialogType="dialogType" v-if="form.link.length" :link.sync="form.link"></fee-related-info-table>
    </div>
    <bpmDetail v-if="activeComp === 'bpm' && form.processInstanceId" :id="form.processInstanceId"></bpmDetail>
    <div slot="footer" class="footer">
      <el-button @click="cancel">返回</el-button>
    </div>
  </ele-modal>
</template>

<script>
import {getFile} from '@/api/system/file';
import dictMixins from '@/mixins/dictMixins';
import bpmDetail from '@/views/bpm/processInstance/detail.vue';
import fileUpload from "@/components/upload/fileUpload.vue";
import {getFeeApplyInfoAPI} from "@/api/financialManage/fee-manage/fee-application";
import feeRelatedInfoTable from "@/views/financialManage/components/feeRelatedInfoTable.vue";
import personSelect from "@/components/CommomSelect/person-select.vue";
// import fileMain from "@/components/addDoc/index.vue";


export default {
  mixins: [dictMixins],
  props: ['detailDialogFlag'],
  components: {
    // fileMain,
    personSelect,
    feeRelatedInfoTable,
    fileUpload,
    bpmDetail
  },
  data() {
    return {
      fullscreen:false,
      activeComp: 'main',
      tabOptions: [
        {key: 'main', name: '申请详情'},
        {key: 'bpm', name: '流程详情'}
      ],
      title: '详情',
      dialogType: '',
      form: {},
    };
  },
  methods: {
    //初始化
    async init(row = {}, type) {
      this.title = '详情'
      this.dialogType = type
      await this.getFeeApplyInfoInfo(row.id)
    },
    //获取详情
    async getFeeApplyInfoInfo(id) {
      this.form = await getFeeApplyInfoAPI(id)
      this.form.documentType = this.form.documentType+''
    },
    downloadFile(file) {
      getFile({objectName: file.storePath}, file.name);
    },
    cancel() {
      this.$emit('update:detailDialogFlag', false)
    }
  }
};
</script>

<style scoped lang="scss">
.ele-dialog-form {
  .el-form-item {
    margin-bottom: 10px;
  }
}

.headbox {
  display: flex;
  justify-content: flex-start;
  align-items: center;

  .amount {
    font-size: 14px;
    font-weight: bold;
    margin-right: 20px;
  }
}
</style>
