import type { VxeGridProps } from '#/adapter/vxe-table';

import { getStoreInputList } from '../api';

interface RowType {
  id: number;
  name: string;
  type: number;
  clinic_type: number;
  status: number;
  input_user_id: number;
  inputUser: {
    nick_name: string;
  };
  auditAdmin: {
    nick_name: string;
  };
  audit_time: number;
  created_at: string;
}

// 录入列表表格配置
export const inputGridOptions: VxeGridProps<RowType> = {
  checkboxConfig: {
    highlight: true,
    labelField: '',
  },
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
  },
  columns: [
    { type: 'checkbox', width: 60 },
    { field: 'id', align: 'left', title: 'ID', width: 100 },
    { field: 'name', align: 'left', title: '门店名称' },
    {
      field: 'type',
      align: 'left',
      title: '类型',
      width: 100,
      slots: { default: 'type' },
    },
    {
      field: 'clinic_type',
      align: 'left',
      title: '诊所类型',
      width: 120,
      slots: { default: 'clinic_type' },
    },
    {
      field: 'status',
      align: 'left',
      title: '审核状态',
      width: 120,
      slots: { default: 'status' },
    },
    { field: 'contact', title: '联系人' },
    { field: 'mobile', title: '联系电话', slots: { default: 'mobile' } },
    { field: 'position', title: '详细地址' },
    { field: 'created_at', title: '录入时间' },
    {
      field: 'inputUser',
      title: '录入人',
      minWidth: 140,
      slots: { default: 'inputUser' },
    },
    {
      field: 'promoter_admin',
      title: '业务员',
      minWidth: 160,
      slots: { default: 'promoter_admin' },
    },
    {
      type: 'html',
      title: '操作',
      align: 'right',
      slots: { default: 'action' },
    },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getStoreInputList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
  height: 'auto',
  border: false,
  toolbarConfig: {
    search: true,
    refresh: true,
    print: false,
    export: false,
    zoom: true,
    slots: {
      buttons: 'toolbar-actions',
    },
  },
  showOverflow: false,
};

// 审核列表表格配置
export const auditGridOptions: VxeGridProps<RowType> = {
  checkboxConfig: {
    highlight: true,
    labelField: '',
  },
  columnConfig: {
    useKey: true,
  },
  rowConfig: {
    useKey: true,
  },
  columns: [
    { type: 'checkbox', width: 60 },
    { field: 'id', align: 'left', title: 'ID', width: 100 },
    { field: 'name', align: 'left', title: '门店名称' },
    {
      field: 'type',
      align: 'left',
      title: '类型',
      width: 100,
      slots: { default: 'type' },
    },
    {
      field: 'clinic_type',
      align: 'left',
      title: '诊所类型',
      width: 120,
      slots: { default: 'clinic_type' },
    },
    {
      field: 'status',
      align: 'left',
      title: '审核状态',
      width: 120,
      slots: { default: 'status' },
    },
    {
      field: 'inputUser',
      title: '录入人',
      minWidth: 140,
      slots: { default: 'inputUser' },
    },
    { field: 'auditAdmin.nick_name', title: '审核人' },
    {
      field: 'promoter_admin',
      title: '业务员',
      minWidth: 160,
      slots: { default: 'promoter_admin' },
    },
    { field: 'audit_time', title: '审核时间', slots: { default: 'audit_time' } },
    { field: 'contact', title: '联系人' },
    { field: 'mobile', title: '联系电话', slots: { default: 'mobile' } },
    { field: 'position', title: '详细地址' },
    { field: 'created_at', title: '录入时间' },
    {
      type: 'html',
      title: '操作',
      fixed: 'right',
      width: 200,
      slots: { default: 'action' },
    },
  ],
  keepSource: true,
  pagerConfig: {},
  proxyConfig: {
    ajax: {
      query: async ({ page }, formValues) => {
        return await getStoreInputList({
          page: page.currentPage,
          pageSize: page.pageSize,
          ...formValues,
        });
      },
    },
  },
  height: 'auto',
  border: false,
  toolbarConfig: {
    search: true,
    refresh: true,
    print: false,
    export: false,
    zoom: true,
    slots: {
      buttons: 'toolbar-actions',
    },
  },
  showOverflow: false,
};
