index.ts 4.1 KB

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