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

import {
  SUPPLIER_ONLINE_STATUS_CELLTAG,
  SUPPLIER_PURCHASE_CATEGORY_CELLTAG,
  SUPPLIER_STATUS_CELLTAG,
} from '#/views/srm/enums';

/** 采购下单的采购品类标签页 */
export const PLACE_CATEGORY_TABS = [
  { key: '1', label: '代理商品采购' },
  { key: '2', label: '原辅料采购' },
];

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'name',
      label: '供应商名称',
      component: 'Input',
      componentProps: {
        placeholder: '请输入供应商名称',
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<SrmSupplierApi.SupplierVO>['columns'] {
  return [
    { field: 'code', title: '供应商编码', minWidth: 140 },
    { field: 'name', title: '供应商名称', minWidth: 200 },
    {
      field: 'purchaseCategory',
      title: '采购品类',
      minWidth: 110,
      cellRender: { name: 'CellTag', props: SUPPLIER_PURCHASE_CATEGORY_CELLTAG },
    },
    {
      field: 'onlineStatus',
      title: '在线状态',
      minWidth: 100,
      cellRender: { name: 'CellTag', props: SUPPLIER_ONLINE_STATUS_CELLTAG },
    },
    { field: 'contactName', title: '联系人', minWidth: 100 },
    { field: 'contactMobile', title: '联系电话', minWidth: 130 },
    {
      field: 'status',
      title: '状态',
      minWidth: 80,
      cellRender: { name: 'CellTag', props: SUPPLIER_STATUS_CELLTAG },
    },
    {
      title: '操作',
      width: 120,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
