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
|
```tsx
|
||||||
import { Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
import { Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
||||||
import { uploadFile } from "@/utils/uploader";
|
import { uploadFile } from "@/utils";
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. 基本属性
|
### 2. 基本属性
|
||||||
@ -228,7 +228,7 @@ useEffect(() => {
|
|||||||
import { View } from "@tarojs/components";
|
import { View } from "@tarojs/components";
|
||||||
import { Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
import { Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { uploadFile } from "@/utils/uploader";
|
import { uploadFile } from "@/utils";
|
||||||
|
|
||||||
export default function UploadExample() {
|
export default function UploadExample() {
|
||||||
// 头像上传状态
|
// 头像上传状态
|
||||||
@ -301,4 +301,4 @@ export default function UploadExample() {
|
|||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@ -48,6 +48,10 @@ src/
|
|||||||
├── services/ # API服务层
|
├── services/ # API服务层
|
||||||
├── store/ # 状态管理
|
├── store/ # 状态管理
|
||||||
├── utils/ # 工具函数
|
├── utils/ # 工具函数
|
||||||
|
│ ├── format.ts # 通用格式化工具(日期、距离、金额等)
|
||||||
|
│ ├── amount.ts # 金额处理工具(去除小数后多余零)
|
||||||
|
│ ├── date.ts # 日期处理工具
|
||||||
|
│ └── ... # 其他工具函数
|
||||||
└── types/ # TypeScript类型定义
|
└── types/ # TypeScript类型定义
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -104,12 +108,17 @@ src/
|
|||||||
- 供应商资质管理
|
- 供应商资质管理
|
||||||
- 采购历史关联
|
- 采购历史关联
|
||||||
|
|
||||||
3. **交付管理**:
|
3. **费用管理**:
|
||||||
|
- 采购费用计算和展示
|
||||||
|
- 金额格式化处理(去除小数点后多余零)
|
||||||
|
- 多种费用类型的统一处理
|
||||||
|
|
||||||
|
4. **交付管理**:
|
||||||
- 交付单创建和管理
|
- 交付单创建和管理
|
||||||
- 配送状态跟踪
|
- 配送状态跟踪
|
||||||
- 交付确认和验收
|
- 交付确认和验收
|
||||||
|
|
||||||
4. **用户权限**:
|
5. **用户权限**:
|
||||||
- 基于角色的访问控制(RBAC)
|
- 基于角色的访问控制(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 { PropsWithChildren } from "react";
|
||||||
import Taro, { useLaunch } from "@tarojs/taro";
|
import Taro, { useLaunch } from "@tarojs/taro";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { RouteGuard } from "@/utils/routeGuard";
|
import { RouteGuard } from "@/utils";
|
||||||
import "dayjs/locale/zh-cn";
|
import "dayjs/locale/zh-cn";
|
||||||
import "./app.css";
|
import "./app.css";
|
||||||
import "./iconfont.css";
|
import "./iconfont.css";
|
||||||
|
|||||||
@ -6,11 +6,11 @@ import { globalStore } from "@/store/global-store";
|
|||||||
import { CustomTheme, Icon } from "@/components";
|
import { CustomTheme, Icon } from "@/components";
|
||||||
|
|
||||||
interface ICustomTabBarProps {
|
interface ICustomTabBarProps {
|
||||||
role: AuthAPI.UserRoleVO["slug"];
|
userRoleVO: AuthAPI.UserRoleVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CustomTabBar(props: ICustomTabBarProps) {
|
export default function CustomTabBar(props: ICustomTabBarProps) {
|
||||||
const { role } = props;
|
const { userRoleVO } = props;
|
||||||
const { tabBar, setTabBar } = globalStore((state: any) => state);
|
const { tabBar, setTabBar } = globalStore((state: any) => state);
|
||||||
const [scaleFactor, setScaleFactor] = useState(1);
|
const [scaleFactor, setScaleFactor] = useState(1);
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ export default function CustomTabBar(props: ICustomTabBarProps) {
|
|||||||
text: "我的",
|
text: "我的",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}, [scaleFactor, role]);
|
}, [scaleFactor, userRoleVO]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const selected = tabBarList.findIndex((item) => {
|
const selected = tabBarList.findIndex((item) => {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Button, ButtonSize, Dialog, Toast } from "@nutui/nutui-react-taro";
|
import { Button, ButtonSize, Dialog, Toast } from "@nutui/nutui-react-taro";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl } from "@/utils";
|
||||||
|
|
||||||
interface IPurchaseOrderSubmitReviewProps {
|
interface IPurchaseOrderSubmitReviewProps {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
@ -110,7 +110,7 @@ export default function PurchaseOrderSubmitReview(
|
|||||||
(supplier) => !supplier.contractUpload,
|
(supplier) => !supplier.contractUpload,
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log("hasNoUpdateContractSupplier", hasNoUpdateContractSupplier)
|
console.log("hasNoUpdateContractSupplier", hasNoUpdateContractSupplier);
|
||||||
|
|
||||||
if (hasNoUpdateContractSupplier) {
|
if (hasNoUpdateContractSupplier) {
|
||||||
Dialog.open("dialog", {
|
Dialog.open("dialog", {
|
||||||
|
|||||||
@ -11,9 +11,8 @@ import {
|
|||||||
import { Icon, SupplierPicker } from "@/components";
|
import { Icon, SupplierPicker } from "@/components";
|
||||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||||
import { SupplierVO } from "@/types/typings";
|
import { SupplierVO } from "@/types/typings";
|
||||||
import { uploadFile } from "@/utils/uploader";
|
import { buildUrl, uploadFile } from "@/utils";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
|
|
||||||
// 定义ref暴露的方法接口
|
// 定义ref暴露的方法接口
|
||||||
|
|||||||
@ -19,11 +19,11 @@ import {
|
|||||||
CostItem,
|
CostItem,
|
||||||
SupplierVO,
|
SupplierVO,
|
||||||
} from "@/types/typings";
|
} from "@/types/typings";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
|
||||||
import {
|
import {
|
||||||
convertBoxBrandToOrderPackages,
|
convertBoxBrandToOrderPackages,
|
||||||
convertOrderPackagesToBoxBrands,
|
convertOrderPackagesToBoxBrands,
|
||||||
} from "@/utils/orderPackage";
|
generateShortId,
|
||||||
|
} from "@/utils";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { Decimal } from "decimal.js";
|
import { Decimal } from "decimal.js";
|
||||||
|
|
||||||
|
|||||||
@ -13,11 +13,11 @@ import classNames from "classnames";
|
|||||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import { BoxBrand, BoxProduct, BoxSpec, SupplierVO } from "@/types/typings";
|
import { BoxBrand, BoxProduct, BoxSpec, SupplierVO } from "@/types/typings";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
|
||||||
import {
|
import {
|
||||||
convertBoxBrandToOrderPackages,
|
convertBoxBrandToOrderPackages,
|
||||||
convertOrderPackagesToBoxBrands,
|
convertOrderPackagesToBoxBrands,
|
||||||
} from "@/utils/orderPackage";
|
generateShortId,
|
||||||
|
} from "@/utils";
|
||||||
|
|
||||||
// 定义ref暴露的方法接口
|
// 定义ref暴露的方法接口
|
||||||
export interface OrderPackageRef {
|
export interface OrderPackageRef {
|
||||||
|
|||||||
@ -14,8 +14,7 @@ import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import { validatePrice as validatePrice1 } from "@/utils/format";
|
import { generateShortId, validatePrice as validatePrice1 } from "@/utils";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
|
||||||
import { CostItem } from "@/types/typings";
|
import { CostItem } from "@/types/typings";
|
||||||
|
|
||||||
interface IOrderVehicleProps {
|
interface IOrderVehicleProps {
|
||||||
|
|||||||
@ -2,9 +2,11 @@ import { View } from "@tarojs/components";
|
|||||||
import { CostItem, SupplierVO } from "@/types/typings";
|
import { CostItem, SupplierVO } from "@/types/typings";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Table, TableColumnProps } from "@nutui/nutui-react-taro";
|
import { Table, TableColumnProps } from "@nutui/nutui-react-taro";
|
||||||
import { formatCurrency } from "@/utils/format";
|
import {
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
formatCurrency,
|
||||||
import { OrderSupplierCalculator } from "@/utils/OrderSupplierCalculator";
|
OrderSupplierCalculator,
|
||||||
|
PurchaseOrderCalculator,
|
||||||
|
} from "@/utils";
|
||||||
|
|
||||||
interface IPurchasePreviewProps {
|
interface IPurchasePreviewProps {
|
||||||
purchaseOrder: BusinessAPI.PurchaseOrderCreateCmd;
|
purchaseOrder: BusinessAPI.PurchaseOrderCreateCmd;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { Icon } from "@/components";
|
|||||||
import { SupplierVO } from "@/types/typings";
|
import { SupplierVO } from "@/types/typings";
|
||||||
import { Price, Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
import { Price, Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { uploadFile } from "@/utils/uploader";
|
import { uploadFile } from "@/utils";
|
||||||
|
|
||||||
interface ITicketUploadProps {
|
interface ITicketUploadProps {
|
||||||
value: SupplierVO;
|
value: SupplierVO;
|
||||||
|
|||||||
@ -12,8 +12,7 @@ import {
|
|||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
import { SupplierVO } from "@/types/typings";
|
import { SupplierVO } from "@/types/typings";
|
||||||
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
|
||||||
import { uploadFile } from "@/utils/uploader";
|
import { uploadFile, validatePrice } from "@/utils";
|
||||||
import { validatePrice } from "@/utils/format";
|
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
|
|
||||||
// 定义ref暴露的方法接口
|
// 定义ref暴露的方法接口
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { ScrollView, Text, View } from "@tarojs/components";
|
import { ScrollView, Text, View } from "@tarojs/components";
|
||||||
import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
|
import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { formatCurrency } from "@/utils/format";
|
import { formatCurrency } from "@/utils";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import businessServices from "@/services/business";
|
import businessServices from "@/services/business";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Text, View } from "@tarojs/components";
|
import { Text, View } from "@tarojs/components";
|
||||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||||
import { validatePrice } from "@/utils/format";
|
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default function CostDifferenceSection(props: {
|
export default function CostDifferenceSection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { Table, TableColumnProps } from "@nutui/nutui-react-taro";
|
import { Table, TableColumnProps } from "@nutui/nutui-react-taro";
|
||||||
import { formatCurrency } from "@/utils/format";
|
import { formatCurrency, PurchaseOrderCalculator } from "@/utils";
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function CostSummarySection(props: {
|
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 { useEffect, useState } from "react";
|
||||||
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
|
|||||||
@ -8,8 +8,7 @@ import {
|
|||||||
} from "@nutui/nutui-react-taro";
|
} from "@nutui/nutui-react-taro";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
import { formatCurrency, generateShortId, validatePrice } from "@/utils";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
|
||||||
|
|
||||||
export default function LaborInfoSection(props: {
|
export default function LaborInfoSection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Text, View } from "@tarojs/components";
|
import { Text, View } from "@tarojs/components";
|
||||||
import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
|
import { Button, Input, Popup, Radio, SafeArea } from "@nutui/nutui-react-taro";
|
||||||
import { validatePrice } from "@/utils/format";
|
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
|
|
||||||
export default function MarketPriceSection(props: {
|
export default function MarketPriceSection(props: {
|
||||||
|
|||||||
@ -7,8 +7,7 @@ import {
|
|||||||
SafeArea,
|
SafeArea,
|
||||||
} from "@nutui/nutui-react-taro";
|
} from "@nutui/nutui-react-taro";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { validatePrice } from "@/utils/format";
|
import { generateShortId, validatePrice } from "@/utils";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
|
|
||||||
export default function MaterialCostSection(props: {
|
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 { useEffect, useState } from "react";
|
||||||
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
|
|||||||
@ -8,8 +8,7 @@ import {
|
|||||||
} from "@nutui/nutui-react-taro";
|
} from "@nutui/nutui-react-taro";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
import { validatePrice } from "@/utils/format";
|
import { generateShortId, validatePrice } from "@/utils";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
|
||||||
|
|
||||||
export default function PackagingCostSection(props: {
|
export default function PackagingCostSection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
|
|||||||
@ -8,8 +8,7 @@ import {
|
|||||||
} from "@nutui/nutui-react-taro";
|
} from "@nutui/nutui-react-taro";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
import { formatCurrency, generateShortId, validatePrice } from "@/utils";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
|
||||||
|
|
||||||
export default function ProductionAdvanceSection(props: {
|
export default function ProductionAdvanceSection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
import { formatCurrency, validatePrice } from "@/utils";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
import { Button, Input, Popup, SafeArea, Table } from "@nutui/nutui-react-taro";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { ScrollView, Text, View } from "@tarojs/components";
|
import { ScrollView, Text, View } from "@tarojs/components";
|
||||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
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 { business } from "@/services";
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default function RebateCalcSection(props: {
|
export default function RebateCalcSection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import {
|
|||||||
import { View } from "@tarojs/components";
|
import { View } from "@tarojs/components";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { uploadFile } from "@/utils/uploader";
|
import { uploadFile } from "@/utils";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
|
|
||||||
export default function SupplierInfoSection(props: {
|
export default function SupplierInfoSection(props: {
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Text, View } from "@tarojs/components";
|
import { Text, View } from "@tarojs/components";
|
||||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||||
import { validatePrice } from "@/utils/format";
|
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default function TaxProvisionSection(props: {
|
export default function TaxProvisionSection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Text, View } from "@tarojs/components";
|
import { Text, View } from "@tarojs/components";
|
||||||
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
import { Button, Input, Popup, SafeArea } from "@nutui/nutui-react-taro";
|
||||||
import { validatePrice } from "@/utils/format";
|
import { PurchaseOrderCalculator, validatePrice } from "@/utils";
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default function TaxSubsidySection(props: {
|
export default function TaxSubsidySection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
|
|||||||
@ -8,8 +8,7 @@ import {
|
|||||||
} from "@nutui/nutui-react-taro";
|
} from "@nutui/nutui-react-taro";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Icon } from "@/components";
|
import { Icon } from "@/components";
|
||||||
import { formatCurrency, validatePrice } from "@/utils/format";
|
import { formatCurrency, generateShortId, validatePrice } from "@/utils";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
|
||||||
|
|
||||||
export default function WorkerAdvanceSection(props: {
|
export default function WorkerAdvanceSection(props: {
|
||||||
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { Loading, Overlay } from "@nutui/nutui-react-taro";
|
|||||||
import { View } from "@tarojs/components";
|
import { View } from "@tarojs/components";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import buildParams from "@/utils/buildParams";
|
import { buildParams } from "@/utils";
|
||||||
import { globalStore } from "@/store/global-store";
|
import { globalStore } from "@/store/global-store";
|
||||||
|
|
||||||
const hocAuth = (
|
const hocAuth = (
|
||||||
@ -16,7 +16,7 @@ const hocAuth = (
|
|||||||
base((props: any) => {
|
base((props: any) => {
|
||||||
const { options, router } = props;
|
const { options, router } = props;
|
||||||
const user = userStore(useShallow((state) => state.user));
|
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 [longitude, setLongitude] = useState<number>();
|
||||||
const [latitude, setLatitude] = useState<number>();
|
const [latitude, setLatitude] = useState<number>();
|
||||||
@ -26,7 +26,7 @@ const hocAuth = (
|
|||||||
const [isInitialized, setIsInitialized] = useState(false);
|
const [isInitialized, setIsInitialized] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setRole(Taro.getStorageSync("userRoleVO").slug || "origin-entry");
|
setUserRoleVO(Taro.getStorageSync("userRoleVO"));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -87,7 +87,7 @@ const hocAuth = (
|
|||||||
}, [user]);
|
}, [user]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!user) {
|
if (!user || !userRoleVO) {
|
||||||
if (skeleton) {
|
if (skeleton) {
|
||||||
return skeleton;
|
return skeleton;
|
||||||
}
|
}
|
||||||
@ -119,8 +119,7 @@ const hocAuth = (
|
|||||||
longitude={longitude}
|
longitude={longitude}
|
||||||
latitude={latitude}
|
latitude={latitude}
|
||||||
user={user}
|
user={user}
|
||||||
role={role}
|
userRoleVO={userRoleVO}
|
||||||
setRole={setRole}
|
|
||||||
isInitialized={isInitialized}
|
isInitialized={isInitialized}
|
||||||
setIsInitialized={setIsInitialized}
|
setIsInitialized={setIsInitialized}
|
||||||
setLoading={setLoading}
|
setLoading={setLoading}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import Taro, { useDidHide, useReady, useUnload } from "@tarojs/taro";
|
import Taro, { useDidHide, useReady, useUnload } from "@tarojs/taro";
|
||||||
import { reporter } from "@/utils/reporter";
|
import { reporter } from "@/utils";
|
||||||
import { SWRConfig } from "swr";
|
import { SWRConfig } from "swr";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { userStore } from "@/store/user-store";
|
import { userStore } from "@/store/user-store";
|
||||||
|
|||||||
@ -8,14 +8,13 @@ import Taro from "@tarojs/taro";
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { business, poster } from "@/services";
|
import { business, poster } from "@/services";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl, PdfTemplate } from "@/utils";
|
||||||
import {
|
import {
|
||||||
DeliveryStep1Form,
|
DeliveryStep1Form,
|
||||||
DeliveryStep1FormRef,
|
DeliveryStep1FormRef,
|
||||||
DeliveryStep2Preview,
|
DeliveryStep2Preview,
|
||||||
DeliveryStep3Success,
|
DeliveryStep3Success,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { PdfTemplate } from "@/utils/PdfTemplate";
|
|
||||||
|
|
||||||
// 特殊处理:其他费用要实时获取费用项目
|
// 特殊处理:其他费用要实时获取费用项目
|
||||||
const updateOtherFeesModule = async (
|
const updateOtherFeesModule = async (
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import shipOrder from "@/constant/shipOrder";
|
|||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { business, poster } from "@/services";
|
import { business, poster } from "@/services";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl, PdfTemplate, PurchaseOrderCalculator } from "@/utils";
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
PurchaseStep1Form,
|
PurchaseStep1Form,
|
||||||
@ -15,7 +15,6 @@ import {
|
|||||||
PurchaseStep2Preview,
|
PurchaseStep2Preview,
|
||||||
PurchaseStep3Success,
|
PurchaseStep3Success,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { router, setLoading } = props;
|
const { router, setLoading } = props;
|
||||||
@ -111,7 +110,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
|
|
||||||
// 截图预览内容
|
// 截图预览内容
|
||||||
const capturePreview = async () => {
|
const capturePreview = async () => {
|
||||||
const template = new Template(moduleList);
|
const template = new PdfTemplate(moduleList);
|
||||||
console.log("generateHtmlString", template.generateHtmlString());
|
console.log("generateHtmlString", template.generateHtmlString());
|
||||||
const { data } = await poster.pdf.postApiV1Pdf({
|
const { data } = await poster.pdf.postApiV1Pdf({
|
||||||
html: template.generateHtmlString(),
|
html: template.generateHtmlString(),
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import { business } from "@/services";
|
|||||||
import hocAuth from "@/hocs/auth";
|
import hocAuth from "@/hocs/auth";
|
||||||
import { CommonComponent } from "@/types/typings";
|
import { CommonComponent } from "@/types/typings";
|
||||||
import { Label, Text, View } from "@tarojs/components";
|
import { Label, Text, View } from "@tarojs/components";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl } from "@/utils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import shipOrder from "@/constant/shipOrder";
|
import shipOrder from "@/constant/shipOrder";
|
||||||
import { Button, Popup, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
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 { Button, Dialog, Image, Popup, Toast } from "@nutui/nutui-react-taro";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl, uploadFile } from "@/utils";
|
||||||
import { uploadFile } from "@/utils/uploader";
|
|
||||||
import { globalStore } from "@/store/global-store";
|
import { globalStore } from "@/store/global-store";
|
||||||
import { APP_VERSION } from "@/constant";
|
import { APP_VERSION } from "@/constant";
|
||||||
import { CustomTabBar, Icon } from "@/components";
|
import { CustomTabBar, Icon } from "@/components";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { user, role } = props;
|
const { user, userRoleVO } = props;
|
||||||
const setRole = globalStore((state: any) => state.setRole);
|
console.log("userRoleVO", userRoleVO);
|
||||||
|
const setUserRoleVO = globalStore((state: any) => state.setUserRoleVO);
|
||||||
|
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [employeeVO, setEmployeeVO] = useState<AuthAPI.EmployeeVO>();
|
const [employeeVO, setEmployeeVO] = useState<AuthAPI.EmployeeVO>();
|
||||||
const [userRoleVOList, setUserRoleVOList] = useState<AuthAPI.UserRoleVO[]>();
|
const [userRoleVOList, setUserRoleVOList] = useState<AuthAPI.UserRoleVO[]>();
|
||||||
|
|
||||||
const [userRoleVO, setUserRoleVO] = useState<AuthAPI.UserRoleVO>();
|
|
||||||
|
|
||||||
const [channel, setChannel] = useState<BusinessAPI.ChannelVO>();
|
const [channel, setChannel] = useState<BusinessAPI.ChannelVO>();
|
||||||
|
|
||||||
const initChannel = async () => {
|
const initChannel = async () => {
|
||||||
@ -38,6 +36,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
} = await auth.user.userEmployee({
|
} = await auth.user.userEmployee({
|
||||||
employeeShowQry: {
|
employeeShowQry: {
|
||||||
userId: user.userId,
|
userId: user.userId,
|
||||||
|
platformId: "1991353387274342401",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -67,8 +66,8 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 处理角色切换
|
// 处理角色切换
|
||||||
const handleRoleSelect = (role: AuthAPI.UserRoleVO) => {
|
const handleRoleSelect = (userRoleVO: AuthAPI.UserRoleVO) => {
|
||||||
setUserRoleVO(role);
|
setUserRoleVO(userRoleVO);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 选择图片函数
|
// 选择图片函数
|
||||||
@ -140,7 +139,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
const handleConfirmSwitch = () => {
|
const handleConfirmSwitch = () => {
|
||||||
if (userRoleVO) {
|
if (userRoleVO) {
|
||||||
Taro.setStorageSync("userRoleVO", userRoleVO);
|
Taro.setStorageSync("userRoleVO", userRoleVO);
|
||||||
setRole(userRoleVO.slug);
|
setUserRoleVO(userRoleVO);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
|
||||||
Toast.show("toast", {
|
Toast.show("toast", {
|
||||||
@ -327,7 +326,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
© {dayjs().format("YYYY")} {channel?.technicalSupport} 版权所有
|
© {dayjs().format("YYYY")} {channel?.technicalSupport} 版权所有
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<CustomTabBar role={role} />
|
<CustomTabBar userRoleVO={userRoleVO} />
|
||||||
|
|
||||||
{/* 选择身份 */}
|
{/* 选择身份 */}
|
||||||
<Popup
|
<Popup
|
||||||
@ -347,17 +346,17 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View className={"mb-4 flex flex-col px-2.5"}>
|
<View className={"mb-4 flex flex-col px-2.5"}>
|
||||||
{userRoleVOList?.map((role) => (
|
{userRoleVOList?.map((item) => (
|
||||||
<View
|
<View
|
||||||
key={role.roleId}
|
key={item.roleId}
|
||||||
className={`role-item rounded-lg p-3 ${userRoleVO?.roleId === role.roleId ? "bg-primary/10 border-primary border" : ""}`}
|
className={`role-item rounded-lg p-3 ${item?.slug === userRoleVO.slug ? "bg-primary/10 border-primary border" : ""}`}
|
||||||
onClick={() => handleRoleSelect(role)}
|
onClick={() => handleRoleSelect(item)}
|
||||||
>
|
>
|
||||||
<View className="flex items-center justify-between">
|
<View className="flex items-center justify-between">
|
||||||
<View>
|
<View>
|
||||||
<View className="font-medium">{role.name}</View>
|
<View className="font-medium">{item.name}</View>
|
||||||
<View className="text-xs text-gray-500">
|
<View className="text-xs text-gray-500">
|
||||||
{role.description || "暂无描述"}
|
{item.description || "暂无描述"}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -4,25 +4,26 @@ import { View } from "@tarojs/components";
|
|||||||
import { CustomTabBar, Icon, IconNames } from "@/components";
|
import { CustomTabBar, Icon, IconNames } from "@/components";
|
||||||
import workbench from "@/constant/workbench";
|
import workbench from "@/constant/workbench";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl } from "@/utils";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { role } = props;
|
const { userRoleVO } = props;
|
||||||
|
const { slug } = userRoleVO;
|
||||||
const [reviewCards, setReviewCards] = useState(
|
const [reviewCards, setReviewCards] = useState(
|
||||||
workbench.reviewCardMap[role] || [],
|
workbench.reviewCardMap[slug] || [],
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Taro.setNavigationBarTitle({
|
Taro.setNavigationBarTitle({
|
||||||
title: workbench.roleSlugMap[role] + "工作台",
|
title: workbench.roleSlugMap[slug] + "工作台",
|
||||||
});
|
});
|
||||||
|
|
||||||
setReviewCards(workbench.reviewCardMap[role] || []);
|
setReviewCards(workbench.reviewCardMap[slug] || []);
|
||||||
// 获取草稿数量
|
// 获取草稿数量
|
||||||
if (
|
if (
|
||||||
(role === "origin-entry" || role === "market-buyer") &&
|
(slug === "origin-entry" || slug === "market-buyer") &&
|
||||||
reviewCards.some((card) => card.id === "draftPurchase")
|
reviewCards.some((card) => card.id === "draftPurchase")
|
||||||
) {
|
) {
|
||||||
business.purchaseOrder
|
business.purchaseOrder
|
||||||
@ -42,13 +43,13 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [role]);
|
}, [userRoleVO]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View className="flex flex-1 flex-col gap-2.5 p-2.5">
|
<View className="flex flex-1 flex-col gap-2.5 p-2.5">
|
||||||
{/* 新建采购单按钮 */}
|
{/* 新建采购单按钮 */}
|
||||||
{role === "origin-entry" && (
|
{slug === "origin-entry" && (
|
||||||
<View>
|
<View>
|
||||||
<View
|
<View
|
||||||
className="bg-primary flex w-full flex-col items-center justify-center space-y-2 rounded-xl py-2.5 text-white"
|
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>
|
</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>
|
||||||
<View className="grid grid-cols-4 gap-3">
|
<View className="grid grid-cols-4 gap-3">
|
||||||
{/* 循环渲染快捷功能 */}
|
{/* 循环渲染快捷功能 */}
|
||||||
{workbench.quickActionMap[role].map((action) => (
|
{workbench.quickActionMap[slug].map((action) => (
|
||||||
<View
|
<View
|
||||||
key={action.id}
|
key={action.id}
|
||||||
className="rounded-xl bg-white p-3 text-center shadow-sm"
|
className="rounded-xl bg-white p-3 text-center shadow-sm"
|
||||||
@ -130,7 +103,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
<CustomTabBar role={role} />
|
<CustomTabBar userRoleVO={userRoleVO} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,13 +1,97 @@
|
|||||||
import hocAuth from "@/hocs/auth";
|
import hocAuth from "@/hocs/auth";
|
||||||
import { CommonComponent } from "@/types/typings";
|
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) {
|
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 (
|
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";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { role } = props;
|
const { userRoleVO } = props;
|
||||||
|
|
||||||
console.log("role", role);
|
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useState<"todo" | "done" | "message">(
|
const [activeTab, setActiveTab] = useState<"todo" | "done" | "message">(
|
||||||
"message",
|
"message",
|
||||||
@ -367,7 +365,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
{activeTab === "done" && renderDoneList()}
|
{activeTab === "done" && renderDoneList()}
|
||||||
{activeTab === "message" && renderMessageList()}
|
{activeTab === "message" && renderMessageList()}
|
||||||
</View>
|
</View>
|
||||||
<CustomTabBar role={role} />
|
<CustomTabBar userRoleVO={userRoleVO} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import Taro, { useReady, getCurrentInstance } from "@tarojs/taro";
|
import Taro, { getCurrentInstance, useReady } from "@tarojs/taro";
|
||||||
import { View, Camera, Canvas, Button, Image } from "@tarojs/components";
|
import { Button, Camera, Canvas, Image, View } from "@tarojs/components";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { ocrAction } from "@/utils/ocr";
|
import { ocrAction } from "@/utils";
|
||||||
import ScanCode_FlashClose from "../../../resources/ScanCode_FlashClose@3x.png";
|
import ScanCode_FlashClose from "../../../resources/ScanCode_FlashClose@3x.png";
|
||||||
import ScanCode_Flash from "../../../resources/ScanCode_Flash@3x.png";
|
import ScanCode_Flash from "../../../resources/ScanCode_Flash@3x.png";
|
||||||
import ScanCode_Frame from "../../../resources/ScanCode_Frame.png";
|
import ScanCode_Frame from "../../../resources/ScanCode_Frame.png";
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
|
|||||||
import auth from "@/services/auth";
|
import auth from "@/services/auth";
|
||||||
import { userStore } from "@/store/user-store";
|
import { userStore } from "@/store/user-store";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { aesEncrypt } from "@/utils/aes";
|
import { aesEncrypt } from "@/utils";
|
||||||
import Captcha from "@/components/captcha";
|
import Captcha from "@/components/captcha";
|
||||||
import { Image, Text, View } from "@tarojs/components";
|
import { Image, Text, View } from "@tarojs/components";
|
||||||
import base from "@/hocs/base";
|
import base from "@/hocs/base";
|
||||||
|
|||||||
@ -9,9 +9,12 @@ import {
|
|||||||
PurchaseOrderFinalApprove,
|
PurchaseOrderFinalApprove,
|
||||||
PurchaseOrderRejectFinal,
|
PurchaseOrderRejectFinal,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import {
|
||||||
import { formatCurrency, formatUnitPrice } from "@/utils/format";
|
buildUrl,
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
formatCurrency,
|
||||||
|
formatUnitPrice,
|
||||||
|
PurchaseOrderCalculator,
|
||||||
|
} from "@/utils";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { router, isInitialized, setIsInitialized } = props;
|
const { router, isInitialized, setIsInitialized } = props;
|
||||||
|
|||||||
@ -10,12 +10,10 @@ import { business } from "@/services";
|
|||||||
import hocAuth from "@/hocs/auth";
|
import hocAuth from "@/hocs/auth";
|
||||||
import { CommonComponent } from "@/types/typings";
|
import { CommonComponent } from "@/types/typings";
|
||||||
import { Label, Text, View } from "@tarojs/components";
|
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 { Button } from "@nutui/nutui-react-taro";
|
||||||
import purchaseOrder from "@/constant/purchaseOrder";
|
import purchaseOrder from "@/constant/purchaseOrder";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { formatCurrency } from "@/utils/format";
|
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { shareOptions } = props;
|
const { shareOptions } = props;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { Text, View } from "@tarojs/components";
|
|||||||
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl } from "@/utils";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { router, setLoading } = props;
|
const { router, setLoading } = props;
|
||||||
|
|||||||
@ -15,15 +15,13 @@ import { business } from "@/services";
|
|||||||
import hocAuth from "@/hocs/auth";
|
import hocAuth from "@/hocs/auth";
|
||||||
import { CommonComponent } from "@/types/typings";
|
import { CommonComponent } from "@/types/typings";
|
||||||
import { Label, Text, View } from "@tarojs/components";
|
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 { Button } from "@nutui/nutui-react-taro";
|
||||||
import purchaseOrder from "@/constant/purchaseOrder";
|
import purchaseOrder from "@/constant/purchaseOrder";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { formatCurrency } from "@/utils/format";
|
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { role, shareOptions } = props;
|
const { userRoleVO, shareOptions } = props;
|
||||||
|
|
||||||
const [state, setState] =
|
const [state, setState] =
|
||||||
useState<BusinessAPI.PurchaseOrderPageQry["state"]>();
|
useState<BusinessAPI.PurchaseOrderPageQry["state"]>();
|
||||||
@ -56,7 +54,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
activeKey: "state",
|
activeKey: "state",
|
||||||
defaultActiveKey: state || "ALL",
|
defaultActiveKey: state || "ALL",
|
||||||
items: purchaseOrder.stateList.filter((item) => {
|
items: purchaseOrder.stateList.filter((item) => {
|
||||||
if (role === "reviewer") {
|
if (userRoleVO.slug === "reviewer") {
|
||||||
return item.value !== "DRAFT";
|
return item.value !== "DRAFT";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +98,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
</View>
|
</View>
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
role === "origin-entry" && (
|
userRoleVO.slug === "origin-entry" && (
|
||||||
<View className={"flex flex-row gap-2 p-3"} key={"create"}>
|
<View className={"flex flex-row gap-2 p-3"} key={"create"}>
|
||||||
<View className={"flex-1"}>
|
<View className={"flex-1"}>
|
||||||
<View
|
<View
|
||||||
@ -275,7 +273,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{role === "boss" && (
|
{userRoleVO.slug === "boss" && (
|
||||||
<View className={"py-2.5"}>
|
<View className={"py-2.5"}>
|
||||||
{purchaseOrderVO.state === "WAITING_APPROVE" && (
|
{purchaseOrderVO.state === "WAITING_APPROVE" && (
|
||||||
<View className={"flex flex-row justify-end gap-2"}>
|
<View className={"flex flex-row justify-end gap-2"}>
|
||||||
@ -307,7 +305,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
{role === "reviewer" && (
|
{userRoleVO.slug === "reviewer" && (
|
||||||
<View className={"py-2.5"}>
|
<View className={"py-2.5"}>
|
||||||
{purchaseOrderVO.state === "WAITING_AUDIT" && (
|
{purchaseOrderVO.state === "WAITING_AUDIT" && (
|
||||||
<View className={"flex flex-row justify-end gap-2"}>
|
<View className={"flex flex-row justify-end gap-2"}>
|
||||||
@ -360,7 +358,7 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
{role === "origin-entry" && (
|
{userRoleVO.slug === "origin-entry" && (
|
||||||
<View className={"py-2.5"}>
|
<View className={"py-2.5"}>
|
||||||
{purchaseOrderVO.state === "DRAFT" && (
|
{purchaseOrderVO.state === "DRAFT" && (
|
||||||
<View className={"flex flex-row justify-end gap-2"}>
|
<View className={"flex flex-row justify-end gap-2"}>
|
||||||
|
|||||||
@ -26,11 +26,13 @@ import {
|
|||||||
WeighRef,
|
WeighRef,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
import {
|
||||||
|
buildUrl,
|
||||||
|
generateShortId,
|
||||||
|
PurchaseOrderCalculator,
|
||||||
|
SupplierWeightCalculator,
|
||||||
|
} from "@/utils";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
|
||||||
import { SupplierWeightCalculator } from "@/utils/SupplierWeightCalculator";
|
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
const defaultSupplierList: SupplierVO[] = [
|
const defaultSupplierList: SupplierVO[] = [
|
||||||
{
|
{
|
||||||
@ -61,7 +63,7 @@ const defaultSupplierList: SupplierVO[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { router, role, setLoading } = props;
|
const { router, userRoleVO, setLoading } = props;
|
||||||
|
|
||||||
const [orderId, setOrderId] = useState(
|
const [orderId, setOrderId] = useState(
|
||||||
router.params.orderId as BusinessAPI.PurchaseOrderShowQry["orderId"],
|
router.params.orderId as BusinessAPI.PurchaseOrderShowQry["orderId"],
|
||||||
@ -154,7 +156,10 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
.then(({ data: { data: purchaseOrder, success } }) => {
|
.then(({ data: { data: purchaseOrder, success } }) => {
|
||||||
if (success && purchaseOrder) {
|
if (success && purchaseOrder) {
|
||||||
// 如果订单状态不是草稿,则跳转到预览页面
|
// 如果订单状态不是草稿,则跳转到预览页面
|
||||||
if (purchaseOrder.state !== "DRAFT" && role === "origin-entry") {
|
if (
|
||||||
|
purchaseOrder.state !== "DRAFT" &&
|
||||||
|
userRoleVO.slug === "origin-entry"
|
||||||
|
) {
|
||||||
Taro.redirectTo({
|
Taro.redirectTo({
|
||||||
url: buildUrl("/pages/purchase/purchaser/preview", {
|
url: buildUrl("/pages/purchase/purchaser/preview", {
|
||||||
orderId: purchaseOrder.orderId,
|
orderId: purchaseOrder.orderId,
|
||||||
|
|||||||
@ -11,12 +11,10 @@ import { business } from "@/services";
|
|||||||
import hocAuth from "@/hocs/auth";
|
import hocAuth from "@/hocs/auth";
|
||||||
import { CommonComponent } from "@/types/typings";
|
import { CommonComponent } from "@/types/typings";
|
||||||
import { Label, Text, View } from "@tarojs/components";
|
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 { Button } from "@nutui/nutui-react-taro";
|
||||||
import purchaseOrder from "@/constant/purchaseOrder";
|
import purchaseOrder from "@/constant/purchaseOrder";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { formatCurrency } from "@/utils/format";
|
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { shareOptions } = props;
|
const { shareOptions } = props;
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl } from "@/utils";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { router } = props;
|
const { router } = props;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { Text, View } from "@tarojs/components";
|
|||||||
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl } from "@/utils";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { router, setLoading } = props;
|
const { router, setLoading } = props;
|
||||||
|
|||||||
@ -33,8 +33,7 @@ import {
|
|||||||
TaxSubsidySection,
|
TaxSubsidySection,
|
||||||
WorkerAdvanceSection,
|
WorkerAdvanceSection,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl, PurchaseOrderCalculator } from "@/utils";
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
const sections = {
|
const sections = {
|
||||||
// 市场报价
|
// 市场报价
|
||||||
@ -125,7 +124,8 @@ const sections = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
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
|
const orderId = router.params
|
||||||
.orderId as BusinessAPI.PurchaseOrderVO["orderId"];
|
.orderId as BusinessAPI.PurchaseOrderVO["orderId"];
|
||||||
@ -436,8 +436,8 @@ export default hocAuth(function Page(props: CommonComponent) {
|
|||||||
<Input
|
<Input
|
||||||
type="text"
|
type="text"
|
||||||
disabled={
|
disabled={
|
||||||
role === "boss" ||
|
userRoleVO.slug === "boss" ||
|
||||||
(role === "reviewer" &&
|
(userRoleVO.slug === "reviewer" &&
|
||||||
purchaseOrderVO.state !== "WAITING_AUDIT")
|
purchaseOrderVO.state !== "WAITING_AUDIT")
|
||||||
}
|
}
|
||||||
placeholder="请输入产地负责人姓名"
|
placeholder="请输入产地负责人姓名"
|
||||||
|
|||||||
@ -10,12 +10,10 @@ import { business } from "@/services";
|
|||||||
import hocAuth from "@/hocs/auth";
|
import hocAuth from "@/hocs/auth";
|
||||||
import { CommonComponent } from "@/types/typings";
|
import { CommonComponent } from "@/types/typings";
|
||||||
import { Label, Text, View } from "@tarojs/components";
|
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 { Button } from "@nutui/nutui-react-taro";
|
||||||
import purchaseOrder from "@/constant/purchaseOrder";
|
import purchaseOrder from "@/constant/purchaseOrder";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { formatCurrency } from "@/utils/format";
|
|
||||||
import { PurchaseOrderCalculator } from "@/utils/PurchaseOrderCalculator";
|
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { shareOptions } = props;
|
const { shareOptions } = props;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { Text, View } from "@tarojs/components";
|
|||||||
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
import { Button, SafeArea, Toast } from "@nutui/nutui-react-taro";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
import buildUrl from "@/utils/buildUrl";
|
import { buildUrl } from "@/utils";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { router, setLoading } = props;
|
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 { useShareAppMessage } from "@tarojs/taro";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { business } from "@/services";
|
import { business } from "@/services";
|
||||||
@ -6,8 +12,15 @@ import hocAuth from "@/hocs/auth";
|
|||||||
import { CommonComponent } from "@/types/typings";
|
import { CommonComponent } from "@/types/typings";
|
||||||
import { View } from "@tarojs/components";
|
import { View } from "@tarojs/components";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { Button, Popup, SafeArea, Toast, Uploader, UploaderFileItem } from "@nutui/nutui-react-taro";
|
import {
|
||||||
import { uploadFile } from "@/utils/uploader";
|
Button,
|
||||||
|
Popup,
|
||||||
|
SafeArea,
|
||||||
|
Toast,
|
||||||
|
Uploader,
|
||||||
|
UploaderFileItem,
|
||||||
|
} from "@nutui/nutui-react-taro";
|
||||||
|
import { uploadFile } from "@/utils";
|
||||||
|
|
||||||
export default hocAuth(function Page(props: CommonComponent) {
|
export default hocAuth(function Page(props: CommonComponent) {
|
||||||
const { shareOptions } = props;
|
const { shareOptions } = props;
|
||||||
|
|||||||
@ -1754,6 +1754,8 @@ declare namespace BusinessAPI {
|
|||||||
employeeId?: string;
|
employeeId?: string;
|
||||||
/** 用户ID */
|
/** 用户ID */
|
||||||
userId?: string;
|
userId?: string;
|
||||||
|
/** 平台ID */
|
||||||
|
platformId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type EmployeeUpdateCmd = {
|
type EmployeeUpdateCmd = {
|
||||||
@ -2120,6 +2122,12 @@ declare namespace BusinessAPI {
|
|||||||
hideInMenu?: boolean;
|
hideInMenu?: boolean;
|
||||||
/** 权限Id */
|
/** 权限Id */
|
||||||
permissionId?: number;
|
permissionId?: number;
|
||||||
|
/** 菜单图标 */
|
||||||
|
icon?: string;
|
||||||
|
/** 图标颜色 */
|
||||||
|
iconColor?: string;
|
||||||
|
/** 背景颜色类名 */
|
||||||
|
bgColorClass?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type MenuDestroyCmd = {
|
type MenuDestroyCmd = {
|
||||||
@ -2187,6 +2195,12 @@ declare namespace BusinessAPI {
|
|||||||
hideInMenu?: boolean;
|
hideInMenu?: boolean;
|
||||||
/** 权限Id */
|
/** 权限Id */
|
||||||
permissionId?: number;
|
permissionId?: number;
|
||||||
|
/** 菜单图标 */
|
||||||
|
icon?: string;
|
||||||
|
/** 图标颜色 */
|
||||||
|
iconColor?: string;
|
||||||
|
/** 背景颜色类名 */
|
||||||
|
bgColorClass?: string;
|
||||||
/** 菜单Id */
|
/** 菜单Id */
|
||||||
menuId: string;
|
menuId: string;
|
||||||
};
|
};
|
||||||
@ -2214,6 +2228,12 @@ declare namespace BusinessAPI {
|
|||||||
routes?: any[];
|
routes?: any[];
|
||||||
/** 权限id */
|
/** 权限id */
|
||||||
permissionId: number;
|
permissionId: number;
|
||||||
|
/** 菜单图标 */
|
||||||
|
icon?: string;
|
||||||
|
/** 图标颜色 */
|
||||||
|
iconColor?: string;
|
||||||
|
/** 背景颜色类名 */
|
||||||
|
bgColorClass?: string;
|
||||||
/** 创建时间 */
|
/** 创建时间 */
|
||||||
createdAt?: string;
|
createdAt?: string;
|
||||||
};
|
};
|
||||||
@ -2892,8 +2912,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: AgreementVO[];
|
data?: AgreementVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseBoxBrandVO = {
|
type PageResponseBoxBrandVO = {
|
||||||
@ -2905,8 +2925,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: BoxBrandVO[];
|
data?: BoxBrandVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseBoxProductVO = {
|
type PageResponseBoxProductVO = {
|
||||||
@ -2918,8 +2938,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: BoxProductVO[];
|
data?: BoxProductVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseBoxSpecVO = {
|
type PageResponseBoxSpecVO = {
|
||||||
@ -2931,8 +2951,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: BoxSpecVO[];
|
data?: BoxSpecVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseChannelVO = {
|
type PageResponseChannelVO = {
|
||||||
@ -2944,8 +2964,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: ChannelVO[];
|
data?: ChannelVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseCompanyPaymentAccountVO = {
|
type PageResponseCompanyPaymentAccountVO = {
|
||||||
@ -2957,8 +2977,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: CompanyPaymentAccountVO[];
|
data?: CompanyPaymentAccountVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseCompanyVO = {
|
type PageResponseCompanyVO = {
|
||||||
@ -2970,8 +2990,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: CompanyVO[];
|
data?: CompanyVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseCostItemVO = {
|
type PageResponseCostItemVO = {
|
||||||
@ -2983,8 +3003,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: CostItemVO[];
|
data?: CostItemVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseDealerPaymentAccountVO = {
|
type PageResponseDealerPaymentAccountVO = {
|
||||||
@ -2996,8 +3016,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: DealerPaymentAccountVO[];
|
data?: DealerPaymentAccountVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseDealerRebateCustomerVO = {
|
type PageResponseDealerRebateCustomerVO = {
|
||||||
@ -3009,8 +3029,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: DealerRebateCustomerVO[];
|
data?: DealerRebateCustomerVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseDealerVO = {
|
type PageResponseDealerVO = {
|
||||||
@ -3022,8 +3042,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: DealerVO[];
|
data?: DealerVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseDealerWarehouseVO = {
|
type PageResponseDealerWarehouseVO = {
|
||||||
@ -3035,8 +3055,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: DealerWarehouseVO[];
|
data?: DealerWarehouseVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseDictionaryVO = {
|
type PageResponseDictionaryVO = {
|
||||||
@ -3048,8 +3068,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: DictionaryVO[];
|
data?: DictionaryVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseEmployeeVO = {
|
type PageResponseEmployeeVO = {
|
||||||
@ -3061,8 +3081,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: EmployeeVO[];
|
data?: EmployeeVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseGiftBoxVO = {
|
type PageResponseGiftBoxVO = {
|
||||||
@ -3074,8 +3094,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: GiftBoxVO[];
|
data?: GiftBoxVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseMaterialVO = {
|
type PageResponseMaterialVO = {
|
||||||
@ -3087,8 +3107,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: MaterialVO[];
|
data?: MaterialVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseOrderSupplierVO = {
|
type PageResponseOrderSupplierVO = {
|
||||||
@ -3100,8 +3120,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: OrderSupplierVO[];
|
data?: OrderSupplierVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponsePermissionVO = {
|
type PageResponsePermissionVO = {
|
||||||
@ -3113,8 +3133,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: PermissionVO[];
|
data?: PermissionVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponsePlatformVO = {
|
type PageResponsePlatformVO = {
|
||||||
@ -3126,8 +3146,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: PlatformVO[];
|
data?: PlatformVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseProductVO = {
|
type PageResponseProductVO = {
|
||||||
@ -3139,8 +3159,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: ProductVO[];
|
data?: ProductVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponsePurchaseOrderVO = {
|
type PageResponsePurchaseOrderVO = {
|
||||||
@ -3152,8 +3172,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: PurchaseOrderVO[];
|
data?: PurchaseOrderVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseRoleVO = {
|
type PageResponseRoleVO = {
|
||||||
@ -3165,8 +3185,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: RoleVO[];
|
data?: RoleVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseShipOrderVO = {
|
type PageResponseShipOrderVO = {
|
||||||
@ -3178,8 +3198,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: ShipOrderVO[];
|
data?: ShipOrderVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseSupplierVO = {
|
type PageResponseSupplierVO = {
|
||||||
@ -3191,8 +3211,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: SupplierVO[];
|
data?: SupplierVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PageResponseUserVO = {
|
type PageResponseUserVO = {
|
||||||
@ -3204,8 +3224,8 @@ declare namespace BusinessAPI {
|
|||||||
pageIndex?: number;
|
pageIndex?: number;
|
||||||
data?: UserVO[];
|
data?: UserVO[];
|
||||||
empty?: boolean;
|
empty?: boolean;
|
||||||
notEmpty?: boolean;
|
|
||||||
totalPages?: number;
|
totalPages?: number;
|
||||||
|
notEmpty?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type pageRoleParams = {
|
type pageRoleParams = {
|
||||||
@ -3750,6 +3770,8 @@ declare namespace BusinessAPI {
|
|||||||
roleIdList?: number[];
|
roleIdList?: number[];
|
||||||
/** 平台Id */
|
/** 平台Id */
|
||||||
platformId?: string;
|
platformId?: string;
|
||||||
|
/** 平台Id */
|
||||||
|
platformIdList?: string;
|
||||||
/** 角色类型 */
|
/** 角色类型 */
|
||||||
type?: number;
|
type?: number;
|
||||||
offset?: number;
|
offset?: number;
|
||||||
@ -3810,6 +3832,8 @@ declare namespace BusinessAPI {
|
|||||||
description?: string;
|
description?: string;
|
||||||
/** 平台id */
|
/** 平台id */
|
||||||
platformId: string;
|
platformId: string;
|
||||||
|
/** 平台 */
|
||||||
|
platformVO?: PlatformVO;
|
||||||
/** 权限列表 */
|
/** 权限列表 */
|
||||||
permissionId: number[];
|
permissionId: number[];
|
||||||
/** 菜单列表 */
|
/** 菜单列表 */
|
||||||
@ -4823,6 +4847,8 @@ declare namespace BusinessAPI {
|
|||||||
userId: string;
|
userId: string;
|
||||||
/** 描述 */
|
/** 描述 */
|
||||||
description: string;
|
description: string;
|
||||||
|
/** 平台ID */
|
||||||
|
platformId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type UserShowQry = {
|
type UserShowQry = {
|
||||||
|
|||||||
@ -20,6 +20,8 @@ request.interceptors.request.use(
|
|||||||
config.headers["Xh-Role-Slug"] = slug;
|
config.headers["Xh-Role-Slug"] = slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.headers["Xh-Platform-Id"] = "1991353387274342401";
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
|||||||
@ -4,12 +4,12 @@ type State = {
|
|||||||
tabBar?: {
|
tabBar?: {
|
||||||
selected?: number;
|
selected?: number;
|
||||||
};
|
};
|
||||||
role?: string;
|
userRoleVO?: AuthAPI.UserRoleVO;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Action = {
|
type Action = {
|
||||||
setTabBar: (selected: number) => void;
|
setTabBar: (selected: number) => void;
|
||||||
setRole: (role: string) => void;
|
setUserRoleVO: (userRoleVO: AuthAPI.UserRoleVO) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const globalStore = create<State & Action>((set) => ({
|
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(() => ({
|
set(() => ({
|
||||||
role: role,
|
userRoleVO: userRoleVO,
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import auth from "@/services/auth";
|
import auth from "@/services/auth";
|
||||||
import { getStorageSyncTime, setStorageSyncSecond } from "@/utils/cache";
|
import { getStorageSyncTime, setStorageSyncSecond } from "@/utils";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@ -15,7 +15,7 @@ export const userStore = create<State & Action>((set) => ({
|
|||||||
user: null,
|
user: null,
|
||||||
setUser: async () => {
|
setUser: async () => {
|
||||||
let user = getStorageSyncTime<AuthAPI.UserVO>("user");
|
let user = getStorageSyncTime<AuthAPI.UserVO>("user");
|
||||||
console.log("user", user)
|
console.log("user", user);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
const {
|
const {
|
||||||
|
|||||||
@ -12,10 +12,7 @@ export interface BasicComponent {
|
|||||||
export interface CommonComponent {
|
export interface CommonComponent {
|
||||||
user: AuthAPI.UserVO;
|
user: AuthAPI.UserVO;
|
||||||
shareOptions: any;
|
shareOptions: any;
|
||||||
role: "origin-entry" | "market-buyer" | "reviewer" | "boss";
|
userRoleVO: BusinessAPI.UserRoleVO;
|
||||||
setRole: (
|
|
||||||
role: "origin-entry" | "market-buyer" | "reviewer" | "boss",
|
|
||||||
) => void;
|
|
||||||
router: Router;
|
router: Router;
|
||||||
options: Taro.getLaunchOptionsSync.LaunchOptions;
|
options: Taro.getLaunchOptionsSync.LaunchOptions;
|
||||||
isInitialized: boolean;
|
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 {
|
export class OrderSupplierCalculator {
|
||||||
|
// @ts-ignore
|
||||||
private purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
private purchaseOrderVO: BusinessAPI.PurchaseOrderVO;
|
||||||
private orderSupplier: BusinessAPI.OrderSupplier;
|
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数组
|
// 将BoxBrand转换为OrderPackage数组
|
||||||
import { BoxBrand, BoxProduct, BoxSpec } from "@/types/typings";
|
import { BoxBrand, BoxProduct, BoxSpec } from "@/types/typings";
|
||||||
import { generateShortId } from "@/utils/generateShortId";
|
import { generateShortId } from "@/utils";
|
||||||
|
|
||||||
// 添加一个辅助函数用于分组
|
// 添加一个辅助函数用于分组
|
||||||
const groupBy = <T>(
|
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)
|
return Object.entries(params)
|
||||||
.filter(([_, value]) => value !== undefined && value !== null)
|
.filter(([_, value]) => value !== undefined && value !== null)
|
||||||
.map(([key, value]) => {
|
.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 UAParser from "ua-parser-js";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { load } from "@fingerprintjs/fingerprintjs";
|
import { load } from "@fingerprintjs/fingerprintjs";
|
||||||
import { getStorageSyncTime } from "@/utils/cache";
|
import { getStorageSyncTime } from "@/utils";
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
|
|
||||||
export const base64Key: string = "MTIzNDU2Nzg5MDEyMzQ1Ng==";
|
export const base64Key: string = "MTIzNDU2Nzg5MDEyMzQ1Ng==";
|
||||||
@ -1,8 +1,8 @@
|
|||||||
// src/utils/routeGuard.ts
|
// src/utils/routeGuard.ts
|
||||||
import Taro from "@tarojs/taro";
|
import Taro from "@tarojs/taro";
|
||||||
import {
|
import {
|
||||||
SCREENSHOT_ALLOWED_ROUTES,
|
|
||||||
RedirectResult,
|
RedirectResult,
|
||||||
|
SCREENSHOT_ALLOWED_ROUTES,
|
||||||
TABBAR_ROUTES,
|
TABBAR_ROUTES,
|
||||||
} from "@/config/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