index.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import OEmpty from '@/components/o-empty'
  2. import OHeader from '@/components/o-header'
  3. import OSearch from '@/components/o-search'
  4. import OSticky from '@/components/o-sticky'
  5. import { snedStatus } from '@/constant'
  6. import request from '@/helpers/request'
  7. import { Cell, CellGroup, Icon, List, Tab, Tabs } from 'vant'
  8. import { defineComponent, onMounted, reactive } from 'vue'
  9. import { useRouter } from 'vue-router'
  10. import styles from './index.module.less'
  11. export default defineComponent({
  12. name: 'mass-message',
  13. setup() {
  14. const router = useRouter()
  15. const state = reactive({
  16. list: [],
  17. dataShow: true, // 判断是否有数据
  18. loading: false,
  19. finished: false,
  20. params: {
  21. search: null,
  22. page: 1,
  23. rows: 10
  24. }
  25. })
  26. const getList = async () => {
  27. try {
  28. const res = await request.post('/api-school/imMessageBatchSending/page', {
  29. data: {
  30. ...state.params
  31. }
  32. })
  33. state.loading = false
  34. const result = res.data || {}
  35. // 处理重复请求数据
  36. if (state.list.length > 0 && result.current === 1) {
  37. return
  38. }
  39. state.list = state.list.concat(result.rows || [])
  40. state.finished = result.current >= result.totalPage
  41. state.params.page = result.current + 1
  42. state.dataShow = state.list.length > 0
  43. } catch {
  44. state.dataShow = false
  45. state.finished = true
  46. }
  47. }
  48. onMounted(() => {
  49. getList()
  50. })
  51. return () => (
  52. <div class={styles.massMessage}>
  53. <OSticky position="top">
  54. <OHeader border={false}>
  55. {{
  56. right: () => (
  57. <span
  58. style="color: var(--van-primary-color)"
  59. onClick={() => {
  60. router.push('/create-message')
  61. }}
  62. >
  63. 消息群发
  64. </span>
  65. )
  66. }}
  67. </OHeader>
  68. <Tabs lineWidth={18}>
  69. <Tab title="待发送"></Tab>
  70. <Tab title="已发送"></Tab>
  71. </Tabs>
  72. <OSearch
  73. background="#f6f8f9"
  74. inputBackground="white"
  75. placeholder="请输入群聊/学员名称"
  76. onSearch={(val: string) => {
  77. console.log('val', val)
  78. }}
  79. />
  80. </OSticky>
  81. {state.dataShow ? (
  82. <List
  83. v-model:loading={state.loading}
  84. finished={state.finished}
  85. finishedText=" "
  86. class={[styles.liveList]}
  87. onLoad={getList}
  88. immediateCheck={false}
  89. >
  90. {state.list.map((item: any) => (
  91. <CellGroup inset>
  92. <Cell class={styles.waitSend} titleStyle={{ flex: '1 auto' }}>
  93. {{
  94. title: () => (
  95. <div class={styles.time}>
  96. <Icon name="clock-o" class={styles.clockO} />
  97. {item.sendTime}
  98. </div>
  99. ),
  100. value: () => <span>{snedStatus[item.sendStatus]}</span>
  101. }}
  102. </Cell>
  103. <Cell valueClass={styles.messageContent}>{item.textMessage}</Cell>
  104. </CellGroup>
  105. ))}
  106. </List>
  107. ) : (
  108. <OEmpty btnStatus={false} classImgSize="SMALL" tips="暂无群发消息" />
  109. )}
  110. </div>
  111. )
  112. }
  113. })