Quellcode durchsuchen

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

zhouj1203@hotmail.com vor 2 Jahren
Ursprung
Commit
d2f1af9fe9

+ 4 - 0
TEAMModelOS/ClientApp/src/api/areaArt.js

@@ -29,4 +29,8 @@ export default {
     findArtWork: function (data) {
         return post('/common/art/find-summary-by-work', data)
     },
+    /* 教师端批量提交作业 */
+    batchUploadWork: function (data) {
+        return post('/common/art/upload-all', data)
+    },
 }

+ 117 - 8
TEAMModelOS/ClientApp/src/view/artexam/AcQuos.vue

@@ -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>

+ 13 - 8
TEAMModelOS/ClientApp/src/view/artexam/ExamData.vue

@@ -41,18 +41,19 @@ export default {
             }
         },
         curClass: {
-			type: Object,
+            type: Object,
             default: () => {
                 return {}
             }
-		},
-		subjectId: {
-			type: String,
-			default: ''
-		}
+        },
+        subjectId: {
+            type: String,
+            default: ''
+        }
     },
     data() {
         return {
+            isRequesting: false,
             currentPage: 1,
             quCount: [],
             scoreList: [
@@ -117,6 +118,9 @@ export default {
         },
         //获取学生作答详情数据
         getStudentAnswer() {
+            // debugger
+            // if (this.isRequesting) return
+            this.isRequesting = true
             let examId = this.getExamId()
             if (!examId || !this.subjectId || !this.curClass.id) return
             this.tableLoading = true
@@ -137,6 +141,7 @@ export default {
                 }
             ).finally(() => {
                 this.tableLoading = false
+                this.isRequesting = false
             })
         },
         //初始化表单数据
@@ -266,7 +271,7 @@ export default {
         },
         curClass: {
             immediate: true,
-            deep:true,
+            deep: true,
             handler(n, o) {
                 if (n && n.id) {
                     this.getStudentAnswer()
@@ -295,6 +300,6 @@ export default {
     padding: 10px 10px;
     border-radius: 6px;
     // background: #f0f0f0;
-    background: #F5F7FA;
+    background: #f5f7fa;
 }
 </style>

+ 46 - 35
TEAMModelOS/ClientApp/src/view/artexam/Mgt.vue

@@ -49,7 +49,7 @@
                                 </div>
                             </template>
                             <TabPane v-for="(item, index) in tabListShow" :key="index" :label="item.label" :name="item.name">
-                                <AcQuos :artInfo="artInfo" :treeData="treeData" :curClass="curClass" :subjectId="subjectId"></AcQuos>
+                                <AcQuos :artInfo="artInfo" :treeData="tabTree[item.name]" :curClass="curClass" :subjectId="subjectId"></AcQuos>
                             </TabPane>
                         </Tabs>
                     </vuescroll>
@@ -79,7 +79,8 @@ export default {
             classList: [],
             classId: '',
             subjectId: '',
-            curBarIndex: 0
+            curBarIndex: 0,
+            tabTree: {}
         }
     },
     computed: {
@@ -112,37 +113,6 @@ export default {
         },
         subjectList() {
             return this.artInfo?.subjects || []
-        },
-        treeData() {
-            if (this.tabName && this.quotas.length) {
-                let curQuo = this.quotas.find(q => q.id === this.tabName)
-                let _this = this
-                const filterNodes = function (nodes) {
-                    nodes = nodes.filter(n => {
-                        let isShow = _this.curSettings.find(c => (n.children.length && c.id.includes(n.id)) || (!n.children.length && c.id == n.id))
-                        return !!isShow
-                    })
-                    nodes.forEach(node => {
-                        if (node.children) {
-                            node.children = filterNodes(node.children)
-                        }
-                    })
-                    console.log('---', nodes)
-                    return nodes
-                }
-                let res = filterNodes(curQuo.children)
-                return res
-            }
-            return []
-        },
-        curSettings() {
-            if (this.tabName && this.artInfo?.settings) {
-                let data = this.artInfo.settings.filter(s => {
-                    return s.id.includes(this.tabName)
-                })
-                return data || []
-            }
-            return []
         }
     },
     methods: {
@@ -193,8 +163,13 @@ export default {
             })
         },
         selectArt(index) {
+            this.classList = []
+            this.classId = ''
+            this.subjectId = ''
             this.curIndex = index
-            this.findArtSummary()
+            setTimeout(() => {
+                this.findArtSummary()
+            })
         },
         toCreate() {
             this.$router.push({
@@ -229,6 +204,7 @@ export default {
                     if (this.tabListShow.length) {
                         this.tabName = this.tabListShow[0].name
                     }
+                    this.handleTabTree()
                     if (this.artInfo?.classes) {
                         this.getClassList()
                     }
@@ -236,6 +212,41 @@ export default {
                 (err) => { }
             )
         },
+        curSettings(tabName) {
+            if (tabName && this.artInfo?.settings) {
+                let data = this.artInfo.settings.filter(s => {
+                    return s.id.includes(tabName)
+                })
+                return data || []
+            }
+            return []
+        },
+        handleTabTree() {
+            this.tabListShow.forEach(tab => {
+                if (tab.name && this.quotas.length) {
+                    let curQuo = this.quotas.find(q => q.id === tab.name)
+                    let _this = this
+                    const filterNodes = function (nodes) {
+                        nodes = nodes.filter(n => {
+                            let isShow = _this.curSettings(tab.name).find(c => (n.children.length && c.id.includes(n.id)) || (!n.children.length && c.id == n.id))
+                            return !!isShow
+                        })
+                        nodes.forEach(node => {
+                            if (node.children) {
+                                node.children = filterNodes(node.children)
+                            }
+                        })
+                        console.log('---', nodes)
+                        return nodes
+                    }
+                    let res = filterNodes(curQuo.children)
+                    this.$set(this.tabTree, tab.name, res)
+                } else {
+                    this.$set(this.tabTree, tab.name, [])
+                }
+            })
+            console.log(this.tabTree)
+        },
         getClassList() {
             let req = {
                 ids: this.artInfo.classes,
@@ -279,7 +290,7 @@ export default {
 </script>
 
 <style lang="less" scoped>
-.quo-detail-wrap{
+.quo-detail-wrap {
     background: #f6f6f6;
     padding: 10px;
     width: 100%;

+ 6 - 1
TEAMModelOS/ClientApp/src/view/artexam/WorkData.vue

@@ -76,6 +76,7 @@ export default {
     data() {
         let _this = this
         return {
+            isRequesting:false,
             schoolSas: {},
             hwPreviewFile: {},
             hwViewStatus: false,
@@ -164,6 +165,8 @@ export default {
             }
         },
         findArtWorkData() {
+            // if(this.isRequesting) return
+            this.isRequesting = true
             let workId = this.getWorkId()
             if (!workId || !this.subjectId || !this.curClass.id) return
             let req = {
@@ -178,7 +181,9 @@ export default {
                 err => {
 
                 }
-            )
+            ).finally(()=>{
+                this.isRequesting = false
+            })
         },
         setTableData(data) {
             this.workData = []