ERPTurbo_Client/packages/app-client/src/store/global-store.ts
shenyifei 47c7bdf357 feat(purchase): 新增费用编辑功能及优化瓜农信息管理
- 添加 PriceEditor 组件用于直接编辑费用金额
- 实现 CostCard 和 CostCreate 组件以支持费用的增删改查
- 在 PurchaseOrderSubmitReview 中修正参数名 supplierId 为 orderSupplierId
- 重构 MelonFarmer 组件,改进瓜农信息处理逻辑
- 引入 generateShortId 工具函数生成唯一标识符
- 新增 OrderCostItem 模块用于处理订单费用项初始化与校验
- 优化费用模板解析和默认值填充逻辑
- 增强费用承担方及数量的验证机制
- 调整工头姓名输入时的实时更新与失焦校验功能
2025-11-27 10:37:24 +08:00

65 lines
1.5 KiB
TypeScript

import { create } from "zustand";
import { business } from "@/services";
type State = {
tabBar?: {
selected?: number;
};
loading?: boolean;
userRoleVO?: AuthAPI.UserRoleVO;
costItemVOList?: BusinessAPI.CostItemVO[];
costVOList?: BusinessAPI.CostVO[];
};
type Action = {
setTabBar: (selected: number) => void;
setLoading: (loading: boolean) => void;
setUserRoleVO: (userRoleVO: AuthAPI.UserRoleVO) => void;
fetchCosts: () => Promise<void>;
fetchCostItems: () => Promise<void>;
};
export const globalStore = create<State & Action>((set) => ({
setTabBar: (selected) => {
set(() => ({
tabBar: {
selected: selected,
},
}));
},
setLoading: (loading: boolean) => {
set(() => ({
loading: loading,
}));
},
setUserRoleVO: (userRoleVO: AuthAPI.UserRoleVO) => {
set(() => ({
userRoleVO: userRoleVO,
}));
},
fetchCosts: async () => {
try {
const { data } = await business.cost.listCost({
costListQry: {
status: true,
},
});
set({ costVOList: data.data || [] });
} catch (error) {
console.error("获取费用列表失败:", error);
}
},
fetchCostItems: async () => {
try {
const { data } = await business.costItem.listCostItem({
costItemListQry: {
status: true,
},
});
set({ costItemVOList: data.data || [] });
} catch (error) {
console.error("获取费用项目列表失败:", error);
}
},
}));