feat(store): 恢复门店端独立改价按钮和弹窗
- 去除确认收款弹窗中的“实付金额”输入框 - 改价功能从合并回独立弹窗及按钮 - 新增改价相关状态和函数处理逻辑 - 线下付款未付款状态显示“改价”与“确认收款”按钮 - 改价弹窗包含订单信息、新金额输入及改价备注 - 改价按钮样式调整为橙色背景白字 - 改价提交时更新订单金额及备注并刷新列表
This commit is contained in:
@@ -138,7 +138,14 @@
|
||||
- **deliveryStatus 含义**:10=待发货, 20=已发货, 30=部分发货(未使用)
|
||||
- **状态文案**:deliveryStatus=20+未付款+线下付款 → "已发货待收款"(红),deliveryStatus=20+已付款 → "待收货"(蓝)
|
||||
|
||||
### 门店端:改价功能合并到确认收款弹窗
|
||||
- 去掉独立的"改价"按钮和修改金额弹窗(`editPrice` OpType、`showEditPriceModal`、`editReason` 等)
|
||||
- 在确认收款弹窗中增加"实付金额"输入框(预填当前值,可修改),改价不再需要单独输入原因(收款备注即可说明)
|
||||
- 提交时:如果金额有变化,先调 `updateShopOrder` 更新 `payPrice`+`merchantRemarks`,再调 `confirmOfflinePayment` 确认收款
|
||||
### 门店端:改价功能合并到确认收款弹窗 → 又改回来了
|
||||
- 先去掉了独立的"改价"按钮和修改金额弹窗(`editPrice` OpType、`showEditPriceModal`、`editReason` 等)
|
||||
- 在确认收款弹窗中增加了"实付金额"输入框
|
||||
- **2026-07-17 下午**:用户要求改回来,恢复独立的改价按钮和弹窗
|
||||
- OpType 加回 `editPrice`
|
||||
- `getOrderActions` 中线下付款未付款时显示「改价」+「确认收款」两个按钮
|
||||
- 恢复 `showEditPriceModal`/`editPriceOrder`/`editPriceValue`/`editPriceRemarks`/`editingPrice` 状态
|
||||
- 恢复 `openEditPriceModal`/`closeEditPriceModal`/`submitEditPrice` 函数
|
||||
- 恢复独立改价弹窗(订单信息 + 新金额输入 + 改价原因备注)
|
||||
- 确认收款弹窗去掉「实付金额」输入框,`submitOperation` 中 confirmPay 分支去掉改价逻辑
|
||||
- 改价按钮样式:橙色背景白字 `bg-orange-500`
|
||||
|
||||
@@ -28,13 +28,14 @@ const TABS: { key: TabKey; label: string; params: Partial<ShopOrderParam>[] }[]
|
||||
]
|
||||
|
||||
// ─── 操作类型 ─────────────────────────────────────────────────────
|
||||
type OpType = 'confirmPay' | 'deliver' | 'complete' | 'ship'
|
||||
type OpType = 'confirmPay' | 'deliver' | 'complete' | 'ship' | 'editPrice'
|
||||
|
||||
const OP_LABEL: Record<OpType, string> = {
|
||||
confirmPay: '收款',
|
||||
deliver: '送达',
|
||||
complete: '已完成',
|
||||
ship: '发货',
|
||||
editPrice: '改价',
|
||||
}
|
||||
|
||||
const OP_DESC: Record<OpType, string> = {
|
||||
@@ -42,6 +43,7 @@ const OP_DESC: Record<OpType, string> = {
|
||||
deliver: '上传送达凭证照片,标记为已收货(不改变付款和订单完成状态)',
|
||||
complete: '确认订单已完成,收款后点击此按钮标记订单完成',
|
||||
ship: '选择发货人员并生成发货单,订单将进入已发货状态',
|
||||
editPrice: '修改订单实付金额',
|
||||
}
|
||||
|
||||
// ─── 图片上传 ─────────────────────────────────────────────────────
|
||||
@@ -132,8 +134,9 @@ function isOrderActionable(order: ShopOrder): boolean {
|
||||
function getOrderActions(order: ShopOrder): { label: string; type: OpType }[] {
|
||||
if (!isOrderActionable(order)) return []
|
||||
const actions: { label: string; type: OpType }[] = []
|
||||
// 线下付款·待确认收款:显示"确认收款"按钮
|
||||
// 线下付款·待确认收款:显示"确认收款"和"改价"按钮
|
||||
if (!order.payStatus && order.payType === 9 && order.orderStatus === 0) {
|
||||
actions.push({label: '改价', type: 'editPrice'})
|
||||
actions.push({label: '确认收款', type: 'confirmPay'})
|
||||
}
|
||||
// 发货:
|
||||
@@ -176,8 +179,12 @@ export default function StoreOrdersPage() {
|
||||
const [payRemarks, setPayRemarks] = useState('')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
|
||||
// 确认收款弹窗:修改金额(选填)
|
||||
const [editPayPrice, setEditPayPrice] = useState('')
|
||||
// 改价弹窗状态
|
||||
const [showEditPriceModal, setShowEditPriceModal] = useState(false)
|
||||
const [editPriceOrder, setEditPriceOrder] = useState<ShopOrder | null>(null)
|
||||
const [editPriceValue, setEditPriceValue] = useState('')
|
||||
const [editPriceRemarks, setEditPriceRemarks] = useState('')
|
||||
const [editingPrice, setEditingPrice] = useState(false)
|
||||
|
||||
// 发货弹窗状态
|
||||
const [showShipModal, setShowShipModal] = useState(false)
|
||||
@@ -309,11 +316,15 @@ export default function StoreOrdersPage() {
|
||||
|
||||
/** 打开操作弹窗 */
|
||||
const openModal = (order: ShopOrder, type: OpType) => {
|
||||
// 改价走独立弹窗
|
||||
if (type === 'editPrice') {
|
||||
openEditPriceModal(order)
|
||||
return
|
||||
}
|
||||
setCurrentOrder(order)
|
||||
setOpType(type)
|
||||
setProofImages([])
|
||||
setPayRemarks('')
|
||||
setEditPayPrice(String(order.payPrice || order.totalPrice || ''))
|
||||
setShowModal(true)
|
||||
}
|
||||
|
||||
@@ -323,7 +334,6 @@ export default function StoreOrdersPage() {
|
||||
setCurrentOrder(null)
|
||||
setProofImages([])
|
||||
setPayRemarks('')
|
||||
setEditPayPrice('')
|
||||
}
|
||||
|
||||
/** 选择并上传凭证图片 */
|
||||
@@ -383,23 +393,7 @@ export default function StoreOrdersPage() {
|
||||
setSubmitting(true)
|
||||
try {
|
||||
if (opType === 'confirmPay') {
|
||||
// 确认线下收款:检查是否需要改价,合并改价+确认收款
|
||||
const newPrice = parseFloat(editPayPrice)
|
||||
const oldPriceStr = String(currentOrder.payPrice || currentOrder.totalPrice || '')
|
||||
const oldPrice = parseFloat(oldPriceStr)
|
||||
const priceChanged = !isNaN(newPrice) && newPrice >= 0 && Math.abs(newPrice - oldPrice) > 0.01
|
||||
|
||||
if (priceChanged) {
|
||||
// 先更新金额
|
||||
const changeRecord = `【门店修改金额】原实付¥${oldPriceStr} → 新实付¥${newPrice.toFixed(2)}`
|
||||
await updateShopOrder({
|
||||
orderId: currentOrder.orderId,
|
||||
payPrice: newPrice.toFixed(2),
|
||||
merchantRemarks: (currentOrder.merchantRemarks || '') + `\n${changeRecord}`,
|
||||
} as ShopOrder)
|
||||
}
|
||||
|
||||
// 确认收款
|
||||
// 确认线下收款
|
||||
await confirmOfflinePayment(
|
||||
currentOrder.orderId!,
|
||||
payRemarks.trim() || undefined,
|
||||
@@ -430,6 +424,54 @@ export default function StoreOrdersPage() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开改价弹窗 */
|
||||
const openEditPriceModal = (order: ShopOrder) => {
|
||||
setEditPriceOrder(order)
|
||||
setEditPriceValue(String(order.payPrice || order.totalPrice || ''))
|
||||
setEditPriceRemarks('')
|
||||
setShowEditPriceModal(true)
|
||||
}
|
||||
|
||||
/** 关闭改价弹窗 */
|
||||
const closeEditPriceModal = () => {
|
||||
setShowEditPriceModal(false)
|
||||
setEditPriceOrder(null)
|
||||
setEditPriceValue('')
|
||||
setEditPriceRemarks('')
|
||||
}
|
||||
|
||||
/** 提交改价 */
|
||||
const submitEditPrice = async () => {
|
||||
if (!editPriceOrder) return
|
||||
const newPrice = parseFloat(editPriceValue)
|
||||
if (isNaN(newPrice) || newPrice < 0) {
|
||||
Taro.showToast({title: '请输入有效金额', icon: 'none'})
|
||||
return
|
||||
}
|
||||
const oldPriceStr = String(editPriceOrder.payPrice || editPriceOrder.totalPrice || '0')
|
||||
const oldPrice = parseFloat(oldPriceStr)
|
||||
if (!isNaN(oldPrice) && Math.abs(newPrice - oldPrice) < 0.01) {
|
||||
Taro.showToast({title: '金额未变化', icon: 'none'})
|
||||
return
|
||||
}
|
||||
setEditingPrice(true)
|
||||
try {
|
||||
const changeRecord = `【门店修改金额】原实付¥${oldPriceStr} → 新实付¥${newPrice.toFixed(2)}`
|
||||
await updateShopOrder({
|
||||
orderId: editPriceOrder.orderId,
|
||||
payPrice: newPrice.toFixed(2),
|
||||
merchantRemarks: (editPriceOrder.merchantRemarks || '') + `\n${changeRecord}`,
|
||||
} as ShopOrder)
|
||||
Taro.showToast({title: '改价成功', icon: 'success'})
|
||||
closeEditPriceModal()
|
||||
loadOrders(activeTab, 1)
|
||||
} catch (e: any) {
|
||||
Taro.showToast({title: e.message || '改价失败', icon: 'none'})
|
||||
} finally {
|
||||
setEditingPrice(false)
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开发货弹窗:拉取门店店员列表供选择发货人员 */
|
||||
const openShipModal = async (order: ShopOrder) => {
|
||||
setCurrentOrder(order)
|
||||
@@ -656,6 +698,8 @@ export default function StoreOrdersPage() {
|
||||
? 'bg-blue-500'
|
||||
: act.type === 'ship'
|
||||
? 'bg-purple-500'
|
||||
: act.type === 'editPrice'
|
||||
? 'bg-orange-500'
|
||||
: 'border border-blue-500'
|
||||
}`}
|
||||
onClick={() => act.type === 'ship'
|
||||
@@ -663,7 +707,7 @@ export default function StoreOrdersPage() {
|
||||
: openModal(order, act.type)}
|
||||
>
|
||||
<Text className={`text-sm ${
|
||||
act.type === 'complete' || act.type === 'confirmPay' || act.type === 'ship' ? 'text-white' : 'text-blue-500'
|
||||
act.type === 'complete' || act.type === 'confirmPay' || act.type === 'ship' || act.type === 'editPrice' ? 'text-white' : 'text-blue-500'
|
||||
}`}>{act.label}</Text>
|
||||
</View>
|
||||
))}
|
||||
@@ -828,31 +872,17 @@ export default function StoreOrdersPage() {
|
||||
|
||||
{/* 备注(仅确认收款时显示) */}
|
||||
{opType === 'confirmPay' && (
|
||||
<>
|
||||
<View className='mb-6'>
|
||||
<Text className='text-sm text-gray-600 mb-2 block'>备注(选填)</Text>
|
||||
<Textarea
|
||||
className='w-full px-4 py-3 rounded-xl border border-gray-200 text-sm text-gray-800'
|
||||
style={{minHeight: '60px'}}
|
||||
value={payRemarks}
|
||||
onInput={(e) => setPayRemarks(e.detail.value)}
|
||||
placeholder='可填写备注(如:微信转账已收到)'
|
||||
maxlength={200}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/* 修改金额(选填,合并到确认收款) */}
|
||||
<View className='mb-6'>
|
||||
<Text className='text-sm text-gray-600 mb-2 block'>实付金额(元)</Text>
|
||||
<Input
|
||||
type='digit'
|
||||
className='w-full px-4 py-3 rounded-xl border border-gray-200 text-lg text-gray-800'
|
||||
value={editPayPrice}
|
||||
onInput={(e) => setEditPayPrice(e.detail.value)}
|
||||
placeholder='如需改价请直接修改,不改则保持原值'
|
||||
/>
|
||||
</View>
|
||||
</>
|
||||
<View className='mb-6'>
|
||||
<Text className='text-sm text-gray-600 mb-2 block'>备注(选填)</Text>
|
||||
<Textarea
|
||||
className='w-full px-4 py-3 rounded-xl border border-gray-200 text-sm text-gray-800'
|
||||
style={{minHeight: '60px'}}
|
||||
value={payRemarks}
|
||||
onInput={(e) => setPayRemarks(e.detail.value)}
|
||||
placeholder='可填写备注(如:微信转账已收到)'
|
||||
maxlength={200}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 确认完成不需要备注时补充间距 */}
|
||||
@@ -958,6 +988,68 @@ export default function StoreOrdersPage() {
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 改价弹窗 */}
|
||||
{showEditPriceModal && editPriceOrder && (
|
||||
<View className='fixed inset-0 z-50 flex items-end justify-center'>
|
||||
<View className='absolute inset-0 bg-black/50' onClick={closeEditPriceModal}/>
|
||||
<View className='relative bg-white rounded-t-2xl w-full px-5 pt-6 pb-10'>
|
||||
<Text className='text-lg font-medium text-gray-800 text-center mb-5 block'>
|
||||
修改订单金额
|
||||
</Text>
|
||||
|
||||
{/* 订单信息 */}
|
||||
<View className='bg-gray-50 rounded-xl p-4 mb-5'>
|
||||
<Text className='text-sm text-gray-700 block'>订单号:{editPriceOrder.orderNo}</Text>
|
||||
<Text className='text-sm text-gray-700 mt-1 block'>
|
||||
原实付金额:<Text className='text-red-500 font-medium'>¥{editPriceOrder.payPrice || editPriceOrder.totalPrice}</Text>
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
{/* 新金额输入 */}
|
||||
<View className='mb-6'>
|
||||
<Text className='text-sm text-gray-600 mb-2 block'>新实付金额(元)</Text>
|
||||
<Input
|
||||
type='digit'
|
||||
className='w-full px-4 py-3 rounded-xl border border-gray-200 text-lg text-gray-800'
|
||||
value={editPriceValue}
|
||||
onInput={(e) => setEditPriceValue(e.detail.value)}
|
||||
placeholder='请输入新的实付金额'
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/* 改价备注 */}
|
||||
<View className='mb-6'>
|
||||
<Text className='text-sm text-gray-600 mb-2 block'>改价原因(选填)</Text>
|
||||
<Textarea
|
||||
className='w-full px-4 py-3 rounded-xl border border-gray-200 text-sm text-gray-800'
|
||||
style={{minHeight: '60px'}}
|
||||
value={editPriceRemarks}
|
||||
onInput={(e) => setEditPriceRemarks(e.detail.value)}
|
||||
placeholder='如:客户协商优惠、多收退款等'
|
||||
maxlength={200}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/* 操作按钮 */}
|
||||
<View className='flex gap-3'>
|
||||
<View className='flex-1 py-3 rounded-xl bg-gray-100 text-center' onClick={closeEditPriceModal}>
|
||||
<Text className='text-sm text-gray-600'>取消</Text>
|
||||
</View>
|
||||
<View
|
||||
className='flex-1 py-3 rounded-xl bg-orange-500 text-center flex items-center justify-center'
|
||||
onClick={editingPrice ? undefined : submitEditPrice}
|
||||
>
|
||||
{editingPrice ? (
|
||||
<Text className='text-sm text-white'>提交中...</Text>
|
||||
) : (
|
||||
<Text className='text-sm text-white'>确认改价</Text>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user