فهرست منبع

管理员和评审员可下载评审数据

SanHQin 1 سال پیش
والد
کامیت
88fa2f4db5
1فایلهای تغییر یافته به همراه80 افزوده شده و 5 حذف شده
  1. 80 5
      src/components/pages/disAdmin/score.vue

+ 80 - 5
src/components/pages/disAdmin/score.vue

@@ -44,7 +44,8 @@
           
         </div>
         <div class="aName">
-          <div class="search" @click="search">
+          <div class="search" @click="search" :style="`right:170px;`">
+						<!--  ${tType==0?170:90} -->
             <img src="../../../assets/icon/search.png" alt="" />
           </div>
           <el-input
@@ -53,6 +54,7 @@
             placeholder="请输入案例名称"
           ></el-input>
 					<div @click="clear" class="clear">重置</div>
+					<div @click="downExcel" class="clear">下载</div>
           <!-- @input="search" -->
         </div>
       </div>
@@ -464,6 +466,7 @@
 </template>
 
 <script>
+import XLSX from "xlsx"
 export default {
   data() {
     return {
@@ -491,6 +494,7 @@ export default {
       anliName: "",
       anliBox: "",
       tableData: [],
+			downExcelData:[],
 			scoreListData:[],
 			allScoreList:[],
 			scoreFn:2,// 0 默认 1 升序  2 降序
@@ -706,6 +710,79 @@ export default {
       this.anliBox = "";
       this.getAnliList(this.reCid);
     },
+		downExcel(){
+			let header = [];
+			let excelData = [];
+			let title = '评审数据.xlsx'
+			// 处理导出数据  0管理员    2评审
+			if(this.tType==0){
+				header = ["序号","项目案例","案例分类","所属单位","评委姓名/分数","平均得分"]
+				excelData = this.downExcelData.map((i,index)=>{
+					return [
+						index+1,
+						i.info.title ? i.info.title : "暂无名称",
+						i.typename ? i.typename : '-',
+						i.school ? i.school : '-',
+						i.scoreList.length>0?i.scoreList.map(s=>s.name+"/"+s.score).join(","):'-',
+						i.scoreList.length>0?i.scoreList.length>=2?i.sum?i.sum:'-':'-':"",
+					]
+				})
+				title = `${this.$store.state.userInfo.name} 管理员评审数据.xlsx`
+			}else if(this.tType==2){
+				header = ["序号","项目案例","案例分类","我的评分","评分时间"]
+				excelData = this.downExcelData.map((i,index)=>{
+					return [
+						index+1,
+						i.info.title ? i.info.title : "暂无名称",
+						i.typename ? i.typename : '-',
+						i.ownScore? i.ownScore : '-',
+						i.scoreTime? i.scoreTime : '-'
+					]
+				})
+				title = `${this.$store.state.userInfo.name} 评审员评审数据.xlsx`
+			}else{
+				return
+			}
+
+			// 将表头添加到数据的最前面
+			excelData.unshift(header)
+
+			// 创建一个新的工作簿
+			let wb = XLSX.utils.book_new();
+
+			// 将数据转换为工作表
+			let ws = XLSX.utils.aoa_to_sheet(excelData);
+
+			// 将工作表添加到工作簿
+			XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
+
+			// 将工作簿转换为blob
+			const wbout = XLSX.write(wb, {bookType:'xlsx', bookSST:true, type: 'binary'});
+
+			function s2ab(s) {
+			    var buf = new ArrayBuffer(s.length);
+			    var view = new Uint8Array(buf);
+			    for (var i=0; i<s.length; i++) view[i] = s.charCodeAt(i) & 0xFF;
+			    return buf;
+			}
+
+			// 创建一个blob对象
+			let blob = new Blob([s2ab(wbout)], {type: 'application/octet-stream'});
+
+			// 创建一个隐藏的a标签,设置其href属性为blob对象的url,download属性为文件名
+			let a = document.createElement('a');
+			a.style.display = 'none';
+			a.href = URL.createObjectURL(blob);
+			a.download = title;
+			document.body.appendChild(a);
+
+			// 模拟点击a标签,开始下载
+			a.click();
+
+			// 下载完成后,移除a标签
+			setTimeout(function() { URL.revokeObjectURL(a.href); document.body.removeChild(a); }, 100);
+
+		},
     getAnliList(rc) {
       this.isLoading = true;
       var typeE = [];
@@ -847,7 +924,7 @@ export default {
 					
 
 					sessionStorage.setItem("allScoreList",JSON.stringify(p.map(i=>i.id)))
-
+					this.downExcelData = p;
 					const start = (this.page - 1) * 10;
           const end = start + 10;
           let result = p.slice(start, end);
@@ -856,8 +933,6 @@ export default {
 						let typeName = i.typename;
 						if(typeName=="活动类" || typeName =="学科类" || !typeName)return;
 						let replaceValue = "";
-						// console.log(typeName.indexOf("活动类"))
-						// console.log(typeName.indexOf("理科类"))
 						if(typeName.indexOf("活动类")!=-1){
 							replaceValue = typeName.replace("活动类","")
 							typeName = `活动类:${replaceValue.split('/').filter(f=>f!=='').join('/')}`
@@ -1544,6 +1619,7 @@ export default {
   line-height: 35px;
   cursor: pointer;
   font-size: 16px;
+	margin-right: 10px;
 }
 .anliCss {
   display: flex;
@@ -1759,7 +1835,6 @@ export default {
   width: 25px;
   position: absolute;
   top: 7px;
-  right: 80px;
   z-index: 9;
   cursor: pointer;
 }