receive.vue 11 KB

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