ppt -优化活动列表 #141
|
@ -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 })
|
||||||
|
|
|
@ -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{
|
||||||
|
|
Loading…
Reference in New Issue