Commit b3b86e77 by member

Merge branch 'dev' of 115.159.76.241:memberTag/memberTag-web into dev

parents 46d47610 ec084423
<template>
<div class="flex m-t-20 tags">
<div v-for="(tags, index) in tagsList" :key="tags" :style="`width: ${100 / tagsList.length}%`" class="tag-group">
<div v-for="(tags, index) in tagsListFilter" :key="tags" :style="`width: ${100 / tagsList.length}%`" class="tag-group">
<ul class="tag-list">
<li class="tag-item" v-for="tag in tags" :key="tag.tagId">
<span>{{ tag.tagName }}</span>
<span class="tags-item__name">【选择:{{ getTagVal(tag) }}</span>
</li>
</ul>
<div v-if="(index === 0 && tagsList.length > 1) || (index === 1 && tagsList.length > 2)" class="tag-relation">
<div v-if="(index === 0 && tagsListFilter.length > 1) || (index === 1 && tagsListFilter.length > 2)" class="tag-relation">
<span class="tag-relation__wrap">
<i class="tag-relation__cont">
{{ tagsList[index][0].levelType === 'or' ? '或者' : tagsList[index][0].levelType === 'andNot' ? '剔除' : '' }}
{{ tags[0].levelType === 'or' ? '或者' : tags[0].levelType === 'andNot' ? '剔除' : '' }}
</i>
</span>
</div>
......@@ -27,6 +27,11 @@ export default {
required: true
}
},
computed: {
tagsListFilter() {
return this.tagsList.filter(tags => tags.length > 0);
}
},
methods: {
getTagVal(tagData) {
const tag = JSON.parse(tagData.tagParams);
......
......@@ -418,9 +418,6 @@ export default {
list.forEach(li => {
li.tagParams && (li.tagParams = JSON.parse(li.tagParams));
});
list[0][0].levelType = 'or';
list[1] = list[0];
list[2] = list[0];
this.selectedTagData = list;
})
.catch(e => {
......
......@@ -50,7 +50,7 @@
</el-select>
</el-form-item>
<el-form-item label="">
<el-button type="primary" @click.stop="postSave">保存</el-button>
<el-button type="primary" @click.stop="confirmSavePost">保存</el-button>
<el-button>
<router-link to="/memberGroupList">返回</router-link>
</el-button>
......@@ -99,7 +99,6 @@ import tagContainer from '@/view/platformTag/tag-container.vue';
import editTag from './edit-tag';
import tagsGroupList from './tags-group-list.vue';
import showMsg from '@/common/js/showmsg';
import { _debounce } from '@/common/js/public';
import { postRequest } from '@/api/api';
import { getMemberTagCount } from '@/request/memberGroup.js';
import { getMemberTagList } from '@/request/api.js';
......@@ -279,6 +278,21 @@ export default {
];
}
},
/**
* 检查标签是不是实时
* 1=实时 0=非实时
*/
watch: {
'ruleForm.selectedTags': {
deep: true,
handler() {
let flag = this.ruleForm.selectedTags.length === 0 || this.ruleForm.selectedTags.some(tagsGroup => {
return tagsGroup.length === 0 || tagsGroup.some(tag => parseInt(tag.isActive) === 0);
});
this.ruleForm.isActive = flag ? 0 : 1;
}
}
},
methods: {
/**
* 路由跳转
......@@ -339,50 +353,20 @@ export default {
this.ruleForm.selectedTags.splice(this.activeTagsGroupIndex, 1, tagsGroup);
break;
}
this.checkRealTime();
},
/**
* 已选标签-删除-检查实时
*/
checkRealTime() {
if (this.ruleForm.selectedTags.length === 0) {
this.rule.isActive = 0;
return;
}
let flag = this.ruleForm.selectedTags.some(tagsGroup => {
return tagsGroup.some(tag => parseInt(tag.isActive) === 0);
});
this.ruleForm.isActive = flag ? 0 : 1;
},
/**
* 点击保存
*/
confirmSave: _debounce(function() {
// 优化掉
return;
confirmSavePost() {
this.$refs.ruleForm.validate(valid => {
if (valid) this.postSave();
});
}, 500),
confirmSavePost(formName) {
// 优化掉
return;
const that = this;
that.$refs[formName].validate(valid => {
if (valid) {
console.log('valid', that.ruleForm);
const flag = that.ruleForm.isActive == 0 && that.ruleForm.updateType != 1 && that.ruleForm.updateDay == '';
if (!!flag) {
that.$message.error({ message: '请选择更新频率!' });
const flag = this.ruleForm.isActive === 0 && this.ruleForm.updateType !== 1 && this.ruleForm.updateDay === '';
if (flag) {
this.$message.error({ message: '请选择更新频率!' });
return false;
}
that.postSave(that.ruleForm);
} else {
return false;
this.postSave();
}
});
},
......@@ -393,6 +377,12 @@ export default {
postSave() {
let ruleForm = this.ruleForm;
ruleForm.selectedTags.forEach((tagsGroup, tagsGroupIndex) => {
let relation = ruleForm.tagsGroupRelation[tagsGroupIndex];
tagsGroup.forEach(item => {
item.levelType = relation ? relation : 'or';
})
});
const para = {
memberTagGroupId: ruleForm.memberTagGroupId,
groupName: ruleForm.groupName,
......@@ -410,12 +400,14 @@ export default {
postRequest(postUrl, para)
.then(res => {
if (res.data.errorCode === 1) {
showMsg.showmsg('编辑成功', 'success');
showMsg.showmsg(this.ruleForm.memberTagGroupId ? '编辑成功' : '新增成功', 'success');
this.changeRoute('/memberGroupList');
} else {
this.$message.warning(res.data.message);
}
})
.catch(function(error) {
console.log(error);
.catch(error => {
this.$message.warning(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