<template>
  <el-tabs v-model="activeName" class="demo-tabs">
    <el-tab-pane label="项目入库详情" name="1">
      <ProjectDetails :isEdit="false" :projectid="projectid" />
    </el-tab-pane>
    <el-tab-pane label="项目资料详情" name="2" 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="3" v-if="fieldChangeDetailList?.length > 0">
      <fieldChangeDetail v-for=" (item, index) in fieldChangeDetailList" :fieldChangeGroupid="item.groupId" :isEdit="false" />
    </el-tab-pane>
  </el-tabs>
  <!-- <ProjectDetails :isEdit="false" :projectid="projectid" />

  <div v-if="stage >= 3&&IsModify==2">
    <el-divider content-position="left">项目资料详情</el-divider>
    <BasicTable @register="registerResourceTable">
      <template #action="{ record }">
        <TableAction :actions="getTableAction(record)" />
      </template>
</BasicTable>
</div> -->
  <ApprovalDetails :projectid="projectid" :stage="showUploadfileDetail ? 'supervisionFile' : 'creatProjectinfo'" v-if="isSubProject==undefined"/>

</template>
<script lang="ts" name="Detailpage" setup>
import { defineProps, ref, onMounted } from 'vue'
import { resourcetableColumns } from './projectInfo.data';
import { uploacFilePageList, getFieldchangeListByprojectid } from './projectInfo.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'
let dataTo = defineProps(["projectid", "stage", "IsModify","showUploadfileDetail","isSubProject"])
let fieldChangeDetailList = ref<Array<Object>>()
console.log("dataTodataTodataTo", dataTo)

onMounted(async () => {
  fieldChangeDetailList.value = await getFieldchangeListByprojectid({ 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>
