- 在 PageList 组件中实现选择行功能,支持复选框操作和状态管理 - 更新 ToolBar 类型定义,允许传递任意类型的选中数据 - 添加新的图标资源:eye、eye-slash 和 phone-flip - 重构 SupplierPicker 组件以适配最新的 API 接口类型 - 在工作台常量中增加“瓜农管理”和“上传发票”页面路由配置 - 创建供应商采购发票页面及列表展示组件 - 实现瓜农列表页面,支持搜索和详情展示 - 引入并导出订单供应商相关服务接口和类型定义 - 扩展业务模块的类型声明文件,新增订单供应商相关结构体 - 更新字体图标库版本,并添加新图标样式 - 在应用配置中注册新的供应商相关页面路径 - 优化采购订单计算器逻辑,排除特定费用项的重复计算
166 lines
5.0 KiB
TypeScript
166 lines
5.0 KiB
TypeScript
import {
|
|
ActionType,
|
|
Icon,
|
|
PageList,
|
|
SupplierPicker,
|
|
ToolBar,
|
|
} from "@/components";
|
|
import { useShareAppMessage } from "@tarojs/taro";
|
|
import { useRef, useState } from "react";
|
|
import { business } from "@/services";
|
|
import hocAuth from "@/hocs/auth";
|
|
import { CommonComponent } from "@/types/typings";
|
|
import { View } from "@tarojs/components";
|
|
import dayjs from "dayjs";
|
|
|
|
export default hocAuth(function Page(props: CommonComponent) {
|
|
const { shareOptions } = props;
|
|
|
|
const [supplierVO, setSupplierVO] = useState<BusinessAPI.SupplierVO>();
|
|
|
|
const actionRef = useRef<ActionType>();
|
|
const toolbar: ToolBar = {
|
|
selectRow: {
|
|
onClick: async (orderSupplierVOList: BusinessAPI.OrderSupplierVO[]) => {
|
|
console.log("orderSupplierVOList", orderSupplierVOList);
|
|
},
|
|
},
|
|
search: {
|
|
activeKey: "vehicleNo",
|
|
defaultActiveKey: "vehicleNo",
|
|
items: [
|
|
{
|
|
key: "vehicleNo",
|
|
name: "车次号",
|
|
placeholder: "请输入车次号",
|
|
},
|
|
{
|
|
key: "plate",
|
|
name: "车牌号",
|
|
placeholder: "请输入车牌号",
|
|
},
|
|
],
|
|
},
|
|
render: () => (
|
|
<>
|
|
<View className={"flex flex-row gap-2.5"}>
|
|
<SupplierPicker
|
|
onFinish={(supplierVO) => {
|
|
setSupplierVO(supplierVO);
|
|
actionRef.current?.reload();
|
|
}}
|
|
trigger={
|
|
<View
|
|
className={`"border-2 border-primary flex h-6 items-center rounded-md px-2.5`}
|
|
>
|
|
<View className={"text-primary text-xs"}>
|
|
{supplierVO?.name || "瓜农"}
|
|
</View>
|
|
{supplierVO?.name ? (
|
|
<Icon
|
|
name={"circle-xmark"}
|
|
size={16}
|
|
onClick={(event) => {
|
|
setSupplierVO(undefined);
|
|
actionRef.current?.reload();
|
|
event.stopPropagation();
|
|
}}
|
|
/>
|
|
) : (
|
|
<Icon name={"chevron-down"} size={16} />
|
|
)}
|
|
</View>
|
|
}
|
|
/>
|
|
</View>
|
|
</>
|
|
),
|
|
};
|
|
|
|
useShareAppMessage((res) => {
|
|
console.log("useShareAppMessage1", res, shareOptions);
|
|
// 如果是按钮触发的转发,使用默认配置
|
|
if (res.from === "button") {
|
|
return shareOptions;
|
|
}
|
|
// 页面转发使用设置的配置
|
|
return {};
|
|
});
|
|
|
|
return (
|
|
<PageList<BusinessAPI.OrderSupplierVO, BusinessAPI.OrderSupplierPageQry>
|
|
rowId={"orderSupplierId"}
|
|
itemHeight={182}
|
|
type={"infinite"}
|
|
actionRef={actionRef}
|
|
render={(orderSupplierVO: BusinessAPI.OrderSupplierVO, index) => (
|
|
<View className={"mb-2.5 flex-1"} key={index}>
|
|
<View
|
|
className={
|
|
"relative flex flex-col divide-y-2 divide-neutral-100 rounded-lg bg-white p-2.5"
|
|
}
|
|
>
|
|
<View className="flex-1">
|
|
<View className="flex items-start justify-between">
|
|
<View>
|
|
<View className="text-base font-medium text-gray-800">
|
|
{orderSupplierVO.name} (
|
|
{orderSupplierVO.orderVehicle?.origin}-
|
|
{orderSupplierVO.orderVehicle?.destination})
|
|
</View>
|
|
</View>
|
|
{/*<View className="rounded bg-gray-100 px-2 py-1 text-xs text-gray-800">*/}
|
|
{/* 草稿*/}
|
|
{/*</View>*/}
|
|
</View>
|
|
<View className="my-1 flex flex-row flex-wrap gap-1 text-sm text-gray-600">
|
|
<View className="text-primary">
|
|
{orderSupplierVO.orderVehicle?.vehicleNo
|
|
? "第" + orderSupplierVO.orderVehicle?.vehicleNo + "车"
|
|
: "暂未生成车次"}
|
|
</View>
|
|
<View>
|
|
{dayjs(orderSupplierVO.orderVehicle?.deliveryTime).format(
|
|
"MM-DD",
|
|
)}
|
|
</View>
|
|
<View>|</View>
|
|
<View>{orderSupplierVO.netWeight}斤</View>
|
|
<View>|</View>
|
|
<View>¥{orderSupplierVO.invoiceAmount}</View>
|
|
</View>
|
|
<View className="text-xs text-gray-500">
|
|
{`${orderSupplierVO.productName} | 品种:`}
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
)}
|
|
toolbar={toolbar}
|
|
request={async (params) => {
|
|
const {
|
|
data: { data, success, notEmpty },
|
|
} = await business.orderSupplier.pageOrderSupplier({
|
|
orderSupplierPageQry: {
|
|
...params,
|
|
...(supplierVO
|
|
? {
|
|
supplierId: supplierVO.supplierId,
|
|
}
|
|
: {}),
|
|
},
|
|
});
|
|
|
|
return {
|
|
data,
|
|
success,
|
|
hasMore: notEmpty,
|
|
};
|
|
}}
|
|
pagination={{
|
|
pageSize: 10,
|
|
}}
|
|
/>
|
|
);
|
|
});
|