|
@@ -179,7 +179,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 清除所有连线及连线的状态 -->
|
|
|
- <div class="fuwei">
|
|
|
+ <div class="fuwei" :class="[TaskModel == 'ANSWER'?'notAllow':'']">
|
|
|
<div @click="clearLine">
|
|
|
<img src="../../../assets/adult/fuwei.png" alt="" />
|
|
|
复位
|
|
@@ -194,7 +194,7 @@
|
|
|
export default {
|
|
|
//import引入的组件需要注入到对象中才能使用
|
|
|
components: {},
|
|
|
- props: ["curQue"],
|
|
|
+ props: ["curQue","TaskModel"],
|
|
|
data() {
|
|
|
//这里存放数据
|
|
|
return {
|
|
@@ -252,9 +252,11 @@ export default {
|
|
|
methods: {
|
|
|
// 清除所有连线
|
|
|
clearLine() {
|
|
|
- this.jsPlumb.deleteEveryConnection(); //清除连线方法
|
|
|
- this.data = [];
|
|
|
- sessionStorage.removeItem("LineData");
|
|
|
+ if(!this.TaskModel||this.TaskModel!='ANSWER'){
|
|
|
+ this.jsPlumb.deleteEveryConnection(); //清除连线方法
|
|
|
+ this.data = [];
|
|
|
+ sessionStorage.removeItem("LineData");
|
|
|
+ }
|
|
|
},
|
|
|
showPlumb() {
|
|
|
this.jsPlumb = this.$jsPlumb.getInstance({
|
|
@@ -300,36 +302,42 @@ export default {
|
|
|
for (let j = 0; j < this.curQue.option.length; j++) {
|
|
|
this.initLeaf(this.curQue.option[j].nodeId, "target");
|
|
|
}
|
|
|
- });
|
|
|
+ });
|
|
|
this.setjsPlumb(true, true);
|
|
|
//点击连线
|
|
|
this.jsPlumb.bind("click", (conn, originalEvent) => {
|
|
|
- // 删除点击的线
|
|
|
- this.data.forEach((item, i) => {
|
|
|
- if (item.source == conn.sourceId) {
|
|
|
- this.data.splice(i, 1);
|
|
|
+ if(!this.TaskModel||this.TaskModel!='ANSWER'){
|
|
|
+ // 删除点击的线
|
|
|
+ this.data.forEach((item, i) => {
|
|
|
+ if (item.source == conn.sourceId) {
|
|
|
+ this.data.splice(i, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let node = document.getElementById(conn.sourceId);
|
|
|
+ this.jsPlumb.removeAllEndpoints(node);
|
|
|
+ sessionStorage.setItem("LineData", JSON.stringify(this.data));
|
|
|
+ this.$set(this.curQue, "Bookanswer", JSON.stringify(this.data));
|
|
|
}
|
|
|
- });
|
|
|
- let node = document.getElementById(conn.sourceId);
|
|
|
- this.jsPlumb.removeAllEndpoints(node);
|
|
|
- sessionStorage.setItem("LineData", JSON.stringify(this.data));
|
|
|
});
|
|
|
|
|
|
//连线时触发
|
|
|
this.jsPlumb.bind("connection", (conn, originalEvent) => {
|
|
|
- let fig = false;
|
|
|
- this.data.forEach((item) => {
|
|
|
- if (item.source == conn.sourceId && item.target == conn.targetId) {
|
|
|
- fig = true;
|
|
|
+ if(!this.TaskModel||this.TaskModel!='ANSWER'){
|
|
|
+ let fig = false;
|
|
|
+ this.data.forEach((item) => {
|
|
|
+ if (item.source == conn.sourceId && item.target == conn.targetId) {
|
|
|
+ fig = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!fig) {
|
|
|
+ this.data.push({
|
|
|
+ source: conn.sourceId,
|
|
|
+ target: conn.targetId,
|
|
|
+ });
|
|
|
+ sessionStorage.setItem("LineData", JSON.stringify(this.data));
|
|
|
+ this.$set(this.curQue, "Bookanswer", JSON.stringify(this.data));
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
- if (!fig) {
|
|
|
- this.data.push({
|
|
|
- source: conn.sourceId,
|
|
|
- target: conn.targetId,
|
|
|
- });
|
|
|
- sessionStorage.setItem("LineData", JSON.stringify(this.data));
|
|
|
- }
|
|
|
});
|
|
|
|
|
|
//右键触发
|
|
@@ -366,7 +374,13 @@ export default {
|
|
|
},
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
|
created() {
|
|
|
- let sData = JSON.parse(sessionStorage.getItem("LineData"));
|
|
|
+ let sData = null
|
|
|
+ if (!this.curQue.Bookanswer) {
|
|
|
+ // sData = JSON.parse(sessionStorage.getItem("LineData"));
|
|
|
+ sData = []
|
|
|
+ }else{
|
|
|
+ sData = JSON.parse(this.curQue.Bookanswer)
|
|
|
+ }
|
|
|
this.data = [];
|
|
|
if (sData) {
|
|
|
this.data = sData;
|
|
@@ -397,6 +411,7 @@ export default {
|
|
|
}
|
|
|
setTimeout(() => {
|
|
|
if (this.data.length > 0) {
|
|
|
+ console.log(this.data)
|
|
|
this.data.forEach((item) => {
|
|
|
this.jsPlumb.connect({
|
|
|
source: item.source,
|
|
@@ -588,6 +603,11 @@ export default {
|
|
|
.fuwei {
|
|
|
margin-top: 16px;
|
|
|
height: 40px;
|
|
|
+ &.notAllow{
|
|
|
+ >div{
|
|
|
+ cursor: not-allowed;
|
|
|
+ }
|
|
|
+ }
|
|
|
> div {
|
|
|
float: right;
|
|
|
width: 72px;
|