systemNotificationTable.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. :cell-style="{ textAlign: 'center' }"
  15. :header-cell-style="{ 'text-align': 'center' }"
  16. style="width: 100%; margin-top: 16px; --el-table-border-color: none"
  17. >
  18. <el-table-column width="380" prop="title" label="消息标题" />
  19. <el-table-column width="200" prop="pushChannel" label="推送渠道">
  20. <template #default="scope">
  21. <div>
  22. {{ scope.row.pushChannel.map((channel) => pushChannelMapping[channel]).join(',') }}
  23. </div>
  24. </template>
  25. </el-table-column>
  26. <el-table-column width="200" prop="recipientType" label="推送对象">
  27. <template #default="scope">
  28. <div>
  29. {{ recipientTypeMapping[scope.row.recipientType] }}
  30. </div>
  31. </template>
  32. </el-table-column>
  33. <el-table-column width="135" prop="status" label="推送状态">
  34. <template #default="scope">
  35. <div class="pushstatus" v-if="scope.row.status === 0"
  36. ><img src="../img//prepareToPush.png" alt=""
  37. /></div>
  38. <div class="pushstatus" v-else><img src="../img/completed.png" alt="" /></div>
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="pushAt" label="推送时间" />
  42. <el-table-column label="操作" fixed="right">
  43. <template #default="scope">
  44. <div class="operation">
  45. <el-tooltip class="box-item" effect="light" content="查看" placement="bottom">
  46. <img src="../img/view.png" @click="handleView(scope.row.id)" />
  47. </el-tooltip>
  48. <el-tooltip class="box-item" effect="light" content="删除" placement="bottom">
  49. <img src="../img/delete.png" @click="handleDelete(scope.row.id)" />
  50. </el-tooltip>
  51. </div>
  52. </template>
  53. </el-table-column>
  54. <template #empty>
  55. <div class="emptyDiv">
  56. <img src="../img/empty.png" class="emptyImg" />
  57. <span class="emptySpan">暂无数据</span>
  58. </div>
  59. </template>
  60. </el-table>
  61. <div class="pagination" v-if="total != 0">
  62. <el-pagination
  63. :page-sizes="[10, 20, 30, 40, 50, 80]"
  64. :small="false"
  65. :background="true"
  66. layout="total, sizes, prev, pager, next, jumper"
  67. :total="total"
  68. @size-change="handleSizeChange"
  69. @current-change="handleCurrentChange"
  70. />
  71. </div>
  72. <el-dialog v-model="deleteDialog" width="424px" top="20%" class="deleteDialog">
  73. <template #header="">
  74. <div class="deleteDialogHeader">
  75. <img src="../img/deleteTip.png" class="deleteTip" />
  76. <span class="titleSpan">请确认是否删除</span>
  77. </div>
  78. </template>
  79. <span style="margin-left: 37px">删除之后,该条数据将无法恢复</span>
  80. <div class="dialogBottom">
  81. <el-button class="dialogBtn" @click="deleteDialog = false">取消</el-button>
  82. <el-button class="dialogBtn" type="primary" @click="confirmDelete">确定</el-button>
  83. </div>
  84. </el-dialog>
  85. </template>
  86. <script lang="ts" setup>
  87. import { ref, onMounted } from 'vue';
  88. import { useRouter } from 'vue-router';
  89. import { pushChannelMapping, recipientTypeMapping, pushStatusMapping } from '../type';
  90. import SearchBar from './SearchBar.vue';
  91. import { storeToRefs } from 'pinia';
  92. import useSysNotion from '../store/index';
  93. import { deleteSystemMessage } from '../api/index';
  94. import { ElMessage } from 'element-plus';
  95. const sysNotion = useSysNotion();
  96. const { total, page, pagesize, sysNotionData } = storeToRefs(sysNotion);
  97. const { getSysNotion } = sysNotion;
  98. const deleteDialog = ref(false);
  99. const router = useRouter();
  100. const createNotification = () => {
  101. router.push('/message/sysnotion-config');
  102. };
  103. const handleView = (id: number) => {
  104. router.push(`/message/sysnotion-config?id=${id}`);
  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. justify-content: center;
  165. /* :first-child {
  166. margin-right: 20px;
  167. } */
  168. :nth-child(2) {
  169. margin-left: 20px;
  170. }
  171. }
  172. .emptyDiv {
  173. margin-top: 78px;
  174. margin: auto;
  175. width: 396px;
  176. .emptyImg {
  177. height: 257px;
  178. }
  179. .emptySpan {
  180. font-family: PingFangSC, PingFang SC;
  181. font-weight: 400;
  182. font-size: 18px;
  183. color: rgba(0, 0, 0, 0.45);
  184. text-align: left;
  185. font-style: normal;
  186. }
  187. }
  188. :deep(.el-dialog) {
  189. border-radius: 8px;
  190. }
  191. .pushstatus {
  192. display: flex;
  193. justify-content: center;
  194. width: 100%;
  195. }
  196. </style>