import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { RoleEnum } from '/@/enums/roleEnum';
import { getServiceTypes,queryServiceTags,queryDicsByName,queryCoors } from '/@/api/resource/map';

const resTag = await queryServiceTags()
let listTag = []
resTag.map(item => {
  listTag.push({
    label: item.name,
    value: item.code
  })
})
/**
 * 密级字典
*/
export const secrets = await queryDicsByName('密级')
/**
 * 服务标签
*/
export const serviceTags = listTag;
/**
 * 坐标系列表
*/
export const sysCoors = await queryCoors()
/**
 * 服务类型
*/
export const serviceTypes = await getServiceTypes()
/**
 * 责任处室
*/
export const respDept = await queryDicsByName('责任处室')
/**
 * 保管单位
*/
export const collectDept = await queryDicsByName('保管单位')
/**
 * EPSG code
*/
export const EPSGCodes = await queryDicsByName('EPSG code')


const checkStatus = [
  { label: '未提交', value: 1 },
  { label: '审核中', value: 2 },
  { label: '审核不通过', value: 3 },
  { label: '被驳回', value: 4 },
  { label: '审核通过', value: 5 },
  { label: '我的', value: 6 },
]
export enum KeysTypeEnum {
  DISABLED = 'disabled',
  ENABLED = 'enabled',
}

export const RoleMenuDictEnum: Recordable<{ key: string; keyType: KeysTypeEnum }> = {
  [RoleEnum.PLATFORM_ADMIN]: { key: 'enabled_platform_admin_auth', keyType: KeysTypeEnum.ENABLED },
  [RoleEnum.SYS_ADMIN]: { key: 'enabled_sysadmin_auth', keyType: KeysTypeEnum.ENABLED },
  [RoleEnum.TENANT_ADMIN]: { key: 'disabled_tenant_auth', keyType: KeysTypeEnum.DISABLED },
  [RoleEnum.CUSTOMER_USER]: { key: 'disabled_tenant_auth', keyType: KeysTypeEnum.DISABLED },
};

/**
 * 查询条件
*/
export const searchFormSchema: FormSchema[] = [
  {
    field: 'resTag',
    label: '资源标签',
    component: 'Select',
    componentProps: {
      options: serviceTags,
      // [
      //   { label: '标签1', value: 1 },
      //   { label: '标签2', value: 2 },
      //   { label: '标签3', value: 3 },
      // ],
    },
    colProps: { span: 5 },
  },
  {
    field: 'resName',
    label: '资源名称',
    component: 'Input',
    colProps: { span: 5 },
    componentProps: {
      maxLength: 255,
    },
  },
  {
    field: 'checkStatus',
    label: '审核状态',
    component: 'Select',
    componentProps: {
      options: checkStatus,
    },
    colProps: { span: 5 },
  },
];

/**
 * 列表显示信息
*/
export const columns: BasicColumn[] = [
  {
    title: '分组名称',
    dataIndex: 'groupName',
    align:'center',
  },
  {
    title: '接口名称',
    dataIndex: 'name',
    align:'center',
  },
  {
    title: '接口id',
    dataIndex: 'id',
    align:'center',
  },
  {
    title: '调用次数',
    dataIndex: 'isOpen',
    align:'center',
  },
  {
    title: '发布时间',
    dataIndex: 'publishTime',
    align:'center',
  },
  {
    title: '接口说明',
    dataIndex: 'remark',
    align:'center',
  },
  {
    title: '接口状态',
    dataIndex: 'status',
    align:'center',
  },
  {
    title: '版本号',
    align:'center',
    dataIndex: 'version',
  },
  {
    title: '审核状态',
    align:'center',
    dataIndex: 'assemblyStatus',
    slots: { customRender: 'assemblyStatus' },
  }
];



/**
 * 表单
*/
export const formSchema: FormSchema[] = [
  {
    field: 'groupName',
    label: '角色名称',
    required: true,
    component: 'Input',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入角色名称',
    },
  },
  {
    label: '排序',
    field: 'sort',
    component: 'Input',
    componentProps: {
      maxLength: 255,
      placeholder: '请输入排序',
    },
  }
];
