feat(dealer): 添加订单月份筛选和详情展示功能
- 更新开发环境API地址为本地调试地址 -为订单模型添加结算金额、支付金额和月份字段- 在订单查询中使用resourceId替代userId并支持按月份筛选 - 在订单列表中展示订单号、客户名称、结算月份、结算电量等详细信息 - 添加日期选择器组件用于选择查询月份- 升级@nutui/nutui-react-taro依赖版本以支持新组件- 调整订单状态展示逻辑,显示结算金额和实发金额
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, {useState, useEffect, useCallback} from 'react'
|
||||
import {View, Text, ScrollView} from '@tarojs/components'
|
||||
import {Empty, PullToRefresh, Loading} from '@nutui/nutui-react-taro'
|
||||
import {Empty, PullToRefresh, Loading, Cell, DatePicker} from '@nutui/nutui-react-taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {pageShopDealerOrder} from '@/api/shop/shopDealerOrder'
|
||||
import {useDealerUser} from '@/hooks/useDealerUser'
|
||||
@@ -14,6 +14,10 @@ interface OrderWithDetails extends ShopDealerOrder {
|
||||
|
||||
const DealerOrders: React.FC = () => {
|
||||
const [loading, setLoading] = useState<boolean>(false)
|
||||
const d = new Date()
|
||||
const currDay = `${d.getFullYear()}${d.getMonth() + 1}`
|
||||
const [date, setDate] = useState(currDay)
|
||||
const [show1, setShow1] = useState(false)
|
||||
const [refreshing, setRefreshing] = useState<boolean>(false)
|
||||
const [loadingMore, setLoadingMore] = useState<boolean>(false)
|
||||
const [orders, setOrders] = useState<OrderWithDetails[]>([])
|
||||
@@ -37,7 +41,8 @@ const DealerOrders: React.FC = () => {
|
||||
|
||||
const result = await pageShopDealerOrder({
|
||||
isInvalid: 0,
|
||||
userId: Taro.getStorageSync('UserId'),
|
||||
resourceId: Taro.getStorageSync('UserId'),
|
||||
month: date,
|
||||
page,
|
||||
limit: 10
|
||||
})
|
||||
@@ -108,10 +113,7 @@ const DealerOrders: React.FC = () => {
|
||||
<View key={order.id} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
||||
<View className="flex justify-between items-start mb-1">
|
||||
<Text className="font-semibold text-gray-800">
|
||||
电费收益
|
||||
</Text>
|
||||
<Text className="text-lg text-orange-500 font-semibold">
|
||||
¥{(Number(order.orderPrice) * 10).toFixed(2)}
|
||||
订单号:{order.id}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -119,15 +121,30 @@ const DealerOrders: React.FC = () => {
|
||||
<Text className="text-sm text-gray-400">
|
||||
客户名称:{order.comments}
|
||||
</Text>
|
||||
<Text className="text-sm text-gray-400">
|
||||
税费:{order.rate}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View className="flex justify-between items-center">
|
||||
<Text className="text-sm text-gray-400">
|
||||
结算月份:{order.month}
|
||||
</Text>
|
||||
<Text className="text-sm text-gray-400">
|
||||
结算电量:{order.orderPrice || '0.00'}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View className="flex justify-between items-center mb-1">
|
||||
<Text className="text-sm text-gray-400">
|
||||
结算金额:{order.settledPrice}
|
||||
</Text>
|
||||
<Text className="text-sm text-gray-400">
|
||||
实发金额:{order.payPrice}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View className="flex justify-between items-center mb-1">
|
||||
<Text className="text-sm text-gray-400">
|
||||
税费:{order.rate}
|
||||
</Text>
|
||||
<Text className="text-sm text-gray-400">
|
||||
状态:{getStatusText(order.isSettled, order.isInvalid)}
|
||||
</Text>
|
||||
@@ -152,6 +169,27 @@ const DealerOrders: React.FC = () => {
|
||||
refreshingText="刷新中..."
|
||||
completeText="刷新完成"
|
||||
>
|
||||
<Cell
|
||||
description={date ? `${date}` : '请选择'}
|
||||
extra={'选择月份'}
|
||||
onClick={() => setShow1(true)}
|
||||
/>
|
||||
<DatePicker
|
||||
title="日期选择"
|
||||
visible={show1}
|
||||
pickerProps={{
|
||||
popupProps: {zIndex: 1220},
|
||||
}}
|
||||
type={'year-month'}
|
||||
defaultValue={new Date(`${date}`)}
|
||||
showChinese
|
||||
onCancel={() => setShow1(false)}
|
||||
onConfirm={(_, values) => {
|
||||
setShow1(false)
|
||||
setDate(`${values[0]}${values[1]}`)
|
||||
fetchOrders(1).then()
|
||||
}}
|
||||
/>
|
||||
<ScrollView
|
||||
scrollY
|
||||
className="h-screen"
|
||||
|
||||
Reference in New Issue
Block a user