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

import { computed } from 'vue';

import { z } from '@vben/common-ui';

import { $t } from '#/locales';

export const querySchema = computed(() => [
  {
    component: 'Input',
    fieldName: 'phoneNumber',
    label: $t('abp.CTWingManagement.PhoneNumber'),
  },
]);

export const tableSchema: any = computed((): VxeGridProps['columns'] => [
  { title: $t('common.seq'), type: 'seq', width: 50 },
  {
    field: 'accountId',
    title: $t('abp.CTWingManagement.CTWingAccountId'),
    minWidth: '150',
  },
  {
    field: 'accountName',
    title: $t('abp.CTWingManagement.AccountName'),
    minWidth: '150',
  },
  {
    field: 'phoneNumber',
    title: $t('abp.CTWingManagement.PhoneNumber'),
    minWidth: '150',
  },
  {
    field: 'appId',
    title: $t('common.AppId'),
    minWidth: '150',
  },
  {
    field: 'appKey',
    title: $t('common.AppKey'),
    minWidth: '150',
  },
  {
    field: 'appSecret',
    title: $t('common.AppSecret'),
    minWidth: '150',
  },
  {
    field: 'productCount',
    title: $t('abp.CTWingManagement.ProductCount'),
    minWidth: '150',
  },
  {
    title: $t('common.action'),
    field: 'action',
    fixed: 'right',
    width: '150',
    slots: { default: 'action' },
  },
]);

export const addAccountFormSchema: any = computed(() => [
  {
    component: 'Input',
    fieldName: 'ctWingAccountId',
    label: $t('abp.CTWingManagement.CTWingAccountId'),
    rules: z.string().min(1, {
      message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.CTWingManagement.CTWingAccountId')}`,
    }),
  },
  {
    component: 'Input',
    fieldName: 'accountName',
    label: $t('abp.CTWingManagement.AccountName'),
    rules: z.string().min(1, {
      message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.CTWingManagement.AccountName')}`,
    }),
  },
  {
    component: 'Input',
    fieldName: 'accountAccesskey',
    label: $t('abp.CTWingManagement.AccountAccesskey'),
    rules: z.string().min(1, {
      message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.CTWingManagement.AccountAccesskey')}`,
    }),
  },
  {
    component: 'Input',
    fieldName: 'phoneNumber',
    label: $t('abp.CTWingManagement.PhoneNumber'),
    rules: z
      .string()
      .min(1, {
        message: `${$t('common.pleaseInput')}${$t('abp.CTWingManagement.PhoneNumber')}`,
      })
      .refine((value) => /^1[3-9]\d{9}$/.test(value), {
        message: $t('common.PhoneNumberFormatError'),
      }),
  },
]);

export const editAccountFormSchemaEdit: any = computed(() => [
  {
    component: 'Input',
    fieldName: 'ctWingAccountId',
    label: $t('abp.CTWingManagement.CTWingAccountId'),
    disabled: true,
  },
  {
    component: 'Input',
    fieldName: 'accountName',
    label: $t('abp.CTWingManagement.AccountName'),
    rules: z.string().min(1, {
      message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.CTWingManagement.AccountName')}`,
    }),
  },
  {
    component: 'Input',
    fieldName: 'accountAccesskey',
    label: $t('abp.CTWingManagement.AccountAccesskey'),
    rules: z.string().min(1, {
      message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.CTWingManagement.AccountAccesskey')}`,
    }),
  },
  {
    component: 'Input',
    fieldName: 'phoneNumber',
    label: $t('abp.CTWingManagement.PhoneNumber'),
    rules: z
      .string()
      .min(1, {
        message: `${$t('common.pleaseInput')}${$t('abp.CTWingManagement.PhoneNumber')}`,
      })
      .refine((value) => /^1[3-9]\d{9}$/.test(value), {
        message: $t('common.PhoneNumberFormatError'),
      }),
  },
]);
