dbsd_kczx/src/views/zy/jiaoXueDanYuanNeiRong/index.vue

778 lines
28 KiB
Vue
Raw Normal View History

2024-05-14 08:36:59 +08:00
<template>
<div class="max">
<!-- <a-affix :offset-top="0" :target="() => doctomen"> -->
2024-05-29 16:19:17 +08:00
<div style="background: #fff;margin-top: 10px;">
<div style="font-size: 12px;color: #ff8400;border-radius:3px; margin:0 10px; padding:8px;width:98%;background: linear-gradient(to left,#fff4d8, #ffeec4); border:1px dashed #f39800;">提示每一个小的章节都可以上传章节相关的教学资源</div>
<div class="topButton">
<a-space v-if="!isPreview">
<!-- <a-button type="primary" @click="save" :loading="saveLoading" title="保存"><Icon icon="ant-design:save-outlined"/>保存</a-button> -->
2024-06-04 08:47:27 +08:00
<a-button type="primary" @click="addOne()" class="addBtn" title="新增章节"><Icon icon="ant-design:plus-outlined"/>新增章节</a-button>
2024-07-05 10:37:21 +08:00
<a-button type="primary" v-if="!isPreview" @click="() => { isPreview = true; reloadStn(); }" class="addBtn" title="预览"><Icon icon="ant-design:fund-view-outlined"/>预览</a-button>
<!-- <a-button @click="reload"><Icon icon="ant-design:reload-outlined"/>刷新</a-button> -->
</a-space>
<template v-else>
<a-space>
2024-07-05 10:37:21 +08:00
<!-- <a-button @click="reloadStn"><Icon icon="ant-design:reload-outlined"/>刷新</a-button> -->
<a-button type="primary" @click="() => { isPreview = false }" class="addBtn" title="返回"><Icon icon="ant-design:fund-view-outlined"/>返回</a-button>
</a-space>
</template>
2024-05-29 16:22:22 +08:00
</div>
</div>
<!-- </a-affix> -->
<stuIndex ref="stuIndexRef" v-show="isPreview" :hiddenBtn="true"/>
<div v-show="!isPreview" class="maxDiv">
<a-empty v-if="!dataSource || !dataSource.length"/>
<draggable v-bind="draggableBind" v-model="dataSource">
2024-05-14 08:36:59 +08:00
<template #item="{ element: one }">
<div class="box">
<!-- 下一层 -->
<a-card @mouseenter="() => one.showBtn = true" @mouseleave="() => one.showBtn = false">
<a-collapse ghost expandIconPosition="right">
<a-collapse-panel :key="one._id" forceRender>
<template #header>
<div class="topDiv">
<Icon icon="ant-design:holder-outlined"/>
<div>{{ one.sort }}</div>
<div class="inputd">
2024-07-05 10:37:21 +08:00
<a-input v-if="one.isEdit" :value="one.title" style="border:0;" @change="changeInput($event, one, 'title')" @blur="() => { one.isEdit = false; editOne(one) }" @click="stop" class="ainput inputpad"/>
2024-05-29 16:19:17 +08:00
<div v-else class="ainput ainputpad ainputNoEdit" @click="(e) => { stop(e);one.isEdit = true }" >&nbsp;{{ one.title }}</div>
</div>
</div>
</template>
<template #extra>
2024-07-05 10:37:21 +08:00
<span v-show="!one.showBtn">
<div v-show="one.fabu=='0'" style="color:#b2b2b2;width: 3rem;">未发布</div>
<div v-show="one.fabu=='1'" style="color:#b2b2b2;width: 3rem">已发布</div>
</span>
<span v-show="one.showBtn">
<a-space>
2024-07-05 10:37:21 +08:00
<div v-show="one.fabu=='0'" style="color:#b2b2b2;width: 3rem;">未发布</div>
<div v-show="one.fabu=='1'" style="color:#b2b2b2;width: 3rem">已发布</div>
2024-06-04 08:47:27 +08:00
<div><a-button type="primary" size="small" @click="addTwo($event, one)" class="twoBtn addBtn" title="新增节次"><Icon icon="ant-design:plus-outlined"/></a-button></div>
<div><a-button type="primary" size="small" danger @click="delOne($event, one)" class="addBtn" title="删除"><Icon icon="ant-design:delete"/></a-button></div>
2024-07-05 10:37:21 +08:00
<div v-show="one.fabu=='0'||!one.fabu"><a-button type="primary" size="small" @click="handleFabu(one,'1')" class="addBtn" title="发布">发布</a-button></div>
<div v-show="one.fabu=='1'"><a-button type="primary" size="small" @click="handleFabu(one,'0')" class="addBtn" title="取消发布">取消发布</a-button></div>
</a-space>
</span>
</template>
<draggable v-bind="draggableBind" v-model="one.childrenList">
<template #item="{ element: two }">
<div class="box">
<!-- 下一层 -->
<a-card @mouseenter="() => two.showBtn = true" @mouseleave="() => two.showBtn = false">
<a-collapse ghost expandIconPosition="right">
<a-collapse-panel :key="two._id" :showArrow="false" forceRender>
<template #header>
<div class="twoTopDiv">
<div class="topDiv">
<Icon icon="ant-design:holder-outlined"/>
<div>{{ one.sort }}.{{ two.sort }}</div>
<div class="twoInputd">
<a-input v-if="two.isEdit" :value="two.title" @change="changeInput($event, two, 'title')" @blur="() => { two.isEdit = false; editTwo(two) }" @click="stop" class="ainput"/>
2024-05-29 16:19:17 +08:00
<div v-else class="ainput ainputpad ainputNoEdit" @click="(e) => { stop(e);two.isEdit = true }" >&nbsp;{{ two.title }}</div>
</div>
</div>
</div>
</template>
<template #extra>
<span v-show="two.showBtn">
<a-space>
2024-07-05 10:37:21 +08:00
<a-button type="primary" size="small" class="addBtn" title="上传资源"><Icon icon="ant-design:swap-outlined" style="transform: rotate(90deg)"/></a-button>
<a-button type="primary" size="small" danger @click="delTwo($event, one, two)" class="addBtn" title="删除"><Icon icon="ant-design:delete"/></a-button>
</a-space>
</span>
</template>
2024-05-29 16:19:17 +08:00
<div style="padding-bottom: 0.2rem;">
<a-space>
<div><a-button type="primary" size="small" @click="addThree($event, two, 'video')" class="addBtn"><Icon icon="ant-design:video-camera-outlined"/>视频</a-button></div>
<div><a-button type="primary" size="small" @click="addThree($event, two, 'document')" class="addBtn"><Icon icon="ant-design:file-outlined"/>文档</a-button></div>
<div><a-button type="primary" size="small" @click="addThree($event, two, 'richText')" class="addBtn"><Icon icon="ant-design:file-text-outlined"/>富文本</a-button></div>
<!-- <div><a-button type="primary" @click="addThree($event, two, 'classroomTest')" class="addBtn"><Icon icon="ant-design:plus-outlined"/>随堂测试</a-button></div>
<div><a-button type="primary" @click="addThree($event, two, 'discuss')" class="addBtn"><Icon icon="ant-design:plus-outlined"/>讨论</a-button></div> -->
</a-space>
2024-05-14 08:36:59 +08:00
</div>
<draggable v-bind="draggableBind" v-model="two.childrenList">
<template #item="{ element: three, index: threeIndex }">
<div class="box" @mouseenter="() => three.showBtn = true" @mouseleave="() => three.showBtn = false">
<Icon icon="ant-design:holder-outlined"/>
{{ one.sort }}.{{ two.sort }}.{{ three.sort }}
<a-tag class="hand" @click="viewThreePage(three)">
<template v-if="three.type == 'video'"><Icon icon="ant-design:video-camera-outlined" />视频</template>
<template v-if="three.type == 'document'"><Icon icon="ant-design:file-outlined" />文档</template>
<template v-if="three.type == 'richText'"><Icon icon="ant-design:file-text-outlined" />富文本</template>
</a-tag>
<span class="hand" @click="viewThreePage(three)">{{ three.title }}</span>
2024-07-05 10:37:21 +08:00
<span v-show="three.showBtn" style="margin-left: 10px;">
<a-space>
<a-button type="primary" size="small" title="下载" v-if="three.type == 'video' || three.type == 'document'" @click="downloadFile(three)" class="addBtn"><Icon icon="ant-design:vertical-align-bottom-outlined"/></a-button>
2024-05-27 14:45:05 +08:00
<a-button type="primary" size="small" title="查看" v-if="three.type == 'richText'" @click="viewThreePage(three)" class="addBtn"><Icon icon="ant-design:fund-view-outlined"/></a-button>
<a-button type="primary" size="small" title="编辑" @click="editThreePage(two, Object.assign({},three), threeIndex)" class="addBtn"><Icon icon="ant-design:edit"/></a-button>
<a-button type="primary" size="small" title="删除" danger @click="delThree($event, two, three)" class="addBtn"><Icon icon="ant-design:delete"/></a-button>
</a-space>
</span>
</div>
</template>
</draggable>
</a-collapse-panel>
</a-collapse>
</a-card>
</div>
</template>
</draggable>
</a-collapse-panel>
</a-collapse>
2024-05-14 08:36:59 +08:00
</a-card>
</div>
</template>
<!-- <template #footer> -->
<!-- <a-button @click="sureChange" type="primary" style="margin-top: 100px">确定</a-button> -->
<!-- </template> -->
2024-05-14 08:36:59 +08:00
</draggable>
<a-modal :title="threePageTitle" :width="800" :visible="threePageOpen" :maskClosable="false" @ok="threePageHandleOk" :okButtonProps="{ class: { 'jee-hidden': threePageDisableSubmit } }" @cancel="threePageHandleCancel" cancelText="关闭">
<a-card v-if="threePageData?.three">
<div>
标题
<a-input v-if="!threePageDisableSubmit" :value="threePageData.three.title" @change="changeInput($event, threePageData.three, 'title')" @click="stop" class="ainput"/>
<div v-else>{{ threePageData.three.title }}</div>
</div>
2024-05-29 16:19:17 +08:00
<div style="margin-top:10px;">
<template v-if="threePageData.three.type == 'video'">
<j-upload v-if="!threePageDisableSubmit" v-model:value="threePageData.three.filePath" :maxCount="1" text="上传视频" accept=".mp4,.webm,.ogv" :forceAcceptVerify="true" :isGetBiz="true" :getBizParam="{ rwbh, xqxn, wjlx: '教学单元' }"/>
<downloadAssembly v-else :filePath="threePageData.three.filePath"/>
</template>
<template v-if="threePageData.three.type == 'document'">
<j-upload v-if="!threePageDisableSubmit" v-model:value="threePageData.three.filePath" :maxCount="1" :isGetBiz="true" :getBizParam="{ rwbh, xqxn, wjlx: '教学单元' }" />
<downloadAssembly v-else :filePath="threePageData.three.filePath"/>
</template>
<template v-if="threePageData.three.type == 'richText' && threePageOpen">
<j-editor v-if="!threePageDisableSubmit" v-model:value="threePageData.three.richText"/>
<div v-else class="richText" v-html="threePageData.three.richText"></div>
</template>
</div>
</a-card>
</a-modal>
2024-05-14 08:36:59 +08:00
</div>
</div>
2024-05-27 19:41:21 +08:00
<div class="example">
<a-spin :spinning="spinning" size="large" tip="下载中..." />
</div>
2024-05-14 08:36:59 +08:00
</template>
<script lang="ts" name="jiaoXueDanYuanNeiRongIndex" setup>
import { ref, reactive, onMounted, unref, nextTick } from 'vue';
import { Input, Popover, Pagination, Empty, Affix as aAffix } from 'ant-design-vue';
2024-05-14 08:36:59 +08:00
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
import { useRouter } from 'vue-router';
import { randomString, simpleDebounce, getFileAccessHttpUrl } from '/@/utils/common/compUtils'
2024-05-14 08:36:59 +08:00
import draggable from 'vuedraggable';
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
import JEditor from '/@/components/Form/src/jeecg/components/JEditor.vue';
import downloadAssembly from '/@/views/zy/jiaoXueDanYuanNeiRong/downloadAssembly.vue';
import stuIndex from './stuIndex.vue';
2024-06-08 15:48:41 +08:00
import { downloadFile as ajaxDownloadFileFn } from '/@/api/common/api';
2024-05-27 19:41:21 +08:00
const spinning = ref<boolean>(false);
2024-05-14 08:36:59 +08:00
//当前路由信息
const { currentRoute } = useRouter();
const { query } = unref(currentRoute);
2024-06-04 08:47:27 +08:00
const { rwbh, xqxn, type,teano } = query;//获取传递参数
2024-05-14 08:36:59 +08:00
const { createConfirm, createMessage } = useMessage();
const queryParam = ref<any>({});
const dataSource = ref<any>([]);
const isNotMove = ref<boolean>(true);
const saveLoading = ref<boolean>(false);
const isPreview = ref<boolean>(false);
const threePageTitle = ref<String>('详细');
const threePageOpen = ref<boolean>(false);
const threePageDisableSubmit = ref<boolean>(false);
const threePageData = ref<Object>(null);
const stuIndexRef = ref<any>();
//公共的拖动排序组件绑定数据
const draggableBind = ref<Object>({
//唯一键
itemKey: '_id',
// onStart: moveDraggable,
// onAdd: onAddFn,
// onRemove: onRemoveFn,
// onUpdate: onUpdateFn,
//有效移动后触发
onEnd: endDraggable,
//鼠标按下触发
// onChoose: simpleDebounce(chooseDraggable, 500),
// onChoose: chooseDraggable,
//鼠标松开后触发
// onUnchoose: unchooseDraggable,
// onSort: onSortFn,
// onFilter: onFilterFn,
// onClone: onCloneFn,
// onMove: onMoveFn,
});
enum Api {
list = '/teachingunitcontent/kcTeachingUnitContentOne/allList',
editAll = '/teachingunitcontent/kcTeachingUnitContentOne/editAll',
addOne = '/teachingunitcontent/kcTeachingUnitContentOne/add',
editOne = '/teachingunitcontent/kcTeachingUnitContentOne/edit',
delOne = '/teachingunitcontent/kcTeachingUnitContentOne/delete',
2024-06-04 08:47:27 +08:00
editJxdyOne = '/teachingunitcontent/kcTeachingUnitContentOne/editJxdyOne',
addTwo = '/teachingunitcontent/kcTeachingUnitContentTwo/add',
editTwo = '/teachingunitcontent/kcTeachingUnitContentTwo/edit',
delTwo = '/teachingunitcontent/kcTeachingUnitContentTwo/delete',
addThree = '/teachingunitcontent/kcTeachingUnitContentThree/add',
editThree = '/teachingunitcontent/kcTeachingUnitContentThree/edit',
delThree = '/teachingunitcontent/kcTeachingUnitContentThree/delete',
}
/**
* 列表接口
* @param params
*/
const listAll = (params) => defHttp.get({ url: Api.list, params });
const editAll = (params) => defHttp.post({ url: Api.editAll, params }, { isTransformResponse: true });
const addOneFetch = (params) => defHttp.post({ url: Api.addOne, params }, { isTransformResponse: false });
const editOneFetch = (params) => defHttp.put({ url: Api.editOne, params }, { isTransformResponse: false });
const delOneFetch = (params) => defHttp.delete({ url: Api.delOne, params }, { isTransformResponse: false, joinParamsToUrl: true });
2024-06-04 08:47:27 +08:00
const editJxdyOne = (params) => defHttp.put({ url: Api.editJxdyOne, params }, { isTransformResponse: false });
const addTwoFetch = (params) => defHttp.post({ url: Api.addTwo, params }, { isTransformResponse: false });
const editTwoFetch = (params) => defHttp.put({ url: Api.editTwo, params }, { isTransformResponse: false });
const delTwoFetch = (params) => defHttp.delete({ url: Api.delTwo, params }, { isTransformResponse: false, joinParamsToUrl: true });
const addThreeFetch = (params) => defHttp.post({ url: Api.addThree, params }, { isTransformResponse: false });
const editThreeFetch = (params) => defHttp.put({ url: Api.editThree, params }, { isTransformResponse: false });
const delThreeFetch = (params) => defHttp.delete({ url: Api.delThree, params }, { isTransformResponse: false, joinParamsToUrl: true });
2024-05-14 08:36:59 +08:00
function reload() {
loadData();
}
function reloadStn() {
stuIndexRef.value.reload();
}
async function loadData() {
dataSource.value = [];
let params = {
rwbh,
xqxn,
2024-06-04 08:47:27 +08:00
teano,
}
await listAll(params).then(res => {
dataRecursion(res, (x) => x._id = x.id);
dataSource.value = res;
});
nextTick(() => {
// setTimeout(() => {
expandAllTable();
// nextTick(() => {
// expandAllTable();
// });
// }, 1000);
});
}
function expandAllTable() {
document.querySelectorAll('.max .ant-collapse-header').forEach(x => {
if(x.getAttribute('aria-expanded') == 'false') x.click()
});
}
//递归执行方法
function dataRecursion(list, fn){
let _list = list;
_list.forEach((x,i) => {
fn(x,i);
if(x.childrenList && x.childrenList.length){
dataRecursion(x.childrenList, fn);
}
})
}
//刷新数据的排序
function refreshDataSort(){
dataRecursion(dataSource.value, (x, i) => x.sort = i+1);
}
2024-06-04 08:47:27 +08:00
function handleFabu(record,type){
console.log(`🚀 ~ handleFabu ~ record,type:`, record,type)
var params = {id:record.id,fabu:type}
editJxdyOne(params).then(res => {
if(res.success){
createMessage.success('操作成功!');
reload();
}
});
}
//获取祖宗级对象
function getBtnEle(e, className){
if(e){
//如果一级就是,直接甩出去
if(e?.classList?.contains(className)){
return e;
} else {
//如果父节点也没有,往更父的节点查找
return getBtnEle(e.parentElement, className);
}
// //如果父节点也没有,往更深的
// if(!e.parentElement.classList.contains(className)){
// //不存在
// console.log('111111',e.parentElement);
// }else{
// console.log('2222',e.parentElement);
// return e.parentElement;
// }
}
}
//创建新的节点
2024-05-14 08:36:59 +08:00
function createNoneData(){
let data = {
//临时ID兼容新增和修改
_id: randomString(32),
rwbh,
xqxn,
title: null,
sort: 0,
2024-05-14 08:36:59 +08:00
childrenList: [],
}
return data;
}
function stop(e) {
e?.stopPropagation();
}
function changeInput(e, pdata, key) {
let { target } = e;
let { value } = target;
pdata[key] = value;
}
2024-05-14 08:36:59 +08:00
function addOne(){
//调用后台保存(创建个新的)
let nowData = createNoneData();
dataSource.value.push(nowData);
refreshDataSort();
addOneFetch(nowData).then(res => {
if(res.success){
nowData.id = res.result.id;
2024-06-04 08:47:27 +08:00
createMessage.success('新增章节成功!');
// nextTick(() => {
// refreshDataSort();
// });
}
});
}
function editOne(one){
editOneFetch(one).then(res => {
if(res.success){
2024-06-04 08:47:27 +08:00
createMessage.success('修改章节成功!');
}
});
2024-05-14 08:36:59 +08:00
}
function delOne(e, one){
stop(e);
//删除
delOneFetch({ id: one.id }).then(res => {
if(res.success){
let index = dataSource.value.findIndex(x => x == one);
if(index == -1) return;
dataSource.value.splice(index, 1);
2024-06-04 08:47:27 +08:00
createMessage.success('删除章节成功!');
nextTick(() => {
refreshDataSort();
})
}
});
2024-05-14 08:36:59 +08:00
}
// function insertOne(index){
// dataSource.value.splice(index,0, createNoneData());
// }
function addTwo(e, one){
let btn = getBtnEle(e.target, 'twoBtn');
if(btn == null){
console.error('出大事了!');
return;
}
let tab = null;
document.querySelectorAll('.maxDiv .box .ant-collapse-header').forEach(x => {
let twoBtn = x.querySelector('.twoBtn');
if(twoBtn == btn){
tab = x;
}
});
let ariaExpanded = tab.getAttribute('aria-expanded');
if(ariaExpanded == 'false') {
}else{
stop(e);
}
let nowData = createNoneData();
nowData.pid = one.id;
if(one.childrenList){
one.childrenList.push(nowData);
}else{
one.childrenList = [ nowData ];
}
refreshDataSort();
addTwoFetch(nowData).then(res => {
if(res.success){
nowData.id = res.result.id;
2024-06-04 08:47:27 +08:00
createMessage.success('添加节次成功!');
}
});
}
function editTwo(two){
editTwoFetch(two).then(res => {
if(res.success){
2024-06-04 08:47:27 +08:00
createMessage.success('修改节次成功!');
}
});
2024-05-14 08:36:59 +08:00
}
function delTwo(e, one, two){
stop(e);
delTwoFetch({ id: two.id }).then(res => {
if(res.success){
let index = one.childrenList.findIndex(x => x == two);
if(index == -1) return;
one.childrenList.splice(index, 1);
2024-06-04 08:47:27 +08:00
createMessage.success('删除节次成功!');
nextTick(() => {
refreshDataSort();
})
}
});
2024-05-14 08:36:59 +08:00
}
// function insertTwo(one, index){
// one.childrenList.splice(index,0, createNoneData());
// }
function addThree(e, two, type){
stop(e);
let data = createNoneData();
delete data.title;
data.type = type;
data.richText = null;
data.filePath = null;
// if(two.childrenList){
// two.childrenList.push(data);
// }else{
// two.childrenList = [ data ];
// }
//createMessage.success('新增成功!');
// nextTick(() => {
// refreshDataSort();
// })
editThreePage(two, data, null);
}
function editThreePage(two, three, threeIndex) {
threePageOpen.value = true;
threePageDisableSubmit.value = false;
threePageData.value = { two, three, threeIndex, };
}
function viewThreePage(three) {
threePageOpen.value = true;
threePageDisableSubmit.value = true;
threePageData.value = { three };
2024-05-14 08:36:59 +08:00
}
function delThree(e, two, three){
stop(e);
delThreeFetch({ id: three.id }).then(res => {
if(res.success){
let index = two.childrenList.findIndex(x => x == three);
if(index == -1) return;
two.childrenList.splice(index, 1);
createMessage.success('删除成功!');
nextTick(() => {
refreshDataSort();
})
}
});
2024-05-14 08:36:59 +08:00
}
function downloadFile(three) {
let url = getFileAccessHttpUrl(three.filePath);
2024-05-27 19:41:21 +08:00
// window.open(url,"_blank");
openWindowWithLoading(url);
}
function openWindowWithLoading(url){
spinning.value = true;
2024-06-08 15:48:41 +08:00
let fileName = url.substring(url.lastIndexOf("/")+1);
let uploadAxiosHttpConfig = {
//超时时间,分钟 * 秒 * 毫秒 60分钟
timeout: 60 * 60 * 1000,
//不自动拼接前缀
joinPrefix: false,
//自定义前缀
apiUrl: '',
//不自动处理
isTransformResponse: false
2024-05-27 19:41:21 +08:00
}
2024-06-08 15:48:41 +08:00
ajaxDownloadFileFn(url, fileName, {}, () => { spinning.value = false; }, uploadAxiosHttpConfig);
// let xhr = new XMLHttpRequest();
// spinning.value = true;
// xhr.open('GET',url,true);
// xhr.send();
// xhr.responseType = "arraybuffer";
// xhr.onreadystatechange = event =>{
// if(xhr.readyState == 4){
// if(xhr.status == 200){
// let fileName = url.substring(url.lastIndexOf("/")+1);
// let blob = new Blob([xhr.response]);
// const downLoadLink = document.createElement('a');
// downLoadLink.download = fileName;
// downLoadLink.href = URL.createObjectURL(blob);
// downLoadLink.click();
// }else if (xhr.status == 404){
// createMessage.warning('没有找到可下载的资源!');
// }
// }
// spinning.value = false;
// }
}
2024-05-14 08:36:59 +08:00
//移动结束时触发,如果未移动则不触发,刷新排序,
function endDraggable(){
//移动后如果有富文本编辑器则会失效,需要此法重置一下
isNotMove.value = false;
nextTick(() => {
isNotMove.value = true;
refreshDataSort();
})
2024-05-14 08:36:59 +08:00
}
function threePageHandleOk(){
let { two, three, threeIndex, } = threePageData.value;
//校验
if(!three.title){
createMessage.warn('请填写标题!');
return;
} else if(three.type == 'video'){
if(!three.filePath){
createMessage.warn('请上传视频!');
return;
}
} else if(three.type == 'document'){
if(!three.filePath){
2024-05-27 14:55:40 +08:00
createMessage.warn('请上传文档!');
return;
}
} else if(three.type == 'richText'){
if(!three.richText){
createMessage.warn('请填写富文本!');
return;
}
}
if(!threeIndex && threeIndex !== 0){
three.pid = two.id;
//新增
if(two.childrenList){
two.childrenList.push(three);
}else{
two.childrenList = [ three ];
}
refreshDataSort();
addThreeFetch(three).then(res => {
if(res.success){
three.id = res.result.id;
createMessage.success('添加成功!');
}
});
}else{
//修改
two.childrenList[threeIndex] = three;
refreshDataSort();
editThreeFetch(three).then(res => {
if(res.success){
createMessage.success('修改成功!');
}
});
}
threePageOpen.value = false;
}
function threePageHandleCancel(){
threePageOpen.value = false;
threePageData.value = {};
}
//按下鼠标按键后触发
// function chooseDraggable(){
// // isNotMove.value = false;
// }
2024-05-14 08:36:59 +08:00
//松开鼠标按键后触发
// function unchooseDraggable(){
// // isNotMove.value = true;
// }
// function onAddFn() { console.log('onAddFn'); }
// function onRemoveFn() { console.log('onRemoveFn'); }
// function onUpdateFn() { console.log('onUpdateFn'); }
// function onChooseFn() { console.log('onChooseFn'); }
// function onUnchooseFn() { console.log('onUnchooseFn'); }
// function onSortFn() { console.log('onSortFn'); }
// function onFilterFn() { console.log('onFilterFn'); }
// function onCloneFn() { console.log('onCloneFn'); }
// function onMoveFn() { console.log('onMoveFn'); }
// //移动时触发,关闭富文本编辑器
// function moveDraggable() {
// console.log('move');
// isNotMove.value = false;
// }
2024-05-14 08:36:59 +08:00
async function save(){
saveLoading.value = true;
console.log(unref(dataSource));
let saveData = {
rwbh,
xqxn,
teachingUnitContentOneList: unref(dataSource),
}
if(!saveData.rwbh || !saveData.xqxn){
createMessage.error('无法保存!');
saveLoading.value = false;
return;
}else if(!saveData.teachingUnitContentOneList || !saveData.teachingUnitContentOneList.length){
createMessage.warn('请添加数据!');
saveLoading.value = false;
return;
}
await editAll(saveData);
saveLoading.value = false;
}
loadData();
2024-05-14 08:36:59 +08:00
</script>
<style lang="less" scoped>
.hand {
cursor:pointer;
}
.max {
2024-07-05 10:37:21 +08:00
height: calc(100vh - 216px);
//height: calc(-132px + 100vh);
// min-height: calc(-132px + 100vh);
// max-height: calc(-132px + 100vh);
2024-07-05 10:37:21 +08:00
// overflow: auto;
overflow: hidden;
.maxDiv {
height: calc(100% - 94px);
overflow-y: auto;
}
}
2024-05-14 08:36:59 +08:00
.box {
margin: .5rem 0 0 0;
.itemTop {
width: 100%;
}
}
.topButton {
padding: 10px;
}
.ainput {
width: 100%;
2024-07-05 10:37:21 +08:00
border:0px;
2024-05-29 16:19:17 +08:00
}
.ainputpad {
padding: 3px 0;
border-radius: 3px;
}
.ainputNoEdit {
}
.inputd {
width: calc(100% - 35px);
}
.topDiv {
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
}
.twoInputd {
width: calc(100% - 45px);
}
.twoTopDiv {
width: 100%;
}
.richText {
max-height: 400px;
overflow: auto;
}
:deep(.maxDiv){
.ant-collapse-header{
align-items: center;
padding-bottom: 0;
}
.ant-card-body {
2024-05-29 16:19:17 +08:00
padding: 5px;
}
}
2024-05-27 19:41:21 +08:00
.example {
text-align: center;
background: rgba(0, 0, 0, 0);
border-radius: 4px;
position: absolute;
left: 50%;
top: 50%;
2024-05-29 16:19:17 +08:00
}
.ant-empty {
margin: 25% 8px;
font-size: 14px;
line-height: 1.5715;
text-align: center;
}
.ant-btn-sm {
height: 28px;
padding: 0px 8px;
font-size: 14px;
border-radius: 2px;
2024-05-27 19:41:21 +08:00
}
2024-05-29 16:19:17 +08:00
</style>