import { defineComponent, onMounted, reactive } from 'vue'; import styles from './index.module.less'; import CardType from '/src/components/card-type'; import Pagination from '/src/components/pagination'; import SearchGroupResources from './search-group-resources'; import { materialQueryPage } from '../../api'; import { NModal, NSpin } from 'naive-ui'; import TheEmpty from '/src/components/TheEmpty'; import CardPreview from '/src/components/card-preview'; export default defineComponent({ name: 'share-resources', setup() { const state = reactive({ searchWord: '', loading: false, pageTotal: 0, pagination: { page: 1, rows: 20 }, searchGroup: { type: 'MUSIC', // keyword: '', bookVersionId: null, subjectId: null, sourceType: 2 }, tableList: [] as any, teachingStatus: false, show: false, item: {} as any }); const getList = async () => { try { state.loading = true; const { data } = await materialQueryPage({ ...state.searchGroup, ...state.pagination }); state.loading = false; state.pageTotal = Number(data.total); state.tableList = data.rows || []; } catch { state.loading = false; } }; const onSearch = async (item: any) => { state.pagination.page = 1; state.searchGroup = Object.assign(state.searchGroup, item); console.log(item, state.searchGroup); getList(); }; onMounted(() => { getList(); }); return () => ( <> onSearch(item)} onAdd={() => (state.teachingStatus = true)} />
{state.tableList.map((item: any) => { const tmpItem = { id: item.id, coverImg: item.coverImg, type: item.type, title: item.name, isCollect: !!item.favoriteFlag, isSelected: item.sourceFrom === 'PLATFORM' ? true : false, content: item.content }; return ( { state.show = true; state.item = val; }} /> ); })} {!state.loading && state.tableList.length <= 0 && ( )}
{/* 弹窗查看 */} {/* 添加自定义教材 */} 1212 ); } });