|
@@ -6,25 +6,45 @@
|
|
v-html="innerText"
|
|
v-html="innerText"
|
|
@input="handleInput"
|
|
@input="handleInput"
|
|
@focus="isChange = false"
|
|
@focus="isChange = false"
|
|
- ></div> -->
|
|
|
|
- <ul class="list">
|
|
|
|
- <li class="item" v-for="(item,index) in conceptList" :key="index">{{item.conceptName}}</li>
|
|
|
|
- </ul>
|
|
|
|
- <div class="source">
|
|
|
|
- <transition-group name="flip-list">
|
|
|
|
- <span
|
|
|
|
- v-for="item in conceptList"
|
|
|
|
- :key="item"
|
|
|
|
- draggable="true"
|
|
|
|
- class="items"
|
|
|
|
- @dragstart="dragstart(item)"
|
|
|
|
- @dragenter="dragenter(item)"
|
|
|
|
- @dragend="dragend(item)"
|
|
|
|
|
|
+ ></div>-->
|
|
|
|
+
|
|
|
|
+ <div class="source" @click="getfouce">
|
|
|
|
+ <div class="select">
|
|
|
|
+ <transition-group name="flip-list">
|
|
|
|
+ <span
|
|
|
|
+ v-for="(item,index) in items"
|
|
|
|
+ :key="item.conceptId"
|
|
|
|
+ draggable="true"
|
|
|
|
+ class="items"
|
|
|
|
+ @dragstart="dragstart(item)"
|
|
|
|
+ @dragenter="dragenter(item)"
|
|
|
|
+ @dragend="dragend(item)"
|
|
|
|
+ >
|
|
|
|
+ {{item.conceptName}}
|
|
|
|
+ <i class="el-icon-close" @click.stop="delTag(index)"></i>
|
|
|
|
+ </span>
|
|
|
|
+ </transition-group>
|
|
|
|
+ <input
|
|
|
|
+ class="inp"
|
|
|
|
+ @mousedown.stop
|
|
|
|
+ ref="inputVal"
|
|
|
|
+ @blur="unblur"
|
|
|
|
+ v-model="value"
|
|
|
|
+ @input="handleInput"
|
|
|
|
+ />
|
|
|
|
+ </div>
|
|
|
|
+ <ul class="list" v-if="conceptList.length>0 && onshow">
|
|
|
|
+ <li
|
|
|
|
+ @mousedown.prevent
|
|
|
|
+ class="item"
|
|
|
|
+ @click="getTag(item)"
|
|
|
|
+ v-for="(item,index) in conceptList"
|
|
|
|
+ :key="index"
|
|
>
|
|
>
|
|
- <span class="tag">{{item}}</span>
|
|
|
|
- </span>
|
|
|
|
- </transition-group>
|
|
|
|
- <input />
|
|
|
|
|
|
+ {{item.conceptName}}
|
|
|
|
+ <img src />
|
|
|
|
+ </li>
|
|
|
|
+ </ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -33,19 +53,28 @@
|
|
import api from '@api/knowledgeTree.js';
|
|
import api from '@api/knowledgeTree.js';
|
|
export default {
|
|
export default {
|
|
name: 'searchTerm',
|
|
name: 'searchTerm',
|
|
- props: ['value', 'type'],
|
|
|
|
|
|
+ props: ['type'],
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- innerText: this.value,
|
|
|
|
conceptList: [],
|
|
conceptList: [],
|
|
oldNum: 0,
|
|
oldNum: 0,
|
|
- newNum: 0
|
|
|
|
|
|
+ newNum: 0,
|
|
|
|
+ value: '',
|
|
|
|
+ items: [],
|
|
|
|
+ listL: [],
|
|
|
|
+ onshow: false
|
|
};
|
|
};
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
- value() {
|
|
|
|
- if (this.isChange) {
|
|
|
|
- this.innerText = this.value;
|
|
|
|
|
|
+ items(newVal, oldVal) {
|
|
|
|
+ // TO DO
|
|
|
|
+ let arr = [];
|
|
|
|
+ newVal.forEach(item => {
|
|
|
|
+ arr.push(item.conceptId);
|
|
|
|
+ });
|
|
|
|
+ console.log(arr);
|
|
|
|
+ if (this.autoValue) {
|
|
|
|
+ this.$emit('updata:list', arr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -54,7 +83,7 @@ export default {
|
|
const param = {
|
|
const param = {
|
|
excludedConceptIds: [],
|
|
excludedConceptIds: [],
|
|
libType: this.type,
|
|
libType: this.type,
|
|
- name: event.target.innerText
|
|
|
|
|
|
+ name: this.value
|
|
};
|
|
};
|
|
api
|
|
api
|
|
.searchConcept(param)
|
|
.searchConcept(param)
|
|
@@ -62,25 +91,47 @@ export default {
|
|
if (res.data.code == '0') {
|
|
if (res.data.code == '0') {
|
|
const data = res.data.data;
|
|
const data = res.data.data;
|
|
this.conceptList = data;
|
|
this.conceptList = data;
|
|
|
|
+ this.onshow = true;
|
|
}
|
|
}
|
|
})
|
|
})
|
|
.catch(error => {
|
|
.catch(error => {
|
|
console.log(error);
|
|
console.log(error);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- shuffle: function() {
|
|
|
|
|
|
+ getfouce() {
|
|
|
|
+ this.$refs.inputVal.focus();
|
|
|
|
+ },
|
|
|
|
+ getTag(item) {
|
|
|
|
+ var v = this.items.some(el => {
|
|
|
|
+ return el.conceptName == item.conceptName;
|
|
|
|
+ });
|
|
|
|
+ if (v) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ this.items.push(item);
|
|
|
|
+ this.onshow = true;
|
|
|
|
+ },
|
|
|
|
+ delTag(index) {
|
|
|
|
+ this.items.splice(index, 1);
|
|
|
|
+ },
|
|
|
|
+ unblur() {
|
|
|
|
+ this.onshow = false;
|
|
|
|
+ this.value = '';
|
|
|
|
+ },
|
|
|
|
+ shuffle() {
|
|
this.items = _.shuffle(this.items);
|
|
this.items = _.shuffle(this.items);
|
|
},
|
|
},
|
|
// 记录初始信息
|
|
// 记录初始信息
|
|
- dragstart: function(value) {
|
|
|
|
|
|
+ dragstart(value) {
|
|
this.oldNum = value;
|
|
this.oldNum = value;
|
|
},
|
|
},
|
|
// 做最终操作
|
|
// 做最终操作
|
|
- dragend: function(value) {
|
|
|
|
|
|
+ dragend(value) {
|
|
if (this.oldNum != this.newNum) {
|
|
if (this.oldNum != this.newNum) {
|
|
let oldIndex = this.items.indexOf(this.oldNum);
|
|
let oldIndex = this.items.indexOf(this.oldNum);
|
|
let newIndex = this.items.indexOf(this.newNum);
|
|
let newIndex = this.items.indexOf(this.newNum);
|
|
let newItems = [...this.items];
|
|
let newItems = [...this.items];
|
|
|
|
+ console.log(oldIndex);
|
|
// 删除老的节点
|
|
// 删除老的节点
|
|
newItems.splice(oldIndex, 1);
|
|
newItems.splice(oldIndex, 1);
|
|
// 在列表中目标位置增加新的节点
|
|
// 在列表中目标位置增加新的节点
|
|
@@ -158,11 +209,23 @@ export default {
|
|
overflow-y: auto;
|
|
overflow-y: auto;
|
|
border-radius: 4px;
|
|
border-radius: 4px;
|
|
margin-top: 6px;
|
|
margin-top: 6px;
|
|
- .items{
|
|
|
|
- border-radius:5px ;
|
|
|
|
- padding: 3px 4px;
|
|
|
|
- background: #48C5D7;
|
|
|
|
- margin: 0 5px;
|
|
|
|
|
|
+
|
|
|
|
+ .select {
|
|
|
|
+ .items {
|
|
|
|
+ height: 30px;
|
|
|
|
+ line-height: 30px;
|
|
|
|
+ font-size: 12px;
|
|
|
|
+ border-radius: 5px;
|
|
|
|
+ padding: 3px 4px;
|
|
|
|
+ background: #48c5d7;
|
|
|
|
+ margin: 0 5px;
|
|
|
|
+ display: inline-block;
|
|
|
|
+ }
|
|
|
|
+ .inp {
|
|
|
|
+ width: 80px;
|
|
|
|
+ height: 30px;
|
|
|
|
+ border: none;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|