index.vue 2.9 KB

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