index.vue 3.5 KB

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