refactor(utils): 重构工具函数导入路径
- 统一从 utils 目录导入工具函数,而非具体的子文件 - 更新了 uploadFile, buildUrl, formatCurrency 等函数的导入路径 - 修改 CustomTabBar 组件接收 userRoleVO 对象而非 role 字符串 - 调整金额格式化相关工具函数的引用方式 - 更新文档中项目结构和费用管理相关说明 - 优化用户角色权限相关的数据传递逻辑
This commit is contained in:
parent
0adce7ac3e
commit
d37626d5bf
@ -18,7 +18,7 @@ trigger: manual
|
||||
|
||||
```tsx
|
||||
import { Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
||||
import { uploadFile } from "@/utils/uploader";
|
||||
import { uploadFile } from "@/utils";
|
||||
```
|
||||
|
||||
### 2. 基本属性
|
||||
@ -228,7 +228,7 @@ useEffect(() => {
|
||||
import { View } from "@tarojs/components";
|
||||
import { Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
||||
import { useState, useEffect } from "react";
|
||||
import { uploadFile } from "@/utils/uploader";
|
||||
import { uploadFile } from "@/utils";
|
||||
|
||||
export default function UploadExample() {
|
||||
// 头像上传状态
|
||||
|
||||
@ -48,6 +48,10 @@ src/
|
||||
├── services/ # API服务层
|
||||
├── store/ # 状态管理
|
||||
├── utils/ # 工具函数
|
||||
│ ├── format.ts # 通用格式化工具(日期、距离、金额等)
|
||||
│ ├── amount.ts # 金额处理工具(去除小数后多余零)
|
||||
│ ├── date.ts # 日期处理工具
|
||||
│ └── ... # 其他工具函数
|
||||
└── types/ # TypeScript类型定义
|
||||
```
|
||||
|
||||
@ -104,12 +108,17 @@ src/
|
||||
- 供应商资质管理
|
||||
- 采购历史关联
|
||||
|
||||
3. **交付管理**:
|
||||
3. **费用管理**:
|
||||
- 采购费用计算和展示
|
||||
- 金额格式化处理(去除小数点后多余零)
|
||||
- 多种费用类型的统一处理
|
||||
|
||||
4. **交付管理**:
|
||||
- 交付单创建和管理
|
||||
- 配送状态跟踪
|
||||
- 交付确认和验收
|
||||
|
||||
4. **用户权限**:
|
||||
5. **用户权限**:
|
||||
- 基于角色的访问控制(RBAC)
|
||||
- 功能权限动态分配
|
||||
- 多角色身份支持
|
||||
@ -120,6 +129,8 @@ src/
|
||||
|
||||
### 数据模型关键概念
|
||||
- **采购单**: 采购业务的核心实体,包含商品、数量、价格、供应商等信息
|
||||
- **金额格式**: 统一的金额展示格式(0.00→0, 0.10→0.1, 10.00→10, 10.01→10.01)
|
||||
- **费用计算**: 采购过程中各类费用的计算和展示逻辑
|
||||
- **角色权限**: 采购员、审核员、审批员等不同角色的操作权限
|
||||
- **状态流转**: 采购单从创建到完成的完整生命周期管理
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { PropsWithChildren } from "react";
|
||||
import Taro, { useLaunch } from "@tarojs/taro";
|
||||
import dayjs from "dayjs";
|
||||
import { RouteGuard } from "@/utils/routeGuard";
|
||||
import { RouteGuard } from "@/utils";
|
||||
import "dayjs/locale/zh-cn";
|
||||
import "./app.css";
|
||||
import "./iconfont.css";
|
||||
|
||||
@ -6,11 +6,11 @@ import { globalStore } from "@/store/global-store";
|
||||
import { CustomTheme, Icon } from "@/components";
|
||||
|
||||
interface ICustomTabBarProps {
|
||||
role: AuthAPI.UserRoleVO["slug"];
|
||||
userRoleVO: AuthAPI.UserRoleVO;
|
||||
}
|
||||
|
||||
export default function CustomTabBar(props: ICustomTabBarProps) {
|
||||
const { role } = props;
|
||||
const { userRoleVO } = props;
|
||||
const { tabBar, setTabBar } = globalStore((state: any) => state);
|
||||
const [scaleFactor, setScaleFactor] = useState(1);
|
||||
|
||||
@ -67,7 +67,7 @@ export default function CustomTabBar(props: ICustomTabBarProps) {
|
||||
text: "我的",
|
||||
},
|
||||
];
|
||||
}, [scaleFactor, role]);
|
||||
}, [scaleFactor, userRoleVO]);
|
||||
|
||||
useEffect(() => {
|
||||
const selected = tabBarList.findIndex((item) => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Button, ButtonSize, Dialog, Toast } from "@nutui/nutui-react-taro";
|
||||
import { business } from "@/services";
|
||||
import Taro from "@tarojs/taro";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl } from "@/utils";
|
||||
|
||||
interface IPurchaseOrderSubmitReviewProps {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
@ -110,7 +110,7 @@ export default function PurchaseOrderSubmitReview(
|
||||
(supplier) => !supplier.contractUpload,
|
||||
);
|
||||
|
||||
console.log("hasNoUpdateContractSupplier", hasNoUpdateContractSupplier)
|
||||
console.log("hasNoUpdateContractSupplier", hasNoUpdateContractSupplier);
|
||||
|
||||
if (hasNoUpdateContractSupplier) {
|
||||
Dialog.open("dialog", {
|
||||
|
||||
@ -11,9 +11,8 @@ import {
|
||||
import { Icon, SupplierPicker } from "@/components";
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||
import { SupplierVO } from "@/types/typings";
|
||||
import { uploadFile } from "@/utils/uploader";
|
||||
import { buildUrl, uploadFile } from "@/utils";
|
||||
import Taro from "@tarojs/taro";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { business } from "@/services";
|
||||
|
||||
// 定义ref暴露的方法接口
|
||||
|
||||
@ -19,11 +19,11 @@ import {
|
||||
CostItem,
|
||||
SupplierVO,
|
||||
} from "@/types/typings";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import {
|
||||
convertBoxBrandToOrderPackages,
|
||||
convertOrderPackagesToBoxBrands,
|
||||
} from "@/utils/orderPackage";
|
||||
generateShortId,
|
||||
} from "@/utils";
|
||||
import classNames from "classnames";
|
||||
import { Decimal } from "decimal.js";
|
||||
|
||||
|
||||
@ -13,11 +13,11 @@ import classNames from "classnames";
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||
import { business } from "@/services";
|
||||
import { BoxBrand, BoxProduct, BoxSpec, SupplierVO } from "@/types/typings";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import {
|
||||
convertBoxBrandToOrderPackages,
|
||||
convertOrderPackagesToBoxBrands,
|
||||
} from "@/utils/orderPackage";
|
||||
generateShortId,
|
||||
} from "@/utils";
|
||||
|
||||
// 定义ref暴露的方法接口
|
||||
export interface OrderPackageRef {
|
||||
|
||||
@ -14,8 +14,7 @@ import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||
import dayjs from "dayjs";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { business } from "@/services";
|
||||
import { validatePrice as validatePrice1 } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import { generateShortId, validatePrice as validatePrice1 } from "@/utils";
|
||||
import { CostItem } from "@/types/typings";
|
||||
|
||||
interface IOrderVehicleProps {
|
||||
|
||||
@ -2,9 +2,11 @@ import { View } from "@tarojs/components";
|
||||
import { CostItem, SupplierVO } from "@/types/typings";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Table, TableColumnProps } from "@nutui/nutui-react-taro";
|
||||
import { formatCurrency } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
import { OrderSupplierCalculator } from "@/utils/OrderSupplierCalculator";
|
||||
import {
|
||||
formatCurrency,
|
||||
OrderSupplierCalculator,
|
||||
PurchaseOrderCalculator,
|
||||
} from "@/utils";
|
||||
|
||||
interface IPurchasePreviewProps {
|
||||
purchaseOrder: BusinessAPI.PurchaseOrderCreateCmd;
|
||||
|
||||
@ -3,7 +3,7 @@ import { Icon } from "@/components";
|
||||
import { SupplierVO } from "@/types/typings";
|
||||
import { Price, Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { uploadFile } from "@/utils/uploader";
|
||||
import { uploadFile } from "@/utils";
|
||||
|
||||
interface ITicketUploadProps {
|
||||
value: SupplierVO;
|
||||
|
||||
@ -12,8 +12,7 @@ import {
|
||||
import { Icon } from "@/components";
|
||||
import { SupplierVO } from "@/types/typings";
|
||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||
import { uploadFile } from "@/utils/uploader";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { uploadFile, validatePrice } from "@/utils";
|
||||
import { business } from "@/services";
|
||||
|
||||
// 定义ref暴露的方法接口
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { ScrollView, Text, View } from "@tarojs/components";
|
||||
import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import dayjs from "dayjs";
|
||||
import { formatCurrency } from "@/utils/format";
|
||||
import { formatCurrency } from "@/utils";
|
||||
import { useEffect, useState } from "react";
|
||||
import businessServices from "@/services/business";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||
|
||||
export default function CostDifferenceSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { Table, TableColumnProps } from "@nutui/nutui-react-taro";
|
||||
import { formatCurrency } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
import { formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function CostSummarySection(props: {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { formatCurrency, validatePrice } from "@/utils";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
@ -8,8 +8,7 @@ import {
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Icon } from "@/components";
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import { formatCurrency, generateShortId, validatePrice } from "@/utils";
|
||||
|
||||
export default function LaborInfoSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
export default function MarketPriceSection(props: {
|
||||
|
||||
@ -7,8 +7,7 @@ import {
|
||||
SafeArea,
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import { generateShortId, validatePrice } from "@/utils";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
export default function MaterialCostSection(props: {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { formatCurrency, validatePrice } from "@/utils";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
@ -8,8 +8,7 @@ import {
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Icon } from "@/components";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import { generateShortId, validatePrice } from "@/utils";
|
||||
|
||||
export default function PackagingCostSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
|
||||
@ -8,8 +8,7 @@ import {
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Icon } from "@/components";
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import { formatCurrency, generateShortId, validatePrice } from "@/utils";
|
||||
|
||||
export default function ProductionAdvanceSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { formatCurrency, validatePrice } from "@/utils";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { ScrollView, Text, View } from "@tarojs/components";
|
||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||
import { business } from "@/services";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
export default function RebateCalcSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
|
||||
@ -9,7 +9,7 @@ import {
|
||||
import { View } from "@tarojs/components";
|
||||
import { useState } from "react";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { uploadFile } from "@/utils/uploader";
|
||||
import { uploadFile } from "@/utils";
|
||||
import { Icon } from "@/components";
|
||||
|
||||
export default function SupplierInfoSection(props: {
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||
|
||||
export default function TaxProvisionSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||
import { validatePrice } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||
|
||||
export default function TaxSubsidySection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
|
||||
@ -8,8 +8,7 @@ import {
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Icon } from "@/components";
|
||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import { formatCurrency, generateShortId, validatePrice } from "@/utils";
|
||||
|
||||
export default function WorkerAdvanceSection(props: {
|
||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
|
||||
@ -5,7 +5,7 @@ import { Loading, Overlay } from "@nutui/nutui-react-taro";
|
||||
import { View } from "@tarojs/components";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Taro from "@tarojs/taro";
|
||||
import buildParams from "@/utils/buildParams";
|
||||
import { buildParams } from "@/utils";
|
||||
import { globalStore } from "@/store/global-store";
|
||||
|
||||
const hocAuth = (
|
||||
@ -16,7 +16,7 @@ const hocAuth = (
|
||||
base((props: any) => {
|
||||
const { options, router } = props;
|
||||
const user = userStore(useShallow((state) => state.user));
|
||||
const { role, setRole } = globalStore((state: any) => state);
|
||||
const { userRoleVO, setUserRoleVO } = globalStore((state: any) => state);
|
||||
|
||||
const [longitude, setLongitude] = useState<number>();
|
||||
const [latitude, setLatitude] = useState<number>();
|
||||
@ -26,7 +26,7 @@ const hocAuth = (
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setRole(Taro.getStorageSync("userRoleVO").slug || "origin-entry");
|
||||
setUserRoleVO(Taro.getStorageSync("userRoleVO"));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@ -87,7 +87,7 @@ const hocAuth = (
|
||||
}, [user]);
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
if (!user || !userRoleVO) {
|
||||
if (skeleton) {
|
||||
return skeleton;
|
||||
}
|
||||
@ -119,8 +119,7 @@ const hocAuth = (
|
||||
longitude={longitude}
|
||||
latitude={latitude}
|
||||
user={user}
|
||||
role={role}
|
||||
setRole={setRole}
|
||||
userRoleVO={userRoleVO}
|
||||
isInitialized={isInitialized}
|
||||
setIsInitialized={setIsInitialized}
|
||||
setLoading={setLoading}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import Taro, { useDidHide, useReady, useUnload } from "@tarojs/taro";
|
||||
import { reporter } from "@/utils/reporter";
|
||||
import { reporter } from "@/utils";
|
||||
import { SWRConfig } from "swr";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { userStore } from "@/store/user-store";
|
||||
|
||||
@ -8,14 +8,13 @@ import Taro from "@tarojs/taro";
|
||||
import classNames from "classnames";
|
||||
import { business, poster } from "@/services";
|
||||
import dayjs from "dayjs";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl, PdfTemplate } from "@/utils";
|
||||
import {
|
||||
DeliveryStep1Form,
|
||||
DeliveryStep1FormRef,
|
||||
DeliveryStep2Preview,
|
||||
DeliveryStep3Success,
|
||||
} from "@/components";
|
||||
import { PdfTemplate } from "@/utils/PdfTemplate";
|
||||
|
||||
// 特殊处理:其他费用要实时获取费用项目
|
||||
const updateOtherFeesModule = async (
|
||||
|
||||
@ -7,7 +7,7 @@ import shipOrder from "@/constant/shipOrder";
|
||||
import Taro from "@tarojs/taro";
|
||||
import classNames from "classnames";
|
||||
import { business, poster } from "@/services";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl, PdfTemplate, PurchaseOrderCalculator } from "@/utils";
|
||||
import {
|
||||
Icon,
|
||||
PurchaseStep1Form,
|
||||
@ -15,7 +15,6 @@ import {
|
||||
PurchaseStep2Preview,
|
||||
PurchaseStep3Success,
|
||||
} from "@/components";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router, setLoading } = props;
|
||||
@ -111,7 +110,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
|
||||
// 截图预览内容
|
||||
const capturePreview = async () => {
|
||||
const template = new Template(moduleList);
|
||||
const template = new PdfTemplate(moduleList);
|
||||
console.log("generateHtmlString", template.generateHtmlString());
|
||||
const { data } = await poster.pdf.postApiV1Pdf({
|
||||
html: template.generateHtmlString(),
|
||||
|
||||
@ -12,7 +12,7 @@ import { business } from "@/services";
|
||||
import hocAuth from "@/hocs/auth";
|
||||
import { CommonComponent } from "@/types/typings";
|
||||
import { Label, Text, View } from "@tarojs/components";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl } from "@/utils";
|
||||
import dayjs from "dayjs";
|
||||
import shipOrder from "@/constant/shipOrder";
|
||||
import { Button, Popup, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
||||
|
||||
@ -6,22 +6,20 @@ import { auth } from "@/services";
|
||||
import { Button, Dialog, Image, Popup, Toast } from "@nutui/nutui-react-taro";
|
||||
import dayjs from "dayjs";
|
||||
import Taro from "@tarojs/taro";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { uploadFile } from "@/utils/uploader";
|
||||
import { buildUrl, uploadFile } from "@/utils";
|
||||
import { globalStore } from "@/store/global-store";
|
||||
import { APP_VERSION } from "@/constant";
|
||||
import { CustomTabBar, Icon } from "@/components";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { user, role } = props;
|
||||
const setRole = globalStore((state: any) => state.setRole);
|
||||
const { user, userRoleVO } = props;
|
||||
console.log("userRoleVO", userRoleVO);
|
||||
const setUserRoleVO = globalStore((state: any) => state.setUserRoleVO);
|
||||
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [employeeVO, setEmployeeVO] = useState<AuthAPI.EmployeeVO>();
|
||||
const [userRoleVOList, setUserRoleVOList] = useState<AuthAPI.UserRoleVO[]>();
|
||||
|
||||
const [userRoleVO, setUserRoleVO] = useState<AuthAPI.UserRoleVO>();
|
||||
|
||||
const [channel, setChannel] = useState<BusinessAPI.ChannelVO>();
|
||||
|
||||
const initChannel = async () => {
|
||||
@ -38,6 +36,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
} = await auth.user.userEmployee({
|
||||
employeeShowQry: {
|
||||
userId: user.userId,
|
||||
platformId: "1991353387274342401",
|
||||
},
|
||||
});
|
||||
|
||||
@ -67,8 +66,8 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}
|
||||
|
||||
// 处理角色切换
|
||||
const handleRoleSelect = (role: AuthAPI.UserRoleVO) => {
|
||||
setUserRoleVO(role);
|
||||
const handleRoleSelect = (userRoleVO: AuthAPI.UserRoleVO) => {
|
||||
setUserRoleVO(userRoleVO);
|
||||
};
|
||||
|
||||
// 选择图片函数
|
||||
@ -140,7 +139,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
const handleConfirmSwitch = () => {
|
||||
if (userRoleVO) {
|
||||
Taro.setStorageSync("userRoleVO", userRoleVO);
|
||||
setRole(userRoleVO.slug);
|
||||
setUserRoleVO(userRoleVO);
|
||||
setVisible(false);
|
||||
|
||||
Toast.show("toast", {
|
||||
@ -327,7 +326,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
© {dayjs().format("YYYY")} {channel?.technicalSupport} 版权所有
|
||||
</Text>
|
||||
</View>
|
||||
<CustomTabBar role={role} />
|
||||
<CustomTabBar userRoleVO={userRoleVO} />
|
||||
|
||||
{/* 选择身份 */}
|
||||
<Popup
|
||||
@ -347,17 +346,17 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}}
|
||||
>
|
||||
<View className={"mb-4 flex flex-col px-2.5"}>
|
||||
{userRoleVOList?.map((role) => (
|
||||
{userRoleVOList?.map((item) => (
|
||||
<View
|
||||
key={role.roleId}
|
||||
className={`role-item rounded-lg p-3 ${userRoleVO?.roleId === role.roleId ? "bg-primary/10 border-primary border" : ""}`}
|
||||
onClick={() => handleRoleSelect(role)}
|
||||
key={item.roleId}
|
||||
className={`role-item rounded-lg p-3 ${item?.slug === userRoleVO.slug ? "bg-primary/10 border-primary border" : ""}`}
|
||||
onClick={() => handleRoleSelect(item)}
|
||||
>
|
||||
<View className="flex items-center justify-between">
|
||||
<View>
|
||||
<View className="font-medium">{role.name}</View>
|
||||
<View className="font-medium">{item.name}</View>
|
||||
<View className="text-xs text-gray-500">
|
||||
{role.description || "暂无描述"}
|
||||
{item.description || "暂无描述"}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@ -4,25 +4,26 @@ import { View } from "@tarojs/components";
|
||||
import { CustomTabBar, Icon, IconNames } from "@/components";
|
||||
import workbench from "@/constant/workbench";
|
||||
import Taro from "@tarojs/taro";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl } from "@/utils";
|
||||
import { useEffect, useState } from "react";
|
||||
import { business } from "@/services";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { role } = props;
|
||||
const { userRoleVO } = props;
|
||||
const { slug } = userRoleVO;
|
||||
const [reviewCards, setReviewCards] = useState(
|
||||
workbench.reviewCardMap[role] || [],
|
||||
workbench.reviewCardMap[slug] || [],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
Taro.setNavigationBarTitle({
|
||||
title: workbench.roleSlugMap[role] + "工作台",
|
||||
title: workbench.roleSlugMap[slug] + "工作台",
|
||||
});
|
||||
|
||||
setReviewCards(workbench.reviewCardMap[role] || []);
|
||||
setReviewCards(workbench.reviewCardMap[slug] || []);
|
||||
// 获取草稿数量
|
||||
if (
|
||||
(role === "origin-entry" || role === "market-buyer") &&
|
||||
(slug === "origin-entry" || slug === "market-buyer") &&
|
||||
reviewCards.some((card) => card.id === "draftPurchase")
|
||||
) {
|
||||
business.purchaseOrder
|
||||
@ -42,13 +43,13 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [role]);
|
||||
}, [userRoleVO]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<View className="flex flex-1 flex-col gap-2.5 p-2.5">
|
||||
{/* 新建采购单按钮 */}
|
||||
{role === "origin-entry" && (
|
||||
{slug === "origin-entry" && (
|
||||
<View>
|
||||
<View
|
||||
className="bg-primary flex w-full flex-col items-center justify-center space-y-2 rounded-xl py-2.5 text-white"
|
||||
@ -70,40 +71,12 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 数据概览卡片 */}
|
||||
{reviewCards?.length > 0 && (
|
||||
<View className="overflow-x-auto">
|
||||
<View className="flex space-x-3" style="width: max-content;">
|
||||
{/* 循环渲染审核卡片 */}
|
||||
{reviewCards.map((card) => (
|
||||
<View
|
||||
key={card.id}
|
||||
className="w-32 flex-shrink-0 rounded-lg bg-white p-2.5 shadow-sm"
|
||||
>
|
||||
<View className="flex items-center justify-between">
|
||||
<View className="text-sm text-gray-500">{card.title}</View>
|
||||
<Icon name={card.icon} color={card.iconColor} size={12} />
|
||||
</View>
|
||||
<View className="mt-2">
|
||||
<View className="text-2xl font-bold text-gray-800">
|
||||
{card.count}
|
||||
</View>
|
||||
<View className="mt-1 text-xs text-gray-500">
|
||||
{card.unit}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
|
||||
{/* 快捷功能入口 */}
|
||||
{workbench.quickActionMap?.[role]?.length > 0 && (
|
||||
{workbench.quickActionMap?.[slug]?.length > 0 && (
|
||||
<View>
|
||||
<View className="grid grid-cols-4 gap-3">
|
||||
{/* 循环渲染快捷功能 */}
|
||||
{workbench.quickActionMap[role].map((action) => (
|
||||
{workbench.quickActionMap[slug].map((action) => (
|
||||
<View
|
||||
key={action.id}
|
||||
className="rounded-xl bg-white p-3 text-center shadow-sm"
|
||||
@ -130,7 +103,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
<CustomTabBar role={role} />
|
||||
<CustomTabBar userRoleVO={userRoleVO} />
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
@ -1,13 +1,97 @@
|
||||
import hocAuth from "@/hocs/auth";
|
||||
import { CommonComponent } from "@/types/typings";
|
||||
import { CustomTabBar } from "@/components";
|
||||
import { CustomTabBar, Icon, IconNames } from "@/components";
|
||||
import { useEffect, useState } from "react";
|
||||
import { auth } from "@/services";
|
||||
import { Text, View } from "@tarojs/components";
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { role } = props;
|
||||
const { userRoleVO } = props;
|
||||
|
||||
const [menuList, setMenuList] = useState<any[]>();
|
||||
|
||||
const initMenuList = async (roleIdList: string[]) => {
|
||||
const {
|
||||
data: { data: menuTree },
|
||||
} = await auth.user.userMenu({
|
||||
roleMenuTreeQry: {
|
||||
roleId: roleIdList,
|
||||
platformId: "1991353387274342401",
|
||||
},
|
||||
});
|
||||
setMenuList(menuTree);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
initMenuList([userRoleVO.roleId]).then();
|
||||
}, [userRoleVO]);
|
||||
|
||||
const handleMenuClick = (menu: BusinessAPI.MenuVO) => {
|
||||
if (menu.path) {
|
||||
Taro.navigateTo({
|
||||
url: menu.path,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const renderMenuTree = (
|
||||
menus: BusinessAPI.MenuVO[] | undefined,
|
||||
level = 0,
|
||||
) => {
|
||||
if (!menus || menus.length === 0) return null;
|
||||
|
||||
console.log("level", level);
|
||||
if (level === 1) {
|
||||
return (
|
||||
<View className="grid grid-cols-4">
|
||||
{menus.map((menu) => (
|
||||
<View
|
||||
key={menu.menuId}
|
||||
className="rounded-xl bg-white text-center"
|
||||
onClick={() => handleMenuClick(menu)}
|
||||
>
|
||||
<View
|
||||
className={`icon-container m-2 mx-auto flex h-10 w-10 items-center justify-center rounded-lg`}
|
||||
style={{ backgroundColor: `rgb(${menu.bgColorClass})` }}
|
||||
>
|
||||
<Icon
|
||||
name={menu.icon?.replace("icon-", "") as IconNames}
|
||||
color={`rgb(${menu.iconColor})`}
|
||||
/>
|
||||
</View>
|
||||
<View className={`text-xs text-gray-700`}>{menu.name}</View>
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className={"flex flex-col gap-2.5"}>
|
||||
{menus.map((menu) => (
|
||||
<View
|
||||
key={menu.menuId}
|
||||
className={`flex flex-col gap-2.5 level-${level}`}
|
||||
>
|
||||
<View className="">
|
||||
<Text className="menu-name">{menu.name}</Text>
|
||||
</View>
|
||||
{menu.routes && menu.routes.length > 0 && (
|
||||
<View className="rounded-md bg-white p-2.5 shadow-md">
|
||||
{renderMenuTree(menu.routes as BusinessAPI.MenuVO[], level + 1)}
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
))}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<CustomTabBar role={role} />
|
||||
<View className="p-2.5">{renderMenuTree(menuList)}</View>
|
||||
<CustomTabBar userRoleVO={userRoleVO} />
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
@ -6,9 +6,7 @@ import { Button } from "@nutui/nutui-react-taro";
|
||||
import { useState } from "react";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { role } = props;
|
||||
|
||||
console.log("role", role);
|
||||
const { userRoleVO } = props;
|
||||
|
||||
const [activeTab, setActiveTab] = useState<"todo" | "done" | "message">(
|
||||
"message",
|
||||
@ -367,7 +365,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
{activeTab === "done" && renderDoneList()}
|
||||
{activeTab === "message" && renderMessageList()}
|
||||
</View>
|
||||
<CustomTabBar role={role} />
|
||||
<CustomTabBar userRoleVO={userRoleVO} />
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import Taro, { useReady, getCurrentInstance } from "@tarojs/taro";
|
||||
import { View, Camera, Canvas, Button, Image } from "@tarojs/components";
|
||||
import Taro, { getCurrentInstance, useReady } from "@tarojs/taro";
|
||||
import { Button, Camera, Canvas, Image, View } from "@tarojs/components";
|
||||
import { useState } from "react";
|
||||
import { ocrAction } from "@/utils/ocr";
|
||||
import { ocrAction } from "@/utils";
|
||||
import ScanCode_FlashClose from "../../../resources/ScanCode_FlashClose@3x.png";
|
||||
import ScanCode_Flash from "../../../resources/ScanCode_Flash@3x.png";
|
||||
import ScanCode_Frame from "../../../resources/ScanCode_Frame.png";
|
||||
|
||||
@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
|
||||
import auth from "@/services/auth";
|
||||
import { userStore } from "@/store/user-store";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { aesEncrypt } from "@/utils/aes";
|
||||
import { aesEncrypt } from "@/utils";
|
||||
import Captcha from "@/components/captcha";
|
||||
import { Image, Text, View } from "@tarojs/components";
|
||||
import base from "@/hocs/base";
|
||||
|
||||
@ -9,9 +9,12 @@ import {
|
||||
PurchaseOrderFinalApprove,
|
||||
PurchaseOrderRejectFinal,
|
||||
} from "@/components";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { formatCurrency, formatUnitPrice } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
import {
|
||||
buildUrl,
|
||||
formatCurrency,
|
||||
formatUnitPrice,
|
||||
PurchaseOrderCalculator,
|
||||
} from "@/utils";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router, isInitialized, setIsInitialized } = props;
|
||||
|
||||
@ -10,12 +10,10 @@ import { business } from "@/services";
|
||||
import hocAuth from "@/hocs/auth";
|
||||
import { CommonComponent } from "@/types/typings";
|
||||
import { Label, Text, View } from "@tarojs/components";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl, formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||
import { Button } from "@nutui/nutui-react-taro";
|
||||
import purchaseOrder from "@/constant/purchaseOrder";
|
||||
import dayjs from "dayjs";
|
||||
import { formatCurrency } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { shareOptions } = props;
|
||||
|
||||
@ -5,7 +5,7 @@ import { Text, View } from "@tarojs/components";
|
||||
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { business } from "@/services";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl } from "@/utils";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router, setLoading } = props;
|
||||
|
||||
@ -15,15 +15,13 @@ import { business } from "@/services";
|
||||
import hocAuth from "@/hocs/auth";
|
||||
import { CommonComponent } from "@/types/typings";
|
||||
import { Label, Text, View } from "@tarojs/components";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl, formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||
import { Button } from "@nutui/nutui-react-taro";
|
||||
import purchaseOrder from "@/constant/purchaseOrder";
|
||||
import dayjs from "dayjs";
|
||||
import { formatCurrency } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { role, shareOptions } = props;
|
||||
const { userRoleVO, shareOptions } = props;
|
||||
|
||||
const [state, setState] =
|
||||
useState<BusinessAPI.PurchaseOrderPageQry["state"]>();
|
||||
@ -56,7 +54,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
activeKey: "state",
|
||||
defaultActiveKey: state || "ALL",
|
||||
items: purchaseOrder.stateList.filter((item) => {
|
||||
if (role === "reviewer") {
|
||||
if (userRoleVO.slug === "reviewer") {
|
||||
return item.value !== "DRAFT";
|
||||
}
|
||||
|
||||
@ -100,7 +98,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
</View>
|
||||
),
|
||||
actions: [
|
||||
role === "origin-entry" && (
|
||||
userRoleVO.slug === "origin-entry" && (
|
||||
<View className={"flex flex-row gap-2 p-3"} key={"create"}>
|
||||
<View className={"flex-1"}>
|
||||
<View
|
||||
@ -275,7 +273,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
{role === "boss" && (
|
||||
{userRoleVO.slug === "boss" && (
|
||||
<View className={"py-2.5"}>
|
||||
{purchaseOrderVO.state === "WAITING_APPROVE" && (
|
||||
<View className={"flex flex-row justify-end gap-2"}>
|
||||
@ -307,7 +305,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
{role === "reviewer" && (
|
||||
{userRoleVO.slug === "reviewer" && (
|
||||
<View className={"py-2.5"}>
|
||||
{purchaseOrderVO.state === "WAITING_AUDIT" && (
|
||||
<View className={"flex flex-row justify-end gap-2"}>
|
||||
@ -360,7 +358,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
)}
|
||||
</View>
|
||||
)}
|
||||
{role === "origin-entry" && (
|
||||
{userRoleVO.slug === "origin-entry" && (
|
||||
<View className={"py-2.5"}>
|
||||
{purchaseOrderVO.state === "DRAFT" && (
|
||||
<View className={"flex flex-row justify-end gap-2"}>
|
||||
|
||||
@ -26,11 +26,13 @@ import {
|
||||
WeighRef,
|
||||
} from "@/components";
|
||||
import { business } from "@/services";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import {
|
||||
buildUrl,
|
||||
generateShortId,
|
||||
PurchaseOrderCalculator,
|
||||
SupplierWeightCalculator,
|
||||
} from "@/utils";
|
||||
import Taro from "@tarojs/taro";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { SupplierWeightCalculator } from "@/utils/SupplierWeightCalculator";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
const defaultSupplierList: SupplierVO[] = [
|
||||
{
|
||||
@ -61,7 +63,7 @@ const defaultSupplierList: SupplierVO[] = [
|
||||
];
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router, role, setLoading } = props;
|
||||
const { router, userRoleVO, setLoading } = props;
|
||||
|
||||
const [orderId, setOrderId] = useState(
|
||||
router.params.orderId as BusinessAPI.PurchaseOrderShowQry["orderId"],
|
||||
@ -154,7 +156,10 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
.then(({ data: { data: purchaseOrder, success } }) => {
|
||||
if (success && purchaseOrder) {
|
||||
// 如果订单状态不是草稿,则跳转到预览页面
|
||||
if (purchaseOrder.state !== "DRAFT" && role === "origin-entry") {
|
||||
if (
|
||||
purchaseOrder.state !== "DRAFT" &&
|
||||
userRoleVO.slug === "origin-entry"
|
||||
) {
|
||||
Taro.redirectTo({
|
||||
url: buildUrl("/pages/purchase/purchaser/preview", {
|
||||
orderId: purchaseOrder.orderId,
|
||||
|
||||
@ -11,12 +11,10 @@ import { business } from "@/services";
|
||||
import hocAuth from "@/hocs/auth";
|
||||
import { CommonComponent } from "@/types/typings";
|
||||
import { Label, Text, View } from "@tarojs/components";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl, formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||
import { Button } from "@nutui/nutui-react-taro";
|
||||
import purchaseOrder from "@/constant/purchaseOrder";
|
||||
import dayjs from "dayjs";
|
||||
import { formatCurrency } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { shareOptions } = props;
|
||||
|
||||
@ -10,7 +10,7 @@ import {
|
||||
} from "@/components";
|
||||
import { business } from "@/services";
|
||||
import Taro from "@tarojs/taro";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl } from "@/utils";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router } = props;
|
||||
|
||||
@ -5,7 +5,7 @@ import { Text, View } from "@tarojs/components";
|
||||
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { business } from "@/services";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl } from "@/utils";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router, setLoading } = props;
|
||||
|
||||
@ -33,8 +33,7 @@ import {
|
||||
TaxSubsidySection,
|
||||
WorkerAdvanceSection,
|
||||
} from "@/components";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
import { buildUrl, PurchaseOrderCalculator } from "@/utils";
|
||||
|
||||
const sections = {
|
||||
// 市场报价
|
||||
@ -125,7 +124,8 @@ const sections = {
|
||||
};
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router, isInitialized, setIsInitialized, role, setLoading } = props;
|
||||
const { router, isInitialized, setIsInitialized, userRoleVO, setLoading } =
|
||||
props;
|
||||
|
||||
const orderId = router.params
|
||||
.orderId as BusinessAPI.PurchaseOrderVO["orderId"];
|
||||
@ -436,8 +436,8 @@ export default hocAuth(function Page(props: CommonComponent) {
|
||||
<Input
|
||||
type="text"
|
||||
disabled={
|
||||
role === "boss" ||
|
||||
(role === "reviewer" &&
|
||||
userRoleVO.slug === "boss" ||
|
||||
(userRoleVO.slug === "reviewer" &&
|
||||
purchaseOrderVO.state !== "WAITING_AUDIT")
|
||||
}
|
||||
placeholder="请输入产地负责人姓名"
|
||||
|
||||
@ -10,12 +10,10 @@ import { business } from "@/services";
|
||||
import hocAuth from "@/hocs/auth";
|
||||
import { CommonComponent } from "@/types/typings";
|
||||
import { Label, Text, View } from "@tarojs/components";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl, formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||
import { Button } from "@nutui/nutui-react-taro";
|
||||
import purchaseOrder from "@/constant/purchaseOrder";
|
||||
import dayjs from "dayjs";
|
||||
import { formatCurrency } from "@/utils/format";
|
||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { shareOptions } = props;
|
||||
|
||||
@ -5,7 +5,7 @@ import { Text, View } from "@tarojs/components";
|
||||
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { business } from "@/services";
|
||||
import buildUrl from "@/utils/buildUrl";
|
||||
import { buildUrl } from "@/utils";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { router, setLoading } = props;
|
||||
|
||||
@ -1,4 +1,10 @@
|
||||
import { ActionType, Icon, PageList, SupplierPicker, ToolBar } from "@/components";
|
||||
import {
|
||||
ActionType,
|
||||
Icon,
|
||||
PageList,
|
||||
SupplierPicker,
|
||||
ToolBar,
|
||||
} from "@/components";
|
||||
import { useShareAppMessage } from "@tarojs/taro";
|
||||
import { useRef, useState } from "react";
|
||||
import { business } from "@/services";
|
||||
@ -6,8 +12,15 @@ import hocAuth from "@/hocs/auth";
|
||||
import { CommonComponent } from "@/types/typings";
|
||||
import { View } from "@tarojs/components";
|
||||
import dayjs from "dayjs";
|
||||
import { Button, Popup, SafeArea, Toast, Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
||||
import { uploadFile } from "@/utils/uploader";
|
||||
import {
|
||||
Button,
|
||||
Popup,
|
||||
SafeArea,
|
||||
Toast,
|
||||
Uploader,
|
||||
UploaderFileItem,
|
||||
} from "@nutui/nutui-react-taro";
|
||||
import { uploadFile } from "@/utils";
|
||||
|
||||
export default hocAuth(function Page(props: CommonComponent) {
|
||||
const { shareOptions } = props;
|
||||
|
||||
@ -1754,6 +1754,8 @@ declare namespace BusinessAPI {
|
||||
employeeId?: string;
|
||||
/** 用户ID */
|
||||
userId?: string;
|
||||
/** 平台ID */
|
||||
platformId?: string;
|
||||
};
|
||||
|
||||
type EmployeeUpdateCmd = {
|
||||
@ -2120,6 +2122,12 @@ declare namespace BusinessAPI {
|
||||
hideInMenu?: boolean;
|
||||
/** 权限Id */
|
||||
permissionId?: number;
|
||||
/** 菜单图标 */
|
||||
icon?: string;
|
||||
/** 图标颜色 */
|
||||
iconColor?: string;
|
||||
/** 背景颜色类名 */
|
||||
bgColorClass?: string;
|
||||
};
|
||||
|
||||
type MenuDestroyCmd = {
|
||||
@ -2187,6 +2195,12 @@ declare namespace BusinessAPI {
|
||||
hideInMenu?: boolean;
|
||||
/** 权限Id */
|
||||
permissionId?: number;
|
||||
/** 菜单图标 */
|
||||
icon?: string;
|
||||
/** 图标颜色 */
|
||||
iconColor?: string;
|
||||
/** 背景颜色类名 */
|
||||
bgColorClass?: string;
|
||||
/** 菜单Id */
|
||||
menuId: string;
|
||||
};
|
||||
@ -2214,6 +2228,12 @@ declare namespace BusinessAPI {
|
||||
routes?: any[];
|
||||
/** 权限id */
|
||||
permissionId: number;
|
||||
/** 菜单图标 */
|
||||
icon?: string;
|
||||
/** 图标颜色 */
|
||||
iconColor?: string;
|
||||
/** 背景颜色类名 */
|
||||
bgColorClass?: string;
|
||||
/** 创建时间 */
|
||||
createdAt?: string;
|
||||
};
|
||||
@ -2892,8 +2912,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: AgreementVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseBoxBrandVO = {
|
||||
@ -2905,8 +2925,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: BoxBrandVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseBoxProductVO = {
|
||||
@ -2918,8 +2938,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: BoxProductVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseBoxSpecVO = {
|
||||
@ -2931,8 +2951,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: BoxSpecVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseChannelVO = {
|
||||
@ -2944,8 +2964,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: ChannelVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseCompanyPaymentAccountVO = {
|
||||
@ -2957,8 +2977,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: CompanyPaymentAccountVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseCompanyVO = {
|
||||
@ -2970,8 +2990,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: CompanyVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseCostItemVO = {
|
||||
@ -2983,8 +3003,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: CostItemVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseDealerPaymentAccountVO = {
|
||||
@ -2996,8 +3016,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: DealerPaymentAccountVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseDealerRebateCustomerVO = {
|
||||
@ -3009,8 +3029,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: DealerRebateCustomerVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseDealerVO = {
|
||||
@ -3022,8 +3042,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: DealerVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseDealerWarehouseVO = {
|
||||
@ -3035,8 +3055,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: DealerWarehouseVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseDictionaryVO = {
|
||||
@ -3048,8 +3068,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: DictionaryVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseEmployeeVO = {
|
||||
@ -3061,8 +3081,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: EmployeeVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseGiftBoxVO = {
|
||||
@ -3074,8 +3094,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: GiftBoxVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseMaterialVO = {
|
||||
@ -3087,8 +3107,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: MaterialVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseOrderSupplierVO = {
|
||||
@ -3100,8 +3120,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: OrderSupplierVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponsePermissionVO = {
|
||||
@ -3113,8 +3133,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: PermissionVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponsePlatformVO = {
|
||||
@ -3126,8 +3146,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: PlatformVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseProductVO = {
|
||||
@ -3139,8 +3159,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: ProductVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponsePurchaseOrderVO = {
|
||||
@ -3152,8 +3172,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: PurchaseOrderVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseRoleVO = {
|
||||
@ -3165,8 +3185,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: RoleVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseShipOrderVO = {
|
||||
@ -3178,8 +3198,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: ShipOrderVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseSupplierVO = {
|
||||
@ -3191,8 +3211,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: SupplierVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type PageResponseUserVO = {
|
||||
@ -3204,8 +3224,8 @@ declare namespace BusinessAPI {
|
||||
pageIndex?: number;
|
||||
data?: UserVO[];
|
||||
empty?: boolean;
|
||||
notEmpty?: boolean;
|
||||
totalPages?: number;
|
||||
notEmpty?: boolean;
|
||||
};
|
||||
|
||||
type pageRoleParams = {
|
||||
@ -3750,6 +3770,8 @@ declare namespace BusinessAPI {
|
||||
roleIdList?: number[];
|
||||
/** 平台Id */
|
||||
platformId?: string;
|
||||
/** 平台Id */
|
||||
platformIdList?: string;
|
||||
/** 角色类型 */
|
||||
type?: number;
|
||||
offset?: number;
|
||||
@ -3810,6 +3832,8 @@ declare namespace BusinessAPI {
|
||||
description?: string;
|
||||
/** 平台id */
|
||||
platformId: string;
|
||||
/** 平台 */
|
||||
platformVO?: PlatformVO;
|
||||
/** 权限列表 */
|
||||
permissionId: number[];
|
||||
/** 菜单列表 */
|
||||
@ -4823,6 +4847,8 @@ declare namespace BusinessAPI {
|
||||
userId: string;
|
||||
/** 描述 */
|
||||
description: string;
|
||||
/** 平台ID */
|
||||
platformId: string;
|
||||
};
|
||||
|
||||
type UserShowQry = {
|
||||
|
||||
@ -20,6 +20,8 @@ request.interceptors.request.use(
|
||||
config.headers["Xh-Role-Slug"] = slug;
|
||||
}
|
||||
|
||||
config.headers["Xh-Platform-Id"] = "1991353387274342401";
|
||||
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
|
||||
@ -4,12 +4,12 @@ type State = {
|
||||
tabBar?: {
|
||||
selected?: number;
|
||||
};
|
||||
role?: string;
|
||||
userRoleVO?: AuthAPI.UserRoleVO;
|
||||
};
|
||||
|
||||
type Action = {
|
||||
setTabBar: (selected: number) => void;
|
||||
setRole: (role: string) => void;
|
||||
setUserRoleVO: (userRoleVO: AuthAPI.UserRoleVO) => void;
|
||||
};
|
||||
|
||||
export const globalStore = create<State & Action>((set) => ({
|
||||
@ -20,9 +20,9 @@ export const globalStore = create<State & Action>((set) => ({
|
||||
},
|
||||
}));
|
||||
},
|
||||
setRole: (role: string) => {
|
||||
setUserRoleVO: (userRoleVO: AuthAPI.UserRoleVO) => {
|
||||
set(() => ({
|
||||
role: role,
|
||||
userRoleVO: userRoleVO,
|
||||
}));
|
||||
},
|
||||
}));
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { create } from "zustand";
|
||||
import auth from "@/services/auth";
|
||||
import { getStorageSyncTime, setStorageSyncSecond } from "@/utils/cache";
|
||||
import { getStorageSyncTime, setStorageSyncSecond } from "@/utils";
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
type State = {
|
||||
@ -15,7 +15,7 @@ export const userStore = create<State & Action>((set) => ({
|
||||
user: null,
|
||||
setUser: async () => {
|
||||
let user = getStorageSyncTime<AuthAPI.UserVO>("user");
|
||||
console.log("user", user)
|
||||
console.log("user", user);
|
||||
|
||||
if (!user) {
|
||||
const {
|
||||
|
||||
@ -12,10 +12,7 @@ export interface BasicComponent {
|
||||
export interface CommonComponent {
|
||||
user: AuthAPI.UserVO;
|
||||
shareOptions: any;
|
||||
role: "origin-entry" | "market-buyer" | "reviewer" | "boss";
|
||||
setRole: (
|
||||
role: "origin-entry" | "market-buyer" | "reviewer" | "boss",
|
||||
) => void;
|
||||
userRoleVO: BusinessAPI.UserRoleVO;
|
||||
router: Router;
|
||||
options: Taro.getLaunchOptionsSync.LaunchOptions;
|
||||
isInitialized: boolean;
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
import buildParams from "@/utils/buildParams";
|
||||
|
||||
export default function buildUrl(path: string, params = {}) {
|
||||
const query = buildParams(params);
|
||||
|
||||
return query ? `${path}?${query}` : path;
|
||||
}
|
||||
@ -5,6 +5,7 @@ import { Decimal } from "decimal.js";
|
||||
* 封装所有与采购订单相关的计算逻辑
|
||||
*/
|
||||
export class OrderSupplierCalculator {
|
||||
// @ts-ignore
|
||||
private purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||
private orderSupplier: BusinessAPI.OrderSupplier;
|
||||
|
||||
10
packages/app-client/src/utils/classes/calculators/index.ts
Normal file
10
packages/app-client/src/utils/classes/calculators/index.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 计算器类统一导出
|
||||
*
|
||||
* 使用方式:
|
||||
* import { PurchaseOrderCalculator } from '@/utils/classes/calculators'
|
||||
*/
|
||||
|
||||
export { PurchaseOrderCalculator } from './PurchaseOrderCalculator'
|
||||
export { OrderSupplierCalculator } from './OrderSupplierCalculator'
|
||||
export { SupplierWeightCalculator } from './SupplierWeightCalculator'
|
||||
12
packages/app-client/src/utils/classes/index.ts
Normal file
12
packages/app-client/src/utils/classes/index.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 类工具统一导出
|
||||
*
|
||||
* 使用方式:
|
||||
* import { PurchaseOrderCalculator, PdfTemplate } from '@/utils/classes'
|
||||
*/
|
||||
|
||||
// 计算器类
|
||||
export { PurchaseOrderCalculator, OrderSupplierCalculator, SupplierWeightCalculator } from './calculators'
|
||||
|
||||
// 模板类
|
||||
export { PdfTemplate } from './templates'
|
||||
8
packages/app-client/src/utils/classes/templates/index.ts
Normal file
8
packages/app-client/src/utils/classes/templates/index.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* 模板类统一导出
|
||||
*
|
||||
* 使用方式:
|
||||
* import { PdfTemplate } from '@/utils/classes/templates'
|
||||
*/
|
||||
|
||||
export { PdfTemplate } from './PdfTemplate'
|
||||
@ -1,6 +1,6 @@
|
||||
// 将BoxBrand转换为OrderPackage数组
|
||||
import { BoxBrand, BoxProduct, BoxSpec } from "@/types/typings";
|
||||
import { generateShortId } from "@/utils/generateShortId";
|
||||
import { generateShortId } from "@/utils";
|
||||
|
||||
// 添加一个辅助函数用于分组
|
||||
const groupBy = <T>(
|
||||
11
packages/app-client/src/utils/converters/index.ts
Normal file
11
packages/app-client/src/utils/converters/index.ts
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* 数据转换器统一导出
|
||||
*
|
||||
* 使用方式:
|
||||
* import { convertBoxBrandToOrderPackages } from '@/utils/converters'
|
||||
*/
|
||||
|
||||
export {
|
||||
convertBoxBrandToOrderPackages,
|
||||
convertOrderPackagesToBoxBrands
|
||||
} from './boxBrandConverter'
|
||||
61
packages/app-client/src/utils/functions/amount.ts
Normal file
61
packages/app-client/src/utils/functions/amount.ts
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
* 金额格式化工具函数
|
||||
* 去除小数点后多余的零,但保留必要的小数位
|
||||
*
|
||||
* @example
|
||||
* formatAmount(0.00) // '0'
|
||||
* formatAmount(0.10) // '0.1'
|
||||
* formatAmount(10.00) // '10'
|
||||
* formatAmount(10.01) // '10.01'
|
||||
*
|
||||
* @param value 需要格式化的数字
|
||||
* @returns 格式化后的字符串
|
||||
*/
|
||||
export function formatAmount(value: number): string {
|
||||
if (!Number.isNaN(value)) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
// 固定保留2位小数
|
||||
const fixedStr = value.toFixed(2);
|
||||
|
||||
// 去除小数点后多余的零
|
||||
// 具体规则:
|
||||
// 1. 如果小数点后都是零,则去掉小数点和零
|
||||
// 2. 如果小数点后只有一位零,则去掉这位零
|
||||
// 3. 保留必要的小数位
|
||||
|
||||
if (fixedStr.endsWith('.00')) {
|
||||
// 情况:0.00, 10.00 -> 去掉小数点后两位零
|
||||
return fixedStr.slice(0, -3);
|
||||
} else if (fixedStr.endsWith('0') && !fixedStr.endsWith('00')) {
|
||||
// 情况:0.10, 10.30 -> 去掉最后的零
|
||||
return fixedStr.slice(0, -1);
|
||||
} else {
|
||||
// 情况:0.01, 10.99 -> 保持不变
|
||||
return fixedStr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 金额格式化工具函数(兼容已有函数)
|
||||
* 保持与项目中 formatCurrency 相似的接口
|
||||
*
|
||||
* @param value 需要格式化的数字
|
||||
* @returns 格式化后的字符串
|
||||
*/
|
||||
export const formatCurrency = (value: number): string => {
|
||||
return formatAmount(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* 验证金额字符串格式
|
||||
* 支持最多两位小数的数字格式
|
||||
*
|
||||
* @param value 待验证的字符串
|
||||
* @returns 是否为有效的金额格式
|
||||
*/
|
||||
export const validateAmount = (value: string): boolean => {
|
||||
const regex = /^\d*\.?\d{0,2}$/;
|
||||
return regex.test(value);
|
||||
};
|
||||
@ -1,4 +1,4 @@
|
||||
export default function buildParams(params = {}) {
|
||||
export function buildParams(params = {}) {
|
||||
return Object.entries(params)
|
||||
.filter(([_, value]) => value !== undefined && value !== null)
|
||||
.map(([key, value]) => {
|
||||
7
packages/app-client/src/utils/functions/buildUrl.ts
Normal file
7
packages/app-client/src/utils/functions/buildUrl.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { buildParams } from "@/utils";
|
||||
|
||||
export function buildUrl(path: string, params = {}) {
|
||||
const query = buildParams(params);
|
||||
|
||||
return query ? `${path}?${query}` : path;
|
||||
}
|
||||
51
packages/app-client/src/utils/functions/index.ts
Normal file
51
packages/app-client/src/utils/functions/index.ts
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 纯函数工具统一导出
|
||||
*
|
||||
* 使用方式:
|
||||
* import { formatAmount, formatDate, aesEncrypt } from '@/utils/functions'
|
||||
*/
|
||||
|
||||
// 金额相关
|
||||
export { formatAmount, formatCurrency, validateAmount } from "./amount";
|
||||
|
||||
// 日期处理
|
||||
export * from "./date";
|
||||
|
||||
// 通用格式化
|
||||
export {
|
||||
formatDistance,
|
||||
formatHumanReadableDate,
|
||||
convertSeconds,
|
||||
formatUnitPrice,
|
||||
validatePrice,
|
||||
} from "./format";
|
||||
|
||||
// ID生成
|
||||
export { generateShortId } from "./generateShortId";
|
||||
|
||||
// 安全相关 - AES加密解密
|
||||
export * from "./aes";
|
||||
|
||||
// 网络相关 - 参数构建、URL构建、文件上传
|
||||
export * from "./buildParams";
|
||||
export * from "./buildUrl";
|
||||
export * from "./uploader";
|
||||
|
||||
// 数据存储 - 缓存处理
|
||||
export * from "./cache";
|
||||
|
||||
// 用户相关
|
||||
export * from "./user";
|
||||
|
||||
// 设备相关 - 电话、OCR
|
||||
export * from "./makePhone";
|
||||
export * from "./ocr";
|
||||
|
||||
// 动画相关
|
||||
export * from "./raf";
|
||||
|
||||
// 报告/日志
|
||||
export * from "./reporter";
|
||||
|
||||
// 路由相关
|
||||
export * from "./routeGuard";
|
||||
@ -3,7 +3,7 @@ import Taro from "@tarojs/taro";
|
||||
// import UAParser from "ua-parser-js";
|
||||
import axios from "axios";
|
||||
import { load } from "@fingerprintjs/fingerprintjs";
|
||||
import { getStorageSyncTime } from "@/utils/cache";
|
||||
import { getStorageSyncTime } from "@/utils";
|
||||
import CryptoJS from "crypto-js";
|
||||
|
||||
export const base64Key: string = "MTIzNDU2Nzg5MDEyMzQ1Ng==";
|
||||
@ -1,8 +1,8 @@
|
||||
// src/utils/routeGuard.ts
|
||||
import Taro from "@tarojs/taro";
|
||||
import {
|
||||
SCREENSHOT_ALLOWED_ROUTES,
|
||||
RedirectResult,
|
||||
SCREENSHOT_ALLOWED_ROUTES,
|
||||
TABBAR_ROUTES,
|
||||
} from "@/config/routes";
|
||||
|
||||
28
packages/app-client/src/utils/index.ts
Normal file
28
packages/app-client/src/utils/index.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* utils 统一导出入口
|
||||
*
|
||||
* 提供多种导入方式:
|
||||
*
|
||||
* 1. 分类导入:
|
||||
* import { formatAmount } from '@/utils/functions'
|
||||
* import { PurchaseOrderCalculator } from '@/utils/classes'
|
||||
* import { convertBoxBrandToOrderPackages } from '@/utils/converters'
|
||||
*
|
||||
* 2. 统一导入:
|
||||
* import { formatAmount, PurchaseOrderCalculator } from '@/utils'
|
||||
*
|
||||
* 3. 命名空间导入:
|
||||
* import * as UtilsFunctions from '@/utils/functions'
|
||||
* import * as UtilsClasses from '@/utils/classes'
|
||||
* import * as UtilsConverters from '@/utils/converters'
|
||||
* import * as Utils from '@/utils'
|
||||
*/
|
||||
|
||||
// 纯函数工具
|
||||
export * from './functions'
|
||||
|
||||
// 数据转换器
|
||||
export * from './converters'
|
||||
|
||||
// 类工具
|
||||
export * from './classes'
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user