systemNotificationTable.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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="../img/view.png" @click="handleView(scope.row.id)" />
  43. </el-tooltip>
  44. <el-tooltip effect="light" content="删除" placement="bottom">
  45. <img src="../img/delete.png" @click="handleDelete(scope.row.id)" />
  46. </el-tooltip>
  47. </div>
  48. </template>
  49. </el-table-column>
  50. <template #empty>
  51. <div class="emptyDiv">
  52. <img src="../img/empty.png" class="emptyImg" />
  53. <span class="emptySpan">暂无数据</span>
  54. </div>
  55. </template>
  56. </el-table>
  57. <div class="pagination" v-if="total != 0">
  58. <el-pagination
  59. :page-sizes="[10, 20, 30, 40, 50, 80]"
  60. :small="false"
  61. :background="true"
  62. layout="total, sizes, prev, pager, next, jumper"
  63. :total="total"
  64. @size-change="handleSizeChange"
  65. @current-change="handleCurrentChange"
  66. />
  67. </div>
  68. <el-dialog v-model="deleteDialog" width="424px" top="20%" class="deleteDialog">
  69. <template #header="">
  70. <div class="deleteDialogHeader">
  71. <img src="../img/deleteTip.png" class="deleteTip" />
  72. <span class="titleSpan">请确认是否删除</span>
  73. </div>
  74. </template>
  75. <span style="margin-left: 37px">删除之后,该条数据将无法恢复</span>
  76. <div class="dialogBottom">
  77. <el-button class="dialogBtn" @click="deleteDialog = false">取消</el-button>
  78. <el-button class="dialogBtn" type="primary" @click="confirmDelete">确定</el-button>
  79. </div>
  80. </el-dialog>
  81. </template>
  82. <script lang="ts" setup>
  83. import { ref, onMounted } from 'vue';
  84. import { useRouter } from 'vue-router';
  85. import { pushChannelMapping, recipientTypeMapping } from '../type';
  86. import SearchBar from './SearchBar.vue';
  87. import { storeToRefs } from 'pinia';
  88. import useSysNotion from '../store/index';
  89. import { deleteSystemMessage } from '@/api/message/system-notifications';
  90. import { ElMessage } from 'element-plus';
  91. const sysNotion = useSysNotion();
  92. const { total, page, pagesize, sysNotionData } = storeToRefs(sysNotion);
  93. const { getSysNotion } = sysNotion;
  94. const deleteDialog = ref(false);
  95. const router = useRouter();
  96. const createNotification = () => {
  97. router.push('/message/sysnotion-config');
  98. };
  99. const handleView = (id: number) => {
  100. router.push(`/message/sysnotion-config?id=${id}`);
  101. };
  102. const deleteId = ref<number>(0);
  103. const handleDelete = (id: number) => {
  104. deleteDialog.value = true;
  105. deleteId.value = id;
  106. };
  107. const confirmDelete = () => {
  108. deleteSystemMessage(deleteId.value).then(() => {
  109. ElMessage({
  110. message: '删除成功',
  111. type: 'success',
  112. plain: true,
  113. });
  114. deleteDialog.value = false;
  115. getSysNotion();
  116. });
  117. };
  118. const handleSizeChange = (newPageSize: number) => {
  119. pagesize.value = newPageSize;
  120. getSysNotion();
  121. };
  122. const handleCurrentChange = (newCurrentPage: number) => {
  123. page.value = newCurrentPage;
  124. getSysNotion();
  125. };
  126. onMounted(() => {
  127. getSysNotion();
  128. });
  129. </script>
  130. <style lang="scss" scoped>
  131. .pagination {
  132. position: absolute;
  133. bottom: 35px;
  134. right: 67px;
  135. }
  136. .deleteDialog {
  137. .deleteDialogHeader {
  138. display: flex;
  139. .deleteTip {
  140. height: 24px;
  141. width: 24px;
  142. }
  143. .titleSpan {
  144. height: 24px;
  145. font-size: 16px;
  146. color: rgba(0, 0, 0, 0.88);
  147. line-height: 24px;
  148. text-align: center;
  149. margin-left: 12px;
  150. }
  151. }
  152. .dialogBottom {
  153. display: flex;
  154. justify-content: flex-end;
  155. margin-top: 12px;
  156. }
  157. }
  158. .operation {
  159. display: flex;
  160. img + img {
  161. margin-left: 20px;
  162. }
  163. }
  164. .emptyDiv {
  165. margin-top: 78px;
  166. margin: auto;
  167. width: 396px;
  168. .emptyImg {
  169. height: 257px;
  170. }
  171. .emptySpan {
  172. font-family: PingFangSC, PingFang SC;
  173. font-weight: 400;
  174. font-size: 18px;
  175. color: rgba(0, 0, 0, 0.45);
  176. text-align: left;
  177. font-style: normal;
  178. }
  179. }
  180. :deep(.el-dialog) {
  181. border-radius: 8px;
  182. }
  183. .pushstatus {
  184. display: flex;
  185. justify-content: center;
  186. width: 100%;
  187. }
  188. </style>