|
@@ -4431,11 +4431,12 @@ export default {
|
|
|
.then((res) => {
|
|
|
// console.log(this.unitJson);
|
|
|
let unitJson = JSON.parse(res.data[0][0].chapters);
|
|
|
- // this.unitJson2 = 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 _unitIndex = JSON.parse(JSON.stringify(this.unitIndex));
|
|
|
+ let _unitIndex2 = JSON.parse(JSON.stringify(this.unitIndex));
|
|
|
let index = 1;
|
|
|
let chapindex;
|
|
|
if (_unitJson2.length > unitJson.length) {
|
|
@@ -4493,8 +4494,9 @@ export default {
|
|
|
_unitJson[i].chapterInfo[0].chapterid !=
|
|
|
unitJson[i].chapterInfo[0].chapterid
|
|
|
) {
|
|
|
- if(i == _unitJson.length - 1){
|
|
|
- this.unitIndex++
|
|
|
+ if (i == _unitJson.length - 1) {
|
|
|
+ // this.unitIndex++
|
|
|
+ _unitIndex2++;
|
|
|
}
|
|
|
_unitJson.splice(i, 0, unitJson[i]);
|
|
|
} else if (i > _unitJson.length - 1) {
|
|
@@ -4513,7 +4515,8 @@ export default {
|
|
|
if (_chapAarry.length && index != 2) {
|
|
|
if (chapindex < _unitIndex) {
|
|
|
this.isDelete = 2;
|
|
|
- this.unitIndex--;
|
|
|
+ // this.unitIndex--;
|
|
|
+ _unitIndex2--;
|
|
|
} else if (
|
|
|
_unitJson2[_unitIndex].chapterInfo[0].chapterid !=
|
|
|
_unitJson[_unitIndex].chapterInfo[0].chapterid
|
|
@@ -4524,21 +4527,27 @@ export default {
|
|
|
_unitJson2[_unitIndex].chapterInfo[0].chapterid ==
|
|
|
_unitJson[n].chapterInfo[0].chapterid
|
|
|
) {
|
|
|
- this.unitIndex = n;
|
|
|
+ // this.unitIndex = n;
|
|
|
+ _unitIndex2 = n;
|
|
|
_unitJson[n] = _unitJson2[_unitIndex];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else if (index != 2) {
|
|
|
- _unitJson[this.unitIndex] = _unitJson2[_unitIndex];
|
|
|
+ // _unitJson[this.unitIndex] = _unitJson2[_unitIndex];
|
|
|
+ _unitJson[_unitIndex2] = _unitJson2[_unitIndex];
|
|
|
}
|
|
|
if (index == 1) {
|
|
|
this.unitJson = _unitJson;
|
|
|
this.$forceUpdate();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isDelete = 2;
|
|
|
+ this.unitIndex = _unitIndex2;
|
|
|
+ }, 0);
|
|
|
this.timer = setTimeout(() => {
|
|
|
this.seleteCourseUpdate();
|
|
|
- }, 3000);
|
|
|
+ }, 2000);
|
|
|
} else if (index == 2) {
|
|
|
let _this = this;
|
|
|
_this
|
|
@@ -4552,19 +4561,26 @@ export default {
|
|
|
}
|
|
|
)
|
|
|
.then(() => {
|
|
|
- _this.restoreWork(
|
|
|
- _chapAarry[0],
|
|
|
- _unitJson,
|
|
|
- chapindex,
|
|
|
- _unitJson2
|
|
|
- );
|
|
|
+ if (_this.time()) {
|
|
|
+ _this.restoreWork(
|
|
|
+ _chapAarry[0],
|
|
|
+ _unitJson,
|
|
|
+ chapindex,
|
|
|
+ _unitJson2,
|
|
|
+ _unitIndex2
|
|
|
+ );
|
|
|
+ }
|
|
|
})
|
|
|
.catch(() => {
|
|
|
_this.unitJson = _unitJson;
|
|
|
_this.$forceUpdate();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isDelete = 2;
|
|
|
+ this.unitIndex = _unitIndex2;
|
|
|
+ }, 0);
|
|
|
_this.timer = setTimeout(() => {
|
|
|
_this.seleteCourseUpdate();
|
|
|
- }, 3000);
|
|
|
+ }, 2000);
|
|
|
});
|
|
|
}
|
|
|
})
|
|
@@ -4572,7 +4588,7 @@ export default {
|
|
|
console.error(err);
|
|
|
});
|
|
|
},
|
|
|
- restoreWork(chapid, unitJson, chapindex, unitJson2) {
|
|
|
+ restoreWork(chapid, unitJson, chapindex, unitJson2, unitIndex2) {
|
|
|
let params = [
|
|
|
{
|
|
|
cid: this.cid,
|
|
@@ -4591,9 +4607,13 @@ export default {
|
|
|
unitJson.splice(chapindex, 0, unitJson2[chapindex]);
|
|
|
this.unitJson = unitJson;
|
|
|
this.$forceUpdate();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.isDelete = 2;
|
|
|
+ this.unitIndex = unitIndex2;
|
|
|
+ }, 0);
|
|
|
this.timer = setTimeout(() => {
|
|
|
this.seleteCourseUpdate();
|
|
|
- }, 3000);
|
|
|
+ }, 2000);
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
this.$message.error("修改失败");
|