index.vue 2.3 KB

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