Commit 31e8b6fe by xinla

修改部分issue问题

1 parent 7e2b9528
......@@ -69,6 +69,13 @@ export default {
let name = this.newInput
if (name) {
Array.isArray(this.form.weTags) || (this.form.weTags = [])
let isExist = this.form.weTags.some((e) => {
return e.name === name
})
if (isExist) {
this.msgError('标签名已存在,不可重复添加')
return
}
this.form.weTags.push({ name })
}
this.visibleAdd = false
......@@ -76,6 +83,7 @@ export default {
},
submit() {
this.$refs['form'].validate((valid) => {
this.newInput = ''
let form = JSON.parse(JSON.stringify(this.form))
if (!form.weTags.length) {
return
......@@ -101,7 +109,7 @@ export default {
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="标签组名称" prop="gourpName">
<el-input
v-model="form.gourpName"
v-model.trim="form.gourpName"
maxlength="15"
show-word-limit
placeholder="请输入标签组名称,该名称不支持再次修改"
......
......@@ -29,15 +29,27 @@ export default {
listOneArray: [],
selectedGroup: '', // 选择的标签分组
removeTag: [],
Pselected: this.selected,
Pselected: [],
}
},
watch: {
type(val) {
val === 'remove' && (this.removeTag = this.selected.slice())
},
// type(val) {
// val === 'remove' && (this.removeTag = this.selected.slice())
// },
selected(val) {
this.Pselected = val
if (this.type === 'add') {
this.Pselected = []
val.forEach((element) => {
let find = this.listOneArray.find((d) => {
return element.tagId === d.tagId
})
this.Pselected.push(find)
})
} else if (this.type === 'remove') {
this.removeTag = val.slice()
this.Pselected = val.slice()
}
// this.list = JSON.parse(JSON.stringify(this.list))
},
},
computed: {
......@@ -52,14 +64,14 @@ export default {
},
},
created() {
// this.type === 'remove' && (this.removeTag = this.Pselected.slice())
this.getList()
},
mounted() {},
methods: {
getList() {
getList().then(({ rows }) => {
this.list = Object.freeze(rows)
// this.list = Object.freeze(rows)
this.list = rows
this.listOneArray = []
this.list.forEach((element) => {
element.weTags.forEach((d) => {
......@@ -69,9 +81,22 @@ export default {
})
},
submit() {
if (!this.Pselected.length) {
this.msgError('请至少选择一个标签')
return
}
this.Pvisible = false
this.$emit('success', this.Pselected)
},
isChecked(unit) {
// debugger
return this.Pselected.some((el) => {
return unit.tagId === el.tagId
})
},
toJson(data) {
return JSON.stringify(data)
},
},
}
</script>
......@@ -89,19 +114,19 @@ export default {
:value="item.groupId"
></el-option>
</el-select>
<div class="mt20">
<el-checkbox-group v-model="Pselected" v-if="type !== 'remove'">
<div class="mt20" v-if="Pvisible">
<el-checkbox-group v-if="type !== 'remove'" v-model="Pselected">
<template v-for="(item, index) in list">
<div
class="bfc-d mr30"
v-show="item.groupId === selectedGroup || !selectedGroup"
v-if="item.groupId === selectedGroup || !selectedGroup"
:key="index"
>
<template v-for="(unit, unique) in item.weTags">
<el-checkbox
v-if="unit.name.trim()"
:label="unit"
:key="index + unique"
:key="index + '' + unique"
>{{ unit.name }}</el-checkbox
>
</template>
......
......@@ -6,25 +6,25 @@
<template>
<section class="app-main">
<transition name="fade-transform" mode="out-in">
<keep-alive :include="cachedViews">
<router-view class="page" :key="key" />
</keep-alive>
<router-view class="page" :key="key" />
<!-- <keep-alive :include="cachedViews">
</keep-alive> -->
</transition>
</section>
</template>
<script>
export default {
name: "AppMain",
name: 'AppMain',
computed: {
cachedViews() {
return this.$store.state.tagsView.cachedViews;
return this.$store.state.tagsView.cachedViews
},
key() {
return this.$route.path;
return this.$route.path
},
},
};
}
</script>
<style lang="scss" scoped>
......
<template>
<div id="tags-view-container" class="tags-view-container">
<scroll-pane ref="scrollPane" class="tags-view-wrapper" @scroll="handleScroll">
<scroll-pane
ref="scrollPane"
class="tags-view-wrapper"
@scroll="handleScroll"
>
<router-link
v-for="tag in visitedViews"
ref="tag"
:key="tag.path"
:class="isActive(tag)?'active':''"
:class="isActive(tag) ? 'active' : ''"
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
tag="span"
class="tags-view-item"
:style="activeStyle(tag)"
@click.middle.native="!isAffix(tag)?closeSelectedTag(tag):''"
@contextmenu.prevent.native="openMenu(tag,$event)"
@click.middle.native="!isAffix(tag) ? closeSelectedTag(tag) : ''"
@contextmenu.prevent.native="openMenu(tag, $event)"
>
{{ tag.title }}
{{ tag.meta.title }}
<span
v-if="!isAffix(tag)"
class="el-icon-close"
......@@ -21,9 +25,15 @@
/>
</router-link>
</scroll-pane>
<ul v-show="visible" :style="{left:left+'px',top:top+'px'}" class="contextmenu">
<ul
v-show="visible"
:style="{ left: left + 'px', top: top + 'px' }"
class="contextmenu"
>
<li @click="refreshSelectedTag(selectedTag)">刷新页面</li>
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">关闭当前</li>
<li v-if="!isAffix(selectedTag)" @click="closeSelectedTag(selectedTag)">
关闭当前
</li>
<li @click="closeOthersTags">关闭其他</li>
<li @click="closeAllTags(selectedTag)">关闭所有</li>
</ul>
......@@ -31,8 +41,8 @@
</template>
<script>
import ScrollPane from "./ScrollPane";
import path from "path";
import ScrollPane from './ScrollPane'
import path from 'path'
export default {
components: { ScrollPane },
......@@ -43,177 +53,177 @@ export default {
left: 0,
selectedTag: {},
affixTags: [],
};
}
},
computed: {
visitedViews() {
return this.$store.state.tagsView.visitedViews;
return this.$store.state.tagsView.visitedViews
},
routes() {
return this.$store.state.permission.routes;
return this.$store.state.permission.routes
},
theme() {
return this.$store.state.settings.theme;
return this.$store.state.settings.theme
},
},
watch: {
$route() {
this.addTags();
this.moveToCurrentTag();
this.addTags()
this.moveToCurrentTag()
},
visible(value) {
if (value) {
document.body.addEventListener("click", this.closeMenu);
document.body.addEventListener('click', this.closeMenu)
} else {
document.body.removeEventListener("click", this.closeMenu);
document.body.removeEventListener('click', this.closeMenu)
}
},
},
mounted() {
this.initTags();
this.addTags();
this.initTags()
this.addTags()
},
methods: {
isActive(route) {
return route.path === this.$route.path;
return route.path === this.$route.path
},
activeStyle(tag) {
if (!this.isActive(tag)) return {};
if (!this.isActive(tag)) return {}
return {
"background-color": this.theme,
"border-color": this.theme,
};
'background-color': this.theme,
'border-color': this.theme,
}
},
isAffix(tag) {
return tag.meta && tag.meta.affix;
return tag.meta && tag.meta.affix
},
filterAffixTags(routes, basePath = "/") {
let tags = [];
filterAffixTags(routes, basePath = '/') {
let tags = []
routes.forEach((route) => {
if (route.meta && route.meta.affix) {
const tagPath = path.resolve(basePath, route.path);
const tagPath = path.resolve(basePath, route.path)
tags.push({
fullPath: tagPath,
path: tagPath,
name: route.name,
meta: { ...route.meta },
});
})
}
if (route.children) {
const tempTags = this.filterAffixTags(route.children, route.path);
const tempTags = this.filterAffixTags(route.children, route.path)
if (tempTags.length >= 1) {
tags = [...tags, ...tempTags];
tags = [...tags, ...tempTags]
}
}
});
return tags;
})
return tags
},
initTags() {
const affixTags = (this.affixTags = this.filterAffixTags(this.routes));
const affixTags = (this.affixTags = this.filterAffixTags(this.routes))
for (const tag of affixTags) {
// Must have tag name
if (tag.name) {
this.$store.dispatch("tagsView/addVisitedView", tag);
this.$store.dispatch('tagsView/addVisitedView', tag)
}
}
},
addTags() {
const { name } = this.$route;
const { name } = this.$route
if (name) {
this.$store.dispatch("tagsView/addView", this.$route);
this.$store.dispatch('tagsView/addView', this.$route)
}
return false;
return false
},
moveToCurrentTag() {
const tags = this.$refs.tag;
const tags = this.$refs.tag
this.$nextTick(() => {
for (const tag of tags) {
if (tag.to.path === this.$route.path) {
this.$refs.scrollPane.moveToTarget(tag);
this.$refs.scrollPane.moveToTarget(tag)
// when query is different then update
if (tag.to.fullPath !== this.$route.fullPath) {
this.$store.dispatch("tagsView/updateVisitedView", this.$route);
this.$store.dispatch('tagsView/updateVisitedView', this.$route)
}
break;
break
}
}
});
})
},
refreshSelectedTag(view) {
this.$store.dispatch("tagsView/delCachedView", view).then(() => {
const { fullPath } = view;
this.$store.dispatch('tagsView/delCachedView', view).then(() => {
const { fullPath } = view
this.$nextTick(() => {
this.$router.replace({
path: "/redirect" + fullPath,
});
});
});
path: '/redirect' + fullPath,
})
})
})
},
closeSelectedTag(view) {
this.$store
.dispatch("tagsView/delView", view)
.dispatch('tagsView/delView', view)
.then(({ visitedViews }) => {
if (this.isActive(view)) {
this.toLastView(visitedViews, view);
this.toLastView(visitedViews, view)
}
});
})
},
closeOthersTags() {
this.$router.push(this.selectedTag);
this.$router.push(this.selectedTag)
this.$store
.dispatch("tagsView/delOthersViews", this.selectedTag)
.dispatch('tagsView/delOthersViews', this.selectedTag)
.then(() => {
this.moveToCurrentTag();
});
this.moveToCurrentTag()
})
},
closeAllTags(view) {
this.$store.dispatch("tagsView/delAllViews").then(({ visitedViews }) => {
this.$store.dispatch('tagsView/delAllViews').then(({ visitedViews }) => {
if (this.affixTags.some((tag) => tag.path === view.path)) {
return;
return
}
this.toLastView(visitedViews, view);
});
this.toLastView(visitedViews, view)
})
},
toLastView(visitedViews, view) {
const latestView = visitedViews.slice(-1)[0];
const latestView = visitedViews.slice(-1)[0]
if (latestView) {
this.$router.push(latestView.fullPath);
this.$router.push(latestView.fullPath)
} else {
// now the default is to redirect to the home page if there is no tags-view,
// you can adjust it according to your needs.
if (view.name === "Dashboard") {
if (view.name === 'Dashboard') {
// to reload home page
this.$router.replace({ path: "/redirect" + view.fullPath });
this.$router.replace({ path: '/redirect' + view.fullPath })
} else {
this.$router.push("/");
this.$router.push('/')
}
}
},
openMenu(tag, e) {
const menuMinWidth = 105;
const offsetLeft = this.$el.getBoundingClientRect().left; // container margin left
const offsetWidth = this.$el.offsetWidth; // container width
const maxLeft = offsetWidth - menuMinWidth; // left boundary
const left = e.clientX - offsetLeft + 15; // 15: margin right
const menuMinWidth = 105
const offsetLeft = this.$el.getBoundingClientRect().left // container margin left
const offsetWidth = this.$el.offsetWidth // container width
const maxLeft = offsetWidth - menuMinWidth // left boundary
const left = e.clientX - offsetLeft + 15 // 15: margin right
if (left > maxLeft) {
this.left = maxLeft;
this.left = maxLeft
} else {
this.left = left;
this.left = left
}
this.top = e.clientY;
this.visible = true;
this.selectedTag = tag;
this.top = e.clientY
this.visible = true
this.selectedTag = tag
},
closeMenu() {
this.visible = false;
this.visible = false
},
handleScroll() {
this.closeMenu();
this.closeMenu()
},
},
};
}
</script>
<style lang="scss" scoped>
......@@ -248,7 +258,7 @@ export default {
color: #fff;
border-color: #42b983;
&::before {
content: "";
content: '';
background: #fff;
display: inline-block;
width: 8px;
......
const state = {
visitedViews: [],
cachedViews: []
cachedViews: [],
}
const mutations = {
ADD_VISITED_VIEW: (state, view) => {
if (state.visitedViews.some(v => v.path === view.path)) return
state.visitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (state.visitedViews.some((v) => v.path === view.path)) return
view.meta.title = view.meta.title || 'no-name'
state.visitedViews.push(Object.assign({}, view))
},
ADD_CACHED_VIEW: (state, view) => {
if (state.cachedViews.includes(view.name)) return
......@@ -33,7 +30,7 @@ const mutations = {
},
DEL_OTHERS_VISITED_VIEWS: (state, view) => {
state.visitedViews = state.visitedViews.filter(v => {
state.visitedViews = state.visitedViews.filter((v) => {
return v.meta.affix || v.path === view.path
})
},
......@@ -46,12 +43,12 @@ const mutations = {
}
},
DEL_ALL_VISITED_VIEWS: state => {
DEL_ALL_VISITED_VIEWS: (state) => {
// keep affix tags
const affixTags = state.visitedViews.filter(tag => tag.meta.affix)
const affixTags = state.visitedViews.filter((tag) => tag.meta.affix)
state.visitedViews = affixTags
},
DEL_ALL_CACHED_VIEWS: state => {
DEL_ALL_CACHED_VIEWS: (state) => {
state.cachedViews = []
},
......@@ -62,7 +59,7 @@ const mutations = {
break
}
}
}
},
}
const actions = {
......@@ -78,69 +75,69 @@ const actions = {
},
delView({ dispatch, state }, view) {
return new Promise(resolve => {
return new Promise((resolve) => {
dispatch('delVisitedView', view)
dispatch('delCachedView', view)
resolve({
visitedViews: [...state.visitedViews],
cachedViews: [...state.cachedViews]
cachedViews: [...state.cachedViews],
})
})
},
delVisitedView({ commit, state }, view) {
return new Promise(resolve => {
return new Promise((resolve) => {
commit('DEL_VISITED_VIEW', view)
resolve([...state.visitedViews])
})
},
delCachedView({ commit, state }, view) {
return new Promise(resolve => {
return new Promise((resolve) => {
commit('DEL_CACHED_VIEW', view)
resolve([...state.cachedViews])
})
},
delOthersViews({ dispatch, state }, view) {
return new Promise(resolve => {
return new Promise((resolve) => {
dispatch('delOthersVisitedViews', view)
dispatch('delOthersCachedViews', view)
resolve({
visitedViews: [...state.visitedViews],
cachedViews: [...state.cachedViews]
cachedViews: [...state.cachedViews],
})
})
},
delOthersVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
return new Promise((resolve) => {
commit('DEL_OTHERS_VISITED_VIEWS', view)
resolve([...state.visitedViews])
})
},
delOthersCachedViews({ commit, state }, view) {
return new Promise(resolve => {
return new Promise((resolve) => {
commit('DEL_OTHERS_CACHED_VIEWS', view)
resolve([...state.cachedViews])
})
},
delAllViews({ dispatch, state }, view) {
return new Promise(resolve => {
return new Promise((resolve) => {
dispatch('delAllVisitedViews', view)
dispatch('delAllCachedViews', view)
resolve({
visitedViews: [...state.visitedViews],
cachedViews: [...state.cachedViews]
cachedViews: [...state.cachedViews],
})
})
},
delAllVisitedViews({ commit, state }) {
return new Promise(resolve => {
return new Promise((resolve) => {
commit('DEL_ALL_VISITED_VIEWS')
resolve([...state.visitedViews])
})
},
delAllCachedViews({ commit, state }) {
return new Promise(resolve => {
return new Promise((resolve) => {
commit('DEL_ALL_CACHED_VIEWS')
resolve([...state.cachedViews])
})
......@@ -148,12 +145,12 @@ const actions = {
updateVisitedView({ commit }, view) {
commit('UPDATE_VISITED_VIEW', view)
}
},
}
export default {
namespaced: true,
state,
mutations,
actions
actions,
}
......@@ -84,7 +84,7 @@ export default {
rules: Object.freeze({
name: [{ required: true, message: '必填项', trigger: 'blur' }],
userId: [{ required: true, message: '必填项', trigger: 'blur' }],
department: [{ required: true, message: '必填项', trigger: 'blur' }],
department: [{ required: true, message: '必填项', trigger: 'change' }],
joinTime: [{ required: true, message: '必填项', trigger: 'blur' }],
wxAccount: [{ required: true, message: '必填项', trigger: 'blur' }],
email: [
......@@ -143,6 +143,7 @@ export default {
this.getList(1)
},
edit(data, type) {
this.$refs['form'] && this.$refs['form'].clearValidate()
this.form = Object.assign({}, data || { _new: true })
this.dialogVisible = true
type || !data ? (this.disabled = false) : (this.disabled = true)
......@@ -309,14 +310,14 @@ export default {
@click="batchImport"
>批量导入</el-button
>
<el-button
<!-- <el-button
v-hasPermi="['contacts:organization:addMember']"
type="primary"
icon="el-icon-plus"
size="mini"
@click="edit()"
>添加成员</el-button
>
> -->
</div>
<el-row :gutter="20">
<!--部门数据-->
......@@ -495,7 +496,7 @@ export default {
<el-radio :label="2">女</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="手机号" prop="name">
<el-form-item label="手机号" prop="mobile">
<el-input v-model="form.mobile"></el-input>
</el-form-item>
<el-form-item label="邮箱">
......
......@@ -136,10 +136,9 @@ export default {
type: 'query',
}
this.dialogVisible = true
this.$refs.selectTag.$forceUpdate()
// this.$refs.selectTag.$forceUpdate()
},
makeTag(type) {
this.selectedTag = []
if (!this.multipleSelection.length) {
this.msgInfo('请选择一位客户')
return
......@@ -148,33 +147,53 @@ export default {
this.msgInfo('同时只能选择一位客户')
return
}
let isError = false
this.selectedTag = []
let hasErrorTag = []
let repeat = []
this.multipleSelection.forEach((element) => {
element.weFlowerCustomerRels.forEach((child) => {
child.weFlowerCustomerTagRels.forEach((grandchild) => {
// 判断是否有重复标签
let isRepeat = this.selectedTag.some((d) => {
return d.tagId === grandchild.tagId
})
// 去重
if (isRepeat) {
repeat.push(grandchild.tagName)
return
}
let filter = this.listTagOneArray.find((d) => {
return d.tagId === grandchild.tagId
})
// 如果没有匹配到,则说明该便签处于异常状态,可能已被删除或破坏
if (!filter) {
hasErrorTag.push(grandchild.tagName)
isError = true
return
}
this.selectedTag.push(filter)
})
})
})
if (isError) {
this.msgError('已有标签不在便签库中,或存在异常')
if (hasErrorTag.length > 0) {
this.msgError('已有标签[' + hasErrorTag + ']不在标签库中,或存在异常')
return
}
if (type === 'remove' && this.selectedTag.length === 0) {
this.msgError('该客户没有标签,不可进行移除')
return
}
this.tagDialogType = {
title: type === 'add' ? '增加标签' : '移出标签',
title:
(type === 'add' ? '增加标签' : '移出标签') +
(repeat.length ? '(重复的标签已去重显示)' : ''),
type: type,
}
this.removeTag = this.selectedTag.slice()
this.dialogVisible = true
this.$refs.selectTag.$forceUpdate()
// this.$refs.selectTag.$forceUpdate()
},
sync() {
const loading = this.$loading({
......@@ -247,6 +266,13 @@ export default {
handleSelectionChange(selection) {
this.multipleSelection = selection
},
// 用于多选变单选
handleSelection(selection, row) {
this.$nextTick(() => {
this.$refs.table.clearSelection()
this.$refs.table.toggleRowSelection(row, true)
})
},
},
}
</script>
......@@ -337,6 +363,7 @@ export default {
size="mini"
icon="el-icon-s-flag"
@click="makeTag('add')"
:disabled="multipleSelection.length !== 1"
>打标签</el-button
>
<el-button
......@@ -345,6 +372,7 @@ export default {
size="mini"
icon="el-icon-brush"
@click="makeTag('remove')"
:disabled="multipleSelection.length !== 1"
>移除标签</el-button
>
<el-button
......@@ -366,10 +394,11 @@ export default {
</div>
<el-table
ref="multipleTable"
ref="table"
:data="list"
tooltip-effect="dark"
style="width: 100%"
highlight-current-row
@select="handleSelection"
@selection-change="handleSelectionChange"
>
<el-table-column
......
......@@ -12,7 +12,7 @@ export default {
// dialogVisible1: false,
dialogVisibleSelectMaterial: false,
form: {
id: '',
// id: '',
mediaId: '',
welcomeMsgTplType: '',
welcomeMsg: '',
......@@ -26,6 +26,7 @@ export default {
computed: {},
created() {
this.form = Object.assign(this.form, this.$route.query)
this.$route.meta.title = (this.form.id ? '编辑' : '新建') + '欢迎语'
},
mounted() {},
methods: {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!