实训标签只可添加,不能删除
This commit is contained in:
parent
b6edc4913b
commit
dd45877e1c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user