index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import dayjs from 'dayjs'
  4. import { DICT_TYPE } from '@/utils/dict'
  5. import { useTable } from '@/hooks/web/useTable'
  6. import { useI18n } from '@/hooks/web/useI18n'
  7. import type { RefundVO } from '@/api/pay/refund/types'
  8. import { allSchemas } from './refund.data'
  9. import * as RefundApi from '@/api/pay/refund'
  10. const { t } = useI18n() // 国际化
  11. // ========== 列表相关 ==========
  12. const { register, tableObject, methods } = useTable<RefundVO>({
  13. getListApi: RefundApi.getRefundPageApi,
  14. delListApi: RefundApi.deleteRefundApi,
  15. exportListApi: RefundApi.exportRefundApi
  16. })
  17. const { getList, setSearchParams, delList, exportList } = methods
  18. // ========== CRUD 相关 ==========
  19. const dialogVisible = ref(false) // 是否显示弹出层
  20. const dialogTitle = ref('edit') // 弹出层标题
  21. // ========== 详情相关 ==========
  22. const detailRef = ref() // 详情 Ref
  23. // 详情操作
  24. const handleDetail = async (row: RefundVO) => {
  25. // 设置数据
  26. detailRef.value = RefundApi.getRefundApi(row.id)
  27. dialogTitle.value = t('action.detail')
  28. dialogVisible.value = true
  29. }
  30. // ========== 初始化 ==========
  31. getList()
  32. </script>
  33. <template>
  34. <!-- 搜索工作区 -->
  35. <ContentWrap>
  36. <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
  37. </ContentWrap>
  38. <ContentWrap>
  39. <!-- 操作工具栏 -->
  40. <div class="mb-10px">
  41. <el-button
  42. type="warning"
  43. v-hasPermi="['system:post:export']"
  44. :loading="tableObject.exportLoading"
  45. @click="exportList('退款订单.xls')"
  46. >
  47. <Icon icon="ep:download" class="mr-5px" /> {{ t('action.export') }}
  48. </el-button>
  49. </div>
  50. <!-- 列表 -->
  51. <Table
  52. :columns="allSchemas.tableColumns"
  53. :selection="false"
  54. :data="tableObject.tableList"
  55. :loading="tableObject.loading"
  56. :pagination="{
  57. total: tableObject.total
  58. }"
  59. v-model:pageSize="tableObject.pageSize"
  60. v-model:currentPage="tableObject.currentPage"
  61. @register="register"
  62. >
  63. <template #status="{ row }">
  64. <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
  65. </template>
  66. <template #createTime="{ row }">
  67. <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  68. </template>
  69. <template #action="{ row }">
  70. <el-button
  71. link
  72. type="primary"
  73. v-hasPermi="['system:post:update']"
  74. @click="handleDetail(row)"
  75. >
  76. <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
  77. </el-button>
  78. <el-button
  79. link
  80. type="primary"
  81. v-hasPermi="['system:post:delete']"
  82. @click="delList(row.id, false)"
  83. >
  84. <Icon icon="ep:delete" class="mr-1px" /> {{ t('action.del') }}
  85. </el-button>
  86. </template>
  87. </Table>
  88. </ContentWrap>
  89. <Dialog v-model="dialogVisible" :title="dialogTitle">
  90. <!-- 对话框(详情) -->
  91. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef">
  92. <template #status="{ row }">
  93. <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
  94. </template>
  95. <template #createTime="{ row }">
  96. <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  97. </template>
  98. </Descriptions>
  99. <!-- 操作按钮 -->
  100. <template #footer>
  101. <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
  102. </template>
  103. </Dialog>
  104. </template>