index.vue 3.6 KB

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