flow.api.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { cacheFor } from '@/request/api/index';
  2. import { type Flow, fromFlowData } from '@/request/model';
  3. import Router from '@/router';
  4. import HTTP from '../alova';
  5. export function copyrightMethod() {
  6. return HTTP.Post(`/fdhb-tablet/warrantManage/getPageSets`, void 0, {
  7. cacheFor, name: `variate:copyright`,
  8. params: { k: 'copyright' },
  9. meta: { ignoreException: true },
  10. transform(data: any, headers) {
  11. if ( !data ) { throw { message: `无效的证书` }; }
  12. return [ data?.partner, data?.technicalSupporter ].filter(Boolean).join('<br>');
  13. },
  14. });
  15. }
  16. export function processMethod() {
  17. const path = unref(Router.currentRoute).path;
  18. return HTTP.Post<string, { tabletProcessModules?: string[]; }>(`/fdhb-tablet/warrantManage/getPageSets`, {}, {
  19. cacheFor, name: `variate:process`,
  20. params: { k: 'process', p: path },
  21. transform(data) {
  22. const options = data.tabletProcessModules ?? [];
  23. const ref = fromFlowData(options);
  24. const flow = ref.get(path);
  25. if ( !flow ) throw { message: `[路由] 配置异常无法解析正确路径,请联系管理员 (${ data?.tabletProcessModules?.join(' -> ') }})` };
  26. return flow.route;
  27. },
  28. });
  29. }
  30. export function processMethod2() {
  31. const path = unref(Router.currentRoute).path;
  32. return HTTP.Post<Flow, { tabletProcessModules?: string[]; }>(`/fdhb-tablet/warrantManage/getPageSets`, {}, {
  33. cacheFor, name: `variate:process`,
  34. params: { k: 'process', p: path },
  35. transform(data) {
  36. const options = data.tabletProcessModules ?? [];
  37. const ref = fromFlowData(options);
  38. const flow = ref.get(path);
  39. if ( !flow ) throw { message: `[路由] 配置异常无法解析正确路径,请联系管理员 (${ data?.tabletProcessModules?.join(' -> ') }})` };
  40. return flow;
  41. },
  42. });
  43. }
  44. export function processMethod3() {
  45. const path = unref(Router.currentRoute).path;
  46. return HTTP.Post<{ current: Flow; prev: Flow; next: Flow }, { tabletProcessModules?: string[]; }>(`/fdhb-tablet/warrantManage/getPageSets`, {}, {
  47. cacheFor, name: `variate:process`,
  48. params: { k: 'process', p: path },
  49. transform(data) {
  50. const options = data.tabletProcessModules ?? [];
  51. const ref = fromFlowData(options);
  52. const [key, current] = [...ref.entries()].find(([,flow]) => flow.route === path) || [];
  53. const prev = [...ref.values()].find(flow => flow.route === key);
  54. const next = ref.get(path);
  55. if ( !next ) throw { message: `[路由] 配置异常无法解析正确路径,请联系管理员 (${ data?.tabletProcessModules?.join(' -> ') }})` };
  56. return { current, prev, next } as any;
  57. }
  58. })
  59. }