Commit 18104794 by caoyanzhi

优化代码实现

parent dcfa7ca9
......@@ -345,20 +345,14 @@ export default {
* 已选标签-删除-检查实时 ????
*/
checkRealTime() {
const that = this;
if (!!that.selectedTagData.length) {
const arrTag = that.selectedTagData.map(item => parseInt(item.isActive));
console.log('已选标签实时/非实时:', arrTag);
if (arrTag.includes(0)) {
that.ruleForm.isActive = 0; // 如果有非实时,最后都是非实时
} else {
that.ruleForm.isActive = 1;
}
console.log(that.ruleForm);
return false;
if (this.ruleForm.selectedTags.length === 0) {
this.rule.isActive = 0;
return;
}
that.ruleForm.isActive = 0; // 如果已选标签为空,就是非实时
let flag = this.ruleForm.selectedTags.some(tagsGroup => {
return tagsGroup.some(tag => parseInt(tag.isActive) === 0);
});
this.ruleForm.isActive = flag ? 0 : 1;
},
/**
......@@ -395,8 +389,8 @@ export default {
* 点击保存---api
*/
postSave() {
const that = this;
let ruleForm = this.ruleForm;
this.checkRealTime();
const para = {
memberTagGroupId: ruleForm.memberTagGroupId,
groupName: ruleForm.groupName,
......@@ -409,13 +403,13 @@ export default {
effectiveDateTmp: `${ruleForm.effectiveDateTmp.split(' ')[0]} 23:59:59`
};
let postUrl = !!that.ruleForm.memberTagGroupId ? '/member-tag-group/update.json' : '/member-tag-group/add.json';
let postUrl = !!this.ruleForm.memberTagGroupId ? '/member-tag-group/update.json' : '/member-tag-group/add.json';
postRequest(postUrl, para)
.then(res => {
if (res.data.errorCode == 1) {
if (res.data.errorCode === 1) {
showMsg.showmsg('编辑成功', 'success');
that.changeRoute('/memberGroupList');
this.changeRoute('/memberGroupList');
}
})
.catch(function(error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment