|
@@ -193,11 +193,9 @@ import { json } from 'd3'
|
|
|
code: ''
|
|
|
},
|
|
|
currentParams: {
|
|
|
- //code: '',
|
|
|
subjectId: '',
|
|
|
school_code: '',
|
|
|
periodId: '',
|
|
|
- //type: 0
|
|
|
},
|
|
|
drag: false,
|
|
|
isDragging: false,
|
|
@@ -252,7 +250,8 @@ import { json } from 'd3'
|
|
|
curDragPoint: null,
|
|
|
pointIndex: null,
|
|
|
pointDatas: {},
|
|
|
- updated:false
|
|
|
+ updated: false,
|
|
|
+ setCount: false
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
@@ -264,13 +263,11 @@ import { json } from 'd3'
|
|
|
},
|
|
|
created() {
|
|
|
this.initSchoolData()
|
|
|
- this.initBlockCount()
|
|
|
},
|
|
|
methods: {
|
|
|
|
|
|
/* 知识点拖动开始 */
|
|
|
onDragStart(item) {
|
|
|
- console.log(item)
|
|
|
this.curDragPoint = item
|
|
|
this.isDragging = true
|
|
|
},
|
|
@@ -339,28 +336,6 @@ import { json } from 'd3'
|
|
|
this.isComposeBlock = true
|
|
|
},
|
|
|
|
|
|
- /* 保存最新知识块内容 */
|
|
|
- savePointAndBlock(pointItem) {
|
|
|
- return new Promise((r, j) => {
|
|
|
- pointItem.code = pointItem.code.replace('Knowledge-', '')
|
|
|
- this.$api.knowledge.SaveOrUpdateKnowledge([pointItem]).then(res => {
|
|
|
- if (!res.error && res.knowledges) {
|
|
|
- this.curDragPoint = null
|
|
|
- this.isLoading = false
|
|
|
- this.checkedPointList = []
|
|
|
- this.initBlockCount()
|
|
|
- this.$Message.success(this.$t('knowledge.success'))
|
|
|
- r(200)
|
|
|
- } else {
|
|
|
- this.isLoading = false
|
|
|
- }
|
|
|
- }).catch(err => {
|
|
|
- j(err)
|
|
|
- this.$Message.warning(this.$t('knowledge.fail'))
|
|
|
- })
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
// 获取当前学校学段学科等基本信息
|
|
|
initSchoolData() {
|
|
|
this.$store.dispatch('user/getSchoolProfile').then(res => {
|
|
@@ -371,7 +346,6 @@ import { json } from 'd3'
|
|
|
this.originData = schoolBaseInfo // 默认选择第一个
|
|
|
if (schoolBaseInfo.period.length) {
|
|
|
this.periodList = schoolBaseInfo.period
|
|
|
- //this.currentParams.code = schoolBaseInfo.id
|
|
|
this.currentParams.school_code = schoolBaseInfo.id
|
|
|
this.currentParams.periodId = schoolBaseInfo.period[0].id
|
|
|
this.currentPeriodIndex = 0 // 默认选择第一个学段
|
|
@@ -383,6 +357,7 @@ import { json } from 'd3'
|
|
|
|
|
|
// 获取当前册别数量(每次都获取最新的数据)
|
|
|
initBlockCount() {
|
|
|
+ this.setCount = false
|
|
|
let params = {}
|
|
|
for (let data of this.subjectList) {
|
|
|
params[this.$store.state.userInfo.schoolCode + "-" + data.id] = this.periodList[this.currentPeriodIndex].id
|
|
@@ -390,6 +365,7 @@ import { json } from 'd3'
|
|
|
this.$api.syllabus.FindBlockCount(params).then(res => {
|
|
|
if (res.datas.length) {
|
|
|
this.$nextTick(() => {
|
|
|
+ this.setCount = true //开始监听数据
|
|
|
this.blockCounts = res.datas
|
|
|
this.schoolBlockCount = res.datas.map(i => i.countBlock)
|
|
|
this.privateBlockCount = res.datas.map(i => i.countBlock)
|
|
@@ -405,13 +381,11 @@ import { json } from 'd3'
|
|
|
let params = JSON.parse(JSON.stringify(this.currentParams))
|
|
|
params.type = 0
|
|
|
this.$api.knowledge.GetSchoolPoints(params).then(res => {
|
|
|
- console.log(res.length)
|
|
|
if (res.length > 0) {
|
|
|
that.pointDatas = res
|
|
|
let list = res[0].blocks
|
|
|
this.blockList = list
|
|
|
this.originBlockList = JSON.parse(JSON.stringify(list))
|
|
|
- // this.handleBlockTap(0, list.length ? list[0] : null)
|
|
|
setTimeout(function () {
|
|
|
that.isLoadBlocks = false
|
|
|
}, 400)
|
|
@@ -442,15 +416,14 @@ import { json } from 'd3'
|
|
|
// 根据学科获取学科下所有知识点数据
|
|
|
getPointsData() {
|
|
|
let that = this
|
|
|
- //this.currentParams.type = 1
|
|
|
this.$api.knowledge.GetSchoolPoints(this.currentParams).then(res => {
|
|
|
if (res.length) {
|
|
|
- console.log(res)
|
|
|
this.pointList = res[0].points
|
|
|
this.originPointList = JSON.parse(JSON.stringify(res[0].points))
|
|
|
setTimeout(function () {
|
|
|
that.isLoadPoints = false
|
|
|
}, 800)
|
|
|
+ this.updated = false
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -573,7 +546,6 @@ import { json } from 'd3'
|
|
|
this.editBlock = {}
|
|
|
this.isAddBlock = false // 关闭窗口
|
|
|
this.blockCounts = []
|
|
|
- //this.initBlockCount()
|
|
|
},
|
|
|
|
|
|
// 添加知识点完成
|
|
@@ -593,7 +565,6 @@ import { json } from 'd3'
|
|
|
this.isEditPoint = false
|
|
|
setTimeout(function () {
|
|
|
that.isLoadPoints = false
|
|
|
- //that.initBlockCount()
|
|
|
}, 400)
|
|
|
},
|
|
|
//查询当前关联的知识块数据
|
|
@@ -642,7 +613,6 @@ import { json } from 'd3'
|
|
|
this.handleBlockTap(0, this.blockList.length ? this.blockList[0] : null)
|
|
|
setTimeout(() => {
|
|
|
that.blockCounts = []
|
|
|
- //that.initBlockCount()
|
|
|
that.isLoading = false
|
|
|
that.$Message.success(this.$t('knowledge.delSuccess'))
|
|
|
}, 1000)
|
|
@@ -756,7 +726,6 @@ import { json } from 'd3'
|
|
|
this.activeBlockIndex = null
|
|
|
this.curBlockPoints = []
|
|
|
this.$Message.success(this.$t('knowledge.success'))
|
|
|
- //this.initBlockCount()
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -811,21 +780,21 @@ import { json } from 'd3'
|
|
|
}
|
|
|
},
|
|
|
//保存修改后的数据
|
|
|
- saveData() {
|
|
|
- if (this.updated) {
|
|
|
+ saveData() {
|
|
|
+ if (this.updated) {
|
|
|
+ this.setCount = false
|
|
|
let params = {}
|
|
|
params = this.pointDatas[0]
|
|
|
params.points = [...this.originPointList]
|
|
|
params.blocks = [...this.originBlockList]
|
|
|
- console.log(params)
|
|
|
this.$api.knowledge.SaveOrUpdateKnowledge(params).then(res => {
|
|
|
- if (res) {
|
|
|
+ if (res) {
|
|
|
this.$Message.success(this.$t('knowledge.saveSuccess'))
|
|
|
this.getPointsData()
|
|
|
- this.initBlockCount()
|
|
|
+ //this.initBlockCount()
|
|
|
} else {
|
|
|
this.$Message.warning(this.$t('knowledge.saveFail'))
|
|
|
- }
|
|
|
+ }
|
|
|
}).catch(err => {
|
|
|
this.$Message.error(this.$t('knowledge.saveFail'))
|
|
|
this.isLoadBlocks = false
|
|
@@ -845,14 +814,16 @@ import { json } from 'd3'
|
|
|
watch: {
|
|
|
originBlockList: {
|
|
|
handler(newValue, oldValue) {
|
|
|
- //console.log(newValue)
|
|
|
- this.updated = true
|
|
|
+ if (this.setCount) {
|
|
|
+ this.updated = true
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
originPointList: {
|
|
|
handler(newValue, oldValue) {
|
|
|
- //console.log(newValue)
|
|
|
- this.updated = true
|
|
|
+ if (this.setCount) {
|
|
|
+ this.updated = true
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
},
|