Przeglądaj źródła

Merge branch 'develop3.0-tmd' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0-tmd

CrazyIter_Bin 4 lat temu
rodzic
commit
0081fdbb7c

+ 1 - 1
TEAMModelOS/ClientApp/src/api/knowledge.js

@@ -6,7 +6,7 @@ export default {
     },
     // 批量更新保存知识点知识块
     SaveOrUpdateKnowledge: function(data) {
-        return post('/knowledge/upsert-all', data)
+        return post('/knowledges/upsert', data)
     },
     SaveOrUpdateSchoolPoint: function(data) {
         return post('/knowledge/SaveOrUpdateAllSchoolPoint', data)

+ 44 - 34
TEAMModelOS/ClientApp/src/view/knowledge-point/index/Index.less

@@ -23,6 +23,18 @@
         padding: 0 20px;
         z-index: 1;
 
+        .school-tools {
+            font-size: var(--font-size-normal);
+            margin-right: 30px;
+            margin-top: 13px;
+            float: right;
+        }
+
+        .school-tools .ivu-icon {
+            font-size: @font-size-large;
+            margin-right: 5px;
+            vertical-align: text-top;
+        }
 
         span {
             margin-right: 10px;
@@ -45,17 +57,17 @@
         height: calc(100% - 70px);
         width: 100%;
         .fl-row-center;
-		
-		.drag-active{
-			 background-color: rgba(149, 149, 149, 0.2);
-		}
-		
-		.gl-new-area{
-			text-align: center;
-			color:@primary-textColor;
-			background: #3e3e3e;
-			padding: 35px 0 !important;
-		}
+
+        .drag-active {
+            background-color: rgba(149, 149, 149, 0.2);
+        }
+
+        .gl-new-area {
+            text-align: center;
+            color: @primary-textColor;
+            background: #3e3e3e;
+            padding: 35px 0 !important;
+        }
 
         .ns-col {
             position: relative;
@@ -133,11 +145,12 @@
                     overflow: hidden;
                     text-overflow: ellipsis;
                     white-space: nowrap;
-					pointer-events: none;
+                    pointer-events: none;
                 }
 
                 .gl-item-info {
-					pointer-events: none;
+                    pointer-events: none;
+
                     span {
                         margin-top: 15px
                     }
@@ -199,7 +212,7 @@
                 background: #0f9272;
                 border: none;
                 color: #fff;
-                margin-left:20px;
+                margin-left: 20px;
             }
 
             .points-wrap {
@@ -208,7 +221,7 @@
                 padding-top: 20px;
 
                 .point-item {
-					position:relative;
+                    position: relative;
                     margin: 10px;
                     padding: 5px 30px;
                     border-radius: 50px;
@@ -219,7 +232,6 @@
                     &-tools {
                         margin-left: 10px;
                         // display: none;
-
                         .btn-delete {
                             margin-left: 4px;
                         }
@@ -229,24 +241,22 @@
                 .point-item-active {
                     background: #0f9272 !important;
                 }
-				
-				// .block-point-item:before{
-				// 	content:'';
-				// 	display:block;
-				// 	width:8px;
-				// 	height:14px;
-				// 	border-right:#fff solid 2px;
-				// 	border-bottom:#fff solid 2px;
-				// 	transform:rotate(35deg);
-				// 	position:absolute;
-				// 	bottom:12px;
-				// 	left:12px;
-				// 	z-index:2;
-				// }
-				
-				.block-point-item{
-					background-color: #006988;
-				}
+                // .block-point-item:before{
+                // 	content:'';
+                // 	display:block;
+                // 	width:8px;
+                // 	height:14px;
+                // 	border-right:#fff solid 2px;
+                // 	border-bottom:#fff solid 2px;
+                // 	transform:rotate(35deg);
+                // 	position:absolute;
+                // 	bottom:12px;
+                // 	left:12px;
+                // 	z-index:2;
+                // }
+                .block-point-item {
+                    background-color: #006988;
+                }
 
                 .point-item:hover {
                     .point-item-tools {

+ 159 - 100
TEAMModelOS/ClientApp/src/view/knowledge-point/index/Index.vue

@@ -13,7 +13,7 @@
 					<Option v-for="(item,index) in periodList" :value="index" :key="index">{{ item.name }}</Option>
 				</Select>
 			</div>
-			<Button v-if="$access.ability('admin','schoolSetting-upd').validateAll" class="school-tools" :loading="isLoading"  icon="ios-albums-outline">{{$t('schoolBaseInfo.saveInfo')}}</Button>
+			<Button v-if="$access.ability('admin','schoolSetting-upd').validateAll" class="school-tools" :disabled="!updated"  icon="ios-albums-outline" @click="saveData()">{{$t('schoolBaseInfo.saveInfo')}}</Button>
 		</div>
 		<!-- 主体内容 -->
 		<div class="new-syllabus-content">
@@ -249,7 +249,9 @@
 				checkedPointList: [],
 				curBlockPoints: [],
 				curDragPoint: null,
-				pointIndex: null
+				pointIndex: null,
+				pointDatas: {},
+                updated:false
 			}
 		},
 		components: {
@@ -345,7 +347,6 @@
 			/* 保存最新知识块内容 */
 			savePointAndBlock(pointItem) {
 				return new Promise((r, j) => {
-					console.log(pointItem)
 					pointItem.code = pointItem.code.replace('Knowledge-', '')
 					this.$api.knowledge.SaveOrUpdateKnowledge([pointItem]).then(res => {
 						if (!res.error && res.knowledges) {
@@ -368,7 +369,6 @@
 			initSchoolData() {
 				this.$store.dispatch('user/getSchoolProfile').then(res => {
 					let schoolBaseInfo = res.school_base
-					console.log('学校基本数据', schoolBaseInfo)
 					if (schoolBaseInfo) {
 						this.schoolInfo = schoolBaseInfo
 						this.originSchoolData = schoolBaseInfo // 默认选择第一个
@@ -387,33 +387,35 @@
 
 			// 获取当前册别数量(每次都获取最新的数据)
 			initBlockCount() {
-				 if (this.blockCounts.length) {
-				 	this.schoolBlockCount = this.blockCounts[this.currentPeriodIndex].map(i => i[0])
-				 	this.privateBlockCount = this.blockCounts[this.currentPeriodIndex].map(i => i[1])
-				 } else {
-				this.$api.syllabus.FindBlockCount({
-					code: this.$store.state.userInfo.schoolCode
-				}).then(res => {
-					if (!res.error) {
-						this.$nextTick(() => {
-							this.blockCounts = res
-							this.schoolBlockCount = res[this.currentPeriodIndex || 0].map(i => i[0])
-							this.privateBlockCount = res[this.currentPeriodIndex || 0].map(i => i[1])
-						})
-					} else {
-						this.$Message.warning('获取数据失败')
-					}
-				})
-				 }
+				if (this.blockCounts.length) {
+					this.schoolBlockCount = this.blockCounts[this.currentPeriodIndex].map(i => i[0])
+					this.privateBlockCount = this.blockCounts[this.currentPeriodIndex].map(i => i[1])
+				} else {
+					this.$api.syllabus.FindBlockCount({
+						code: this.$store.state.userInfo.schoolCode
+					}).then(res => {
+						if (!res.error) {
+							this.$nextTick(() => {
+								this.blockCounts = res
+								this.schoolBlockCount = res[this.currentPeriodIndex || 0].map(i => i[0])
+								this.privateBlockCount = res[this.currentPeriodIndex || 0].map(i => i[1])
+							})
+						} else {
+							this.$Message.warning('获取数据失败')
+						}
+					})
+				}
 			},
 
 			// 根据学科获取所有知识块信息
 			getBlocksData() {
 				let that = this
+				that.pointDatas = []
 				let params = JSON.parse(JSON.stringify(this.currentParams))
 				params.type = 0
 				this.$api.knowledge.GetSchoolPoints(params).then(res => {
 					if (res.length) {
+						that.pointDatas = res
 						let list = res[0].blocks
 						this.blockList = list
 						this.originBlockList = JSON.parse(JSON.stringify(list))
@@ -433,15 +435,12 @@
 			// 根据学科获取学科下所有知识点数据
 			getPointsData() {
 				let that = this
-				console.log('知识点数据', this.currentParams)
 				//this.currentParams.type = 1
 				this.$api.knowledge.GetSchoolPoints(this.currentParams).then(res => {
-					console.log(res)
 					if (res.length) {
+
 						this.pointList = res[0].points
-						console.log('456456456', this.pointList)
 						this.originPointList = JSON.parse(JSON.stringify(res[0].points))
-						console.log(this.originPointList)
 						setTimeout(function () {
 							that.isLoadPoints = false
 						}, 800)
@@ -508,7 +507,6 @@
 
 			// 学科点击事件
 			handleSubjectTap(index) {
-				console.log(index)
 				this.checkedPointList = []
 				this.blockList = []
 				this.originBlockList = []
@@ -530,9 +528,6 @@
 
 			// 知识块点击事件
 			handleBlockTap(index, item) {
-				console.log(index)
-				console.log(item)
-				console.log(this.activeBlockIndex)
 				if (index === this.activeBlockIndex) {
 					this.activeBlockIndex = null
 					this.curBlockPoints = []
@@ -553,7 +548,6 @@
 			// 把当前知识块的知识点排到最前面
 			toStartPosition(points) {
 				points.forEach(i => {
-					console.log(i)
 					let pointIds = this.pointList.map(i => i)
 					if (pointIds.includes(i)) {
 						let index = pointIds.indexOf(i)
@@ -570,10 +564,10 @@
 				if (this.isEditBlock) {
 					let code = this.blockList.findIndex(item => item.name.indexOf(this.editBlock.name) > -1)
 					this.blockList[code].name = val.name
-                    this.originBlockList = JSON.parse(JSON.stringify(this.blockList))
 				} else {
-                    this.blockList.push(val)
-				}
+					this.blockList.push(val)
+				} 
+				this.originBlockList = [...this.blockList]
 				this.editBlock = {}
 				this.isAddBlock = false // 关闭窗口
 				this.blockCounts = []
@@ -586,12 +580,28 @@
 				let that = this
 				this.isLoadPoints = true
 				if (this.isEditPoint) {
-					this.pointList[this.editPointIndex] = val
+					this.pointList[this.editPointIndex] = val.name
+                    this.actionPoint(this.currentPoint, val)
+					//if (this.findPointIndex(this.currentPoint) > 0) {
+					//	this.$Modal.confirm({
+					//		title: '提示',
+					//		content: '<p>当前知识点已关联相关知识块,是否继续修改?</p>',
+					//		okText: '确认',
+					//		cancelText: '取消',
+					//		onOk: () => {
+					//			this.isLoading = true
+					//			setTimeout(() => {
+					//				that.isLoading = false
+					//				that.$Message.success('操作成功!')
+					//			}, 500)
+					//		}
+					//	})
+					//}
 				} else {
 					if (!this.isShowPoints) this.currentBlock.points.push(val.id)
 					this.pointList.push(val.name)
 				}
-				this.$Message.success('操作成功!')
+				this.originPointList = [...this.pointList]
 				this.isAddPoint = false // 关闭窗口
 				this.isEditPoint = false
 				setTimeout(function () {
@@ -599,7 +609,36 @@
 					that.initBlockCount()
 				}, 400)
 			},
+			//查询当前关联的知识块数据
+			findPointIndex(datas) {
+				let data = 0
+				for (let item of this.blockList) {
+					if (this.isEditPoint) {
+						let code = item.points.findIndex(items => items.indexOf(datas) > -1)
+						if (code !== -1) {
+							data++
+						}
+					}
+				}
+				return data
+			},
+
+			//处理关联的知识点数据(修改和删除)
+			actionPoint(data, val) {
+				if (data) {
+					for (let item of this.blockList) {
+						if (this.isEditPoint) {
+							let code = item.points.findIndex(items => items.indexOf(data) > -1)
+							if (code !== -1) {
+								item.points[code] = val.name
+							}
+						} else {
+							item.points.splice(item.points.findIndex(item => item === data), 1)
+						}
+					}
 
+				}
+			},
 			// 删除知识块事件
 			onDeleteBlock(data) {
 				this.$Modal.confirm({
@@ -610,19 +649,19 @@
 					onOk: () => {
 						let that = this
 						this.isLoading = true
-                        if (this.blockList.indexOf(data) !== -1) {
-								this.blockList.splice(this.blockList.indexOf(data), 1)
-								this.originBlockList.splice(this.originBlockList.indexOf(data), 1)
-								this.handleBlockTap(0, this.blockList.length ? this.blockList[0] : null)
-								setTimeout(() => {
-									that.blockCounts = []
-									that.initBlockCount()
-									that.isLoading = false
-									that.$Message.success('删除成功')
-								}, 1000)
-							} else {
-								this.$Message.success('删除失败')
-							}
+						if (this.blockList.indexOf(data) !== -1) {
+							this.blockList.splice(this.blockList.indexOf(data), 1)
+							this.originBlockList.splice(this.originBlockList.indexOf(data), 1)
+							this.handleBlockTap(0, this.blockList.length ? this.blockList[0] : null)
+							setTimeout(() => {
+								that.blockCounts = []
+								that.initBlockCount()
+								that.isLoading = false
+								that.$Message.success('删除成功')
+							}, 1000)
+						} else {
+							this.$Message.success('删除失败')
+						}
 					}
 				})
 			},
@@ -636,23 +675,12 @@
 					cancelText: '取消',
 					onOk: () => {
 						this.isLoadPoints = true
-						this.$api.knowledge.DeleteSchoolPoint({
-							code: data.code.replace('Knowledge-', ''),
-							id: data.id
-						}).then(res => {
-							if (!res.error) {
-								this.$Message.success('删除成功')
-								this.originPointList.splice(this.originPointList.indexOf(data), 1)
-								if (!this.isShowPoints) this.currentBlock.points.splice(this.currentBlock.points.indexOf(data.id), 1)
-								this.pageChange(this.currentPage)
-								this.isLoadPoints = false
-							} else {
-								this.$Message.warning('删除失败,错误代码:' + res.error.code + ',错误信息:' + res.error.message)
-							}
-						}).catch(err => {
-							console.log(err)
-							this.$Message.warning('删除失败')
-						})
+                        this.$Message.success('删除成功')
+                        this.pointList.splice(this.pointList.indexOf(data), 1)
+                        if (!this.isShowPoints) this.currentBlock.points.splice(this.currentBlock.points.indexOf(data), 1)
+						this.actionPoint(data, 0)
+						this.originPointList = [...this.pointList]
+                        this.isLoadPoints = false
 					}
 				})
 			},
@@ -661,20 +689,16 @@
 			onRemovePoint(data) {
 				this.$Modal.confirm({
 					title: '提示',
-					content: `确定将知识点 ${data.name} 从知识块 ${this.currentBlock.name} 中移除?`,
+					content: `确定将知识点 ${data} 从知识块 ${this.currentBlock.name} 中移除?`,
 					okText: '确认',
 					cancelText: '取消',
 					onOk: () => {
-						if (this.currentBlock.points.includes(data.id)) {
-							let that = this
-							this.currentBlock.points.splice(this.currentBlock.points.indexOf(data.id), 1)
-							this.savePointAndBlock(this.currentBlock).then(r => {
-								this.curBlockPoints = []
-								this.currentBlock = null
-								this.activeBlockIndex = null
-								that.handleSubjectTap(that.currentSubjectIndex)
-							})
-
+						if (this.currentBlock.points.includes(data)) {
+							this.currentBlock.points.splice(this.currentBlock.points.indexOf(data), 1)
+							this.originBlockList = [...this.blockList]
+								//this.curBlockPoints = []
+								//this.currentBlock = null
+								//this.activeBlockIndex = null
 						} else {
 							this.$Message.error('移除失败')
 						}
@@ -686,12 +710,7 @@
 			onEditBlock(data) {
 				this.isAddBlock = true // 打开新增窗口
 				this.isEditBlock = true // 设置成编辑状态
-				console.log('121321313131')
-				console.log(this.blockList)
-				console.log(data)
 				this.editBlock = this.blockList[data]
-                console.log(this.editBlock)
-
 			},
 
 			// 新增知识块事件
@@ -713,9 +732,6 @@
 
 			// 编辑知识点事件
 			onEditPoint(data, index) {
-				console.log('知识点数据')
-				console.log(data, index)
-				console.log(this.currentBlock)
 				this.isAddPoint = true // 打开新增窗口
 				this.isEditPoint = true // 设置成编辑状态
 				this.currentPoint = data
@@ -725,11 +741,6 @@
 
 			// 知识点点击事件
 			onPointCheck(item, index) {
-				console.log('000000000000000.000000000000000000')
-				console.log(item)
-				console.log(index)
-				console.log(this.checkedPointList)
-				console.log(this.isShowPoints)
 				if (this.isShowPoints) {
 					let list = this.checkedPointList
 					let isExistIndex = list.indexOf(item)
@@ -750,24 +761,23 @@
 			onComposeFinish(val) {
 				if (val) {
 					let code = this.blockList.findIndex(item => item.name.indexOf(val.name) > -1)
-					console.log(code)
 					if (code == -1) {
-                    this.blockList.push(val)
+						this.blockList.push(val)
 					} else {
-					this.blockList[code].points = val.points
+						this.blockList[code].points = val.points
 					}
-                    this.originBlockList = JSON.parse(JSON.stringify(this.blockList))
+					this.originBlockList = [...this.blockList]
+					console.log(this.originBlockList)
 					this.isComposeBlock = false
 					this.checkedPointList = []
 					this.activeBlockIndex = null
 					this.curBlockPoints = []
-					//this.handleSubjectTap(this.currentSubjectIndex)
 					this.$Message.success('操作成功')
 					this.initBlockCount()
 				}
 
 			},
-			 
+
 			// 搜索知识块输入框onchange事件
 			onSearchBlockChange() {
 				this.blockList = this.originBlockList.filter(item => item.name.indexOf(this.searchBlock) > -1)
@@ -818,7 +828,26 @@
 					this.pageChange(page - 1)
 				}
 			},
-
+			//保存修改后的数据
+			saveData() {
+				console.log(this.pointDatas)
+                if (this.updated) {
+                    let params = {}
+                    params = this.pointDatas[0]
+                    params.points = [...this.originPointList]
+                    params.blocks = [...this.originBlockList]
+                    this.$api.knowledge.SaveOrUpdateKnowledge(params).then(res => {
+                        if (res) {
+                            this.$Message.success('保存数据成功')
+                        } else {
+                            this.$Message.warning('保存数据失败')
+                        }
+                    }).catch(err => {
+                        this.$Message.error('数据保存失败')
+                        this.isLoadBlocks = false
+                    })
+                }
+            },
 			// 切换每页显示页数
 			pageSizeChange(val) {
 				this.pageSize = val
@@ -828,9 +857,39 @@
 
 		},
 		mounted() {
-
-
 		},
+		watch: {
+            originBlockList: {
+				handler(newValue, oldValue) {
+					console.log(newValue)
+					this.updated = true
+                }
+			},
+            originPointList: {
+				handler(newValue, oldValue) {
+					console.log(newValue)
+					this.updated = true
+                }
+            },
+		},
+        beforeRouteLeave(to, from, next) {
+            if (this.updated) {
+                let config = {
+                    title: this.$t('schoolBaseInfo.saveWarning'),
+                    content: this.$t('schoolBaseInfo.ssTips8'),
+                    okText: this.$t('schoolBaseInfo.leaveText'),
+                    onOk: () => {
+                        next()
+                    },
+                    onCancel: () => {
+                        next(false)
+                    }
+                }
+                this.$Modal.confirm(config)
+            } else {
+                next()
+            }
+        },
 		computed: {
 			dragOptions() {
 				return {
@@ -854,7 +913,7 @@
 	}
 </script>
 
-<style>
+<style >
 	.new-syllabus-header .ivu-select-single .ivu-select-selection,
 	.funnel-box .ivu-select-single .ivu-select-selection {
 		background: transparent;

+ 3 - 13
TEAMModelOS/ClientApp/src/view/knowledge-point/index/operation/AddPoint.vue

@@ -51,21 +51,11 @@
                     this.uuid = Math.uuid()
 					console.log(this.schoolInfos)
                     let params = {
-                        type: 1,
                         name: newName,
-                        alias: newName,
-                        subjectId: editPointItem ? editPointItem.subjectId : this.schoolInfos.subjectId,
-                        code: this.addPointType === 'school' ? this.schoolInfos.schoolCode : this.$store.state.userInfo.TEAMModelID, // //判断当前添加为校本或者个人知识点
-                        order: 706,
-                        status: 1,
-                        knowledgeId: editPointItem ? editPointItem.knowledgeId : this.uuid,
-                        periodId: editPointItem ? editPointItem.periodId : this.schoolInfos.period,
-                        source: 1,
-                        points: this.blockDatas ? [this.blockDatas.id] : [],
-                        id: editPointItem ? editPointItem.id : null,
                     }
-					console.log(params)
-                    this.savePointAndBlock(params)
+                    console.log(params)
+                    this.$emit('addFinish', params)
+                        this.isLoading = false
                 }
             },