feat: 订单状态筛选+编辑功能
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Agent
2026-03-25 15:59:51 +00:00
parent 34054065ed
commit 1cb5f6b646
3 changed files with 147 additions and 10 deletions

View File

@@ -164,13 +164,49 @@ export default {
// 其他
paymentMethod: 'cash',
remark: ''
remark: '',
// 编辑模式
editingOrderId: null
}
},
onLoad() {
onLoad(options) {
this.loadCustomers()
this.loadProducts()
if (options.orderId) {
this.editingOrderId = options.orderId
this.loadOrder(options.orderId)
}
},
methods: {
async loadOrder(orderId) {
try {
const detail = await orderApi.getOrderDetail(orderId)
const order = detail.order
// 设置订单信息
if (order.customerId) {
this.selectedCustomer = this.customers.find(c => c.customerId === order.customerId)
}
this.orderItems = (detail.items || []).map(item => ({
productId: item.productId,
productName: item.productName,
spec: item.productSpec,
unit: item.unit,
price: item.price,
quantity: item.quantity
}))
this.discountRate = order.discountRate
this.remark = order.remark || ''
this.paymentMethod = order.paymentMethod || 'cash'
this.calcAmount()
} catch (e) {
console.error(e)
}
},
methods: {
async loadCustomers() {
try {
@@ -248,19 +284,25 @@ export default {
}
try {
const order = await orderApi.createOrder(data)
let order
if (this.editingOrderId) {
order = await orderApi.updateOrder(this.editingOrderId, data)
uni.showToast({ title: '订单更新成功', icon: 'success' })
} else {
order = await orderApi.createOrder(data)
uni.showToast({ title: '订单创建成功', icon: 'success' })
}
uni.showToast({ title: '订单创建成功', icon: 'success' })
// 跳转到订单详情或列表
// 跳转到订单列表(未完成)
setTimeout(() => {
uni.navigateTo({
url: `/pages/order/list`
uni.switchTab({
url: '/pages/order/list?status=0'
})
}, 1500)
} catch (e) {
console.error(e)
}
}
}
}
}