fix:修改pptlist添加活动的bug; #118

Merged
yangws merged 1 commits from yws_dev into main 2024-12-12 11:27:22 +08:00
3 changed files with 12 additions and 37 deletions
Showing only changes of commit 78cc5edd39 - Show all commits

View File

@ -110,6 +110,9 @@ export class PPTApi {
const rid = await API_entpcoursefile.addEntpcoursefileReturnId(params)
if (!!rid) {
data.id = rid
params.id = rid
params.activityContent = null
slidesStore.addWorkItem(params)
slidesStore.updateSlide(data)
// msgUtils.msgSuccess('新增成功')
this.isUpdate = false // 新增后会触发监听,不再更新数据
@ -148,8 +151,6 @@ export class PPTApi {
static updateSlide(data: object): Promise<Boolean> {
return new Promise(async (resolve, reject) => {
const res: Result = await API_entpcoursefile.updateEntpcoursefileNew(data)
console.log(data,'data');
console.log(res,'dresata');
if (res.code === 200) {
resolve(true)
} else msgUtils.msgError(res.msg || '更新失败');resolve(false)

View File

@ -146,45 +146,18 @@ export const useSlidesStore = defineStore('slides', {
this.workItem = list
},
addWorkItem(data: any) {
const id = data?.parentid
const id = data?.id
if (!id) return
this.workItem.splice(this.slideIndex, 0, data)
this.workItem.splice(this.slideIndex + 1, 0, data)
this.slideIndex += 1
},
addSlide(slide: Slide | Slide[]) {
const resource = sessionStore.get('curr.resource')||{}
const enpt = sessionStore.get('curr.entp')||{}
const {id, ...content} = slide
const params = {
parentid: resource.id,
activityContent:null,
entpid: userStore.user.deptId,
entpcourseid: enpt.id,
ppttype: 'file',
title: '',
fileurl: '',
filetype: 'slide',
datacontent: JSON.stringify(content),
filekey: '',
filetag: '',
fileidx: 0,
dflag: 0,
status: '',
edituserid: userStore.id,
}
const slides = Array.isArray(slide) ? slide : [slide]
for (const slide of slides) {
if (slide.sectionTag) delete slide.sectionTag
}
API_entpcoursefile.addEntpcoursefileReturnId(params).then((rid:number) => {
if(!!rid){
params.id = rid
this.addWorkItem(params)
const addIndex = this.slideIndex + 1
this.slides.splice(addIndex, 0, ...slides)
this.slideIndex = addIndex
}
})
this.slides.splice(this.slideIndex, 0, ...slides)
},
updateSlide(props: Partial<Slide>, slideId?: string) {

View File

@ -90,7 +90,8 @@ import { sessionStore } from '@/utils/store'
import { useGetHomework } from '@/hooks/useGetHomework'
import { PPTApi } from '../../../../../api/index'
import { storeToRefs } from 'pinia'
import {useSlidesStore} from '../../../../../store'
import {useSlidesStore} from '../../../../../store'
import { updateEntpcoursefileNew } from '@/api/education/entpcoursefile'
const slidesStore = useSlidesStore()
const { slides, slideIndex, currentSlide, workItem } = storeToRefs(slidesStore)
@ -277,7 +278,6 @@ const getCurrentPPtData = async () => {
workList.value = []
objItem.value = workItem.value[slideIndex.value]
paramData.value.id = objItem.value.id
console.log(paramData.value.id,'paramData.value.id');
paramData.value.activityContent = objItem.value?.activityContent
if (objItem.value?.activityContent) {
@ -302,15 +302,16 @@ const getData = async (data: WorkItem) => {
dialogVisible.value = false
}
const upDateData = async () => {
await PPTApi.updateSlide(paramData.value)
// await PPTApi.updateSlide(paramData.value)
loadingActive.value = true
await updateEntpcoursefileNew(paramData.value)
const res = await homeworklist({ ids: paramData.value.activityContent, pageSize: 100 })
await formatClassWorkFile(res.rows)
const resource = sessionStore.get('curr.resource')
await PPTApi.getSlideList(resource.id)
}
//
const objectsAreEqual = (obj1: any[], obj2: any[]) => {
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;