Commit 3a3e7a3b by Lin

feat(AddFiles, DetailFiles): 更新日期选择逻辑与默认日期处理

- 将日期选择器的起始和结束日期逻辑重构为动态方法,以支持不同场景下的日期限制。
- 为到店日期和创建日期字段添加默认值处理,确保在缺失时自动填充当前日期。
- 移除不再使用的接待场景组件,简化代码结构。
1 parent fc572a67
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
<picker <picker
mode="date" mode="date"
fields="day" fields="day"
:start="startDate" :start="getDatePickerStart(i)"
:end="endDate" :end="getDatePickerEnd(i)"
@change="bindDateChange($event, i.valueKey)" @change="bindDateChange($event, i.valueKey)"
:value="customerInfo[i.valueKey]" :value="customerInfo[i.valueKey]"
> >
...@@ -81,8 +81,8 @@ ...@@ -81,8 +81,8 @@
<picker <picker
mode="date" mode="date"
fields="day" fields="day"
:start="startDate" :start="getDatePickerStart(i)"
:end="endDate" :end="getDatePickerEnd(i)"
@change="bindDateChange($event, i.valueKey)" @change="bindDateChange($event, i.valueKey)"
:value="customerInfo[i.valueKey]" :value="customerInfo[i.valueKey]"
> >
...@@ -123,11 +123,6 @@ ...@@ -123,11 +123,6 @@
carModelKey="carTypeName" carModelKey="carTypeName"
customBoolean customBoolean
/> />
<reception-sence
ref="receptionSceneVisible"
@select="handleSelect($event, 'receptionSceneVisible')"
:customerInfo="customerInfo"
></reception-sence>
<employee <employee
ref="trafficSourceVisible" ref="trafficSourceVisible"
title="流量来源" title="流量来源"
...@@ -155,7 +150,6 @@ ...@@ -155,7 +150,6 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import CarBrands from '@/components/CarBrands.vue' import CarBrands from '@/components/CarBrands.vue'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import ReceptionSence from '@/components/HomeFrame/components/ReceptionCenter/ReceptionSence.vue'
import Employee from '@/components/Employee.vue' import Employee from '@/components/Employee.vue'
import { validateVin, formatVinInput } from '@/utils/vinVaildate' import { validateVin, formatVinInput } from '@/utils/vinVaildate'
const phoneRex = /^[1]([3-9])[0-9]{9}$/, const phoneRex = /^[1]([3-9])[0-9]{9}$/,
...@@ -191,7 +185,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -191,7 +185,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
valueKey: 'arrivalDate', valueKey: 'arrivalDate',
key: 'arrivalDate', key: 'arrivalDate',
required: true, required: true,
type: 'date' type: 'date',
dateUnlimited: true
}, },
{ {
label: '流量来源', label: '流量来源',
...@@ -202,14 +197,6 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -202,14 +197,6 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
popKey: 'trafficSourceVisible', popKey: 'trafficSourceVisible',
merchantNameKey: 'merchantName' merchantNameKey: 'merchantName'
} }
// {
// label: '接待场景',
// valueKey: 'receptionSceneName',
// key: 'receptionScene',
// type: 'select',
// required: true,
// popKey: 'receptionSceneVisible'
// }
], ],
default_optionalForm = [{ default_optionalForm = [{
label: '车架号', label: '车架号',
...@@ -223,7 +210,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -223,7 +210,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
label: '到店日期', label: '到店日期',
valueKey: 'inviteDate', valueKey: 'inviteDate',
key: 'inviteDate', key: 'inviteDate',
type: 'date' type: 'date',
dateFromToday: true
}, },
{ {
label: '建档日期', label: '建档日期',
...@@ -240,7 +228,7 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -240,7 +228,7 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
}] }]
export default { export default {
name: 'AddFiles', name: 'AddFiles',
components: { CarBrands, ReceptionSence, Employee }, components: { CarBrands, Employee },
computed: { computed: {
check () { check () {
let { customerForm, customerInfo } = this, let { customerForm, customerInfo } = this,
...@@ -293,9 +281,7 @@ export default { ...@@ -293,9 +281,7 @@ export default {
carTypeName: '', carTypeName: '',
carChildsBrandId: '', carChildsBrandId: '',
carChildsBrandName: '', carChildsBrandName: '',
receptionScene: '',
arrivalDate: '', arrivalDate: '',
receptionSceneName: '',
standNo: '', standNo: '',
employeeName: '', employeeName: '',
userId: '', userId: '',
...@@ -303,7 +289,7 @@ export default { ...@@ -303,7 +289,7 @@ export default {
sellerName: '', sellerName: '',
sellerUserId: '', sellerUserId: '',
inviteDate: '', inviteDate: '',
filingDate: '' filingDate: dayjs().format('YYYY-MM-DD')
} }
this.inviteDateTouched = false this.inviteDateTouched = false
if (this.customerId) this.findVisitsInfo() if (this.customerId) this.findVisitsInfo()
...@@ -316,6 +302,9 @@ export default { ...@@ -316,6 +302,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.filingDate) {
this.customerInfo.filingDate = dayjs().format('YYYY-MM-DD')
}
this.inviteDateTouched = !!res.inviteDate this.inviteDateTouched = !!res.inviteDate
}, },
backPage () { backPage () {
...@@ -358,15 +347,20 @@ export default { ...@@ -358,15 +347,20 @@ export default {
this.customerInfo[field.valueKey] = item.staffName this.customerInfo[field.valueKey] = item.staffName
this.customerInfo[field.key] = item.uuid this.customerInfo[field.key] = item.uuid
} }
} else {
this.customerInfo.receptionSceneName = item.receptionSceneName
this.customerInfo.receptionScene = item.id
} }
}, },
getDatePickerStart (field) {
if (field.dateUnlimited) return '1970-01-01'
if (field.dateFromToday) return dayjs().format('YYYY-MM-DD')
return this.startDate
},
getDatePickerEnd (field) {
return field.dateUnlimited ? '2099-12-31' : this.endDate
},
bindDateChange (e, valueKey) { bindDateChange (e, valueKey) {
const value = e.detail.value const value = e.detail.value
this.customerInfo[valueKey] = value this.customerInfo[valueKey] = value
if (valueKey === 'arrivalDate' && !this.inviteDateTouched) { if (valueKey === 'arrivalDate' && !this.customerInfo.inviteDate) {
this.customerInfo.inviteDate = value this.customerInfo.inviteDate = value
} }
if (valueKey === 'inviteDate') { if (valueKey === 'inviteDate') {
......
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
<picker <picker
mode="date" mode="date"
fields="day" fields="day"
:start="startDate" :start="getDatePickerStart(i)"
:end="endDate" :end="getDatePickerEnd(i)"
@change="bindDateChange($event, i.valueKey)" @change="bindDateChange($event, i.valueKey)"
:value="customerInfo[i.valueKey]" :value="customerInfo[i.valueKey]"
> >
...@@ -111,8 +111,8 @@ ...@@ -111,8 +111,8 @@
<picker <picker
mode="date" mode="date"
fields="day" fields="day"
:start="startDate" :start="getDatePickerStart(i)"
:end="endDate" :end="getDatePickerEnd(i)"
@change="bindDateChange($event, i.valueKey)" @change="bindDateChange($event, i.valueKey)"
:value="customerInfo[i.valueKey]" :value="customerInfo[i.valueKey]"
> >
...@@ -263,7 +263,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -263,7 +263,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
valueKey: 'deliveryDate', valueKey: 'deliveryDate',
key: 'deliveryDate', key: 'deliveryDate',
required: true, required: true,
type: 'date' type: 'date',
dateUnlimited: true
}, },
// { // {
// label: '接待场景', // label: '接待场景',
...@@ -293,7 +294,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/, ...@@ -293,7 +294,8 @@ const phoneRex = /^[1]([3-9])[0-9]{9}$/,
label: '到店日期', label: '到店日期',
valueKey: 'inviteDate', valueKey: 'inviteDate',
key: 'inviteDate', key: 'inviteDate',
type: 'date' type: 'date',
dateFromToday: true
}, },
{ {
label: '驻店零售', label: '驻店零售',
...@@ -672,7 +674,7 @@ export default { ...@@ -672,7 +674,7 @@ export default {
receptionSceneName: '', receptionSceneName: '',
standNo: '', standNo: '',
inviteDate: '', inviteDate: '',
createdDate: '', createdDate: dayjs().format('YYYY-MM-DD'),
employeeName: '', employeeName: '',
userId: '', userId: '',
merchantName: '', merchantName: '',
...@@ -694,6 +696,9 @@ export default { ...@@ -694,6 +696,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.createdDate) {
this.customerInfo.createdDate = dayjs().format('YYYY-MM-DD')
}
if (!this.customerInfo.contact_id && res.wxId) { if (!this.customerInfo.contact_id && res.wxId) {
this.customerInfo.contact_id = res.wxId this.customerInfo.contact_id = res.wxId
} }
...@@ -758,6 +763,14 @@ export default { ...@@ -758,6 +763,14 @@ export default {
this.customerInfo.receptionScene = item.id this.customerInfo.receptionScene = item.id
} }
}, },
getDatePickerStart (field) {
if (field.dateUnlimited) return '1970-01-01'
if (field.dateFromToday) return dayjs().format('YYYY-MM-DD')
return this.startDate
},
getDatePickerEnd (field) {
return field.dateUnlimited ? '2099-12-31' : this.endDate
},
bindDateChange (e, valueKey) { bindDateChange (e, valueKey) {
this.customerInfo[valueKey] = e.detail.value this.customerInfo[valueKey] = e.detail.value
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!