tplApi.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Copyright (c) 2013-Now https://jeesite.com All rights reserved.
  3. * No deletion without permission, or be held responsible to law.
  4. * @author ThinkGem
  5. */
  6. import { defHttp } from '@jeesite/core/utils/http/axios';
  7. import type { Page } from '@jeesite/core/api/model/baseModel';
  8. import { useGlobSetting } from '@jeesite/core/hooks/setting';
  9. import type { TableInfo } from './types/dto';
  10. import type { TplPageParams } from './types/query';
  11. const { adminPath } = useGlobSetting();
  12. export type TplPageResult = Partial<Page<TableInfo>> & {
  13. list?: TableInfo[];
  14. records?: TableInfo[];
  15. total?: number;
  16. count?: number;
  17. };
  18. export type TplCategoryResult =
  19. | string[]
  20. | Array<Record<string, any>>
  21. | {
  22. data?: string[] | Array<Record<string, any>>;
  23. list?: string[] | Array<Record<string, any>>;
  24. records?: string[] | Array<Record<string, any>>;
  25. result?: string[] | Array<Record<string, any>>;
  26. };
  27. /**
  28. * 获取模板分页列表
  29. */
  30. export const tplPage = (params: TplPageParams) => defHttp.get<TplPageResult>({ url: adminPath + '/tpl/page', params });
  31. /**
  32. * 获取模板详情
  33. */
  34. export const tplDetail = (params: { id: number }) => defHttp.get<TableInfo>({ url: adminPath + '/tpl/detail', params });
  35. /**
  36. * 获取模板分类
  37. */
  38. export const tplCategoryList = () =>
  39. defHttp.get<TplCategoryResult>({ url: adminPath + '/tpl/cag' }, { skipSuccessMessage: true, skipErrorMessage: true });
  40. /**
  41. * 校验模板名称是否可用
  42. */
  43. export const tplCheckTableName = (oldTableNameCn: string, tableNameCn: string) =>
  44. defHttp.get<any>(
  45. {
  46. url: adminPath + '/tpl/checkName',
  47. params: { oldTableNameCn, tableNameCn, name: tableNameCn },
  48. },
  49. { skipSuccessMessage: true, skipErrorMessage: true },
  50. );
  51. /**
  52. * 创建模板
  53. */
  54. export const tplCreate = (params?: any, data?: TableInfo) =>
  55. defHttp.postJson<TableInfo>({ url: adminPath + '/tpl/create', params, data }, { skipSuccessMessage: true });
  56. /**
  57. * 更新模板
  58. */
  59. export const tplUpdate = (params?: any, data?: TableInfo) =>
  60. defHttp.postJson<TableInfo>({ url: adminPath + '/tpl/update', params, data }, { skipSuccessMessage: true });
  61. /**
  62. * 删除模板
  63. */
  64. export const tplDelete = (params: { id: number }) =>
  65. defHttp.delete<void>({ url: adminPath + '/tpl/delete', params }, { skipSuccessMessage: true });