Commit 0de37e18 by Lin

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

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