|
@@ -1,272 +1,75 @@
|
|
|
-import ODialog from '@/components/o-dialog'
|
|
|
-import OEmpty from '@/components/o-empty'
|
|
|
-import OFullRefresh from '@/components/o-full-refresh'
|
|
|
import OHeader from '@/components/o-header'
|
|
|
-import OPopup from '@/components/o-popup'
|
|
|
import OSticky from '@/components/o-sticky'
|
|
|
import request from '@/helpers/request'
|
|
|
-import { router } from '@/router/routes-common'
|
|
|
-import dayjs from 'dayjs'
|
|
|
-import { ActionSheet, Button, Cell, Icon, Image, List, showConfirmDialog, showToast } from 'vant'
|
|
|
+import { Button, Tab, Tabs } from 'vant'
|
|
|
import { defineComponent, onMounted, reactive } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
-import AddInformation from './modal/add-information'
|
|
|
import styles from './orchestra-information.module.less'
|
|
|
+import OrchestraInformationList from './orchestra-information-list'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'orchestra-information',
|
|
|
setup() {
|
|
|
- const route = useRoute()
|
|
|
- const router = useRouter()
|
|
|
+ const tabName = sessionStorage.getItem('orchestra-information-tab')
|
|
|
const state = reactive({
|
|
|
- addStatus: false,
|
|
|
- isLoading: false,
|
|
|
- dialogStatus: false,
|
|
|
- list: [] as any,
|
|
|
+ activeName: tabName || 'publish',
|
|
|
listState: {
|
|
|
- dataShow: true, // 判断是否有数据
|
|
|
- loading: false,
|
|
|
- finished: false,
|
|
|
- refreshing: false,
|
|
|
height: 0 // 页面头部高度,为了处理下拉刷新用的
|
|
|
},
|
|
|
- params: {
|
|
|
- type: 'HOT_CONSULTATION',
|
|
|
- clientType: 'SCHOOL',
|
|
|
- page: 1,
|
|
|
- rows: 20
|
|
|
- },
|
|
|
- oPopover: false,
|
|
|
- selectItem: {} as any,
|
|
|
- selectType: 'add'
|
|
|
+ offlineCount: 0,
|
|
|
+ publishedCount: 0
|
|
|
})
|
|
|
-
|
|
|
- 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
|
|
|
- state.listState.refreshing = false
|
|
|
- const result = res.data || {}
|
|
|
- // 处理重复请求数据
|
|
|
- if (state.list.length > 0 && result.current === 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.listState.refreshing = false
|
|
|
- state.isLoading = false
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- const onSearch = () => {
|
|
|
- state.params.page = 1
|
|
|
- state.list = []
|
|
|
- state.listState.dataShow = true // 判断是否有数据
|
|
|
- state.listState.loading = false
|
|
|
- state.listState.finished = false
|
|
|
- getList()
|
|
|
- }
|
|
|
-
|
|
|
- const onDetail = (item: any) => {
|
|
|
+ const getStat = async () => {
|
|
|
try {
|
|
|
- console.log(item, 'item')
|
|
|
- if (item.linkUrl) {
|
|
|
- window.location.href = item.linkUrl
|
|
|
- } else {
|
|
|
- router.push({
|
|
|
- path: '/information-detail',
|
|
|
- query: {
|
|
|
- id: item.id
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ const { data } = await request.get('/api-school/sysNewsInformation/stat')
|
|
|
+ state.publishedCount = data.publishedCount || 0
|
|
|
+ state.offlineCount = data.offlineCount || 0
|
|
|
} catch {
|
|
|
//
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- const onUpdate = async () => {
|
|
|
- // state.selectType = 'update'
|
|
|
- // state.addStatus = true
|
|
|
- router.push({
|
|
|
- name: 'add-information',
|
|
|
- query: {
|
|
|
- id: state.selectItem.id
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- const onRemove = async () => {
|
|
|
- showConfirmDialog({
|
|
|
- message: '您确认删除该资讯吗?'
|
|
|
- }).then(async () => {
|
|
|
- try {
|
|
|
- await request.post('/api-school/sysNewsInformation/remove', {
|
|
|
- requestType: 'form',
|
|
|
- data: {
|
|
|
- id: state.selectItem.id
|
|
|
- }
|
|
|
- })
|
|
|
- // setTimeout(() => {
|
|
|
- // showToast('删除成功')
|
|
|
- // }, 100)
|
|
|
-
|
|
|
- // setTimeout(() => {
|
|
|
- onSearch()
|
|
|
- // }, 1100)
|
|
|
- } catch {
|
|
|
- //
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- onMounted(() => {
|
|
|
- getList()
|
|
|
+ onMounted(async () => {
|
|
|
+ // getStat()
|
|
|
})
|
|
|
return () => (
|
|
|
- <div class={[styles.information, !state.listState.dataShow && 'emptyRootContainer']}>
|
|
|
+ <div class={[styles.information]}>
|
|
|
<OSticky
|
|
|
position="top"
|
|
|
onGetHeight={(height: any) => {
|
|
|
state.listState.height = height
|
|
|
+ document.documentElement.style.setProperty('--header-height', height + 'px')
|
|
|
}}
|
|
|
>
|
|
|
- <OHeader>
|
|
|
- {{
|
|
|
- right: () => (
|
|
|
- <span
|
|
|
- class={styles.addPhone}
|
|
|
- onClick={() => {
|
|
|
- // state.selectType = 'add'
|
|
|
- // state.addStatus = true
|
|
|
- router.push('/add-information')
|
|
|
- }}
|
|
|
- >
|
|
|
- 添加资讯
|
|
|
- </span>
|
|
|
- )
|
|
|
- }}
|
|
|
- </OHeader>
|
|
|
- {/* <div style="background: #f6f8f9; overflow: hidden;">
|
|
|
- <Button
|
|
|
- icon="plus"
|
|
|
- block
|
|
|
- class={styles.addPhone}
|
|
|
- onClick={() => {
|
|
|
- state.selectType = 'add'
|
|
|
- state.addStatus = true
|
|
|
- }}
|
|
|
- >
|
|
|
- 添加资讯
|
|
|
- </Button>
|
|
|
- </div> */}
|
|
|
+ <OHeader border={false} />
|
|
|
</OSticky>
|
|
|
|
|
|
- {state.listState.dataShow ? (
|
|
|
- <OFullRefresh
|
|
|
- v-model:modelValue={state.listState.refreshing}
|
|
|
- onRefresh={onSearch}
|
|
|
- style={{
|
|
|
- minHeight: `calc(100vh - ${state.listState.height}px)`
|
|
|
- }}
|
|
|
- >
|
|
|
- <List
|
|
|
- // v-model:loading={state.listState.loading}
|
|
|
- finished={state.listState.finished}
|
|
|
- finishedText=" "
|
|
|
- onLoad={getList}
|
|
|
- immediateCheck={false}
|
|
|
- class={styles.informationGroup}
|
|
|
- >
|
|
|
- {state.list.map((item: any, index: number) => (
|
|
|
- <Cell center class={styles.cell} onClick={() => onDetail(item)}>
|
|
|
- {{
|
|
|
- icon: () => <Image src={item.coverImage} class={styles.img} fit="cover" />,
|
|
|
- title: () => (
|
|
|
- <div>
|
|
|
- <div class={[styles.title, 'van-ellipsis']}>{item.title}</div>
|
|
|
- <div class={[styles.content, 'van-multi-ellipsis--l2']}>{item.summary}</div>
|
|
|
- <div
|
|
|
- style={{
|
|
|
- display: 'flex',
|
|
|
- alignItems: 'center',
|
|
|
- justifyContent: 'space-between'
|
|
|
- }}
|
|
|
- >
|
|
|
- <div class={styles.time}>
|
|
|
- {item.createTime ? dayjs(item.createTime).format('YYYY年MM月DD日') : ''}
|
|
|
- </div>
|
|
|
- <Icon
|
|
|
- name="ellipsis"
|
|
|
- size={23}
|
|
|
- color="#777777"
|
|
|
- style={{ fontWeight: 'bold' }}
|
|
|
- onClick={(e: any) => {
|
|
|
- e.stopPropagation()
|
|
|
- state.selectItem = item
|
|
|
- state.oPopover = true
|
|
|
- }}
|
|
|
- />
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- )
|
|
|
- }}
|
|
|
- </Cell>
|
|
|
- ))}
|
|
|
- </List>
|
|
|
- </OFullRefresh>
|
|
|
- ) : (
|
|
|
- <OEmpty btnStatus={false} tips="暂无资讯" />
|
|
|
- )}
|
|
|
-
|
|
|
- {/* <OPopup v-model:modelValue={state.addStatus} style={{ background: '#f8f8f8' }} destroy>
|
|
|
- <AddInformation
|
|
|
- selectType={state.selectType}
|
|
|
- selectItem={state.selectItem}
|
|
|
- onClose={() => (state.addStatus = false)}
|
|
|
- onGetList={onSearch}
|
|
|
- />
|
|
|
- </OPopup> */}
|
|
|
-
|
|
|
- <ActionSheet
|
|
|
- cancelText="取消"
|
|
|
- v-model:show={state.oPopover}
|
|
|
- closeOnClickAction
|
|
|
- actions={[
|
|
|
- { name: '修改', callback: () => onUpdate() },
|
|
|
- {
|
|
|
- name: '删除',
|
|
|
- color: '#F44541',
|
|
|
- callback: () => {
|
|
|
- state.dialogStatus = true
|
|
|
- }
|
|
|
- }
|
|
|
- ]}
|
|
|
- />
|
|
|
-
|
|
|
- <ODialog
|
|
|
- v-model:show={state.dialogStatus}
|
|
|
- title="删除资讯"
|
|
|
- message="是否删除该资讯?确认后学员端、伴学端将同步删除"
|
|
|
- messageAlign="left"
|
|
|
- dialogMarginTop="env(safe-area-inset-top)"
|
|
|
- showCancelButton
|
|
|
- onConfirm={onRemove}
|
|
|
- />
|
|
|
+ <Tabs
|
|
|
+ sticky
|
|
|
+ lineWidth={20}
|
|
|
+ lineHeight={4}
|
|
|
+ animated
|
|
|
+ v-model:active={state.activeName}
|
|
|
+ offsetTop={state.listState.height}
|
|
|
+ swipeable
|
|
|
+ onChange={(val: string) => {
|
|
|
+ sessionStorage.setItem('orchestra-information-tab', val)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Tab title={`已发布(${state.publishedCount})`} name="publish">
|
|
|
+ <OrchestraInformationList
|
|
|
+ headHeight={state.listState.height}
|
|
|
+ type="1"
|
|
|
+ onChangeList={getStat}
|
|
|
+ />
|
|
|
+ </Tab>
|
|
|
+ <Tab title={`已下架(${state.offlineCount})`} name="offline">
|
|
|
+ <OrchestraInformationList
|
|
|
+ headHeight={state.listState.height}
|
|
|
+ type="0"
|
|
|
+ onChangeList={getStat}
|
|
|
+ />
|
|
|
+ </Tab>
|
|
|
+ </Tabs>
|
|
|
</div>
|
|
|
)
|
|
|
}
|