Skip to content

Commit

Permalink
Merge pull request #104 from hLinx/hotfix_3.3.5
Browse files Browse the repository at this point in the history
Hotfix 3.3.5
  • Loading branch information
hLinx authored Jul 16, 2021
2 parents a64c0b4 + a090904 commit 4cc531f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
JbEditHost,
},
props: {
list: {
variableNameList: {
type: Array,
},
data: {
Expand Down Expand Up @@ -185,7 +185,7 @@
if (!globalVariableNameRule.validator(this.formData.name)) {
this.errorNameText = globalVariableNameRule.message;
}
if (this.list.some(item => item.name && item.name === this.formData.name)) {
if (this.variableNameList.includes(this.formData.name)) {
this.errorNameText = I18n.t('template.变量名称已存在,请重新输入');
}
if (this.errorNameText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<render-table-row
v-if="variableItem.id > 0 && variableItem.delete !== 1"
ref="variableEdit"
:list="calcExcludeList(index)"
:variable-name-list="calcExcludeNameList(variableItem)"
:data="variableItem"
:key="variableItem.id"
@on-change="value => handleChange(index, value)"
Expand All @@ -34,7 +34,7 @@
v-else-if="variableItem.id < 0"
ref="variableCreate"
:key="variableItem.id"
:list="calcExcludeList(index)"
:variable-name-list="calcExcludeNameList(variableItem)"
:data="variableItem"
@on-change="value => handleChange(index, value)"
@on-delete="handleDelete(index)"
Expand Down Expand Up @@ -87,13 +87,21 @@
},
methods: {
/**
* @desc 不包含当前索引变量的变量列表
* @desc 不包含当前索引变量的变量名列表
* @param { Object } variableData 变量数据
* @returns { Array }
*
* 不包含变量名为空和已删除的变量
*/
calcExcludeList (index) {
const list = [...this.variableList];
list.splice(index, 1);
return list;
calcExcludeNameList (variableData) {
return this.variableList.reduce((result, item) => {
if (variableData.id !== item.id
&& item.name
&& item.delete !== 1) {
result.push(item.name);
}
return result;
}, []);
},
/**
* @desc 更新变量信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
type: Object,
required: true,
},
list: {
variableNameList: {
type: Array,
},
},
Expand Down Expand Up @@ -105,7 +105,7 @@
trigger: 'blur',
},
{
validator: val => !this.list.some(item => item.name && item.name === val),
validator: val => !this.variableNameList.includes(val),
message: I18n.t('template.变量名称已存在,请重新输入'),
trigger: 'blur',
},
Expand All @@ -123,7 +123,7 @@
this.errorNameText = I18n.t('template.变量名称必填');
} else if (!globalVariableNameRule.validator(this.data.name)) {
this.errorNameText = globalVariableNameRule.message;
} else if (this.list.some(item => item.name === this.data.name)) {
} else if (this.variableNameList.includes(this.data.name)) {
this.errorNameText = I18n.t('template.变量名称已存在,请重新输入');
}
if (this.errorNameText) {
Expand Down

0 comments on commit 4cc531f

Please sign in to comment.