提交 6f71692e authored 作者: matian's avatar matian

代码提交

上级 a8790fd2
...@@ -10,44 +10,47 @@ export function getCustomerGroup(params) { ...@@ -10,44 +10,47 @@ export function getCustomerGroup(params) {
return httpRequest.get('/api/customer/admin/v1/groups', params) return httpRequest.get('/api/customer/admin/v1/groups', params)
} }
// 获取客户 // 获取被分配到客户组的客户
export function customerDetail(params) { export function customerDetail(params) {
return httpRequest.get(`/api/customer/admin/v1/${params.group_id}/group-customers`, params) return httpRequest.get(`/api/customer//admin/v1/${params.group_id}/group-customers`, params)
} }
// 获取员工 // 获取客户列表
export function employeeDetail(params) {
return httpRequest.get(`/api/customer/admin/v1/${params.group_id}/group-staffs`, params)
}
//获取客户列表
export function getEmployeeList(params) { export function getEmployeeList(params) {
return httpRequest.get(`/api/customer/admin/v1/${params.group_id}/customer`, params) return httpRequest.get(`/api/customer/admin/v1/${params.group_id}/customers`, params)
} }
// 编辑客户组 // 编辑客户组
export function editCustomerGroup(id, data) { export function editCustomerGroup(data) {
return httpRequest.put(`/api/customer/admin/v1/group/${id}`, data) return httpRequest.put(`/api/customer/admin/v1/group/${data.id}`, data)
} }
// 删除客户组 // 删除客户组
export function delCustomerGroup(id, data) { export function deleteGroup(data) {
return httpRequest.delete(`/api/customer/admin/v1/group/${id}`, data) return httpRequest.delete(`/api/customer/admin/v1/group/${data.id}`, data)
} }
// 添加客户 // 分配客户到客户组
export function createCustomer(groupId, data) { export function createCustomer(data) {
return httpRequest.post(`/api/customer/admin/v1/${groupId}/customer-to-group`, data) return httpRequest.post(`/api/customer/admin/v1/${data.group_id}/customer-to-group`, data)
} }
// 删除客户
export function delCustomer(id) { // 移除被分配到客户组的客户
return httpRequest.delete(`/api/customer/admin/v1/customer/${id}`) export function delCustomer(data) {
return httpRequest.post('/api/customer/admin/v1/group/remove-group-customers', data)
} }
// 添加员工 // 分配员工到客户组
export function createEmployee(groupId, data) { export function createEmployee(data) {
return httpRequest.post(`/api/customer/admin/v1/${groupId}/staff-to-group`, data) return httpRequest.post(`/api/customer/admin/v1/${data.group_id}/staff-to-group`, data)
} }
// 删除员工
export function delEmployee(id, data) { // 获取客户组的员工
return httpRequest.delete(`/api/customer/admin/v1/contact/${id}`, data) export function employeeDetail(params) {
return httpRequest.get(`/api/customer/admin/v1/${params.group_id}/group-staffs`, params)
}
// 移除被分配到客户组的员工
export function delEmployee(data) {
return httpRequest.post('/api/customer/admin/v1/group/remove-group-staffs', data)
} }
// 搜索员工 // 搜索员工
export function getEmployee(params) { export function getEmployee(params) {
......
...@@ -12,14 +12,22 @@ ...@@ -12,14 +12,22 @@
</template> </template>
<script> <script>
import { getEmployeeList } from '../api' import { getEmployeeList, createCustomer, getEmployee } from '../api'
export default { export default {
data() { data() {
return { return {
employeeList: {
items: []
},
multipleSelection: [] multipleSelection: []
} }
}, },
props: {
id: {
type: String
}
},
computed: { computed: {
// 列表配置 // 列表配置
tableOptions() { tableOptions() {
...@@ -27,94 +35,68 @@ export default { ...@@ -27,94 +35,68 @@ export default {
remote: { remote: {
httpRequest: getEmployeeList, httpRequest: getEmployeeList,
params: { params: {
personal_name: '', name: '',
telephone: '', created_by: '',
id: '', group_id: this.id
sno: ''
} }
}, },
filters: [ filters: [
{ {
type: 'input', type: 'input',
prop: 'name', prop: 'name',
placeholder: '请输入客户名称', placeholder: '客户名称'
filterable: true,
remote: true
}, },
{ {
type: 'select', type: 'select',
prop: 'create', prop: 'username',
options: this.employeeList.items,
labelKey: 'username',
valueKey: 'id',
placeholder: '创建员工', placeholder: '创建员工',
labelKey: 'value',
valueKey: 'key',
options: '',
filterable: true, filterable: true,
remote: true remote: true,
'remote-method': this.fetchEmployeeList
} }
], ],
columns: [ columns: [
{ type: 'selection', minWidth: '50px', fixed: 'left' }, { type: 'selection', minWidth: '50px', fixed: 'left' },
{ label: '客户名称', prop: 'name', align: 'center' }, { label: '客户名称', prop: 'name', align: 'center' },
{ label: '合作项目', prop: 'project', align: 'center' }, { label: '合作项目', prop: 'project_count', align: 'center' },
{ label: '所在地区', prop: 'region', align: 'center' }, { label: '所在地区', prop: 'region', align: 'center' },
{ label: '创建时间', prop: 'created_at', align: 'center' }, { label: '创建时间', prop: 'created_at', align: 'center' },
{ label: '创建人', prop: 'creater', align: 'center' } { label: '创建人', prop: 'created_by.username', align: 'center' }
],
data: [
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
},
{
group_name: '1213'
}
] ]
} }
} }
}, },
mounted() {
// this.getStudent()
},
methods: { methods: {
fetchEmployeeList() {
const params = {
id: '',
name: '',
username: '',
nickname: '',
email: '',
mobile: ''
}
// 搜索员工
getEmployee(params).then(res => {
this.employeeList = res.data
})
},
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val this.multipleSelection = val
}, },
submit() { submit() {
// const params = this.multipleSelection const param = this.multipleSelection
// addCustomer(params).then(res => { const arr = param.map(item => item.id)
// this.$message.success('添加客户成功') console.log(arr)
// this.$emit('update:visible', false) const params = { group_id: this.id, customer_ids: arr }
// this.$emit('success') createCustomer(params).then(res => {
// }) this.$message.success('添加客户成功')
this.$emit('update:visible', false)
this.$emit('success')
})
} }
} }
} }
......
<template> <template>
<el-dialog v-bind="$attrs" v-on="$listeners" width="30%" top="40vh" title="新建客户组"> <el-dialog v-bind="$attrs" v-on="$listeners" width="30%" top="40vh" :title="title">
<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="name"> <el-form-item label="客户组名称" prop="name">
<el-input v-model="form.name" /> <el-input v-model="form.name" />
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</template> </template>
<script> <script>
import { createCustomerGroup } from '../api' import { createCustomerGroup, editCustomerGroup } from '../api'
export default { export default {
data() { data() {
return { return {
...@@ -28,50 +28,48 @@ export default { ...@@ -28,50 +28,48 @@ export default {
} }
} }
}, },
// props: { props: {
// id: { data: {
// type: String, type: Object,
// default: '' default: () => ({})
// } },
// }, isEdit: { type: Boolean, default: false }
// computed: { },
// title() { watch: {
// if (this.id !== '') { data: {
// return '编辑客户组' immediate: true,
// } else { handler(data) {
// return '新建客户组' this.form = Object.assign({}, this.form, data)
// } }
// } }
// }, },
computed: {
title() {
return this.isEdit ? '编辑客户组' : '新建客户组'
}
},
methods: { methods: {
// 提交 // 提交
submit() { submit() {
this.$refs.form.validate().then(() => { this.$refs.form.validate().then(() => {
// if (this.id !== '') { this.isEdit ? this.edit() : this.create()
// //编辑
// this.edit()
// } else {
//新建
this.create()
// }
}) })
}, },
// 编辑/更新客户组 // 编辑/更新客户组
edit() { edit() {
console.log('222') const params = Object.assign({ id: this.row.id }, this.form)
// editGroup(Object.assign({ id: this.id }, this.form)).then(res => { editCustomerGroup(params).then(res => {
// this.$message.success('客户组创建成功') this.$message.success('客户组创建成功')
// this.$emit('update:visible', false) this.$emit('update:visible', false)
// this.$emit('success') this.$emit('success', res.data)
// }) })
}, },
//新建客户组 // 新建客户组
create() { create() {
// console.log('111')
createCustomerGroup(this.form).then(res => { createCustomerGroup(this.form).then(res => {
this.$message.success('客户组创建成功') this.$message.success('客户组创建成功')
this.$emit('update:visible', false) this.$emit('update:visible', false)
this.$emit('success') this.$emit('success', res.data)
}) })
} }
} }
......
<template> <template>
<el-dialog v-bind="$attrs" v-on="$listeners" width="30%" title="添加员工"> <el-dialog v-bind="$attrs" v-on="$listeners" width="30%" title="添加员工">
<el-form ref="form" :model="form" :rules="rules"> <el-form ref="form" :model="form" :rules="rules">
<el-form-item label="员工名称" prop="group_name"> <el-form-item label="员工名称" prop="id">
<el-select <el-select
type="text" type="text"
v-model="form.employee_name" v-model="form.id"
placeholder="员工姓名/手机号码搜索" placeholder="员工姓名/手机号码搜索"
filterable filterable
remote remote
:remote-method="fetchEmployeeList" :remote-method="fetchEmployeeList"
:loading="loading" :loading="loading"
size="80%" size="80%"
multiple
> >
<el-option v-for="item in employeeList" :key="item.id" :label="item.employee_name" :value="item.id"> <el-option v-for="item in employeeList" :key="item.id" :label="item.id" :value="item.id">
<span style="float: left"> <span style="float: left">
{{ item.employee_name }} {{ item.nickname }}
<template v-if="item.mobile">(手机号:{{ item.mobile }})</template> <template v-if="item.mobile">(手机号:{{ item.mobile }})</template>
</span> </span>
</el-option> </el-option>
...@@ -29,15 +30,22 @@ ...@@ -29,15 +30,22 @@
</template> </template>
<script> <script>
import { getEmployee, createEmployee } from '../api'
export default { export default {
props: {
id: {
type: String,
default: ''
}
},
data() { data() {
return { return {
loading: false, loading: false,
form: { form: {
employee_name: '' id: ''
}, },
rules: { rules: {
employee_name: [ id: [
{ required: true, message: '请输入员工名称', trigger: 'blur' }, { required: true, message: '请输入员工名称', trigger: 'blur' },
{ min: 0, max: 20, message: '您最多可输入20个字符', trigger: 'blur' } { min: 0, max: 20, message: '您最多可输入20个字符', trigger: 'blur' }
] ]
...@@ -45,21 +53,40 @@ export default { ...@@ -45,21 +53,40 @@ export default {
employeeList: [] employeeList: []
} }
}, },
mounted() {
console.log(this.id)
},
methods: { methods: {
fetchEmployeeList() { fetchEmployeeList(query) {
this.loading = true this.loading = true
// searchUsers().then(res => { const params = {
// this.loading = false id: '',
// this.employeeList = res.data.list name: '',
// }) username: '',
nickname: '',
email: '',
mobile: ''
}
if (query instanceof Number === true) {
params.mobile = query
} else {
params.nickname = query
}
// 搜索员工
getEmployee(params).then(res => {
this.loading = false
this.employeeList = res.data.items
})
}, },
submit() { submit() {
this.$refs.form.validate().then(() => { this.$refs.form.validate().then(() => {
// addEmployee(this.form).then(res => { const params = Object.assign({ group_id: this.id, staff_ids: this.form.id })
// this.$message.success('添加员工成功') createEmployee(params).then(res => {
// this.$emit('update:visible', false) this.$message.success('添加员工成功')
// this.$emit('success') this.$emit('update:visible', false)
// }) this.$emit('success')
})
}) })
} }
} }
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
<el-button type="text" @click="onRemove(row)">删除</el-button> <el-button type="text" @click="onRemove(row)">删除</el-button>
</template> </template>
</app-list> </app-list>
<AddCustomer :visible.sync="isShowDialog" @success="success" /> <AddCustomer :visible.sync="isShowDialog" @success="success" :id="id" />
</app-card> </app-card>
</template> </template>
<script> <script>
import { customerDetail } from '../api' import { customerDetail, delCustomer } from '../api'
import AddCustomer from '../components/AddCustomer.vue' import AddCustomer from '../components/AddCustomer.vue'
export default { export default {
data() { data() {
...@@ -38,15 +38,13 @@ export default { ...@@ -38,15 +38,13 @@ export default {
remote: { remote: {
httpRequest: customerDetail, httpRequest: customerDetail,
params: { params: {
created_by: '',
name: '',
group_id: this.id group_id: this.id
} }
}, },
columns: [ columns: [
{ label: '客户名称', prop: 'name', align: 'center' }, { label: '客户名称', prop: 'customer.name', align: 'center' },
{ label: '创建时间', prop: 'created_at', align: 'center' }, { label: '创建时间', prop: 'created_at', align: 'center' },
{ label: '创建人', prop: 'created_by', align: 'center' }, { label: '创建人', prop: 'created_by.username', align: 'center' },
{ label: '操作', slots: 'table-x', align: 'center', width: '300', fixed: 'right' } { label: '操作', slots: 'table-x', align: 'center', width: '300', fixed: 'right' }
] ]
} }
...@@ -55,7 +53,7 @@ export default { ...@@ -55,7 +53,7 @@ export default {
mounted() {}, mounted() {},
methods: { methods: {
success() { success() {
// this.$parent.$parent.getDetail() this.$refs.list.refetch()
}, },
// 删除客户 // 删除客户
onRemove(row) { onRemove(row) {
...@@ -69,10 +67,12 @@ export default { ...@@ -69,10 +67,12 @@ export default {
}, },
// 删除 // 删除
handleRemove(row) { handleRemove(row) {
// deleteGroup({ id: row.id }).then(res => { const arr = []
// this.$message({ type: 'success', message: '删除成功' }) arr.push(row.id)
// this.$parent.$parent.getDetail() delCustomer({ ids: arr }).then(res => {
// }) this.$message({ type: 'success', message: '删除成功' })
this.$refs.list.refetch()
})
} }
} }
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<el-button type="text" @click="onRemove(row)">删除</el-button> <el-button type="text" @click="onRemove(row)">删除</el-button>
</template> </template>
</app-list> </app-list>
<AddEmployees :visible.sync="isShowDialog" @success="success" /> <AddEmployees :visible.sync="isShowDialog" @success="success" :id="id" v-if="isShowDialog" />
</app-card> </app-card>
</template> </template>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import AppCard from '@/components/base/AppCard.vue' import AppCard from '@/components/base/AppCard.vue'
import AddEmployees from '../components/AddEmployees.vue' import AddEmployees from '../components/AddEmployees.vue'
import { employeeDetail } from '../api' import { employeeDetail, delEmployee } from '../api'
export default { export default {
data() { data() {
return { return {
...@@ -44,10 +44,10 @@ export default { ...@@ -44,10 +44,10 @@ export default {
} }
}, },
columns: [ columns: [
{ label: '员工姓名', prop: 'username', align: 'center' }, { label: '员工姓名', prop: 'sso_user.username', align: 'center' },
{ label: '手机号', prop: 'mobile', align: 'center' }, { label: '手机号', prop: 'sso_user.mobile', align: 'center' },
{ label: '创建时间', prop: 'created_at', align: 'center' }, { label: '创建时间', prop: 'created_at', align: 'center' },
{ label: '创建人', prop: 'created_by', align: 'center' }, { label: '创建人', prop: 'created_by.username', align: 'center' },
{ label: '操作', slots: 'table-x', align: 'center', width: '300', fixed: 'right' } { label: '操作', slots: 'table-x', align: 'center', width: '300', fixed: 'right' }
] ]
} }
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
methods: { methods: {
success() { success() {
this.$parent.$parent.getDetail() this.$refs.list.refetch()
}, },
// 删除 // 删除
onRemove(row) { onRemove(row) {
...@@ -70,10 +70,11 @@ export default { ...@@ -70,10 +70,11 @@ export default {
}, },
// 删除 // 删除
handleRemove(row) { handleRemove(row) {
// deleteGroup({ id: row.id }).then(res => { const arr = []
// this.$message({ type: 'success', message: '删除成功' }) arr.push(row.id)
// this.$refs.list.refetch() delEmployee({ ids: arr }).then(res => {
// }) this.$message({ type: 'success', message: '删除成功' })
})
} }
} }
} }
......
...@@ -24,8 +24,7 @@ export default { ...@@ -24,8 +24,7 @@ export default {
components: { components: {
Customer, Customer,
Employees Employees
}, }
methods: {}
} }
</script> </script>
......
...@@ -7,27 +7,31 @@ ...@@ -7,27 +7,31 @@
</el-row> </el-row>
</template> </template>
<template v-slot:table-x="{ row }"> <template v-slot:table-x="{ row }">
<!-- <router-link :to="{ name: 'update', query: { id: row.id } }"> -->
<el-button type="text" style="margin-left: 10px" @click="toDetail(row)">查看</el-button> <el-button type="text" style="margin-left: 10px" @click="toDetail(row)">查看</el-button>
<!-- </router-link> -->
<el-button type="text" style="margin-left: 10px" @click="edit(row)">编辑</el-button> <el-button type="text" style="margin-left: 10px" @click="edit(row)">编辑</el-button>
<el-button type="text" @click="onRemove(row)" style="margin-left: 10px">删除</el-button> <el-button type="text" @click="onRemove(row)" style="margin-left: 10px">删除</el-button>
</template> </template>
</app-list> </app-list>
<!-- 新建客户组弹框 --> <!-- 新建客户组弹框 -->
<AddCustomerGroup :visible.sync="isShowDialog" @success="success" /> <AddCustomerGroup
:visible.sync="isShowDialog"
@success="success"
:data="data"
:isEdit="isEdit"
v-if="isShowDialog"
/>
</app-card> </app-card>
</template> </template>
<script> <script>
// 组件 // 组件
import AddCustomerGroup from '../components/AddCustomerGroup.vue' import AddCustomerGroup from '../components/AddCustomerGroup.vue'
import { getCustomerGroup } from '../api' import { getCustomerGroup, deleteGroup } from '../api'
export default { export default {
components: { AddCustomerGroup }, components: { AddCustomerGroup },
data() { data() {
return { return {
id: '', isEdit: false,
isShowDialog: false isShowDialog: false
} }
}, },
...@@ -47,7 +51,7 @@ export default { ...@@ -47,7 +51,7 @@ export default {
{ label: '客户数量', prop: 'customer_count', align: 'center' }, { label: '客户数量', prop: 'customer_count', align: 'center' },
{ label: '员工数量', prop: 'staff_count', align: 'center' }, { label: '员工数量', prop: 'staff_count', align: 'center' },
{ label: '创建时间', prop: 'created_at', align: 'center' }, { label: '创建时间', prop: 'created_at', align: 'center' },
{ label: '创建人', prop: 'created_by', align: 'center' }, { label: '创建人', prop: 'created_by.username', align: 'center' },
{ label: '操作', slots: 'table-x', align: 'center', width: '300', fixed: 'right' } { label: '操作', slots: 'table-x', align: 'center', width: '300', fixed: 'right' }
] ]
} }
...@@ -62,15 +66,20 @@ export default { ...@@ -62,15 +66,20 @@ export default {
} }
}) })
}, },
// 新建
addGroup() { addGroup() {
this.Edit = false
this.data = {}
this.isShowDialog = true this.isShowDialog = true
}, },
// 编辑
edit(row) { edit(row) {
this.id = row.id this.Edit = true
this.data = row
this.isShowDialog = true this.isShowDialog = true
}, },
// 刷新页面
success() { success() {
//刷新页面
this.$refs.list.refetch() this.$refs.list.refetch()
}, },
// 删除客户组 // 删除客户组
...@@ -85,10 +94,10 @@ export default { ...@@ -85,10 +94,10 @@ export default {
}, },
// 删除 // 删除
handleRemove(row) { handleRemove(row) {
// deleteGroup({ id: row.id }).then(res => { deleteGroup({ id: row.id }).then(res => {
// this.$message({ type: 'success', message: '删除成功' }) this.$message({ type: 'success', message: '删除成功' })
// this.$refs.list.refetch() this.$refs.list.refetch()
// }) })
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论