|
@@ -1,13 +1,13 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- <el-tree :data="treeData" :props="defaultProps" class="ac-quo-tree" node-key="id" ref="tree" :render-content="renderContent" :render-after-expand="false" @node-click="nodeClick"></el-tree>
|
|
|
- <Modal v-model="uploadStatus" fullscreen>
|
|
|
+ <el-tree default-expand-all :data="treeData" :props="defaultProps" class="ac-quo-tree" node-key="id" ref="tree" :render-content="renderContent" :render-after-expand="false" @node-click="nodeClick"></el-tree>
|
|
|
+ <Modal v-model="uploadStatus" fullscreen @on-visible-change="handleHideModal" @on-ok="confirmUpload" :loading="modalLoading">
|
|
|
<p slot="header" style="height:fit-content">
|
|
|
批量上传
|
|
|
</p>
|
|
|
<div>
|
|
|
<Upload multiple class="batch-upload-box" type="drag" action="" :before-upload="handleBeforeUpload">
|
|
|
- <div style="padding: 60px 0;background:#f6f6f6;">
|
|
|
+ <div style="padding: 30px 0;background:#f6f6f6;">
|
|
|
<Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon>
|
|
|
<p style="font-size:18px;margin-top:10px;margin-bottom:10px">
|
|
|
批量上传学生资料<strong style="color:#ed4014">(文件请以学生姓名或者学生id命名)</strong>
|
|
@@ -37,6 +37,7 @@
|
|
|
<script>
|
|
|
import ExamData from "./ExamData.vue"
|
|
|
import WorkData from "./WorkData.vue"
|
|
|
+import BlobTool from '@/utils/blobTool.js'
|
|
|
export default {
|
|
|
components: {
|
|
|
ExamData, WorkData
|
|
@@ -67,6 +68,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ modalLoading: true,
|
|
|
uploadStatus: false,
|
|
|
defaultProps: {
|
|
|
children: "children",
|
|
@@ -91,6 +93,99 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ getDefaultOpenNode(treeData) {
|
|
|
+ if (treeData[0].children.length) {
|
|
|
+ return this.getDefaultOpenNode(treeData[0].children)
|
|
|
+ }else{
|
|
|
+ return treeData[0]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ confirmUpload() {
|
|
|
+ if (!this.fileData.length) return
|
|
|
+ let taskId = this.getTaskId(this.uploadNode.id)
|
|
|
+ if (!taskId) return
|
|
|
+ let schoolSas = {
|
|
|
+ sas: '?' + this.$store.state.user.schoolProfile.blob_sas,
|
|
|
+ url: this.$store.state.user.schoolProfile.blob_uri.slice(0, this.$store.state.user.schoolProfile.blob_uri.lastIndexOf(this.$store.state.userInfo.schoolCode) - 1),
|
|
|
+ name: this.$store.state.userInfo.schoolCode
|
|
|
+ }
|
|
|
+ let blobTool = new BlobTool(schoolSas.url, schoolSas.name, schoolSas.sas, 'school')
|
|
|
+ let promises = []
|
|
|
+ let useInfo = this.fileData.filter(item => !!item.studentId)
|
|
|
+ useInfo.forEach(fileItem => {
|
|
|
+ promises.push(blobTool.upload(fileItem.file, {
|
|
|
+ path: `art/${this.artInfo.id}/homework/${taskId}/${fileItem.studentId}`
|
|
|
+ }))
|
|
|
+ })
|
|
|
+ Promise.all(promises).then(
|
|
|
+ reses => {
|
|
|
+ console.log(reses)
|
|
|
+ let stus = []
|
|
|
+ reses.forEach((res, index) => {
|
|
|
+ let stuItem = stus.find(s => s.stuId === useInfo[index].studentId)
|
|
|
+ if (!stuItem) {
|
|
|
+ stuItem = {
|
|
|
+ stuId: useInfo[index].studentId,
|
|
|
+ userType: useInfo[index].userType,
|
|
|
+ attachments: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stuItem.attachments.push({
|
|
|
+ name: res.name,
|
|
|
+ url: res.url,
|
|
|
+ size: res.size,
|
|
|
+ createTime: res.createTime,
|
|
|
+ extension: res.extension,
|
|
|
+ type: res.type,
|
|
|
+ blob: res.blob
|
|
|
+ })
|
|
|
+ stus.push(stuItem)
|
|
|
+ })
|
|
|
+ this.doSaveBatchUpload(stus, taskId)
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ doSaveBatchUpload(stus, acId) {
|
|
|
+ let params = {
|
|
|
+ artId: this.artInfo.id,
|
|
|
+ classId: this.curClass.id,
|
|
|
+ quotaId: this.uploadNode.id,
|
|
|
+ acId: acId,
|
|
|
+ subject: this.subjectId,
|
|
|
+ stus
|
|
|
+ }
|
|
|
+ this.$api.areaArt.batchUploadWork(params).then(
|
|
|
+ res => {
|
|
|
+ if (!res.error) {
|
|
|
+ this.$Message.success('上传成功')
|
|
|
+ this.uploadStatus = false
|
|
|
+ if (this.activeNode.id == this.uploadNode.id) {
|
|
|
+ let comp = this.$refs[`${this.uploadNode.id}_data`]
|
|
|
+ if (comp) comp.findArtWorkData()
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$Message.error('上传失败')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ this.$Message.error('上传失败')
|
|
|
+ }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ getTaskId(nodeId) {
|
|
|
+ let setting = this.artInfo?.settings.find(item => item.id === nodeId)
|
|
|
+ if (setting && setting.task) {
|
|
|
+ let task = setting.task.find(item => item.subject === this.subjectId)
|
|
|
+ return task?.acId || undefined
|
|
|
+ }
|
|
|
+ return undefined
|
|
|
+ },
|
|
|
+ handleHideModal(status) {
|
|
|
+ if (!status) this.fileData = []
|
|
|
+ },
|
|
|
handleBeforeUpload(file) {
|
|
|
let fileItem = {
|
|
|
file,
|
|
@@ -102,10 +197,16 @@ export default {
|
|
|
if (studentInfo) {
|
|
|
fileItem.studentName = studentInfo.name
|
|
|
fileItem.studentId = studentInfo.id
|
|
|
+ fileItem.userType = studentInfo.type
|
|
|
}
|
|
|
console.log(n, studentInfo)
|
|
|
}
|
|
|
- this.fileData.push(fileItem)
|
|
|
+ let index = this.fileData.findIndex(item => item.fileName === file.name)
|
|
|
+ if (index >= 0) {
|
|
|
+ this.fileData.splice(index, 1, fileItem)
|
|
|
+ } else {
|
|
|
+ this.fileData.push(fileItem)
|
|
|
+ }
|
|
|
return false
|
|
|
},
|
|
|
getNodeSetting(id) {
|
|
@@ -156,12 +257,12 @@ export default {
|
|
|
{
|
|
|
class: "type-setting",
|
|
|
props: {
|
|
|
- color: "primary"
|
|
|
+ color: "primary",
|
|
|
},
|
|
|
nativeOn: {
|
|
|
click: (evt) => {
|
|
|
- console.log(node)
|
|
|
_this.uploadStatus = true
|
|
|
+ _this.uploadNode = node.data
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -182,14 +283,15 @@ export default {
|
|
|
: undefined,
|
|
|
_this.activeNode?.id == node.data.id &&
|
|
|
node.data.type === 2
|
|
|
- ? h(
|
|
|
+ ? _this.$createElement(
|
|
|
WorkData,
|
|
|
{
|
|
|
class: ["data-wrap"],
|
|
|
+ ref: node.data.id + '_data',
|
|
|
props: {
|
|
|
taskInfo: _this.getNodeSetting(node.data.id),
|
|
|
curClass: _this.curClass,
|
|
|
- subjectId: _this.subjectId
|
|
|
+ subjectId: _this.subjectId,
|
|
|
}
|
|
|
}
|
|
|
)
|
|
@@ -198,6 +300,13 @@ export default {
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ console.log('*****', this.treeData)
|
|
|
+ if (this.treeData && this.treeData.length) {
|
|
|
+ this.activeNode = this.getDefaultOpenNode(this.treeData)
|
|
|
+ console.log(this.activeNode)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|