import { ActionType, DealerPicker, Icon, PageList, PurchaseOrderRejectApprove, PurchaseOrderRejectFinal, PurchaseOrderWithdrawReview, State, ToolBar, } from "@/components"; import Taro, { useShareAppMessage } from "@tarojs/taro"; import { useRef, useState } from "react"; import { business } from "@/services"; import hocAuth from "@/hocs/auth"; import { CommonComponent } from "@/types/typings"; import { Label, Text, View } from "@tarojs/components"; import { buildUrl, formatCurrency, PurchaseOrderCalculator } from "@/utils"; import { Button } from "@nutui/nutui-react-taro"; import purchaseOrder from "@/constant/purchaseOrder"; import dayjs from "dayjs"; export default hocAuth(function Page(props: CommonComponent) { const { userRoleVO, shareOptions } = props; const [state, setState] = useState(); const [dealerVO, setDealerVO] = useState(); const actionRef = useRef(); const toolbar: ToolBar = { search: { activeKey: "vehicleNo", defaultActiveKey: "vehicleNo", items: [ { key: "vehicleNo", name: "车次号", placeholder: "请输入车次号", }, { key: "plate", name: "车牌号", placeholder: "请输入车牌号", }, { key: "supplierName", name: "瓜农姓名", placeholder: "请输入瓜农姓名", }, ], }, tabs: { activeKey: "state", defaultActiveKey: state || "ALL", items: purchaseOrder.stateList.filter((item) => { if (userRoleVO.slug === "reviewer") { return item.value !== "DRAFT"; } return item; }), onChange: (item) => { setState(item as BusinessAPI.PurchaseOrderPageQry["state"]); actionRef.current?.reload(); }, }, render: () => ( { setDealerVO(dealerVO); actionRef.current?.reload(); }} trigger={ {dealerVO?.shortName || "经销商"} {dealerVO?.shortName ? ( { setDealerVO(undefined); actionRef.current?.reload(); event.stopPropagation(); }} /> ) : ( )} } /> ), actions: [ userRoleVO.slug === "origin-entry" && ( { Taro.navigateTo({ url: buildUrl("/pages/purchase/purchaser/create"), }); }} > 新建采购单 ), ], }; useShareAppMessage((res) => { console.log("useShareAppMessage1", res, shareOptions); // 如果是按钮触发的转发,使用默认配置 if (res.from === "button") { return shareOptions; } // 页面转发使用设置的配置 return {}; }); return ( rowId={"purchaseOrderId"} itemHeight={182} type={"infinite"} actionRef={actionRef} render={(purchaseOrderVO: BusinessAPI.PurchaseOrderVO, index) => { const calculator = new PurchaseOrderCalculator(purchaseOrderVO); return ( { if (purchaseOrderVO.active === 7) { Taro.navigateTo({ url: buildUrl("/pages/purchase/purchaser/preview", { orderId: purchaseOrderVO.orderId, }), }); event.stopPropagation(); } }} > {/* 复制 */} {purchaseOrderVO.orderVehicle?.vehicleNo ? "第" + purchaseOrderVO.orderVehicle?.vehicleNo + "车" : "暂未生成车次"} {purchaseOrderVO.orderSn} {purchaseOrderVO.createdByName} {dayjs(purchaseOrderVO.createdAt).format("MM-DD HH:mm")} {purchaseOrderVO.orderVehicle?.origin} {"->"} {purchaseOrderVO.orderVehicle?.destination} {purchaseOrderVO.orderVehicle.dealerName} {purchaseOrderVO.orderVehicle?.plate} {purchaseOrderVO.orderSupplierList.length} 位 毛重 {formatCurrency(calculator.getTotalGrossWeight())}{" "} 斤 / 净重{" "} {formatCurrency(calculator.getTotalNetWeight())} 斤 {userRoleVO.slug === "boss" && ( {purchaseOrderVO.state === "WAITING_APPROVE" && ( { actionRef.current?.reload(); }} /> )} )} {userRoleVO.slug === "reviewer" && ( {purchaseOrderVO.state === "WAITING_AUDIT" && ( { actionRef.current?.reload(); }} /> )} {purchaseOrderVO.state === "WAITING_APPROVE" && ( )} )} {userRoleVO.slug === "origin-entry" && ( {purchaseOrderVO.state === "DRAFT" && ( {purchaseOrderVO.active === 7 && ( )} )} {purchaseOrderVO.state === "WAITING_AUDIT" && ( { actionRef.current?.reload(); }} /> )} )} ); }} toolbar={toolbar} request={async (params) => { const { data: { data, success, notEmpty }, } = await business.purchaseOrder.pagePurchaseOrder({ purchaseOrderPageQry: { ...params, //@ts-ignore state: state !== "ALL" ? state : undefined, ...(dealerVO ? { dealerId: dealerVO.dealerId, } : {}), }, }); return { data, success, hasMore: notEmpty, }; }} pagination={{ pageSize: 10, }} /> ); });