提交 a4ccd0e4 authored 作者: matian's avatar matian

联系人信息

上级 c5eb0e1b
...@@ -22,9 +22,13 @@ export function deleteCustomer(id) { ...@@ -22,9 +22,13 @@ export function deleteCustomer(id) {
} }
// 新建联系人 // 新建联系人
export function createContact(data) { export function createContact(data) {
return httpRequest.post('/api/customer/admin/v1/{customer_id}/contact', data) return httpRequest.post(`/api/customer/admin/v1/${data.customer_id}/contact`, data)
} }
// 获取联系人 // 获取联系人
export function getContactList(params) { export function getContactList(params) {
return httpRequest.get(`/api/customer/admin/v1/${params.customer_id}/contacts`, params) return httpRequest.get(`/api/customer/admin/v1/${params.customer_id}/contacts`, params)
} }
// 更新联系人
export function UpdateContact(data) {
return httpRequest.put(`/api/customer/admin/v1/contact/${data.id}`, data)
}
<template> <template>
<div class="base-info"> <div class="base-info">
<div class="bar"> <div class="bar">
<el-button type="primary" size="small" @click="add">添加联系人</el-button> <el-button type="primary" size="small" @click="handleAdd">添加联系人</el-button>
</div> </div>
<app-list v-bind="tableOptions" ref="list"> <app-list v-bind="tableOptions" ref="list">
<!-- 操作 --> <!-- 操作 -->
...@@ -11,7 +11,14 @@ ...@@ -11,7 +11,14 @@
<el-button type="text" @click="handleDelete(row)" size="mini">删除</el-button> <el-button type="text" @click="handleDelete(row)" size="mini">删除</el-button>
</template> </template>
</template> </template>
<CreateContact :visible.sync="isShowDialog" :isEdit="isEdit" :data="data" /> <CreateContact
:visible.sync="isShowDialog"
@success="success"
:row="row"
:isEdit="isEdit"
v-if="isShowDialog"
:id="id"
/>
</app-list> </app-list>
</div> </div>
</template> </template>
...@@ -24,7 +31,6 @@ export default { ...@@ -24,7 +31,6 @@ export default {
components: { AppList, CreateContact }, components: { AppList, CreateContact },
data() { data() {
return { return {
data: {},
isEdit: false, isEdit: false,
isShowDialog: false isShowDialog: false
} }
...@@ -57,7 +63,7 @@ export default { ...@@ -57,7 +63,7 @@ export default {
{ prop: 'wechat', label: '微信号', minWidth: '140px' }, { prop: 'wechat', label: '微信号', minWidth: '140px' },
{ prop: 'sub_mobile', label: '附属手机号', minWidth: '140px' }, { prop: 'sub_mobile', label: '附属手机号', minWidth: '140px' },
{ prop: 'qq', label: 'QQ号', minWidth: '140px' }, { prop: 'qq', label: 'QQ号', minWidth: '140px' },
{ prop: 'created_by', label: '创建员工', minWidth: '140px' }, { prop: 'created_by.username', label: '创建员工', minWidth: '140px' },
{ prop: 'created_at', label: '创建时间', minWidth: '140px' }, { prop: 'created_at', label: '创建时间', minWidth: '140px' },
{ label: '操作', minWidth: '140px', slots: 'table-operate' } { label: '操作', minWidth: '140px', slots: 'table-operate' }
] ]
...@@ -66,15 +72,18 @@ export default { ...@@ -66,15 +72,18 @@ export default {
}, },
methods: { methods: {
success() {
this.$refs.list.refetch()
},
handleEdit(row) { handleEdit(row) {
this.Edit = false this.Edit = false
this.data = row this.row = row
this.isShowDialog = true this.isShowDialog = true
}, },
add() { handleAdd() {
this.Edit = true this.Edit = true
this.data = {} this.row = {}
this.isShowDialog = true this.isShowDialog = true
}, },
handleDelete() {} handleDelete() {}
......
<template> <template>
<el-dialog v-bind="$attrs" v-on="$listeners" top="40vh" :title="title"> <el-dialog v-bind="$attrs" v-on="$listeners" top="20vh" :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" />
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
</template> </template>
<script> <script>
import { createContact } from '../api' import { createContact, UpdateContact } from '../api'
export default { export default {
data() { data() {
return { return {
...@@ -55,13 +55,22 @@ export default { ...@@ -55,13 +55,22 @@ export default {
} }
}, },
props: { props: {
data: { row: {
type: Object, type: Object,
default: () => ({}) default: () => {}
}, },
isEdit: { id: {
type: Boolean, type: String,
default: false default: ''
},
isEdit: { type: Boolean, default: false }
},
watch: {
row: {
immediate: true,
handler(row) {
this.form = Object.assign({}, this.form, row)
}
} }
}, },
computed: { computed: {
...@@ -76,16 +85,16 @@ export default { ...@@ -76,16 +85,16 @@ export default {
this.isEdit ? this.edit() : this.create() this.isEdit ? this.edit() : this.create()
}) })
}, },
edit() { edit(row) {
const params = Object.assign({ group_id: this.id }, this.form) const params = Object.assign({ id: row.id }, this.form)
createContact(params).then(res => { UpdateContact(params).then(res => {
this.$message.success('新建联系人成功') this.$message.success('新建联系人成功')
this.$emit('update:visible', false) this.$emit('update:visible', false)
this.$emit('success', res.data) this.$emit('success', res.data)
}) })
}, },
create() { create() {
const params = Object.assign({ group_id: this.id }, this.form) const params = Object.assign({ customer_id: this.id }, this.form)
createContact(params).then(res => { createContact(params).then(res => {
this.$message.success('新建联系人成功') this.$message.success('新建联系人成功')
this.$emit('update:visible', false) this.$emit('update:visible', false)
......
...@@ -31,6 +31,7 @@ export default { ...@@ -31,6 +31,7 @@ export default {
components: { AddCustomerGroup }, components: { AddCustomerGroup },
data() { data() {
return { return {
data: {},
isEdit: false, isEdit: false,
isShowDialog: false isShowDialog: false
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论