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 useDrawingReviewGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'code',
      label: '审核单号',
      component: 'Input',
      componentProps: { placeholder: '请输入审核单号' },
    },
    {
      fieldName: 'status',
      label: '审核状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_TYPE.MES_PD_DRAWING_REVIEW_STATUS, 'number'),
        placeholder: '请选择审核状态',
      },
    },
  ];
}

export function useDrawingReviewGridColumns(): VxeTableGridOptions['columns'] {
  return [
    { field: 'code', title: '审核单号', minWidth: 130 },
    { field: 'documentName', title: '资料名称', minWidth: 160 },
    { field: 'documentVersion', title: '资料版本', minWidth: 90 },
    { field: 'reviewerName', title: '审核人', minWidth: 100 },
    {
      field: 'status',
      title: '审核状态',
      minWidth: 100,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.MES_PD_DRAWING_REVIEW_STATUS },
      },
    },
    {
      field: 'reviewTime',
      title: '审核时间',
      minWidth: 160,
      formatter: 'formatDateTime',
    },
    {
      field: 'action',
      title: '操作',
      width: 160,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

export function useDrawingReviewFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: { triggerFields: [''], show: () => false },
    },
    {
      fieldName: 'documentName',
      label: '资料名称',
      component: 'Input',
      componentProps: { disabled: true },
    },
    {
      fieldName: 'status',
      label: '审核结果',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_TYPE.MES_PD_DRAWING_REVIEW_STATUS, 'number'),
      },
      rules: 'required',
    },
    {
      fieldName: 'reviewComment',
      label: '审核意见',
      component: 'Textarea',
      componentProps: { placeholder: '请输入审核意见', rows: 4 },
    },
  ];
}
