<template>
  <div>
    <!--引用表格-->
    <BasicTable @register="registerTable" :rowSelection="rowSelection">
      <!--操作栏-->
      <template #action="{ record }">
        <TableAction :actions="getTableAction(record)"/>
      </template>
      <!--字段回显插槽-->
      <template #htmlSlot="{ text }">
        <div v-html="text"></div>
      </template>
    </BasicTable>
    <ArchiveDrawer ref="refArchiveDrawer"  @callback="handleSuccess"/>
  </div>
</template>

<script lang="ts" name="baosong-baosongTask" setup>
  import { ref, computed, unref } from 'vue';
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';
  import ArchiveDrawer from './ArchiveDrawer.vue';
  

  import { columns, searchFormSchema } from '/@/views/baosong/task/BaosongTask.data';
  import { archiveList } from '/@/views/baosong/task/BaosongTask.api';
  
  const refArchiveDrawer = ref();


  const { tableContext } = useListPage({
    tableProps: {
      title: '任务表',
      api: archiveList,
      columns,
      canResize: false,
      formConfig: {
        labelWidth: "30%",
        schemas: searchFormSchema,
        autoSubmitOnEnter: true,
        showAdvancedButton: true,
        fieldMapToNumber: [],
        fieldMapToTime: [],
      },
      actionColumn: {
        width: 200,
        fixed: 'right',
      },
    },
  });

  const [registerTable, { reload }, {rowSelection, selectedRowKeys}] = tableContext;

  async function handleSuccess() {
    (selectedRowKeys.value = []) && reload();
  }
  
  async function handleOpenDrawer(record){
    refArchiveDrawer.value.openDrawer(record)
  }

  function getTableAction(record) {
    return [
      {
        label: '下载',
        //disabled:(record.sta!=9),
        onClick: handleOpenDrawer.bind(null, record),
      },
    ];
  }

</script>

<style scoped>
</style>
