import type { FormSchema } from '@/components/core/schema-form/';
import { ContractStatusEnum } from '@/enums/contractEnum';
import { formatStatus } from './columns';
import { useDictStore } from '@/store/modules/dict';
import { DictEnum } from '@/enums/dictEnum';
const { getDictItemsByCode } = useDictStore();
export const formSchemas = (isEdit = false): FormSchema<API.ContractEntity>[] => [
  {
    field: 'contractNumber',
    component: 'Input',
    label: '合同编号',
    rules: [{ required: true, type: 'string' }],
    colProps: {
      span: 12,
    },
  },
  {
    field: 'title',
    component: 'Input',
    label: '合同标题',
    rules: [{ required: true, type: 'string' }],
    colProps: {
      span: 12,
    },
  },

  {
    field: 'partyA',
    component: 'Input',
    label: '甲方',
    rules: [{ required: true, type: 'string' }],
    colProps: {
      span: 12,
    },
  },
  {
    field: 'partyB',
    component: 'Input',
    label: '乙方',
    rules: [{ required: true, type: 'string' }],
    colProps: {
      span: 12,
    },
  },

  {
    field: 'signingDate',
    label: '签订时间',
    component: 'DatePicker',
    colProps: { span: 12 },
    componentProps: {},
  },
  {
    field: 'deliveryDeadline',
    label: '交付期限',
    component: 'DatePicker',
    colProps: { span: 12 },
  },
  {
    field: 'type',
    label: '合同类型',
    component: 'Select',
    required: true,
    colProps: {
      span: 12,
    },
    componentProps: {
      options: getDictItemsByCode(DictEnum.ContractType).map(({ label, id }) => ({
        value: id,
        label,
      })),
    },
  },
  {
    field: 'status',
    label: '审核结果',
    component: 'Select',
    required: true,
    vIf:isEdit,
    defaultValue: 0,
    colProps: {
      span: 12,
    },
    componentProps: {
      allowClear: false,
      options: Object.values(ContractStatusEnum)
        .filter((value) => typeof value === 'number')
        .map((item) => formatStatus(item as ContractStatusEnum)),
    },
  },
  // {
  //   field: 'remark',
  //   component: 'InputTextArea',
  //   label: '备注',
  // },
  // {
  //   field: 'menuIds',
  //   component: 'Tree',
  //   label: '菜单权限',
  //   componentProps: {
  //     checkable: true,
  //     vModelKey: 'checkedKeys',
  //     fieldNames: {
  //       title: 'name',
  //       key: 'id',
  //     },
  //     style: {
  //       height: '350px',
  //       paddingTop: '5px',
  //       overflow: 'auto',
  //       borderRadius: '6px',
  //       border: '1px solid #dcdfe6',
  //       resize: 'vertical',
  //     },
  //   },
  // },
];
