feat(web-admin): add createDate and default pickup/delivery on plan forms
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
349e031790
commit
a276f09350
3 files changed
+52
-8
No files matched your search
@@ -52,6 +52,15 @@
|
||||
<h3 class="pl-plan-form-section-title">基础信息</h3>
|
||||
<el-form ref="basicFormRef" :model="formData" :rules="basicRules" label-position="right" label-width="100px" class="pl-dialog-form">
|
||||
<div class="form-grid-4">
|
||||
<el-form-item label="创建日期" prop="createDate">
|
||||
<el-date-picker
|
||||
v-model="formData.createDate"
|
||||
type="date"
|
||||
placeholder="选择日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="计划日期" prop="planDate">
|
||||
<el-date-picker
|
||||
v-model="formData.planDate"
|
||||
@@ -326,6 +335,10 @@ function resolveCurrentUserName() {
|
||||
return info.realName || info.userName || info.username || info.nickName || ''
|
||||
}
|
||||
|
||||
function todayYmd(): string {
|
||||
return new Date().toISOString().split('T')[0]
|
||||
}
|
||||
|
||||
const isEdit = computed(() => !!props.planId)
|
||||
const dialogTitle = computed(() => (isEdit.value ? '编辑运输计划' : '新增运输计划'))
|
||||
const showSaveAndArrange = computed(
|
||||
@@ -357,7 +370,8 @@ const vehicleBundle = ref<VehicleViewBundle | null>(null)
|
||||
const selectedDriverId = ref('')
|
||||
|
||||
const formData = reactive({
|
||||
planDate: new Date().toISOString().split('T')[0],
|
||||
createDate: todayYmd(),
|
||||
planDate: todayYmd(),
|
||||
belongsCompany: 'shanxia',
|
||||
planType: '',
|
||||
followUserId: '',
|
||||
@@ -381,12 +395,12 @@ const formData = reactive({
|
||||
pickupAddress: '',
|
||||
pickupLng: null as number | null,
|
||||
pickupLat: null as number | null,
|
||||
pickupTime: '',
|
||||
pickupTime: todayYmd(),
|
||||
pickupNotes: '',
|
||||
destinationAddress: '',
|
||||
destinationLng: null as number | null,
|
||||
destinationLat: null as number | null,
|
||||
deliveryTime: '',
|
||||
deliveryTime: todayYmd(),
|
||||
destinationNotes: '',
|
||||
vehicleId: '',
|
||||
carrierId: '',
|
||||
@@ -397,6 +411,7 @@ const formData = reactive({
|
||||
})
|
||||
|
||||
const basicRules = {
|
||||
createDate: [{ required: true, message: '请选择创建日期', trigger: 'change' }],
|
||||
planDate: [{ required: true, message: '请选择计划日期', trigger: 'change' }],
|
||||
belongsCompany: [{ required: true, message: '请选择归属公司', trigger: 'change' }]
|
||||
}
|
||||
@@ -558,6 +573,7 @@ function buildTransportBlock(options?: { allowClear?: boolean }) {
|
||||
|
||||
function buildPlanCommonPayload(options?: { allowClearTransport?: boolean }): PlanUpdatePayload {
|
||||
return {
|
||||
createDate: formData.createDate,
|
||||
planDate: formData.planDate,
|
||||
belongsCompany: formData.belongsCompany,
|
||||
planType: formData.planType || '',
|
||||
@@ -638,8 +654,10 @@ function resetForm() {
|
||||
contractSnapshot.value = null
|
||||
vehicleBundle.value = null
|
||||
selectedDriverId.value = ''
|
||||
const d = todayYmd()
|
||||
Object.assign(formData, {
|
||||
planDate: new Date().toISOString().split('T')[0],
|
||||
createDate: d,
|
||||
planDate: d,
|
||||
belongsCompany: 'shanxia',
|
||||
planType: '',
|
||||
followUserId: resolveCurrentUserId(),
|
||||
@@ -663,12 +681,12 @@ function resetForm() {
|
||||
pickupAddress: '',
|
||||
pickupLng: null as number | null,
|
||||
pickupLat: null as number | null,
|
||||
pickupTime: '',
|
||||
pickupTime: d,
|
||||
pickupNotes: '',
|
||||
destinationAddress: '',
|
||||
destinationLng: null as number | null,
|
||||
destinationLat: null as number | null,
|
||||
deliveryTime: '',
|
||||
deliveryTime: d,
|
||||
destinationNotes: '',
|
||||
vehicleId: '',
|
||||
carrierId: '',
|
||||
@@ -698,6 +716,7 @@ async function loadPlanForEdit(planId: string) {
|
||||
const res = await planApi.get(planId)
|
||||
const data = (res.data ?? res) as Plan
|
||||
Object.assign(formData, {
|
||||
createDate: data.createDate || formatDate(data.createTime) || todayYmd(),
|
||||
planDate: data.planDate,
|
||||
belongsCompany: data.belongsCompany,
|
||||
planType: data.planType,
|
||||
|
||||
Reference in new issue
Block a user