From e72ea5c4043cc79ae7eaf875242a03e3fe1421d9 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期日, 23 二月 2025 12:44:52 +0800 Subject: [PATCH] tag标签可修改 --- src/views/projectEngineering/projectLibrary/component/TagList.vue | 69 ++++++++++++++++++++++------------ 1 files changed, 45 insertions(+), 24 deletions(-) diff --git a/src/views/projectEngineering/projectLibrary/component/TagList.vue b/src/views/projectEngineering/projectLibrary/component/TagList.vue index 04ca707..9d4e077 100644 --- a/src/views/projectEngineering/projectLibrary/component/TagList.vue +++ b/src/views/projectEngineering/projectLibrary/component/TagList.vue @@ -1,41 +1,61 @@ <template> <div> - <el-button v-if="!inputVisible" class="button-new-tag" size="small" @click="showInput">+ 鏍囩</el-button> - <el-input - v-else - class="input-new-tag" - v-model="inputValue" - ref="saveTagInput" - size="small" - @keyup.enter.native="handleInputConfirm" - @blur="handleInputConfirm" - > - </el-input> - <div class="tags-container"> - <el-tag - v-for="tag in dynamicTags" - :key="tag" - closable - :disable-transitions="false" - @close="handleClose(tag)"> - {{tag}} - </el-tag> + <div> + <el-button v-if="!inputVisible" class="button-new-tag" size="small" @click="showInput">+ 鏍囩</el-button> </div> + <div> + <el-input + v-if="inputVisible" + class="input-new-tag" + v-model="inputValue" + ref="saveTagInput" + size="small" + @keyup.enter.native="handleInputConfirm" + @blur="handleInputConfirm" + > + </el-input> + <div class="tags-container"> + <el-tag + v-for="(tag, index) in tags" + :key="tag + index" + closable + @close="handleClose(index)"> + {{tag}} + </el-tag> + </div> + </div> + </div> </template> <script> export default { + props: { + tagList: { + required: true, + type: Array + } + }, + watch: { + tagList(newV, oldV) { + this.tags = newV + } + }, data() { return { - dynamicTags: ['閲嶇偣鏍囪', '鍙戞敼鍏虫敞', '骞村害椤圭洰'], + tags: [], inputVisible: false, inputValue: '' }; }, methods: { - handleClose(tag) { - this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1); + setTags(list) { + this.tags = list; + }, + handleClose(index) { + console.log("鐐逛簡") + this.tags.splice(index, 1); + this.$emit("getTags", this.tags) }, showInput() { @@ -48,7 +68,8 @@ handleInputConfirm() { let inputValue = this.inputValue; if (inputValue) { - this.dynamicTags.push(inputValue); + this.tags.push(inputValue); + this.$emit("getTags", this.tags) } this.inputVisible = false; this.inputValue = ''; -- Gitblit v1.8.0