systemNotificationTable.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <SearchBar />
  3. <el-button
  4. type="primary"
  5. @click="createNotification"
  6. style="margin-top: 24px; margin-bottom: 16px; width: 138px"
  7. >
  8. <img src="../img/create.png" style="margin-top: -1px; margin-right: 5px" />新建系统通知
  9. </el-button>
  10. <el-table
  11. :data="sysNotionData"
  12. stripe
  13. height="calc(100vh - 400px)"
  14. style="width: 100%; margin-top: 16px; --el-table-border-color: none"
  15. >
  16. <el-table-column prop="title" label="消息标题" />
  17. <el-table-column width="300" prop="pushChannel" label="推送渠道">
  18. <template #default="scope">
  19. <div>
  20. {{ scope.row.pushChannel.map((channel) => pushChannelMapping[channel]).join(',') }}
  21. </div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column width="200" prop="recipientType" label="推送对象">
  25. <template #default="scope">
  26. <div>
  27. {{ recipientTypeMapping[scope.row.recipientType] }}
  28. </div>
  29. </template>
  30. </el-table-column>
  31. <el-table-column width="135" prop="status" label="推送状态">
  32. <template #default="scope">
  33. <img src="../img//prepareToPush.png" alt="" v-if="scope.row.status === 0" />
  34. <img src="../img/completed.png" alt="" v-else />
  35. </template>
  36. </el-table-column>
  37. <el-table-column prop="pushAt" label="推送时间" width="200px" />
  38. <el-table-column label="操作" fixed="right" width="120px">
  39. <template #default="scope">
  40. <div class="operation">
  41. <el-tooltip effect="light" content="查看" placement="bottom">
  42. <img src="@/views/message/alarmMessages/img/view.png" @click="handleView(scope.row.id, 'view')" />
  43. </el-tooltip>
  44. <el-tooltip class="box-item" effect="light" content="编辑" placement="bottom" v-if="scope.row.status === PushStatusEnum.PEDDING">
  45. <img src="@/views/message/alarmMessages/img/edit.png" @click="handleView(scope.row.id, 'edit')" />
  46. </el-tooltip>
  47. <el-tooltip effect="light" content="删除" placement="bottom">
  48. <img src="@/views/message/alarmMessages/img/delete.png" @click="handleDelete(scope.row.id)" />
  49. </el-tooltip>
  50. </div>
  51. </template>
  52. </el-table-column>
  53. <template #empty>
  54. <div class="emptyDiv">
  55. <img src="../img/empty.png" class="emptyImg" />
  56. <span class="emptySpan">暂无数据</span>
  57. </div>
  58. </template>
  59. </el-table>
  60. <div class="pagination" v-if="total != 0">
  61. <el-pagination
  62. :page-sizes="[10, 20, 30, 40, 50, 80]"
  63. :small="false"
  64. :background="true"
  65. layout="total, sizes, prev, pager, next, jumper"
  66. :total="total"
  67. @size-change="handleSizeChange"
  68. @current-change="handleCurrentChange"
  69. />
  70. </div>
  71. <el-dialog v-model="deleteDialog" width="424px" top="20%" class="deleteDialog">
  72. <template #header="">
  73. <div class="deleteDialogHeader">
  74. <img src="../img/deleteTip.png" class="deleteTip" />
  75. <span class="titleSpan">请确认是否删除</span>
  76. </div>
  77. </template>
  78. <span style="margin-left: 37px">删除之后,该条数据将无法恢复</span>
  79. <div class="dialogBottom">
  80. <el-button class="dialogBtn" @click="deleteDialog = false">取消</el-button>
  81. <el-button class="dialogBtn" type="primary" @click="confirmDelete">确定</el-button>
  82. </div>
  83. </el-dialog>
  84. </template>
  85. <script lang="ts" setup>
  86. import { ref, onMounted } from 'vue';
  87. import { useRouter } from 'vue-router';
  88. import { pushChannelMapping, recipientTypeMapping, PushStatusEnum } from '../type';
  89. import SearchBar from './SearchBar.vue';
  90. import { storeToRefs } from 'pinia';
  91. import useSysNotion from '../store/index';
  92. import { deleteSystemMessage } from '@/api/message/system-notifications';
  93. import { ElMessage } from 'element-plus';
  94. const sysNotion = useSysNotion();
  95. const { total, page, pagesize, sysNotionData } = storeToRefs(sysNotion);
  96. const { getSysNotion } = sysNotion;
  97. const deleteDialog = ref(false);
  98. const router = useRouter();
  99. type ViewModel = 'view' | 'edit';
  100. const createNotification = () => {
  101. router.push('/message/sys-notification-config');
  102. };
  103. const handleView = (id: number, model: ViewModel ) => {
  104. router.push(`/message/sys-notification-config?id=${id}&viewModel=${model}`);
  105. };
  106. const deleteId = ref<number>(0);
  107. const handleDelete = (id: number) => {
  108. deleteDialog.value = true;
  109. deleteId.value = id;
  110. };
  111. const confirmDelete = () => {
  112. deleteSystemMessage(deleteId.value).then(() => {
  113. ElMessage({
  114. message: '删除成功',
  115. type: 'success',
  116. plain: true,
  117. });
  118. deleteDialog.value = false;
  119. getSysNotion();
  120. });
  121. };
  122. const handleSizeChange = (newPageSize: number) => {
  123. pagesize.value = newPageSize;
  124. getSysNotion();
  125. };
  126. const handleCurrentChange = (newCurrentPage: number) => {
  127. page.value = newCurrentPage;
  128. getSysNotion();
  129. };
  130. onMounted(() => {
  131. getSysNotion();
  132. });
  133. </script>
  134. <style lang="scss" scoped>
  135. .pagination {
  136. position: absolute;
  137. bottom: 35px;
  138. right: 67px;
  139. }
  140. .deleteDialog {
  141. .deleteDialogHeader {
  142. display: flex;
  143. .deleteTip {
  144. height: 24px;
  145. width: 24px;
  146. }
  147. .titleSpan {
  148. height: 24px;
  149. font-size: 16px;
  150. color: rgba(0, 0, 0, 0.88);
  151. line-height: 24px;
  152. text-align: center;
  153. margin-left: 12px;
  154. }
  155. }
  156. .dialogBottom {
  157. display: flex;
  158. justify-content: flex-end;
  159. margin-top: 12px;
  160. }
  161. }
  162. .operation {
  163. display: flex;
  164. img + img {
  165. margin-left: 20px;
  166. }
  167. button {
  168. margin-: 20px;
  169. }
  170. }
  171. .emptyDiv {
  172. margin-top: 78px;
  173. margin: auto;
  174. width: 396px;
  175. .emptyImg {
  176. height: 257px;
  177. }
  178. .emptySpan {
  179. font-family: PingFangSC, PingFang SC;
  180. font-weight: 400;
  181. font-size: 18px;
  182. color: rgba(0, 0, 0, 0.45);
  183. text-align: left;
  184. font-style: normal;
  185. }
  186. }
  187. :deep(.el-dialog) {
  188. border-radius: 8px;
  189. }
  190. .pushstatus {
  191. display: flex;
  192. justify-content: center;
  193. width: 100%;
  194. }
  195. </style>