Commit 3043e528 by xinlaa

添加标签组件抽离,客户打标签,移出标签异常判断等

1 parent 739d65ea
<script>
import { getList } from '@/api/customer/tag'
export default {
name: 'SelectTag',
components: {},
props: {
// 添加标签显隐
visible: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '选择成员',
},
selected: {
type: Array,
default: () => [],
},
type: {
type: String,
default: 'add',
},
},
data() {
return {
list: [],
listOneArray: [],
selectedGroup: '', // 选择的标签分组
removeTag: [],
Pselected: this.selected,
}
},
watch: {
type(val) {
val === 'remove' && (this.removeTag = this.selected.slice())
},
},
computed: {
Pvisible: {
get() {
// this.getTree();
return this.visible
},
set(val) {
this.$emit('update:visible', val)
},
},
},
created() {
// this.type === 'remove' && (this.removeTag = this.Pselected.slice())
this.getList()
},
mounted() {},
methods: {
getList() {
getList().then(({ rows }) => {
this.list = Object.freeze(rows)
this.listOneArray = []
this.list.forEach((element) => {
element.weTags.forEach((d) => {
this.listOneArray.push(d)
})
})
})
},
submit() {
this.Pvisible = false
this.$emit('success', this.Pselected)
},
},
}
</script>
<template>
<el-dialog :title="title" :visible.sync="Pvisible">
<div>
<span class="mr20">选择分组</span>
<el-select v-model="selectedGroup" placeholder="请选择">
<el-option label="所有标签" value></el-option>
<el-option
v-for="(item, index) in list"
:key="index"
:label="item.gourpName"
:value="item.groupId"
></el-option>
</el-select>
<div class="mt20">
<el-checkbox-group v-model="Pselected" v-if="type !== 'remove'">
<template v-for="(item, index) in list">
<div
class="bfc-d"
v-show="item.groupId === selectedGroup || !selectedGroup"
:key="index"
>
<el-checkbox
:label="unit"
v-for="(unit, unique) in item.weTags"
:key="index + unique"
>{{ unit.name }}</el-checkbox
>
</div>
</template>
</el-checkbox-group>
<el-checkbox-group v-else v-model="Pselected">
<template v-for="(item, index) in removeTag">
<el-checkbox
v-if="item.groupId === selectedGroup || !selectedGroup"
:label="item"
:key="index"
>{{ item.name }}</el-checkbox
>
</template>
</el-checkbox-group>
</div>
<slot></slot>
</div>
<div slot="footer">
<el-button @click="Pvisible = false">取 消</el-button>
<el-button type="primary" @click="submit">确 定</el-button>
</div>
</el-dialog>
</template>
<style lang="scss" scoped>
.user-list {
.el-row {
line-height: 26px;
}
}
</style>
......@@ -2,12 +2,13 @@
import * as api from '@/api/customer'
import { getList as getListTag } from '@/api/customer/tag'
import { getList as getListOrganization } from '@/api/organization'
import AddTag from './components/AddTag'
import SelectUser from './components/SelectUser'
import AddTag from '@/components/AddTag'
import SelectUser from '@/components/SelectUser'
import SelectTag from '@/components/SelectTag'
export default {
name: 'Customer',
components: { AddTag, SelectUser },
components: { AddTag, SelectUser, SelectTag },
props: {},
data() {
return {
......@@ -67,7 +68,6 @@ export default {
weTags: [],
},
list: [], // 客户列表
listTag: [], // 标签列表
listOrganization: [], // 组织架构列表
multipleSelection: [], // 多选数组
dialogVisible: false, // 选择标签弹窗显隐
......@@ -116,9 +116,8 @@ export default {
},
getListTag() {
getListTag().then(({ rows }) => {
this.listTag = Object.freeze(rows)
this.listTagOneArray = []
this.listTag.forEach((element) => {
rows.forEach((element) => {
element.weTags.forEach((d) => {
this.listTagOneArray.push(d)
})
......@@ -148,21 +147,30 @@ export default {
this.msgInfo('同时只能选择一位客户')
return
}
this.tagDialogType = {
title: type === 'add' ? '增加标签' : '移出标签',
type: type,
}
let isError = false
this.multipleSelection.forEach((element) => {
// debugger;
element.weFlowerCustomerRels.forEach((child) => {
child.weFlowerCustomerTagRels.forEach((grandchild) => {
let filter = this.listTagOneArray.find((d) => {
return d.tagId === grandchild.tagId
})
// 如果没有匹配到,则说明该便签处于异常状态,可能已被删除或破坏
if (!filter) {
isError = true
return
}
this.selectedTag.push(filter)
})
})
})
if (isError) {
this.msgError('已有标签不在便签库中,或存在异常')
return
}
this.tagDialogType = {
title: type === 'add' ? '增加标签' : '移出标签',
type: type,
}
this.removeTag = this.selectedTag.slice()
this.dialogVisible = true
},
......@@ -204,16 +212,16 @@ export default {
this.queryUser = list
this.query.userIds = list.map((d) => d.userId) + ''
},
submitSelectTag(formName) {
submitSelectTag(selected) {
if (this.tagDialogType.type === 'query') {
this.query.tagIds = this.selectedTag.map((d) => d.tagId) + ''
this.query.tagIds = selected.map((d) => d.tagId) + ''
// debugger;
this.queryTag = this.selectedTag
this.queryTag = selected
this.dialogVisible = false
} else {
let data = {
externalUserid: this.multipleSelection[0].externalUserid,
addTag: this.selectedTag,
addTag: selected,
}
let apiType = {
add: 'makeLabel',
......@@ -228,6 +236,8 @@ export default {
},
resetForm(formName) {
this.dateRange = []
this.queryTag = []
this.queryUser = []
this.$refs['queryForm'].resetFields()
},
// 多选框选中数据
......@@ -436,7 +446,20 @@ export default {
/>
<!-- 选择标签弹窗 -->
<el-dialog
<SelectTag
:visible.sync="dialogVisible"
:title="tagDialogType.title"
:selected="selectedTag"
:type="tagDialogType.type"
@success="submitSelectTag"
>
<div class="mt20" v-show="tagDialogType.type === 'add'">
<el-button type="primary" @click="dialogVisibleAddTag = true"
>添加标签</el-button
>
</div>
</SelectTag>
<!-- <el-dialog
key="1"
:title="tagDialogType.title"
:visible.sync="dialogVisible"
......@@ -493,7 +516,7 @@ export default {
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="submitSelectTag">确 定</el-button>
</div>
</el-dialog>
</el-dialog> -->
<!-- 选择添加人弹窗 -->
<SelectUser
......
<script>
import * as api from "@/api/customer/dimission";
import SelectUser from "../components/SelectUser";
import * as api from '@/api/customer/dimission'
import SelectUser from '@/components/SelectUser'
export default {
name: "Dimission",
name: 'Dimission',
components: { SelectUser },
props: {},
data() {
......@@ -20,8 +20,8 @@ export default {
isMoreFilter: false,
total: 0,
form: {
user: "",
region: "",
user: '',
region: '',
},
list: [],
currentRow: {},
......@@ -30,81 +30,81 @@ export default {
// 日期快捷选项
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
return time.getTime() > Date.now()
},
shortcuts: [
{
text: "最近一周",
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit("pick", [start, end]);
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
picker.$emit('pick', [start, end])
},
},
{
text: "最近一个月",
text: '最近一个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
},
},
{
text: "最近三个月",
text: '最近三个月',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit("pick", [start, end]);
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
picker.$emit('pick', [start, end])
},
},
],
},
};
}
},
watch: {},
computed: {},
created() {
this.getList();
this.getList()
},
mounted() {},
methods: {
/** 查询 */
getList(page) {
if (this.dateRange[0]) {
this.query.beginTime = this.dateRange[0];
this.query.endTime = this.dateRange[1];
this.query.beginTime = this.dateRange[0]
this.query.endTime = this.dateRange[1]
}
page && (this.query.pageNum = page);
this.loading = true;
page && (this.query.pageNum = page)
this.loading = true
api
.getListNo(this.query)
.then(({ rows, total }) => {
this.list = rows;
this.total = +total;
this.loading = false;
this.list = rows
this.total = +total
this.loading = false
})
.catch(() => {
this.loading = false;
});
this.loading = false
})
},
resetForm(formName) {
this.dateRange = [];
this.$refs["queryForm"].resetFields();
this.dateRange = []
this.$refs['queryForm'].resetFields()
},
showSelectDialog() {
if (this.currentRow.userId) {
this.dialogVisibleSelectUser = true;
this.dialogVisibleSelectUser = true
} else {
this.$message.warning("请先选择一位员工");
this.$message.warning('请先选择一位员工')
}
},
allocate(userlist) {
if (userlist.length > 1) {
this.dialogVisibleSelectUser = true;
return;
this.dialogVisibleSelectUser = true
return
}
api
.allocate({
......@@ -112,20 +112,26 @@ export default {
takeoverUserid: userlist[0].userId,
})
.then(() => {
this.msgSuccess("操作成功");
});
this.msgSuccess('操作成功')
})
},
// 选中数据
handleCurrentChange(val) {
this.currentRow = val;
this.currentRow = val
},
},
};
}
</script>
<template>
<div class="page">
<el-form ref="queryForm" :inline="true" :model="query" label-width="100px" class="top-search">
<el-form
ref="queryForm"
:inline="true"
:model="query"
label-width="100px"
class="top-search"
>
<el-form-item label="已离职员工">
<el-input v-model="query.userName" placeholder="请输入"></el-input>
</el-form-item>
......@@ -142,37 +148,48 @@ export default {
</el-form-item>
<el-form-item label="离职日期">
<el-date-picker v-model="query.beginTime" type="date" placeholder="离职日期" align="right"></el-date-picker>
<el-date-picker
v-model="query.beginTime"
type="date"
placeholder="离职日期"
align="right"
></el-date-picker>
</el-form-item>
<el-form-item label>
<el-button
v-hasPermi="['customerManage:dimission:query']"
type="primary"
@click="getList(1)"
>查询</el-button>
>查询</el-button
>
<el-button
v-hasPermi="['customerManage:dimission:query']"
type="info"
@click="resetForm('queryForm')"
>重置</el-button>
>重置</el-button
>
</el-form-item>
</el-form>
<div class="mid-action">
<div class="total">从通讯录将离职员工删除后,可以分配他的客户及客户群给其他员工继续跟进</div>
<div class="total">
从通讯录将离职员工删除后,可以分配他的客户及客户群给其他员工继续跟进
</div>
<div>
<el-button
v-hasPermi="['customerManage:dimission:filter']"
type="primary"
size="mini"
@click="$router.push({path: '/customerManage/allocatedStaffList'})"
>已分配的离职员工</el-button>
@click="$router.push({ path: '/customerManage/allocatedStaffList' })"
>已分配的离职员工</el-button
>
<el-button
v-hasPermi="['customerManage:dimission:allocate']"
type="primary"
size="mini"
@click="showSelectDialog"
>分配给其他员工</el-button>
>分配给其他员工</el-button
>
</div>
</div>
......@@ -187,9 +204,21 @@ export default {
<el-table-column type="index" label="序号" width="55"></el-table-column>
<el-table-column prop="userName" label="已离职员工"></el-table-column>
<el-table-column prop="department" label="所属部门"></el-table-column>
<el-table-column prop="allocateCustomerNum" label="待分配客户数" show-overflow-tooltip></el-table-column>
<el-table-column prop="allocateGroupNum" label="待分配群聊数" show-overflow-tooltip></el-table-column>
<el-table-column prop="dimissionTime" label="离职时间" show-overflow-tooltip>
<el-table-column
prop="allocateCustomerNum"
label="待分配客户数"
show-overflow-tooltip
></el-table-column>
<el-table-column
prop="allocateGroupNum"
label="待分配群聊数"
show-overflow-tooltip
></el-table-column>
<el-table-column
prop="dimissionTime"
label="离职时间"
show-overflow-tooltip
>
<template slot-scope="scope">{{ scope.row.dimissionTime }}</template>
</el-table-column>
<!-- <el-table-column label="操作" width="100">
......@@ -200,7 +229,7 @@ export default {
</el-table>
<pagination
v-show="total>0"
v-show="total > 0"
:total="total"
:page.sync="query.pageNum"
:limit.sync="query.pageSize"
......@@ -208,7 +237,11 @@ export default {
/>
<!-- 选择添加人弹窗 -->
<SelectUser :visible.sync="dialogVisibleSelectUser" title="选择分配人" @success="allocate"></SelectUser>
<SelectUser
:visible.sync="dialogVisibleSelectUser"
title="选择分配人"
@success="allocate"
></SelectUser>
</div>
</template>
......
<script>
import * as api from "@/api/customer/tag";
import AddTag from "./components/AddTag";
import * as api from '@/api/customer/tag'
import AddTag from '@/components/AddTag'
export default {
name: "CustomerTag",
name: 'CustomerTag',
components: { AddTag },
data() {
return {
query: {
pageNum: 1,
pageSize: "",
pageSize: '',
},
// 遮罩层
loading: false,
dialogVisible: false,
// 表单参数
form: {
gourpName: "",
gourpName: '',
weTags: [],
},
// 添加标签输入框
newInput: "",
newInput: '',
// 添加标签显隐
newInputVisible: false,
// 表单验证规则
rules: Object.freeze({
gourpName: [{ required: true, message: "必填项", trigger: "blur" }],
gourpName: [{ required: true, message: '必填项', trigger: 'blur' }],
}),
// 选中数组
ids: [],
......@@ -35,66 +35,66 @@ export default {
total: 0,
// 表格数据
list: [],
};
}
},
created() {
this.getList();
this.getList()
},
methods: {
getList(page) {
page && (this.query.pageNum = page);
this.loading = true;
page && (this.query.pageNum = page)
this.loading = true
api
.getList(this.query)
.then(({ rows, total }) => {
this.list = rows;
this.total = +total;
this.loading = false;
this.list = rows
this.total = +total
this.loading = false
})
.catch(() => {
this.loading = false;
});
this.loading = false
})
},
edit(data, type) {
this.form = JSON.parse(
JSON.stringify(Object.assign({ weTags: [] }, data || {}))
);
this.dialogVisible = true;
)
this.dialogVisible = true
},
syncTag() {
const loading = this.$loading({
lock: true,
text: "Loading",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
});
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)',
})
api.syncTag().then(() => {
loading.close();
this.msgSuccess("操作成功");
this.getList();
});
loading.close()
this.msgSuccess('操作成功')
this.getList()
})
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.groupId);
this.multiple = !selection.length;
this.ids = selection.map((item) => item.groupId)
this.multiple = !selection.length
},
/** 删除按钮操作 */
remove(id) {
const operIds = id || this.ids + "";
this.$confirm("是否确认删除吗?", "警告", {
type: "warning",
const operIds = id || this.ids + ''
this.$confirm('是否确认删除吗?', '警告', {
type: 'warning',
})
.then(function () {
return api.remove(operIds);
.then(function() {
return api.remove(operIds)
})
.then(() => {
this.getList();
this.msgSuccess("删除成功");
});
this.getList()
this.msgSuccess('删除成功')
})
},
},
};
}
</script>
<template>
<div class="app-container">
......@@ -107,14 +107,16 @@ export default {
size="mini"
icon="el-icon-plus"
@click="edit()"
>新建标签组</el-button>
>新建标签组</el-button
>
<el-button
v-hasPermi="['customerManage:tag:sync']"
type="primary"
size="mini"
icon="el-icon-refresh"
@click="syncTag"
>同步标签组</el-button>
>同步标签组</el-button
>
<el-button
v-hasPermi="['customerManage:tag:remove']"
v-if="ids.length"
......@@ -122,16 +124,26 @@ export default {
size="mini"
icon="el-icon-delete"
@click="remove()"
>批量删除</el-button>
>批量删除</el-button
>
</div>
</div>
<el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
<el-table
v-loading="loading"
:data="list"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="标签组" align="center" prop="gourpName" />
<el-table-column label="标签" align="center" prop="weTags">
<template slot-scope="scope">
<el-tag type="info" v-for="(item, index) in scope.row.weTags" :key="index">{{item.name}}</el-tag>
<el-tag
type="info"
v-for="(item, index) in scope.row.weTags"
:key="index"
>{{ item.name }}</el-tag
>
</template>
</el-table-column>
<el-table-column label="创建人" align="center" prop="createBy" />
......@@ -140,24 +152,34 @@ export default {
<span>{{ parseTime(scope.row.operTime) }}</span>
</template>
</el-table-column>-->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
v-hasPermi="['customerManage:tag:edit']"
type="text"
@click="edit(scope.row,scope.index)"
>编辑</el-button>
@click="edit(scope.row, scope.index)"
>编辑</el-button
>
<el-button
v-hasPermi="['customerManage:tag:remove']"
@click="remove(scope.row.groupId)"
type="text"
>删除</el-button>
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<!-- 弹窗 -->
<AddTag :visible.sync="dialogVisible" :form="form" @success="getList(!form.groupId && 1)" />
<AddTag
:visible.sync="dialogVisible"
:form="form"
@success="getList(!form.groupId && 1)"
/>
</div>
</template>
<style lang="scss" scoped>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!