ppt -优化活动列表 #141

Merged
zhengdegang merged 1 commits from zdg_dev into main 2024-12-16 15:03:16 +08:00
2 changed files with 51 additions and 116 deletions

View File

@ -158,11 +158,13 @@ export class PPTApi {
} }
} }
} }
// 更新幻灯片 // 更新幻灯片 isThum 是否更新缩略图
static updateSlide(data: object): Promise<Boolean> { static updateSlide(data: object, isThum = true): Promise<Boolean> {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
if (isThum) { // 更新缩略图
const thumUrl = await this.getSlideThumUrl() const thumUrl = await this.getSlideThumUrl()
data.base64Code = thumUrl // 更新缩略图 data.base64Code = thumUrl // 更新缩略图
}
const res: Result = await API_entpcoursefile.updateEntpcoursefileNew(data) const res: Result = await API_entpcoursefile.updateEntpcoursefileNew(data)
if (res.code === 200) { if (res.code === 200) {
resolve(true) resolve(true)
@ -222,7 +224,6 @@ export class PPTApi {
// const workIds = res?.data?.activityContent||'' // const workIds = res?.data?.activityContent||''
// workItem-获取作业id // workItem-获取作业id
const workIds = workItem.find(o => o.id == slideId)?.activityContent const workIds = workItem.find(o => o.id == slideId)?.activityContent
console.log('更新-活动列表', workItem, currentSlide, slideId, workIds)
if (!workIds) return resolveData(resolve) if (!workIds) return resolveData(resolve)
// 获取作业列表 // 获取作业列表
const resW = await API_classwork.homeworklist({ ids: workIds, pageSize: 1000 }) const resW = await API_classwork.homeworklist({ ids: workIds, pageSize: 1000 })

View File

@ -39,7 +39,7 @@
<el-tooltip :content="item.uniquekey" placement="top"> <el-tooltip :content="item.uniquekey" placement="top">
<div class="tt">{{item.uniquekey}}</div> <div class="tt">{{item.uniquekey}}</div>
</el-tooltip> </el-tooltip>
<el-button class="btn-del" type="danger" link @click="handleRemoveDemoActivityClassWork(item)">删除</el-button> <el-button class="btn-del" type="danger" link @click="removeWork(item, index)">删除</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -94,7 +94,6 @@ import {useSlidesStore} from '../../../../../store'
import { updateEntpcoursefileNew } from '@/api/education/entpcoursefile' import { updateEntpcoursefileNew } from '@/api/education/entpcoursefile'
const slidesStore = useSlidesStore() const slidesStore = useSlidesStore()
const { slides, slideIndex, currentSlide, workItem } = storeToRefs(slidesStore) const { slides, slideIndex, currentSlide, workItem } = storeToRefs(slidesStore)
console.log('slidesStore',slidesStore.workList)
interface CourseNode { interface CourseNode {
rootid: number; rootid: number;
parentNode: { id: number }; parentNode: { id: number };
@ -174,61 +173,25 @@ const type = ref<WorkType[]>([
} }
]) ])
const objItem = ref<any>({})
//
const workList = ref<WorkItem[]>([])
// //
const selectedWorkList = ref<WorkItem[]>([]) const selectedWorkList = ref<WorkItem[]>([])
// loading // loading
const loadingActive = ref<boolean>(false) const loadingActive = ref<boolean>(false)
//
const paramData = ref<{ id: number, activityContent: string }>({} as { id: number, activityContent: string })
const selectable = (row: WorkItem, index: number): boolean => { const selectable = (row: WorkItem, index: number): boolean => {
return row.status === '10'; return row.status === '10';
}; };
//
const formatClassWorkFile = async (postData: WorkItem[]): Promise<void> => { const removeWork = (item: WorkItem, index: number) => {
for (let i = 0; i < postData.length; i++) {
let item = postData[i];
switch (item.worktype) {
case '框架梳理': {
}
break;
case '习题训练': {
// let workIds = item.quizlist!.map(items => items.id).join(',');
// let ress = await listEntpcoursework({ ids: workIds });
// const arr = ress.rows.map((item:{id:number}) => {
// return item.id
// })
// processList(ress.rows);
}
break;
case '课堂展示': {
// item.base64 = JSON.parse(item.workcodes).base64;
}
break;
case '常规作业': {
// item.prevData = JSON.parse(item.workcodes);
}
}
workList.value.push(item)
loadingActive.value = false
}
await nextTick();
}//
const handleRemoveDemoActivityClassWork = (item: WorkItem) => {
ElMessageBox.confirm('是否确认删除?') ElMessageBox.confirm('是否确认删除?')
.then(() => { .then(async() => {
workList.value = [] // workList
const arr = paramData.value.activityContent.split(',') // slidesStore.workList.splice(index, 1)
const filterArr = arr.filter(itemId => itemId!== item.id.toString()) console.log('删除作业', item)
paramData.value.activityContent = filterArr.join(',') await upDateData('del', [item.id])
upDateData() ElMessage.success('删除成功')
}) })
.catch(() => { }); .catch(() => { });
} }
@ -257,6 +220,7 @@ const showDialog = (item: string) => {
dialogVisible.value = true dialogVisible.value = true
} }
//
const openList = () => { const openList = () => {
activeVisible.value = true activeVisible.value = true
initHomeWork() initHomeWork()
@ -264,65 +228,44 @@ const openList = () => {
// //
const savePPtData = async () => { const savePPtData = async () => {
if (selectedWorkList.value.length === 0) { if (!selectedWorkList.value.length) {
ElMessage.warning('请选择活动') ElMessage.warning('请选择活动')
return return
} }
workList.value = []
const arr = selectedWorkList.value.map(item => item.id) const arr = selectedWorkList.value.map(item => item.id)
// await upDateData('add', arr)
const existingIds = paramData.value.activityContent ? paramData.value.activityContent.split(',') : []
paramData.value.activityContent = Array.from(new Set([...existingIds, ...arr])).join(',')
upDateData()
activeVisible.value = false activeVisible.value = false
} }
// ppt
const getCurrentPPtData = async () => {
workList.value = []
objItem.value = workItem.value[slideIndex.value]
paramData.value.id = objItem.value.id
paramData.value.activityContent = objItem.value?.activityContent
if (objItem.value?.activityContent) {
loadingActive.value = true
const res = await homeworklist({ ids: objItem.value?.activityContent, pageSize: 100 })
await formatClassWorkFile(res.rows)
}
}
// //
const getData = async (data: WorkItem) => { const getData = async (data: WorkItem) => {
workList.value = [] await upDateData('add', [data.id])
if(paramData.value.activityContent){
const arr = paramData.value.activityContent.split(',')
arr.push(data.id.toString())
const unitArr = Array.from(new Set(arr))
paramData.value.activityContent = unitArr.join(',')
}else{
paramData.value.activityContent = data.id.toString()
}
upDateData()
dialogVisible.value = false dialogVisible.value = false
} }
const upDateData = async () => { // - type add/ | del/ ids id
const upDateData = (type: string, ids: number[]): Promise<any> => {
return new Promise(async (resolve, reject) => {
loadingActive.value = true loadingActive.value = true
await PPTApi.updateSlide(paramData.value) //
// await updateEntpcoursefileNew(paramData.value) let workIds = slidesStore.workList.map((o:any) => o.id)
const resource = sessionStore.get('curr.resource') const id = slidesStore.currentSlide.id
await PPTApi.getSlideList(resource.id) if (type === 'del') { //
const res = await homeworklist({ ids: paramData.value.activityContent, pageSize: 100 }) workIds = workIds.filter(id => !ids.includes(id))
await formatClassWorkFile(res.rows) } else { //
} workIds = Array.from(new Set([...workIds, ...ids]))
//
const objectsAreEqual = (obj1: Record<string, any>, obj2: Record<string, any>) => {
const keys1 = Object.keys(obj1);
const keys2 = Object.keys(obj2);
if (keys1.length !== keys2.length) return false;
for (const key of keys1) {
if (obj1[key] !== obj2[key]) return false;
} }
return true; //
const wItem:any = slidesStore.workItem.find((o:any) => o.id === id)
const workIdsStr = workIds.join(',') // id->
if (!!wItem) wItem.activityContent = workIdsStr
const data = { id, activityContent: workIdsStr }
//
await PPTApi.updateSlide(data, false)
//
await PPTApi.updateWorkList()
loadingActive.value = false
resolve(true)
})
} }
onMounted(() => { onMounted(() => {
@ -332,17 +275,8 @@ onMounted(() => {
currentCourse.levelSecondId = curNode.id currentCourse.levelSecondId = curNode.id
currentCourse.coursetitle = curNode.itemtitle currentCourse.coursetitle = curNode.itemtitle
currentCourse.node = curNode currentCourse.node = curNode
// objItem.value = workItem.value[slideIndex.value]
// getCurrentPPtData()
}) })
watch(() => [workItem.value.length,workItem.value[slideIndex.value]?.id], (newVal,oldVal) => {
if(!objectsAreEqual(newVal,oldVal))
if(workItem.value[slideIndex.value])
getCurrentPPtData()
})
// watch(() => workItem.value.length, () => {
// getCurrentPPtData()
// })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.buttonDiv{ .buttonDiv{