feat: 修复错误以及添加 Customer 组件

This commit is contained in:
hz
2025-10-31 16:05:37 +08:00
parent 40a983cfc3
commit c16e0f0f3f
3 changed files with 122 additions and 5 deletions

View File

@@ -40,7 +40,7 @@
v-model="userInfo.name"
@blur="nameChange"
@on-click="selectClick('1')"
></customer-picker>
/>
<van-field
:value="userInfo.idType | idToText('insuredIdType')"
v-validate="'required'"

View File

@@ -0,0 +1,113 @@
<template>
<div class="customer">
<van-index-bar>
<div v-if="data.length > 0">
<div class=" bg-white mt10 " v-for="customerInfo in data" :key="customerInfo.letter">
<van-index-anchor :index="customerInfo.letter" />
<div v-for="customer in customerInfo.data" :key="customer.name" class="flex ml15 mt10 pb10 content border-b align-items-c" @click="choose(customer)">
<img class="w40 mr15 " :src="require('@/assets/images/bnf_avatar.png')" />
<div class="c-gray-darker fs14">
<div>{{ customer.customerName }}</div>
<div class="mt5">{{ customer.customerPhone }}</div>
</div>
<div class="text-right" style="flex:1">
<van-tag :color="customer.customerType == 0 ? '#7ED321' : customer.customerType == 1 ? '#5CA7DE' : '#333'" class="mr40" plain>{{
customer.typeName
}}</van-tag>
</div>
</div>
</div>
</div>
<div v-else class="text-center">
<img class="mt40 w200" :src="require('@/assets/images/pic_page-non.png')" alt=""/>
<p class="mt15">暂无客户</p>
</div>
</van-index-bar>
</div>
</template>
<script>
import { getCustomersList, getAgentCustomerInfo } from '@/api/ebiz/customer/customer'
import dataDictionary from '@/assets/js/utils/data-dictionary' //根据数据字典找到用户等级
import utils from '@/assets/js/business-common'
import { IndexBar, IndexAnchor, Tag, Icon } from 'vant'
export default {
name: 'Customer',
data() {
return {
data: [],
isSuccess: false,
type: ['success', 'primary', 'danger', '']
}
},
created() {
this.getList()
},
components: {
[IndexBar.name]: IndexBar,
[IndexAnchor.name]: IndexAnchor,
[Tag.name]: Tag,
[Icon.name]: Icon
},
mounted() {},
methods: {
choose(data) {
let params = {
customerNumber: data.customerNumber
}
getAgentCustomerInfo(params).then(res => {
console.log(res, '详情')
if (res.result == '0') {
this.isSuccess = true
let content = res.content
if (content.birthday) {
content.age = utils.jsGetAge(content.birthday)
}
this.$emit('on-choose', content)
}
})
},
getList() {
getCustomersList({}).then(res => {
console.log(res)
if (res.result == '0') {
let customerList = []
//根据数据字典中的客户等级 展示
for (var key in res.agentCustomerList) {
res.agentCustomerList[key].forEach(current => {
dataDictionary.customerType.forEach(type => {
if (current.customerType == type.id) {
current.typeName = type.text
}
})
})
let current = {
data: res.agentCustomerList[key],
letter: key
}
customerList.push(current)
}
this.data = customerList
}
})
}
}
}
</script>
<style lang="scss">
.customer {
.van-index-anchor {
padding-top: 2px;
padding-bottom: 2px;
border-bottom: 1px solid #d6d6d6;
}
.border-b {
border-bottom: 1px solid #d6d6d6;
}
.content:last-child {
border: none;
}
}
</style>

View File

@@ -11,14 +11,15 @@
:readonly="readonly"
@blur="handleFieldBlur"
/>
<van-popup v-model="parentShowPicker" position="bottom">
<van-popup v-model="showPicker" position="bottom" style="max-height: 95%">
<customer @on-choose="choose" :code="code" :name="name" :life="life" :health="health"></customer>
</van-popup>
</div>
</template>
<script>
import { Field, Popup, Icon, Sticky } from 'vant'
import Customer from '@/components//ebiz/claims/Customer.vue'
import Customer from './Customer.vue'
import TitleBar from '@/views/ebiz/productFlowImprove/components/TitleBar.vue'
export default {
name: 'CustomerPicker',
@@ -86,6 +87,7 @@ export default {
}
},
components: {
TitleBar,
[Field.name]: Field,
[Popup.name]: Popup,
[Customer.name]: Customer,
@@ -117,6 +119,7 @@ export default {
},
choose(data) {
this.name = data.customerName
this.$emit("update:parentShowPicker", false)
this.$emit('on-choose', data)
},
chooseCustomer() {
@@ -131,8 +134,9 @@ export default {
this.$emit('cancel', '')
},
handleFieldBlur() {
this.$emit("update:value", this.name)
this.$emit('blur', this.name)
console.log(this.name)
// this.$emit("update:value", this.name)
// this.$emit('blur', this.name)
}
}
}