|
@@ -8708,13 +8708,204 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.$forceUpdate();
|
|
|
- if (this.timer) {
|
|
|
- clearTimeout(this.timer);
|
|
|
- this.timer = null;
|
|
|
+
|
|
|
+ let 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 > unitJson2.length) {
|
|
|
+ for (let c = 0; c < _unitJson2.length; c++) {
|
|
|
+ _chapAarry.push(_unitJson2[c].chapterInfo[0].chapterid);
|
|
|
+ }
|
|
|
+ for (let j = 0; j < unitJson2.length; j++) {
|
|
|
+ let count = 0;
|
|
|
+ for (let k = 0; k < _unitJson2.length; k++) {
|
|
|
+ if (
|
|
|
+ unitJson2[j].chapterInfo[0].chapterid ==
|
|
|
+ _unitJson2[k].chapterInfo[0].chapterid
|
|
|
+ ) {
|
|
|
+ count++;
|
|
|
+ _chapAarry.splice(
|
|
|
+ _chapAarry.indexOf(_unitJson2[k].chapterInfo[0].chapterid),
|
|
|
+ 1
|
|
|
+ );
|
|
|
+ _unitJson.push(unitJson2[j]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 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);
|
|
|
+ for (let d = 0; d < _unitJson2.length; d++) {
|
|
|
+ if (
|
|
|
+ _chapAarry.indexOf(_unitJson2[d].chapterInfo[0].chapterid) != -1
|
|
|
+ ) {
|
|
|
+ if (_unitIndex == d) {
|
|
|
+ index = 2;
|
|
|
+ }
|
|
|
+ chapindex = d;
|
|
|
+ // this.$message.error("您所修改的阶段已经被其他老师删除了");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ _unitJson = JSON.parse(JSON.stringify(_unitJson2));
|
|
|
}
|
|
|
- this.timer = setTimeout(() => {
|
|
|
- this.seleteCourseUpdate();
|
|
|
- }, 1000);
|
|
|
+
|
|
|
+ for (let i = 0; i < unitJson2.length; i++) {
|
|
|
+ if (
|
|
|
+ (i < _unitJson.length - 1 || i == _unitJson.length - 1) &&
|
|
|
+ _unitJson[i].chapterInfo[0].chapterid !=
|
|
|
+ unitJson2[i].chapterInfo[0].chapterid
|
|
|
+ ) {
|
|
|
+ if (i == _unitJson.length - 1) {
|
|
|
+ // this.unitIndex++
|
|
|
+ _unitIndex2++;
|
|
|
+ }
|
|
|
+ _unitJson.splice(i, 0, unitJson2[i]);
|
|
|
+ } else if (i > _unitJson.length - 1) {
|
|
|
+ _unitJson.push(unitJson2[i]);
|
|
|
+ } else if (
|
|
|
+ _unitJson[i].chapterInfo[0].chapterid ==
|
|
|
+ unitJson2[i].chapterInfo[0].chapterid
|
|
|
+ ) {
|
|
|
+ _unitJson[i] = unitJson2[i];
|
|
|
+ }
|
|
|
+ // if (i == _unitIndex) {
|
|
|
+ // continue;
|
|
|
+ // } else
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_chapAarry.length && index != 2) {
|
|
|
+ if (chapindex < _unitIndex) {
|
|
|
+ this.isDelete = 2;
|
|
|
+ // this.unitIndex--;
|
|
|
+ _unitIndex2--;
|
|
|
+ } else if (
|
|
|
+ _unitJson2[_unitIndex].chapterInfo[0].chapterid !=
|
|
|
+ _unitJson[_unitIndex].chapterInfo[0].chapterid
|
|
|
+ ) {
|
|
|
+ this.isDelete = 2;
|
|
|
+ for (let n = 0; n < _unitJson.length; n++) {
|
|
|
+ if (
|
|
|
+ _unitJson2[_unitIndex].chapterInfo[0].chapterid ==
|
|
|
+ _unitJson[n].chapterInfo[0].chapterid
|
|
|
+ ) {
|
|
|
+ // this.unitIndex = n;
|
|
|
+ _unitIndex2 = n;
|
|
|
+ _unitJson[n] = _unitJson2[_unitIndex];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (index != 2) {
|
|
|
+ // _unitJson[this.unitIndex] = _unitJson2[_unitIndex];
|
|
|
+ _unitJson2[_unitIndex];
|
|
|
+ for (
|
|
|
+ var ci = 0;
|
|
|
+ ci < _unitJson2[_unitIndex].chapterInfo[0].taskJson.length;
|
|
|
+ ci++
|
|
|
+ ) {
|
|
|
+ _unitJson2[_unitIndex].chapterInfo[0].taskJson[ci].toolChoose =
|
|
|
+ _unitJson2[_unitIndex].chapterInfo[0].taskJson[ci].toolChoose
|
|
|
+ ? _unitJson2[_unitIndex].chapterInfo[0].taskJson[ci]
|
|
|
+ .toolChoose
|
|
|
+ : [];
|
|
|
+ let _chapterData = [];
|
|
|
+ for (
|
|
|
+ var c = 0;
|
|
|
+ c <
|
|
|
+ _unitJson2[_unitIndex].chapterInfo[0].taskJson[ci].chapterData
|
|
|
+ .length;
|
|
|
+ c++
|
|
|
+ ) {
|
|
|
+ if (
|
|
|
+ _unitJson2[_unitIndex].chapterInfo[0].taskJson[ci]
|
|
|
+ .chapterData[c]
|
|
|
+ ) {
|
|
|
+ _chapterData.push(
|
|
|
+ _unitJson2[_unitIndex].chapterInfo[0].taskJson[ci]
|
|
|
+ .chapterData[c]
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _unitJson2[_unitIndex].chapterInfo[0].taskJson[ci].chapterData =
|
|
|
+ _chapterData;
|
|
|
+ }
|
|
|
+ _unitJson[_unitIndex2] = _unitJson2[_unitIndex];
|
|
|
+ }
|
|
|
+ if (index == 1) {
|
|
|
+ this.unitJson = _unitJson;
|
|
|
+ this.$forceUpdate();
|
|
|
+ setTimeout(() => {
|
|
|
+ if (this.unitIndex != _unitIndex2) {
|
|
|
+ this.isDelete = 2;
|
|
|
+ this.unitIndex = _unitIndex2;
|
|
|
+ }
|
|
|
+ }, 0);
|
|
|
+ this.timer = setTimeout(() => {
|
|
|
+ this.seleteCourseUpdate();
|
|
|
+ }, 1000);
|
|
|
+ } else if (index == 2) {
|
|
|
+ let _this = this;
|
|
|
+ _this
|
|
|
+ .$confirm(
|
|
|
+ "您所修改的阶段已经被其他老师删除了,需要恢复嘛?",
|
|
|
+ "提示",
|
|
|
+ {
|
|
|
+ confirmButtonText: "需要",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ if (_this.time()) {
|
|
|
+ _this.restoreWork(
|
|
|
+ _chapAarry[0],
|
|
|
+ _unitJson,
|
|
|
+ chapindex,
|
|
|
+ _unitJson2,
|
|
|
+ _unitIndex2
|
|
|
+ );
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ _this.unitJson = _unitJson;
|
|
|
+ _this.$forceUpdate();
|
|
|
+ setTimeout(() => {
|
|
|
+ if (this.unitIndex != _unitIndex2) {
|
|
|
+ this.isDelete = 2;
|
|
|
+ this.unitIndex = _unitIndex2;
|
|
|
+ }
|
|
|
+ }, 0);
|
|
|
+ _this.timer = setTimeout(() => {
|
|
|
+ _this.seleteCourseUpdate();
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // this.$forceUpdate();
|
|
|
+ // if (this.timer) {
|
|
|
+ // clearTimeout(this.timer);
|
|
|
+ // this.timer = null;
|
|
|
+ // }
|
|
|
+ // this.timer = setTimeout(() => {
|
|
|
+ // this.seleteCourseUpdate();
|
|
|
+ // }, 1000);
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
console.error(err);
|