index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <app-view class="market-spot">
  3. <template #header>
  4. <app-navbar title="现货行情" />
  5. </template>
  6. <Tabs @change="onTabChange" v-model:active="active">
  7. <template v-for="(item, index) in tabList" :key="index">
  8. <Tab :name="item.spotname" :title="item.spotname" />
  9. </template>
  10. </Tabs>
  11. <template v-if="dataList.length">
  12. <app-list :columns="columns" :data-list="dataList" :showHeader="false" @click="onRowClick">
  13. <template #spotprice="{ value }">
  14. <span class="text-red">{{ value }}元/吨</span>
  15. </template>
  16. <template #spotqty="{ value }">
  17. <span class="text-red">{{ value }}吨</span>
  18. </template>
  19. </app-list>
  20. </template>
  21. <Empty v-else />
  22. </app-view>
  23. </template>
  24. <script lang="ts" setup>
  25. import { shallowRef } from 'vue'
  26. import { Tab, Tabs, Empty } from 'vant'
  27. import { useNavigation } from '@/hooks/navigation'
  28. import { useRequest } from '@/hooks/request'
  29. import { queryThjSpotQuote, queryThjSpotQuoteConfig } from '@/services/api/market'
  30. import AppList from '@mobile/components/base/list/index.vue'
  31. const { router } = useNavigation()
  32. const active = shallowRef(0)
  33. const { dataList, run } = useRequest(queryThjSpotQuoteConfig, {
  34. manual: true
  35. })
  36. const { dataList: tabList } = useRequest(queryThjSpotQuote, {
  37. onSuccess: (res) => {
  38. if (res.data) {
  39. run({ spotname: res.data[0].spotname })
  40. }
  41. }
  42. })
  43. const columns: Model.TableColumn[] = [
  44. { prop: 'spotmonth', label: '月份' },
  45. { prop: 'spotsrc', label: '来源' },
  46. { prop: 'spotprice', label: '价格' },
  47. { prop: 'spotqty', label: '数量' },
  48. ]
  49. const onTabChange = (spotname: string) => {
  50. run({ spotname })
  51. }
  52. const onRowClick = (row: Model.ThjSpotQuoteConfigRsp) => {
  53. if (row.relatedid) {
  54. router.push({ name: 'news-details', query: { id: row.relatedid } })
  55. }
  56. }
  57. </script>
  58. <style lang="less" scoped>
  59. @import './index.less';
  60. </style>