receive.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div>
  3. <van-sticky>
  4. <van-nav-bar
  5. :title="generateTitle($route.name,$route.params.title||$route.meta.title)"
  6. @click-left="$router.push({ name: 'dashboard' })"
  7. />
  8. <van-tabs v-show="tabDatas.length>1" v-model="tabActive" color="#3396FB" line-width="40" class="ibps-border-bm" @click="onClickTab">
  9. <van-tab v-for="data in tabDatas" :key="data.name" :name="data.name" :title="data.title" >
  10. <template #title>
  11. <div class="badge">
  12. {{data.title}}
  13. <div class="icon">{{ data.val }}</div>
  14. </div>
  15. </template>
  16. </van-tab>
  17. </van-tabs>
  18. <van-search
  19. v-model="subject"
  20. show-action
  21. placeholder="请输入主题搜索关键词"
  22. @search="onSearch"
  23. >
  24. <template #action>
  25. <van-icon name="filter-o" :class="{'ibps-active':stateActive}" @click="clickMoreSearch" />
  26. </template>
  27. </van-search>
  28. </van-sticky>
  29. <div class="ibps-blank-bar" />
  30. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  31. <van-list v-model="loading" :finished="finished" @load="loadData">
  32. <van-cell
  33. v-for="(item,index) in listData"
  34. :key="item.id+index"
  35. :title="item.subject"
  36. :label="item.ownerName"
  37. size="large"
  38. @click="onClick(item,index)"
  39. >
  40. <template slot="icon">
  41. <ibps-avatar
  42. :icon="_randomIcon(index)"
  43. :text="item.name"
  44. :bg-color="_randomColor(index)"
  45. radius="4"
  46. icon-prefix="ibps-icon"
  47. class="ibps-mr-10"
  48. />
  49. </template>
  50. <span>{{ item.createTime }}</span>
  51. <div>
  52. <van-tag
  53. size="medium"
  54. :color="item.messageType | optionsFilter(typeOptions,'type')"
  55. :text-color="item.messageType | optionsFilter(typeOptions,'type') "
  56. >
  57. {{ item.messageType| optionsFilter(typeOptions) }}</van-tag>
  58. </div>
  59. </van-cell>
  60. <ibps-list-result-page
  61. :result-type="resultType"
  62. :error-type="errorType"
  63. :result-message="resultMessage"
  64. />
  65. </van-list>
  66. </van-pull-refresh>
  67. <ibps-more-search
  68. :show="moreSearchPopup"
  69. :search-forms="searchForms"
  70. @callback="onMoreSearch"
  71. @close="show => moreSearchPopup = show"
  72. @reset-form="resetForm"
  73. />
  74. <detail
  75. :id="innerMessageId"
  76. :visible="formVisible"
  77. @callback="onRefresh"
  78. @close="visible => formVisible = visible"
  79. />
  80. </div>
  81. </template>
  82. <script>
  83. import { getMsgList, getMyMsgListAll } from '@/api/platform/message/innerMessage'
  84. import { typeOptions } from './constants'
  85. import ActionUtils from '@/utils/action'
  86. import i18n from '@/utils/i18n'
  87. import random from '@/mixins/random'
  88. import IbpsMoreSearch from '@/components/ibps-more-search'
  89. import IbpsAvatar from '@/components/ibps-avatar'
  90. import IbpsListResultPage from '@/components/ibps-list-result-page'
  91. import Detail from './detail'
  92. export default {
  93. components: {
  94. IbpsMoreSearch,
  95. IbpsAvatar,
  96. IbpsListResultPage,
  97. Detail
  98. },
  99. mixins: [random],
  100. data() {
  101. return {
  102. typeOptions: typeOptions,
  103. stateActive: false,
  104. moreSearchPopup: false,
  105. searchForms: {
  106. forms: [
  107. { prop: 'Q^subject^SL', label: '主题', fieldType: 'text' },
  108. { prop: 'Q^ownerName^SL', label: '发送人', fieldType: 'text' },
  109. { prop: 'Q^messageType.^S', label: '消息类型', fieldType: 'checker', cols: 3, valueKey: 'value', options: typeOptions },
  110. { prop: 'Q^content^SL', label: '消息内容', fieldType: 'text' },
  111. { prop: ['Q^beginreceiveTime^DL', 'Q^endreceiveTime^DG'], label: '发送时间', fieldType: 'dateRange', options: { datefmt: 'yyyy-MM-dd' }}
  112. ]
  113. },
  114. tabActive: '2',
  115. tabDatas: [{
  116. name: '2',
  117. title: '全部'
  118. }, {
  119. name: '0',
  120. title: '未读'
  121. }, {
  122. name: '1',
  123. title: '已读'
  124. }],
  125. subject: '',
  126. moreParams: {},
  127. listData: [],
  128. pagination: {},
  129. sorts: {},
  130. loading: false,
  131. finished: false,
  132. refreshing: false,
  133. resultType: 'init',
  134. errorType: null,
  135. resultMessage: null,
  136. innerMessageId: '',
  137. formVisible: false
  138. }
  139. },
  140. methods: {
  141. generateTitle(name, title) { // generateTitle by vue-i18n
  142. return i18n.generateTitle(name, title)
  143. },
  144. /**
  145. * 加载数据
  146. */
  147. loadData() {
  148. this.loading = true
  149. getMyMsgListAll(this.getSearcFormData()).then(response => {
  150. // 处理数据
  151. ActionUtils.handleListData(this, response.data)
  152. const index = this.tabDatas.findIndex(i=>i.name==this.tabActive)
  153. let a = this.tabDatas[index]
  154. a['val'] = response.data.pageResult.totalCount
  155. this.$set(this.tabDatas,index,a)
  156. }).catch((e) => {
  157. ActionUtils.handleErrorData(this, e)
  158. })
  159. this.totalCount()
  160. },
  161. totalCount(){
  162. let mid = []
  163. this.tabDatas.forEach((e,i)=>{
  164. if(e.name!=this.tabActive){
  165. mid.push({name:e.name,index:i})
  166. }
  167. })
  168. mid.forEach((e,i)=>{
  169. getMyMsgListAll(this.getSearcFormData(e.name))
  170. .then(response => {
  171. // this.tabDatas[e.index]['val']=response.data.pageResult.totalCount
  172. let a = this.tabDatas[e.index]
  173. a['val'] = response.data.pageResult.totalCount
  174. this.$set(this.tabDatas,e.index,a)
  175. })
  176. .catch(e => {
  177. let a = this.tabDatas[e.index]
  178. a['val'] = 0
  179. this.$set(this.tabDatas,e.index,a)
  180. })
  181. })
  182. },
  183. /**
  184. * 获取格式化参数
  185. */
  186. getSearcFormData(t) {
  187. let params = {}
  188. params['Q^isRead^SN'] =t?t: this.tabActive
  189. if (this.$utils.isNotEmpty(this.subject)) {
  190. params['Q^subject^SL'] = this.subject
  191. }
  192. if (this.$utils.isNotEmpty(this.moreParams)) {
  193. params = Object.assign(params, this.moreParams)
  194. }
  195. return ActionUtils.formatParams(
  196. params,
  197. this.pagination,
  198. this.sorts)
  199. },
  200. /**
  201. * 下拉刷新
  202. */
  203. onRefresh() {
  204. this.refreshing = true
  205. this.finished = false
  206. this.loading = true
  207. this.onSearch()
  208. },
  209. /**
  210. * 查询
  211. */
  212. onSearch() {
  213. this.stateActive = false
  214. ActionUtils.initListData(this)
  215. this.loadData()
  216. },
  217. /**
  218. * 高级查询
  219. */
  220. onMoreSearch(params) {
  221. if (this.$utils.isNotEmpty(this.typeId)) {
  222. params['Q^type_id_^SL'] = this.typeId
  223. }
  224. this.moreParams = params
  225. this.onSearch()
  226. if (this.$utils.isNotEmpty(params)) {
  227. this.stateActive = true
  228. }
  229. },
  230. /**
  231. * 弹窗更多查询条件
  232. */
  233. clickMoreSearch() {
  234. this.moreSearchPopup = true
  235. this.stateActive = false
  236. },
  237. /**
  238. * 重置表单
  239. */
  240. resetForm() {
  241. this.typeId = ''
  242. },
  243. onClick(item) {
  244. this.innerMessageId = item.id
  245. this.formVisible = true
  246. },
  247. onClickTab(){
  248. this.title = ''
  249. this.finished = false
  250. this.loading = true
  251. this.onSearch()
  252. }
  253. }
  254. }
  255. </script>
  256. <style lang="scss" scoped>
  257. .badge{
  258. display: flex;
  259. align-items:center;
  260. .icon{
  261. border-radius: 10px;
  262. color: #FFF;
  263. display: inline-block;
  264. font-size: 10px;
  265. height: 14px;
  266. line-height: 14px;
  267. padding: 0 4px;
  268. text-align: center;
  269. white-space: nowrap;
  270. border: 1px solid #FFF;
  271. background-color: #F56C6C;
  272. }
  273. }
  274. </style>