import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';

import { DICT_TYPE } from '#/packages/constants/src';
import { getDictOptions } from '#/packages/effects/hooks/src';

export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'archiveCode',
      label: '归档编号',
      component: 'Input',
      componentProps: { placeholder: '请输入归档编号' },
    },
    {
      fieldName: 'productCode',
      label: '产品编码',
      component: 'Input',
      componentProps: { placeholder: '请输入产品编码' },
    },
    {
      fieldName: 'productName',
      label: '产品名称',
      component: 'Input',
      componentProps: { placeholder: '请输入产品名称' },
    },
    {
      fieldName: 'archiveStatus',
      label: '归档状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_TYPE.MES_PD_ARCHIVE_STATUS, 'number'),
        placeholder: '请选择归档状态',
      },
    },
  ];
}

export function useGridColumns(): VxeTableGridOptions['columns'] {
  return [
    {
      field: 'archiveCode',
      title: '归档编号',
      minWidth: 130,
      slots: { default: 'archiveCode' },
    },
    { field: 'productCode', title: '产品编码', minWidth: 120 },
    { field: 'productName', title: '产品名称', minWidth: 140 },
    { field: 'taskCode', title: '任务编码', minWidth: 130 },
    { field: 'taskName', title: '任务名称', minWidth: 160 },
    { field: 'archiveCount', title: '归档数量', minWidth: 90 },
    {
      field: 'archiveStatus',
      title: '归档状态',
      minWidth: 100,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.MES_PD_ARCHIVE_STATUS },
      },
    },
    { field: 'archiverNickname', title: '归档人', minWidth: 100 },
    {
      field: 'archiveTime',
      title: '归档时间',
      minWidth: 160,
      formatter: 'formatDateTime',
    },
    { field: 'updaterNickname', title: '更新人', minWidth: 100 },
    {
      field: 'updateTime',
      title: '更新时间',
      minWidth: 160,
      formatter: 'formatDateTime',
    },


  ];
}
