index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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="['system:post:create']"
  12. @click="openModal('create')"
  13. />
  14. <!-- 操作:导出 -->
  15. <XButton
  16. type="primary"
  17. plain
  18. preIcon="ep:download"
  19. :title="t('action.export')"
  20. v-hasPermi="['system:post:export']"
  21. @click="exportList('岗位列表.xls')"
  22. />
  23. </template>
  24. <template #actionbtns_default="{ row }">
  25. <!-- 操作:修改 -->
  26. <XTextButton
  27. preIcon="ep:edit"
  28. :title="t('action.edit')"
  29. v-hasPermi="['system:post:update']"
  30. @click="openModal('update', row?.id)"
  31. />
  32. <!-- 操作:详情 -->
  33. <XTextButton
  34. preIcon="ep:view"
  35. :title="t('action.detail')"
  36. v-hasPermi="['system:post:query']"
  37. @click="openModal('detail', row?.id)"
  38. />
  39. <!-- 操作:删除 -->
  40. <XTextButton
  41. preIcon="ep:delete"
  42. :title="t('action.delete')"
  43. v-hasPermi="['system:post:delete']"
  44. @click="deleteData(row?.id)"
  45. />
  46. </template>
  47. </XTable>
  48. </ContentWrap>
  49. <!-- 表单弹窗:添加/修改/详情 -->
  50. <PostForm ref="modalRef" @success="reload()" />
  51. </template>
  52. <script setup lang="ts" name="Post">
  53. import * as PostApi from '@/api/system/post'
  54. import { allSchemas } from './post.data'
  55. import PostForm from './form.vue'
  56. const { t } = useI18n() // 国际化
  57. // 列表相关的变量
  58. const [registerTable, { reload, deleteData, exportList }] = useXTable({
  59. allSchemas: allSchemas, // 列表配置
  60. getListApi: PostApi.getPostPageApi, // 加载列表的 API
  61. deleteApi: PostApi.deletePostApi, // 删除数据的 API
  62. exportListApi: PostApi.exportPostApi // 导出数据的 API
  63. })
  64. // 表单相关的变量
  65. const modalRef = ref()
  66. const openModal = (actionType: string, id?: number) => {
  67. modalRef.value.openModal(actionType, id)
  68. }
  69. </script>