<template>
  <div class="p-0">

    <BasicTable @register="registerTable" > 
    <!--操作栏-->
    <template #action="{ record }">
      <TableAction :actions="getTableAction(record)" />
    </template>
  </BasicTable>
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { BasicTable, useTable, TableAction, BasicColumn, ActionItem, EditRecordRow } from '/@/components/Table';

import { useTabs } from '/@/hooks/web/useTabs';


import { useListPage } from '/@/hooks/system/useListPage';
import { useUserStoreWithOut } from '/@/store/modules/user';
import { useRouter } from 'vue-router';
const router = useRouter();
const user = useUserStoreWithOut();
const { closeCurrent, refreshPage, setTitle } = useTabs();

 function getQueryParam(paramName) {
    const urlParams = new URLSearchParams(window.location.search);
    return urlParams.get(paramName);
  }

const listAll = '/flow/flowCclist/list';

  const refTable = ref();
  const dataList = ref([]);

let queryParamSta = getQueryParam('sta');
console.log('queryParamSta ',queryParamSta);
if (queryParamSta==null){
  queryParamSta=0;
}

  //定义表格列
  const columns: BasicColumn[] = [
    {
    title: '流程',
    align: "center",
    dataIndex: 'flowname',
    width: 300,
  },
  {
    title: '标题',
    align: "center",
    dataIndex: 'title',
    width: 300,
  },
  {
    title: '抄送人',
    align: "center",
    dataIndex: 'recempname',
    width: 100,
  },
  

   {
    title: '当前节点',
    align: "center",
    dataIndex: 'nodename'
  },
 {
    title: '发起日期',
    align: "center",
    dataIndex: 'rdt'
  },
  


  ];

    //ajax请求api接口
  const demoListApi = (params) => {
    return defHttp.get({ url: listAll, params: {token: user.getJflowToken,sta:queryParamSta} });
  };

    // 列表页面公共参数、方法
  const { tableContext } = useListPage({
    tableProps: {
      api: demoListApi,
      columns: columns,
      actionColumn: {
        width: 120,
      },
      useSearchForm:false,
      pagination:false,
    }, //tableProps


  }); //useListPage

   //注册table数据
  const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext

   /**
   * 操作栏
   */
  function getTableAction(record): ActionItem[] {
    return [
      {
        label: '查看',
        onClick: handleEdit.bind(null, record),
      },
    ];
  }

  function handleEdit(record) {
    //console.log(record);

    router.push({path: '/workflow/base/cc/MyFlow',query:{
      WorkID:record.workid,MyPK:record.mypk,FK_Flow:record.fkFlow,FK_Node:record.nodeidwork,FID:record.fid,Sta:record.sta,Rec:record.recempname,NodeName:record.nodename
    }})
  }


  







  

</script>

