Commit 3a3e7a3b by Lin

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

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