receive.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="receive-container">
  3. <ibps-crud
  4. ref="crud"
  5. :height="height"
  6. :data="listData"
  7. :toolbars="listConfig.toolbars"
  8. :search-form="listConfig.searchForm"
  9. :pk-key="pkKey"
  10. :columns="listConfig.columns"
  11. :row-handle="listConfig.rowHandle"
  12. :pagination="pagination"
  13. :loading="loading"
  14. :index-row="false"
  15. displayField="消息中心"
  16. @action-event="handleAction"
  17. @sort-change="handleSortChange"
  18. @column-link-click="handleLinkClick"
  19. @pagination-change="handlePaginationChange"
  20. >
  21. <template slot="handIcon" slot-scope="scope">
  22. <el-tooltip v-if="!scope.row.receiverTime" class="item" effect="dark" content="未读" placement="bottom">
  23. <i class="ibps-icon-envelope-o" />
  24. </el-tooltip>
  25. <el-tooltip v-else class="item" effect="dark" content="已读" placement="bottom">
  26. <i class="ibps-icon-envelope-open-o" />
  27. </el-tooltip>
  28. <el-tooltip v-if="scope.row.fileMsg" class="item" effect="dark" content="含附件" placement="bottom">
  29. <i class="ibps-icon-paperclip" />
  30. </el-tooltip>
  31. </template>
  32. </ibps-crud>
  33. <!-- 明细 -->
  34. <detail
  35. :id="editId"
  36. :title="title"
  37. :readonly="readonly"
  38. :visible="dialogFormVisible"
  39. @callback="search"
  40. @close="visible => closeDetail(visible)"
  41. />
  42. <!-- 回复 -->
  43. <reply
  44. :id="editId"
  45. :title="title"
  46. :visible="repliFormVisible"
  47. @callback="search"
  48. @close="visible => (repliFormVisible = visible)"
  49. />
  50. </div>
  51. </template>
  52. <script>
  53. import { queryReceivePageList, getMyMsgList, remove, markRead } from '@/api/platform/message/innerMessage'
  54. import ActionUtils from '@/utils/action'
  55. import FixHeight from '@/mixins/height'
  56. import { typeOptions, renderHeader } from './constants'
  57. import Detail from './detail/dialog'
  58. import Reply from './reply'
  59. export default {
  60. components: {
  61. Detail,
  62. Reply
  63. },
  64. mixins: [FixHeight],
  65. data() {
  66. return {
  67. dialogFormVisible: false, // 弹窗
  68. repliFormVisible: false, // 弹窗
  69. editId: '', // 编辑dialog需要使用
  70. pkKey: 'id', // 主键 如果主键不是pk需要传主键
  71. title: '',
  72. loading: true,
  73. isEnvelope: true,
  74. link: false,
  75. readonly: false,
  76. height: document.clientHeight,
  77. listData: [],
  78. pagination: {},
  79. sorts: {},
  80. listConfig: {
  81. toolbars: [
  82. {
  83. key: 'search'
  84. },
  85. {
  86. key: 'remove'
  87. },
  88. {
  89. key: 'markRead',
  90. icon: 'ibps-icon-check-circle',
  91. label: '标记为已读'
  92. }
  93. ],
  94. searchForm: {
  95. forms: [
  96. { prop: 'Q^subject^SL', label: '主题' },
  97. { prop: 'Q^ownerName^SL', label: '发送人' },
  98. {
  99. prop: 'Q^messageType^SL',
  100. label: '消息类型',
  101. fieldType: 'select',
  102. options: typeOptions
  103. },
  104. {
  105. prop: ['Q^beginreceiveTime^DL', 'Q^endreceiveTime^DG'],
  106. label: '发送时间',
  107. fieldType: 'daterange'
  108. }
  109. ]
  110. },
  111. // 表格字段配置
  112. columns: [
  113. {
  114. prop: 'stateIcon',
  115. label: '',
  116. slotName: 'handIcon',
  117. width: '65',
  118. renderHeader: renderHeader
  119. },
  120. {
  121. prop: 'subject',
  122. sortBy: 'SUBJECT_',
  123. label: '主题',
  124. link: 'dialog',
  125. sortable: 'custom',
  126. width: '250'
  127. },
  128. { prop: 'ownerName', label: '发送人', width: '150' },
  129. { prop: 'messageType', label: '消息类型', tags: typeOptions, width: '250' },
  130. { prop: 'content', label: '消息描述' },
  131. { prop: 'createTime', label: '发送时间', dateFormat: 'yyyy-MM-dd HH:mm:ss', width: '250' }
  132. ],
  133. rowHandle: {
  134. actions: [
  135. {
  136. key: 'reply',
  137. icon: 'ibps-icon-reply-all',
  138. label: '回复',
  139. hidden: function (row, index) {
  140. return (row.canreply === 0 || row.messageType === 'system' || row.messageType === 'bulletin')
  141. }
  142. },
  143. {
  144. key: 'remove'
  145. },
  146. {
  147. key: 'detail'
  148. }
  149. ]
  150. }
  151. }
  152. }
  153. },
  154. created() {
  155. this.loadData()
  156. },
  157. methods: {
  158. // 加载数据
  159. loadData() {
  160. this.loading = true
  161. // queryReceivePageList({
  162. // parameters:[
  163. // {key: "Q^subject^SL", value: "提醒"},
  164. // {key: "Q^messageType^SL", value: "system"}
  165. // ],
  166. // requestPage:{limit: 10,pageNo: 1,totalCount: 0},
  167. // sorts: []
  168. // }).then(response => {
  169. getMyMsgList(this.getSearcFormData()).then(response => {
  170. ActionUtils.handleListData(this, response.data)
  171. this.loading = false
  172. }).catch(err => {
  173. this.loading = false
  174. })
  175. },
  176. /**
  177. * 获取格式化参数
  178. */
  179. getSearcFormData() {
  180. return ActionUtils.formatParams(
  181. this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {},
  182. this.pagination,
  183. this.sorts
  184. )
  185. },
  186. /**
  187. * 处理分页事件
  188. */
  189. handlePaginationChange(page) {
  190. ActionUtils.setPagination(this.pagination, page)
  191. this.loadData()
  192. },
  193. /**
  194. * 处理排序
  195. */
  196. handleSortChange(sort) {
  197. ActionUtils.setSorts(this.sorts, sort)
  198. this.loadData()
  199. },
  200. /**
  201. * 查询
  202. */
  203. search() {
  204. this.loadData()
  205. },
  206. handleLinkClick(data, columns) {
  207. this.handleEdit(data.id, true)
  208. this.title = '信息明细'
  209. },
  210. /**
  211. * 处理按钮事件
  212. */
  213. handleAction(command, position, selection, data) {
  214. switch (command) {
  215. case 'search': // 查询
  216. ActionUtils.setFirstPagination(this.pagination)
  217. this.search()
  218. break
  219. case 'markRead': // 标记为已读
  220. ActionUtils.selectedMultiRecord(selection).then(id => {
  221. this.handleAlreadyRead(id)
  222. // this.isEnvelope = false
  223. }).catch(() => {})
  224. break
  225. case 'reply': // 回复
  226. ActionUtils.selectedRecord(selection).then(id => {
  227. this.handleReply(id)
  228. this.title = '信息回复'
  229. }).catch(() => {})
  230. break
  231. case 'detail': // 明细
  232. ActionUtils.selectedRecord(selection).then(id => {
  233. this.handleEdit(id, true)
  234. this.title = '信息明细'
  235. }).catch(() => {})
  236. break
  237. case 'remove': // 删除
  238. ActionUtils.removeRecord(selection).then(ids => {
  239. this.handleRemove(ids)
  240. }).catch(() => {})
  241. break
  242. default:
  243. break
  244. }
  245. },
  246. /**
  247. * 标记为已读
  248. */
  249. handleAlreadyRead(ids) {
  250. markRead({ innerMessageIds: ids }).then(response => {
  251. ActionUtils.success('标记已读成功')
  252. this.search()
  253. }).catch(() => {})
  254. },
  255. /**
  256. * 处理回复
  257. */
  258. handleReply(id = '') {
  259. this.editId = id
  260. this.repliFormVisible = true
  261. },
  262. /**
  263. * 处理明细
  264. */
  265. handleEdit(id = '', readonly) {
  266. this.editId = id
  267. this.readonly = readonly
  268. this.dialogFormVisible = true
  269. },
  270. /**
  271. * 处理删除
  272. */
  273. handleRemove(ids) {
  274. remove({ innerMessageIds: ids }).then(response => {
  275. ActionUtils.removeSuccessMessage()
  276. this.search()
  277. }).catch(() => {})
  278. },
  279. closeDetail(visible) {
  280. this.dialogFormVisible = visible
  281. this.search()
  282. }
  283. }
  284. }
  285. </script>