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

联系人信息

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