实训标签只可添加,不能删除

This commit is contained in:
dong 2023-05-06 16:01:16 +08:00
parent b6edc4913b
commit dd45877e1c

View File

@ -25,6 +25,8 @@
v-for="tag in tagForm.dynamicTags"
:key="tag"
closable
:class="dataLabel.includes(tag) ? 'tagDisable' : ''"
:type="dataLabel.includes(tag) ? 'info' : ''"
:disable-transitions="false"
@close="handleClose(tag)"
>
@ -69,6 +71,7 @@ export default {
},
inputVisible: false,
inputValue: '',
dataLabel: [], //
tagForm: {
client: '',
dynamicTags: []
@ -113,6 +116,7 @@ export default {
},
methods: {
handleClose(tag) {
if (this.dataLabel.includes(tag)) { return; }
this.tagForm.dynamicTags.splice(this.tagForm.dynamicTags.indexOf(tag), 1);
},
showInput() {
@ -123,7 +127,7 @@ export default {
},
handleInputConfirm() {
const inputValue = this.inputValue;
if (inputValue) {
if (inputValue && !this.tagForm.dynamicTags.includes(inputValue)) {
this.tagForm.dynamicTags.push(inputValue);
}
this.inputVisible = false;
@ -152,6 +156,7 @@ export default {
Object.keys(this.formModel).forEach(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.client = data.client;
}
@ -179,11 +184,19 @@ export default {
doClose() {
this.$refs.dataform && this.$refs.dataform.resetForm();
this.$refs.form && this.$refs.form.resetFields();
this.dataLabel = [];
this.dialogVisible = false;
}
}
};
</script>
<style lang="scss">
.tagDisable {
.el-tag__close {
cursor: not-allowed;
}
}
</style>
<style lang="scss" scoped>
/deep/ .el-dialog--center .el-dialog__body{
padding: 25px 65px 30px 10px;