index.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <!-- 搜索工作栏 -->
  3. <ContentWrap>
  4. <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams">
  5. <!-- 新增等操作按钮 -->
  6. <template #actionMore>
  7. <el-button
  8. type="primary"
  9. @click="openModal('create')"
  10. v-hasPermi="['system:mail-account:create']"
  11. >
  12. <Icon icon="ep:plus" class="mr-5px" /> 新增
  13. </el-button>
  14. </template>
  15. </Search>
  16. </ContentWrap>
  17. <!-- 列表 -->
  18. <ContentWrap>
  19. <Table
  20. :columns="allSchemas.tableColumns"
  21. :data="tableObject.tableList"
  22. :loading="tableObject.loading"
  23. :pagination="{
  24. total: tableObject.total
  25. }"
  26. v-model:pageSize="tableObject.pageSize"
  27. v-model:currentPage="tableObject.currentPage"
  28. >
  29. <template #action="{ row }">
  30. <el-button
  31. link
  32. type="primary"
  33. @click="openModal('update', row.id)"
  34. v-hasPermi="['system:mail-account:update']"
  35. >
  36. 编辑
  37. </el-button>
  38. <el-button
  39. link
  40. type="danger"
  41. v-hasPermi="['system:mail-account:delete']"
  42. @click="handleDelete(row.id)"
  43. >
  44. 删除
  45. </el-button>
  46. </template>
  47. </Table>
  48. </ContentWrap>
  49. <!-- 表单弹窗:添加/修改 -->
  50. <MailAccountForm ref="modalRef" @success="getList" />
  51. </template>
  52. <script setup lang="ts" name="MailAccount">
  53. import { allSchemas } from './account.data'
  54. import { useTable } from '@/hooks/web/useTable'
  55. import * as MailAccountApi from '@/api/system/mail/account'
  56. import MailAccountForm from './form.vue'
  57. // https://kailong110120130.gitee.io/vue-element-plus-admin-doc/components/table.html#usetable
  58. // tableObject:表格的属性对象,可获得分页大小、条数等属性
  59. // tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
  60. const { tableObject, tableMethods } = useTable({
  61. getListApi: MailAccountApi.getMailAccountPage, // 分页接口
  62. delListApi: MailAccountApi.deleteMailAccount // 删除接口
  63. })
  64. // 获得表格的各种操作
  65. const { getList, setSearchParams } = tableMethods
  66. /** 添加/修改操作 */
  67. const modalRef = ref()
  68. const openModal = (type: string, id?: number) => {
  69. modalRef.value.openModal(type, id)
  70. }
  71. /** 删除按钮操作 */
  72. const handleDelete = (id: number) => {
  73. tableMethods.delList(id, false)
  74. }
  75. /** 初始化 **/
  76. onMounted(() => {
  77. getList()
  78. })
  79. </script>