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
@@ -412,6 +412,7 @@ export interface PlanProduct {
|
||||
export interface Plan {
|
||||
id: string
|
||||
planNo: string
|
||||
createDate: string
|
||||
planDate: string
|
||||
belongsCompany: string
|
||||
planType: string
|
||||
@@ -504,6 +505,7 @@ export interface PlanTransportCreateBlock {
|
||||
|
||||
export interface PlanCreateFullPayload {
|
||||
contractId: string
|
||||
createDate: string
|
||||
planDate: string
|
||||
belongsCompany: string
|
||||
planType: string
|
||||
@@ -622,7 +624,13 @@ export const planApi = {
|
||||
updateSiteFeedback: (id: string, linkId: string, data: PlanSiteFeedbackUpdateBody) =>
|
||||
request.patch<Plan>(`/transport/plan/${id}/site-feedback/${linkId}`, data),
|
||||
delete: (id: string) => request.delete(`/transport/plan/${id}`),
|
||||
createFromContract: (data: { contractId: string; planDate: string; followUserId?: string; followUserName?: string }) =>
|
||||
createFromContract: (data: {
|
||||
contractId: string
|
||||
planDate: string
|
||||
createDate?: string
|
||||
followUserId?: string
|
||||
followUserName?: string
|
||||
}) =>
|
||||
request.post<Plan>('/transport/plan/create-from-contract', data),
|
||||
getInboundSlipTemplate: (id: string) =>
|
||||
request.get<string>(`/transport/plan/${id}/inbound-slip-template`),
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -24,6 +24,15 @@
|
||||
<el-option label="出库单" value="outbound" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<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"
|
||||
@@ -218,6 +227,7 @@ const formRef = ref()
|
||||
const formData = reactive({
|
||||
belongsCompany: 'shanxia',
|
||||
planType: 'direct',
|
||||
createDate: '',
|
||||
planDate: '',
|
||||
contractId: '',
|
||||
contractNo: '',
|
||||
@@ -242,6 +252,7 @@ const formData = reactive({
|
||||
|
||||
const formRules = {
|
||||
belongsCompany: [{ required: true, message: '请选择归属公司', trigger: 'change' }],
|
||||
createDate: [{ required: true, message: '请选择创建日期', trigger: 'change' }],
|
||||
planDate: [{ required: true, message: '请选择计划日期', trigger: 'change' }]
|
||||
}
|
||||
|
||||
@@ -272,6 +283,7 @@ async function handleSubmit() {
|
||||
const payload = {
|
||||
belongsCompany: formData.belongsCompany,
|
||||
planType: formData.planType,
|
||||
createDate: formData.createDate,
|
||||
planDate: formData.planDate,
|
||||
contractId: formData.contractId,
|
||||
contractNo: formData.contractNo,
|
||||
@@ -321,6 +333,7 @@ async function fetchDetail() {
|
||||
Object.assign(formData, {
|
||||
belongsCompany: data.belongsCompany,
|
||||
planType: data.planType,
|
||||
createDate: data.createDate || (data.createTime ? String(data.createTime).slice(0, 10) : ''),
|
||||
planDate: data.planDate,
|
||||
contractId: data.contractId,
|
||||
contractNo: data.contractNo,
|
||||
@@ -348,8 +361,12 @@ async function fetchDetail() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const today = new Date().toISOString().split('T')[0]
|
||||
if (!formData.createDate) {
|
||||
formData.createDate = today
|
||||
}
|
||||
if (!formData.planDate) {
|
||||
formData.planDate = new Date().toISOString().split('T')[0]
|
||||
formData.planDate = today
|
||||
}
|
||||
fetchDetail()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user