index.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import APP from '@/services';
  2. import { setAllEnum } from '@/services/bus/allEnum';
  3. import { getLongTypeLoginID } from '@/services/bus/login';
  4. import { localStorageUtil } from '@/utils/storage';
  5. import moment from 'moment';
  6. import { commonSearch_go } from '../index';
  7. import * as type from './interface';
  8. /**
  9. * 获取服务器时间
  10. */
  11. export function getServerTime(): Promise<string> {
  12. return commonSearch_go('/Common/GetServerTime', {})
  13. .then((res) => {
  14. const time = moment(res)
  15. .utc()
  16. .format('YYYY-MM-DD HH:mm:ss');
  17. APP.set('systemDate', time);
  18. return 'ok';
  19. })
  20. .catch((err: Error) => {
  21. throw new Error('获取服务器时间数据错误:' + err);
  22. });
  23. }
  24. /**
  25. * 获取所有枚举信息
  26. * @param autoid autoid传入后则返回这个ID之后的数据;如不传则返回所有
  27. */
  28. export function getAllEnums(autoid?: number): Promise<string> {
  29. const param = autoid ? { autoid } : {};
  30. return commonSearch_go('/Common/GetAllEnums', param)
  31. .then((res) => {
  32. console.log('所有枚举信息', res);
  33. setAllEnum(res)
  34. return 'ok';
  35. })
  36. .catch((err: Error) => {
  37. throw new Error('查询获取所有枚举信息:' + err);
  38. });
  39. }
  40. /**
  41. * 获取数据库错误信息
  42. * @param rowNumber 如果传入rowNumber,则返回此rowNumber后的数据
  43. */
  44. export function queryErrorInfos(rowNumber?: string): Promise<string> {
  45. const param = rowNumber ? { rowNumber } : {};
  46. return commonSearch_go('/Common/QueryErrorInfos', param)
  47. .then((res) => {
  48. localStorageUtil.setItem('errorCodeInfos', res);
  49. return 'ok';
  50. })
  51. .catch((err: Error) => {
  52. throw new Error('查询获取所有枚举信息:' + err);
  53. });
  54. }
  55. /**
  56. * 通知公告设置已读请求
  57. * @param loginID 登录账号
  58. * @param noticeID 通知公告ID
  59. */
  60. export function queryNoticeReaded(noticeID: number): Promise<string> {
  61. const param = { noticeID, loginID: Number(getLongTypeLoginID()) };
  62. return commonSearch_go('/Common/NoticeReaded', param, 'post')
  63. .then(() => 'ok')
  64. .catch((err: Error) => {
  65. throw new Error(`通知公告设置已读请求失败:${err}`);
  66. });
  67. }
  68. /**
  69. * 通知公告系统消息查询
  70. */
  71. export function queryNotice(): Promise<type.QueryNoticeRsp[]> {
  72. const param = { loginID: Number(getLongTypeLoginID()) };
  73. return commonSearch_go('/Common/QueryNotice', param).catch((err: Error) => {
  74. throw new Error(`通知公告系统消息查询失败:${err}`);
  75. });
  76. }
  77. /**
  78. * 获取PC交易端菜单
  79. */
  80. export function GetPCMenus(): Promise<string> {
  81. const param = {
  82. loginID: Number(getLongTypeLoginID()),
  83. clientType: 0, // 终端类型,0:PC 1:Mobile
  84. };
  85. return commonSearch_go('/Common/GetClientMenus', param)
  86. .then((res) => {
  87. APP.set('menus', res);
  88. console.log('res', res);
  89. return 'ok';
  90. })
  91. .catch((err: Error) => {
  92. throw new Error(`获取PC交易端菜单失败:${err}`);
  93. });
  94. }
  95. /**
  96. * 查询交易端列表头信息
  97. * @returns
  98. */
  99. export function QueryTableDefine(): Promise<type.TableDefineRsp[]> {
  100. const param = {
  101. tableType: 2, // 列表类型 - 1:管理端 2:H5终端 3:移动终端
  102. };
  103. return commonSearch_go('/Common/QueryTableDefine', param)
  104. .then((res) => {
  105. console.log('查询交易端列表头信息', res);
  106. APP.set('tableHead', res);
  107. return res;
  108. })
  109. .catch((err: Error) => {
  110. throw new Error(`查询交易端列表头信息:${err}`);
  111. });
  112. }