<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();


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

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



  //定义表格列
  const columns: BasicColumn[] = [
    {
    title: '标题',
    align: "center",
    dataIndex: 'title',
    width: 300,
  },
  {
    title: '发起人',
    align: "center",
    dataIndex: 'startername',
    width: 100,
  },
   {
    title: '发起日期',
    align: "center",
    dataIndex: 'rdt'
  },

   {
    title: '停留节点',
    align: "center",
    dataIndex: 'nodename'
  },

   {
    title: '发送人',
    align: "center",
    dataIndex: 'sender'
  },
 
  {
    title: '发送日期',
    align: "center",
    dataIndex: 'adt'
  },


  ];

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

    // 列表页面公共参数、方法
  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);
    /**
    http://47.98.203.68:82/#/WF/MyFlow?WorkID=215631418&FK_Flow=093&PWorkID=0&PFlowNo=&FK_Node=9302&FID=0&Token=8671b894b2ae4861af9849e83bafbe34&win=true
    */

    router.push({path: '/workflow/base/todo/MyFlow',query:{
      WorkID:record.workid,FK_Flow:record.fkFlow,FK_Node:record.fkNode,FID:record.fid
    }})
  }


  







  

</script>

