index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <XTable @register="registerTable">
  5. <template #accountId_search>
  6. <el-select v-model="queryParams.accountId">
  7. <el-option :key="undefined" label="全部" :value="undefined" />
  8. <el-option
  9. v-for="item in accountOptions"
  10. :key="item.id"
  11. :label="item.mail"
  12. :value="item.id"
  13. />
  14. </el-select>
  15. </template>
  16. <template #toMail_default="{ row }">
  17. <div>{{ row.toMail }}</div>
  18. <div v-if="row.userType && row.userId">
  19. <dict-tag :type="DICT_TYPE.USER_TYPE" :value="row.userType" />{{ '(' + row.userId + ')' }}
  20. </div>
  21. </template>
  22. <template #actionbtns_default="{ row }">
  23. <!-- 操作:详情 -->
  24. <XTextButton
  25. preIcon="ep:view"
  26. :title="t('action.detail')"
  27. v-hasPermi="['system:mail-log:query']"
  28. @click="handleDetail(row.id)"
  29. />
  30. </template>
  31. </XTable>
  32. </ContentWrap>
  33. <!-- 弹窗 -->
  34. <XModal id="mailLogModel" :loading="modelLoading" v-model="modelVisible" :title="modelTitle">
  35. <!-- 表单:详情 -->
  36. <Descriptions
  37. v-if="actionType === 'detail'"
  38. :schema="allSchemas.detailSchema"
  39. :data="detailData"
  40. />
  41. <template #footer>
  42. <!-- 按钮:关闭 -->
  43. <XButton :loading="actionLoading" :title="t('dialog.close')" @click="modelVisible = false" />
  44. </template>
  45. </XModal>
  46. </template>
  47. <script setup lang="ts" name="MailLog">
  48. // 业务相关的 import
  49. import { allSchemas } from './log.data'
  50. import * as MailLogApi from '@/api/system/mail/log'
  51. import * as MailAccountApi from '@/api/system/mail/account'
  52. const { t } = useI18n() // 国际化
  53. // 列表相关的变量
  54. const queryParams = reactive({
  55. accountId: null
  56. })
  57. const [registerTable] = useXTable({
  58. allSchemas: allSchemas,
  59. params: queryParams,
  60. getListApi: MailLogApi.getMailLogPageApi
  61. })
  62. const accountOptions = ref([]) // 账号下拉选项
  63. // 弹窗相关的变量
  64. const modelVisible = ref(false) // 是否显示弹出层
  65. const modelTitle = ref('edit') // 弹出层标题
  66. const modelLoading = ref(false) // 弹出层loading
  67. const actionType = ref('') // 操作按钮的类型
  68. const actionLoading = ref(false) // 按钮 Loading
  69. const detailData = ref() // 详情 Ref
  70. // 设置标题
  71. const setDialogTile = (type: string) => {
  72. modelLoading.value = true
  73. modelTitle.value = t('action.' + type)
  74. actionType.value = type
  75. modelVisible.value = true
  76. }
  77. // 详情操作
  78. const handleDetail = async (rowId: number) => {
  79. setDialogTile('detail')
  80. const res = await MailLogApi.getMailLogApi(rowId)
  81. detailData.value = res
  82. modelLoading.value = false
  83. }
  84. // ========== 初始化 ==========
  85. onMounted(() => {
  86. MailAccountApi.getSimpleMailAccounts().then((data) => {
  87. accountOptions.value = data
  88. })
  89. })
  90. </script>