Commit 31e8b6fe by xinla

修改部分issue问题

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