提交 9980a17b authored 作者: matian's avatar matian

update:新增客户组接口联调

上级 ae5c1ca3
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
v-loading="loading" v-loading="loading"
v-bind="$attrs" v-bind="$attrs"
v-on="$listeners" v-on="$listeners"
style="width: 100%;" style="width: 100%"
ref="table" ref="table"
> >
<template v-for="item in columns"> <template v-for="item in columns">
...@@ -140,8 +140,8 @@ export default { ...@@ -140,8 +140,8 @@ export default {
let params = this.params let params = this.params
// 翻页参数设置 // 翻页参数设置
if (this.hasPagination) { if (this.hasPagination) {
params.page = (this.page.currentPage - 1).toString() params.page = this.page.currentPage.toString()
params.page_size = this.page.size.toString() params['per-page'] = this.page.size.toString()
} }
// 接口请求之前 // 接口请求之前
if (beforeRequest) { if (beforeRequest) {
...@@ -155,9 +155,9 @@ export default { ...@@ -155,9 +155,9 @@ export default {
this.loading = true this.loading = true
httpRequest(params) httpRequest(params)
.then(res => { .then(res => {
const { data = [], page_info: pageInfo = {} } = res || {} const { data = {} } = res || {}
this.page.total = parseInt(pageInfo.total_number || '') this.page.total = parseInt(data.total || 0)
this.dataList = callback ? callback(data) : data this.dataList = callback ? callback(data) : data.data
}) })
.catch(() => { .catch(() => {
this.page.total = 0 this.page.total = 0
......
import httpRequest from '@/utils/axios' import httpRequest from '@/utils/axios'
// 新建客户组
export function createCustomerGroup(data) {
return httpRequest.post('/api/customer/admin/v1/group', data)
}
// 获取客户组列表
export function getCustomerGroup(params) {
return httpRequest.get('/api/customer/admin/v1/groups', params)
}
// 编辑客户组
export function editCustomerGroup(id, data) {
return httpRequest.put(`/api/customer/admin/v1/group/${id}`, data)
}
// 删除客户组
export function delCustomerGroup(id, data) {
return httpRequest.delete(`/api/customer/admin/v1/group/${id}`, data)
}
// 客户组详情
export function customerGroupDetail(id, params) {
return httpRequest.get(`/api/customer/admin/v1/group/${id}`, params)
}
// 添加客户
export function createCustomer(group_id, data) {
return httpRequest.post(`/api/customer/admin/v1/${group_id}/customer-to-group`, data)
}
// 删除客户
export function delCustomer(id) {
return httpRequest.delete(`/api/customer/admin/v1/customer/${id}`)
}
// 添加员工
export function createEmployee(group_id, data) {
return httpRequest.post(`/api/customer/admin/v1/${group_id}/staff-to-group`, data)
}
// 删除员工
export function delEmployee(id, data) {
return httpRequest.delete(`/api/customer/admin/v1/contact/${id}`, data)
}
// 搜索员工
export function getEmployee(params) {
return httpRequest.get('/api/customer/admin/v1/system/search-sso-users', { params })
}
...@@ -38,12 +38,19 @@ export default { ...@@ -38,12 +38,19 @@ export default {
{ {
type: 'input', type: 'input',
prop: 'name', prop: 'name',
placeholder: '请输入客户名称' placeholder: '请输入客户名称',
filterable: true,
remote: true
}, },
{ {
type: 'select', type: 'select',
prop: 'create', prop: 'create',
placeholder: '创建员工' placeholder: '创建员工',
labelKey: 'value',
valueKey: 'key',
options: '',
filterable: true,
remote: true
} }
], ],
columns: [ columns: [
......
<template> <template>
<el-dialog v-bind="$attrs" v-on="$listeners" width="30%" top="40vh" :title="title"> <el-dialog v-bind="$attrs" v-on="$listeners" width="30%" top="40vh" 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="customer_group_name"> <el-form-item label="客户组名称" prop="name">
<el-input v-model="form.customer_group_name" /> <el-input v-model="form.name" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" style="margin-left: 20px" @click="submit">提交</el-button> <el-button type="primary" style="margin-left: 20px" @click="submit">提交</el-button>
...@@ -13,46 +13,47 @@ ...@@ -13,46 +13,47 @@
</template> </template>
<script> <script>
import { createCustomerGroup } from '../api'
export default { export default {
data() { data() {
return { return {
form: { form: {
customer_group_name: '' name: ''
}, },
rules: { rules: {
customer_group_name: [ name: [
{ 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' }
] ]
} }
} }
}, },
props: { // props: {
id: { // id: {
type: String, // type: String,
default: '' // default: ''
} // }
}, // },
computed: { // computed: {
title() { // title() {
if (this.id !== '') { // if (this.id !== '') {
return '编辑客户组' // return '编辑客户组'
} else { // } else {
return '新建客户组' // return '新建客户组'
} // }
} // }
}, // },
methods: { methods: {
// 提交 // 提交
submit() { submit() {
this.$refs.form.validate().then(() => { this.$refs.form.validate().then(() => {
if (this.id !== '') { // if (this.id !== '') {
//编辑 // //编辑
this.edit() // this.edit()
} else { // } else {
//新建 //新建
this.create() this.create()
} // }
}) })
}, },
// 编辑/更新客户组 // 编辑/更新客户组
...@@ -66,12 +67,12 @@ export default { ...@@ -66,12 +67,12 @@ export default {
}, },
//新建客户组 //新建客户组
create() { create() {
console.log('111') // console.log('111')
// createGroup(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')
// }) })
} }
} }
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</template> </template>
</app-list> </app-list>
<!-- 新建客户组弹框 --> <!-- 新建客户组弹框 -->
<AddCustomerGroup :visible.sync="isShowDialog" :id="id" @success="success" /> <AddCustomerGroup :visible.sync="isShowDialog" @success="success" />
</app-card> </app-card>
</template> </template>
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,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 AddCustomerGroup from '../components/AddCustomerGroup.vue' import AddCustomerGroup from '../components/AddCustomerGroup.vue'
import { getCustomerGroup } from '../api'
export default { export default {
components: { AppCard, AppList, AddCustomerGroup }, components: { AppCard, AppList, AddCustomerGroup },
data() { data() {
...@@ -36,27 +37,20 @@ export default { ...@@ -36,27 +37,20 @@ export default {
// 列表配置 // 列表配置
tableOptions() { tableOptions() {
return { return {
// remote: { remote: {
// httpRequest: getStudentList, httpRequest: getCustomerGroup,
// params: { params: {
// personal_name: '', id: '',
// telephone: '', name: ''
// id: '', }
// sno: '' },
// }
// },
columns: [ columns: [
{ label: '客户组名称', prop: 'name', align: 'center' }, { label: '客户组名称', prop: 'name', align: 'center' },
{ label: '客户数量', prop: 'customer_num', align: 'center' }, { label: '客户数量', prop: 'customer_count', align: 'center' },
{ label: '员工数量', prop: 'employees_num', 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', align: 'center' },
{ label: '操作', slots: 'table-x', align: 'center', width: '300', fixed: 'right' } { label: '操作', slots: 'table-x', align: 'center', width: '300', fixed: 'right' }
],
data: [
{
group_name: '1213'
}
] ]
} }
} }
...@@ -71,7 +65,7 @@ export default { ...@@ -71,7 +65,7 @@ export default {
}, },
success() { success() {
//刷新页面 //刷新页面
// this.$refs.list.refetch() this.$refs.list.refetch()
}, },
// 删除客户组 // 删除客户组
onRemove(row) { onRemove(row) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论