index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <div class="filter-container">
  5. <el-form
  6. label-width="100px"
  7. class="ele-form-search"
  8. @keyup.enter.native="reload"
  9. @submit.native.prevent
  10. >
  11. <el-row :gutter="15">
  12. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  13. <el-form-item label="状态:" prop="readStatus">
  14. <el-select
  15. style="width: 100%"
  16. v-model="params.readStatus"
  17. placeholder="请选择状态"
  18. clearable
  19. >
  20. <el-option :value="1" label="已读"></el-option>
  21. <el-option :value="0" label="未读"></el-option>
  22. </el-select>
  23. </el-form-item>
  24. </el-col>
  25. <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
  26. <el-form-item label="发送时间:" prop="createTime">
  27. <el-date-picker
  28. v-model="params.createTime"
  29. style="width: 100%"
  30. value-format="yyyy-MM-dd HH:mm:ss"
  31. type="daterange"
  32. range-separator="-"
  33. start-placeholder="开始日期"
  34. end-placeholder="结束日期"
  35. :default-time="['00:00:00', '23:59:59']"
  36. />
  37. </el-form-item>
  38. </el-col>
  39. <el-col
  40. v-bind="styleResponsive ? { lg: 12, md: 24 } : { span: 12 }"
  41. >
  42. <div class="ele-form-actions">
  43. <el-button
  44. type="primary"
  45. icon="el-icon-search"
  46. class="ele-btn-icon"
  47. @click="reload('search')"
  48. >
  49. 查询
  50. </el-button>
  51. <el-button @click="reload('reset')">重置</el-button>
  52. </div>
  53. </el-col>
  54. </el-row>
  55. </el-form>
  56. </div>
  57. <ele-pro-table ref="table" :columns="columns" :datasource="datasource">
  58. <!-- <template v-slot:templateContent="{ row }">
  59. <el-link type="primary" :underline="false" @click="goDetail(row)">
  60. {{ row.templateContent }}
  61. </el-link>
  62. </template> -->
  63. <!-- 操作列 -->
  64. <template v-slot:action="{ row }">
  65. <el-link
  66. type="primary"
  67. :underline="false"
  68. icon="el-icon-view"
  69. v-if="!row.readStatus"
  70. @click="handleAddOrEdit(row)"
  71. >
  72. 已读
  73. </el-link>
  74. <el-link
  75. type="primary"
  76. :underline="false"
  77. icon="el-icon-view"
  78. v-if="row.formPath"
  79. @click="handleAddOrEdit(row, row.formPath)"
  80. >
  81. 处理
  82. </el-link>
  83. </template>
  84. <template v-slot:readStatus="{ row }">
  85. <el-tag v-if="row.readStatus" type="success">{{ '已读' }}</el-tag>
  86. <el-tag v-else type="danger">{{ '未读' }}</el-tag>
  87. </template>
  88. </ele-pro-table>
  89. </el-card>
  90. </div>
  91. </template>
  92. <script>
  93. import {
  94. notifyMessagePageAPI,
  95. updateNotifyMessageReadByIdAPI
  96. } from '@/api/bpm/task';
  97. import { mapGetters } from 'vuex';
  98. export default {
  99. data() {
  100. return {
  101. addOrEditDialogFlag: false,
  102. params: {
  103. createTime: null,
  104. readStatus: null
  105. },
  106. columns: [
  107. {
  108. columnKey: 'index',
  109. label: '序号',
  110. type: 'index',
  111. width: 55,
  112. align: 'center',
  113. showOverflowTooltip: true,
  114. fixed: 'left'
  115. },
  116. {
  117. prop: 'templateContent',
  118. label: '消息',
  119. minWidth: '250',
  120. slot: 'templateContent'
  121. },
  122. {
  123. prop: 'readStatus',
  124. label: '状态',
  125. width: '80',
  126. align: 'center',
  127. slot: 'readStatus'
  128. },
  129. {
  130. prop: 'readTime',
  131. label: '阅读时间',
  132. width: '180',
  133. align: 'center',
  134. showOverflowTooltip: true
  135. },
  136. {
  137. prop: 'templateNickname',
  138. label: '发送人',
  139. width: '150',
  140. align: 'center'
  141. },
  142. {
  143. prop: 'createTime',
  144. label: '发送时间',
  145. width: '180',
  146. align: 'center',
  147. showOverflowTooltip: true
  148. },
  149. {
  150. columnKey: 'action',
  151. label: '操作',
  152. width: 150,
  153. align: 'center',
  154. slot: 'action',
  155. fixed: 'right'
  156. }
  157. ],
  158. searchForm: {},
  159. tableData: [],
  160. size: 10,
  161. page: 1,
  162. total: 0
  163. };
  164. },
  165. computed: {
  166. ...mapGetters(['user']),
  167. // 是否开启响应式布局
  168. styleResponsive() {
  169. return this.$store.state.theme.styleResponsive;
  170. }
  171. },
  172. methods: {
  173. //新增或修改模板
  174. async handleAddOrEdit(row, formPath) {
  175. await updateNotifyMessageReadByIdAPI([row.id]);
  176. if (formPath) {
  177. // 跨子系统跳转:使用 location.href 整页跳转
  178. this.goDetail(formPath);
  179. // window.location.href = formPath;
  180. // return;
  181. }
  182. this.$refs.table.reload();
  183. },
  184. reload(type) {
  185. if (type == 'reset') {
  186. this.params = {
  187. createTime: null,
  188. readStatus: null
  189. };
  190. }
  191. this.$refs.table.reload({ page: 1, where: this.params });
  192. },
  193. goDetail(formPath) {
  194. if (!formPath) return;
  195. // 获取当前子系统的路由 base 前缀
  196. const routerBase = this.$router.options.base || '/';
  197. // 判断目标路径是否属于当前子系统(以当前子系统 base 开头或不含 /page- 前缀)
  198. const isCurrentApp =
  199. formPath.startsWith(routerBase) || !formPath.startsWith('/page-');
  200. if (isCurrentApp) {
  201. // 本系统内跳转:去掉 base 前缀后使用 router.push
  202. const innerPath = formPath.startsWith(routerBase)
  203. ? formPath.slice(routerBase.length - 1)
  204. : formPath;
  205. this.$router.push(innerPath);
  206. } else {
  207. // 跨子系统跳转:使用 location.href 整页跳转,让主应用重新加载目标子系统
  208. window.location.href = formPath;
  209. }
  210. },
  211. datasource({ page, where, limit, ...row }) {
  212. return notifyMessagePageAPI({
  213. ...where,
  214. pageNum: page,
  215. size: limit,
  216. userId: this.user.info.userId
  217. });
  218. }
  219. }
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. .app-container {
  224. background: #f0f3f3;
  225. min-height: calc(100vh - 84px);
  226. }
  227. .zw-page-table {
  228. background: #ffffff;
  229. padding-top: 20px;
  230. }
  231. .pagination-wrap {
  232. display: flex;
  233. justify-content: flex-end;
  234. padding: 10px 0;
  235. }
  236. .table {
  237. width: 100%;
  238. margin-top: 10px;
  239. }
  240. </style>