<template>
    <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
      <div class="w-1/4 xl:w-1/5 leftbox flex column">
        <div class="flex ai-c jc-sb">
          <div class="textbox">
            <p>算法库</p>
            <span>行业生态算法厂商</span>
          </div>
          <a-button type="primary" size="small" @click="createAddClick">
            <template #icon><PlusOutlined /></template>
            创建
          </a-button>
        </div>
        <div class="flex ai-c jc-c column flex-1">
          <div class="descbox">
            <p>请先创建自定义算法，基于算法新增实例<br />了解更多：<BookOutlined :style="{fontSize: '14px', color: '#0A99EB'}" /> 说明书</p>
          </div>
          <a-button type="primary" @click="createAddClick">
            <template #icon><PlusOutlined /></template>
            创建自定义算法
          </a-button>
        </div>
      </div>
      <BasicTable
        class="w-3/4 xl:w-4/5"
        @register="registerTable"
        @fetch-success="onFetchSuccess"
        :searchInfo="searchInfo"
      >
       
      </BasicTable>
      <Modal
        @submitsuccess="submitsuccess"
        @register="registerModal"
        @submit-reload="submitReload"
      />
    </PageWrapper>
  </template>
  <script lang="ts" setup>
    import { reactive, nextTick, ref } from 'vue';
    import { PlusOutlined, BookOutlined } from '@ant-design/icons-vue';
    import { BasicTable, useTable } from '@/components/Table';
    import { getButtonList, getMenuDetail, deleteButton } from '@/api/demo/system';
    import { PageWrapper } from '@/components/Page';
    import { columns, searchFormSchema } from './index.data';
    import { useMessage } from '@/hooks/web/useMessage';
    import Modal from './modal.vue';
    import { useModal } from '@/components/Modal';
  
    const { createConfirm, createMessage } = useMessage();
    defineOptions({ name: 'MenuManagement' });
    const searchInfo = reactive<Recordable>({});
  
    const [registerTable, { reload, expandAll, getSelectRows, clearSelectedRowKeys }] = useTable({
      title: '算法列表',
      // api: getButtonList,
      columns,
      rowKey: 'id',
      formConfig: {
        labelWidth: 120,
        schemas: searchFormSchema,
      },
      isTreeTable: true,
      striped: false,
      useSearchForm: true,
      showTableSetting: true,
      bordered: true,
      showIndexColumn: false,
      rowSelection: {
        //多选框
        // type: 'checkbox',
        type: 'radio',
      },
      handleSearchInfoFn(info) {
        return info;
      },
    });
    const [registerModal, { openModal }] = useModal();
    function createAddClick(){
      openModal(true, {
        
      });
    }
  
    function onFetchSuccess() {
      // 演示默认展开所有表项
      nextTick(expandAll);
    }
  </script>
  <style scoped>
  .flex{
    display: flex;
  }
  .flex-1{
    flex: 1;
  }
  .column{
    flex-direction: column;
  }
  .ai-c{
    align-items: center;
  }
  .jc-sb{
    justify-content: space-between;
  }
  .jc-c{
    justify-content: center;
  }
  .leftbox{
    background: #fff;
    margin: 16px 0 16px 16px;
    padding: 16px;
    .textbox{
      p{
        font-weight: 500;
        font-size: 16px;
        color: #060606;
        line-height: 22px;
        margin-bottom: 0;
      }
      span{
        font-weight: 400;
        font-size: 13px;
        color: #393939;
        line-height: 18px;
      }
    }
    .descbox{
      font-weight: 400;
      font-size: 13px;
      color: #393939;
      line-height: 18px;
      text-align: center;
    }
  }
  </style>
  