From 375513370cc01fcd976987d07797249600b0bb3e Mon Sep 17 00:00:00 2001 From: 杨磊 <505174330@qq.com> Date: 星期四, 07 八月 2025 17:15:09 +0800 Subject: [PATCH] 'first' --- src/components/detail/resource.vue | 482 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 482 insertions(+), 0 deletions(-) diff --git a/src/components/detail/resource.vue b/src/components/detail/resource.vue new file mode 100644 index 0000000..a863fd5 --- /dev/null +++ b/src/components/detail/resource.vue @@ -0,0 +1,482 @@ +<template> + <div class="resourceBox"> + <div> + <div class="itemTitle"> + <div class="titleName">閰嶅璧勬簮绀轰緥</div> + </div> + <div class="resourceItem" v-if="resourceSupportList.length > 0"> + <div + class="itemBox" + v-for="(item, index) in resourceSupportList" + :key="index" + > + <div class="tag"> + {{ item.caupress_fileType.split("_")[1] | fileType }} + </div> + <div class="countentBox"> + {{ item.name }} + </div> + <div class="previewBox"> + <div @click="preview(item)"> + 棰勮 + <i class="iconfont icon-icon_yulan"></i> + </div> + <div @click="collectReource(item)" v-if="!item.isFavourite"> + 鏀惰棌 + <i class="iconfont icon-shoucang"></i> + </div> + <div @click="collectReource(item)" v-else> + 宸叉敹钘� + <i class="iconfont icon-shoucang" style="color: red"></i> + </div> + </div> + </div> + </div> + <el-empty :image-size="100" description="鏆傛棤璧勬簮" v-else></el-empty> + </div> + + <div> + <div class="itemTitle allResource"> + <div class="titleName">鍏ㄩ儴璧勬簮</div> + <span + v-if=" + userInfo && + userInfo.role == 'Teacher' && + downloadState == undefined && + allResource.length > 0 + " + class="applyForDownload" + @click="applyForDownload" + > + 鐢宠涓嬭浇 + <i class="el-icon-download"></i> + </span> + <span + v-if=" + userInfo && + userInfo.role == 'Teacher' && + downloadState == 'Normal' && + allResource.length > 0 + " + class="resoucename2btn" + > + 缁撴潫鏃堕棿锛歿{ downloadEndDate }} + </span> + <span + v-if=" + userInfo && + userInfo.role == 'Teacher' && + downloadState == 'WaitAudit' && + allResource.length > 0 + " + class="resoucename3" + > + 瀹℃牳涓�.. + </span> + <span + v-if=" + userInfo && + userInfo.role == 'Teacher' && + downloadState == 'Reject' && + allResource.length > 0 + " + class="popoverItem" + > + <el-popover width="400" placement="top" trigger="hover"> + <p class="reason"> + <span> 鎷掔粷鍘熷洜锛� </span> + {{ popoverReasen }} + </p> + <el-button class="reApply" type="success" @click="applyForDownload" + >閲嶆柊鐢宠</el-button + > + <template slot="reference"> + <span style="cursor: pointer"> 宸叉嫆缁� </span> + </template> + </el-popover> + </span> + </div> + <div class="resourceItem" v-if="allResource.length > 0"> + <div class="itemBox" v-for="(item, index) in allResource" :key="index"> + <div class="tag allTag"> + {{ item.caupress_fileType.split("_")[1] }} + </div> + <div class="countentBox"> + {{ item.name }} + </div> + <div class="previewBox allBox" v-if="downloadState == 'Normal'"> + <div + @click="downloadResource(item)" + v-if="downloadState == 'Normal'" + > + 涓嬭浇 + <i class="iconfont icon-xiazai"></i> + </div> + + <!-- <div + @click="collectReource(item)" + v-if="!item.isFavourite" + > + 鏀惰棌 + <i class="iconfont icon-shoucang"></i> + </div> + <div + @click="collectReource(item)" + v-else + > + 宸叉敹钘� + <i + class="iconfont icon-shoucang" + style="color: #009a44" + ></i> + </div> --> + </div> + <div class="previewBox allBox grey" v-else> + + </div> + </div> + </div> + <el-empty :image-size="100" description="鏆傛棤璧勬簮" v-else></el-empty> + </div> + </div> +</template> + +<script> +import { mapState } from "vuex"; +export default { + props: { + allResource: { + type: Array, + default: () => {}, + }, + resourceSupportList: { + type: Array, + default: () => {}, + }, + bookInfo: { + type: Object, + default: () => {}, + }, + }, + computed: { + ...mapState(["userInfo"]), + }, + data() { + return { + resourceTypeList: { + caupress_audio: "闊抽", + caupress_video: "瑙嗛", + caupress_zip: "璧勬簮鍖�", + caupress_pdf: "PDF", + caupress_img: "鍥剧墖", + caupress_document: "鏂囨。", + }, + downloadState: "WaitAudit", // 涓嬭浇鐘舵�� + popoverReasen: "", // 瀹℃牳鎷掔粷鐨勫師鍥� + }; + }, + created() { + this.isPass(); + }, + filters: { + fileType: function (val) { + if (val == "audio") { + return "mp3"; + } else if (val == "video") { + return "mp4"; + } else { + return val; + } + }, + }, + methods: { + // 鏈喘涔扮偣鍑绘敹钘� + + toBuyBook() { + this.$alert("褰撳墠涔︾睄灏氭湭璐拱锛岃璐拱鍚庢搷浣滐紒", "鎻愮ず", { + confirmButtonText: "纭畾", + callback: (action) => {}, + }); + }, + // 涓嬭浇璧勬簮 + downloadResource(item) { + let end = new Date(this.downloadEndDate + "T23:59:59").getTime(); + let getEndNum = Number(sessionStorage.currentDate); + console.log(); + console.log(end,"end"); + console.log(getEndNum,"getEndNum"); + + if (end < getEndNum) { + this.$message({ + type: "warning", + message: "鍏佽璧勬簮鍙笅杞芥椂闂村凡鍒版湡锛岃鑱旂郴绠$悊鍛橈紒", + }); + return false; + } + // if (this.downloadState != "Normal") { + // this.$message({ + // type: "warning", + // message: "鏈敵璇疯祫婧愪笅杞芥垨鐢宠鏈�氳繃锛岃鑱旂郴绠$悊鍛橈紒", + // }); + // return false; + // } + let url = + this.config.requestCtx + + "/file/api/ApiDownload?md5=" + + item.caupress_file; + window.open(url, "_blank"); + }, + + downloadSupport(item) { + if (item.caupress_file) { + let url = + this.config.requestCtx + + "/file/api/ApiDownload?md5=" + + item.caupress_file; + window.open(url, "_blank"); + } else { + this.$message({ + type: "warning", + message: "鏆傛棤鍙笅杞借祫婧�", + }); + } + }, + + // 棰勮 + preview(item) { + let previewType = item.caupress_fileType.split("_")[1]; + console.log(previewType, "previewType"); + if (previewType == "zip") { + this.$message({ + type: "warning", + message: "姝ゆ枃浠剁被鍨嬩笉鏀寔棰勮", + }); + } else { + this.$router.push({ + name: `preview-${previewType}`, + query: { + md5: item.caupress_file, + titleName: item.name, + productLinkPath: item.productLinkInfo[0].LinkPath, + }, + }); + } + }, + // 鐢宠涓嬭浇 + applyForDownload() { + let obj = { + name: this.bookInfo.name, // 涔﹀悕 + icon: this.bookInfo.icon, // 灏侀潰 + idPath: this.bookInfo.idPath, // 璇锋眰璺緞 + rootCmsItemId: this.bookInfo.rootCmsItemId, + isdn: this.bookInfo.caupress_ISBN, // ISDN鍙� + author: this.bookInfo.caupress_author, // 浣滆�� + id: this.bookInfo.id, + }; + this.MG.ugc.delTopicMessage({ messageIds: [] }).then(() => {}); + let data = { + topicIdOrRefCode: this.config.refCodes.productDownLoad, + name: this.bookInfo.name, + content: JSON.stringify(obj), + state: "WaitAudit", + type: "applyForDownload", + icon: this.bookInfo.icon, + cmsTypeRefCode: "", + newDataListRequest: [], + }; + + this.MG.ugc.newTopicMessage(data).then((res) => { + if (res) { + this.$message({ + type: "success", + message: "鐢宠鎴愬姛锛岀瓑寰呯鐞嗗憳瀹℃牳!", + }); + this.isPass(); + } + }); + }, + + //鏀惰棌 + collectReource(item) { + if (item.isFavourite) { + this.MG.resource + .delCmsItemLink({ + cmsItemIds: [item.id], + linkType: "Favorite", + }) + .then((res) => { + this.$parent.getData(); + }); + } else { + this.MG.resource + .collectCmsItem({ + cmsItemIds: [item.id], + linkType: "Favorite", + }) + .then((res) => { + this.$parent.getData(); + }); + } + }, + + // 鑾峰彇鐢宠鐨勪笅杞界姸鎬� + isPass() { + let data = { + start: 0, + size: 1, + topicIdOrRefCode: "productDownLoad", + appRefCode: this.config.appRefCode, + sort: { + type: "Desc", + field: "CreateDate", + }, + }; + this.MG.ugc.getTopicMessageList(data).then((res) => { + // try { + console.log(res,"endTime"); + if (res.datas.length > 0) { + this.downloadState = res.datas[0].state; + if (res.datas[0].feedBack) { + let feedBack = JSON.parse(res.datas[0].feedBack); + res.datas[0].endDate = feedBack.endDate ? feedBack.endDate : ""; + this.popoverReasen = feedBack.reason ? feedBack.reason : ""; + this.downloadEndDate = res.datas[0].endDate; + let end = new Date(this.downloadEndDate + "T23:59:59").getTime(); + let getEndNum = Number(sessionStorage.currentDate); + if (end < getEndNum) { + this.downloadState = undefined; + } + } + } else { + this.downloadState = undefined; + } + console.log(this.downloadState,"downloadState"); + // } catch (error) { + // this.downloadState = undefined; + // } + }); + }, + }, +}; +</script> + +<style scoped> +.resourceBox { + width: 813px; + background-color: #fff; + margin: 10px 0 0 10px; + padding: 40px; + box-sizing: border-box; +} +.itemTitle { + height: 30px; + line-height: 30px; + padding: 0 10px; + background: #f8f8f8; + /* position: relative; */ +} +.titleName { + font-size: 18px; + font-weight: 700; + /* position: absolute; + top: -10px; */ +} +.applyForDownload { + font-size: 16px; + font-weight: 700; + color: #00873c; + cursor: pointer; +} +.resourceItem { + display: flex; + flex-wrap: wrap; + justify-content: space-between; +} +.itemBox { + width: 350px; + height: 120px; + box-shadow: 2px 2px 10px #f2f2f2; + margin-top: 20px; + position: relative; + border-radius: 4px; + line-height: 80px; +} +.tag { + position: absolute; + width: 60px; + height: 20px; + background-color: #f2f2f2; + right: 0px; + text-align: center; + line-height: 20px; + border-radius: 0px 4px 0px 4px; +} +.previewBox { + width: 100%; + position: absolute; + height: 40px; + background-color: #d8f7e6; + bottom: 0px; + border-radius: 4px; + text-align: center; + line-height: 40px; + color: #00873c; + cursor: pointer; + display: flex; + justify-content: space-around; +} + +.disable { + background-color: #ccc; +} +.countentBox { + height: 60px; + margin-top: 20px; + line-height: 30px; + padding: 0 20px; + color: #444444; + font-weight: 700; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; /* 杩欓噷鏄秴鍑哄嚑琛岀渷鐣� */ + overflow: hidden; +} +.allResource { + margin-top: 40px; + display: flex; + justify-content: space-between; + font-size: 18px; + font-weight: 700; +} +.allTag { + background-color: #d8f7e6; + color: #00873c; +} +.allBox { + background-color: #00873c; + color: #fff; +} +.resoucename2btn { + font-size: 14px; + color: #00873c; +} +.resoucename3 { + color: #8b4513; + font-size: 14px; +} +.popoverItem { + color: #ee0a24; + font-size: 14px; +} +.reApply { + float: right; +} +.reason { + display: inline-block; + padding-bottom: 20px; +} +.grey{ + background-color: #ccc; +} +</style> -- Gitblit v1.9.1