index.ts 3.5 KB

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