index.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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="handleExport()"
  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 { ref } from 'vue'
  46. import { useI18n } from '@/hooks/web/useI18n'
  47. import { useXTable } from '@/hooks/web/useXTable'
  48. import { allSchemas } from './order.data'
  49. import * as OrderApi from '@/api/pay/order'
  50. const { t } = useI18n() // 国际化
  51. // 列表相关的变量
  52. const [registerTable, { exportList }] = useXTable({
  53. allSchemas: allSchemas,
  54. getListApi: OrderApi.getOrderPageApi,
  55. exportListApi: OrderApi.exportOrderApi
  56. })
  57. // ========== CRUD 相关 ==========
  58. const actionLoading = ref(false) // 遮罩层
  59. const actionType = ref('') // 操作按钮的类型
  60. const dialogVisible = ref(false) // 是否显示弹出层
  61. const dialogTitle = ref('edit') // 弹出层标题
  62. const detailData = ref() // 详情 Ref
  63. // 设置标题
  64. const setDialogTile = (type: string) => {
  65. dialogTitle.value = t('action.' + type)
  66. actionType.value = type
  67. dialogVisible.value = true
  68. }
  69. // 新增操作
  70. const handleCreate = () => {
  71. setDialogTile('create')
  72. }
  73. // 导出操作
  74. const handleExport = async () => {
  75. await exportList('订单数据.xls')
  76. }
  77. // 详情操作
  78. const handleDetail = async (rowId: number) => {
  79. setDialogTile('detail')
  80. const res = await OrderApi.getOrderApi(rowId)
  81. detailData.value = res
  82. }
  83. </script>