123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import OEmpty from '@/components/o-empty'
- import OPopup from '@/components/o-popup'
- import request from '@/helpers/request'
- import dayjs from 'dayjs'
- import { Button, Cell, Image, List } from 'vant'
- import { defineComponent, onMounted, reactive } from 'vue'
- import { useRoute } from 'vue-router'
- import AddInformation from './modal/add-information'
- import styles from './orchestra-information.module.less'
- export default defineComponent({
- name: 'orchestra-information',
- setup() {
- const route = useRoute()
- const state = reactive({
- addStatus: false,
- isLoading: false,
- list: [] as any,
- listState: {
- dataShow: true, // 判断是否有数据
- loading: false,
- finished: false
- },
- params: {
- type: 'HOT_CONSULTATION',
- clientType: 'SCHOOL',
- page: 1,
- rows: 20
- }
- })
- const getList = async () => {
- try {
- if (state.isLoading) return
- state.isLoading = true
- const res = await request.post('/api-school/sysNewsInformation/page', {
- data: {
- ...state.params,
- orchestraPhotoAlbumId: route.query.photoId
- }
- })
- state.listState.loading = false
- const result = res.data || {}
- // 处理重复请求数据
- if (state.list.length > 0 && result.pageNo === 1) {
- return
- }
- const rows = result.rows || []
- state.list = state.list.concat(rows)
- state.listState.finished = result.current >= result.pages
- state.params.page = result.current + 1
- state.listState.dataShow = state.list.length > 0
- state.isLoading = false
- } catch {
- state.listState.dataShow = false
- state.listState.finished = true
- state.isLoading = false
- }
- }
- onMounted(() => {
- getList()
- })
- return () => (
- <div class={styles.information}>
- <Button icon="plus" block class={styles.addPhone} onClick={() => (state.addStatus = true)}>
- 添加资讯
- </Button>
- {state.listState.dataShow ? (
- <List
- v-model:loading={state.listState.loading}
- finished={state.listState.finished}
- finishedText=" "
- onLoad={getList}
- immediateCheck={false}
- >
- {state.list.map((item: any, index: number) => (
- <Cell center class={styles.cell}>
- {{
- icon: () => <Image src={item.coverImage} class={styles.img} />,
- title: () => (
- <div>
- <div class={[styles.title, 'van-ellipsis']}>{item.title}</div>
- <div class={[styles.content, 'van-multi-ellipsis--l2']}>{item.memo}</div>
- <div class={styles.time}>{dayjs(item.createBy).format('YYYY年MM月DD日')}</div>
- </div>
- )
- }}
- </Cell>
- ))}
- </List>
- ) : (
- <OEmpty btnStatus={false} classImgSize="SMALL" tips="暂无资讯" />
- )}
- <OPopup v-model:modelValue={state.addStatus} style={{ background: '#f8f8f8' }}>
- <AddInformation onClose={() => (state.addStatus = false)} />
- </OPopup>
- </div>
- )
- }
- })
|