|
@@ -2630,7 +2630,8 @@ export default {
|
|
|
courseUserid: "",
|
|
|
timer: null,
|
|
|
checkId: "",
|
|
|
- isDelete:1,
|
|
|
+ isDelete: 1,
|
|
|
+ addindex: 0,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -2644,7 +2645,7 @@ export default {
|
|
|
},
|
|
|
watch: {
|
|
|
unitIndex(newValue, oldValue) {
|
|
|
- if(this.isDelete == 2){
|
|
|
+ if (this.isDelete == 2) {
|
|
|
this.isDelete = 1;
|
|
|
return;
|
|
|
}
|
|
@@ -2696,6 +2697,12 @@ export default {
|
|
|
this.unitIndex = oldValue;
|
|
|
return;
|
|
|
}
|
|
|
+ for (var i = 0; i < this.unitJson.length; i++) {
|
|
|
+ if (this.addindex != i) {
|
|
|
+ delete this.unitJson[i].isUpdate;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.addindex = -1;
|
|
|
let params = [
|
|
|
{
|
|
|
cid: this.cid,
|
|
@@ -3353,6 +3360,7 @@ export default {
|
|
|
addunit() {
|
|
|
this.unitJson.push({
|
|
|
dyName: "", //单元标题
|
|
|
+ isUpdate: 1,
|
|
|
chapterInfo: [
|
|
|
{
|
|
|
isread: false,
|
|
@@ -3393,6 +3401,7 @@ export default {
|
|
|
},
|
|
|
],
|
|
|
});
|
|
|
+ this.addindex = this.unitJson.length - 1;
|
|
|
setTimeout(() => {
|
|
|
this.unitIndex = this.unitJson.length - 1;
|
|
|
this.unitSet(this.unitIndex);
|
|
@@ -3603,10 +3612,14 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (cPan == 2) {
|
|
|
this.steps--;
|
|
|
return;
|
|
|
}
|
|
|
+ for (var i = 0; i < this.unitJson.length; i++) {
|
|
|
+ delete this.unitJson[i].isUpdate;
|
|
|
+ }
|
|
|
let params = [
|
|
|
{
|
|
|
uid: this.userid,
|
|
@@ -3762,6 +3775,9 @@ export default {
|
|
|
this.steps--;
|
|
|
return;
|
|
|
}
|
|
|
+ for (var i = 0; i < this.unitJson.length; i++) {
|
|
|
+ delete this.unitJson[i].isUpdate;
|
|
|
+ }
|
|
|
let params = [
|
|
|
{
|
|
|
cid: this.cid,
|
|
@@ -4413,40 +4429,64 @@ export default {
|
|
|
this.ajax
|
|
|
.get(this.$store.state.api + "select_course_detail", params)
|
|
|
.then((res) => {
|
|
|
+ // console.log(this.unitJson);
|
|
|
let unitJson = JSON.parse(res.data[0][0].chapters);
|
|
|
// this.unitJson2 = JSON.parse(res.data[0][0].chapters);
|
|
|
let _unitJson2 = JSON.parse(JSON.stringify(this.unitJson));
|
|
|
let _unitJson = [];
|
|
|
- let _chapAarry = []
|
|
|
+ let _chapAarry = [];
|
|
|
let _unitIndex = this.unitIndex;
|
|
|
- if(_unitJson2.length > unitJson.length){
|
|
|
- for(let c = 0;c<_unitJson2.length;c++){
|
|
|
- _chapAarry.push(_unitJson2[c].chapterInfo[0].chapterid)
|
|
|
+ if (_unitJson2.length > unitJson.length) {
|
|
|
+ for (let c = 0; c < _unitJson2.length; c++) {
|
|
|
+ _chapAarry.push(_unitJson2[c].chapterInfo[0].chapterid);
|
|
|
}
|
|
|
- for(let j = 0;j<unitJson.length;j++){
|
|
|
- let count = 0
|
|
|
- for(let k = 0;k<_unitJson2.length;k++){
|
|
|
- if(unitJson[j].chapterInfo[0].chapterid == _unitJson2[k].chapterInfo[0].chapterid){
|
|
|
- count++
|
|
|
- _chapAarry.splice(_chapAarry.indexOf(_unitJson2[k].chapterInfo[0].chapterid),1)
|
|
|
+ for (let j = 0; j < unitJson.length; j++) {
|
|
|
+ let count = 0;
|
|
|
+ for (let k = 0; k < _unitJson2.length; k++) {
|
|
|
+ if (
|
|
|
+ unitJson[j].chapterInfo[0].chapterid ==
|
|
|
+ _unitJson2[k].chapterInfo[0].chapterid
|
|
|
+ ) {
|
|
|
+ count++;
|
|
|
+ _chapAarry.splice(
|
|
|
+ _chapAarry.indexOf(_unitJson2[k].chapterInfo[0].chapterid),
|
|
|
+ 1
|
|
|
+ );
|
|
|
_unitJson.push(unitJson[j]);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- if(count === 0){
|
|
|
- this.$message.error("您所修改的阶段已经被其他老师删除了");
|
|
|
+ // if(count === 0){
|
|
|
+ // this.$message.error("您所修改的阶段已经被其他老师删除了");
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ for (let k = 0; k < _unitJson2.length; k++) {
|
|
|
+ if (_unitJson2[k].isUpdate == 1) {
|
|
|
+ _chapAarry.splice(
|
|
|
+ _chapAarry.indexOf(_unitJson2[k].chapterInfo[0].chapterid),
|
|
|
+ 1
|
|
|
+ );
|
|
|
+ _unitJson.push(_unitJson2[k]);
|
|
|
}
|
|
|
}
|
|
|
console.log(_chapAarry);
|
|
|
- }else{
|
|
|
- _unitJson = _unitJson2
|
|
|
+ for (let d = 0; d < _unitJson2.length; d++) {
|
|
|
+ if (_chapAarry(_unitJson2[d].chapterInfo[0].chapterid) != -1) {
|
|
|
+ this.$message.error("您所修改的阶段已经被其他老师删除了");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _unitJson = _unitJson2;
|
|
|
}
|
|
|
for (let i = 0; i < unitJson.length; i++) {
|
|
|
if (i == _unitIndex) {
|
|
|
continue;
|
|
|
} else if (i > this.unitJson.length - 1) {
|
|
|
_unitJson.push(unitJson[i]);
|
|
|
- } else if(_unitJson[i].chapterInfo[0].chapterid == unitJson[i].chapterInfo[0].chapterid){
|
|
|
+ } else if (
|
|
|
+ _unitJson[i].chapterInfo[0].chapterid ==
|
|
|
+ unitJson[i].chapterInfo[0].chapterid
|
|
|
+ ) {
|
|
|
_unitJson[i] = unitJson[i];
|
|
|
}
|
|
|
}
|