message-activity.component.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <nz-page-header [nzGhost]="false">
  2. <nz-page-header-title>消息活动管理</nz-page-header-title>
  3. <nz-page-header-extra>
  4. <button nz-button nzType="primary" (click)="showCreateModal()">
  5. <span nz-icon nzType="plus"></span>新建活动
  6. </button>
  7. </nz-page-header-extra>
  8. <nz-page-header-content>
  9. 管理消息推送活动,包括定时推送、周期性推送和定向推送
  10. </nz-page-header-content>
  11. </nz-page-header>
  12. <nz-card>
  13. <nz-spin [nzSpinning]="isLoading">
  14. <nz-table
  15. #activitiesTable
  16. [nzData]="activities"
  17. [nzLoading]="isLoading"
  18. [nzFrontPagination]="false"
  19. [nzBordered]="true"
  20. [nzSize]="'small'"
  21. [nzShowPagination]="false"
  22. >
  23. <thead>
  24. <tr>
  25. <th>活动名称</th>
  26. <th>消息模板</th>
  27. <th>推送策略</th>
  28. <th>计划时间</th>
  29. <th>每日推送</th>
  30. <th>状态</th>
  31. <th>创建时间</th>
  32. <th>更新时间</th>
  33. <th>操作</th>
  34. </tr>
  35. </thead>
  36. <tbody>
  37. @for (activity of activitiesTable.data; track activity._id) {
  38. <tr>
  39. <td>
  40. <a (click)="showDetailModal(activity)">{{ activity.name }}</a>
  41. </td>
  42. <td>
  43. <a
  44. [routerLink]="['/message-template']"
  45. [queryParams]="{
  46. templateName: getTemplateName(activity.templateId)
  47. }"
  48. >
  49. {{ getTemplateName(activity.templateId) }}
  50. </a>
  51. </td>
  52. <td>
  53. <nz-tag [nzColor]="getStrategyColor(activity.strategy)">
  54. {{ getStrategyName(activity.strategy) }}
  55. </nz-tag>
  56. </td>
  57. <td>{{ activity.scheduleAt | date : "yyyy-MM-dd HH:mm" }}</td>
  58. <td>
  59. <nz-switch
  60. [ngModel]="activity.everyday"
  61. [nzDisabled]="true"
  62. ></nz-switch>
  63. </td>
  64. <td>
  65. <nz-tag [nzColor]="getStatusColor(activity.status)">
  66. {{ getStatusName(activity.status) }}
  67. </nz-tag>
  68. </td>
  69. <td>{{ activity.createdAt | date : "yyyy-MM-dd HH:mm" }}</td>
  70. <td>{{ activity.updatedAt | date : "yyyy-MM-dd HH:mm" }}</td>
  71. <td>
  72. <a (click)="showEditModal(activity)">编辑</a>
  73. <nz-divider nzType="vertical"></nz-divider>
  74. <!-- 状态变更操作 -->
  75. @if (activity.status === 0) {
  76. <a
  77. nz-popconfirm
  78. nzPopconfirmTitle="确定要发布此活动吗?"
  79. nzPopconfirmOkText="确定"
  80. nzPopconfirmCancelText="取消"
  81. (nzOnConfirm)="publishActivity(activity._id)"
  82. >
  83. 发布
  84. </a>
  85. } @if (activity.status === 1) {
  86. <a
  87. nz-popconfirm
  88. nzPopconfirmTitle="确定要发布此活动吗?"
  89. nzPopconfirmOkText="确定"
  90. nzPopconfirmCancelText="取消"
  91. (nzOnConfirm)="publishActivity(activity._id)"
  92. >
  93. 发布
  94. </a>
  95. <a
  96. nzDanger
  97. nz-popconfirm
  98. nzPopconfirmTitle="确定要中止此活动吗?"
  99. nzPopconfirmOkText="确定"
  100. nzPopconfirmCancelText="取消"
  101. (nzOnConfirm)="abortActivity(activity._id)"
  102. >
  103. 中止
  104. </a>
  105. }
  106. <nz-divider nzType="vertical"></nz-divider>
  107. <a
  108. nzDanger
  109. nz-popconfirm
  110. nzPopconfirmTitle="确定要删除此活动吗?"
  111. nzPopconfirmOkText="确定"
  112. nzPopconfirmCancelText="取消"
  113. (nzOnConfirm)="deleteActivity(activity._id)"
  114. >
  115. 删除
  116. </a>
  117. </td>
  118. </tr>
  119. }
  120. </tbody>
  121. </nz-table>
  122. <nz-empty
  123. *ngIf="activities.length === 0 && !isLoading"
  124. nzNotFoundContent="暂无消息活动"
  125. ></nz-empty>
  126. </nz-spin>
  127. </nz-card>
  128. <!-- 创建/编辑活动模态框 -->
  129. <nz-modal
  130. [(nzVisible)]="isModalVisible"
  131. [nzTitle]="isEditMode ? '编辑消息活动' : '新建消息活动'"
  132. [nzOkText]="isEditMode ? '更新' : '创建'"
  133. [nzCancelText]="'取消'"
  134. (nzOnCancel)="handleCancel()"
  135. (nzOnOk)="handleOk()"
  136. [nzOkLoading]="isSubmitting"
  137. [nzWidth]="800"
  138. >
  139. <form nz-form [formGroup]="activityForm" *nzModalContent>
  140. <nz-form-item>
  141. <nz-form-label nzRequired>活动名称</nz-form-label>
  142. <nz-form-control>
  143. <input
  144. nz-input
  145. formControlName="name"
  146. placeholder="输入活动名称(内部使用,不可重复)"
  147. />
  148. </nz-form-control>
  149. </nz-form-item>
  150. <nz-form-item>
  151. <nz-form-label>活动描述</nz-form-label>
  152. <nz-form-control>
  153. <textarea
  154. nz-input
  155. rows="4"
  156. formControlName="description"
  157. placeholder="输入活动描述"
  158. >
  159. </textarea>
  160. </nz-form-control>
  161. </nz-form-item>
  162. <nz-form-item>
  163. <nz-form-label nzRequired>消息模板</nz-form-label>
  164. <nz-form-control>
  165. <nz-select
  166. formControlName="templateId"
  167. nzPlaceHolder="选择关联的消息模板"
  168. nzShowSearch
  169. nzAllowClear
  170. nzOptionFilterProp="label"
  171. >
  172. @for (template of templates; track template._id) {
  173. <nz-option
  174. [nzLabel]="template.templateName"
  175. [nzValue]="template._id"
  176. ></nz-option>
  177. }
  178. </nz-select>
  179. </nz-form-control>
  180. </nz-form-item>
  181. <nz-form-item>
  182. <nz-form-label>通知图片</nz-form-label>
  183. <nz-form-control>
  184. <input
  185. nz-input
  186. formControlName="image"
  187. placeholder="输入通知图片URL(可选)"
  188. />
  189. @if (activityForm.get('image')?.value) {
  190. <div style="margin-top: 8px">
  191. <img
  192. [src]="activityForm.get('image')?.value"
  193. style="max-width: 100px; max-height: 100px"
  194. onerror="this.style.display='none'"
  195. />
  196. </div>
  197. }
  198. </nz-form-control>
  199. </nz-form-item>
  200. <nz-form-item>
  201. <nz-form-label>允许展开</nz-form-label>
  202. <nz-form-control>
  203. <nz-switch formControlName="bigger"></nz-switch>
  204. <span nz-typography nzType="secondary">(有图片时有效)</span>
  205. </nz-form-control>
  206. </nz-form-item>
  207. <nz-form-item>
  208. <nz-form-label>客户端行为</nz-form-label>
  209. <nz-form-control>
  210. <nz-select
  211. formControlName="action"
  212. nzPlaceHolder="选择客户端行为"
  213. (ngModelChange)="onActionChange($event)"
  214. >
  215. @for (action of getActionOptions(); track action.value) {
  216. <nz-option
  217. [nzLabel]="action.label"
  218. [nzValue]="action.value"
  219. ></nz-option>
  220. }
  221. </nz-select>
  222. </nz-form-control>
  223. </nz-form-item>
  224. @if (showParamField()) {
  225. <nz-form-item>
  226. <nz-form-label>参数</nz-form-label>
  227. <nz-form-control>
  228. <input
  229. nz-input
  230. formControlName="param"
  231. [placeholder]="getParamPlaceholder()"
  232. />
  233. </nz-form-control>
  234. </nz-form-item>
  235. }
  236. <nz-form-item>
  237. <nz-form-label>扩展参数</nz-form-label>
  238. <nz-form-control>
  239. <input
  240. nz-input
  241. formControlName="extend"
  242. placeholder="输入扩展参数(可选)"
  243. />
  244. </nz-form-control>
  245. </nz-form-item>
  246. <nz-form-item>
  247. <nz-form-label>推送策略</nz-form-label>
  248. <nz-form-control>
  249. <nz-select
  250. formControlName="strategy"
  251. nzPlaceHolder="选择推送策略"
  252. [nzAllowClear]="true"
  253. >
  254. <nz-option nzValue="0" nzLabel="自定义策略"></nz-option>
  255. <nz-option nzValue="1" nzLabel="活跃用户推送"></nz-option>
  256. <nz-option nzValue="2" nzLabel="新用户推送"></nz-option>
  257. <nz-option nzValue="3" nzLabel="沉默用户唤醒"></nz-option>
  258. </nz-select>
  259. </nz-form-control>
  260. </nz-form-item>
  261. <nz-form-item>
  262. <nz-form-label>计划推送时间</nz-form-label>
  263. <nz-form-control>
  264. <nz-date-picker
  265. formControlName="scheduleAt"
  266. nzShowTime
  267. nzFormat="yyyy-MM-dd HH:mm"
  268. nzPlaceHolder="选择推送时间"
  269. ></nz-date-picker>
  270. </nz-form-control>
  271. </nz-form-item>
  272. <nz-form-item>
  273. <nz-form-label>每日推送</nz-form-label>
  274. <nz-form-control>
  275. <nz-switch formControlName="everyday"></nz-switch>
  276. </nz-form-control>
  277. </nz-form-item>
  278. <!-- 筛选条件面板 -->
  279. <app-filter-panel
  280. [filterConditions]="filterConditions"
  281. [filterFields]="filterFields"
  282. [operatorsMap]="operatorsMap"
  283. [countries]="countries"
  284. [estimatedUserCount]="estimatedUserCount"
  285. [isCountingUsers]="isCountingUsers"
  286. (addConditionEvent)="addCondition()"
  287. (removeConditionEvent)="removeCondition($event)"
  288. (estimateUserCountEvent)="estimateUserCount()"
  289. ></app-filter-panel>
  290. </form>
  291. </nz-modal>
  292. <!-- 活动详情模态框 -->
  293. <app-activity-detail
  294. [activity]="selectedActivity"
  295. [isVisible]="isDetailModalVisible"
  296. [templates]="templates"
  297. (onCancel)="isDetailModalVisible = false"
  298. ></app-activity-detail>