import type { VxeGridProps } from '#/adapter/vxe-table';

import { type FormSchemaGetter } from '#/adapter/form';
import { OptionsTag } from '#/components/table';

import { activityStatusOptions, publishStatusOptions } from './constant';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'flowName',
    label: '流程名称',
  },
  {
    component: 'Input',
    fieldName: 'flowCode',
    label: '流程code',
  },
];

export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    field: 'flowName',
    title: '流程名称',
    minWidth: 150,
  },
  {
    field: 'flowCode',
    title: '流程code',
    minWidth: 150,
  },
  {
    field: 'version',
    title: '版本号',
    minWidth: 80,
    formatter: ({ cellValue }) => `V${cellValue}.0`,
  },
  {
    field: 'activityStatus',
    title: '状态',
    minWidth: 100,
    slots: {
      default: ({ row }) => {
        const cellValue = row.activityStatus;
        return (
          <OptionsTag
            options={activityStatusOptions as any}
            value={cellValue}
          />
        );
      },
    },
  },
  {
    field: 'isPublish',
    title: '发布状态',
    minWidth: 100,
    slots: {
      default: ({ row }) => {
        const cellValue = row.isPublish;
        return (
          <OptionsTag options={publishStatusOptions as any} value={cellValue} />
        );
      },
    },
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: 280,
  },
];
