setup.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { ref } from 'vue';
  2. import { useRoute } from 'vue-router';
  3. import { initData } from "@/common/methods";
  4. import { serviceURL } from "@/services/request";
  5. import { getToken } from "@/services/bus/token";
  6. import { OperationTabMenuAuth } from '@/services/go/commonService/interface';
  7. const iframeCode: { code: string, tabIndex: number }[] = [
  8. {
  9. code: 'goods_spot', // 基础设置-商品设置-现货品种
  10. tabIndex: 1,
  11. },
  12. {
  13. code: 'goods_hedge', // 基础设置-商品设置-套保品种
  14. tabIndex: 2,
  15. },
  16. {
  17. code: 'company_normal', // 基础设置-主体设置-正常
  18. tabIndex: 1,
  19. },
  20. {
  21. code: 'company_disabled', // 基础设置-主体设置-停用
  22. tabIndex: 2,
  23. },
  24. {
  25. code: 'futures_spot_finish', // 现货套保-期现关联-外部成交单关联
  26. tabIndex: 1,
  27. },
  28. {
  29. code: 'futures_spot_order', // 现货套保-期现关联-期现单据关联
  30. tabIndex: 2,
  31. },
  32. {
  33. code: 'futures_spot_record', // 现货套保-期现关联-关联记录
  34. tabIndex: 3,
  35. },
  36. {
  37. code: 'hedge_ratio_checkpending', // 风管审核-套保比例审核-待审核
  38. tabIndex: 1,
  39. },
  40. {
  41. code: 'hedge_ratio_performance', // 风管审核-套保比例审核-已审核
  42. tabIndex: 2,
  43. },
  44. {
  45. code: 'spot_params_checkpending', // 风管审核-现货参数审核-待审核
  46. tabIndex: 1,
  47. },
  48. {
  49. code: 'spot_params_performance', // 风管审核-现货参数审核-已审核
  50. tabIndex: 2,
  51. },
  52. {
  53. code: 'price_report_spot', // 统计报表-定价报表
  54. tabIndex: 1,
  55. }
  56. ]
  57. /**
  58. * 获取管理端url
  59. */
  60. export function getIframeUrl() {
  61. const route = useRoute();
  62. const url = ref('');
  63. const getUrl = () => {
  64. // 管理端地址
  65. const serviceUrl = serviceURL.pcMangerUrl + route.meta.url;
  66. // 根据当前路由 name(code) 查找出对应的 iframeCode
  67. const item = iframeCode.find((item) => item.code === route.name);
  68. if (item) {
  69. const auth = route.meta.auth as OperationTabMenuAuth[];
  70. const param = auth.reduce((res, item) => res + `:${item.code}`, '');
  71. url.value = `${serviceUrl}?token=${getToken()}&tabindex=${item.tabIndex}&resourcepcmenu=${param}`;
  72. }
  73. }
  74. initData(() => {
  75. getUrl();
  76. })
  77. return {
  78. url
  79. }
  80. }