index.vue 1.9 KB

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