Browse Source

tree cache

hare8999@163.com 2 năm trước cách đây
mục cha
commit
ee9c44a173

+ 10 - 11
src/components/UploadDialog/index.vue

@@ -46,7 +46,8 @@
               全选学生
             </el-checkbox>
             <el-checkbox-group v-model="checkedStudent" @change="handleStudentChange">
-              <el-checkbox v-for="student in studentData" :label="student.code" :key="student.id">{{ student.name }}
+              <el-checkbox v-for="student in studentData" :label="student.code" :key="student.id"
+                           :disabled="defaultSelected.includes(student.code)">{{ student.name }}
               </el-checkbox>
             </el-checkbox-group>
           </div>
@@ -114,6 +115,10 @@ export default {
     scene: {
       type: String,
       default: '上传'
+    },
+    defaultSelected: {
+      type: Array,
+      default: () => []
     }
   },
   data() {
@@ -128,7 +133,7 @@ export default {
       studentData: [],
       checkedGrade: '',
       checkedClass: '',
-      checkedStudent: [],
+      checkedStudent: [...this.defaultSelected],
       gradeIndeterminate: true,
       classIndeterminate: true,
       studentIndeterminate: true,
@@ -198,7 +203,7 @@ export default {
     changeGrade() {
       this.checkedClass = ''
       this.studentData = []
-      this.checkedStudent = []
+      this.checkedStudent = [...this.defaultSelected]
       this.gradeData.forEach(item => {
         if (item.gradeId == this.checkedGrade) {
           this.classData = item.classes
@@ -220,7 +225,7 @@ export default {
       this.classIndeterminate = checkedCount > 0 && checkedCount < this.classData.length
     },
     changeClass() {
-      this.checkedStudent = []
+      this.checkedStudent = [...this.defaultSelected]
       this.classData.forEach(item => {
         if (item.classId == this.checkedClass) {
           this.studentData = item.students
@@ -238,13 +243,7 @@ export default {
     },
 
     forClassStudent(data, k) {
-      console.log(data)
-      let cacheArr = []
-      data.forEach(item => {
-        console.log(item)
-        cacheArr.push(item[k])
-      })
-      return cacheArr
+      return data.map(item => item[k])
     },
     getStudentsData() {
       getClassStudents().then(response => {

+ 6 - 1
src/views/questioncenter/components/generate-tabs/paper-by-hand.vue

@@ -175,6 +175,7 @@ export default {
         label: 'name',
         children: 'children'
       },
+      treeCache: {},
       treeCacheKey: '',
       currentNode: null,
       title: '',
@@ -268,7 +269,11 @@ export default {
       if (newTreeCacheKey != this.treeCacheKey) {
         this.treeCacheKey = newTreeCacheKey
         const treeFunc = this.isKnowledgeBranch ? knowledgeTree : chapterTree
-        const treeRes = await treeFunc(this.queryOutput)
+        let treeRes = this.treeCache[this.treeCacheKey]
+        if (!treeRes) {
+          treeRes = await treeFunc(this.queryOutput)
+          this.treeCache[this.treeCacheKey] = treeRes
+        }
         this.branchTree.length = 0 // clear
         this.branchTree.push(...treeRes.data)
         // current & query question

+ 4 - 1
src/views/questioncenter/components/generate-tabs/paper-work-history-detail.vue

@@ -1,6 +1,9 @@
 <template>
   <div>
     <dynamic-table :rows="rows" :columns="columns">
+      <template #index="{$index}">
+        {{ $index + 1 }}
+      </template>
       <template #type="{display}">
         {{ translateType(display) }}
       </template>
@@ -46,7 +49,7 @@ export default {
     },
     columns() {
       return [
-        { prop: 'id', label: 'ID', width: '80px', sortable: true },
+        { prop: 'id', label: '序号', width: '80px', slotBody: 'index' },
         { prop: 'type', label: '类型', width: '120px', slotBody: 'type' },
         { prop: 'title', label: '学生', slotBody: 'title' },
         { prop: 'doneTime', label: '完成时间', width: '180px', slotBody: 'doneTime' },

+ 5 - 1
src/views/questioncenter/components/generate-tabs/paper-work-history.vue

@@ -4,6 +4,9 @@
       <el-button icon="el-icon-refresh" circle @click="handleQuery"></el-button>
     </div>
     <dynamic-table :rows="rows" :columns="columns">
+      <template #index="{$index}">
+        {{ (queryParams.pageNum - 1) * queryParams.pageSize + $index + 1 }}
+      </template>
       <template #type="{display}">
         {{ translateType(display) }}
       </template>
@@ -57,7 +60,7 @@ export default {
         pageSize: 20
       },
       columns: [
-        { prop: 'id', label: 'ID', width: '80px' },
+        { prop: 'id', label: '序号', width: '80px', slotBody: 'index' },
         { prop: 'type', label: '类型', width: '120px', slotBody: 'type' },
         { prop: 'title', label: '标题' },
         { prop: 'createTime', label: '创建时间', width: '180px' },
@@ -128,6 +131,7 @@ export default {
 
   .el-badge__content.is-fixed {
     top: 8px;
+    right: 12px;
   }
 }
 </style>

+ 14 - 5
src/views/questioncenter/components/generate-tabs/paper-work-publish.vue

@@ -4,6 +4,9 @@
       <el-button icon="el-icon-refresh" circle @click="handleQuery"></el-button>
     </div>
     <dynamic-table :rows="rows" :columns="columns">
+      <template #index="{$index}">
+        {{ (queryParams.pageNum - 1) * queryParams.pageSize + $index + 1 }}
+      </template>
       <template #type="{display}">
         {{ translateType(display) }}
       </template>
@@ -12,7 +15,10 @@
           <el-button v-if="row.type == paperWorkType.value" type="text" icon="el-icon-edit"
                      @click="clickEditPaper(row)">编辑
           </el-button>
-          <el-button type="text" icon="el-icon-connection" @click="clickPublish(row)">发布</el-button>
+          <el-button type="text" icon="el-icon-connection" @click="clickPublish(row)">
+            发布
+            <template v-if="row.publishedCount">({{ row.publishedCount }})</template>
+          </el-button>
         </div>
       </template>
     </dynamic-table>
@@ -34,7 +40,7 @@
 
 <script>
 import DynamicTable from '@/components/dynamic-table/index'
-import { getHomeworks, publicStudentHomework } from '@/api/webApi/homework'
+import { getHomeworks, getHomeworkStudents, publicStudentHomework } from '@/api/webApi/homework'
 import consts from '@/common/mx-const'
 import { download, listCustomerPaperQeustions } from '@/api/webApi/webQue'
 import { mapGetters } from 'vuex'
@@ -51,11 +57,11 @@ export default {
         pageSize: 20
       },
       columns: [
-        { prop: 'id', label: 'ID', width: '80px' },
+        { prop: 'id', label: '序号', width: '80px', slotBody: 'index' },
         { prop: 'type', label: '类型', width: '120px', slotBody: 'type' },
         { prop: 'title', label: '标题' },
         { prop: 'createTime', label: '创建时间', width: '180px' },
-        { prop: 'action', label: '操作', width: '120px', slotBody: 'action' }],
+        { prop: 'action', label: '操作', width: '180px', slotBody: 'action' }],
       rows: [],
       total: 0,
       uploadWork: null,
@@ -63,6 +69,7 @@ export default {
         title: '发布作业',
         pageName: '',
         selectType: '',
+        defaultSelected: [],
         dialogVisible: false
       }
     }
@@ -107,9 +114,11 @@ export default {
     clickDownloadPaper(paperId) {
       download(paperId, this.period)
     },
-    clickPublish(work) {
+    async clickPublish(work) {
+      const res = await getHomeworkStudents({ workId: work.id })
       this.uploadWork = work
       this.uploadOption.selectType = 'student'
+      this.uploadOption.defaultSelected = res.data.map(item => item.customerCode) || []
       this.uploadOption.dialogVisible = true
     },
     async handleUploadReady(type, name, selectData) {

+ 4 - 1
src/views/questioncenter/homework.vue

@@ -5,6 +5,9 @@
         <el-button icon="el-icon-refresh" circle @click="queryParams.pageNum=1,getList()"></el-button>
       </div>
       <dynamic-table :columns="columns" :rows="rows">
+        <template #index="{$index}">
+          {{ (queryParams.pageNum - 1) * queryParams.pageSize + $index + 1 }}
+        </template>
         <template #type="{display}">
           {{ translateType(display) }}
         </template>
@@ -53,7 +56,7 @@ export default {
         pageSize: 20
       },
       columns: [
-        { prop: 'id', label: 'ID', width: '80px' },
+        { prop: 'id', label: '序号', width: '80px', slotBody: 'index' },
         { prop: 'type', label: '类型', width: '120px', slotBody: 'type' },
         { prop: 'createTime', label: '创建时间', width: '180px' },
         { prop: 'title', label: '标题' },