Index.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <app-view class="goods-detail g-form">
  3. <template #header>
  4. <app-navbar :title="quote ? quote.goodscode + '/' + quote.goodsname : '挂牌大厅'" />
  5. </template>
  6. <component :is="Price" v-bind="{ goodsCode }" />
  7. <component :is="Chart" v-bind="{ goodsCode }" />
  8. <component :is="Forex" v-bind="{ goodsCode }" />
  9. <component :is="Tik" v-bind="{ goodsCode }" />
  10. <template #footer>
  11. <div class="g-form__footer">
  12. <Button block type="danger" square @click="onListing(EBuildType.BUILDTYPE_OPEN)">订立</Button>
  13. <Button block type="primary" square :disabled="isDisabledClose"
  14. @click="onListing(EBuildType.BUILDTYPE_CLOSE)">转让</Button>
  15. </div>
  16. <component ref="componentRef" :is="componentMap.get(componentId)" v-bind="{ goodsCode, buildType }"
  17. @closed="closeComponent" v-if="componentId" />
  18. </template>
  19. </app-view>
  20. </template>
  21. <script lang="ts" setup>
  22. import { shallowRef, defineAsyncComponent, computed } from 'vue'
  23. import { Button } from 'vant'
  24. import { useNavigation } from '../../../router/navigation'
  25. import { useComponent } from '@/hooks/component'
  26. import { EBuildType } from '@/constants/client'
  27. import { useFuturesStore } from '@/stores'
  28. import { usePosition } from '@/business/position'
  29. const Price = defineAsyncComponent(() => import('../../../components/modules/quote/price/index.vue'))
  30. const Chart = defineAsyncComponent(() => import('../../../components/modules/quote/chart/index.vue'))
  31. const Forex = defineAsyncComponent(() => import('../../../components/modules/quote/forex/index.vue'))
  32. const Tik = defineAsyncComponent(() => import('../../../components/modules/quote/tik/index.vue'))
  33. const componentMap = new Map<string, unknown>([
  34. ['listing', defineAsyncComponent(() => import('./components/listing/Index.vue'))],
  35. ])
  36. const { positionList } = usePosition(50)
  37. const { getQueryStringToNumber } = useNavigation()
  38. const futuresStore = useFuturesStore()
  39. const goodsid = getQueryStringToNumber('goodsid')
  40. const quote = futuresStore.getQuoteDayInfo(goodsid)
  41. const buildType = shallowRef<EBuildType>() // 挂牌类型
  42. const goodsCode = computed(() => quote.value?.goodscode ?? '')
  43. const isDisabledClose = computed(() => !positionList.value.some((e) => e.goodsid === goodsid))
  44. const { componentRef, componentId, openComponent, closeComponent } = useComponent()
  45. const onListing = (type: EBuildType) => {
  46. buildType.value = type
  47. openComponent('listing')
  48. }
  49. </script>