sent.vue 6.6 KB

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