|
@@ -412,6 +412,48 @@ export default defineComponent({
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ // 拖拽添加数据
|
|
|
|
+ const addDragCoursewareItem = async (item: any, newIndex: number) => {
|
|
|
|
+ clearTimeout(timer);
|
|
|
|
+ const materialList: any[] = [];
|
|
|
|
+ try {
|
|
|
|
+ const { data } = await api_materialDetail(item.materialId);
|
|
|
|
+ if (Array.isArray(data.materialRefs)) {
|
|
|
|
+ data.materialRefs.forEach((item: any) => {
|
|
|
|
+ if (item.refType === 'STRONG') {
|
|
|
|
+ const relateMaterialInfo = item.relateMaterialInfo || {};
|
|
|
|
+ materialList.push({
|
|
|
|
+ content: relateMaterialInfo.content,
|
|
|
|
+ coverImg: relateMaterialInfo.coverImg,
|
|
|
|
+ isSelected:
|
|
|
|
+ relateMaterialInfo.sourceFrom === 'PLATFORM' ? true : false,
|
|
|
|
+ materialId: relateMaterialInfo.id,
|
|
|
|
+ title: relateMaterialInfo.name,
|
|
|
|
+ type: relateMaterialInfo.type
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } catch {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nextTick(() => {
|
|
|
|
+ const array: any = forms.coursewareList[item.index || 0].list || [];
|
|
|
|
+ array[newIndex] = item;
|
|
|
|
+ materialList.forEach((m: any) => {
|
|
|
|
+ array.splice(newIndex + 1, 0, m);
|
|
|
|
+ });
|
|
|
|
+ forms.coursewareList[item.index || 0].list = array;
|
|
|
|
+
|
|
|
|
+ console.log(forms.coursewareList, 'courseware add drag');
|
|
|
|
+ timer = setTimeout(() => {
|
|
|
|
+ // 内容有更新 - 相关资源会刷新
|
|
|
|
+ eventGlobal.emit('onCoursewareUpdate');
|
|
|
|
+ }, 100);
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
// 提交
|
|
// 提交
|
|
const onSubmit = async () => {
|
|
const onSubmit = async () => {
|
|
try {
|
|
try {
|
|
@@ -690,43 +732,44 @@ export default defineComponent({
|
|
{forms.coursewareList.map((item: any, index: number) => (
|
|
{forms.coursewareList.map((item: any, index: number) => (
|
|
<div
|
|
<div
|
|
class={[styles.listItems, 'row-group']}
|
|
class={[styles.listItems, 'row-group']}
|
|
- onDragenter={(e: any) => {
|
|
|
|
- e.preventDefault();
|
|
|
|
- }}
|
|
|
|
- onDragover={(e: any) => {
|
|
|
|
- e.preventDefault();
|
|
|
|
- }}
|
|
|
|
- onDrop={(e: any) => {
|
|
|
|
- let dropItem = e.dataTransfer.getData('text');
|
|
|
|
- dropItem =
|
|
|
|
- dropItem && e.dataTransfer.effectAllowed === 'all'
|
|
|
|
- ? JSON.parse(dropItem)
|
|
|
|
- : {};
|
|
|
|
- // 判断是否有数据
|
|
|
|
- if (dropItem.id) {
|
|
|
|
- // 获取拖拽的目标元素
|
|
|
|
- eventGlobal.emit(
|
|
|
|
- 'onPrepareAddItem',
|
|
|
|
- {
|
|
|
|
- materialId: dropItem.id,
|
|
|
|
- coverImg: dropItem.coverImg,
|
|
|
|
- type: dropItem.type,
|
|
|
|
- title: dropItem.title,
|
|
|
|
- refFlag: dropItem.refFlag,
|
|
|
|
- isCollect: dropItem.isCollect,
|
|
|
|
- isSelected: dropItem.isSelected,
|
|
|
|
- content: dropItem.content,
|
|
|
|
- removeFlag: false,
|
|
|
|
- index,
|
|
|
|
- addType: 'drag'
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- x: e.clientX,
|
|
|
|
- y: e.clientY
|
|
|
|
- }
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- }}>
|
|
|
|
|
|
+ // onDragenter={(e: any) => {
|
|
|
|
+ // e.preventDefault();
|
|
|
|
+ // }}
|
|
|
|
+ // onDragover={(e: any) => {
|
|
|
|
+ // e.preventDefault();
|
|
|
|
+ // }}
|
|
|
|
+ // onDrop={(e: any) => {
|
|
|
|
+ // let dropItem = e.dataTransfer.getData('text');
|
|
|
|
+ // dropItem =
|
|
|
|
+ // dropItem && e.dataTransfer.effectAllowed === 'all'
|
|
|
|
+ // ? JSON.parse(dropItem)
|
|
|
|
+ // : {};
|
|
|
|
+ // // 判断是否有数据
|
|
|
|
+ // if (dropItem.id) {
|
|
|
|
+ // // 获取拖拽的目标元素
|
|
|
|
+ // eventGlobal.emit(
|
|
|
|
+ // 'onPrepareAddItem',
|
|
|
|
+ // {
|
|
|
|
+ // materialId: dropItem.id,
|
|
|
|
+ // coverImg: dropItem.coverImg,
|
|
|
|
+ // type: dropItem.type,
|
|
|
|
+ // title: dropItem.title,
|
|
|
|
+ // refFlag: dropItem.refFlag,
|
|
|
|
+ // isCollect: dropItem.isCollect,
|
|
|
|
+ // isSelected: dropItem.isSelected,
|
|
|
|
+ // content: dropItem.content,
|
|
|
|
+ // removeFlag: false,
|
|
|
|
+ // index,
|
|
|
|
+ // addType: 'drag'
|
|
|
|
+ // },
|
|
|
|
+ // {
|
|
|
|
+ // x: e.clientX,
|
|
|
|
+ // y: e.clientY
|
|
|
|
+ // }
|
|
|
|
+ // );
|
|
|
|
+ // }
|
|
|
|
+ // }}
|
|
|
|
+ >
|
|
<div class={styles.knowledgePoint}>
|
|
<div class={styles.knowledgePoint}>
|
|
{/* <div class={styles.btnItem}>
|
|
{/* <div class={styles.btnItem}>
|
|
<span class={styles.btnTitle}>
|
|
<span class={styles.btnTitle}>
|
|
@@ -805,6 +848,41 @@ export default defineComponent({
|
|
// scrollSensitivity={120}
|
|
// scrollSensitivity={120}
|
|
// forceAutoScrollFallback={true}
|
|
// forceAutoScrollFallback={true}
|
|
animation={200}
|
|
animation={200}
|
|
|
|
+ // onChange={(evt: any) => {
|
|
|
|
+ // const added = evt.added;
|
|
|
|
+ // // 是否为添加
|
|
|
|
+ // if (!added || (added && !added.element)) {
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ // if (added.element.sourceForm !== 'resource-item') {
|
|
|
|
+ // return;
|
|
|
|
+ // }
|
|
|
|
+ // // console.log(forms.coursewareList, 'courseware');
|
|
|
|
+ // }}
|
|
|
|
+ onAdd={(evt: any) => {
|
|
|
|
+ // console.log(
|
|
|
|
+ const list = forms.coursewareList[index].list;
|
|
|
|
+ const dropItem = list[evt.newDraggableIndex];
|
|
|
|
+ console.log(dropItem, 'dropItem');
|
|
|
|
+ if (dropItem.sourceForm === 'resource-item') {
|
|
|
|
+ addDragCoursewareItem(
|
|
|
|
+ {
|
|
|
|
+ materialId: dropItem.id,
|
|
|
|
+ coverImg: dropItem.coverImg,
|
|
|
|
+ type: dropItem.type,
|
|
|
|
+ title: dropItem.title,
|
|
|
|
+ refFlag: dropItem.refFlag,
|
|
|
|
+ isCollect: dropItem.isCollect,
|
|
|
|
+ isSelected: dropItem.isSelected,
|
|
|
|
+ content: dropItem.content,
|
|
|
|
+ removeFlag: false,
|
|
|
|
+ index
|
|
|
|
+ },
|
|
|
|
+ evt.newDraggableIndex
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
onDrag={(event: any) => {
|
|
onDrag={(event: any) => {
|
|
// 修复滚动超出范围
|
|
// 修复滚动超出范围
|
|
const container: any = document.querySelector(
|
|
const container: any = document.querySelector(
|
|
@@ -817,7 +895,6 @@ export default defineComponent({
|
|
window.innerHeight - event.clientY <
|
|
window.innerHeight - event.clientY <
|
|
sensitivity
|
|
sensitivity
|
|
) {
|
|
) {
|
|
- console.log('1111');
|
|
|
|
container.scrollTop += 8;
|
|
container.scrollTop += 8;
|
|
}
|
|
}
|
|
}}
|
|
}}
|