notice.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <script setup lang="ts" name="Notice">
  2. import apis from "@/api"
  3. import appStore from "@s"
  4. const tableRef = ref()
  5. const modalRef = ref()
  6. const opts = reactive({
  7. columns: [
  8. { field: "noticeId", name: "公告公告ID", width: 100, isSort: true, visible: false },
  9. { field: "noticeTitle", name: "公告通知", visible: true },
  10. { field: "noticeType", name: "公告通知类型", visible: true, width: 130 },
  11. { field: "readStatus", name: "是否阅读", visible: true, width: 100 },
  12. { field: "createTime", name: "公告通知时间", visible: true, width: 190 },
  13. { field: "actions", name: `操作`, width: 80 }
  14. ] as any,
  15. queryParams: {
  16. noticeTitle: "",
  17. noticeType: undefined,
  18. status: undefined
  19. },
  20. searchFormItems: [
  21. {
  22. field: "noticeTitle",
  23. label: "通知公告标题",
  24. class: "w-100",
  25. required: false,
  26. placeholder: "请输入通知公告标题",
  27. listeners: {
  28. keyup: (e: KeyboardEvent) => {
  29. if (e.code == "Enter") {
  30. handleQuery()
  31. }
  32. }
  33. }
  34. }
  35. // {
  36. // field: "noticeType",
  37. // label: "公告类型",
  38. // class: "w-100",
  39. // required: false,
  40. // component: "Dict",
  41. // props: {
  42. // placeholder: "请选择公告类型",
  43. // dictType: "sys_notice_type"
  44. // }
  45. // },
  46. // {
  47. // field: "status",
  48. // label: "通知状态",
  49. // class: "w-100",
  50. // required: false,
  51. // component: "Dict",
  52. // props: {
  53. // placeholder: "请选择公告状态",
  54. // dictType: "sys_notice_status"
  55. // }
  56. // }
  57. ] as any,
  58. permission: "",
  59. handleFuns: {
  60. handleRemoveAll
  61. },
  62. customBtns: [
  63. {
  64. key: "handleRemoveAll",
  65. name: "删除全部已读",
  66. icon: "bi bi-dash-square",
  67. btnClass: "btn btn-light-danger",
  68. disabledFun: () => false
  69. }
  70. ],
  71. tableListFun: apis.system.noticeApi.listMyNotice
  72. })
  73. const { queryParams } = toRefs(opts)
  74. /** 搜索按钮操作 */
  75. function handleQuery(query?: any) {
  76. query = query || tableRef.value?.getQueryParams() || queryParams.value
  77. tableRef.value?.query(query)
  78. }
  79. /** 重置按钮操作 */
  80. function resetQuery() {
  81. //
  82. }
  83. const detailData = ref()
  84. function handleRead(row: any) {
  85. if (row.noticeType == "1") {
  86. appStore.noticeStore.readNotice(row)
  87. } else {
  88. detailData.value = row
  89. if (row.readStatus == "1") {
  90. modalRef.value.show()
  91. return
  92. }
  93. apis.system.noticeApi.read(row.noticeId, row.noticeType).then(() => {
  94. modalRef.value.show()
  95. handleQuery()
  96. })
  97. }
  98. }
  99. function handleRemove(row: any) {
  100. apis.system.noticeApi.removeRead(row.noticeId).then(() => {
  101. message.msgSuccess("删除成功")
  102. handleQuery()
  103. })
  104. }
  105. function handleRemoveAll() {
  106. apis.system.noticeApi.removeReadAll().then(() => {
  107. message.msgSuccess("全部已读删除成功")
  108. handleQuery()
  109. })
  110. }
  111. function init() {}
  112. onMounted(init)
  113. </script>
  114. <template>
  115. <div class="app-container">
  116. <VbTable
  117. ref="tableRef"
  118. :handle-perm="opts.permission"
  119. :handle-funs="opts.handleFuns"
  120. :search-form-items="opts.searchFormItems"
  121. :columns="opts.columns"
  122. :custom-btns="opts.customBtns"
  123. :remote-fun="opts.tableListFun"
  124. :modal="modalRef"
  125. v-model:query-params="queryParams"
  126. :url="apis.system.noticeApi.tableUrl"
  127. :check-multiple="true"
  128. :init-search="true"
  129. :reset-search-form-fun="resetQuery"
  130. :custom-search-fun="handleQuery">
  131. <template #noticeTitle="{ row }">
  132. <span v-if="row.noticeType == '1'" class="w-100 text-primary" @click="handleRead(row)">
  133. {{ row.noticeTitle }}
  134. </span>
  135. <span v-else>{{ row.noticeTitle }}</span>
  136. </template>
  137. <template #noticeType="{ row }">
  138. <DictTag type="sys_notice_type" :value="row.noticeType"></DictTag>
  139. </template>
  140. <template #status="{ row }">
  141. <DictTag type="sys_notice_status" :value="row.status"></DictTag>
  142. </template>
  143. <template #readStatus="{ row }">
  144. <DictTag type="sys_notice_read_status" :value="row.readStatus"></DictTag>
  145. </template>
  146. <template #actions="{ row }">
  147. <vb-tooltip content="阅读" placement="top">
  148. <el-button link type="primary" @click="handleRead(row)">
  149. <template #icon>
  150. <VbIcon icon-name="book" icon-type="duotone" class="fs-3"></VbIcon>
  151. </template>
  152. </el-button>
  153. </vb-tooltip>
  154. <vb-tooltip v-if="row.readStatus == '1'" content="删除" placement="top">
  155. <el-button link type="danger" @click="handleRemove(row)">
  156. <template #icon>
  157. <VbIcon icon-name="trash-square" icon-type="duotone" class="fs-3"></VbIcon>
  158. </template>
  159. </el-button>
  160. </vb-tooltip>
  161. </template>
  162. </VbTable>
  163. <VbModal
  164. v-model:modal="modalRef"
  165. title="公告详情"
  166. :confirm-btn="false"
  167. :close-btn-class="'btn btn-danger'"
  168. append-to-body>
  169. <template #body>
  170. <div v-if="detailData" class="d-flex flex-column">
  171. <div class="fw-bold text-center my-3">{{ detailData.noticeTitle }}</div>
  172. <div v-html="detailData.noticeContent"></div>
  173. </div>
  174. </template>
  175. </VbModal>
  176. </div>
  177. </template>