fix:修改pptlist添加活动的bug;
This commit is contained in:
parent
9f4e232d6f
commit
78cc5edd39
|
@ -110,6 +110,9 @@ export class PPTApi {
|
||||||
const rid = await API_entpcoursefile.addEntpcoursefileReturnId(params)
|
const rid = await API_entpcoursefile.addEntpcoursefileReturnId(params)
|
||||||
if (!!rid) {
|
if (!!rid) {
|
||||||
data.id = rid
|
data.id = rid
|
||||||
|
params.id = rid
|
||||||
|
params.activityContent = null
|
||||||
|
slidesStore.addWorkItem(params)
|
||||||
slidesStore.updateSlide(data)
|
slidesStore.updateSlide(data)
|
||||||
// msgUtils.msgSuccess('新增成功')
|
// msgUtils.msgSuccess('新增成功')
|
||||||
this.isUpdate = false // 新增后会触发监听,不再更新数据
|
this.isUpdate = false // 新增后会触发监听,不再更新数据
|
||||||
|
@ -148,8 +151,6 @@ export class PPTApi {
|
||||||
static updateSlide(data: object): Promise<Boolean> {
|
static updateSlide(data: object): Promise<Boolean> {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const res: Result = await API_entpcoursefile.updateEntpcoursefileNew(data)
|
const res: Result = await API_entpcoursefile.updateEntpcoursefileNew(data)
|
||||||
console.log(data,'data');
|
|
||||||
console.log(res,'dresata');
|
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
resolve(true)
|
resolve(true)
|
||||||
} else msgUtils.msgError(res.msg || '更新失败');resolve(false)
|
} else msgUtils.msgError(res.msg || '更新失败');resolve(false)
|
||||||
|
|
|
@ -146,45 +146,18 @@ export const useSlidesStore = defineStore('slides', {
|
||||||
this.workItem = list
|
this.workItem = list
|
||||||
},
|
},
|
||||||
addWorkItem(data: any) {
|
addWorkItem(data: any) {
|
||||||
const id = data?.parentid
|
const id = data?.id
|
||||||
if (!id) return
|
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[]) {
|
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]
|
const slides = Array.isArray(slide) ? slide : [slide]
|
||||||
for (const slide of slides) {
|
for (const slide of slides) {
|
||||||
if (slide.sectionTag) delete slide.sectionTag
|
if (slide.sectionTag) delete slide.sectionTag
|
||||||
}
|
}
|
||||||
API_entpcoursefile.addEntpcoursefileReturnId(params).then((rid:number) => {
|
this.slides.splice(this.slideIndex, 0, ...slides)
|
||||||
if(!!rid){
|
|
||||||
params.id = rid
|
|
||||||
this.addWorkItem(params)
|
|
||||||
const addIndex = this.slideIndex + 1
|
|
||||||
this.slides.splice(addIndex, 0, ...slides)
|
|
||||||
this.slideIndex = addIndex
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateSlide(props: Partial<Slide>, slideId?: string) {
|
updateSlide(props: Partial<Slide>, slideId?: string) {
|
||||||
|
|
|
@ -91,6 +91,7 @@ import { useGetHomework } from '@/hooks/useGetHomework'
|
||||||
import { PPTApi } from '../../../../../api/index'
|
import { PPTApi } from '../../../../../api/index'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import {useSlidesStore} from '../../../../../store'
|
import {useSlidesStore} from '../../../../../store'
|
||||||
|
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)
|
||||||
|
|
||||||
|
@ -277,7 +278,6 @@ const getCurrentPPtData = async () => {
|
||||||
workList.value = []
|
workList.value = []
|
||||||
objItem.value = workItem.value[slideIndex.value]
|
objItem.value = workItem.value[slideIndex.value]
|
||||||
paramData.value.id = objItem.value.id
|
paramData.value.id = objItem.value.id
|
||||||
console.log(paramData.value.id,'paramData.value.id');
|
|
||||||
|
|
||||||
paramData.value.activityContent = objItem.value?.activityContent
|
paramData.value.activityContent = objItem.value?.activityContent
|
||||||
if (objItem.value?.activityContent) {
|
if (objItem.value?.activityContent) {
|
||||||
|
@ -302,15 +302,16 @@ const getData = async (data: WorkItem) => {
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
}
|
}
|
||||||
const upDateData = async () => {
|
const upDateData = async () => {
|
||||||
await PPTApi.updateSlide(paramData.value)
|
// await PPTApi.updateSlide(paramData.value)
|
||||||
loadingActive.value = true
|
loadingActive.value = true
|
||||||
|
await updateEntpcoursefileNew(paramData.value)
|
||||||
const res = await homeworklist({ ids: paramData.value.activityContent, pageSize: 100 })
|
const res = await homeworklist({ ids: paramData.value.activityContent, pageSize: 100 })
|
||||||
await formatClassWorkFile(res.rows)
|
await formatClassWorkFile(res.rows)
|
||||||
const resource = sessionStore.get('curr.resource')
|
const resource = sessionStore.get('curr.resource')
|
||||||
await PPTApi.getSlideList(resource.id)
|
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 keys1 = Object.keys(obj1);
|
||||||
const keys2 = Object.keys(obj2);
|
const keys2 = Object.keys(obj2);
|
||||||
if (keys1.length !== keys2.length) return false;
|
if (keys1.length !== keys2.length) return false;
|
||||||
|
|
Loading…
Reference in New Issue