import { BasicColumn, FormSchema } from '/@/components/Table';
import { transformTime } from '/@/hooks/web/useDateToLocaleString';
import { h } from 'vue';

export const columns: BasicColumn[] = [
  {
    title: '创建时间',
    dataIndex: 'createdTime',
    width: 200,
    format: (_text: string, record: Recordable) => {
      return transformTime(record.createdTime);
    },
  },
  {
    title: '名称',
    dataIndex: 'name',
    width: 200,
  },
  {
    title: '说明',
    dataIndex: 'description',
    width: 120,
  },
  {
    title: '默认',
    dataIndex: 'default',
    width: 200,
    format: (_text: string, record: Recordable) => {
      return record.default == false ? '否' : '是';
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'textSearch',
    label: '租户配置名称',
    colProps: { span: 6 },
    component: 'Input',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入租户配置名称',
    },
  },
];
export const formSchema: FormSchema[] = [
  {
    field: 'name',
    label: '名称',
    colProps: { span: 24 },
    required: true,
    component: 'Input',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入名称',
    },
  },
  {
    field: 'isolatedTbRuleEngine',
    label: '',
    component: 'Checkbox',
    renderComponentContent: () => {
      return h('span', {}, [
        h('span', {}, '隔离板芯容器中的加工'),
        h('span', { style: { color: 'grey' } }, '（每个独立租户需要单独的微服务）'),
      ]);
    },
  },
  {
    field: 'isolatedTbCore',
    label: '',
    component: 'Checkbox',
    renderComponentContent: () => {
      return h('span', {}, [
        h('span', {}, '在独立的规则引擎中处理'),
        h('span', { style: { color: 'grey' } }, '（每个独立租户需要单独的微服务）'),
      ]);
    },
  },
  {
    field: 'description',
    label: '说明',
    colProps: { span: 24 },
    component: 'InputTextArea',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入说明',
    },
  },
];
