|
|
@@ -989,15 +989,31 @@ export default {
|
|
|
* @param {Object} data - 保存后的订单数据
|
|
|
* @description 订单保存成功后触发,携带最新的订单数据
|
|
|
*/
|
|
|
- this.$emit(ORDER_FORM_EVENTS.SAVE_SUCCESS, response.data.data)
|
|
|
+ // 为了兼容父组件的处理逻辑,将返回的订单ID包装成对象格式
|
|
|
+ const orderData = typeof response.data.data === 'string'
|
|
|
+ ? { id: response.data.data }
|
|
|
+ : response.data.data
|
|
|
+ this.$emit(ORDER_FORM_EVENTS.SAVE_SUCCESS, orderData)
|
|
|
|
|
|
// 保持在当前页:新增与编辑模式均不主动返回列表
|
|
|
+ // 新增模式:保存成功后使用返回的订单ID加载订单详情并切换到编辑模式
|
|
|
// 编辑模式:保存成功后刷新订单详情,已保存的物料置为不可删除
|
|
|
if (this.isEdit) {
|
|
|
const savedId = (response && response.data && response.data.data && response.data.data.id) || this.orderId || (this.formData && this.formData.id)
|
|
|
if (savedId) {
|
|
|
await this.loadOrderDetail(String(savedId))
|
|
|
}
|
|
|
+ } else {
|
|
|
+ // 新增模式:使用接口返回的订单ID加载订单详情并切换到编辑模式
|
|
|
+ const newOrderId = response && response.data && response.data.data
|
|
|
+ if (newOrderId) {
|
|
|
+ // 设置订单ID,触发编辑模式
|
|
|
+ this.orderId = String(newOrderId)
|
|
|
+ // 加载订单详情数据
|
|
|
+ await this.loadOrderDetail(String(newOrderId))
|
|
|
+ // 可选:显示成功提示,告知用户已切换到编辑模式
|
|
|
+ this.$message.success('订单创建成功,已自动切换到编辑模式')
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|