实训标签只可添加,不能删除
This commit is contained in:
parent
b6edc4913b
commit
dd45877e1c
@ -25,6 +25,8 @@
|
|||||||
v-for="tag in tagForm.dynamicTags"
|
v-for="tag in tagForm.dynamicTags"
|
||||||
:key="tag"
|
:key="tag"
|
||||||
closable
|
closable
|
||||||
|
:class="dataLabel.includes(tag) ? 'tagDisable' : ''"
|
||||||
|
:type="dataLabel.includes(tag) ? 'info' : ''"
|
||||||
:disable-transitions="false"
|
:disable-transitions="false"
|
||||||
@close="handleClose(tag)"
|
@close="handleClose(tag)"
|
||||||
>
|
>
|
||||||
@ -69,6 +71,7 @@ export default {
|
|||||||
},
|
},
|
||||||
inputVisible: false,
|
inputVisible: false,
|
||||||
inputValue: '',
|
inputValue: '',
|
||||||
|
dataLabel: [], // 原始标签,不能修改删除,只可添加
|
||||||
tagForm: {
|
tagForm: {
|
||||||
client: '',
|
client: '',
|
||||||
dynamicTags: []
|
dynamicTags: []
|
||||||
@ -113,6 +116,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClose(tag) {
|
handleClose(tag) {
|
||||||
|
if (this.dataLabel.includes(tag)) { return; }
|
||||||
this.tagForm.dynamicTags.splice(this.tagForm.dynamicTags.indexOf(tag), 1);
|
this.tagForm.dynamicTags.splice(this.tagForm.dynamicTags.indexOf(tag), 1);
|
||||||
},
|
},
|
||||||
showInput() {
|
showInput() {
|
||||||
@ -123,7 +127,7 @@ export default {
|
|||||||
},
|
},
|
||||||
handleInputConfirm() {
|
handleInputConfirm() {
|
||||||
const inputValue = this.inputValue;
|
const inputValue = this.inputValue;
|
||||||
if (inputValue) {
|
if (inputValue && !this.tagForm.dynamicTags.includes(inputValue)) {
|
||||||
this.tagForm.dynamicTags.push(inputValue);
|
this.tagForm.dynamicTags.push(inputValue);
|
||||||
}
|
}
|
||||||
this.inputVisible = false;
|
this.inputVisible = false;
|
||||||
@ -152,6 +156,7 @@ export default {
|
|||||||
Object.keys(this.formModel).forEach(key => {
|
Object.keys(this.formModel).forEach(key => {
|
||||||
this.formModel[key] = data[key];
|
this.formModel[key] = data[key];
|
||||||
});
|
});
|
||||||
|
this.dataLabel = data.labelJson ? JSON.parse(data.labelJson) : [];
|
||||||
this.tagForm.dynamicTags = data.labelJson ? JSON.parse(data.labelJson) : [];
|
this.tagForm.dynamicTags = data.labelJson ? JSON.parse(data.labelJson) : [];
|
||||||
this.tagForm.client = data.client;
|
this.tagForm.client = data.client;
|
||||||
}
|
}
|
||||||
@ -179,11 +184,19 @@ export default {
|
|||||||
doClose() {
|
doClose() {
|
||||||
this.$refs.dataform && this.$refs.dataform.resetForm();
|
this.$refs.dataform && this.$refs.dataform.resetForm();
|
||||||
this.$refs.form && this.$refs.form.resetFields();
|
this.$refs.form && this.$refs.form.resetFields();
|
||||||
|
this.dataLabel = [];
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
<style lang="scss">
|
||||||
|
.tagDisable {
|
||||||
|
.el-tag__close {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
/deep/ .el-dialog--center .el-dialog__body{
|
/deep/ .el-dialog--center .el-dialog__body{
|
||||||
padding: 25px 65px 30px 10px;
|
padding: 25px 65px 30px 10px;
|
||||||
|
Loading…
Reference in New Issue
Block a user