import type { VbenFormProps, VxeGridProps } from '#/adapter';

import { TenantApi } from '#/api';
import { formatterStatus } from '#/api/model';

export const searchFormOptions: VbenFormProps = {
  schema: [
    {
      component: 'Input',
      fieldName: 'name',
      label: '租户名称',
    },
    {
      component: 'Input',
      fieldName: 'phone',
      label: '联系人',
    },
  ],
};

export const gridOptions: VxeGridProps<TenantApi.RecordItem> = {
  checkboxConfig: {
    highlight: true,
    labelField: 'name',
  },
  columns: [
    { title: '序号', type: 'seq', width: 50 },
    {
      align: 'left',
      field: 'name',
      title: '租户名称',
      // type: 'checkbox',
      width: 200,
    },
    { align: 'left', field: 'adminAccount', title: '联系人', width: 120 },
    { align: 'left', field: 'phone', title: '联系电话', width: 120 },
    { field: 'tenantTypeName', title: '租户类型', width: 80 },
    {
      field: 'status',
      title: '状态',
      width: 60,
      formatter: formatterStatus,
    },
    { field: 'sort', title: '排序', width: 50 },
    { align: 'left', field: 'remark', title: '备注' },
    {
      field: 'action',
      fixed: 'right',
      slots: { default: 'action' },
      title: '操作',
      width: 180,
    },
  ],
  height: 'auto',
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await TenantApi.getPage({
          pageIndex: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
};
