courseSelect.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. <template>
  2. <h2 class="contentTitle" v-if="classDown">
  3. <div class="Levelone">
  4. 课程列表
  5. </div>
  6. </h2>
  7. <div class="grandTitle2">人工智能通识课</div>
  8. <div class="course_select">
  9. <span class="grandTitle">课程类型:</span>
  10. <el-button :class="courseTypeShow ? 'el_button_active' : ''" @click="SwitchCourseType(true)">AI通识课2025版</el-button>
  11. <!-- <el-button :class="!courseTypeShow ? 'el_button_active' : ''" @click="SwitchCourseType(false)">AI通识课2024版</el-button> -->
  12. </div>
  13. <div class="course_select">
  14. <span class="grandTitle">年级:</span>
  15. <el-button :class="selectGrand == '三年级' ? 'el_button_active' : ''" @click="clickGrand('三年级')">三年级</el-button>
  16. <el-button :class="selectGrand == '四年级' ? 'el_button_active' : ''" @click="clickGrand('四年级')">四年级</el-button>
  17. <el-button :class="selectGrand == '五年级' ? 'el_button_active' : ''" @click="clickGrand('五年级')">五年级</el-button>
  18. <el-button :class="selectGrand == '六年级' ? 'el_button_active' : ''" @click="clickGrand('六年级')">六年级</el-button>
  19. <el-button :class="selectGrand == '七年级' ? 'el_button_active' : ''" @click="clickGrand('七年级')">七年级</el-button>
  20. <el-button :class="selectGrand == '八年级' ? 'el_button_active' : ''" @click="clickGrand('八年级')">八年级</el-button>
  21. <el-button v-if="courseTypeShow" :class="selectGrand == '九年级' ? 'el_button_active' : ''"
  22. @click="clickGrand('九年级')">九年级</el-button>
  23. </div>
  24. <div class="course_select">
  25. <el-button :class="volumes ? 'el_button_active' : ''" @click="volumes = true">上册</el-button>
  26. <el-button v-if="!courseTypeShow" :class="!volumes ? 'el_button_active' : ''"
  27. @click="volumes = false">下册</el-button>
  28. <div v-if="currentData && currentData.shang.length > 0 && volumes">
  29. <el-row :gutter="20">
  30. <el-col :span="6" v-for="item in currentData.shang" :key="item.title" style="margin-top: 10px;">
  31. <div class="grid-content ep-bg-purple">
  32. <img :src="getImageUrl(item.url)" alt="">
  33. <div class="course_content">
  34. <div class="div_title">
  35. <span>上册</span>
  36. {{ item.title }}
  37. <!-- v-if="isupdateCourse" -->
  38. <!-- v-if="isupdateCourse && item.courseType == '1'" -->
  39. <el-popover v-if="isupdateCourse" placement="bottom" :width="210"
  40. trigger="click" show-after="500" @hide="checked1 = false">
  41. <template #reference>
  42. <img :src="DownloadImg" v-if="item.courseType == '2'" alt="">
  43. <img :src="DownloadImg" v-else alt="" @click="getDate(item.dataId)">
  44. </template>
  45. <div>
  46. <div>
  47. <span>资源列表({{ item.dataList.length }})</span>
  48. <el-checkbox style="position: relative;top: 0;left: 35px;height: 30px;" v-model="checked1"
  49. label="全选" size="large" @click="checkedAll(item.dataId)" />
  50. </div>
  51. <div v-if="item.dataList.length > 0">
  52. <div class="div_hover" v-for="dataitem in item.dataList" :key="dataitem.dataId">
  53. <span style="display: inline-block;width: 130px;" :title="dataitem.name">{{
  54. dataitem.name.length > 10 ?
  55. dataitem.name.substring(0, 8) + '...' : dataitem.name }}</span>
  56. <span v-if="!checked1" class="el_popover_a" style="position: relative;left: 20px;top: 5px;"
  57. @click="downloadOne(dataitem.url, dataitem.name)">
  58. <img :src="DownloadImg" alt="">
  59. </span>
  60. <el-checkbox v-if="checked1" v-model="dataitem.checked" label="全选" size="large" />
  61. </div>
  62. <el-button style="margin-top: 10px;" v-if="checked1"
  63. @click="DownloadProcessing()">批量下载</el-button>
  64. </div>
  65. <div v-else>
  66. 暂无数据
  67. </div>
  68. </div>
  69. </el-popover>
  70. </div>
  71. </div>
  72. <div class="class_button" v-if="isupdateCourse">
  73. <el-popover placement="bottom" trigger="hover">
  74. <template #reference>
  75. <el-button
  76. style="width: 50%;background: rgba(255, 255, 245, 1);color: rgba(0, 0, 0, 0.6);">备课</el-button>
  77. </template>
  78. <ul class="beike">
  79. <li @click="openCourseDetail(item.id)">查看</li>
  80. <li @click="updateCourse(item.id, item)">修改</li>
  81. <li @click="ReductionCourse(item.id)">还原</li>
  82. </ul>
  83. </el-popover>
  84. <el-button style="width: 50%;" class="el_button_active"
  85. @click="openCourseDetail(item.id, item)">上课</el-button>
  86. </div>
  87. </div>
  88. </el-col>
  89. </el-row>
  90. </div>
  91. <div v-if="currentData && currentData.xia.length > 0 && !volumes">
  92. <el-row :gutter="20">
  93. <el-col :span="6" v-for="item in currentData.xia" :key="item.title" style="margin-top: 10px;">
  94. <div class="grid-content ep-bg-purple">
  95. <img :src="getImageUrl(item.url)" alt="">
  96. <div class="course_content">
  97. <div class="div_title" style="">
  98. <span>下册</span>
  99. {{ item.title }}
  100. <!-- v-if="isupdateCourse" -->
  101. <el-popover v-if="isupdateCourse && item.courseType == '1'" placement="bottom" :width="210"
  102. trigger="click" show-after="500" @hide="checked1 = false">
  103. <template #reference>
  104. <img :src="DownloadImg" alt="" @click="getDate(item.dataId)">
  105. </template>
  106. <div>
  107. <div>
  108. <span>资源列表({{ item.dataList.length }})</span>
  109. <el-checkbox style="position: relative;top: 0;left: 35px;height: 30px;" v-model="checked1"
  110. label="全选" size="large" @click="checkedAll(item.dataId)" />
  111. </div>
  112. <div v-if="item.dataList.length > 0">
  113. <div class="div_hover" v-for="dataitem in item.dataList" :key="dataitem.dataId">
  114. <span style="display: inline-block;width: 130px;" :title="dataitem.name">{{
  115. dataitem.name.length > 10 ?
  116. dataitem.name.substring(0, 8) + '...' : dataitem.name }}</span>
  117. <span v-if="!checked1" class="el_popover_a" style="position: relative;left: 20px;top: 5px;"
  118. @click="downloadOne(dataitem.url, dataitem.name)">
  119. <img :src="DownloadImg" alt="">
  120. </span>
  121. <el-checkbox v-if="checked1" v-model="dataitem.checked" label="全选" size="large" />
  122. </div>
  123. <el-button style="margin-top: 10px;" v-if="checked1"
  124. @click="DownloadProcessing()">批量下载</el-button>
  125. </div>
  126. <div v-else>
  127. 暂无数据
  128. </div>
  129. </div>
  130. </el-popover>
  131. </div>
  132. </div>
  133. <div class="class_button" v-if="isupdateCourse">
  134. <el-popover v-if="item.courseType == '1'" placement="bottom" trigger="hover">
  135. <template #reference>
  136. <el-button
  137. style="width: 50%;background: rgba(255, 255, 245, 1);color: rgba(0, 0, 0, 0.6);">备课</el-button>
  138. </template>
  139. <ul class="beike">
  140. <li @click="openCourseDetail(item.id)">查看</li>
  141. <li @click="updateCourse(item.id, item)">修改</li>
  142. <li @click="ReductionCourse(item.id)">还原</li>
  143. </ul>
  144. </el-popover>
  145. <el-button :style="item.courseType == '1' ? 'width: 50%;' : 'width: 100%;'" class="el_button_active"
  146. @click="openCourseDetail(item.id, item)">上课</el-button>
  147. </div>
  148. </div>
  149. </el-col>
  150. </el-row>
  151. </div>
  152. </div>
  153. <div style="margin-top: 20px;">
  154. <span class="grandTitle2" v-if="gotype.gotype == 'bjs'">人工智能竞赛课</span>
  155. <span class="grandTitle2" v-else>竞赛主题课程</span>
  156. </div>
  157. <div class="course_select">
  158. <span class="grandTitle">课程类型:</span>
  159. <el-button @click="cutmod(0)" :class="[cutmodpage == 0 ? 'el_button_active' :'']">
  160. <span v-if="gotype.gotype == 'bjs'">智能体课程</span>
  161. <span v-else>智能体设计与应用课程</span>
  162. </el-button>
  163. <el-button @click="cutmod(1)" :class="[cutmodpage == 1 ? 'el_button_active' :'']">
  164. <span>创意智造课程</span>
  165. </el-button>
  166. <!-- <el-button :class="!courseTypeShow ? 'el_button_active' : ''" @click="SwitchCourseType(false)">AI通识课2024版</el-button> -->
  167. </div>
  168. <div class="course_select">
  169. <span class="grandTitle">模块:</span>
  170. <el-button :class="selectmod == '模块一' ? 'el_button_active' : ''" @click="clickmod('模块一')">模块一</el-button>
  171. <el-button v-if="cutmodpage == 0" :class="selectmod == '模块二' ? 'el_button_active' : ''" @click="clickmod('模块二')">模块二</el-button>
  172. <el-button v-if="cutmodpage == 0" :class="selectmod == '模块三' ? 'el_button_active' : ''" @click="clickmod('模块三')">模块三</el-button>
  173. <el-button v-if="gotype.gotype == 'bjs' && cutmodpage == 0" :class="selectmod == '模块四' ? 'el_button_active' : ''" @click="clickmod('模块四')">模块四</el-button>
  174. </div>
  175. <div class="course_select" v-if="gotype.gotype == 'bjs' && cutmodpage == 0">
  176. <div v-if="currentmodData && currentmodData.shang.length > 0">
  177. <el-row :gutter="20">
  178. <el-col :span="6" v-for="item in currentmodData.shang" :key="item.title" style="margin-top: 10px;">
  179. <div class="grid-content ep-bg-purple">
  180. <img :src="getImageUrl(item.url)" alt="">
  181. <div class="course_content">
  182. <div class="div_title">
  183. {{ item.title }}
  184. </div>
  185. </div>
  186. <div class="class_button" v-if="isupdateCourse">
  187. <el-button :style="item.courseType == '1' ? 'width: 50%;' : 'width: 100%;'" class="el_button_active"
  188. @click="openCourseDetail(item.id, item)">上课</el-button>
  189. </div>
  190. </div>
  191. </el-col>
  192. </el-row>
  193. </div>
  194. </div>
  195. <div class="course_select" v-if="cutmodpage == 1">
  196. <div v-if="currentAI6TwoData && currentAI6TwoData.shang.length > 0">
  197. <el-row :gutter="20">
  198. <el-col :span="6" v-for="item in currentAI6TwoData.shang" :key="item.title" style="margin-top: 10px;">
  199. <div class="grid-content ep-bg-purple">
  200. <img :src="getImageUrl(item.url)" alt="">
  201. <div class="course_content">
  202. <div class="div_title">
  203. {{ item.title }}
  204. </div>
  205. </div>
  206. <div class="class_button" v-if="isupdateCourse">
  207. <el-button :style="item.courseType == '1' ? 'width: 50%;' : 'width: 100%;'" class="el_button_active"
  208. @click="openCourseDetail(item.id, item)">上课</el-button>
  209. </div>
  210. </div>
  211. </el-col>
  212. </el-row>
  213. </div>
  214. </div>
  215. <div class="course_select" v-if="gotype.gotype != 'bjs' && cutmodpage == 0">
  216. <div v-if="currentAI6Data && currentAI6Data.shang.length > 0">
  217. <el-row :gutter="20">
  218. <el-col :span="6" v-for="item in currentAI6Data.shang" :key="item.title" style="margin-top: 10px;">
  219. <div class="grid-content ep-bg-purple">
  220. <img :src="getImageUrl(item.url)" alt="">
  221. <div class="course_content">
  222. <div class="div_title">
  223. {{ item.title }}
  224. </div>
  225. </div>
  226. <div class="class_button" v-if="isupdateCourse">
  227. <el-button :style="item.courseType == '1' ? 'width: 50%;' : 'width: 100%;'" class="el_button_active"
  228. @click="openCourseDetail(item.id, item)">上课</el-button>
  229. </div>
  230. </div>
  231. </el-col>
  232. </el-row>
  233. </div>
  234. </div>
  235. <el-dialog v-model="dialogVisible" :before-close="handleClose" width=500>
  236. <template #header>
  237. <div class="dialog-header img_text_middle">
  238. <img :src="WarningImg" alt="">
  239. <span class="warning_text">操作警告</span>
  240. </div>
  241. </template>
  242. <span>启用还原功能将重置当前修改,并将课程内容恢复至标准版本。请确认是否继续执行相关操作。</span>
  243. <template #footer>
  244. <div class="dialog-footer">
  245. <el-button type="primary" @click="updateReduction()">
  246. 确认修改
  247. </el-button>
  248. <el-button @click="dialogVisible = false">取消</el-button>
  249. </div>
  250. </template>
  251. </el-dialog>
  252. </template>
  253. <script setup>
  254. import { ref, onMounted, watchEffect } from 'vue';
  255. import { userCurrentRole, userInfoStore, userCurrent,pageGotype } from '../../stores/counter'
  256. // import JSZip from 'jszip';
  257. // import { saveAs } from 'file-saver';
  258. import DownloadImg from '@/assets/img/download.png'
  259. // import PDFImg from '@/assets/img/PDF.png'
  260. import WarningImg from '@/assets/icon/icon.png'
  261. import courseDataJson from '@/assets/course.json'
  262. // import { Value } from 'sass';
  263. // import { dataType } from 'element-plus/es/components/table-v2/src/common';
  264. import axios from 'axios';
  265. const props = defineProps({
  266. classDown: {
  267. type: Boolean,
  268. default: true
  269. }
  270. })
  271. const volumes = ref(true)
  272. const user = userInfoStore()
  273. const CurrentRole = userCurrentRole()
  274. const Current = userCurrent()
  275. const selectGrand = ref('三年级')
  276. const selectmod = ref('模块一')
  277. const gotype = pageGotype()
  278. const isupdateCourse = ref(false)
  279. const currentData = ref(courseDataJson.new.三年级)
  280. const currentmodData = ref(courseDataJson.mod.模块一)
  281. const currentAI6Data = ref(courseDataJson.AI6one.模块一)
  282. const currentAI6TwoData = ref(courseDataJson.AI6Two.模块一)
  283. const cutmodpage = ref('0')
  284. const dialogVisible = ref(false)
  285. const updateReductionId = ref("")
  286. const checked1 = ref(false)
  287. // const visible = ref(false)
  288. const getUpdateCourseId = ref("")
  289. const courseTypeShow = ref(true) // old 旧版 new 纲要
  290. const setIntervalNum = ref(null)
  291. const courseData = ref(courseDataJson.new)
  292. const modData = ref(courseDataJson.mod)
  293. const AI6Data = ref(courseDataJson.AI6one)
  294. const AI6TwoData = ref(courseDataJson.AI6Two)
  295. onMounted(() => {
  296. currentData.value = courseData.value["三年级"]
  297. getTimeCourse(1, 1)
  298. })
  299. const clickGrand = val => {
  300. selectGrand.value = val
  301. console.log('courseData.value',courseData.value);
  302. currentData.value = courseData.value[val]
  303. }
  304. const handleClose =(done)=>{
  305. done()
  306. }
  307. const cutmod = (val) => {
  308. cutmodpage.value = val
  309. clickmod(selectmod.value)
  310. }
  311. const clickmod = val => {
  312. selectmod.value = val
  313. if (gotype.gotype === 'bjs' && cutmodpage.value == 0) {
  314. currentmodData.value = modData.value[val]
  315. } else if (cutmodpage.value == 1) {
  316. currentAI6TwoData.value = AI6TwoData.value[val]
  317. } else if (gotype.gotype != 'bjs' && cutmodpage.value == 0){
  318. currentAI6Data.value = AI6Data.value[val]
  319. }
  320. }
  321. const SwitchCourseType = (val) => {
  322. courseTypeShow.value = val
  323. if (val) {
  324. courseData.value = courseDataJson.new
  325. volumes.value = true
  326. } else {
  327. courseData.value = courseDataJson.old
  328. }
  329. currentData.value = courseData.value[selectGrand.value]
  330. }
  331. const getImageUrl = (url) => {
  332. return new URL(url, import.meta.url).href
  333. }
  334. const openCourseDetail = (id) => {
  335. console.log(user.user)
  336. // 会返回复制得课程
  337. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/getcopyCourseByUseridSz", [id, user.user.userid], function (res) {
  338. console.log(res)
  339. if (res.value[0].length > 0) {
  340. // let isSave = res.value[0].filter(x => {
  341. // return x.courseId == id
  342. // })
  343. //这个是打开指定的课程接口
  344. top.U.MD.D.I.openInApplication("studyDetail", res.value[0][0].courseId, 2, user.user.type);
  345. } else {
  346. updateCourseId(id, "studyDetail")
  347. }
  348. }, [], { "type": "POST", "withCredentials": true });
  349. }
  350. const getTimeCourse = (id, item) => {
  351. if (setIntervalNum.value) {
  352. clearInterval(setIntervalNum.value)
  353. }
  354. try {
  355. setIntervalNum.value = setInterval(() => {
  356. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/addOperationTimeT", [user.user.userid, id, '5', 30], function (res) {
  357. console.log(res, "22222222222222222");
  358. }, [], { "type": "POST", "withCredentials": true });
  359. }, 30000)
  360. } catch (e) {
  361. console.log(e)
  362. }
  363. //
  364. const middleTime = Math.random() * 2 + 6;
  365. const interValtTime = Math.floor(middleTime * 60) * 1000 + 30000;
  366. const params = {
  367. serverName: "深教AI6",
  368. dataType: 0,
  369. teacherName: user.user.name,
  370. teacherAccount: "",
  371. eduId: Current.userCurrent.eduId,
  372. schoolName: user.user.schoolName,
  373. schoolType: "",
  374. area: "",
  375. coursePackageName: "AI课程",
  376. courseId: id,
  377. courseName: item.title,
  378. courseGrade: selectGrand.value,
  379. courseTime: Math.round(middleTime),
  380. startTime: new Date().toLocaleString().replace(/\//g, "-"),
  381. endTime: "",
  382. }
  383. setTimeout(() => {
  384. params.endTime = new Date().toLocaleString().replace(/\//g, "-")
  385. console.log(params, interValtTime)
  386. axios.post("//pbl.cocorobo.cn/api/szdjg/sync/class", JSON.stringify(params), {
  387. headers: {
  388. 'Content-Type': 'application/json'
  389. }
  390. }).then(res => {
  391. console.log(res)
  392. })
  393. }, interValtTime);
  394. }
  395. const updateCourse = (id, item) => {
  396. // 会返回courseId和state 两个参数 然后打开
  397. getTimeCourse(id, item)
  398. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/getcopyCourseByUseridSz", [id, user.user.userid], function (res) {
  399. console.log(res)
  400. if (res.value[0].length > 0) {
  401. // let isSave = res.value[0].filter(x => {
  402. // return x.courseId == id
  403. // })
  404. top.U.MD.D.I.openInApplication('openCourseNewUpdate', res.value[0][0].courseId); //这个是打开指定的课程接口
  405. } else {
  406. updateCourseId(id, "openCourseNewUpdate")
  407. }
  408. }, [], { "type": "POST", "withCredentials": true });
  409. }
  410. const updateCourseId = (id, type) => {
  411. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/copyCourseSz", [id, user.user.userid], function (res) {
  412. console.log(res)
  413. if (res.value[0][0].courseId != "") {
  414. if (type == "openCourseNewUpdate") {
  415. top.U.MD.D.I.openInApplication("openCourseNewUpdate", res.value[0][0].courseId)
  416. } else {
  417. top.U.MD.D.I.openInApplication("studyDetail", res.value[0][0].courseId, 3, user.user.type);
  418. }
  419. }
  420. }, [], { "type": "POST", "withCredentials": true });
  421. }
  422. const ReductionCourse = id => {
  423. // updateReductionId.value = id
  424. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/getcopyCourseByUseridSz", [id, user.user.userid], function (res) {
  425. console.log(res)
  426. if (res.value[0].length > 0) {
  427. // let isSave = res.value[0].filter(x => {
  428. // return x.courseId == id
  429. // })
  430. dialogVisible.value = true
  431. updateReductionId.value = res.value[0][0].courseId
  432. } else {
  433. ElMessage({
  434. message: '该课程就是最初课程,不能还原',
  435. type: 'warning',
  436. })
  437. }
  438. }, [], { "type": "POST", "withCredentials": true });
  439. }
  440. const updateReduction = () => {
  441. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/revertCourseSz", [updateReductionId.value], function (res) {
  442. console.log(res, "还原")
  443. dialogVisible.value = false
  444. }, [], { "type": "POST", "withCredentials": true });
  445. }
  446. const getDate = async (id) => {
  447. // currentData
  448. let dataList = [];
  449. return new Promise((resolve, reject) => {
  450. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/selectCourseDetailSz", [id], function (res) {
  451. console.log(res);
  452. if (!res || !res.value || res.value[0].length === 0 || res.value[0][0].chapters.length === 0) {
  453. reject(new Error("Invalid response or no chapters found"));
  454. return;
  455. }
  456. const datachapters = JSON.parse(res.value[0][0].chapters);
  457. for (let i = 0; i < datachapters.length; i++) {
  458. const data = datachapters[i];
  459. for (let j = 0; j < data.chapterInfo.length; j++) {
  460. const dataChapterInfo = data.chapterInfo[j];
  461. for (let k = 0; k < dataChapterInfo.taskJson.length; k++) {
  462. const DatahapterData = dataChapterInfo.taskJson[k];
  463. for (let l = 0; l < DatahapterData.chapterData.length; l++) {
  464. const obj = DatahapterData.chapterData[l];
  465. obj.checked = false;
  466. dataList.push(obj);
  467. }
  468. }
  469. }
  470. }
  471. resolve(dataList);
  472. }, [], { "type": "POST", "withCredentials": true });
  473. })
  474. .then((dataList) => {
  475. getUpdateCourse(dataList, id);
  476. })
  477. .catch((error) => {
  478. console.error("Error fetching data:", error);
  479. });
  480. };
  481. const getUpdateCourse = async (dataList, id) => {
  482. let m = currentData.value
  483. if (volumes.value) {
  484. await m.shang.map(x => {
  485. if (x.dataId == id) {
  486. x.dataList = dataList
  487. }
  488. return x
  489. })
  490. } else {
  491. await m.xia.map(x => {
  492. if (x.dataId == id) {
  493. x.dataList = dataList
  494. }
  495. return x
  496. })
  497. }
  498. currentData.value = m
  499. getUpdateCourseId.value = id
  500. }
  501. const checkedAll = (id) => {
  502. let data = currentData.value
  503. if (volumes.value) {
  504. data.shang.map(x => {
  505. x.dataList.map(y => {
  506. y.checked = false
  507. })
  508. })
  509. data.shang.map(x => {
  510. if (x.dataId == id) {
  511. x.dataList.map(y => {
  512. y.checked = !checked1.value
  513. })
  514. }
  515. return x
  516. })
  517. } else {
  518. data.xia.map(x => {
  519. if (x.dataId == id) {
  520. x.dataList.map(y => {
  521. y.checked = !checked1.value
  522. })
  523. }
  524. return x
  525. })
  526. }
  527. console.log(id, checked1.value)
  528. console.log(data)
  529. currentData.value = data
  530. // checked1.value = true
  531. }
  532. const downloadOne = async (url, fileName) => {
  533. try {
  534. console.log("urls", [user.user.userid, getUpdateCourseId.value, '4', 1])
  535. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/addOperationTimeT", [user.user.userid, getUpdateCourseId.value, '4', 1], function (res) {
  536. console.log(res, '11111111111')
  537. }, [], { "type": "POST", "withCredentials": true });
  538. } catch (error) {
  539. console.log(error);
  540. }
  541. try {
  542. // 使用fetch获取文件,然后创建blob下载
  543. const response = await fetch(url);
  544. const blob = await response.blob();
  545. // 创建blob URL
  546. const blobUrl = window.URL.createObjectURL(blob);
  547. const a = document.createElement('a');
  548. a.style.display = 'none';
  549. a.href = blobUrl;
  550. a.download = fileName || 'download.pdf';
  551. document.body.appendChild(a);
  552. a.click();
  553. document.body.removeChild(a);
  554. // 清理blob URL
  555. setTimeout(() => {
  556. window.URL.revokeObjectURL(blobUrl);
  557. }, 100);
  558. } catch (error) {
  559. console.log('Fetch下载失败:', error);
  560. // 回退方案:直接在新窗口打开,让用户手动保存
  561. window.open(url, '_blank');
  562. }
  563. }
  564. const DownloadProcessing = async () => {
  565. let data = currentData.value
  566. let urls = []
  567. if (volumes.value) {
  568. await data.shang.map(x => {
  569. // console.log(x)
  570. x.dataList.length > 0 && x.dataList.map(m => {
  571. if (m.checked) {
  572. urls.push(m)
  573. }
  574. return m
  575. })
  576. return x
  577. })
  578. } else {
  579. await data.xia.map(x => {
  580. // console.log(x)
  581. x.dataList.length > 0 && x.dataList.map(m => {
  582. if (m.checked) {
  583. urls.push(m)
  584. }
  585. return m
  586. })
  587. return x
  588. })
  589. }
  590. try {
  591. console.log("urls", [user.user.userid, getUpdateCourseId.value, '4', urls.length])
  592. top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/addOperationTimeT", [user.user.userid, getUpdateCourseId.value, '4', urls.length], function (res) {
  593. console.log(res, '11111111111')
  594. }, [], { "type": "POST", "withCredentials": true });
  595. } catch (error) {
  596. console.log(error);
  597. }
  598. for (let i = 0; i < urls.length; i++) {
  599. fetch(urls[i].url)
  600. .then(response => response.blob()) // 获取文件数据流
  601. .then(blob => {
  602. const url = window.URL.createObjectURL(blob); // 生成文件在浏览器中的链接
  603. const a = document.createElement('a');
  604. a.href = url;
  605. a.download = urls[i].name; // 文件名
  606. a.style.display = 'none';
  607. document.body.appendChild(a);
  608. a.click();
  609. document.body.removeChild(a);
  610. window.URL.revokeObjectURL(url); // 清除文件链接
  611. })
  612. .catch(console.error);
  613. }
  614. }
  615. // 获取课程下载资料
  616. // top.U.A.Request("https://pbl.cocorobo.cn/api/pbl/selectCourseDetailSz", ['课程id'], function (res) {}, [], { "type": "POST", "withCredentials": true });
  617. watchEffect(() => {
  618. if (JSON.stringify(user.user) != "{}") {
  619. if (CurrentRole.currentRole == "edupersonnel" || CurrentRole.currentRole == "areaAdministrator" || CurrentRole.currentRole == "userAdministrator" || CurrentRole.currentRole == "securityAuditor" || CurrentRole.currentRole == "schoolAdministrator" || CurrentRole.currentRole == "schoolSecurityAuditor" || CurrentRole.currentRole == "teacher" || user.type != 2) {
  620. isupdateCourse.value = true
  621. }
  622. }
  623. })
  624. </script>
  625. <style lang="scss" scoped>
  626. .course_select {
  627. margin-top: 10px;
  628. .grid-content {
  629. border-radius: 4px;
  630. min-height: 36px;
  631. background: #fff;
  632. padding: 12px;
  633. // height: 300px;
  634. img {
  635. width: 100%;
  636. border-radius: 5px;
  637. }
  638. .course_content {
  639. .div_title {
  640. margin-top: 10px;
  641. white-space: nowrap;
  642. text-overflow: ellipsis;
  643. overflow: hidden;
  644. span {
  645. // display: inline-block;
  646. padding: 2px 8px;
  647. background: rgba(224, 234, 251, 1);
  648. border-radius: 5px;
  649. font-size: 12px;
  650. color: rgba(54, 129, 252, 1);
  651. }
  652. img {
  653. width: 28px;
  654. cursor: pointer;
  655. float: right;
  656. }
  657. }
  658. }
  659. }
  660. .Screening {
  661. font-size: 20px;
  662. font-weight: 400;
  663. line-height: 28px;
  664. letter-spacing: 0em;
  665. text-align: center;
  666. color: rgba(0, 0, 0, 0.9);
  667. }
  668. .grandTitle {
  669. font-size: 15px;
  670. font-weight: 400;
  671. line-height: 28px;
  672. letter-spacing: 0em;
  673. text-align: center;
  674. }
  675. .el-button {
  676. // background: rgba(54, 129, 252, 1);
  677. color: rgba(54, 129, 252, 1);
  678. }
  679. .el_button_active {
  680. background: rgba(54, 129, 252, 1);
  681. color: #fff;
  682. }
  683. .class_button {
  684. margin-top: 15px;
  685. display: flex;
  686. justify-content: space-between;
  687. }
  688. }
  689. .el-row {
  690. margin-top: 20px;
  691. margin-bottom: 20px;
  692. }
  693. .el-row:last-child {
  694. margin-bottom: 0;
  695. }
  696. .el-col {
  697. border-radius: 4px;
  698. }
  699. .warning_text {
  700. font-weight: bold;
  701. font-size: 16px;
  702. color: rgba(0, 0, 0, 0.9);
  703. margin-left: 8px;
  704. }
  705. .div_hover {
  706. // padding: 8px 0 10px;
  707. height: 35px;
  708. line-height: 35px;
  709. }
  710. .div_hover:hover {
  711. background: rgb(240, 242, 245);
  712. }
  713. .el_popover_a {
  714. display: none;
  715. }
  716. .div_hover:hover .el_popover_a {
  717. display: inline-block;
  718. }
  719. .beike {
  720. li {
  721. padding: 8px 5px;
  722. border-radius: 5px;
  723. }
  724. li:hover {
  725. background: rgba(0, 0, 0, 0.1);
  726. cursor: pointer;
  727. }
  728. }
  729. .Levelone{
  730. width: 120px;
  731. background: #E0EAFB;
  732. border-radius: 5px;
  733. color: #5D8AFB;
  734. display: flex;
  735. justify-content: center;
  736. align-items: center;
  737. height: 33px;
  738. font-size: 16px;
  739. font-weight: 500;
  740. }
  741. .grandTitle2 {
  742. font-size: 16px;
  743. font-weight: 600 !important;
  744. line-height: 28px;
  745. letter-spacing: 0em;
  746. // text-align: center;
  747. }
  748. .grandTitle3{
  749. margin-top: 0;
  750. }
  751. </style>