index.vue 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. <DictTag :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 { DICT_TYPE } from '@/utils/dict'
  50. import { allSchemas } from './log.data'
  51. import * as MailLogApi from '@/api/system/mail/log'
  52. import * as MailAccountApi from '@/api/system/mail/account'
  53. const { t } = useI18n() // 国际化
  54. // 列表相关的变量
  55. const queryParams = reactive({
  56. accountId: null
  57. })
  58. const [registerTable] = useXTable({
  59. allSchemas: allSchemas,
  60. params: queryParams,
  61. getListApi: MailLogApi.getMailLogPageApi
  62. })
  63. const accountOptions = ref<any[]>([]) // 账号下拉选项
  64. // 弹窗相关的变量
  65. const modelVisible = ref(false) // 是否显示弹出层
  66. const modelTitle = ref('edit') // 弹出层标题
  67. const modelLoading = ref(false) // 弹出层loading
  68. const actionType = ref('') // 操作按钮的类型
  69. const actionLoading = ref(false) // 按钮 Loading
  70. const detailData = ref() // 详情 Ref
  71. // 设置标题
  72. const setDialogTile = (type: string) => {
  73. modelLoading.value = true
  74. modelTitle.value = t('action.' + type)
  75. actionType.value = type
  76. modelVisible.value = true
  77. }
  78. // 详情操作
  79. const handleDetail = async (rowId: number) => {
  80. setDialogTile('detail')
  81. const res = await MailLogApi.getMailLogApi(rowId)
  82. detailData.value = res
  83. modelLoading.value = false
  84. }
  85. // ========== 初始化 ==========
  86. onMounted(() => {
  87. MailAccountApi.getSimpleMailAccounts().then((data) => {
  88. accountOptions.value = data
  89. })
  90. })
  91. </script>