You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
9.0 KiB

3 years ago
<template>
<div>
<!--查询-->
<div>
<div ref="lxHeader">
<lx-header icon="md-apps" style="margin-bottom: 10px; border: 0px; margin-top: 15px" text="客户列表">
<div slot="content"></div>
<slot>
<div>
<Input placeholder="关键字搜索" style="width: 200px; margin-right: 10px"/>
3 years ago
<Button style="margin-left: 10px" type="primary" @click="select.page = 1,getCustomers()">查询</Button>
3 years ago
<Button style="margin-left: 10px" type="primary"
@click="$refs['addCustomer'].type = 'add',$refs['addCustomer'].isShow = true">录入客户
</Button>
</div>
</slot>
</lx-header>
</div>
</div>
3 years ago
<xy-table
ref="table"
:total="total"
:list="list"
:table-item="tableItem"
3 years ago
:default-expand-all="false"
3 years ago
@pageSizeChange="e => select.page_size = e"
3 years ago
@pageIndexChange="e => {select.page = e;getCustomers()}">
<template v-slot:btns>
<el-table-column fixed="right" width="166" header-align="center" align="center" label="操作">
<template v-slot:default="scope">
<Poptip
transfer
confirm
title="确认要删除?"
@on-ok="destroy(scope.row)">
<Button size="small" type="error" ghost style="margin-right: 6px">删除</Button>
</Poptip>
<Button size="small" ghost type="primary" @click="editor(scope.row)" style="margin-right: 6px">编辑</Button>
3 years ago
<Button size="small" type="primary" @click="$refs['addOrder'].isShow = true,$refs['addOrder'].form.customer_id = scope.row.id">录入</Button>
3 years ago
</template>
</el-table-column>
</template>
3 years ago
</xy-table>
3 years ago
<addOrder ref="addOrder" :types="types" :accounts="accounts"></addOrder>
<add-customer ref="addCustomer" :types="types" :accounts="accounts" :cities="cities" :disability-level="disabilityLevel" @refresh="getCustomers"></add-customer>
3 years ago
</div>
</template>
<script>
3 years ago
import {getList,destroy} from '@/api/customer'
3 years ago
import {getparameter} from '@/api/system/dictionary'
3 years ago
import {getList as getUnit} from "@/api/payUnit";
3 years ago
import {getList as getTypes} from '@/api/productType'
3 years ago
3 years ago
import addCustomer from "@/views/customer/component/addCustomer";
import addOrder from './component/addOrder'
3 years ago
export default {
components: {
3 years ago
addCustomer,
addOrder
3 years ago
},
data() {
return {
select: {
page: 1,
page_size: 10,
keyword: ''
},
disabilityLevel: [],
3 years ago
cities:[],
3 years ago
accounts:[],
3 years ago
types:[],
3 years ago
total: 0,
list: [],
tableItem: [
3 years ago
{
type:'expand',
expandFn:(props) => {
return (
<Table style={{'margin':'0 166px 0 40px'}}
width={1370}
stripe={true}
border={true}
size="small"
columns={
[
{
title:'订单编号',
key:'no',
width:220,
align:'center'
},
{
title:'订单产品',
width: 200,
align:'center',
render:(h,params)=>{
return h('div',params.row.product.name)
}
},
{
title:'时间',
width: 270,
align:'center',
render:(h,params)=>{
return h('div',[
h('span',params.row.start_date),
h('span',' ~ '),
h('span',params.row.end_date)
])
}
},
{
title:'单次价格',
width: 180,
align:'right',
key:'unit_price'
},
{
title:'总计时长',
width: 160,
align: 'center',
key:'total_time'
},
{
title:'总计金额',
width: 190,
align:'right',
key:'total_money'
},
{
title:'执行状态',
align:'center',
render:(h,params)=>{
let statusName = new Map([
[0,'未开始'],
[1,'进行中'],
[2,'已完成'],
])
let statusColor = new Map([
[0,'blue'],
[1,'red'],
[2,'green'],
])
return h('div',{
style:{
color:statusColor.get(params.row.status)
}
},statusName.get(params.row.status))
}
}
]
}
data={props?.row.orders}>
</Table>
)
}
},
3 years ago
{
width: 40,
type:'index',
fixed:'left'
},
3 years ago
{
3 years ago
prop: "name",
label: "姓名",
3 years ago
width: "180",
3 years ago
},
3 years ago
{
label:'订单产品',
width: 220,
align:'left',
customFn:(row) => {
return (
<div>
{
row.orders.map(item => {
return item.product.name
}).toString()
}
</div>
)
}
},
3 years ago
{
3 years ago
prop: "idcard",
label: "身份证号",
width: "220"
3 years ago
},
{
3 years ago
prop: "phone",
label: "手机号",
width: "160"
3 years ago
},
{
3 years ago
label: "委托人",
width: "180",
prop:'contact_name'
3 years ago
},
{
3 years ago
label: "委托人电话",
width: "160",
prop:'contact_phone'
},
{
prop:'idcard_address',
label:'户籍地址',
width: 140
},
{
label:'默认上门地址',
3 years ago
minWidth:300,
align:'left',
customFn:(row)=>{
return (
<div>
{
row.customer_address.filter(item => {
return item.default === 1
})[0]?.address || row.customer_address[0]?.address || '无'
}
</div>
)
}
3 years ago
},
{
3 years ago
label:'上门地址数',
prop:'customer_address_count',
width: 140
3 years ago
}
]
}
},
methods: {
async getDisabilityLevel() {
3 years ago
const res = await getparameter({number: 'disabilityLevel'},false)
3 years ago
this.disabilityLevel = res.detail
},
async getCustomers() {
3 years ago
const res = await getList(this.select,false)
3 years ago
this.list = res.data.data
this.total = res.data.total
},
3 years ago
async getAccounts(){
3 years ago
const res = await getUnit({page:1,page_size:9999},false)
3 years ago
this.accounts = res.data
},
3 years ago
async getTypes(){
const res = await getTypes({page:1,page_size:9999},false)
this.types = res.data
},
3 years ago
async getCity(){
let city = await getparameter({number: 'city'},false)
for(let i = 0;i < city.detail.length;i ++){
let area = await getparameter({number : city.detail[i].remark},false)
city.detail[i].children = area.detail
for(let j = 0;j < area.detail.length;j++){
let street = await getparameter({number : area.detail[j].remark},false)
area.detail[j].children = street.detail
}
}
this.cities = city.detail
},
3 years ago
editor(row){
this.$refs['addCustomer'].id = row.id
this.$refs['addCustomer'].type = 'editor'
this.$refs['addCustomer'].isShow = true
3 years ago
},
destroy(row){
destroy(row.id).then(res => {
this.$successMessage('destroy','客户')
this.getCustomers()
})
3 years ago
}
},
mounted() {
this.getDisabilityLevel()
this.getCustomers()
3 years ago
this.getCity()
3 years ago
this.getAccounts()
3 years ago
this.getTypes()
3 years ago
}
}
</script>
<style lang="scss" scoped>
3 years ago
::v-deep .ivu-table-header thead tr th{
text-align: center !important;
}
3 years ago
</style>