<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 { ActionItem, BasicColumn, BasicTable, TableAction } from '/@/components/Table';
  
import { useListPage } from '/@/hooks/system/useListPage';
import { useUserStoreWithOut } from '/@/store/modules/user';
import { useRouter } from 'vue-router';
const router = useRouter();
const user = useUserStoreWithOut();


const listAll = '/api/jflow/getFlow';

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



  //定义表格列
  const columns: BasicColumn[] = [
    {
      title: '流程类型',
      dataIndex: 'FK_FlowSortText',
      width: 100,
      resizable: true,
    },
    {
      title: '流程名称',
      dataIndex: 'Name',
      width: 260,
      align: 'left',
      resizable: true,
      sorter: {
        multiple: 1,
      },
    },
    
   
  ];

    //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,
    }, //tableProps


  }); //useListPage

   //注册table数据
  const [registerTable, {  }] = 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?No=087&Name=计划审核流程&IsBatchStart=0&Icon=icon-plane&
    //FK_FlowSort=101&FK_FlowSortText=流程基础&DomainExt=&MobileColorType=0&IsStartInMobile=1&Idx=7&WorkModel=0&SortIdx=0&FlowMark=&
    //FlowSortIcon=icon-direction&Btns=流程列表&Token=cafc72ad2ac74391a413a7fd5b485b74&win=true
    router.push({path: '/workflow/base/start/DB_StarFlows',query:{
      No:record.No,Name:record.Name,IsBatchStart:record.IsBatchStart,Icon:record.Icon,
      FK_FlowSort:record.FK_FlowSort,FK_FlowSortText:record.FK_FlowSortText,MobileColorType:record.MobileColorType,
      IsStartInMobile:record.IsStartInMobile,Idx:record.Idx,WorkModel:record.WorkModel,SortIdx:record.SortIdx
      }})
  }


  







  

</script>

