index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!-- 挂牌大厅-我的询价 -->
  2. <template>
  3. <app-view>
  4. <template #header>
  5. <app-filter :options="filterOptons" :loading="loading" />
  6. </template>
  7. <!-- 表格数据 -->
  8. <app-table :data="dataList" v-model:columns="columns" :loading="loading">
  9. <!-- 申请状态 -->
  10. <template #applystatus="{ value }">
  11. {{ getApplyStatusName(value) }}
  12. </template>
  13. <!-- 价格 -->
  14. <template #price="{ row }">
  15. {{ row.zscurrencytypedisplayunit + formatDecimal(row.price) }}
  16. </template>
  17. <!-- 我的出价 -->
  18. <template #applyprice="{ row }">
  19. {{ row.zscurrencytypedisplayunit + formatDecimal(row.applyprice) }}
  20. </template>
  21. <!-- 克拉单价 -->
  22. <template #priceper="{ row }">
  23. {{ row.zscurrencytypedisplayunit + formatDecimal(row.priceper) }}
  24. </template>
  25. <!-- 操作 -->
  26. <template #operate="{ row }">
  27. <app-auth-operation type="dropdown" :menus="handleOperateButtons(row)" :options="{ selectedRow: row }"
  28. @closed="onRefresh" />
  29. </template>
  30. <template #footer>
  31. <app-pagination :total="total" v-model:page-size="pageSize" v-model:page-index="pageIndex"
  32. @change="onRefresh" />
  33. </template>
  34. </app-table>
  35. </app-view>
  36. </template>
  37. <script lang="ts" setup>
  38. import { shallowRef } from 'vue'
  39. import { ElMessage } from 'element-plus'
  40. import { formatDecimal } from '@/filters'
  41. import { useDataFilter } from '@/hooks/datatable'
  42. import { BuyOrSell } from '@/constants/order'
  43. import { useBargain } from '@/business/bargain'
  44. import { getApplyStatusName, ApplyStatus } from '@/constants/order'
  45. import { useComposeTable } from '@pc/components/base/table'
  46. import AppTable from '@pc/components/base/table/index.vue'
  47. import AppPagination from '@pc/components/base/pagination/index.vue'
  48. import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
  49. import AppFilter from '@pc/components/base/table-filter/index.vue'
  50. const { loading, dataList, total, pageIndex, pageSize, getBargainOrderList } = useBargain()
  51. const { filterOptons, getQueryParams } = useDataFilter<(Ermcp.MyBargainApplyReq | Ermcp.MyDelistingApplyReq) & { buyorsell: number }>()
  52. // 求购表格列
  53. const { tableColumns: buyColumns } = useComposeTable<Ermcp.MyBargainApplyRsp>({ rowKey: 'wrtradeorderid', columnKey: 'listing_bargain_buy' })
  54. // 出售表格列
  55. const { tableColumns: sellColumns } = useComposeTable<Ermcp.MyDelistingApplyRsp>({ rowKey: 'ladingbillid', columnKey: 'listing_bargain_sell' })
  56. // 默认表格列
  57. const columns = shallowRef<Ermcp.TableColumn[]>([])
  58. // “待确认”状态 有撤销按钮
  59. const handleOperateButtons = (row: Ermcp.MyBargainApplyRsp | Ermcp.MyDelistingApplyRsp) => {
  60. if (row.applystatus === ApplyStatus.Pending) {
  61. return ['trade_bargain_details', 'trade_bargain_cancel']
  62. }
  63. return ['trade_bargain_details']
  64. }
  65. // 切换表格列
  66. const getColumns = (buyorsell?: number) => {
  67. switch (buyorsell) {
  68. case BuyOrSell.Buy: {
  69. columns.value = buyColumns.value
  70. break
  71. }
  72. case BuyOrSell.Sell: {
  73. columns.value = sellColumns.value
  74. break
  75. }
  76. default: {
  77. columns.value = []
  78. }
  79. }
  80. }
  81. const onSearch = (clear = false) => {
  82. getQueryParams((qs) => {
  83. pageIndex.value = 1
  84. getColumns(qs.buyorsell)
  85. getBargainOrderList(qs)
  86. }, clear)
  87. }
  88. const onRefresh = () => {
  89. getQueryParams((qs) => {
  90. getColumns(qs.buyorsell)
  91. getBargainOrderList(qs).catch((err) => ElMessage.error(err))
  92. })
  93. }
  94. filterOptons.selectList = [
  95. {
  96. label: '询价',
  97. key: 'buyorsell',
  98. selectedValue: BuyOrSell.Buy,
  99. options: [
  100. { label: '求购申请', value: BuyOrSell.Buy },
  101. { label: '出售申请', value: BuyOrSell.Sell }
  102. ],
  103. },
  104. {
  105. label: '状态',
  106. key: 'applystatus',
  107. selectedValue: 1,
  108. options: [
  109. { label: '全部', value: 0 },
  110. { label: '待确认', value: 1 }
  111. ],
  112. },
  113. ]
  114. filterOptons.buttonList = [
  115. { lable: '查询', className: 'el-button--primary', onClick: () => onSearch() }
  116. ]
  117. onRefresh()
  118. </script>