import { Component } from '@angular/core'; import { CommonModule, DatePipe, JsonPipe } from '@angular/common'; // NG-ZORRO 组件 import { NzDescriptionsModule } from 'ng-zorro-antd/descriptions'; import { NzTagModule } from 'ng-zorro-antd/tag'; import { NzSwitchModule } from 'ng-zorro-antd/switch'; // 类型 import { IMessageRecord } from '../services/message.service'; import { NzModalRef } from 'ng-zorro-antd/modal'; @Component({ selector: 'app-message-record-detail', standalone: true, imports: [ CommonModule, NzDescriptionsModule, NzTagModule, NzSwitchModule, DatePipe, JsonPipe, ], template: ` {{ record.uid }} {{ record.cc }}
@if(record.activityName) {
活动: {{ record.activityName }}
} @if(record.strategyName) {
策略: {{ record.strategyName }}
} @if(record.templateName) {
模板: {{ record.templateName }}
}
{{ record.title }} {{ record.content }} {{ getStatusName(record.status) }} {{ record.image || '' }} {{ record.bigger }} {{ record.action || '' }} {{ record.param || '' }}
{{ record.extend ? (record.extend | json) : '无' }}
{{ record.errno || '' }} {{ record.fcmReceipt || '' }} {{ record.plannedSendAt | date : 'yyyy-MM-dd HH:mm:ss' }} {{ record.actualSendAt | date : 'yyyy-MM-dd HH:mm:ss' }} {{ record.deliveredAt | date : 'yyyy-MM-dd HH:mm:ss' }} {{ record.openedAt | date : 'yyyy-MM-dd HH:mm:ss' }} @if(record.deliveredAt) { {{ record.inforeground ? '在前台' : '在后台' }} } {{ record.createdAt | date : 'yyyy-MM-dd HH:mm:ss' }} {{ record.updatedAt | date : 'yyyy-MM-dd HH:mm:ss' }}
`, styles: [ ` pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; } .source-item { display: flex; flex-direction: column; gap: 4px; } .source-item div { line-height: 1.5; } `, ], }) export class MessageRecordDetailComponent { record: IMessageRecord; constructor(private modalRef: NzModalRef) { this.record = this.modalRef.getConfig().nzData?.record; } getStatusName(status: number): string { const statuses: Record = { 0: '未发送', 1: '发送成功', 2: '已送达', 3: '已打开', [-1]: '发送失败', }; return statuses[status] || '未知状态'; } getStatusColor(status: number): string { const colors: Record = { 0: 'default', 1: 'processing', 2: 'success', 3: 'green', [-1]: 'error', }; return colors[status] || 'default'; } }