<template>
  <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="stage>=3&&IsModify==2?2:1"/>

</template>
<script lang="ts" name="Detailpage" setup>
import { defineProps } from 'vue'
import { resourcetableColumns } from './projectInfo.data';
import { uploacFilePageList } from './projectInfo.api'
import { ActionItem, BasicTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { downloadFile } from "../../../api/common/api"
import ProjectDetails from "../../ProcessApprovalSubPage/component/ProjectDetails.vue"
import ApprovalDetails from "../../ProcessApprovalSubPage/component/ApprovalDetails.vue"

let dataTo = defineProps(["projectid","stage","IsModify"])
console.log("dataTo11111",dataTo)
function getTableAction(record): ActionItem[] {
  return [
    {
      label: '下载',
      ifShow: true,
      onClick: handleDetailpage.bind(null, record),
    }
  ];
}


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


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>
