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 },
]
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: 'source',
  //   label: '资源标签',
  //   component: 'Select',
  //   componentProps: {
  //     // options: serviceTags,
  //     options: [
  //       { label: '地图浏览工具', value: '地图浏览工具' },
  //       { label: '服务加载工具', value: '服务加载工具' },
  //       { label: 'GIS功能工具', value: 'GIS功能工具' },
  //       { label: '空间分析工具', value: '空间分析工具' },
  //       { label: '三维可视化效果工具', value: '三维可视化效果工具' },
  //     ],
  //   },
  //   colProps: { span: 5 },
  // },
  {
    field: 'filterValue',
    label: '组件名称',
    component: 'Input',
    colProps: { span: 5 },
    componentProps: {
      maxLength: 255,
    },
  },
  {
    field: 'status',
    label: '审核状态',
    component: 'Select',
    componentProps: {
      options: [
        { label: '未提交', value: "3" },
        { label: '审核中', value: "0" },
        { label: '审核通过', value: "1" },
        { label: '审核不通过', value: "2" },
      ],
    },
    colProps: { span: 5 },
  },
];

/**
 * 列表显示信息
*/
export const columns: BasicColumn[] = [
  {
    title: '组件编号',
    dataIndex: 'serviceid',
    width: 120,
  },
  {
    title: '组件名称',
    dataIndex: 'servicename',
    width: 160,
  },
  {
    title: '组件分组',
    dataIndex: 'source',
    width: 160,
  },
  // {
  //   title: '预览图',
  //   dataIndex: 'publiccurl',
  //   width: 160,
  // },
  // {
  //   title: '资源标签',
  //   dataIndex: 'typename',
  //   width: 120,
  // },
  {
    title: '发布人',
    dataIndex: 'publisher',
    width: 120,
  },
  // {
  //   title: '发布时间',
  //   dataIndex: 'publishdate',
  //   width: 180,
  //   slots: { customRender: 'pdate' },
  // },
  {
    title: '当前环节',
    dataIndex: 'nodename',
    slots: { customRender: 'nodename' },
    width: 90,
  },
  {
    title: '当前处理人',
    dataIndex: 'checkname',
    slots: { customRender: 'checkname' },
    width: 100,
  },
  {
    title: '审核状态',
    dataIndex: 'status',
    width: 110,
    slots: { customRender: 'status' },
  },
  // {
  //     title: '审核人',
  //     dataIndex: 'checkname',
  //     width: 100,
  //   },
  {
    title: '审核时间',
    dataIndex: 'checktime',
    width: 160,
    slots: { customRender: 'checktime' },
  },
];



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