- 在MelonFarmer组件中新增supplierCount属性用于判断是否显示拼车选项 - 修改"是否为最后一个瓜农"为"是否要拼车"的逻辑与文案 - 更新多个图标引用,包括新增address-book图标 - 调整输入框样式,增加图标前缀提升用户体验 - 优化称重信息页面的提示文字,使其更清晰易懂 - 增加OrderPackage相关类型定义及转换工具函数 - 更新页面审核和创建流程中的样式与交互逻辑 - 升级iconfont字体文件版本,支持新图标 - 修复部分组件样式问题,如SupplierList底部间距等
128 lines
3.7 KiB
TypeScript
128 lines
3.7 KiB
TypeScript
import { Popup, SafeArea, SearchBar } from "@nutui/nutui-react-taro";
|
|
import { Icon } from "@/components";
|
|
import { ScrollView, View } from "@tarojs/components";
|
|
import React, { useEffect, useState } from "react";
|
|
import { business } from "@/services";
|
|
import { SupplierVO } from "@/types/typings";
|
|
|
|
interface ISupplierPickerProps {
|
|
trigger?: React.ReactNode;
|
|
onFinish: (supplierVO: SupplierVO) => void;
|
|
}
|
|
|
|
export default function SupplierPicker(props: ISupplierPickerProps) {
|
|
const { onFinish, trigger } = props;
|
|
|
|
const [supplierVO, setSupplierVO] = useState<SupplierVO>();
|
|
const [visible, setVisible] = useState(false);
|
|
const [supplierList, setSupplierList] = useState<SupplierVO[]>();
|
|
const [searchText, setSearchText] = useState("");
|
|
|
|
useEffect(() => {
|
|
if (visible) {
|
|
handleSearch().then();
|
|
}
|
|
}, [visible]);
|
|
|
|
const handleSearch = async (value?: string) => {
|
|
const { data } = await business.supplier.listSupplier({
|
|
supplierListQry: {
|
|
name: value || undefined,
|
|
status: true
|
|
},
|
|
});
|
|
|
|
let supplierList = data?.data;
|
|
setSupplierList(supplierList as any);
|
|
};
|
|
|
|
return (
|
|
<View>
|
|
<View
|
|
onClick={(event) => {
|
|
setVisible(true);
|
|
event.stopPropagation();
|
|
}}
|
|
>
|
|
{trigger}
|
|
</View>
|
|
|
|
{/* 选择瓜农 */}
|
|
<Popup
|
|
closeable
|
|
destroyOnClose
|
|
duration={150}
|
|
visible={visible}
|
|
title="选择瓜农"
|
|
position="bottom"
|
|
onClose={async () => {
|
|
if (visible) {
|
|
setSupplierVO(undefined)
|
|
setSearchText("");
|
|
setVisible(false);
|
|
} else if (supplierVO) {
|
|
onFinish(supplierVO);
|
|
}
|
|
}}
|
|
>
|
|
<SearchBar
|
|
className={"!px-2.5 !py-1"}
|
|
placeholder="请输入瓜农名称搜索"
|
|
value={searchText}
|
|
onChange={(value) => setSearchText(value)}
|
|
onSearch={handleSearch}
|
|
onClear={() => handleSearch("")}
|
|
/>
|
|
<ScrollView scrollY className="h-96">
|
|
<View className={"flex flex-col px-2.5"}>
|
|
{supplierList?.length === 0 && (
|
|
<View className={"flex flex-col items-center gap-2 p-5"}>
|
|
<View className={"text-sm"}>未找到匹配的瓜农</View>
|
|
</View>
|
|
)}
|
|
{supplierList?.map((item) => (
|
|
<View
|
|
className={
|
|
"flex flex-row items-center justify-between gap-2 border-b border-gray-100 p-4"
|
|
}
|
|
key={item.supplierId}
|
|
onClick={async () => {
|
|
setSupplierVO(item);
|
|
setSearchText("")
|
|
setVisible(false);
|
|
}}
|
|
>
|
|
<View className={"flex flex-1 flex-col gap-1"}>
|
|
<View className={"text-base font-medium"}>{item.name}</View>
|
|
</View>
|
|
|
|
<Icon name={"chevron-right"} size={16} />
|
|
</View>
|
|
))}
|
|
</View>
|
|
</ScrollView>
|
|
|
|
{/*<View className={"p-3"}>*/}
|
|
{/* <Button*/}
|
|
{/* type={"primary"}*/}
|
|
{/* block*/}
|
|
{/* fill={"none"}*/}
|
|
{/* size={"large"}*/}
|
|
{/* onClick={() => {*/}
|
|
{/* Taro.navigateTo({*/}
|
|
{/* url: "/pages/community/choose/index",*/}
|
|
{/* success: () => {*/}
|
|
{/* setVisible(false);*/}
|
|
{/* },*/}
|
|
{/* });*/}
|
|
{/* }}*/}
|
|
{/* >*/}
|
|
{/* 加入新小区*/}
|
|
{/* </Button>*/}
|
|
{/*</View>*/}
|
|
<SafeArea position={"bottom"} />
|
|
</Popup>
|
|
</View>
|
|
);
|
|
}
|