Prechádzať zdrojové kódy

修改表单显示待办

11wqe1 1 týždeň pred
rodič
commit
17bb82d802

+ 65 - 6
src/components/pages/liyuan/page/teadTest.vue

@@ -23,7 +23,10 @@
                             </el-tooltip>
                         </div>
                         <div class="state">
-                            <span :class="{ is: item.array.length > 0, no: !item.array.length }">{{ item.array.length > 0 ? "已完成" : "未完成" }}</span>
+                            <span :class="{ is: isOK(item.array) == '已完成', no: isOK(item.array) == '待办' }">
+                                {{ isOK(item.array) }}
+                                <!-- {{ item.array.length > 0 ? "已完成" : "未完成" }} -->
+                            </span>
                         </div>
                         <div class="time">
                             <span v-if="item.overtime" :class="{isDead: isDeadlinePassed(item.overtime)}">截止时间:{{ item.overtime }}</span>
@@ -50,6 +53,7 @@
                                 <div class="time">
                                     <span v-if="!test.editName && !test.name">提交记录{{item.array.length - index}}</span>
                                     <span v-if="!test.editName && test.name">{{test.name}}</span>
+                                    <el-input :ref="`changeName_${test.id}`" v-if="test.editName" v-model="test.name"  @blur="changeNameUpdate(test.courseid,test.id)" @keyup.enter.native="changeNameUpdate(test.courseid,test.id)"></el-input>
                                 </div>
                                 <div class="testType">
                                     <span :class="`typeStatus_${test.type}`">{{ typeStatusList[test.type] }}</span>
@@ -57,13 +61,16 @@
                                 <div class="utime">
                                     <span>{{ test.utime }}</span>
                                 </div>
-                                <div class="mask">
+                                <div class="mask" v-if="!test.isReview">
                                     <div @click="doTest(test.courseid, test.id)">
                                         <span>编辑</span>
                                     </div>
                                     <div @click="deleteTest(test.id)" class="delete">
                                         <span>删除</span>
                                     </div>
+                                    <div @click="changeName(test.courseid,test.id)">
+                                        <span>重命名</span>
+                                    </div>
                                 </div>
                             </div>
                         </div>
@@ -125,6 +132,25 @@ export default {
         };
     },
     computed: {
+        isOK(){
+            return function (array) {
+                // console.log('array',array);
+                let result = ''
+                if (array.length > 0) {
+                    let k = array.filter(e => e.type == 1 || e.type == 4)
+                   if (k.length) {
+                        result = '待办'
+                   }else{
+                        result = '已完成'
+                   }
+                    
+                }else{
+                    result = '待办'
+                }
+                
+                return result;
+            };
+        },
         getNum() {
             return function (array) {
                 let _array = JSON.parse(array);
@@ -654,10 +680,43 @@ export default {
             return res.data[0]
         },
         changeShowType(value){
-            console.log('changeShowType',value);
-            
-            this.checkTypeValue = value;
-            this.getWorks();
+          this.checkTypeValue = value;
+          this.getWorks();
+        },
+        changeName(courseId,testId){
+          let array = this.worksArray.find(i=>i.courseid == courseId);
+          if(array){
+            array = array.array;
+            array.find(i=>i.id==testId).editName = true;
+            this.$forceUpdate();
+            this.$nextTick(()=>{
+              console.log(this.$refs[`changeName_${testId}`])
+              this.$refs[`changeName_${testId}`][0].focus();
+            })
+          }
+        },
+        changeNameUpdate(courseId,testId){
+          let array = this.worksArray.find(i=>i.courseid == courseId);
+          if(array){
+            array = array.array;
+            array.find(i=>i.id==testId).editName = false;
+            this.$forceUpdate();
+            let data = array.find(i=>i.id==testId);
+            let params = [{
+              uid:this.userid,
+              testId:testId,
+              newName:data.name,
+            }]
+
+            this.ajax.post(this.$store.state.api+"update_testCourseWorksNameById",params).then(res=>{
+              if(res.data == 1){
+                this.$message.success("修改成功")
+              }else{
+                this.$message.error("修改失败")
+                array.find(i=>i.id==testId).name = "";
+              }
+            })
+          }
         }
     },
     mounted() {

+ 24 - 2
src/components/pages/testPerson/test/test.vue

@@ -36,7 +36,10 @@
                         </el-tooltip>
                     </div>
                     <div class="state">
-                        <span :class="{ is: item.array.length > 0, no: !item.array.length }">{{ item.array.length > 0 ? "已完成" : "未完成" }}</span>
+                        <span :class="{ is: isOK(item.array) == '已完成', no: isOK(item.array) == '待办' }">
+                            {{ isOK(item.array) }}
+                            <!-- {{ item.array.length > 0 ? "已完成" : "未完成" }} -->
+                        </span>
                     </div>
                     <div class="time">
                         <span v-if="item.overtime" :class="{isDead: isDeadlinePassed(item.overtime)}">截止时间:{{ item.overtime }}</span>
@@ -73,7 +76,7 @@
                             <div class="utime">
                                 <span>{{ test.utime }}</span>
                             </div>
-                            <div class="mask">
+                            <div class="mask" v-if="!test.isReview">
                                 <div @click="doTest(test.courseid, test.id)">
                                     <span>编辑</span>
                                 </div>
@@ -166,6 +169,25 @@ export default {
         };
     },
     computed: {
+        isOK(){
+            return function (array) {
+                // console.log('array',array);
+                let result = ''
+                if (array.length > 0) {
+                    let k = array.filter(e => e.type == 1 || e.type == 4)
+                   if (k.length) {
+                        result = '待办'
+                   }else{
+                        result = '已完成'
+                   }
+                    
+                }else{
+                    result = '待办'
+                }
+                
+                return result;
+            };
+        },
         getNum() {
             return function (array) {
                 let _array = JSON.parse(array);