From 5f00696dfb25bc90034448ceb634ed1ef256681a Mon Sep 17 00:00:00 2001 From: qiyunfeng-create <1940665526@qq.com> Date: 星期四, 21 八月 2025 21:13:35 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/xiehe_website --- src/views/classManage/teachingPlan.vue | 516 ++++++++++++++++++++++++++++++-------------------------- 1 files changed, 276 insertions(+), 240 deletions(-) diff --git a/src/views/classManage/teachingPlan.vue b/src/views/classManage/teachingPlan.vue index 3c1f67b..8df386c 100644 --- a/src/views/classManage/teachingPlan.vue +++ b/src/views/classManage/teachingPlan.vue @@ -12,7 +12,11 @@ <div class="titleBox"> <div class="titleOptions"> <span>鏁欏璁″垝</span> - <el-button v-if="userInfo?.role == 'Teacher'" @click="openPlan()" type="primary" round + <el-button + v-if="userInfo?.role == 'Teacher'" + @click="openPlan()" + type="primary" + round >鏂板缓 <el-icon style="margin-left: 3px"><Plus /></el-icon ></el-button> </div> @@ -25,7 +29,12 @@ @keydown.enter="searchData()" > <template #append> - <el-button type="primary" @click="searchData()" class="searchBtn" :icon="Search" /> + <el-button + type="primary" + @click="searchData()" + class="searchBtn" + :icon="Search" + /> </template> </el-input> </div> @@ -71,7 +80,7 @@ v-for="(item, index) in scope.row.datas.uploadResources" :key="index" > - {{ item.FileName + '.' + item.Extension }} + {{ item.FileName + "." + item.Extension }} </span> </div> </template> @@ -131,7 +140,12 @@ </el-col> <el-col :span="20"> <div class="grid-content ep-bg-purple-light" /> - <el-input v-model="taskItem.title" placeholder="璇峰~鍐欏悕绉�" size="large" clearable /> + <el-input + v-model="taskItem.title" + placeholder="璇峰~鍐欏悕绉�" + size="large" + clearable + /> </el-col> </el-row> <el-row> @@ -160,7 +174,12 @@ </el-cascader> </div> <div class="btngroup"> - <el-button type="primary" @click="addGroup" style="height: 40px" :icon="Plus" /> + <el-button + type="primary" + @click="addGroup" + style="height: 40px" + :icon="Plus" + /> <el-button type="warning" :disabled="dynamicList.length == 1" @@ -192,7 +211,12 @@ ></el-input> </div> <div class="btngroup"> - <el-button type="primary" @click="addGroup" style="height: 40px" :icon="Plus" /> + <el-button + type="primary" + @click="addGroup" + style="height: 40px" + :icon="Plus" + /> <el-button type="warning" :disabled="dynamicList.length == 1" @@ -222,7 +246,13 @@ >涓婁紶</el-button > </el-upload> --> - <el-upload class="upload" drag action="#" multiple :http-request="fileUpload"> + <el-upload + class="upload" + drag + action="#" + multiple + :http-request="fileUpload" + > <el-icon class="el-icon--upload"><upload-filled /></el-icon> <div class="el-upload__text">鎷栨嫿鎴栫偣鍑绘枃浠朵笂浼�</div> </el-upload> @@ -276,112 +306,112 @@ </template> <script setup lang="ts"> -import { Search, ArrowRight, Plus, Minus } from '@element-plus/icons-vue' -import { ElMessage } from 'element-plus' -import { reactive, ref, onMounted, inject, watch } from 'vue' -import { useRoute } from 'vue-router' -import axios from 'axios' +import { Search, ArrowRight, Plus, Minus } from "@element-plus/icons-vue"; +import { ElMessage } from "element-plus"; +import { reactive, ref, onMounted, inject, watch } from "vue"; +import { useRoute } from "vue-router"; +import axios from "axios"; -const route: any = useRoute() -const MG: any = inject('MG') -const config: any = inject('config') -const tool: any = inject('toolClass') -const classInfo = JSON.parse(route.query.classInfo) -const userInfo = ref() -const searchKey = ref('') -const visible = ref(false) -const dynamicList: any = ref([]) -const tableData: any = ref([]) -const classItem = ref([]) -const fileList: any = ref([]) -const chapterList: any = ref([]) -const childrenList: any = ref([]) -const taskData: any = ref() +const route: any = useRoute(); +const MG: any = inject("MG"); +const config: any = inject("config"); +const tool: any = inject("toolClass"); +const classInfo = JSON.parse(route.query.classInfo); +const userInfo = ref(); +const searchKey = ref(""); +const visible = ref(false); +const dynamicList: any = ref([]); +const tableData: any = ref([]); +const classItem = ref([]); +const fileList: any = ref([]); +const chapterList: any = ref([]); +const childrenList: any = ref([]); +const taskData: any = ref(); // 鏂板缓鏁欏璁″垝闃叉姈 -const newLoading = ref(false) -const teachPlanvalue = ref('') +const newLoading = ref(false); +const teachPlanvalue = ref(""); const taskItem = reactive({ - title: '', - selectChapter: '', - referenceMaterial: '', - explain: '', - uploadResources: '' -}) + title: "", + selectChapter: "", + referenceMaterial: "", + explain: "", + uploadResources: "", +}); let pages = reactive({ page: 1, pageSize: 13, count: 0, - loading: false -}) + loading: false, +}); onMounted(() => { - const list = [{ key: 1, parentVal: '', childVal: '' }] - dynamicList.value = list - const userCache: any = localStorage.getItem('jesk-userInfo') + const list = [{ key: 1, parentVal: "", childVal: "" }]; + dynamicList.value = list; + const userCache: any = localStorage.getItem(config.userInfoKey); if (userCache) { - userInfo.value = JSON.parse(userCache) + userInfo.value = JSON.parse(userCache); } - pages.loading = true - getTaskList() -}) + pages.loading = true; + getTaskList(); +}); const searchData = () => { - pages.page = 1 - getTaskCmsList() -} + pages.page = 1; + getTaskCmsList(); +}; const openPlan = () => { - visible.value = true - taskItem.title = '' - taskItem.selectChapter = '' - taskItem.referenceMaterial = '' - taskItem.explain = '' - taskItem.uploadResources = '' - dynamicList.value = [{ key: 1, parentVal: '', childVal: '' }] - fileList.value = [] -} + visible.value = true; + taskItem.title = ""; + taskItem.selectChapter = ""; + taskItem.referenceMaterial = ""; + taskItem.explain = ""; + taskItem.uploadResources = ""; + dynamicList.value = [{ key: 1, parentVal: "", childVal: "" }]; + fileList.value = []; +}; const reduceGroup = () => { - dynamicList.value.pop() -} + dynamicList.value.pop(); +}; const addGroup = () => { - const source = dynamicList.value[dynamicList.value.length - 1] - const obj = { key: source.key++, parentVal: '', childVal: '' } - dynamicList.value.push(obj) -} + const source = dynamicList.value[dynamicList.value.length - 1]; + const obj = { key: source.key++, parentVal: "", childVal: "" }; + dynamicList.value.push(obj); +}; const handleSizeChange = (val: number) => { - pages.pageSize = val - getTaskCmsList() -} + pages.pageSize = val; + getTaskCmsList(); +}; const handleCurrentChange = (val: number) => { - pages.page = val - getTaskCmsList() -} + pages.page = val; + getTaskCmsList(); +}; // 鏂板缓浠诲姟 const newTask = () => { const data = { - name: classInfo?.name + '鏁欏璁″垝', - description: '', - icon: '', + name: classInfo?.name + "鏁欏璁″垝", + description: "", + icon: "", type: config.taskType.teachingPlan, - state: 'Normal', + state: "Normal", groupId: classInfo?.id, order: 0, - beginDate: '2024-09-09T03:38:07.167Z', - endDate: '2024-09-09T03:38:07.167Z', - duration: 0 - } + beginDate: "2024-09-09T03:38:07.167Z", + endDate: "2024-09-09T03:38:07.167Z", + duration: 0, + }; MG.edu .newTask(data) .then((res: any) => {}) .catch((e: any) => { - console.log(e) - }) -} + console.log(e); + }); +}; // 鑾峰彇浠诲姟鍒楄〃 const getTaskList = () => { @@ -391,33 +421,33 @@ filterList: [ { value: config.taskType.teachingPlan, - field: 'Type', - subFilters: [] - } + field: "Type", + subFilters: [], + }, ], searchList: [], - groupId: classInfo?.id - } + groupId: classInfo?.id, + }; MG.edu .getTaskList(data) .then((res: any) => { - if (res.datas.length == 0 && userInfo.value.role == 'Teacher') { - newTask() + if (res.datas.length == 0 && userInfo.value.role == "Teacher") { + newTask(); } if (res.datas.length > 0) { - taskData.value = res.datas[0] - classInfo.taskId = taskData.value?.id - classInfo.rootTaskCmsId = taskData.value?.rootCmsItemId + taskData.value = res.datas[0]; + classInfo.taskId = taskData.value?.id; + classInfo.rootTaskCmsId = taskData.value?.rootCmsItemId; } - getTypeByCode() + getTypeByCode(); if (classInfo.bookRefCode) { - getCatalogueList() + getCatalogueList(); } }) .catch((e: any) => { - console.log(e) - }) -} + console.log(e); + }); +}; // 鍓嶅線闃呰鍣� const toRead = (item: any) => { @@ -426,35 +456,35 @@ if (classInfo.bookRefCode) { const url = config.textReaderUrl + - '?bookId=' + + "?bookId=" + classInfo?.bookRefCode + - '&token=' + - localStorage.getItem('jsek-token') + - '&chapter=' + + "&token=" + + localStorage.getItem(config.tokenKey) + + "&chapter=" + item.parentVal + - '&startPage=' + - item.childVal - window.open(url, '_blank') + "&startPage=" + + item.childVal; + window.open(url, "_blank"); } else { - ElMessage.warning('褰撳墠绔犺妭鏃犳硶璺宠浆') + ElMessage.warning("褰撳墠绔犺妭鏃犳硶璺宠浆"); } -} +}; // 涓嬭浇涓婁紶璧勬簮 const downloadRes = (item: any) => { - const url = config.requestCtx + '/file/api/ApiDownload?md5=' + item.Md5 - window.open(url, '_blank') -} + const url = config.requestCtx + "/file/api/ApiDownload?md5=" + item.Md5; + window.open(url, "_blank"); +}; // 閫夋嫨鍣� const parentSelect = (val: any, item: any) => { if (val?.length) { - const str = val[2] - const obj = findObj(chapterList.value, str) - item.parentVal = obj.chapter - item.childVal = obj.start + const str = val[2]; + const obj = findObj(chapterList.value, str); + item.parentVal = obj.chapter; + item.childVal = obj.start; } -} +}; // 鏂囦欢涓婁紶 const fileUpload = (file: any) => { @@ -469,104 +499,105 @@ // ElMessage.error('涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃 300KB!') // return reject() // } - const FileName = file.file.name.split('.')[0] - const Extension = file.file.name.split('.')[1] - const FileType = file.file.type - let size = 1024 + const FileName = file.file.name.split(".")[0]; + const Extension = file.file.name.split(".")[1]; + const FileType = file.file.type; + let size = 1024; tool .getFileMd5(file.file, size * 1024) .then((e: string) => { if (!fileList.value.find((item: any) => item.md5 == e)) { - const imgData = new FormData() - imgData.append('Md5', e) - imgData.append('FileName', FileName) - imgData.append('Extension', Extension) - imgData.append('FileType', FileType) - imgData.append('MetaData', null) - imgData.append('file', file.file) + const imgData = new FormData(); + imgData.append("Md5", e); + imgData.append("FileName", FileName); + imgData.append("Extension", Extension); + imgData.append("FileType", FileType); + imgData.append("MetaData", null); + imgData.append("file", file.file); MG.file.upload(imgData).then(() => { fileList.value.push({ md5: e, - linkType: 'LinkFile', - linkProtectType: 'Public', + linkType: "LinkFile", + linkProtectType: "Public", fileName: FileName, extension: Extension, - url: config.requestCtx + `鈥�/file鈥�/api鈥�/ApiDownload?md5=` + e - }) - }) + url: config.requestCtx + `鈥�/file鈥�/api鈥�/ApiDownload?md5=` + e, + }); + }); } else { - ElMessage.warning('褰撳墠鏂囦欢宸蹭笂浼狅紝璇峰嬁閲嶅鎿嶄綔锛�') + ElMessage.warning("褰撳墠鏂囦欢宸蹭笂浼狅紝璇峰嬁閲嶅鎿嶄綔锛�"); } }) .catch((e: any) => { - console.error(e) - }) - }) -} + console.error(e); + }); + }); +}; // 鑾峰彇绔犺妭鐩綍 const getCatalogueList = () => { - const url = config.requestCtx + '/books/resource/' + classInfo?.bookRefCode + '/information.json' + const url = + config.requestCtx + "/books/resource/" + classInfo?.bookRefCode + "/information.json"; axios .get(url) .then((res) => { if (res.data?.data.length > 0) { - const datas = res.data.data - const list = datas?.filter((item: any) => item.children?.length > 0) - chapterList.value = changeCascaderData(list) + const datas = res.data.data; + const list = datas?.filter((item: any) => item.children?.length > 0); + chapterList.value = changeCascaderData(list); } }) .catch((e) => { - console.log(e) - }) -} + console.log(e); + }); +}; // 閫掑綊鏇存暟缁� const changeCascaderData = (data: any) => { for (const item of data) { - item.value = item.start + item.value = item.start; if (item.children?.length > 0) { - changeCascaderData(item.children) + changeCascaderData(item.children); } } - return data -} + return data; +}; // 閫掑綊鏌ユ壘 const findObj = (arr: any, val: any) => { for (let i = 0; i < arr.length; i++) { - const obj = arr[i] + const obj = arr[i]; if (obj.start === val) { - return obj // 鎵惧埌鐩爣瀵硅薄锛岀洿鎺ヨ繑鍥� + return obj; // 鎵惧埌鐩爣瀵硅薄锛岀洿鎺ヨ繑鍥� } if (obj.children && obj.children.length > 0) { // 濡傛灉褰撳墠瀵硅薄鏈夊瓙瀵硅薄锛岄�掑綊鏌ユ壘瀛愬璞� - const found: any = findObj(obj.children, val) + const found: any = findObj(obj.children, val); if (found) { - return found // 鍦ㄥ瓙瀵硅薄涓壘鍒扮洰鏍囧璞★紝杩斿洖 + return found; // 鍦ㄥ瓙瀵硅薄涓壘鍒扮洰鏍囧璞★紝杩斿洖 } } } - return null -} + return null; +}; // 鑾峰彇绫诲瀷瀛楁 const getTypeByCode = () => { MG.resource .getCmsTypeByRefCode({ - refCodes: [config.refCodes.teachingPlan] + refCodes: [config.refCodes.teachingPlan], }) .then((res: any) => { - const data = res[0]?.cmsTypeLinks[0]?.children + const data = res[0]?.cmsTypeLinks[0]?.children; if (data?.length) { - classItem.value = data + classItem.value = data; } - getTaskCmsList() + getTaskCmsList(); }) .catch((err: any) => { - console.log(err) - }) -} + console.log(err); + }); +}; // 鑾峰彇浠诲姟涓嬬殑璧勬簮鍒楄〃 const getTaskCmsList = () => { @@ -577,80 +608,81 @@ ? [ { keywords: searchKey.value, - field: 'Name', - compareType: 'Contains' - } + field: "Name", + compareType: "Contains", + }, ] : [], taskId: classInfo?.taskId, path: String(classInfo?.rootTaskCmsId), - type: '*', - keys: ['referenceMaterial', 'Name', 'selectChapter', 'uploadResources', 'explain'] - } + type: "*", + keys: ["referenceMaterial", "Name", "selectChapter", "uploadResources", "explain"], + }; MG.edu .getTaskCmsItem(data) .then((res: any) => { - pages.loading = false - pages.count = res.totalSize + pages.loading = false; + pages.count = res.totalSize; for (let i = 0; i < res.datas.length; i++) { - const item = res.datas[i] + const item = res.datas[i]; // 澶勭悊瀛楁 if (taskItem != null) { for (let fieldKey in taskItem) { if (item.datas[fieldKey]) { - const values = JSON.parse(item.datas[fieldKey]) + const values = JSON.parse(item.datas[fieldKey]); if (values.length > 0) { // 鐢ㄥ瓧娈靛悕澶勭悊杩斿洖鐨勫瓧娈靛�� if (values[0].Value) { - item.datas[fieldKey] = values[0].Value + item.datas[fieldKey] = values[0].Value; } else if (values[0].Data) { - item.datas[fieldKey] = values[0].Data.Value + item.datas[fieldKey] = values[0].Data.Value; } else if (!values[0].Value && values[0].FileList?.length > 0) { - item.datas[fieldKey] = values[0].FileList + item.datas[fieldKey] = values[0].FileList; } else { - item.datas[fieldKey] = '-' + item.datas[fieldKey] = "-"; } - if (fieldKey == 'selectChapter' && values[0].Value) { - const data = JSON.parse(values[0].Value) - item.datas['selectChapter'] = data.map((citem: any) => { + if (fieldKey == "selectChapter" && values[0].Value) { + const data = JSON.parse(values[0].Value); + item.datas["selectChapter"] = data.map((citem: any) => { if (classInfo.bookRefCode) { - const dataS = findObj(chapterList.value, citem.childVal) + const dataS = findObj(chapterList.value, citem.childVal); return { ...citem, parentName: - chapterList.value.find((sitem: any) => sitem.chapter == citem.parentVal) - ?.label + - '---' + - dataS?.label - } + chapterList.value.find( + (sitem: any) => sitem.chapter == citem.parentVal + )?.label + + "---" + + dataS?.label, + }; } else { return { ...citem, - parentName: citem.parentVal + '---' + citem.childVal - } + parentName: citem.parentVal + "---" + citem.childVal, + }; } - }) + }); } - if (fieldKey == 'selectChapter' && !values[0].Value) { - item.datas['selectChapter'] = [] + if (fieldKey == "selectChapter" && !values[0].Value) { + item.datas["selectChapter"] = []; } } - const index = i - item.datas['index'] = index + 1 + const index = i; + item.datas["index"] = index + 1; } } } } - tableData.value = res.datas + tableData.value = res.datas; }) .catch((e: any) => { ElMessage({ - message: '鍒楄〃鑾峰彇澶辫触', - type: 'error' - }) - console.log(e) - }) -} + message: "鍒楄〃鑾峰彇澶辫触", + type: "error", + }); + console.log(e); + }); +}; // 鍒犻櫎璧勬簮 const removeTaskItem = (item: any) => { @@ -659,56 +691,56 @@ requests: [ { cmsItemId: item.id, - path: String(classInfo?.rootTaskCmsId) - } - ] - } + path: String(classInfo?.rootTaskCmsId), + }, + ], + }; MG.edu .removeTaskCmsItemList(data) .then((res: any) => { if (res) { ElMessage({ - message: '鍒犻櫎鎴愬姛', - type: 'success' - }) - getTaskCmsList() + message: "鍒犻櫎鎴愬姛", + type: "success", + }); + getTaskCmsList(); } }) .catch((e: any) => { ElMessage({ - message: '鍒犻櫎澶辫触', - type: 'error' - }) - }) -} + message: "鍒犻櫎澶辫触", + type: "error", + }); + }); +}; // 涓轰换鍔℃柊寤鸿祫婧� const newTaskCmsItems = () => { - newLoading.value = true - taskItem.selectChapter = JSON.stringify(dynamicList.value) + newLoading.value = true; + taskItem.selectChapter = JSON.stringify(dynamicList.value); if (!taskItem.title) { ElMessage({ - message: '璇峰~鍐欐暀瀛﹀悕绉�', - type: 'warning' - }) - newLoading.value = false - return false + message: "璇峰~鍐欐暀瀛﹀悕绉�", + type: "warning", + }); + newLoading.value = false; + return false; } - if (dynamicList.value[0]?.parentVal == '') { + if (dynamicList.value[0]?.parentVal == "") { ElMessage({ - message: '璇烽�夋嫨鏁欏绔犺妭', - type: 'warning' - }) - newLoading.value = false - return false + message: "璇烽�夋嫨鏁欏绔犺妭", + type: "warning", + }); + newLoading.value = false; + return false; } if (fileList.value.length == 0) { ElMessage({ - message: '璇蜂笂浼犳暀瀛︽枃浠�', - type: 'warning' - }) - newLoading.value = false - return false + message: "璇蜂笂浼犳暀瀛︽枃浠�", + type: "warning", + }); + newLoading.value = false; + return false; } const data = { groupId: classInfo?.id, @@ -717,29 +749,33 @@ newGroupCmsItemRequests: [ { name: taskItem.title, - description: '', - icon: '', + description: "", + icon: "", type: config.refCodes.teachingPlan, - state: 'Normal', + state: "Normal", order: 0, - newDataListRequest: tool.worksDataBytool(classItem.value, taskItem, fileList.value), + newDataListRequest: tool.worksDataBytool( + classItem.value, + taskItem, + fileList.value + ), newCmsItemAndFileLinkListRequest: [], - newChildrenListRequest: [] - } - ] - } + newChildrenListRequest: [], + }, + ], + }; MG.edu.newTaskCmsItem(data).then((res: any) => { - newLoading.value = false + newLoading.value = false; if (res) { ElMessage({ - message: '鏂板缓鎴愬姛', - type: 'success' - }) - visible.value = false - getTaskCmsList() + message: "鏂板缓鎴愬姛", + type: "success", + }); + visible.value = false; + getTaskCmsList(); } - }) -} + }); +}; // // 缂栬緫璧勬簮 // const editOpen = (item: any) => { -- Gitblit v1.9.1