Commit 0de37e18 by Lin

feature(customerPages): 添加性别选择功能

- 在 addFiles.vue 和 detailFiles.vue 中新增性别选择的单选框组件。
- 更新 customerInfo 对象以包含性别字段,并设置默认值为 '1'(男)。
- 实现 radioChange 方法以处理性别选择的变化。
1 parent 1c494ddb
...@@ -50,6 +50,14 @@ ...@@ -50,6 +50,14 @@
</view> </view>
</picker> </picker>
</template> </template>
<template v-else-if="i.type == 'radio'">
<radio-group class="radio-group flex" @change="radioChange($event, i)">
<label class="radio-item flex" v-for="item in i.radioList" :key="item.value">
<radio style="transform: scale(0.7)" :value="item.value" :checked="customerInfo[i.key] == item.value" />
<view class="radio-name">{{ item.name }}</view>
</label>
</radio-group>
</template>
<template v-else> <template v-else>
<view <view
:class="['select flex', { placeholderStyle: !customerInfo[i.valueKey] }]" :class="['select flex', { placeholderStyle: !customerInfo[i.valueKey] }]"
...@@ -104,6 +112,14 @@ ...@@ -104,6 +112,14 @@
</view> </view>
</picker> </picker>
</template> </template>
<template v-else-if="i.type == 'radio'">
<radio-group class="radio-group flex" @change="radioChange($event, i)">
<label class="radio-item flex" v-for="item in i.radioList" :key="item.value">
<radio style="transform: scale(0.7)" :value="item.value" :checked="customerInfo[i.key] == item.value" />
<view class="radio-name">{{ item.name }}</view>
</label>
</radio-group>
</template>
<template v-else> <template v-else>
<view <view
:class="['select flex', { placeholderStyle: !customerInfo[i.valueKey] }]" :class="['select flex', { placeholderStyle: !customerInfo[i.valueKey] }]"
...@@ -207,6 +223,17 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -207,6 +223,17 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
} }
], ],
default_optionalForm = [{ default_optionalForm = [{
label: '性别',
valueKey: 'customerSex',
key: 'customerSex',
type: 'radio',
current: '1',
radioList: [
{ value: '1', name: '男' },
{ value: '2', name: '女' }
]
},
{
label: '车架号', label: '车架号',
valueKey: 'standNo', valueKey: 'standNo',
key: 'standNo', key: 'standNo',
...@@ -288,6 +315,7 @@ export default { ...@@ -288,6 +315,7 @@ export default {
this.customerInfo = { this.customerInfo = {
customerName: '', customerName: '',
customerPhone: '', customerPhone: '',
customerSex: '1',
carTypeName: '', carTypeName: '',
carChildsBrandId: '', carChildsBrandId: '',
carChildsBrandName: '', carChildsBrandName: '',
...@@ -312,6 +340,9 @@ export default { ...@@ -312,6 +340,9 @@ export default {
if (res.inviteDate) res.inviteDate = dayjs(res.inviteDate).format("YYYY-MM-DD") if (res.inviteDate) res.inviteDate = dayjs(res.inviteDate).format("YYYY-MM-DD")
if (res.filingDate) res.filingDate = dayjs(res.filingDate).format("YYYY-MM-DD") if (res.filingDate) res.filingDate = dayjs(res.filingDate).format("YYYY-MM-DD")
this.customerInfo = res this.customerInfo = res
if (!this.customerInfo.customerSex) {
this.customerInfo.customerSex = '1'
}
if (!this.customerInfo.filingDate) { if (!this.customerInfo.filingDate) {
this.customerInfo.filingDate = dayjs().format('YYYY-MM-DD') this.customerInfo.filingDate = dayjs().format('YYYY-MM-DD')
} }
...@@ -367,6 +398,9 @@ export default { ...@@ -367,6 +398,9 @@ export default {
getDatePickerEnd (field) { getDatePickerEnd (field) {
return field.dateUnlimited ? '2099-12-31' : this.endDate return field.dateUnlimited ? '2099-12-31' : this.endDate
}, },
radioChange (e, field) {
this.customerInfo[field.key] = e.detail.value
},
bindDateChange (e, valueKey) { bindDateChange (e, valueKey) {
const value = e.detail.value const value = e.detail.value
this.customerInfo[valueKey] = value this.customerInfo[valueKey] = value
...@@ -503,6 +537,7 @@ export default { ...@@ -503,6 +537,7 @@ export default {
baseSceneCode:'100101', baseSceneCode:'100101',
customerName:params.customerName, customerName:params.customerName,
customerPhone:params.customerPhone, customerPhone:params.customerPhone,
customerSex: params.customerSex,
carBrand:params.carBrand, carBrand:params.carBrand,
carBrandId:params.carBrandId, carBrandId:params.carBrandId,
carChildsBrandId: params.carTypeId, carChildsBrandId: params.carTypeId,
...@@ -707,6 +742,19 @@ export default { ...@@ -707,6 +742,19 @@ export default {
.error { .error {
border: toRpx(2) solid #f24724 !important; border: toRpx(2) solid #f24724 !important;
} }
.radio-group {
width: toRpx(738);
height: toRpx(76);
align-items: center;
gap: toRpx(48);
}
.radio-item {
align-items: center;
}
.radio-name {
color: #333333;
font-size: toRpx(28);
}
} }
.btns { .btns {
justify-content: center; justify-content: center;
......
...@@ -77,6 +77,14 @@ ...@@ -77,6 +77,14 @@
</view> </view>
</picker> </picker>
</template> </template>
<template v-else-if="i.type == 'radio'">
<radio-group class="radio-group flex" @change="radioChange($event, i)">
<label class="radio-item flex" v-for="item in i.radioList" :key="item.value">
<radio style="transform: scale(0.7)" :value="item.value" :checked="customerInfo[i.key] == item.value" />
<view class="radio-name">{{ item.name }}</view>
</label>
</radio-group>
</template>
<template v-else> <template v-else>
<view <view
:class="['select flex', { placeholderStyle: !customerInfo[i.valueKey] }]" :class="['select flex', { placeholderStyle: !customerInfo[i.valueKey] }]"
...@@ -126,6 +134,14 @@ ...@@ -126,6 +134,14 @@
</view> </view>
</picker> </picker>
</template> </template>
<template v-else-if="i.type == 'radio'">
<radio-group class="radio-group flex" @change="radioChange($event, i)">
<label class="radio-item flex" v-for="item in i.radioList" :key="item.value">
<radio style="transform: scale(0.7)" :value="item.value" :checked="customerInfo[i.key] == item.value" />
<view class="radio-name">{{ item.name }}</view>
</label>
</radio-group>
</template>
<template v-else> <template v-else>
<view <view
:class="['select flex', { placeholderStyle: !customerInfo[i.valueKey] }]" :class="['select flex', { placeholderStyle: !customerInfo[i.valueKey] }]"
...@@ -282,8 +298,19 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -282,8 +298,19 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
type: 'readonly', type: 'readonly',
required: true, required: true,
merchantNameKey: 'merchantName' merchantNameKey: 'merchantName'
},{
label: '性别',
valueKey: 'customerSex',
key: 'customerSex',
type: 'radio',
current: '1',
radioList: [
{ value: '1', name: '男' },
{ value: '2', name: '女' }
]
}], }],
default_optionalForm = [{ default_optionalForm = [
{
label: '车架号', label: '车架号',
valueKey: 'standNo', valueKey: 'standNo',
key: 'standNo', key: 'standNo',
...@@ -512,6 +539,7 @@ export default { ...@@ -512,6 +539,7 @@ export default {
const requestParams = { const requestParams = {
id: this.customerInfo.id, id: this.customerInfo.id,
customerName: this.customerInfo.customerName, customerName: this.customerInfo.customerName,
customerSex: this.customerInfo.customerSex,
carBrand: this.customerInfo.carBrand, carBrand: this.customerInfo.carBrand,
carBrandId: this.customerInfo.carBrandId, carBrandId: this.customerInfo.carBrandId,
carChildsBrandName: this.customerInfo.carChildsBrandName, carChildsBrandName: this.customerInfo.carChildsBrandName,
...@@ -676,6 +704,7 @@ export default { ...@@ -676,6 +704,7 @@ export default {
this.customerInfo = { this.customerInfo = {
customerName: '', customerName: '',
customerPhone: '', customerPhone: '',
customerSex: '1',
carBrand: '', carBrand: '',
carBrandId: '', carBrandId: '',
carSeriesName: '', carSeriesName: '',
...@@ -709,6 +738,9 @@ export default { ...@@ -709,6 +738,9 @@ export default {
if (res.inviteDate) res.inviteDate = dayjs(res.inviteDate).format("YYYY-MM-DD") if (res.inviteDate) res.inviteDate = dayjs(res.inviteDate).format("YYYY-MM-DD")
// 合并而非整对象替换,保留 initForm 中已声明的响应式字段(如 contact_name) // 合并而非整对象替换,保留 initForm 中已声明的响应式字段(如 contact_name)
Object.assign(this.customerInfo, res) Object.assign(this.customerInfo, res)
if (!this.customerInfo.customerSex) {
this.customerInfo.customerSex = '1'
}
if (!this.customerInfo.createdDate) { if (!this.customerInfo.createdDate) {
this.customerInfo.createdDate = dayjs().format('YYYY-MM-DD') this.customerInfo.createdDate = dayjs().format('YYYY-MM-DD')
} }
...@@ -855,6 +887,9 @@ export default { ...@@ -855,6 +887,9 @@ export default {
this.syncInviteDateFromDelivery() this.syncInviteDateFromDelivery()
} }
}, },
radioChange (e, field) {
this.customerInfo[field.key] = e.detail.value
},
inputBlur (e, val) { inputBlur (e, val) {
const standNoVal = this.customerInfo.standNo const standNoVal = this.customerInfo.standNo
if (val.key === 'standNo' && standNoVal) { if (val.key === 'standNo' && standNoVal) {
...@@ -1180,6 +1215,19 @@ export default { ...@@ -1180,6 +1215,19 @@ export default {
.error { .error {
border: toRpx(2) solid #f24724 !important; border: toRpx(2) solid #f24724 !important;
} }
.radio-group {
width: toRpx(738);
height: toRpx(76);
align-items: center;
gap: toRpx(48);
}
.radio-item {
align-items: center;
}
.radio-name {
color: #333333;
font-size: toRpx(28);
}
.input--readonly { .input--readonly {
color: #666666; color: #666666;
background: #f5f7fa; background: #f5f7fa;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!