index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  5. <template #toolbar_buttons>
  6. <!-- 操作:新增 -->
  7. <XButton
  8. type="primary"
  9. preIcon="ep:zoom-in"
  10. :title="t('action.add')"
  11. v-hasPermi="['pay:order:create']"
  12. @click="handleCreate()"
  13. />
  14. <!-- 操作:导出 -->
  15. <XButton
  16. type="warning"
  17. preIcon="ep:download"
  18. :title="t('action.export')"
  19. v-hasPermi="['pay:order:export']"
  20. @click="exportList('订单数据.xls')"
  21. />
  22. </template>
  23. <template #actionbtns_default="{ row }">
  24. <!-- 操作:详情 -->
  25. <XTextButton
  26. preIcon="ep:view"
  27. :title="t('action.detail')"
  28. v-hasPermi="['pay:order:query']"
  29. @click="handleDetail(row.id)"
  30. />
  31. </template>
  32. </XTable>
  33. </ContentWrap>
  34. <XModal v-model="dialogVisible" :title="dialogTitle">
  35. <!-- 对话框(详情) -->
  36. <Descriptions :schema="allSchemas.detailSchema" :data="detailData" />
  37. <!-- 操作按钮 -->
  38. <template #footer>
  39. <!-- 按钮:关闭 -->
  40. <XButton :loading="actionLoading" :title="t('dialog.close')" @click="dialogVisible = false" />
  41. </template>
  42. </XModal>
  43. </template>
  44. <script setup lang="ts" name="Order">
  45. import { useI18n } from '@/hooks/web/useI18n'
  46. import { useXTable } from '@/hooks/web/useXTable'
  47. import { allSchemas } from './order.data'
  48. import * as OrderApi from '@/api/pay/order'
  49. const { t } = useI18n() // 国际化
  50. // 列表相关的变量
  51. const [registerTable, { exportList }] = useXTable({
  52. allSchemas: allSchemas,
  53. getListApi: OrderApi.getOrderPageApi,
  54. exportListApi: OrderApi.exportOrderApi
  55. })
  56. // ========== CRUD 相关 ==========
  57. const actionLoading = ref(false) // 遮罩层
  58. const actionType = ref('') // 操作按钮的类型
  59. const dialogVisible = ref(false) // 是否显示弹出层
  60. const dialogTitle = ref('edit') // 弹出层标题
  61. const detailData = ref() // 详情 Ref
  62. // 设置标题
  63. const setDialogTile = (type: string) => {
  64. dialogTitle.value = t('action.' + type)
  65. actionType.value = type
  66. dialogVisible.value = true
  67. }
  68. // 新增操作
  69. const handleCreate = () => {
  70. setDialogTile('create')
  71. }
  72. // 详情操作
  73. const handleDetail = async (rowId: number) => {
  74. setDialogTile('detail')
  75. const res = await OrderApi.getOrderApi(rowId)
  76. detailData.value = res
  77. }
  78. </script>