import request from '@/config/axios'
import { get } from 'http'

// 列表查询字段 VO
export interface TableVO {
  id: number // 自增主键
  menuCode: string // 菜单编码
  gridCode: string // grid编码
  gridName: string // grid名称
  enabled: number // 状态(0-启用 1-停用)
  remark: string // 备注说明
  itemId: number // 来源ItemID
  version: number // 版本
}

// 列表查询字段 API
export const TableApi = {
  // 查询列表查询字段分页
  getTablePage: async (params: any) => {
    return await request.get({ url: `/grid/table/page`, params })
  },

  // 查询列表查询字段详情
  getTable: async (id: number) => {
    return await request.get({ url: `/grid/table/get?id=` + id })
  },

  // 新增列表查询字段
  createTable: async (data: TableVO) => {
    return await request.post({ url: `/grid/table/create`, data })
  },

  // 修改列表查询字段
  updateTable: async (data: TableVO) => {
    return await request.put({ url: `/grid/table/update`, data })
  },

  // 删除列表查询字段
  deleteTable: async (id: number) => {
    return await request.delete({ url: `/grid/table/delete?id=` + id })
  },
  // 批量删除${subTable.classComment}
  deleteTableList: async (ids: number[]) => {
    return await request.delete({ url: `/grid/table/delete-list?ids=` + ids })
  },

  // 导出列表查询字段 Excel
  exportTable: async (params) => {
    return await request.download({ url: `/grid/table/export-excel`, params })
  },

  // 创建主题
  themeCreate: async (data: {}) => {
    return await request.post({ url: `/grid/theme/create`, data })
  },
  // 主题分页
  gridThemePage: async (params: any) => {
    return await request.get({ url: `/grid/theme/page`, params })
  },
  // 查询主题详情
  getTheme: async (id: number) => {
    return await request.get({ url: `/grid/theme/get?id=` + id })
  },
  // 修改主题
  themeUpdate: async (data: {}) => {
    return await request.put({ url: `/grid/theme/update`, data })
  },
  // 修改主题
  themeUpdateStatus: async (data: {}) => {
    return await request.post({ url: `/grid/theme/updateStatus`, data })
  },
  // 根据gridCode和角色获取生效主题
  getEnabledTheme: async (data: {}) => {
    return await request.post({ url: `/grid/theme/getEnabledThemeInfo`, data })
  },
  // 获取表单字段扩展字段列表
  getExtensionFieldList: async (gridCode: number | string) => {
    return await request.get({ url: `/grid/form-field/extension-field-list?gridCode=` + gridCode })
  }
}
