import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter,dateFormatter2 } from '@/utils/formatTime'

// 表单校验
export const SupplierinvoiceInvoicedRules = reactive({
  supplierCode: [required],
  poNumber: [required],
  currency: [required],
  concurrencyStamp: [required],
})

export const SupplierinvoiceInvoiced = useCrudSchemas(reactive<CrudSchema[]>([
  {
    label: '供应商代码',
    field: 'supplierCode',
    sort: 'custom',
    isSearch: true,
    table: {
      width: 150
    },
  },
  {
    label: '订单号',
    field: 'poNumber',
    sort: 'custom',
    table: {
      width: 150
    },
  },
  {
    label: '待开票单据号',
    field: 'recvBillNum',
    sort: 'custom',
    isSearch: true,
    table: {
      width: 150
    },
  },
  {
    label: '发货单号',
    field: 'asnBillNum',
    sort: 'custom',
    table: {
      width: 150
    },
  },
  {
    label: '供应商送货日期',
    field: 'supplierDeliveryTime',
    sort: 'custom',
    formatter: dateFormatter2,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
    form: {
      component: 'DatePicker',
      componentProps: {
        style: {width:'100%'},
        type: 'datetime',
        dateFormat: 'YYYY-MM-DD',
        valueFormat: 'x',
      }
    },
    table: {
      width: 150
    },
    isForm: false,
  },
  {
    label: '收货日期',
    field: 'prhRcpDate',
    sort: 'custom',
    isSearch: true,
    formatter: dateFormatter2,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
    form: {
      component: 'DatePicker',
      componentProps: {
        style: {width:'100%'},
        type: 'datetime',
        dateFormat: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      }
    },
    table: {
      width: 150
    },
    isForm: false,
  },
  {
    label: '项目编码',
    field: 'projectCode',
    sort: 'custom',
    isTable:false,
    isTableForm:false,
    table: {
      width: 150
    },
  },
  {
    label: '单据类型',
    field: 'billType',
    dictType: DICT_TYPE.BILL_TYPE,
    dictClass: 'string',
    sort: 'custom',
    form: {
      component: 'SelectV2'
    },
    table: {
      width: 150
    },
  },

  {
    label: '状态',
    field: 'status',
    dictType: DICT_TYPE.SUPPLIERINVOICE_STATUS,
    dictClass: 'string',
    isTable: true,
    isForm:false,
    sort: 'custom',
    table: {
      width: 150
    },
    isSearch: true,
    form: {
      value: '1',
      componentProps: {
        disabled: true
      }
    }
  },

  {
    label: '发票申请状态',
    field: 'requestStatus',
    dictType: DICT_TYPE.INVOICE_REQUEST_STATUS,
    dictClass: 'string',
    isTable: true,
    isForm:false,
    sort: 'custom',
    table: {
      width: 150
    },
    isSearch: true,
    form: {
      value: '1',
      componentProps: {
        disabled: true
      }
    }
  },


  {
    label: '订单行',
    field: 'poLine',
    sort: 'custom',
    table: {
      width: 150
    },
  },
  {
    label: '采购价格',
    field: 'purchasePrice',
    sort: 'custom',
    table: {
      width: 150
    },
  },
  {
    label: '可开票数量',
    field: 'invoicableQuantity',
    sort: 'custom',
    table: {
      width: 150
    },
  },
  {
    label: '零件号',
    field: 'itemCode',
    sort: 'custom',
    table: {
      width: 150
    },
  },
  {
    label: '计量单位',
    field: 'uom',
    dictType: DICT_TYPE.UOM,
    dictClass: 'string', 
    sort: 'custom',
    table: {
      width: 150
    },
  },
  {
    label: '货币',
    field: 'currency',
    sort: 'custom',
    dictType: DICT_TYPE.CURRENCY,
    dictClass: 'string',
    table: {
      width: 150
    },
    tableForm:{
      type:'Select',
      disabled: true
    }
  },
  {
    label: '创建时间',
    field: 'createTime',
    sort: 'custom',
    formatter: dateFormatter,
    form: {
      component: 'DatePicker',
      componentProps: {
        style: {width:'100%'},
        type: 'datetime',
        dateFormat: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      }
    },
    table: {
      width: 150
    },
    isForm: false,
    isSearch: true,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
  },
  {
    label: '备注',
    field: 'remark',
    sort: 'custom',
    table: {
      width: 150
    },
  },
  {
    label: '操作',
    field: 'action',
    isForm: false,
    table: {
      width: 200,
      fixed: 'right'
    }
  }
]))