<template>
  <PageWrapper dense contentFullHeight fixedHeight>
    <BasicTable @register="registerTable" isMenuTable>
      <template #toolbar> </template>
    </BasicTable>
  </PageWrapper>
</template>
<script lang="ts" setup>
  import { getProcessInstancePage } from '/@/api/workflow/delegate';
  import { BasicTable, useTable, FormSchema, BasicColumn } from '/@/components/Table';

  import { PageWrapper } from '/@/components/Page';
  import { useI18n } from '/@/hooks/web/useI18n';
  const { t } = useI18n();
  const configColumns: BasicColumn[] = [
    {
      title: t('流程名称'),
      dataIndex: 'processName',
      width: 180,
      resizable: true,
      sorter: {
        multiple: 1,
      },
    },
    {
      title: t('开始时间'),
      dataIndex: 'startTime',
      width: 180,
      resizable: true,
      sorter: {
        multiple: 2,
      },
    },
    {
      title: t('结束时间'),
      dataIndex: 'endTime',
      width: 180,
      resizable: true,
      sorter: {
        multiple: 2,
      },
    },
    {
      title: t('发起人'),
      dataIndex: 'startUserName',
      width: 180,
      resizable: true,
      sorter: {
        multiple: 3,
      },
    },
    {
      title: t('是否异常'),
      dataIndex: 'isError',
      width: 180,
      resizable: true,
      sorter: {
        multiple: 5,
      },
      customRender: ({ record }) => {
        return record.isError ? '异常' : '正常';
      },
    },
  ];
  const searchFormSchema: FormSchema[] = [
    {
      field: 'keyword',
      label: t('关键字'),
      component: 'Input',
      colProps: { span: 8 },
      componentProps: {
        placeholder: t('请输入关键字'),
      },
    },
  ];
  const [registerTable] = useTable({
    title: t('流程实例分析列表'),
    api: getProcessInstancePage,
    columns: configColumns,
    formConfig: {
      rowProps: {
        gutter: 16,
      },
      schemas: searchFormSchema,
      showResetButton: false,
    },
    striped: false,
    useSearchForm: true,
    showTableSetting: true,
    tableSetting: {
      size: false,
    },
  });
</script>
