import { ActionType, DealerPicker, Icon, OrderItem, PageList, SupplierPicker, ToolBar, } from "@/components"; import React, { useRef, useState } from "react"; import { business } from "@/services"; import { View } from "@tarojs/components"; import { buildUrl } from "@/utils"; import Taro from "@tarojs/taro"; import { purchase } from "@/constant"; interface IOrderListProps { params: BusinessAPI.OrderPageQry; create?: boolean; toolbar?: ToolBar; actionRef?: React.MutableRefObject; } export default function OrderList(props: IOrderListProps) { const { params: bizParams, create = false, toolbar: defaultToolbar, actionRef: externalActionRef, } = props; const { type = "PRODUCTION_PURCHASE" } = bizParams; const internalActionRef = useRef(); const actionRef = externalActionRef || internalActionRef; const [dealerVO, setDealerVO] = useState(); const [supplierVO, setSupplierVO] = useState(); const toolbar: ToolBar = { ...defaultToolbar, search: { activeKey: "plate", defaultActiveKey: "plate", items: [ { key: "plate", name: "车牌号", placeholder: "请输入车牌号", }, ], }, render: () => ( { setDealerVO(dealerVO); actionRef.current?.reload(); }} trigger={ {dealerVO?.shortName || "经销商"} {dealerVO?.shortName ? ( { setDealerVO(undefined); actionRef.current?.reload(); event.stopPropagation(); }} /> ) : ( )} } /> { setSupplierVO(supplierVO); actionRef.current?.reload(); }} trigger={ {supplierVO?.name || (type === "PRODUCTION_PURCHASE" ? "瓜农" : "档口")} {supplierVO?.name ? ( { setSupplierVO(undefined); actionRef.current?.reload(); event.stopPropagation(); }} /> ) : ( )} } /> ), actions: [ create && ( { Taro.navigateTo({ url: buildUrl(purchase.path[type].create), }); }} > 新建采购单 ), ], }; return ( rowId={"orderId"} itemHeight={182} type={"infinite"} actionRef={actionRef} render={(orderVO: BusinessAPI.OrderVO, index) => { return ( ); }} toolbar={toolbar} request={async (params) => { const { data: { data, success, notEmpty }, } = await business.order.pageOrder({ orderPageQry: { ...params, ...bizParams, dealerId: dealerVO?.dealerId, supplierId: supplierVO?.supplierId, }, }); return { data, success, hasMore: notEmpty, }; }} pagination={{ pageSize: 10, }} /> ); }