<template>
  <el-tabs v-model="activeName" class="demo-tabs">
    <el-tab-pane label="项目申报详情" name="1">
      <ProjectDetails :isEdit="false" :projectid="projectid" />
      <el-divider content-position="left">资金承诺函</el-divider>
      <UploadfileDetail :projectid="projectid" :stage="5" />
      <ApprovalDetails :projectid="projectid" :stage="'creatProjectinfo'" v-if="showApprovalDetails==true"/>

    </el-tab-pane>
    <el-tab-pane label="项目资金详情" name="2" >
      <projectMoneyDetail :projectid="projectid" />
    </el-tab-pane>
    <el-tab-pane label="项目资料详情" name="3" v-if="showUploadfileDetail">
      <el-divider content-position="left">项目资料详情</el-divider>
      <UploadfileDetail :projectid="projectid" :stage="1" />
      <el-divider content-position="left">意见文件</el-divider>
      <UploadfileDetail :projectid="projectid" :stage="2" />
    </el-tab-pane>
    <el-tab-pane label="项目变更信息详情" name="4" v-if="fieldChangeDetailList?.length > 0">
      <fieldChangeDetail v-for=" (item, index) in fieldChangeDetailList" :fieldChangeGroupid="item.groupId" :isEdit="false" />
    </el-tab-pane>
    <el-tab-pane label="由以下项目合并" name="5" v-if="mergeDetailList?.length > 0">
      <ProjectTable :row="mergeDetailList"/>
    </el-tab-pane>
    <el-tab-pane label="由以下项目拆分" name="6" v-if="splitDetailList?.length > 0">
      <ProjectTable :row="splitDetailList"/>
    </el-tab-pane>
    <el-tab-pane label="项目计划详情" name="7" v-if="showtuList?.length > 0">
      <showtu  :res="showtuList"  />
    </el-tab-pane>

  </el-tabs>

</template>
<script lang="ts" name="Detailpage" setup>
import { defineProps, ref, onMounted } from 'vue'
import { resourcetableColumns } from './projectInfo.data';
import { uploacFilePageList, getFieldchangeListByprojectid,getMergeDetailList,getSplitDetailList } from './projectInfo.api'

import { queryPlanInfoMainTimeline } from '@/views/projectLib/projectPlan/projectPlan.api'
import { ActionItem, BasicTable, TableAction, useTable } from '@/components/Table';
import { downloadFile } from "@/api/common/api"
import ProjectDetails from "../../ProcessApprovalSubPage/component/ProjectDetails.vue"
import ApprovalDetails from "../../ProcessApprovalSubPage/component/ApprovalDetails.vue"
import UploadfileDetail from '../../ProcessApprovalSubPage/component/UploadfileDetail.vue'
import fieldChangeDetail from '../../ProcessApprovalSubPage/component/fieldChangeDetail.vue'
import ProjectTable from "@/views/ProcessApprovalSubPage/component/ProjectTable.vue"
import projectMoneyDetail from "@/views/projectLib/projectInfo/projectMoneyDetail.vue"
import showtu from "@/views/projectLib/projectPlan/showtu.vue"
let dataTo = defineProps(["projectid", "stage", "IsModify","showUploadfileDetail","showApprovalDetails"])
let fieldChangeDetailList = ref<Array<Object>>()
let mergeDetailList = ref<Array<Object>>()
let splitDetailList = ref<Array<Object>>()
let showtuList = ref<Array<Object>>()
console.log("dataTodataTodataTo", dataTo)

onMounted(async () => {
  fieldChangeDetailList.value = await getFieldchangeListByprojectid({ projectid: dataTo.projectid })
  mergeDetailList.value=await getMergeDetailList({ projectid: dataTo.projectid })
  splitDetailList.value=await getSplitDetailList({ projectid: dataTo.projectid })
  showtuList.value =await queryPlanInfoMainTimeline({ projectid: dataTo.projectid })
})
let activeName = ref("1")
function getTableAction(record): ActionItem[] {
  return [
    {
      label: '下载',
      ifShow: true,
      onClick: handleDetailpage.bind(null, record),
    }
  ];
}


//项目资料table
const [registerResourceTable] = useTable({
  size: 'small',//紧凑型表格
  title: '项目申报资料详情',
  api: uploacFilePageList,
  columns: resourcetableColumns,
  useSearchForm: false,
  actionColumn: {
    width: 120,
    fixed: "right",
  },
  beforeFetch(params) {
    params.stage = "1",
      params.projectid = dataTo.projectid
  },
  afterFetch(data) {
  }
});


function handleDetailpage(record) {
  console.log("我这一行的数据是", record)
  let param = {
    path: record.documentPath,
    fileName: record.documentName
  }
  //
  console.log("我这一行的数据是", param)

  downloadFile("/huzhouUploadfileinfo/downloadfile", record.documentName, param)
}
</script>
<style></style>
