mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 07:09:20 +08:00
Compare commits
13
Commits
3f8f066a7c
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e183ed7a6 | ||
|
|
2f60efb8ef | ||
|
|
fb05b47d46 | ||
|
|
abe75f87aa | ||
|
|
7781f53d8a | ||
|
|
5427b3830c | ||
|
|
f382ba9bd7 | ||
|
|
e47f76c22a | ||
|
|
b45729fa1a | ||
|
|
16933b38ff | ||
|
|
b06cdc0309 | ||
|
|
9fafe55c4e | ||
|
|
ee985e33a9 |
@@ -0,0 +1,5 @@
|
|||||||
|
# 根目录仅薄脚本入口;勿提交本地依赖与锁外产物
|
||||||
|
node_modules/
|
||||||
|
.DS_Store
|
||||||
|
*.log
|
||||||
|
.pnpm-store/
|
||||||
@@ -1,6 +1,22 @@
|
|||||||
# AGENTS.md
|
# AGENTS.md
|
||||||
|
|
||||||
电商 DMB / ECBI 系统。根目录**不是统一工作区**:各 app 各自构建、各自装依赖,根目录无 package.json。提交走 git(分支 `dev`),commit message 用中文 conventional 格式(`feat:`/`fix:`/`refactor:`/`sql:` 前缀)。
|
电商 DMB / ECBI 系统。根目录**不是业务 monorepo**:各 app 各自构建、各自装依赖;根 `package.json` 只做开发启动薄封装(仅 `concurrently`)。`pnpm-workspace.yaml` 的 `packages: []` 用于阻断向上解析到家目录 workspace,**不要**把 `apps/*` 写进去。提交走 git(分支 `dev`),commit message 用中文 conventional 格式(`feat:`/`fix:`/`refactor:`/`sql:` 前缀)。
|
||||||
|
|
||||||
|
## 本地一键启动(根目录)
|
||||||
|
|
||||||
|
先各自装好依赖(`apps/web` 的 `pnpm install`、`apps/agent` 的 venv、Server 环境变量等),再在仓库根:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm install # 仅安装 concurrently
|
||||||
|
pnpm dev # 并行:web + server + agent
|
||||||
|
pnpm dev:web-server # 只要前后端
|
||||||
|
pnpm dev:web # 仅前端
|
||||||
|
pnpm dev:server # 仅 Java(./mvnw spring-boot:run)
|
||||||
|
pnpm dev:agent # 仅 Agent(需 apps/agent/.venv)
|
||||||
|
pnpm deploy:tui # 部署 TUI(需先 cd deploy && pnpm install;勿用 pnpm deploy,会撞内置命令)
|
||||||
|
```
|
||||||
|
|
||||||
|
Server 仍依赖本机 `DB_*` / Redis / `JWT_SECRET` 等;Agent 读 `apps/agent/.env.dev`。
|
||||||
|
|
||||||
## 目录一览
|
## 目录一览
|
||||||
|
|
||||||
@@ -53,7 +69,7 @@ deploy/ # 部署 TUI(原 ecom-deploy),流程见 deploy/MANU
|
|||||||
|
|
||||||
## 部署(deploy)
|
## 部署(deploy)
|
||||||
|
|
||||||
- TUI:`cd deploy && pnpm dev`,可选自动部署 / 仅编译 / 上传并重启
|
- TUI:根目录 `pnpm deploy:tui`(或 `cd deploy && pnpm dev`),可选自动部署 / 仅编译 / 上传并重启
|
||||||
- **`config.json` 含真实服务器地址与 SSH 私钥路径,切勿提交或打印**
|
- **`config.json` 含真实服务器地址与 SSH 私钥路径,切勿提交或打印**
|
||||||
- 部署模式:运行时镜像 + 挂载 `app/` 目录;更新 = 上传产物 + 重启容器,无需重建镜像
|
- 部署模式:运行时镜像 + 挂载 `app/` 目录;更新 = 上传产物 + 重启容器,无需重建镜像
|
||||||
- 编译产物统一放 `artifacts/`(已 gitignore):`backend/app.jar`、`frontend/` dist、`license/` 整目录
|
- 编译产物统一放 `artifacts/`(已 gitignore):`backend/app.jar`、`frontend/` dist、`license/` 整目录
|
||||||
|
|||||||
@@ -17,35 +17,26 @@ async def load_tools_for_turn(
|
|||||||
scene: str = SCENE_GENERAL,
|
scene: str = SCENE_GENERAL,
|
||||||
client_tools: list[Any] | None = None,
|
client_tools: list[Any] | None = None,
|
||||||
) -> list[Any]:
|
) -> list[Any]:
|
||||||
"""general:builtin + memory + 全部 MCP;发布场景:builtin + 目录/拼多多 MCP + 前端 ui_ 工具。"""
|
"""各场景均挂 memory_*;general 全量 MCP,发布场景仅目录/拼多多 + 前端 ui_。"""
|
||||||
from agent.tools.builtin import builtin_tools
|
from agent.tools.builtin import builtin_tools
|
||||||
from agent.tools.memory import memory_tools
|
from agent.tools.memory import memory_tools
|
||||||
from infrastructure.mcp.client import load_mcp_tools
|
from infrastructure.mcp.client import load_mcp_tools
|
||||||
|
|
||||||
scene_value = (scene or SCENE_GENERAL).strip() or SCENE_GENERAL
|
scene_value = (scene or SCENE_GENERAL).strip() or SCENE_GENERAL
|
||||||
tools: list[Any] = [*builtin_tools()]
|
tools: list[Any] = [*builtin_tools(), *memory_tools(memory, actor)]
|
||||||
|
|
||||||
|
mcp_tools = await load_mcp_tools(
|
||||||
|
settings,
|
||||||
|
company_id=actor.company_id,
|
||||||
|
user_id=actor.user_id,
|
||||||
|
)
|
||||||
if scene_value == SCENE_ECOM_GOODS_PUBLISH:
|
if scene_value == SCENE_ECOM_GOODS_PUBLISH:
|
||||||
mcp_tools = await load_mcp_tools(
|
|
||||||
settings,
|
|
||||||
company_id=actor.company_id,
|
|
||||||
user_id=actor.user_id,
|
|
||||||
)
|
|
||||||
# 发布场景:目录 + 拼多多渠道;不挂经营 BI
|
# 发布场景:目录 + 拼多多渠道;不挂经营 BI
|
||||||
mcp_tools = [
|
mcp_tools = [
|
||||||
t
|
t
|
||||||
for t in mcp_tools
|
for t in mcp_tools
|
||||||
if _tool_name(t).startswith(("catalog_", "pdd_")) or _tool_name(t) == "mcp_ping"
|
if _tool_name(t).startswith(("catalog_", "pdd_")) or _tool_name(t) == "mcp_ping"
|
||||||
]
|
]
|
||||||
tools.extend(mcp_tools)
|
|
||||||
if client_tools:
|
|
||||||
tools.extend(client_tools)
|
|
||||||
return tools
|
|
||||||
|
|
||||||
tools.extend(memory_tools(memory, actor))
|
|
||||||
mcp_tools = await load_mcp_tools(
|
|
||||||
settings, company_id=actor.company_id, user_id=actor.user_id
|
|
||||||
)
|
|
||||||
tools.extend(mcp_tools)
|
tools.extend(mcp_tools)
|
||||||
if client_tools:
|
if client_tools:
|
||||||
tools.extend(client_tools)
|
tools.extend(client_tools)
|
||||||
|
|||||||
@@ -87,13 +87,11 @@ class ChatService:
|
|||||||
session.llm_response_chain = None
|
session.llm_response_chain = None
|
||||||
await self._session_repo.update(session)
|
await self._session_repo.update(session)
|
||||||
|
|
||||||
just_saved = None
|
# 各 scene 均可按需 memory_*;显式「记住」也会 maybe_capture
|
||||||
memory_count = 0
|
just_saved = await self._memory.maybe_capture_from_user(
|
||||||
if scene == "general":
|
actor, thread_id=thread_id, text=text
|
||||||
just_saved = await self._memory.maybe_capture_from_user(
|
)
|
||||||
actor, thread_id=thread_id, text=text
|
memory_count = await self._memory.count_active(actor)
|
||||||
)
|
|
||||||
memory_count = await self._memory.count_active(actor)
|
|
||||||
|
|
||||||
system_prompt = build_system_prompt(
|
system_prompt = build_system_prompt(
|
||||||
memory_count=memory_count,
|
memory_count=memory_count,
|
||||||
|
|||||||
@@ -57,9 +57,28 @@ _PUBLISH_SYSTEM = (
|
|||||||
"不要复述工具名、回执原文、字数统计、查了几条、竞品标题全文或改写策略,除非用户问为什么这样改。"
|
"不要复述工具名、回执原文、字数统计、查了几条、竞品标题全文或改写策略,除非用户问为什么这样改。"
|
||||||
"不要主动列 SKU 编码表,不要给没问过的下一版备选,不要让用户刷新、核对,或说「如果还是旧的再告诉我」。"
|
"不要主动列 SKU 编码表,不要给没问过的下一版备选,不要让用户刷新、核对,或说「如果还是旧的再告诉我」。"
|
||||||
"禁止向用户索要或复述数字 ID。"
|
"禁止向用户索要或复述数字 ID。"
|
||||||
|
"【长期记忆】跨会话用户级记忆不自动注入;标题口径、常用规格写法、用户偏好等需要时:"
|
||||||
|
"先 memory_search,必要时 memory_load;用户要求记住用 memory_save。"
|
||||||
|
"改表仍以当前表单与用户本轮指令为准,记忆只作补充,勿用旧记忆覆盖用户刚说的写法。"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _append_memory_status(
|
||||||
|
system: str,
|
||||||
|
*,
|
||||||
|
memory_count: int,
|
||||||
|
memory_just_saved: str | None,
|
||||||
|
) -> str:
|
||||||
|
if memory_count > 0:
|
||||||
|
system += (
|
||||||
|
f"\n\n当前用户约有 {memory_count} 条长期记忆,"
|
||||||
|
"需要时用 memory_search / memory_load。"
|
||||||
|
)
|
||||||
|
if memory_just_saved:
|
||||||
|
system += f"\n\n【本轮已写入长期记忆】{memory_just_saved}"
|
||||||
|
return system
|
||||||
|
|
||||||
|
|
||||||
def build_system_prompt(
|
def build_system_prompt(
|
||||||
*,
|
*,
|
||||||
memory_count: int = 0,
|
memory_count: int = 0,
|
||||||
@@ -73,16 +92,15 @@ def build_system_prompt(
|
|||||||
# 控制体积,避免拖垮上下文
|
# 控制体积,避免拖垮上下文
|
||||||
if len(snap_text) > 12000:
|
if len(snap_text) > 12000:
|
||||||
snap_text = snap_text[:12000] + "…(截断)"
|
snap_text = snap_text[:12000] + "…(截断)"
|
||||||
return (
|
system = f"{_PUBLISH_SYSTEM}\n\n【当前发布表单】\n{snap_text}"
|
||||||
f"{_PUBLISH_SYSTEM}\n\n【当前发布表单】\n{snap_text}"
|
return _append_memory_status(
|
||||||
|
system,
|
||||||
|
memory_count=memory_count,
|
||||||
|
memory_just_saved=memory_just_saved,
|
||||||
)
|
)
|
||||||
|
|
||||||
system = _BASE_SYSTEM
|
return _append_memory_status(
|
||||||
if memory_count > 0:
|
_BASE_SYSTEM,
|
||||||
system += (
|
memory_count=memory_count,
|
||||||
f"\n\n当前用户约有 {memory_count} 条长期记忆,"
|
memory_just_saved=memory_just_saved,
|
||||||
"需要时用 memory_search / memory_load。"
|
)
|
||||||
)
|
|
||||||
if memory_just_saved:
|
|
||||||
system += f"\n\n【本轮已写入长期记忆】{memory_just_saved}"
|
|
||||||
return system
|
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
-- 快递报价编辑页:后端动态路由(embedded,不进侧栏)
|
||||||
|
|
||||||
|
INSERT INTO `sys_menu` (
|
||||||
|
`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`,
|
||||||
|
`redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
14022,
|
||||||
|
(SELECT id FROM `sys_menu` WHERE `id` = 7 OR `title` = '经营店铺' OR `route_name` = 'ShopCatalog' LIMIT 1),
|
||||||
|
0,
|
||||||
|
'ExpressQuoteEdit',
|
||||||
|
'快递报价单编辑',
|
||||||
|
'/ec/warehouse/express-quote/edit/:id?',
|
||||||
|
'/ec/warehouse/express-quote/edit/index',
|
||||||
|
'',
|
||||||
|
'lucide:file-pen-line',
|
||||||
|
'embedded',
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
8
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_menu` WHERE `id` = 14022 OR `route_name` = 'ExpressQuoteEdit'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 菜单权限:读写创建更新(打开编辑页)
|
||||||
|
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||||
|
SELECT m.id, p.id
|
||||||
|
FROM `sys_menu` m
|
||||||
|
JOIN `sys_permission` p ON p.code IN (
|
||||||
|
'ec:express-quote:read',
|
||||||
|
'ec:express-quote:create',
|
||||||
|
'ec:express-quote:update'
|
||||||
|
)
|
||||||
|
WHERE m.route_name = 'ExpressQuoteEdit' OR m.id = 14022;
|
||||||
|
|
||||||
|
-- 已开通快递报价列表的公司同步开通编辑页
|
||||||
|
INSERT IGNORE INTO `org_company_menu` (`company_id`, `menu_id`, `status`)
|
||||||
|
SELECT DISTINCT cm.`company_id`, 14022, 1
|
||||||
|
FROM `org_company_menu` cm
|
||||||
|
WHERE cm.`menu_id` = 14021;
|
||||||
|
|
||||||
|
-- 已有快递报价菜单的岗位同步开通
|
||||||
|
INSERT IGNORE INTO `org_position_menu` (`position_id`, `menu_id`)
|
||||||
|
SELECT pm.`position_id`, 14022
|
||||||
|
FROM `org_position_menu` pm
|
||||||
|
WHERE pm.`menu_id` = 14021;
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
-- 发货仓库 / 快递报价从「经营店铺」拆到一级目录「发货物流」
|
||||||
|
|
||||||
|
INSERT INTO `sys_menu` (
|
||||||
|
`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`,
|
||||||
|
`redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
14019,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
'FreightCatalog',
|
||||||
|
'发货物流',
|
||||||
|
'/freight',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
'lucide:truck',
|
||||||
|
'catalog',
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
6
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_menu` WHERE `id` = 14019 OR `route_name` = 'FreightCatalog'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 子菜单改挂到发货物流(含编辑页 embedded)
|
||||||
|
UPDATE `sys_menu`
|
||||||
|
SET `parent_id` = 14019
|
||||||
|
WHERE `id` IN (14020, 14021, 14022)
|
||||||
|
OR `route_name` IN (
|
||||||
|
'WarehouseManagement',
|
||||||
|
'ExpressQuoteManagement',
|
||||||
|
'ExpressQuoteEdit'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 已开通仓/报价子菜单的公司补挂父目录,避免侧栏断树
|
||||||
|
INSERT IGNORE INTO `org_company_menu` (`company_id`, `menu_id`, `status`)
|
||||||
|
SELECT DISTINCT cm.`company_id`, 14019, 1
|
||||||
|
FROM `org_company_menu` cm
|
||||||
|
WHERE cm.`menu_id` IN (14020, 14021, 14022);
|
||||||
|
|
||||||
|
-- 已有子菜单的岗位补挂父目录
|
||||||
|
INSERT IGNORE INTO `org_position_menu` (`position_id`, `menu_id`)
|
||||||
|
SELECT DISTINCT pm.`position_id`, 14019
|
||||||
|
FROM `org_position_menu` pm
|
||||||
|
WHERE pm.`menu_id` IN (14020, 14021, 14022);
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
-- 发货物流:发货仓商品(仓×SKU 默认分配)
|
||||||
|
|
||||||
|
-- 侧栏顺序:发货仓库 → 发货仓商品 → 快递报价
|
||||||
|
UPDATE `sys_menu` SET `order` = 1 WHERE `id` = 14020 OR `route_name` = 'WarehouseManagement';
|
||||||
|
UPDATE `sys_menu` SET `order` = 3 WHERE `id` = 14021 OR `route_name` = 'ExpressQuoteManagement';
|
||||||
|
|
||||||
|
INSERT INTO `sys_menu` (
|
||||||
|
`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`,
|
||||||
|
`redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
14023,
|
||||||
|
(SELECT id FROM `sys_menu` WHERE `id` = 14019 OR `route_name` = 'FreightCatalog' LIMIT 1),
|
||||||
|
0,
|
||||||
|
'WarehouseSkuManagement',
|
||||||
|
'发货仓商品',
|
||||||
|
'/ec/warehouse/sku',
|
||||||
|
'/ec/warehouse/sku/index',
|
||||||
|
'',
|
||||||
|
'lucide:boxes',
|
||||||
|
'menu',
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
FROM DUAL
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT 1 FROM `sys_menu` WHERE `id` = 14023 OR `route_name` = 'WarehouseSkuManagement'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 复用发货仓库读写权限
|
||||||
|
INSERT IGNORE INTO `sys_menu_permission` (`menu_id`, `permission_id`)
|
||||||
|
SELECT m.id, p.id
|
||||||
|
FROM `sys_menu` m
|
||||||
|
JOIN `sys_permission` p ON p.code IN ('ec:warehouse:read', 'ec:warehouse:update')
|
||||||
|
WHERE m.route_name = 'WarehouseSkuManagement' OR m.id = 14023;
|
||||||
|
|
||||||
|
-- 已开通发货物流或发货仓库的公司同步开通
|
||||||
|
INSERT IGNORE INTO `org_company_menu` (`company_id`, `menu_id`, `status`)
|
||||||
|
SELECT DISTINCT cm.`company_id`, 14023, 1
|
||||||
|
FROM `org_company_menu` cm
|
||||||
|
WHERE cm.`menu_id` IN (14019, 14020);
|
||||||
|
|
||||||
|
INSERT IGNORE INTO `org_position_menu` (`position_id`, `menu_id`)
|
||||||
|
SELECT DISTINCT pm.`position_id`, 14023
|
||||||
|
FROM `org_position_menu` pm
|
||||||
|
WHERE pm.`menu_id` IN (14019, 14020);
|
||||||
+6
@@ -21,4 +21,10 @@ public class ProductSkuFilterDTO {
|
|||||||
|
|
||||||
/** 模糊匹配:SKU 名称、SKU 编码、所属商品名称、商品编码 */
|
/** 模糊匹配:SKU 名称、SKU 编码、所属商品名称、商品编码 */
|
||||||
private String keywords;
|
private String keywords;
|
||||||
|
|
||||||
|
/** 默认发货仓;与 unassignedOnly 互斥(未分配优先) */
|
||||||
|
private Long warehouseId;
|
||||||
|
|
||||||
|
/** true = 仅未分配发货仓(warehouse_id IS NULL) */
|
||||||
|
private Boolean unassignedOnly;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -239,6 +239,11 @@ public class ProductSkuServiceImpl extends ServiceImpl<ProductSkuMapper, Product
|
|||||||
if (filter.getExcludeProductId() != null) {
|
if (filter.getExcludeProductId() != null) {
|
||||||
wrapper.ne(ProductSkuPO::getProductId, filter.getExcludeProductId());
|
wrapper.ne(ProductSkuPO::getProductId, filter.getExcludeProductId());
|
||||||
}
|
}
|
||||||
|
if (Boolean.TRUE.equals(filter.getUnassignedOnly())) {
|
||||||
|
wrapper.isNull(ProductSkuPO::getWarehouseId);
|
||||||
|
} else if (filter.getWarehouseId() != null) {
|
||||||
|
wrapper.eq(ProductSkuPO::getWarehouseId, filter.getWarehouseId());
|
||||||
|
}
|
||||||
if (filter.getKeywords() != null && !filter.getKeywords().trim().isEmpty()) {
|
if (filter.getKeywords() != null && !filter.getKeywords().trim().isEmpty()) {
|
||||||
String keywords = filter.getKeywords().trim();
|
String keywords = filter.getKeywords().trim();
|
||||||
LambdaQueryWrapper<ProductPO> productKw = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<ProductPO> productKw = new LambdaQueryWrapper<>();
|
||||||
|
|||||||
+4
-2
@@ -74,8 +74,10 @@ public class ExpressQuoteController {
|
|||||||
|
|
||||||
@GetMapping("/detail/{id}")
|
@GetMapping("/detail/{id}")
|
||||||
@RequirePermission(value = "ec:express-quote:read", description = "报价详情", allowSuper = true)
|
@RequirePermission(value = "ec:express-quote:read", description = "报价详情", allowSuper = true)
|
||||||
public ApiResponse<ExpressQuoteVO> detail(@PathVariable Long id) {
|
public ApiResponse<ExpressQuoteVO> detail(
|
||||||
return ApiResponse.success("获取成功", expressQuoteService.detail(id));
|
@PathVariable Long id,
|
||||||
|
@RequestParam(value = "withHistory", defaultValue = "false") boolean withHistory) {
|
||||||
|
return ApiResponse.success("获取成功", expressQuoteService.detail(id, withHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/{quoteId}/version")
|
@PostMapping("/{quoteId}/version")
|
||||||
|
|||||||
+24
-1
@@ -6,14 +6,16 @@ import top.xyquan.ecomdmbbackend.common.annotation.RequirePermission;
|
|||||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.vo.ProductSkuVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.dto.WarehouseDtos;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.dto.WarehouseDtos;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.WarehouseExpressBindVO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.WarehouseExpressBindVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.WarehouseVO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.WarehouseVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.service.WarehouseService;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.service.WarehouseService;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/** 发货仓库与报价绑定。 */
|
/** 发货仓库、报价绑定与仓商品。 */
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/ec/warehouse")
|
@RequestMapping("/api/ec/warehouse")
|
||||||
public class WarehouseController {
|
public class WarehouseController {
|
||||||
@@ -86,4 +88,25 @@ public class WarehouseController {
|
|||||||
warehouseService.removeBind(bindId);
|
warehouseService.removeBind(bindId);
|
||||||
return ApiResponse.success("已解绑");
|
return ApiResponse.success("已解绑");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/skus/list")
|
||||||
|
@RequirePermission(value = "ec:warehouse:read", description = "发货仓商品列表", allowSuper = true)
|
||||||
|
public ApiResponse<PageResultVO<ProductSkuVO>> skuList(
|
||||||
|
@Valid @RequestBody PageQueryDTO<WarehouseDtos.SkuFilter> query) {
|
||||||
|
return ApiResponse.success("获取成功", warehouseService.pageSkus(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/skus/unassigned-count")
|
||||||
|
@RequirePermission(value = "ec:warehouse:read", description = "未分配 SKU 数", allowSuper = true)
|
||||||
|
public ApiResponse<Map<String, Long>> unassignedSkuCount() {
|
||||||
|
return ApiResponse.success("获取成功", Map.of("count", warehouseService.countUnassignedSkus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/skus/batch-assign")
|
||||||
|
@RequirePermission(value = "ec:warehouse:update", description = "批量分配发货仓", allowSuper = true)
|
||||||
|
public ApiResponse<Map<String, Integer>> batchAssignSkus(
|
||||||
|
@Valid @RequestBody WarehouseDtos.SkuBatchAssign dto) {
|
||||||
|
int updated = warehouseService.batchAssignSkus(dto);
|
||||||
|
return ApiResponse.success("分配成功", Map.of("updated", updated));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ public class FreightCostCalculator {
|
|||||||
.toList();
|
.toList();
|
||||||
Map<Long, ProductSkuPO> skuMap = new HashMap<>();
|
Map<Long, ProductSkuPO> skuMap = new HashMap<>();
|
||||||
if (!skuIds.isEmpty()) {
|
if (!skuIds.isEmpty()) {
|
||||||
for (ProductSkuPO sku : productSkuMapper.selectBatchIds(skuIds)) {
|
for (ProductSkuPO sku : productSkuMapper.selectByIds(skuIds)) {
|
||||||
skuMap.put(sku.getId(), sku);
|
skuMap.put(sku.getId(), sku);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
@@ -1,9 +1,12 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.dto;
|
package top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.dto;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/** 仓库相关 DTO。 */
|
/** 仓库相关 DTO。 */
|
||||||
public final class WarehouseDtos {
|
public final class WarehouseDtos {
|
||||||
|
|
||||||
@@ -55,4 +58,22 @@ public final class WarehouseDtos {
|
|||||||
private Integer priority;
|
private Integer priority;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 发货仓商品列表筛选(走仓权限,内部复用 SKU 查询) */
|
||||||
|
@Data
|
||||||
|
public static class SkuFilter {
|
||||||
|
private String keywords;
|
||||||
|
private Long warehouseId;
|
||||||
|
/** true = 仅未分配 */
|
||||||
|
private Boolean unassignedOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量设置 SKU 默认发货仓;warehouseId 空=取消分配 */
|
||||||
|
@Data
|
||||||
|
public static class SkuBatchAssign {
|
||||||
|
@NotEmpty(message = "请选择 SKU")
|
||||||
|
private List<Long> skuIds;
|
||||||
|
/** null = 取消分配 */
|
||||||
|
private Long warehouseId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -22,5 +22,7 @@ public class WarehouseVO {
|
|||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
/** 已绑定报价数 */
|
/** 已绑定报价数 */
|
||||||
private Integer bindCount;
|
private Integer bindCount;
|
||||||
|
/** 默认发此仓的 SKU 数 */
|
||||||
|
private Integer skuCount;
|
||||||
private List<WarehouseExpressBindVO> binds;
|
private List<WarehouseExpressBindVO> binds;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ public class ExpressQuoteImportService {
|
|||||||
}
|
}
|
||||||
expressQuoteService.requireCompanyQuote(params.getQuoteId());
|
expressQuoteService.requireCompanyQuote(params.getQuoteId());
|
||||||
expressQuoteService.upsertVersion(params.getQuoteId(), toVersionDto(draft));
|
expressQuoteService.upsertVersion(params.getQuoteId(), toVersionDto(draft));
|
||||||
return expressQuoteService.detail(params.getQuoteId());
|
return expressQuoteService.detail(params.getQuoteId(), false);
|
||||||
}
|
}
|
||||||
throw new BusinessException("不支持的导入模式: " + params.getMode());
|
throw new BusinessException("不支持的导入模式: " + params.getMode());
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -21,7 +21,12 @@ public interface ExpressQuoteService {
|
|||||||
|
|
||||||
List<ExpressQuoteVO> listEnabled();
|
List<ExpressQuoteVO> listEnabled();
|
||||||
|
|
||||||
ExpressQuoteVO detail(Long id);
|
/**
|
||||||
|
* 报价详情。
|
||||||
|
*
|
||||||
|
* @param withHistory true=加载全部版本的分区/重量带(详情抽屉);false=仅当前版本明细(编辑页)
|
||||||
|
*/
|
||||||
|
ExpressQuoteVO detail(Long id, boolean withHistory);
|
||||||
|
|
||||||
ExpressQuotePO requireCompanyQuote(Long id);
|
ExpressQuotePO requireCompanyQuote(Long id);
|
||||||
|
|
||||||
|
|||||||
+11
-1
@@ -2,6 +2,7 @@ package top.xyquan.ecomdmbbackend.modules.ec.warehouse.service;
|
|||||||
|
|
||||||
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
import top.xyquan.ecomdmbbackend.common.model.dto.PageQueryDTO;
|
||||||
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.vo.ProductSkuVO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.dto.WarehouseDtos;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.dto.WarehouseDtos;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.WarehousePO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.po.WarehousePO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.WarehouseExpressBindVO;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.WarehouseExpressBindVO;
|
||||||
@@ -9,7 +10,7 @@ import top.xyquan.ecomdmbbackend.modules.ec.warehouse.model.vo.WarehouseVO;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/** 发货仓库与报价绑定。 */
|
/** 发货仓库、报价绑定与仓商品分配。 */
|
||||||
public interface WarehouseService {
|
public interface WarehouseService {
|
||||||
|
|
||||||
WarehouseVO create(WarehouseDtos.Create dto);
|
WarehouseVO create(WarehouseDtos.Create dto);
|
||||||
@@ -33,4 +34,13 @@ public interface WarehouseService {
|
|||||||
void removeBind(Long bindId);
|
void removeBind(Long bindId);
|
||||||
|
|
||||||
List<WarehouseExpressBindVO> listBinds(Long warehouseId);
|
List<WarehouseExpressBindVO> listBinds(Long warehouseId);
|
||||||
|
|
||||||
|
/** 按仓/未分配筛选 SKU(仓权限) */
|
||||||
|
PageResultVO<ProductSkuVO> pageSkus(PageQueryDTO<WarehouseDtos.SkuFilter> query);
|
||||||
|
|
||||||
|
/** 未分配默认仓的 SKU 数量 */
|
||||||
|
long countUnassignedSkus();
|
||||||
|
|
||||||
|
/** 批量设置/清空 SKU 默认发货仓 */
|
||||||
|
int batchAssignSkus(WarehouseDtos.SkuBatchAssign dto);
|
||||||
}
|
}
|
||||||
|
|||||||
+76
-18
@@ -35,7 +35,9 @@ import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -91,7 +93,7 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
if (dto.getInitialVersion() != null) {
|
if (dto.getInitialVersion() != null) {
|
||||||
upsertVersionInternal(po, dto.getInitialVersion());
|
upsertVersionInternal(po, dto.getInitialVersion());
|
||||||
}
|
}
|
||||||
return detail(po.getId());
|
return detail(po.getId(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,7 +109,7 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
po.setUpdateBy(currentUserContext.getCurrentUserId());
|
po.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||||
updateById(po);
|
updateById(po);
|
||||||
markDirtyForQuote(po.getId(), null);
|
markDirtyForQuote(po.getId(), null);
|
||||||
return detail(id);
|
return detail(id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -166,20 +168,58 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExpressQuoteVO detail(Long id) {
|
public ExpressQuoteVO detail(Long id, boolean withHistory) {
|
||||||
ExpressQuotePO po = requireCompanyQuote(id);
|
ExpressQuotePO po = requireCompanyQuote(id);
|
||||||
ExpressQuoteVO vo = toBriefVo(po);
|
ExpressQuoteVO vo = new ExpressQuoteVO();
|
||||||
|
BeanCopyUtils.copyProperties(po, vo);
|
||||||
|
|
||||||
List<ExpressQuoteVersionPO> versions = versionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteVersionPO>()
|
List<ExpressQuoteVersionPO> versions = versionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteVersionPO>()
|
||||||
.eq(ExpressQuoteVersionPO::getQuoteId, id)
|
.eq(ExpressQuoteVersionPO::getQuoteId, id)
|
||||||
.orderByDesc(ExpressQuoteVersionPO::getEffectiveFrom));
|
.orderByDesc(ExpressQuoteVersionPO::getEffectiveFrom)
|
||||||
List<ExpressQuoteVO.VersionVO> versionVos = new ArrayList<>();
|
.orderByDesc(ExpressQuoteVersionPO::getId));
|
||||||
|
if (versions.isEmpty()) {
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑页只要当前版本明细;详情抽屉再拉全历史分区(避免 N 版 × 2 次查询)
|
||||||
|
List<ExpressQuoteVersionPO> versionsToExpand = withHistory
|
||||||
|
? versions
|
||||||
|
: List.of(versions.get(0));
|
||||||
|
List<Long> expandIds = versionsToExpand.stream().map(ExpressQuoteVersionPO::getId).toList();
|
||||||
|
|
||||||
|
Map<Long, List<ExpressQuoteRegionPO>> regionsByVersion = Map.of();
|
||||||
|
Map<Long, List<ExpressQuoteBandPO>> bandsByRegion = Map.of();
|
||||||
|
if (!expandIds.isEmpty()) {
|
||||||
|
List<ExpressQuoteRegionPO> allRegions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
||||||
|
.in(ExpressQuoteRegionPO::getVersionId, expandIds)
|
||||||
|
.orderByAsc(ExpressQuoteRegionPO::getSortOrder)
|
||||||
|
.orderByAsc(ExpressQuoteRegionPO::getId));
|
||||||
|
regionsByVersion = allRegions.stream()
|
||||||
|
.collect(Collectors.groupingBy(ExpressQuoteRegionPO::getVersionId, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
|
||||||
|
List<Long> regionIds = allRegions.stream().map(ExpressQuoteRegionPO::getId).toList();
|
||||||
|
if (!regionIds.isEmpty()) {
|
||||||
|
List<ExpressQuoteBandPO> allBands = bandMapper.selectList(new LambdaQueryWrapper<ExpressQuoteBandPO>()
|
||||||
|
.in(ExpressQuoteBandPO::getRegionId, regionIds)
|
||||||
|
.orderByAsc(ExpressQuoteBandPO::getSortOrder)
|
||||||
|
.orderByAsc(ExpressQuoteBandPO::getWeightFromG)
|
||||||
|
.orderByAsc(ExpressQuoteBandPO::getId));
|
||||||
|
bandsByRegion = allBands.stream()
|
||||||
|
.collect(Collectors.groupingBy(ExpressQuoteBandPO::getRegionId, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ExpressQuoteVO.VersionVO> versionVos = new ArrayList<>(versions.size());
|
||||||
for (ExpressQuoteVersionPO v : versions) {
|
for (ExpressQuoteVersionPO v : versions) {
|
||||||
versionVos.add(toVersionVo(v, true));
|
boolean expand = expandIds.contains(v.getId());
|
||||||
|
versionVos.add(toVersionVo(
|
||||||
|
v,
|
||||||
|
expand,
|
||||||
|
expand ? regionsByVersion.getOrDefault(v.getId(), List.of()) : List.of(),
|
||||||
|
expand ? bandsByRegion : Map.of()));
|
||||||
}
|
}
|
||||||
vo.setVersions(versionVos);
|
vo.setVersions(versionVos);
|
||||||
if (!versionVos.isEmpty()) {
|
vo.setCurrentVersion(versionVos.get(0));
|
||||||
vo.setCurrentVersion(versionVos.get(0));
|
|
||||||
}
|
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,20 +499,38 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ExpressQuoteVO.VersionVO toVersionVo(ExpressQuoteVersionPO v, boolean withRegions) {
|
private ExpressQuoteVO.VersionVO toVersionVo(ExpressQuoteVersionPO v, boolean withRegions) {
|
||||||
ExpressQuoteVO.VersionVO vo = new ExpressQuoteVO.VersionVO();
|
|
||||||
BeanCopyUtils.copyProperties(v, vo);
|
|
||||||
if (!withRegions) {
|
if (!withRegions) {
|
||||||
|
ExpressQuoteVO.VersionVO vo = new ExpressQuoteVO.VersionVO();
|
||||||
|
BeanCopyUtils.copyProperties(v, vo);
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
List<ExpressQuoteRegionPO> regions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
List<ExpressQuoteRegionPO> regions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
||||||
.eq(ExpressQuoteRegionPO::getVersionId, v.getId())
|
.eq(ExpressQuoteRegionPO::getVersionId, v.getId())
|
||||||
.orderByAsc(ExpressQuoteRegionPO::getSortOrder));
|
.orderByAsc(ExpressQuoteRegionPO::getSortOrder));
|
||||||
List<ExpressQuoteBandPO> bands = bandMapper.selectList(new LambdaQueryWrapper<ExpressQuoteBandPO>()
|
List<Long> regionIds = regions.stream().map(ExpressQuoteRegionPO::getId).toList();
|
||||||
.eq(ExpressQuoteBandPO::getVersionId, v.getId())
|
Map<Long, List<ExpressQuoteBandPO>> bandsByRegion = Map.of();
|
||||||
.orderByAsc(ExpressQuoteBandPO::getSortOrder)
|
if (!regionIds.isEmpty()) {
|
||||||
.orderByAsc(ExpressQuoteBandPO::getWeightFromG));
|
List<ExpressQuoteBandPO> bands = bandMapper.selectList(new LambdaQueryWrapper<ExpressQuoteBandPO>()
|
||||||
var bandsByRegion = bands.stream().collect(Collectors.groupingBy(ExpressQuoteBandPO::getRegionId));
|
.in(ExpressQuoteBandPO::getRegionId, regionIds)
|
||||||
List<ExpressQuoteVO.RegionVO> regionVos = new ArrayList<>();
|
.orderByAsc(ExpressQuoteBandPO::getSortOrder)
|
||||||
|
.orderByAsc(ExpressQuoteBandPO::getWeightFromG));
|
||||||
|
bandsByRegion = bands.stream().collect(Collectors.groupingBy(ExpressQuoteBandPO::getRegionId));
|
||||||
|
}
|
||||||
|
return toVersionVo(v, true, regions, bandsByRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 用预取的分区/重量带组装,避免详情 N+1 */
|
||||||
|
private ExpressQuoteVO.VersionVO toVersionVo(
|
||||||
|
ExpressQuoteVersionPO v,
|
||||||
|
boolean withRegions,
|
||||||
|
List<ExpressQuoteRegionPO> regions,
|
||||||
|
Map<Long, List<ExpressQuoteBandPO>> bandsByRegion) {
|
||||||
|
ExpressQuoteVO.VersionVO vo = new ExpressQuoteVO.VersionVO();
|
||||||
|
BeanCopyUtils.copyProperties(v, vo);
|
||||||
|
if (!withRegions) {
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
List<ExpressQuoteVO.RegionVO> regionVos = new ArrayList<>(regions.size());
|
||||||
for (ExpressQuoteRegionPO r : regions) {
|
for (ExpressQuoteRegionPO r : regions) {
|
||||||
ExpressQuoteVO.RegionVO rv = new ExpressQuoteVO.RegionVO();
|
ExpressQuoteVO.RegionVO rv = new ExpressQuoteVO.RegionVO();
|
||||||
rv.setId(r.getId());
|
rv.setId(r.getId());
|
||||||
|
|||||||
+100
-7
@@ -1,6 +1,7 @@
|
|||||||
package top.xyquan.ecomdmbbackend.modules.ec.warehouse.service.impl;
|
package top.xyquan.ecomdmbbackend.modules.ec.warehouse.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -12,7 +13,10 @@ import top.xyquan.ecomdmbbackend.common.model.vo.PageResultVO;
|
|||||||
import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
|
import top.xyquan.ecomdmbbackend.common.utils.BeanCopyUtils;
|
||||||
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.service.BiOrderStatDirtyDayService;
|
import top.xyquan.ecomdmbbackend.modules.bi.orderstat.service.BiOrderStatDirtyDayService;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.mapper.ProductSkuMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.mapper.ProductSkuMapper;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.dto.ProductSkuFilterDTO;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.po.ProductSkuPO;
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.po.ProductSkuPO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.model.vo.ProductSkuVO;
|
||||||
|
import top.xyquan.ecomdmbbackend.modules.ec.product.sku.service.ProductSkuService;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.freight.ExpressCarrierCodes;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.freight.ExpressCarrierCodes;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.ExpressQuoteMapper;
|
||||||
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.WarehouseExpressBindMapper;
|
import top.xyquan.ecomdmbbackend.modules.ec.warehouse.mapper.WarehouseExpressBindMapper;
|
||||||
@@ -41,17 +45,20 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse
|
|||||||
private final WarehouseExpressBindMapper bindMapper;
|
private final WarehouseExpressBindMapper bindMapper;
|
||||||
private final ExpressQuoteMapper quoteMapper;
|
private final ExpressQuoteMapper quoteMapper;
|
||||||
private final ProductSkuMapper productSkuMapper;
|
private final ProductSkuMapper productSkuMapper;
|
||||||
|
private final ProductSkuService productSkuService;
|
||||||
private final BiOrderStatDirtyDayService dirtyDayService;
|
private final BiOrderStatDirtyDayService dirtyDayService;
|
||||||
|
|
||||||
public WarehouseServiceImpl(CurrentUserContext currentUserContext,
|
public WarehouseServiceImpl(CurrentUserContext currentUserContext,
|
||||||
WarehouseExpressBindMapper bindMapper,
|
WarehouseExpressBindMapper bindMapper,
|
||||||
ExpressQuoteMapper quoteMapper,
|
ExpressQuoteMapper quoteMapper,
|
||||||
ProductSkuMapper productSkuMapper,
|
ProductSkuMapper productSkuMapper,
|
||||||
|
ProductSkuService productSkuService,
|
||||||
BiOrderStatDirtyDayService dirtyDayService) {
|
BiOrderStatDirtyDayService dirtyDayService) {
|
||||||
this.currentUserContext = currentUserContext;
|
this.currentUserContext = currentUserContext;
|
||||||
this.bindMapper = bindMapper;
|
this.bindMapper = bindMapper;
|
||||||
this.quoteMapper = quoteMapper;
|
this.quoteMapper = quoteMapper;
|
||||||
this.productSkuMapper = productSkuMapper;
|
this.productSkuMapper = productSkuMapper;
|
||||||
|
this.productSkuService = productSkuService;
|
||||||
this.dirtyDayService = dirtyDayService;
|
this.dirtyDayService = dirtyDayService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +76,7 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse
|
|||||||
}
|
}
|
||||||
po.setCreateBy(currentUserContext.getCurrentUserId());
|
po.setCreateBy(currentUserContext.getCurrentUserId());
|
||||||
save(po);
|
save(po);
|
||||||
return toVo(po, false);
|
return toVo(po, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -86,7 +93,8 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse
|
|||||||
}
|
}
|
||||||
po.setUpdateBy(currentUserContext.getCurrentUserId());
|
po.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||||
updateById(po);
|
updateById(po);
|
||||||
return toVo(po, true);
|
Map<Long, Integer> skuCounts = loadSkuCounts(po.getCompanyId());
|
||||||
|
return toVo(po, true, skuCounts.getOrDefault(po.getId(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -120,24 +128,92 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse
|
|||||||
}
|
}
|
||||||
w.orderByDesc(WarehousePO::getId);
|
w.orderByDesc(WarehousePO::getId);
|
||||||
Page<WarehousePO> page = page(new Page<>(query.getPage(), query.getPageSize()), w);
|
Page<WarehousePO> page = page(new Page<>(query.getPage(), query.getPageSize()), w);
|
||||||
List<WarehouseVO> records = page.getRecords().stream().map(p -> toVo(p, false)).toList();
|
Map<Long, Integer> skuCounts = loadSkuCounts(companyId);
|
||||||
|
List<WarehouseVO> records = page.getRecords().stream()
|
||||||
|
.map(p -> toVo(p, false, skuCounts.getOrDefault(p.getId(), 0)))
|
||||||
|
.toList();
|
||||||
return PageResultVO.create(records, page.getTotal(), query.getPage(), query.getPageSize());
|
return PageResultVO.create(records, page.getTotal(), query.getPage(), query.getPageSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<WarehouseVO> listEnabled() {
|
public List<WarehouseVO> listEnabled() {
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
Map<Long, Integer> skuCounts = loadSkuCounts(companyId);
|
||||||
return list(new LambdaQueryWrapper<WarehousePO>()
|
return list(new LambdaQueryWrapper<WarehousePO>()
|
||||||
.eq(WarehousePO::getCompanyId, companyId)
|
.eq(WarehousePO::getCompanyId, companyId)
|
||||||
.eq(WarehousePO::getStatus, 1)
|
.eq(WarehousePO::getStatus, 1)
|
||||||
.orderByAsc(WarehousePO::getCode)).stream()
|
.orderByAsc(WarehousePO::getCode)).stream()
|
||||||
.map(p -> toVo(p, false))
|
.map(p -> toVo(p, false, skuCounts.getOrDefault(p.getId(), 0)))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WarehouseVO detail(Long id) {
|
public WarehouseVO detail(Long id) {
|
||||||
return toVo(requireCompanyWarehouse(id), true);
|
WarehousePO po = requireCompanyWarehouse(id);
|
||||||
|
Map<Long, Integer> skuCounts = loadSkuCounts(po.getCompanyId());
|
||||||
|
return toVo(po, true, skuCounts.getOrDefault(po.getId(), 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResultVO<ProductSkuVO> pageSkus(PageQueryDTO<WarehouseDtos.SkuFilter> query) {
|
||||||
|
ProductSkuFilterDTO skuFilter = new ProductSkuFilterDTO();
|
||||||
|
WarehouseDtos.SkuFilter f = query.getFilters();
|
||||||
|
if (f != null) {
|
||||||
|
skuFilter.setKeywords(f.getKeywords());
|
||||||
|
skuFilter.setWarehouseId(f.getWarehouseId());
|
||||||
|
skuFilter.setUnassignedOnly(f.getUnassignedOnly());
|
||||||
|
}
|
||||||
|
PageQueryDTO<ProductSkuFilterDTO> pageQuery = new PageQueryDTO<>();
|
||||||
|
pageQuery.setPage(query.getPage());
|
||||||
|
pageQuery.setPageSize(query.getPageSize());
|
||||||
|
pageQuery.setFilters(skuFilter);
|
||||||
|
return productSkuService.getProductSkuPage(pageQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long countUnassignedSkus() {
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
Long count = productSkuMapper.selectCount(new LambdaQueryWrapper<ProductSkuPO>()
|
||||||
|
.eq(ProductSkuPO::getCompanyId, companyId)
|
||||||
|
.isNull(ProductSkuPO::getWarehouseId));
|
||||||
|
return count == null ? 0L : count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public int batchAssignSkus(WarehouseDtos.SkuBatchAssign dto) {
|
||||||
|
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||||
|
Long userId = currentUserContext.getCurrentUserId();
|
||||||
|
Long targetWarehouseId = dto.getWarehouseId();
|
||||||
|
if (targetWarehouseId != null) {
|
||||||
|
requireCompanyWarehouse(targetWarehouseId);
|
||||||
|
}
|
||||||
|
List<Long> skuIds = dto.getSkuIds().stream().filter(Objects::nonNull).distinct().toList();
|
||||||
|
if (skuIds.isEmpty()) {
|
||||||
|
throw new BusinessException("请选择 SKU");
|
||||||
|
}
|
||||||
|
List<ProductSkuPO> skus = productSkuMapper.selectList(new LambdaQueryWrapper<ProductSkuPO>()
|
||||||
|
.eq(ProductSkuPO::getCompanyId, companyId)
|
||||||
|
.in(ProductSkuPO::getId, skuIds));
|
||||||
|
if (skus.size() != skuIds.size()) {
|
||||||
|
throw new BusinessException("部分 SKU 不存在或不属于本公司");
|
||||||
|
}
|
||||||
|
LocalDate from = LocalDate.now().minusYears(1);
|
||||||
|
int updated = 0;
|
||||||
|
for (ProductSkuPO sku : skus) {
|
||||||
|
if (Objects.equals(sku.getWarehouseId(), targetWarehouseId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// 允许 warehouseId 置空(取消分配)
|
||||||
|
productSkuMapper.update(null, new LambdaUpdateWrapper<ProductSkuPO>()
|
||||||
|
.eq(ProductSkuPO::getId, sku.getId())
|
||||||
|
.eq(ProductSkuPO::getCompanyId, companyId)
|
||||||
|
.set(ProductSkuPO::getWarehouseId, targetWarehouseId)
|
||||||
|
.set(ProductSkuPO::getUpdateBy, userId));
|
||||||
|
dirtyDayService.markAfterFreightQuoteChange(companyId, sku.getId(), from, userId);
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -244,12 +320,29 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private WarehouseVO toVo(WarehousePO po, boolean withBinds) {
|
/** 按仓汇总默认 SKU 数 */
|
||||||
|
private Map<Long, Integer> loadSkuCounts(Long companyId) {
|
||||||
|
List<ProductSkuPO> rows = productSkuMapper.selectList(new LambdaQueryWrapper<ProductSkuPO>()
|
||||||
|
.eq(ProductSkuPO::getCompanyId, companyId)
|
||||||
|
.isNotNull(ProductSkuPO::getWarehouseId)
|
||||||
|
.select(ProductSkuPO::getWarehouseId));
|
||||||
|
Map<Long, Integer> counts = new HashMap<>();
|
||||||
|
for (ProductSkuPO row : rows) {
|
||||||
|
if (row.getWarehouseId() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
counts.merge(row.getWarehouseId(), 1, Integer::sum);
|
||||||
|
}
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WarehouseVO toVo(WarehousePO po, boolean withBinds, int skuCount) {
|
||||||
WarehouseVO vo = new WarehouseVO();
|
WarehouseVO vo = new WarehouseVO();
|
||||||
BeanCopyUtils.copyProperties(po, vo);
|
BeanCopyUtils.copyProperties(po, vo);
|
||||||
List<WarehouseExpressBindPO> binds = bindMapper.selectList(new LambdaQueryWrapper<WarehouseExpressBindPO>()
|
List<WarehouseExpressBindPO> binds = bindMapper.selectList(new LambdaQueryWrapper<WarehouseExpressBindPO>()
|
||||||
.eq(WarehouseExpressBindPO::getWarehouseId, po.getId()));
|
.eq(WarehouseExpressBindPO::getWarehouseId, po.getId()));
|
||||||
vo.setBindCount(binds.size());
|
vo.setBindCount(binds.size());
|
||||||
|
vo.setSkuCount(skuCount);
|
||||||
if (withBinds) {
|
if (withBinds) {
|
||||||
vo.setBinds(toBindVos(binds));
|
vo.setBinds(toBindVos(binds));
|
||||||
}
|
}
|
||||||
@@ -263,7 +356,7 @@ public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse
|
|||||||
List<Long> quoteIds = binds.stream().map(WarehouseExpressBindPO::getQuoteId).distinct().toList();
|
List<Long> quoteIds = binds.stream().map(WarehouseExpressBindPO::getQuoteId).distinct().toList();
|
||||||
Map<Long, ExpressQuotePO> quoteMap = new HashMap<>();
|
Map<Long, ExpressQuotePO> quoteMap = new HashMap<>();
|
||||||
if (!quoteIds.isEmpty()) {
|
if (!quoteIds.isEmpty()) {
|
||||||
for (ExpressQuotePO q : quoteMapper.selectBatchIds(quoteIds)) {
|
for (ExpressQuotePO q : quoteMapper.selectByIds(quoteIds)) {
|
||||||
quoteMap.put(q.getId(), q);
|
quoteMap.put(q.getId(), q);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-4
@@ -60,15 +60,17 @@ public class DepartmentController {
|
|||||||
|
|
||||||
@GetMapping("/all")
|
@GetMapping("/all")
|
||||||
@RequirePermission(value = "org:department:read", description = "查询全部部门", allowSuper = true)
|
@RequirePermission(value = "org:department:read", description = "查询全部部门", allowSuper = true)
|
||||||
public ApiResponse<List<DepartmentVO>> getAllDepartments() {
|
public ApiResponse<List<DepartmentVO>> getAllDepartments(
|
||||||
List<DepartmentVO> result = departmentService.getAllDepartments();
|
@RequestParam(required = false) Long companyId) {
|
||||||
|
List<DepartmentVO> result = departmentService.getAllDepartments(companyId);
|
||||||
return ApiResponse.success("获取全部部门成功", result);
|
return ApiResponse.success("获取全部部门成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/tree")
|
@GetMapping("/tree")
|
||||||
@RequirePermission(value = "org:department:read", description = "查询部门树", allowSuper = true)
|
@RequirePermission(value = "org:department:read", description = "查询部门树", allowSuper = true)
|
||||||
public ApiResponse<List<DepartmentVO>> getDepartmentTree() {
|
public ApiResponse<List<DepartmentVO>> getDepartmentTree(
|
||||||
List<DepartmentVO> result = departmentService.getDepartmentTree();
|
@RequestParam(required = false) Long companyId) {
|
||||||
|
List<DepartmentVO> result = departmentService.getDepartmentTree(companyId);
|
||||||
return ApiResponse.success("获取部门树成功", result);
|
return ApiResponse.success("获取部门树成功", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -22,4 +22,9 @@ public class DepartmentFilterDTO {
|
|||||||
* 状态
|
* 状态
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司ID(仅超管可跨公司查询)
|
||||||
|
*/
|
||||||
|
private Long companyId;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
@@ -55,6 +55,14 @@ public interface DepartmentService extends IService<DepartmentPO> {
|
|||||||
*/
|
*/
|
||||||
List<DepartmentVO> getAllDepartments();
|
List<DepartmentVO> getAllDepartments();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定公司全部部门(companyId 为空则取当前公司;跨公司仅超管)
|
||||||
|
*
|
||||||
|
* @param companyId 公司ID,可空
|
||||||
|
* @return 部门列表
|
||||||
|
*/
|
||||||
|
List<DepartmentVO> getAllDepartments(Long companyId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前公司部门树
|
* 获取当前公司部门树
|
||||||
*
|
*
|
||||||
@@ -62,6 +70,14 @@ public interface DepartmentService extends IService<DepartmentPO> {
|
|||||||
*/
|
*/
|
||||||
List<DepartmentVO> getDepartmentTree();
|
List<DepartmentVO> getDepartmentTree();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定公司部门树(companyId 为空则取当前公司;跨公司仅超管)
|
||||||
|
*
|
||||||
|
* @param companyId 公司ID,可空
|
||||||
|
* @return 部门树
|
||||||
|
*/
|
||||||
|
List<DepartmentVO> getDepartmentTree(Long companyId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 为指定公司创建部门(用于初始化)
|
* 为指定公司创建部门(用于初始化)
|
||||||
*
|
*
|
||||||
|
|||||||
+35
-20
@@ -158,6 +158,19 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析查询用公司ID:超管可传 companyId 跨公司;否则强制当前公司。
|
||||||
|
*/
|
||||||
|
private Long resolveCompanyId(Long requestedCompanyId) {
|
||||||
|
if (requestedCompanyId == null) {
|
||||||
|
return currentUserContext.getCurrentCompanyId();
|
||||||
|
}
|
||||||
|
if (!currentUserContext.isCurrentUserSuper()) {
|
||||||
|
throw new BusinessException("无权跨公司查询部门");
|
||||||
|
}
|
||||||
|
return requestedCompanyId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门分页列表
|
* 获取部门分页列表
|
||||||
* @param pageQueryDTO 分页查询DTO
|
* @param pageQueryDTO 分页查询DTO
|
||||||
@@ -165,14 +178,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<DepartmentVO> getDepartmentPage(PageQueryDTO<DepartmentFilterDTO> pageQueryDTO) {
|
public PageResultVO<DepartmentVO> getDepartmentPage(PageQueryDTO<DepartmentFilterDTO> pageQueryDTO) {
|
||||||
// 从token中获取公司ID
|
DepartmentFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
Long companyId = resolveCompanyId(queryDTO != null ? queryDTO.getCompanyId() : null);
|
||||||
|
|
||||||
// 构建查询条件
|
|
||||||
LambdaQueryWrapper<DepartmentPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DepartmentPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
// 添加过滤条件
|
|
||||||
DepartmentFilterDTO queryDTO = pageQueryDTO.getFilters();
|
|
||||||
if (queryDTO != null) {
|
if (queryDTO != null) {
|
||||||
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
||||||
wrapper.like(DepartmentPO::getName, queryDTO.getName());
|
wrapper.like(DepartmentPO::getName, queryDTO.getName());
|
||||||
@@ -184,37 +194,36 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
wrapper.eq(DepartmentPO::getStatus, queryDTO.getStatus());
|
wrapper.eq(DepartmentPO::getStatus, queryDTO.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 强制添加公司ID过滤条件
|
|
||||||
wrapper.eq(DepartmentPO::getCompanyId, companyId);
|
wrapper.eq(DepartmentPO::getCompanyId, companyId);
|
||||||
|
|
||||||
// 排序
|
|
||||||
wrapper.orderByAsc(DepartmentPO::getCreateTime);
|
wrapper.orderByAsc(DepartmentPO::getCreateTime);
|
||||||
|
|
||||||
// 分页查询
|
|
||||||
Page<DepartmentPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
Page<DepartmentPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||||
IPage<DepartmentPO> pageResult = this.page(page, wrapper);
|
IPage<DepartmentPO> pageResult = this.page(page, wrapper);
|
||||||
|
|
||||||
// 转换为VO
|
|
||||||
List<DepartmentVO> records = pageResult.getRecords().stream()
|
List<DepartmentVO> records = pageResult.getRecords().stream()
|
||||||
.map(this::convertToVO)
|
.map(this::convertToVO)
|
||||||
.toList();
|
.toList();
|
||||||
PageResultVO<DepartmentVO> result = PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
return PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||||
pageQueryDTO.getPageSize());
|
pageQueryDTO.getPageSize());
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前公司全部部门
|
* 获取当前公司全部部门
|
||||||
*
|
|
||||||
* @return 部门列表
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentVO> getAllDepartments() {
|
public List<DepartmentVO> getAllDepartments() {
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
return getAllDepartments(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定公司全部部门
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DepartmentVO> getAllDepartments(Long companyId) {
|
||||||
|
Long resolvedCompanyId = resolveCompanyId(companyId);
|
||||||
|
|
||||||
LambdaQueryWrapper<DepartmentPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<DepartmentPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(DepartmentPO::getCompanyId, companyId)
|
wrapper.eq(DepartmentPO::getCompanyId, resolvedCompanyId)
|
||||||
.orderByAsc(DepartmentPO::getCreateTime);
|
.orderByAsc(DepartmentPO::getCreateTime);
|
||||||
|
|
||||||
return this.list(wrapper).stream()
|
return this.list(wrapper).stream()
|
||||||
@@ -224,12 +233,18 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前公司部门树
|
* 获取当前公司部门树
|
||||||
*
|
|
||||||
* @return 部门树
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<DepartmentVO> getDepartmentTree() {
|
public List<DepartmentVO> getDepartmentTree() {
|
||||||
List<DepartmentVO> allDepartments = getAllDepartments();
|
return getDepartmentTree(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定公司部门树
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<DepartmentVO> getDepartmentTree(Long companyId) {
|
||||||
|
List<DepartmentVO> allDepartments = getAllDepartments(companyId);
|
||||||
if (allDepartments.isEmpty()) {
|
if (allDepartments.isEmpty()) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -17,4 +17,9 @@ public class PositionFilterDTO {
|
|||||||
* 状态
|
* 状态
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公司ID(仅超管可跨公司查询)
|
||||||
|
*/
|
||||||
|
private Long companyId;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-13
@@ -147,6 +147,19 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
|||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析查询用公司ID:超管可传 companyId 跨公司;否则强制当前公司。
|
||||||
|
*/
|
||||||
|
private Long resolveCompanyId(Long requestedCompanyId) {
|
||||||
|
if (requestedCompanyId == null) {
|
||||||
|
return currentUserContext.getCurrentCompanyId();
|
||||||
|
}
|
||||||
|
if (!currentUserContext.isCurrentUserSuper()) {
|
||||||
|
throw new BusinessException("无权跨公司查询岗位");
|
||||||
|
}
|
||||||
|
return requestedCompanyId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取岗位分页列表
|
* 获取岗位分页列表
|
||||||
* @param pageQueryDTO 分页查询DTO
|
* @param pageQueryDTO 分页查询DTO
|
||||||
@@ -154,14 +167,11 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResultVO<PositionVO> getPositionPage(PageQueryDTO<PositionFilterDTO> pageQueryDTO) {
|
public PageResultVO<PositionVO> getPositionPage(PageQueryDTO<PositionFilterDTO> pageQueryDTO) {
|
||||||
// 从token中获取公司ID
|
PositionFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
Long companyId = resolveCompanyId(queryDTO != null ? queryDTO.getCompanyId() : null);
|
||||||
|
|
||||||
// 构建查询条件
|
|
||||||
LambdaQueryWrapper<PositionPO> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PositionPO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
// 添加过滤条件
|
|
||||||
PositionFilterDTO queryDTO = pageQueryDTO.getFilters();
|
|
||||||
if (queryDTO != null) {
|
if (queryDTO != null) {
|
||||||
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
if (queryDTO.getName() != null && StringUtils.hasText(queryDTO.getName())) {
|
||||||
wrapper.like(PositionPO::getName, queryDTO.getName());
|
wrapper.like(PositionPO::getName, queryDTO.getName());
|
||||||
@@ -170,24 +180,17 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
|||||||
wrapper.eq(PositionPO::getStatus, queryDTO.getStatus());
|
wrapper.eq(PositionPO::getStatus, queryDTO.getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 强制添加公司ID过滤条件
|
|
||||||
wrapper.eq(PositionPO::getCompanyId, companyId);
|
wrapper.eq(PositionPO::getCompanyId, companyId);
|
||||||
|
|
||||||
// 排序
|
|
||||||
wrapper.orderByAsc(PositionPO::getCreateTime);
|
wrapper.orderByAsc(PositionPO::getCreateTime);
|
||||||
|
|
||||||
// 分页查询
|
|
||||||
Page<PositionPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
Page<PositionPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||||
IPage<PositionPO> pageResult = this.page(page, wrapper);
|
IPage<PositionPO> pageResult = this.page(page, wrapper);
|
||||||
|
|
||||||
// 转换为VO
|
|
||||||
List<PositionVO> records = pageResult.getRecords().stream()
|
List<PositionVO> records = pageResult.getRecords().stream()
|
||||||
.map(this::convertToVO)
|
.map(this::convertToVO)
|
||||||
.toList();
|
.toList();
|
||||||
PageResultVO<PositionVO> result = PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
return PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||||
pageQueryDTO.getPageSize());
|
pageQueryDTO.getPageSize());
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ public class CreateSysAccountDTO {
|
|||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@NotBlank(message = "密码不能为空")
|
@NotBlank(message = "密码不能为空")
|
||||||
@Size(min = 8, max = 20, message = "密码长度必须在8-20个字符之间")
|
@Size(min = 6, max = 20, message = "密码长度必须在6-20个字符之间")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@NotBlank(message = "用户姓名不能为空")
|
@NotBlank(message = "用户姓名不能为空")
|
||||||
|
|||||||
@@ -727,6 +727,10 @@ INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path
|
|||||||
SELECT 14006, NULL, 0, 'ProductCatalog', '经营商品', '/product', '', '', 'icon-park-outline:ad-product', 'catalog', 1, 1, 0, 5
|
SELECT 14006, NULL, 0, 'ProductCatalog', '经营商品', '/product', '', '', 'icon-park-outline:ad-product', 'catalog', 1, 1, 0, 5
|
||||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 14006 OR `route_name` = 'ProductCatalog');
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 14006 OR `route_name` = 'ProductCatalog');
|
||||||
|
|
||||||
|
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||||
|
SELECT 14019, NULL, 0, 'FreightCatalog', '发货物流', '/freight', '', '', 'lucide:truck', 'catalog', 1, 1, 0, 6
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 14019 OR `route_name` = 'FreightCatalog');
|
||||||
|
|
||||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||||
SELECT 2, (SELECT id FROM `sys_menu` WHERE `id` = 1 OR `title` = '系统设置' LIMIT 1), 1, 'MenuManagement', '系统菜单', '/sys/menu', '/sys/menu/index', '', 'lucide:menu', 'menu', 1, 1, 0, 1
|
SELECT 2, (SELECT id FROM `sys_menu` WHERE `id` = 1 OR `title` = '系统设置' LIMIT 1), 1, 'MenuManagement', '系统菜单', '/sys/menu', '/sys/menu/index', '', 'lucide:menu', 'menu', 1, 1, 0, 1
|
||||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 2 OR `route_name` = 'MenuManagement');
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 2 OR `route_name` = 'MenuManagement');
|
||||||
@@ -798,6 +802,16 @@ INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path
|
|||||||
SELECT 43, (SELECT id FROM `sys_menu` WHERE `id` = 6 OR `title` = '电商页面' LIMIT 1), 0, 'ProductOverview', '商品概览', '/ec/product/overview/:id', '/ec/product/overview/index', '', 'lets-icons:chart', 'embedded', 0, 1, 1, 2
|
SELECT 43, (SELECT id FROM `sys_menu` WHERE `id` = 6 OR `title` = '电商页面' LIMIT 1), 0, 'ProductOverview', '商品概览', '/ec/product/overview/:id', '/ec/product/overview/index', '', 'lets-icons:chart', 'embedded', 0, 1, 1, 2
|
||||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 43 OR `route_name` = 'ProductOverview');
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 43 OR `route_name` = 'ProductOverview');
|
||||||
|
|
||||||
|
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||||
|
SELECT 14023, (SELECT id FROM `sys_menu` WHERE `id` = 14019 OR `title` = '发货物流' OR `route_name` = 'FreightCatalog' LIMIT 1), 0,
|
||||||
|
'WarehouseSkuManagement', '发货仓商品', '/ec/warehouse/sku', '/ec/warehouse/sku/index', '', 'lucide:boxes', 'menu', 1, 1, 1, 2
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 14023 OR `route_name` = 'WarehouseSkuManagement');
|
||||||
|
|
||||||
|
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||||
|
SELECT 14022, (SELECT id FROM `sys_menu` WHERE `id` = 14019 OR `title` = '发货物流' OR `route_name` = 'FreightCatalog' LIMIT 1), 0,
|
||||||
|
'ExpressQuoteEdit', '快递报价单编辑', '/ec/warehouse/express-quote/edit/:id?', '/ec/warehouse/express-quote/edit/index', '', 'lucide:file-pen-line', 'embedded', 0, 1, 0, 8
|
||||||
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 14022 OR `route_name` = 'ExpressQuoteEdit');
|
||||||
|
|
||||||
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
INSERT INTO `sys_menu` (`id`, `parent_id`, `super`, `route_name`, `title`, `path`, `component`, `redirect`, `icon`, `type`, `visible`, `status`, `keep_alive`, `order`)
|
||||||
SELECT 53, (SELECT id FROM `sys_menu` WHERE `id` = 6 OR `title` = '电商页面' LIMIT 1), 0, 'PlatformOverview', '平台概览', '/ec/platform/overview/:code', '/ec/platform/overview/index', '', 'lucide:layers', 'embedded', 0, 1, 1, 4
|
SELECT 53, (SELECT id FROM `sys_menu` WHERE `id` = 6 OR `title` = '电商页面' LIMIT 1), 0, 'PlatformOverview', '平台概览', '/ec/platform/overview/:code', '/ec/platform/overview/index', '', 'lucide:layers', 'embedded', 0, 1, 1, 4
|
||||||
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 53 OR `route_name` = 'PlatformOverview');
|
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_menu` WHERE `id` = 53 OR `route_name` = 'PlatformOverview');
|
||||||
|
|||||||
@@ -23,9 +23,14 @@ export async function getEnabledExpressQuotesApi() {
|
|||||||
return requestClient.get<ExpressQuoteVO.Info[]>('/ec/express-quote/enabled');
|
return requestClient.get<ExpressQuoteVO.Info[]>('/ec/express-quote/enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getExpressQuoteDetailApi(id: number) {
|
/** withHistory:详情抽屉拉全版本分区;编辑页默认 false 仅当前版本明细 */
|
||||||
|
export async function getExpressQuoteDetailApi(
|
||||||
|
id: number,
|
||||||
|
withHistory = false,
|
||||||
|
) {
|
||||||
return requestClient.get<ExpressQuoteVO.Info>(
|
return requestClient.get<ExpressQuoteVO.Info>(
|
||||||
`/ec/express-quote/detail/${id}`,
|
`/ec/express-quote/detail/${id}`,
|
||||||
|
{ params: { withHistory } },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ export namespace ProductSkuDTO {
|
|||||||
skuCode?: string;
|
skuCode?: string;
|
||||||
/** 关键字(模糊查询 SKU 名称、SKU 编码) */
|
/** 关键字(模糊查询 SKU 名称、SKU 编码) */
|
||||||
keywords?: string;
|
keywords?: string;
|
||||||
|
warehouseId?: number;
|
||||||
|
unassignedOnly?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 商品 SKU 查询 DTO(用于批量查询) */
|
/** 商品 SKU 查询 DTO(用于批量查询) */
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { WarehouseDTO, WarehouseVO } from './types';
|
import type { WarehouseDTO, WarehouseVO } from './types';
|
||||||
|
|
||||||
|
import type { ProductSkuVO } from '#/api/ec/product/sku';
|
||||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
@@ -59,3 +60,28 @@ export async function updateWarehouseBindApi(
|
|||||||
export async function removeWarehouseBindApi(bindId: number) {
|
export async function removeWarehouseBindApi(bindId: number) {
|
||||||
return requestClient.delete(`/ec/warehouse/bind/${bindId}`);
|
return requestClient.delete(`/ec/warehouse/bind/${bindId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 发货仓商品分页(仓权限) */
|
||||||
|
export async function getWarehouseSkuPageApi(
|
||||||
|
params: PageQueryDTO<WarehouseDTO.SkuFilters>,
|
||||||
|
) {
|
||||||
|
return requestClient.post<PageResultVO<ProductSkuVO.Info>>(
|
||||||
|
'/ec/warehouse/skus/list',
|
||||||
|
params,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUnassignedWarehouseSkuCountApi() {
|
||||||
|
return requestClient.get<{ count: number }>(
|
||||||
|
'/ec/warehouse/skus/unassigned-count',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function batchAssignWarehouseSkusApi(
|
||||||
|
data: WarehouseDTO.SkuBatchAssign,
|
||||||
|
) {
|
||||||
|
return requestClient.post<{ updated: number }>(
|
||||||
|
'/ec/warehouse/skus/batch-assign',
|
||||||
|
data,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,4 +34,17 @@ export namespace WarehouseDTO {
|
|||||||
priority?: number;
|
priority?: number;
|
||||||
status?: number;
|
status?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 发货仓商品筛选 */
|
||||||
|
export interface SkuFilters {
|
||||||
|
keywords?: string;
|
||||||
|
warehouseId?: number;
|
||||||
|
unassignedOnly?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量分配默认发货仓;warehouseId 空=取消分配 */
|
||||||
|
export interface SkuBatchAssign {
|
||||||
|
skuIds: number[];
|
||||||
|
warehouseId?: number | null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ export namespace WarehouseVO {
|
|||||||
createTime?: string;
|
createTime?: string;
|
||||||
updateTime?: string;
|
updateTime?: string;
|
||||||
bindCount?: number;
|
bindCount?: number;
|
||||||
|
/** 默认发此仓的 SKU 数 */
|
||||||
|
skuCount?: number;
|
||||||
binds?: Bind[];
|
binds?: Bind[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,15 +53,19 @@ export async function deleteDepartmentApi(id: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取全部部门
|
* 获取全部部门(超管可传 companyId 跨公司)
|
||||||
*/
|
*/
|
||||||
export async function getAllDepartmentsApi() {
|
export async function getAllDepartmentsApi(companyId?: number) {
|
||||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/all');
|
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/all', {
|
||||||
|
params: companyId == null ? undefined : { companyId },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取部门树
|
* 获取部门树(超管可传 companyId 跨公司)
|
||||||
*/
|
*/
|
||||||
export async function getDepartmentTreeApi() {
|
export async function getDepartmentTreeApi(companyId?: number) {
|
||||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/tree');
|
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/tree', {
|
||||||
|
params: companyId == null ? undefined : { companyId },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,5 +35,7 @@ export namespace DepartmentDTO {
|
|||||||
parentId?: number;
|
parentId?: number;
|
||||||
/** 状态 */
|
/** 状态 */
|
||||||
status?: number;
|
status?: number;
|
||||||
|
/** 公司ID(仅超管可跨公司) */
|
||||||
|
companyId?: number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,5 +37,7 @@ export namespace PositionDTO {
|
|||||||
name?: string;
|
name?: string;
|
||||||
/** 状态 */
|
/** 状态 */
|
||||||
status?: number;
|
status?: number;
|
||||||
|
/** 公司ID(仅超管可跨公司) */
|
||||||
|
companyId?: number;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,28 @@ import { $t } from '#/locales';
|
|||||||
|
|
||||||
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
|
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
|
||||||
|
|
||||||
|
/** 编辑类 embedded 路由:侧栏高亮回列表菜单 */
|
||||||
|
const ACTIVE_PATH_BY_ROUTE_NAME: Record<string, string> = {
|
||||||
|
ExpressQuoteEdit: '/ec/warehouse/express-quote',
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 就地写入 activePath,避免 mapTree 展开 meta 后 title 被推断成 string | undefined */
|
||||||
|
function enrichRouteMeta(
|
||||||
|
routes: RouteRecordStringComponent[],
|
||||||
|
): RouteRecordStringComponent[] {
|
||||||
|
for (const node of routes) {
|
||||||
|
const name = String(node.name ?? '');
|
||||||
|
const activePath = ACTIVE_PATH_BY_ROUTE_NAME[name];
|
||||||
|
if (activePath && node.meta) {
|
||||||
|
node.meta.activePath = activePath;
|
||||||
|
}
|
||||||
|
if (node.children?.length) {
|
||||||
|
enrichRouteMeta(node.children as RouteRecordStringComponent[]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return routes;
|
||||||
|
}
|
||||||
|
|
||||||
/** 将 glob key 规范成与后端 component 一致的 /xxx/index.vue */
|
/** 将 glob key 规范成与后端 component 一致的 /xxx/index.vue */
|
||||||
function normalizePageKey(path: string): string {
|
function normalizePageKey(path: string): string {
|
||||||
const normalized = path.replace(/^(\.\/|\.\.\/)+/, '');
|
const normalized = path.replace(/^(\.\/|\.\.\/)+/, '');
|
||||||
@@ -83,7 +105,9 @@ async function generateAccess(
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const routes = await getUserMenuApi();
|
const routes = await getUserMenuApi();
|
||||||
return filterMissingPageRoutes(routes || [], pageMap, layoutMap);
|
return enrichRouteMeta(
|
||||||
|
filterMissingPageRoutes(routes || [], pageMap, layoutMap),
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ 获取用户菜单路由失败:', error);
|
console.error('❌ 获取用户菜单路由失败:', error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { defineStore } from 'pinia';
|
|||||||
export type ColSidebarKind =
|
export type ColSidebarKind =
|
||||||
| 'company'
|
| 'company'
|
||||||
| 'ec-shop'
|
| 'ec-shop'
|
||||||
|
| 'ec-warehouse'
|
||||||
| 'pdd-shop'
|
| 'pdd-shop'
|
||||||
| 'pdd-publish-agent';
|
| 'pdd-publish-agent';
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ const AGENT_DEFAULT_LAYOUT: ColSidebarLayout = {
|
|||||||
function createDefaultLayouts(): Record<ColSidebarKind, ColSidebarLayout> {
|
function createDefaultLayouts(): Record<ColSidebarKind, ColSidebarLayout> {
|
||||||
return {
|
return {
|
||||||
'ec-shop': { ...DEFAULT_LAYOUT },
|
'ec-shop': { ...DEFAULT_LAYOUT },
|
||||||
|
'ec-warehouse': { ...DEFAULT_LAYOUT },
|
||||||
'pdd-shop': { ...DEFAULT_LAYOUT },
|
'pdd-shop': { ...DEFAULT_LAYOUT },
|
||||||
company: { ...DEFAULT_LAYOUT },
|
company: { ...DEFAULT_LAYOUT },
|
||||||
'pdd-publish-agent': { ...AGENT_DEFAULT_LAYOUT },
|
'pdd-publish-agent': { ...AGENT_DEFAULT_LAYOUT },
|
||||||
|
|||||||
@@ -964,7 +964,8 @@ void loadEnabledModels().then(() => refreshSessions());
|
|||||||
class="mt-24"
|
class="mt-24"
|
||||||
description="开始提问吧(需先在「模型管理」配置 API)"
|
description="开始提问吧(需先在「模型管理」配置 API)"
|
||||||
/>
|
/>
|
||||||
<div class="mx-auto max-w-[760px]">
|
<!-- w-full:避免仅 max-w 时在 flex 列里被内容撑成窄条,短气泡左右贴中间 -->
|
||||||
|
<div class="mx-auto w-full max-w-[760px]">
|
||||||
<ChatItem
|
<ChatItem
|
||||||
v-for="item in bubbleViews"
|
v-for="item in bubbleViews"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
@@ -1086,18 +1087,21 @@ html.dark .agent-session-item--active,
|
|||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item {
|
.agent-td-item {
|
||||||
/* ChatItem 根节点即 .t-chat__inner,样式打在本类上 */
|
/* ChatItem 根节点即 .t-chat__inner;行必须拉满,短文案才能各贴左右 */
|
||||||
display: flex;
|
display: flex;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
padding-inline: 20px;
|
padding-inline: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 内容区占满行宽,气泡用 align-items 贴边;勿对 content 用 fit-content(会把左右挤到中间) */
|
||||||
.agent-td-item :deep(.t-chat__content) {
|
.agent-td-item :deep(.t-chat__content) {
|
||||||
flex: 0 1 auto !important;
|
flex: 1 1 auto !important;
|
||||||
width: fit-content !important;
|
width: 100% !important;
|
||||||
max-width: min(680px, 100%);
|
max-width: 100%;
|
||||||
|
min-width: 0;
|
||||||
justify-content: flex-start !important;
|
justify-content: flex-start !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1106,30 +1110,31 @@ html.dark .agent-session-item--active,
|
|||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item--assistant :deep(.t-chat__content) {
|
.agent-td-item--assistant :deep(.t-chat__content) {
|
||||||
align-self: flex-start;
|
|
||||||
align-items: flex-start !important;
|
align-items: flex-start !important;
|
||||||
margin-right: auto;
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item--user {
|
.agent-td-item--user {
|
||||||
|
/* 无头像时关掉 TDesign row-reverse,避免与左右对齐打架 */
|
||||||
|
flex-direction: row !important;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item--user :deep(.t-chat__content) {
|
.agent-td-item--user :deep(.t-chat__content) {
|
||||||
align-self: flex-end;
|
|
||||||
align-items: flex-end !important;
|
align-items: flex-end !important;
|
||||||
margin-left: auto;
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.agent-td-item--user :deep(.t-chat__base) {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 只有气泡随文字收缩;行宽始终 100% */
|
||||||
.agent-td-item :deep(.t-chat__detail) {
|
.agent-td-item :deep(.t-chat__detail) {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
max-width: 100%;
|
max-width: min(680px, 100%);
|
||||||
margin-inline: 0;
|
margin-inline: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.agent-td-item :deep(.t-chat__text__name) {
|
.agent-td-item :deep(.t-chat__name) {
|
||||||
opacity: 0.55;
|
opacity: 0.55;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,128 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
/**
|
||||||
|
* 发货仓双栏页:左栏 WarehouseSidebarList,宽度/收起走全局持久化。
|
||||||
|
*/
|
||||||
|
import type { WarehouseVO } from '#/api/ec/warehouse';
|
||||||
|
import type { WarehouseSidebarScope } from '#/views/ec/components/WarehouseSidebarList.vue';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { ColPage } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { useColSidebarLayout } from '#/store/col-sidebar-layout';
|
||||||
|
import WarehouseSidebarList from '#/views/ec/components/WarehouseSidebarList.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'EcWarehouseColPage' });
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
scope?: WarehouseSidebarScope;
|
||||||
|
selectedWarehouseId?: number;
|
||||||
|
autoContentHeight?: boolean;
|
||||||
|
leftMinWidth?: number;
|
||||||
|
leftMaxWidth?: number;
|
||||||
|
leftCollapsedWidth?: number;
|
||||||
|
leftCollapsible?: boolean;
|
||||||
|
resizable?: boolean;
|
||||||
|
splitHandle?: boolean;
|
||||||
|
splitLine?: boolean;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
scope: 'all',
|
||||||
|
selectedWarehouseId: undefined,
|
||||||
|
autoContentHeight: true,
|
||||||
|
leftMinWidth: 16,
|
||||||
|
leftMaxWidth: 36,
|
||||||
|
leftCollapsedWidth: 3,
|
||||||
|
leftCollapsible: true,
|
||||||
|
resizable: true,
|
||||||
|
splitHandle: false,
|
||||||
|
splitLine: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:scope': [scope: WarehouseSidebarScope];
|
||||||
|
'update:selectedWarehouseId': [id: number | undefined];
|
||||||
|
select: [
|
||||||
|
payload: {
|
||||||
|
scope: WarehouseSidebarScope;
|
||||||
|
warehouse: WarehouseVO.Info | null;
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const { width: leftWidth, collapsed: leftCollapsed } =
|
||||||
|
useColSidebarLayout('ec-warehouse');
|
||||||
|
|
||||||
|
const listRef = ref<InstanceType<typeof WarehouseSidebarList> | null>(null);
|
||||||
|
|
||||||
|
function refreshSidebar() {
|
||||||
|
void listRef.value?.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ refreshSidebar });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="ec-warehouse-col-page h-full min-h-0">
|
||||||
|
<ColPage
|
||||||
|
v-model:left-width="leftWidth"
|
||||||
|
v-model:left-collapsed="leftCollapsed"
|
||||||
|
:auto-content-height="autoContentHeight"
|
||||||
|
:left-min-width="leftMinWidth"
|
||||||
|
:left-max-width="leftMaxWidth"
|
||||||
|
:left-collapsed-width="leftCollapsedWidth"
|
||||||
|
:left-collapsible="leftCollapsible"
|
||||||
|
:right-width="100 - leftWidth"
|
||||||
|
:resizable="resizable"
|
||||||
|
:split-handle="splitHandle"
|
||||||
|
:split-line="splitLine"
|
||||||
|
content-class="!p-2 sm:!p-3"
|
||||||
|
>
|
||||||
|
<template #left="{ isCollapsed, expand, collapse }">
|
||||||
|
<div
|
||||||
|
class="flex h-full min-h-0 flex-col"
|
||||||
|
:class="
|
||||||
|
isCollapsed
|
||||||
|
? 'warehouse-sidebar-collapsed-mark min-w-[56px] overflow-visible'
|
||||||
|
: 'min-w-0 overflow-hidden'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<WarehouseSidebarList
|
||||||
|
ref="listRef"
|
||||||
|
fluid
|
||||||
|
:collapsed="!!isCollapsed"
|
||||||
|
show-collapse-action
|
||||||
|
:scope="scope"
|
||||||
|
:selected-warehouse-id="selectedWarehouseId"
|
||||||
|
@collapse="collapse"
|
||||||
|
@expand="expand"
|
||||||
|
@update:scope="emit('update:scope', $event)"
|
||||||
|
@update:selected-warehouse-id="
|
||||||
|
emit('update:selectedWarehouseId', $event)
|
||||||
|
"
|
||||||
|
@select="emit('select', $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<slot />
|
||||||
|
</ColPage>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.ec-warehouse-col-page :deep([data-panel]:has(.warehouse-sidebar-collapsed-mark)),
|
||||||
|
.ec-warehouse-col-page
|
||||||
|
:deep(
|
||||||
|
[data-panel-group-direction]
|
||||||
|
> *:first-child:has(.warehouse-sidebar-collapsed-mark)
|
||||||
|
) {
|
||||||
|
flex: 0 0 56px !important;
|
||||||
|
width: 56px !important;
|
||||||
|
min-width: 56px !important;
|
||||||
|
max-width: 56px !important;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,455 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
/**
|
||||||
|
* 发货仓侧栏:全部 / 未分配 / 指定仓;交互对齐 ShopSidebarList。
|
||||||
|
*/
|
||||||
|
import type { WarehouseVO } from '#/api/ec/warehouse';
|
||||||
|
|
||||||
|
import { computed, onMounted, ref } from 'vue';
|
||||||
|
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Empty,
|
||||||
|
Input,
|
||||||
|
message,
|
||||||
|
Spin,
|
||||||
|
Tag,
|
||||||
|
Tooltip,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getUnassignedWarehouseSkuCountApi,
|
||||||
|
getWarehousePageApi,
|
||||||
|
} from '#/api/ec/warehouse';
|
||||||
|
|
||||||
|
defineOptions({ name: 'WarehouseSidebarList' });
|
||||||
|
|
||||||
|
export type WarehouseSidebarScope = 'all' | 'unassigned' | 'warehouse';
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
scope?: WarehouseSidebarScope;
|
||||||
|
/** scope=warehouse 时选中的仓 id */
|
||||||
|
selectedWarehouseId?: number;
|
||||||
|
fluid?: boolean;
|
||||||
|
showCollapseAction?: boolean;
|
||||||
|
collapsed?: boolean;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
scope: 'all',
|
||||||
|
selectedWarehouseId: undefined,
|
||||||
|
fluid: false,
|
||||||
|
showCollapseAction: false,
|
||||||
|
collapsed: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:scope': [scope: WarehouseSidebarScope];
|
||||||
|
'update:selectedWarehouseId': [id: number | undefined];
|
||||||
|
select: [
|
||||||
|
payload: {
|
||||||
|
scope: WarehouseSidebarScope;
|
||||||
|
warehouse: WarehouseVO.Info | null;
|
||||||
|
},
|
||||||
|
];
|
||||||
|
collapse: [];
|
||||||
|
expand: [];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const WarehouseIcon = createIconifyIcon('lucide:warehouse');
|
||||||
|
const BoxesIcon = createIconifyIcon('lucide:boxes');
|
||||||
|
const InboxIcon = createIconifyIcon('lucide:inbox');
|
||||||
|
const PanelCloseIcon = createIconifyIcon('lucide:panel-left-close');
|
||||||
|
const PanelOpenIcon = createIconifyIcon('lucide:panel-left-open');
|
||||||
|
const ChevronUpIcon = createIconifyIcon('lucide:chevron-up');
|
||||||
|
const ChevronDownIcon = createIconifyIcon('lucide:chevron-down');
|
||||||
|
|
||||||
|
const keyword = ref('');
|
||||||
|
const warehouses = ref<WarehouseVO.Info[]>([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const unassignedCount = ref(0);
|
||||||
|
const pagination = ref({ current: 1, pageSize: 20, total: 0 });
|
||||||
|
|
||||||
|
const totalPages = computed(() => {
|
||||||
|
const { total, pageSize } = pagination.value;
|
||||||
|
return Math.max(1, Math.ceil(total / pageSize) || 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
const allSelected = computed(() => props.scope === 'all');
|
||||||
|
const unassignedSelected = computed(() => props.scope === 'unassigned');
|
||||||
|
|
||||||
|
async function loadUnassignedCount() {
|
||||||
|
try {
|
||||||
|
const res = await getUnassignedWarehouseSkuCountApi();
|
||||||
|
unassignedCount.value = Number(res?.count ?? 0);
|
||||||
|
} catch {
|
||||||
|
unassignedCount.value = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchWarehouses(resetPage = false) {
|
||||||
|
if (resetPage) {
|
||||||
|
pagination.value.current = 1;
|
||||||
|
}
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const result = await getWarehousePageApi({
|
||||||
|
page: pagination.value.current,
|
||||||
|
pageSize: pagination.value.pageSize,
|
||||||
|
filters: {
|
||||||
|
keywords: keyword.value || undefined,
|
||||||
|
status: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
warehouses.value = result.records ?? [];
|
||||||
|
pagination.value.total = result.total ?? 0;
|
||||||
|
} catch (error: any) {
|
||||||
|
message.error(error?.message || '获取仓库列表失败');
|
||||||
|
warehouses.value = [];
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetSearch() {
|
||||||
|
keyword.value = '';
|
||||||
|
void searchWarehouses(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function goPage(page: number) {
|
||||||
|
const next = Math.min(totalPages.value, Math.max(1, page));
|
||||||
|
if (next === pagination.value.current) return;
|
||||||
|
pagination.value.current = next;
|
||||||
|
void searchWarehouses();
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectAll() {
|
||||||
|
emit('update:scope', 'all');
|
||||||
|
emit('update:selectedWarehouseId', undefined);
|
||||||
|
emit('select', { scope: 'all', warehouse: null });
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectUnassigned() {
|
||||||
|
emit('update:scope', 'unassigned');
|
||||||
|
emit('update:selectedWarehouseId', undefined);
|
||||||
|
emit('select', { scope: 'unassigned', warehouse: null });
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectWarehouse(wh: WarehouseVO.Info) {
|
||||||
|
emit('update:scope', 'warehouse');
|
||||||
|
emit('update:selectedWarehouseId', wh.id);
|
||||||
|
emit('select', { scope: 'warehouse', warehouse: wh });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refresh() {
|
||||||
|
await Promise.all([loadUnassignedCount(), searchWarehouses()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ refresh });
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void refresh();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div
|
||||||
|
v-if="collapsed"
|
||||||
|
class="flex h-full min-h-0 w-full flex-col items-center gap-1 pb-2 pt-3"
|
||||||
|
>
|
||||||
|
<Tooltip title="展开仓库列表">
|
||||||
|
<Button type="text" size="small" class="!px-1" @click="emit('expand')">
|
||||||
|
<PanelOpenIcon class="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flex min-h-0 w-full flex-1 flex-col items-center gap-1.5 overflow-y-auto px-1.5 pb-1 pt-2"
|
||||||
|
>
|
||||||
|
<Tooltip title="全部 SKU">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||||
|
:class="
|
||||||
|
allSelected
|
||||||
|
? 'ring-2 ring-primary ring-offset-1 ring-offset-background'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectAll"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex h-9 w-9 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||||
|
>
|
||||||
|
<BoxesIcon class="h-4 w-4 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="未分配">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||||
|
:class="
|
||||||
|
unassignedSelected
|
||||||
|
? 'ring-2 ring-primary ring-offset-1 ring-offset-background'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectUnassigned"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex h-9 w-9 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||||
|
>
|
||||||
|
<InboxIcon class="h-4 w-4 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Spin
|
||||||
|
:spinning="loading"
|
||||||
|
size="small"
|
||||||
|
wrapper-class-name="warehouse-sidebar-collapsed-spin"
|
||||||
|
>
|
||||||
|
<div class="flex w-full flex-col items-center gap-1.5">
|
||||||
|
<Tooltip
|
||||||
|
v-for="wh in warehouses"
|
||||||
|
:key="wh.id"
|
||||||
|
:title="`${wh.name}(${wh.skuCount ?? 0})`"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="inline-flex shrink-0 rounded-md p-0.5 transition-colors hover:bg-accent"
|
||||||
|
:class="
|
||||||
|
scope === 'warehouse' && selectedWarehouseId === wh.id
|
||||||
|
? 'ring-2 ring-primary ring-offset-1 ring-offset-background'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectWarehouse(wh)"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex h-9 w-9 items-center justify-center rounded-md border border-border bg-card text-xs font-medium"
|
||||||
|
>
|
||||||
|
{{ (wh.name || wh.code || '?').slice(0, 1) }}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="totalPages > 1"
|
||||||
|
class="flex shrink-0 flex-col items-center gap-0.5"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
class="!h-6 !px-1"
|
||||||
|
:disabled="pagination.current <= 1 || loading"
|
||||||
|
@click="goPage(pagination.current - 1)"
|
||||||
|
>
|
||||||
|
<ChevronUpIcon class="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
<span class="text-[10px] leading-none text-muted-foreground">
|
||||||
|
{{ pagination.current }}/{{ totalPages }}
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
class="!h-6 !px-1"
|
||||||
|
:disabled="pagination.current >= totalPages || loading"
|
||||||
|
@click="goPage(pagination.current + 1)"
|
||||||
|
>
|
||||||
|
<ChevronDownIcon class="h-3.5 w-3.5" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
v-else
|
||||||
|
class="flex h-full flex-col overflow-hidden"
|
||||||
|
:class="fluid ? 'w-full min-w-0' : 'w-[320px] shrink-0'"
|
||||||
|
:body-style="{
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '8px',
|
||||||
|
minHeight: 0,
|
||||||
|
minWidth: 0,
|
||||||
|
overflow: 'hidden',
|
||||||
|
padding: '12px',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span class="flex items-center gap-2 text-base font-semibold">
|
||||||
|
<WarehouseIcon class="h-4 w-4" />
|
||||||
|
发货仓
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-if="showCollapseAction" #extra>
|
||||||
|
<Tooltip title="收起仓库列表">
|
||||||
|
<Button type="text" size="small" class="!px-1" @click="emit('collapse')">
|
||||||
|
<PanelCloseIcon class="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="flex min-w-0 shrink-0 items-center gap-2">
|
||||||
|
<Input
|
||||||
|
v-model:value="keyword"
|
||||||
|
placeholder="名称/编码"
|
||||||
|
allow-clear
|
||||||
|
class="min-w-0 flex-1"
|
||||||
|
@press-enter="searchWarehouses(true)"
|
||||||
|
/>
|
||||||
|
<Button type="primary" class="shrink-0" @click="searchWarehouses(true)">
|
||||||
|
搜索
|
||||||
|
</Button>
|
||||||
|
<Button class="shrink-0" @click="resetSearch">重置</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">
|
||||||
|
<div class="flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto">
|
||||||
|
<Card
|
||||||
|
size="small"
|
||||||
|
:body-style="{ padding: '10px 12px' }"
|
||||||
|
class="cursor-pointer !shadow-none hover:border-primary"
|
||||||
|
:class="allSelected ? 'border-primary bg-primary/5' : undefined"
|
||||||
|
@click="selectAll"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<div
|
||||||
|
class="flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||||
|
>
|
||||||
|
<BoxesIcon class="h-4 w-4 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<div class="flex items-center justify-between gap-2">
|
||||||
|
<span class="min-w-0 truncate text-sm font-medium">全部</span>
|
||||||
|
<span class="shrink-0 text-xs text-muted-foreground">全部 SKU</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
size="small"
|
||||||
|
:body-style="{ padding: '10px 12px' }"
|
||||||
|
class="cursor-pointer !shadow-none hover:border-primary"
|
||||||
|
:class="unassignedSelected ? 'border-primary bg-primary/5' : undefined"
|
||||||
|
@click="selectUnassigned"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<div
|
||||||
|
class="flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-dashed border-border bg-muted/50"
|
||||||
|
>
|
||||||
|
<InboxIcon class="h-4 w-4 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<div class="flex items-center justify-between gap-2">
|
||||||
|
<span class="min-w-0 truncate text-sm font-medium">未分配</span>
|
||||||
|
<Tag class="m-0 shrink-0">{{ unassignedCount }}</Tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Spin
|
||||||
|
:spinning="loading"
|
||||||
|
wrapper-class-name="warehouse-sidebar-list-spin"
|
||||||
|
>
|
||||||
|
<Empty
|
||||||
|
v-if="!loading && warehouses.length === 0"
|
||||||
|
class="py-8"
|
||||||
|
description="暂无启用仓库"
|
||||||
|
/>
|
||||||
|
<div v-else class="flex flex-col gap-2">
|
||||||
|
<Card
|
||||||
|
v-for="wh in warehouses"
|
||||||
|
:key="wh.id"
|
||||||
|
size="small"
|
||||||
|
:body-style="{ padding: '10px 12px' }"
|
||||||
|
class="cursor-pointer !shadow-none hover:border-primary"
|
||||||
|
:class="
|
||||||
|
scope === 'warehouse' && selectedWarehouseId === wh.id
|
||||||
|
? 'border-primary bg-primary/5'
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
@click="selectWarehouse(wh)"
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<div
|
||||||
|
class="flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-border bg-card"
|
||||||
|
>
|
||||||
|
<WarehouseIcon class="h-4 w-4 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<div class="flex items-center justify-between gap-2">
|
||||||
|
<span class="min-w-0 truncate text-sm font-medium">
|
||||||
|
{{ wh.name }}
|
||||||
|
</span>
|
||||||
|
<Tag class="m-0 shrink-0">{{ wh.skuCount ?? 0 }}</Tag>
|
||||||
|
</div>
|
||||||
|
<div class="truncate text-xs text-muted-foreground">
|
||||||
|
{{ wh.code }}
|
||||||
|
<template v-if="wh.province || wh.city">
|
||||||
|
· {{ [wh.province, wh.city].filter(Boolean).join(' ') }}
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="mt-2 flex w-full min-w-0 shrink-0 items-center justify-between gap-2"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
class="shrink-0"
|
||||||
|
:disabled="pagination.current <= 1 || loading"
|
||||||
|
@click="goPage(pagination.current - 1)"
|
||||||
|
>
|
||||||
|
上一页
|
||||||
|
</Button>
|
||||||
|
<span
|
||||||
|
class="min-w-0 flex-1 truncate text-center text-xs text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ pagination.current }} / {{ totalPages }}
|
||||||
|
<span class="ml-1 opacity-70">({{ pagination.total }})</span>
|
||||||
|
</span>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
class="shrink-0"
|
||||||
|
:disabled="pagination.current >= totalPages || loading"
|
||||||
|
@click="goPage(pagination.current + 1)"
|
||||||
|
>
|
||||||
|
下一页
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
:deep(.warehouse-sidebar-collapsed-spin),
|
||||||
|
:deep(.warehouse-sidebar-collapsed-spin .ant-spin-container) {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.warehouse-sidebar-list-spin),
|
||||||
|
:deep(.warehouse-sidebar-list-spin .ant-spin-container) {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+1
-1
@@ -76,7 +76,7 @@ async function open(id: number) {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
detail.value = null;
|
detail.value = null;
|
||||||
try {
|
try {
|
||||||
detail.value = await getExpressQuoteDetailApi(id);
|
detail.value = await getExpressQuoteDetailApi(id, true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
message.error('加载报价详情失败');
|
message.error('加载报价详情失败');
|
||||||
|
|||||||
-486
@@ -1,486 +0,0 @@
|
|||||||
<script lang="ts" setup>
|
|
||||||
import type { ExpressQuoteDTO, ExpressQuoteVO } from '#/api/ec/express-quote';
|
|
||||||
|
|
||||||
import { computed, reactive, ref } from 'vue';
|
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
|
||||||
|
|
||||||
import {
|
|
||||||
Button,
|
|
||||||
Form,
|
|
||||||
FormItem,
|
|
||||||
Input,
|
|
||||||
InputNumber,
|
|
||||||
message,
|
|
||||||
Select,
|
|
||||||
Switch,
|
|
||||||
} from 'ant-design-vue';
|
|
||||||
|
|
||||||
import {
|
|
||||||
createExpressQuoteApi,
|
|
||||||
getExpressCarriersApi,
|
|
||||||
getExpressProvincesApi,
|
|
||||||
getExpressQuoteDetailApi,
|
|
||||||
updateExpressQuoteApi,
|
|
||||||
upsertExpressQuoteVersionApi,
|
|
||||||
} from '#/api/ec/express-quote';
|
|
||||||
|
|
||||||
const emit = defineEmits<{ success: [] }>();
|
|
||||||
|
|
||||||
interface BandRow {
|
|
||||||
weightFromG: number;
|
|
||||||
weightToG: number | null;
|
|
||||||
priceMode: string;
|
|
||||||
flatAmount: number;
|
|
||||||
firstWeightG: number;
|
|
||||||
firstAmount: number;
|
|
||||||
continuePerKg: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RegionRow {
|
|
||||||
regionName: string;
|
|
||||||
zoneLabel: string;
|
|
||||||
provinces: string[];
|
|
||||||
isDefault: boolean;
|
|
||||||
bands: BandRow[];
|
|
||||||
}
|
|
||||||
|
|
||||||
function emptyBand(fromG = 0): BandRow {
|
|
||||||
return {
|
|
||||||
weightFromG: fromG,
|
|
||||||
weightToG: null,
|
|
||||||
priceMode: 'FLAT_TICKET',
|
|
||||||
flatAmount: 0,
|
|
||||||
firstWeightG: 0,
|
|
||||||
firstAmount: 0,
|
|
||||||
continuePerKg: 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function emptyRegion(): RegionRow {
|
|
||||||
return {
|
|
||||||
regionName: '默认区',
|
|
||||||
zoneLabel: '',
|
|
||||||
provinces: [],
|
|
||||||
isDefault: true,
|
|
||||||
bands: [emptyBand(0)],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const isEdit = ref(false);
|
|
||||||
const editingId = ref<number>();
|
|
||||||
const carriers = ref<ExpressQuoteVO.CarrierOption[]>([]);
|
|
||||||
const provinces = ref<ExpressQuoteVO.ProvinceOption[]>([]);
|
|
||||||
|
|
||||||
const form = reactive({
|
|
||||||
code: '',
|
|
||||||
name: '',
|
|
||||||
carrierCode: 'ZTO',
|
|
||||||
billingMode: 'FLAT',
|
|
||||||
status: 1,
|
|
||||||
remark: '',
|
|
||||||
effectiveFrom: new Date().toISOString().slice(0, 10),
|
|
||||||
flatAmount: 0,
|
|
||||||
unitScope: 'ORDER',
|
|
||||||
pricePerKg: 0,
|
|
||||||
minAmount: undefined as number | undefined,
|
|
||||||
volumeDivisor: 6000,
|
|
||||||
useVolumetric: false,
|
|
||||||
weightRound: 'NONE',
|
|
||||||
regions: [emptyRegion()] as RegionRow[],
|
|
||||||
});
|
|
||||||
|
|
||||||
const isRegion = computed(() => form.billingMode === 'REGION_WEIGHT');
|
|
||||||
const isFlat = computed(() => form.billingMode === 'FLAT');
|
|
||||||
const isPerKg = computed(() => form.billingMode === 'PER_KG');
|
|
||||||
|
|
||||||
const provinceOptions = computed(() =>
|
|
||||||
provinces.value.map((p) => ({ value: p.code, label: p.name })),
|
|
||||||
);
|
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
|
||||||
onConfirm: handleSubmit,
|
|
||||||
onOpenChange: (open) => {
|
|
||||||
if (!open) reset();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function reset() {
|
|
||||||
Object.assign(form, {
|
|
||||||
code: '',
|
|
||||||
name: '',
|
|
||||||
carrierCode: 'ZTO',
|
|
||||||
billingMode: 'FLAT',
|
|
||||||
status: 1,
|
|
||||||
remark: '',
|
|
||||||
effectiveFrom: new Date().toISOString().slice(0, 10),
|
|
||||||
flatAmount: 0,
|
|
||||||
unitScope: 'ORDER',
|
|
||||||
pricePerKg: 0,
|
|
||||||
minAmount: undefined,
|
|
||||||
volumeDivisor: 6000,
|
|
||||||
useVolumetric: false,
|
|
||||||
weightRound: 'NONE',
|
|
||||||
});
|
|
||||||
form.regions = [emptyRegion()];
|
|
||||||
isEdit.value = false;
|
|
||||||
editingId.value = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function ensureMeta() {
|
|
||||||
if (!carriers.value.length) {
|
|
||||||
carriers.value = await getExpressCarriersApi();
|
|
||||||
}
|
|
||||||
if (!provinces.value.length) {
|
|
||||||
provinces.value = await getExpressProvincesApi();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillFromVersion(v?: ExpressQuoteVO.Version) {
|
|
||||||
if (!v) return;
|
|
||||||
form.effectiveFrom = v.effectiveFrom;
|
|
||||||
form.flatAmount = v.flatAmount ?? 0;
|
|
||||||
form.unitScope = v.unitScope || 'ORDER';
|
|
||||||
form.pricePerKg = v.pricePerKg ?? 0;
|
|
||||||
form.minAmount = v.minAmount;
|
|
||||||
form.volumeDivisor = v.volumeDivisor ?? 6000;
|
|
||||||
form.useVolumetric = v.useVolumetric === 1;
|
|
||||||
form.weightRound = v.weightRound || 'NONE';
|
|
||||||
if (v.regions?.length) {
|
|
||||||
form.regions = v.regions.map((r) => ({
|
|
||||||
regionName: r.regionName,
|
|
||||||
zoneLabel: r.zoneLabel || '',
|
|
||||||
provinces: r.provinces ? [...r.provinces] : [],
|
|
||||||
isDefault: r.isDefault === 1,
|
|
||||||
bands:
|
|
||||||
r.bands?.length ?
|
|
||||||
r.bands.map((b) => ({
|
|
||||||
weightFromG: b.weightFromG ?? 0,
|
|
||||||
weightToG: b.weightToG ?? null,
|
|
||||||
priceMode: b.priceMode || 'FLAT_TICKET',
|
|
||||||
flatAmount: b.flatAmount ?? 0,
|
|
||||||
firstWeightG: b.firstWeightG ?? 0,
|
|
||||||
firstAmount: b.firstAmount ?? 0,
|
|
||||||
continuePerKg: b.continuePerKg ?? 0,
|
|
||||||
}))
|
|
||||||
: [emptyBand(0)],
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function open(edit: boolean, row?: ExpressQuoteVO.Info) {
|
|
||||||
await ensureMeta();
|
|
||||||
isEdit.value = edit;
|
|
||||||
if (edit && row) {
|
|
||||||
editingId.value = row.id;
|
|
||||||
const detail = await getExpressQuoteDetailApi(row.id);
|
|
||||||
form.code = detail.code;
|
|
||||||
form.name = detail.name;
|
|
||||||
form.carrierCode = detail.carrierCode;
|
|
||||||
form.billingMode = detail.billingMode;
|
|
||||||
form.status = detail.status;
|
|
||||||
form.remark = detail.remark || '';
|
|
||||||
fillFromVersion(detail.currentVersion);
|
|
||||||
} else {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
modalApi.setState({
|
|
||||||
title: edit ? '编辑报价单' : '新建报价单',
|
|
||||||
class: form.billingMode === 'REGION_WEIGHT' ? 'w-[920px]' : 'w-[640px]',
|
|
||||||
});
|
|
||||||
modalApi.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
function addRegion() {
|
|
||||||
form.regions.push({
|
|
||||||
regionName: `分区${form.regions.length + 1}`,
|
|
||||||
zoneLabel: '',
|
|
||||||
provinces: [],
|
|
||||||
isDefault: false,
|
|
||||||
bands: [emptyBand(0)],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeRegion(idx: number) {
|
|
||||||
if (form.regions.length <= 1) {
|
|
||||||
message.warning('至少保留一个分区');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
form.regions.splice(idx, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function addBand(region: RegionRow) {
|
|
||||||
const last = region.bands[region.bands.length - 1];
|
|
||||||
const nextFrom =
|
|
||||||
last?.weightToG != null ? last.weightToG + 1 : (last?.weightFromG ?? 0) + 1000;
|
|
||||||
region.bands.push(emptyBand(nextFrom));
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeBand(region: RegionRow, idx: number) {
|
|
||||||
if (region.bands.length <= 1) {
|
|
||||||
message.warning('每分区至少一条重量带');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
region.bands.splice(idx, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildVersion(): ExpressQuoteDTO.VersionUpsert {
|
|
||||||
const version: ExpressQuoteDTO.VersionUpsert = {
|
|
||||||
effectiveFrom: form.effectiveFrom,
|
|
||||||
volumeDivisor: form.volumeDivisor,
|
|
||||||
useVolumetric: form.useVolumetric ? 1 : 0,
|
|
||||||
weightRound: form.weightRound,
|
|
||||||
};
|
|
||||||
if (form.billingMode === 'FLAT') {
|
|
||||||
version.flatAmount = form.flatAmount;
|
|
||||||
version.unitScope = form.unitScope;
|
|
||||||
} else if (form.billingMode === 'PER_KG') {
|
|
||||||
version.pricePerKg = form.pricePerKg;
|
|
||||||
version.minAmount = form.minAmount;
|
|
||||||
} else {
|
|
||||||
version.regions = form.regions.map((r, i) => ({
|
|
||||||
regionName: r.regionName.trim() || `分区${i + 1}`,
|
|
||||||
zoneLabel: r.zoneLabel.trim() || undefined,
|
|
||||||
provinces: r.provinces,
|
|
||||||
isDefault: r.isDefault ? 1 : 0,
|
|
||||||
sortOrder: i,
|
|
||||||
bands: r.bands.map((b, bi) => ({
|
|
||||||
weightFromG: b.weightFromG ?? 0,
|
|
||||||
weightToG: b.weightToG,
|
|
||||||
priceMode: b.priceMode,
|
|
||||||
flatAmount: b.priceMode === 'FLAT_TICKET' ? b.flatAmount : undefined,
|
|
||||||
firstWeightG: b.priceMode === 'FIRST_PLUS_KG' ? b.firstWeightG : undefined,
|
|
||||||
firstAmount: b.priceMode === 'FIRST_PLUS_KG' ? b.firstAmount : undefined,
|
|
||||||
continuePerKg: b.priceMode === 'FIRST_PLUS_KG' ? b.continuePerKg : undefined,
|
|
||||||
sortOrder: bi,
|
|
||||||
})),
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
|
||||||
if (!form.name.trim() || (!isEdit.value && !form.code.trim())) {
|
|
||||||
message.warning('请填写编码与名称');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isRegion.value) {
|
|
||||||
for (const r of form.regions) {
|
|
||||||
if (!r.bands.length) {
|
|
||||||
message.warning(`分区「${r.regionName}」至少一条重量带`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
modalApi.setState({ confirming: true });
|
|
||||||
try {
|
|
||||||
if (isEdit.value && editingId.value) {
|
|
||||||
await updateExpressQuoteApi(editingId.value, {
|
|
||||||
name: form.name.trim(),
|
|
||||||
carrierCode: form.carrierCode,
|
|
||||||
status: form.status,
|
|
||||||
remark: form.remark || undefined,
|
|
||||||
});
|
|
||||||
if (form.effectiveFrom) {
|
|
||||||
await upsertExpressQuoteVersionApi(editingId.value, buildVersion());
|
|
||||||
}
|
|
||||||
message.success('已更新');
|
|
||||||
} else {
|
|
||||||
await createExpressQuoteApi({
|
|
||||||
code: form.code.trim(),
|
|
||||||
name: form.name.trim(),
|
|
||||||
carrierCode: form.carrierCode,
|
|
||||||
billingMode: form.billingMode,
|
|
||||||
status: form.status,
|
|
||||||
remark: form.remark || undefined,
|
|
||||||
initialVersion: buildVersion(),
|
|
||||||
});
|
|
||||||
message.success('创建成功');
|
|
||||||
}
|
|
||||||
modalApi.close();
|
|
||||||
emit('success');
|
|
||||||
} finally {
|
|
||||||
modalApi.setState({ confirming: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({ open });
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Modal>
|
|
||||||
<Form layout="vertical" class="max-h-[75vh] overflow-y-auto px-1">
|
|
||||||
<FormItem v-if="!isEdit" label="报价编码" required>
|
|
||||||
<Input v-model:value="form.code" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="名称" required>
|
|
||||||
<Input v-model:value="form.name" />
|
|
||||||
</FormItem>
|
|
||||||
<div class="grid grid-cols-2 gap-3">
|
|
||||||
<FormItem label="承运商" required>
|
|
||||||
<Select
|
|
||||||
v-model:value="form.carrierCode"
|
|
||||||
:options="carriers.map((c) => ({ value: c.code, label: c.name }))"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="计费模式" required>
|
|
||||||
<Select
|
|
||||||
v-model:value="form.billingMode"
|
|
||||||
:disabled="isEdit"
|
|
||||||
:options="[
|
|
||||||
{ value: 'FLAT', label: '一口价 FLAT' },
|
|
||||||
{ value: 'PER_KG', label: '按千克 PER_KG' },
|
|
||||||
{ value: 'REGION_WEIGHT', label: '分区×重量带' },
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
</div>
|
|
||||||
<FormItem label="状态">
|
|
||||||
<Select
|
|
||||||
v-model:value="form.status"
|
|
||||||
:options="[
|
|
||||||
{ label: '启用', value: 1 },
|
|
||||||
{ label: '停用', value: 0 },
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="生效日(版本)" required>
|
|
||||||
<Input v-model:value="form.effectiveFrom" placeholder="yyyy-MM-dd" />
|
|
||||||
</FormItem>
|
|
||||||
<template v-if="isFlat">
|
|
||||||
<div class="grid grid-cols-2 gap-3">
|
|
||||||
<FormItem label="一口价(元)">
|
|
||||||
<InputNumber v-model:value="form.flatAmount" :min="0" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="计费单位">
|
|
||||||
<Select
|
|
||||||
v-model:value="form.unitScope"
|
|
||||||
:options="[
|
|
||||||
{ value: 'ORDER', label: '每单' },
|
|
||||||
{ value: 'PIECE', label: '每件' },
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-if="isPerKg">
|
|
||||||
<div class="grid grid-cols-2 gap-3">
|
|
||||||
<FormItem label="元/kg">
|
|
||||||
<InputNumber v-model:value="form.pricePerKg" :min="0" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="最低消费">
|
|
||||||
<InputNumber v-model:value="form.minAmount" :min="0" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-if="isRegion">
|
|
||||||
<div class="mb-2 flex items-center justify-between">
|
|
||||||
<span class="text-sm text-muted-foreground">目的分区 × 重量带(对齐承运商报价矩阵)</span>
|
|
||||||
<Button size="small" type="dashed" @click="addRegion">添加分区</Button>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-for="(region, ri) in form.regions"
|
|
||||||
:key="ri"
|
|
||||||
class="mb-3 rounded border border-border p-3"
|
|
||||||
>
|
|
||||||
<div class="mb-2 flex items-start justify-between gap-2">
|
|
||||||
<div class="grid flex-1 grid-cols-3 gap-2">
|
|
||||||
<FormItem label="分区名" class="mb-0">
|
|
||||||
<Input v-model:value="region.regionName" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="价区标签" class="mb-0">
|
|
||||||
<Input v-model:value="region.zoneLabel" placeholder="一类/二类…" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="默认分区" class="mb-0">
|
|
||||||
<Switch v-model:checked="region.isDefault" />
|
|
||||||
</FormItem>
|
|
||||||
</div>
|
|
||||||
<Button size="small" danger type="link" @click="removeRegion(ri)">删除</Button>
|
|
||||||
</div>
|
|
||||||
<FormItem label="目的地(省或市)" class="mb-2">
|
|
||||||
<Select
|
|
||||||
v-model:value="region.provinces"
|
|
||||||
mode="tags"
|
|
||||||
allow-clear
|
|
||||||
show-search
|
|
||||||
option-filter-prop="label"
|
|
||||||
:options="provinceOptions"
|
|
||||||
placeholder="选省或输入市名如深圳市"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
<div class="mb-1 flex items-center justify-between">
|
|
||||||
<span class="text-xs text-muted-foreground">重量带</span>
|
|
||||||
<Button size="small" type="link" @click="addBand(region)">加带</Button>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-for="(band, bi) in region.bands"
|
|
||||||
:key="bi"
|
|
||||||
class="mb-2 grid grid-cols-12 items-end gap-2 rounded bg-muted/40 p-2"
|
|
||||||
>
|
|
||||||
<FormItem label="从(克)" class="col-span-2 mb-0">
|
|
||||||
<InputNumber v-model:value="band.weightFromG" :min="0" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="到(克)" class="col-span-2 mb-0">
|
|
||||||
<InputNumber
|
|
||||||
v-model:value="band.weightToG"
|
|
||||||
:min="0"
|
|
||||||
class="w-full"
|
|
||||||
placeholder="空=无上限"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="方式" class="col-span-3 mb-0">
|
|
||||||
<Select
|
|
||||||
v-model:value="band.priceMode"
|
|
||||||
:options="[
|
|
||||||
{ value: 'FLAT_TICKET', label: '元/票' },
|
|
||||||
{ value: 'FIRST_PLUS_KG', label: '首重+续重/kg' },
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
<template v-if="band.priceMode === 'FLAT_TICKET'">
|
|
||||||
<FormItem label="元/票" class="col-span-3 mb-0">
|
|
||||||
<InputNumber v-model:value="band.flatAmount" :min="0" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<FormItem label="首重克" class="col-span-1 mb-0">
|
|
||||||
<InputNumber v-model:value="band.firstWeightG" :min="0" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="首重价" class="col-span-2 mb-0">
|
|
||||||
<InputNumber v-model:value="band.firstAmount" :min="0" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="续重元/kg" class="col-span-2 mb-0">
|
|
||||||
<InputNumber v-model:value="band.continuePerKg" :min="0" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
</template>
|
|
||||||
<div class="col-span-2 flex justify-end pb-1">
|
|
||||||
<Button size="small" type="link" danger @click="removeBand(region, bi)">
|
|
||||||
删带
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<div class="grid grid-cols-3 gap-3">
|
|
||||||
<FormItem label="启用体积重">
|
|
||||||
<Switch v-model:checked="form.useVolumetric" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="体积重除数">
|
|
||||||
<InputNumber v-model:value="form.volumeDivisor" :min="1" class="w-full" />
|
|
||||||
</FormItem>
|
|
||||||
<FormItem label="计费重取整">
|
|
||||||
<Select
|
|
||||||
v-model:value="form.weightRound"
|
|
||||||
:options="[
|
|
||||||
{ value: 'NONE', label: '不取整' },
|
|
||||||
{ value: 'CEIL_KG', label: '向上整千克' },
|
|
||||||
]"
|
|
||||||
/>
|
|
||||||
</FormItem>
|
|
||||||
</div>
|
|
||||||
<FormItem label="备注">
|
|
||||||
<Input.TextArea v-model:value="form.remark" :rows="2" />
|
|
||||||
</FormItem>
|
|
||||||
</Form>
|
|
||||||
</Modal>
|
|
||||||
</template>
|
|
||||||
+476
@@ -0,0 +1,476 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 分区×重量带编辑:左侧分区导航(可选进入拖拽排序)+ 右侧分区卡片。
|
||||||
|
* 排序落库用数组下标 → sortOrder(表字段已有)。
|
||||||
|
*/
|
||||||
|
import type { Sortable } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { computed, nextTick, onBeforeUnmount, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useSortable } from '@vben/hooks';
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Input,
|
||||||
|
InputNumber,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Switch,
|
||||||
|
Table,
|
||||||
|
message,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { createRegionUid, type BandRow, type RegionRow } from './region-band';
|
||||||
|
|
||||||
|
/** 分区导航拖拽手柄 */
|
||||||
|
const GripVerticalIcon = createIconifyIcon('lucide:grip-vertical');
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
modelValue: RegionRow[];
|
||||||
|
provinceOptions: { label: string; value: string }[];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [value: RegionRow[]];
|
||||||
|
}>();
|
||||||
|
|
||||||
|
defineOptions({ name: 'RegionBandEditor' });
|
||||||
|
|
||||||
|
const scrollRef = ref<HTMLElement | null>(null);
|
||||||
|
const navListRef = ref<HTMLElement | null>(null);
|
||||||
|
let navSortable: Sortable | null = null;
|
||||||
|
|
||||||
|
/** 是否处于拖拽排序模式 */
|
||||||
|
const sorting = ref(false);
|
||||||
|
/** 排序草稿,确定后写回 model;取消则丢弃 */
|
||||||
|
const draftRegions = ref<RegionRow[]>([]);
|
||||||
|
|
||||||
|
const regions = computed({
|
||||||
|
get: () => props.modelValue,
|
||||||
|
set: (v) => emit('update:modelValue', v),
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 导航列表数据源:排序中用草稿,否则用正式数据 */
|
||||||
|
const navRegions = computed(() =>
|
||||||
|
sorting.value ? draftRegions.value : regions.value,
|
||||||
|
);
|
||||||
|
|
||||||
|
const bandColumnDefs = [
|
||||||
|
{ title: '从(克)', key: 'from', width: 110 },
|
||||||
|
{ title: '到(克)', key: 'to', width: 110 },
|
||||||
|
{ title: '方式', key: 'mode', width: 150 },
|
||||||
|
{ title: '价格', key: 'price' },
|
||||||
|
{ title: '操作', key: 'action', width: 72 },
|
||||||
|
];
|
||||||
|
|
||||||
|
function emptyBand(fromG = 0): BandRow {
|
||||||
|
return {
|
||||||
|
weightFromG: fromG,
|
||||||
|
weightToG: null,
|
||||||
|
priceMode: 'FLAT_TICKET',
|
||||||
|
flatAmount: 0,
|
||||||
|
firstWeightG: 0,
|
||||||
|
firstAmount: 0,
|
||||||
|
continuePerKg: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollToRegion(uid: string) {
|
||||||
|
if (sorting.value) return;
|
||||||
|
document
|
||||||
|
.getElementById(`quote-region-${uid}`)
|
||||||
|
?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroyNavSortable() {
|
||||||
|
navSortable?.destroy();
|
||||||
|
navSortable = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 进入排序后再绑 Sortable,避免默认态误拖、也避免 ref 未挂载 */
|
||||||
|
async function initNavSortable() {
|
||||||
|
destroyNavSortable();
|
||||||
|
await nextTick();
|
||||||
|
const el = navListRef.value;
|
||||||
|
if (!el || draftRegions.value.length < 2) return;
|
||||||
|
const { initializeSortable } = useSortable(el, {
|
||||||
|
animation: 200,
|
||||||
|
delay: 0,
|
||||||
|
handle: '.region-nav-drag-handle',
|
||||||
|
draggable: '.region-nav-item',
|
||||||
|
onEnd(evt) {
|
||||||
|
const { oldIndex, newIndex } = evt;
|
||||||
|
if (
|
||||||
|
oldIndex == null ||
|
||||||
|
newIndex == null ||
|
||||||
|
oldIndex === newIndex ||
|
||||||
|
Number.isNaN(oldIndex) ||
|
||||||
|
Number.isNaN(newIndex)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const list = [...draftRegions.value];
|
||||||
|
const [moved] = list.splice(oldIndex, 1);
|
||||||
|
if (!moved) return;
|
||||||
|
list.splice(newIndex, 0, moved);
|
||||||
|
draftRegions.value = list;
|
||||||
|
// Vue 按 uid 重排 DOM 后需重绑,否则下次拖拽失效
|
||||||
|
void initNavSortable();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
navSortable = await initializeSortable();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function enterSortMode() {
|
||||||
|
if (regions.value.length < 2) {
|
||||||
|
message.warning('至少两个分区才能排序');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
draftRegions.value = regions.value.map((r) => ({ ...r }));
|
||||||
|
sorting.value = true;
|
||||||
|
await initNavSortable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function confirmSort() {
|
||||||
|
regions.value = draftRegions.value.map((r) => ({ ...r }));
|
||||||
|
destroyNavSortable();
|
||||||
|
sorting.value = false;
|
||||||
|
draftRegions.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelSort() {
|
||||||
|
destroyNavSortable();
|
||||||
|
sorting.value = false;
|
||||||
|
draftRegions.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
destroyNavSortable();
|
||||||
|
});
|
||||||
|
|
||||||
|
function addRegion() {
|
||||||
|
if (sorting.value) return;
|
||||||
|
const uid = createRegionUid();
|
||||||
|
const nextIndex = regions.value.length;
|
||||||
|
regions.value = [
|
||||||
|
...regions.value,
|
||||||
|
{
|
||||||
|
uid,
|
||||||
|
regionName: `分区${nextIndex + 1}`,
|
||||||
|
zoneLabel: '',
|
||||||
|
provinces: [],
|
||||||
|
isDefault: false,
|
||||||
|
bands: [emptyBand(0)],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
void nextTick(() => scrollToRegion(uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeRegion(idx: number) {
|
||||||
|
if (sorting.value) return;
|
||||||
|
if (regions.value.length <= 1) {
|
||||||
|
message.warning('至少保留一个分区');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const next = [...regions.value];
|
||||||
|
next.splice(idx, 1);
|
||||||
|
regions.value = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
function patchRegion(idx: number, patch: Partial<RegionRow>) {
|
||||||
|
const next = [...regions.value];
|
||||||
|
const cur = next[idx];
|
||||||
|
if (!cur) return;
|
||||||
|
next[idx] = { ...cur, ...patch };
|
||||||
|
regions.value = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBand(ri: number) {
|
||||||
|
const region = regions.value[ri];
|
||||||
|
if (!region) return;
|
||||||
|
const last = region.bands[region.bands.length - 1];
|
||||||
|
const nextFrom =
|
||||||
|
last?.weightToG != null ? last.weightToG + 1 : (last?.weightFromG ?? 0) + 1000;
|
||||||
|
patchRegion(ri, { bands: [...region.bands, emptyBand(nextFrom)] });
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeBand(ri: number, bi: number) {
|
||||||
|
const region = regions.value[ri];
|
||||||
|
if (!region) return;
|
||||||
|
if (region.bands.length <= 1) {
|
||||||
|
message.warning('每分区至少一条重量带');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const bands = [...region.bands];
|
||||||
|
bands.splice(bi, 1);
|
||||||
|
patchRegion(ri, { bands });
|
||||||
|
}
|
||||||
|
|
||||||
|
function patchBand(ri: number, bi: number, patch: Partial<BandRow>) {
|
||||||
|
const region = regions.value[ri];
|
||||||
|
if (!region) return;
|
||||||
|
const bands = region.bands.map((b, i) => (i === bi ? { ...b, ...patch } : b));
|
||||||
|
patchRegion(ri, { bands });
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Card
|
||||||
|
size="small"
|
||||||
|
title="目的分区 × 重量带"
|
||||||
|
class="eq-panel-card flex h-full min-h-0 flex-col overflow-hidden"
|
||||||
|
:body-style="{
|
||||||
|
flex: '1 1 0%',
|
||||||
|
minHeight: 0,
|
||||||
|
overflow: 'hidden',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
padding: '12px',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #extra>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="dashed"
|
||||||
|
:disabled="sorting"
|
||||||
|
@click="addRegion"
|
||||||
|
>
|
||||||
|
添加分区
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<div class="flex min-h-0 flex-1 gap-3 overflow-hidden">
|
||||||
|
<aside
|
||||||
|
class="w-44 shrink-0 overflow-y-auto border-r border-border pr-2 pt-1"
|
||||||
|
>
|
||||||
|
<div class="mb-2 flex items-center justify-between gap-1">
|
||||||
|
<span class="text-xs text-muted-foreground">分区导航</span>
|
||||||
|
<template v-if="sorting">
|
||||||
|
<Space :size="4">
|
||||||
|
<Button size="small" type="link" @click="cancelSort">取消</Button>
|
||||||
|
<Button size="small" type="link" @click="confirmSort">
|
||||||
|
确定
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
<Button
|
||||||
|
v-else
|
||||||
|
size="small"
|
||||||
|
type="link"
|
||||||
|
class="!px-0"
|
||||||
|
:disabled="regions.length < 2"
|
||||||
|
@click="enterSortMode"
|
||||||
|
>
|
||||||
|
调整顺序
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="sorting"
|
||||||
|
class="mb-1 text-xs text-muted-foreground"
|
||||||
|
>
|
||||||
|
拖动手柄调整,完成后点确定
|
||||||
|
</div>
|
||||||
|
<div ref="navListRef" class="flex flex-col gap-0.5">
|
||||||
|
<div
|
||||||
|
v-for="(region, ri) in navRegions"
|
||||||
|
:key="region.uid"
|
||||||
|
class="region-nav-item flex items-center gap-1 rounded px-1 py-1 text-sm hover:bg-muted/50"
|
||||||
|
:class="sorting ? 'bg-muted/30' : undefined"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
v-if="sorting"
|
||||||
|
class="region-nav-drag-handle shrink-0 cursor-grab text-muted-foreground active:cursor-grabbing"
|
||||||
|
title="拖动调整顺序"
|
||||||
|
@click.stop
|
||||||
|
>
|
||||||
|
<GripVerticalIcon class="size-3.5" />
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="min-w-0 flex-1 truncate text-left text-foreground"
|
||||||
|
:class="sorting ? 'cursor-default' : undefined"
|
||||||
|
:title="region.zoneLabel || region.regionName || `分区${ri + 1}`"
|
||||||
|
@click="scrollToRegion(region.uid)"
|
||||||
|
>
|
||||||
|
{{ region.zoneLabel || region.regionName || `分区${ri + 1}` }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
<div
|
||||||
|
ref="scrollRef"
|
||||||
|
class="flex min-h-0 min-w-0 flex-1 flex-col gap-3 overflow-x-hidden overflow-y-auto pb-1"
|
||||||
|
>
|
||||||
|
<Card
|
||||||
|
v-for="(region, ri) in regions"
|
||||||
|
:id="`quote-region-${region.uid}`"
|
||||||
|
:key="region.uid"
|
||||||
|
size="small"
|
||||||
|
class="shrink-0 scroll-mt-2"
|
||||||
|
:title="region.regionName || `分区${ri + 1}`"
|
||||||
|
>
|
||||||
|
<template #extra>
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
danger
|
||||||
|
size="small"
|
||||||
|
:disabled="sorting"
|
||||||
|
@click="removeRegion(ri)"
|
||||||
|
>
|
||||||
|
删除分区
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
<div class="mb-3 grid grid-cols-1 gap-3 md:grid-cols-4">
|
||||||
|
<div>
|
||||||
|
<div class="mb-1 text-xs text-muted-foreground">分区名</div>
|
||||||
|
<Input
|
||||||
|
:value="region.regionName"
|
||||||
|
@update:value="(v) => patchRegion(ri, { regionName: String(v) })"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="mb-1 text-xs text-muted-foreground">价区标签</div>
|
||||||
|
<Input
|
||||||
|
:value="region.zoneLabel"
|
||||||
|
placeholder="一类/二类…"
|
||||||
|
@update:value="(v) => patchRegion(ri, { zoneLabel: String(v) })"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="mb-1 text-xs text-muted-foreground">默认分区</div>
|
||||||
|
<Switch
|
||||||
|
:checked="region.isDefault"
|
||||||
|
@update:checked="(v) => patchRegion(ri, { isDefault: !!v })"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="md:col-span-4">
|
||||||
|
<div class="mb-1 text-xs text-muted-foreground">
|
||||||
|
目的地(省或市)
|
||||||
|
</div>
|
||||||
|
<Select
|
||||||
|
class="w-full"
|
||||||
|
mode="tags"
|
||||||
|
allow-clear
|
||||||
|
show-search
|
||||||
|
option-filter-prop="label"
|
||||||
|
:options="provinceOptions"
|
||||||
|
:value="region.provinces"
|
||||||
|
placeholder="选省或输入市名如深圳市"
|
||||||
|
@update:value="
|
||||||
|
(v) => patchRegion(ri, { provinces: (v as string[]) || [] })
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-2 flex justify-end">
|
||||||
|
<Button size="small" type="link" @click="addBand(ri)">
|
||||||
|
加重量带
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
:pagination="false"
|
||||||
|
:columns="bandColumnDefs"
|
||||||
|
:data-source="region.bands"
|
||||||
|
:row-key="(_r: BandRow, i?: number) => `${region.uid}-${i ?? 0}`"
|
||||||
|
>
|
||||||
|
<template #bodyCell="{ column, index }">
|
||||||
|
<template v-if="column.key === 'from'">
|
||||||
|
<InputNumber
|
||||||
|
class="w-full"
|
||||||
|
:min="0"
|
||||||
|
:value="region.bands[index]?.weightFromG"
|
||||||
|
@update:value="
|
||||||
|
(v) => patchBand(ri, index, { weightFromG: Number(v ?? 0) })
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'to'">
|
||||||
|
<InputNumber
|
||||||
|
class="w-full"
|
||||||
|
:min="0"
|
||||||
|
placeholder="空=无上限"
|
||||||
|
:value="region.bands[index]?.weightToG ?? undefined"
|
||||||
|
@update:value="
|
||||||
|
(v) =>
|
||||||
|
patchBand(ri, index, {
|
||||||
|
weightToG: v == null ? null : Number(v),
|
||||||
|
})
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'mode'">
|
||||||
|
<Select
|
||||||
|
class="w-full"
|
||||||
|
:value="region.bands[index]?.priceMode"
|
||||||
|
:options="[
|
||||||
|
{ value: 'FLAT_TICKET', label: '元/票' },
|
||||||
|
{ value: 'FIRST_PLUS_KG', label: '首重+续重/kg' },
|
||||||
|
]"
|
||||||
|
@update:value="
|
||||||
|
(v) => patchBand(ri, index, { priceMode: String(v) })
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'price'">
|
||||||
|
<InputNumber
|
||||||
|
v-if="region.bands[index]?.priceMode === 'FLAT_TICKET'"
|
||||||
|
class="w-full"
|
||||||
|
:min="0"
|
||||||
|
addon-after="元/票"
|
||||||
|
:value="region.bands[index]?.flatAmount"
|
||||||
|
@update:value="
|
||||||
|
(v) => patchBand(ri, index, { flatAmount: Number(v ?? 0) })
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<Space v-else wrap>
|
||||||
|
<InputNumber
|
||||||
|
class="w-28"
|
||||||
|
:min="0"
|
||||||
|
addon-after="首重克"
|
||||||
|
:value="region.bands[index]?.firstWeightG"
|
||||||
|
@update:value="
|
||||||
|
(v) =>
|
||||||
|
patchBand(ri, index, { firstWeightG: Number(v ?? 0) })
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<InputNumber
|
||||||
|
class="w-28"
|
||||||
|
:min="0"
|
||||||
|
addon-after="首重价"
|
||||||
|
:value="region.bands[index]?.firstAmount"
|
||||||
|
@update:value="
|
||||||
|
(v) =>
|
||||||
|
patchBand(ri, index, { firstAmount: Number(v ?? 0) })
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<InputNumber
|
||||||
|
class="w-28"
|
||||||
|
:min="0"
|
||||||
|
addon-after="续/kg"
|
||||||
|
:value="region.bands[index]?.continuePerKg"
|
||||||
|
@update:value="
|
||||||
|
(v) =>
|
||||||
|
patchBand(ri, index, { continuePerKg: Number(v ?? 0) })
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'action'">
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
danger
|
||||||
|
size="small"
|
||||||
|
@click="removeBand(ri, index)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</Table>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
/** 分区×重量带编辑用的行模型与前端 uid */
|
||||||
|
|
||||||
|
export interface BandRow {
|
||||||
|
weightFromG: number;
|
||||||
|
weightToG: number | null;
|
||||||
|
priceMode: string;
|
||||||
|
flatAmount: number;
|
||||||
|
firstWeightG: number;
|
||||||
|
firstAmount: number;
|
||||||
|
continuePerKg: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RegionRow {
|
||||||
|
/** 前端稳定键,拖拽重排后避免卡片错位 */
|
||||||
|
uid: string;
|
||||||
|
regionName: string;
|
||||||
|
zoneLabel: string;
|
||||||
|
provinces: string[];
|
||||||
|
isDefault: boolean;
|
||||||
|
bands: BandRow[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 生成分区前端 uid */
|
||||||
|
export function createRegionUid() {
|
||||||
|
return `r-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
||||||
|
}
|
||||||
@@ -0,0 +1,582 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import type { ExpressQuoteDTO, ExpressQuoteVO } from '#/api/ec/express-quote';
|
||||||
|
|
||||||
|
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
||||||
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
import { ColPage } from '@vben/common-ui';
|
||||||
|
import { useTabs } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { Button, Card, Empty, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createExpressQuoteApi,
|
||||||
|
getExpressCarriersApi,
|
||||||
|
getExpressProvincesApi,
|
||||||
|
getExpressQuoteDetailApi,
|
||||||
|
updateExpressQuoteApi,
|
||||||
|
upsertExpressQuoteVersionApi,
|
||||||
|
} from '#/api/ec/express-quote';
|
||||||
|
import { formatOverviewTabTitle } from '#/utils/overview-tab-title';
|
||||||
|
|
||||||
|
import RegionBandEditor from './components/RegionBandEditor.vue';
|
||||||
|
import { createRegionUid, type RegionRow } from './components/region-band';
|
||||||
|
|
||||||
|
defineOptions({ name: 'ExpressQuoteEdit' });
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
const { setTabTitle, closeCurrentTab } = useTabs();
|
||||||
|
|
||||||
|
const quoteId = computed(() => {
|
||||||
|
const raw = route.params.id;
|
||||||
|
const id = raw ? Number(raw) : 0;
|
||||||
|
return Number.isFinite(id) && id > 0 ? id : undefined;
|
||||||
|
});
|
||||||
|
const isEdit = computed(() => quoteId.value != null);
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const saving = ref(false);
|
||||||
|
const pageTitle = ref('快递报价单编辑「新建」');
|
||||||
|
const provinces = ref<ExpressQuoteVO.ProvinceOption[]>([]);
|
||||||
|
const regions = ref<RegionRow[]>([
|
||||||
|
{
|
||||||
|
uid: createRegionUid(),
|
||||||
|
regionName: '默认区',
|
||||||
|
zoneLabel: '',
|
||||||
|
provinces: [],
|
||||||
|
isDefault: true,
|
||||||
|
bands: [
|
||||||
|
{
|
||||||
|
weightFromG: 0,
|
||||||
|
weightToG: null,
|
||||||
|
priceMode: 'FLAT_TICKET',
|
||||||
|
flatAmount: 0,
|
||||||
|
firstWeightG: 0,
|
||||||
|
firstAmount: 0,
|
||||||
|
continuePerKg: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const provinceOptions = computed(() =>
|
||||||
|
provinces.value.map((p) => ({ value: p.code, label: p.name })),
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 编辑页乐观按分区模式,避免首屏按 FLAT 分栏约束被拉成对半 */
|
||||||
|
const billingMode = ref(isEdit.value ? 'REGION_WEIGHT' : 'FLAT');
|
||||||
|
const isRegion = computed(() => billingMode.value === 'REGION_WEIGHT');
|
||||||
|
|
||||||
|
async function syncTabTitle(name?: string) {
|
||||||
|
let rawName = name;
|
||||||
|
if (rawName == null) {
|
||||||
|
try {
|
||||||
|
const values = await formApi.getValues();
|
||||||
|
rawName = values.name ? String(values.name) : undefined;
|
||||||
|
} catch {
|
||||||
|
rawName = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const title = formatOverviewTabTitle(
|
||||||
|
'快递报价单编辑',
|
||||||
|
rawName,
|
||||||
|
isEdit.value ? `#${quoteId.value}` : '新建',
|
||||||
|
);
|
||||||
|
pageTitle.value = title;
|
||||||
|
await setTabTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 分区模式左栏贴最小宽;与 billingMode 乐观初始值对齐 */
|
||||||
|
const leftWidth = ref(isEdit.value ? 22 : 50);
|
||||||
|
|
||||||
|
function syncLeftWidthByMode() {
|
||||||
|
leftWidth.value = isRegion.value ? 22 : 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 外层 Card 撑满列高,body 内滚动 */
|
||||||
|
const cardBodyScrollStyle = {
|
||||||
|
flex: '1 1 0%',
|
||||||
|
minHeight: 0,
|
||||||
|
overflowY: 'auto' as const,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column' as const,
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(isRegion, () => {
|
||||||
|
syncLeftWidthByMode();
|
||||||
|
});
|
||||||
|
|
||||||
|
const [BaseForm, formApi] = useVbenForm({
|
||||||
|
layout: 'vertical',
|
||||||
|
compact: true,
|
||||||
|
commonConfig: {
|
||||||
|
componentProps: { class: 'w-full' },
|
||||||
|
labelClass: 'w-full',
|
||||||
|
},
|
||||||
|
wrapperClass: 'grid-cols-1',
|
||||||
|
showDefaultActions: false,
|
||||||
|
handleValuesChange(values, fieldsChanged) {
|
||||||
|
if (fieldsChanged.includes('billingMode') && values.billingMode) {
|
||||||
|
billingMode.value = String(values.billingMode);
|
||||||
|
}
|
||||||
|
if (fieldsChanged.includes('name')) {
|
||||||
|
void syncTabTitle(String(values.name ?? ''));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '报价编码',
|
||||||
|
rules: 'required',
|
||||||
|
dependencies: {
|
||||||
|
show: () => !isEdit.value,
|
||||||
|
triggerFields: ['name'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '名称',
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'ApiSelect',
|
||||||
|
fieldName: 'carrierCode',
|
||||||
|
label: '承运商',
|
||||||
|
rules: 'selectRequired',
|
||||||
|
defaultValue: 'ZTO',
|
||||||
|
componentProps: {
|
||||||
|
api: getExpressCarriersApi,
|
||||||
|
afterFetch: (data: ExpressQuoteVO.CarrierOption[]) =>
|
||||||
|
(data || []).map((c) => ({ label: c.name, value: c.code })),
|
||||||
|
immediate: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
fieldName: 'billingMode',
|
||||||
|
label: '计费模式',
|
||||||
|
rules: 'selectRequired',
|
||||||
|
defaultValue: 'FLAT',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ value: 'FLAT', label: '一口价 FLAT' },
|
||||||
|
{ value: 'PER_KG', label: '按千克 PER_KG' },
|
||||||
|
{ value: 'REGION_WEIGHT', label: '分区×重量带' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
disabled: () => isEdit.value,
|
||||||
|
triggerFields: ['name'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
defaultValue: 1,
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '启用', value: 1 },
|
||||||
|
{ label: '停用', value: 0 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'DatePicker',
|
||||||
|
fieldName: 'effectiveFrom',
|
||||||
|
label: '生效日(版本)',
|
||||||
|
rules: 'required',
|
||||||
|
defaultValue: new Date().toISOString().slice(0, 10),
|
||||||
|
componentProps: {
|
||||||
|
valueFormat: 'YYYY-MM-DD',
|
||||||
|
class: 'w-full',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'flatAmount',
|
||||||
|
label: '一口价(元)',
|
||||||
|
defaultValue: 0,
|
||||||
|
dependencies: {
|
||||||
|
if: (values) => values.billingMode === 'FLAT',
|
||||||
|
triggerFields: ['billingMode'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
fieldName: 'unitScope',
|
||||||
|
label: '计费单位',
|
||||||
|
defaultValue: 'ORDER',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ value: 'ORDER', label: '每单' },
|
||||||
|
{ value: 'PIECE', label: '每件' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dependencies: {
|
||||||
|
if: (values) => values.billingMode === 'FLAT',
|
||||||
|
triggerFields: ['billingMode'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'pricePerKg',
|
||||||
|
label: '元/kg',
|
||||||
|
defaultValue: 0,
|
||||||
|
dependencies: {
|
||||||
|
if: (values) => values.billingMode === 'PER_KG',
|
||||||
|
triggerFields: ['billingMode'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'minAmount',
|
||||||
|
label: '最低消费',
|
||||||
|
dependencies: {
|
||||||
|
if: (values) => values.billingMode === 'PER_KG',
|
||||||
|
triggerFields: ['billingMode'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Switch',
|
||||||
|
fieldName: 'useVolumetric',
|
||||||
|
label: '启用体积重',
|
||||||
|
defaultValue: false,
|
||||||
|
// 覆盖 commonConfig 的 w-full,避免开关被拉成整栏宽
|
||||||
|
componentProps: { class: 'w-auto' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'InputNumber',
|
||||||
|
fieldName: 'volumeDivisor',
|
||||||
|
label: '体积重除数',
|
||||||
|
defaultValue: 6000,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
fieldName: 'weightRound',
|
||||||
|
label: '计费重取整',
|
||||||
|
defaultValue: 'NONE',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ value: 'NONE', label: '不取整' },
|
||||||
|
{ value: 'CEIL_KG', label: '向上整千克' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Textarea',
|
||||||
|
fieldName: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
componentProps: { rows: 2 },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
function fillRegionsFromVersion(v?: ExpressQuoteVO.Version) {
|
||||||
|
if (!v?.regions?.length) {
|
||||||
|
regions.value = [
|
||||||
|
{
|
||||||
|
uid: createRegionUid(),
|
||||||
|
regionName: '默认区',
|
||||||
|
zoneLabel: '',
|
||||||
|
provinces: [],
|
||||||
|
isDefault: true,
|
||||||
|
bands: [
|
||||||
|
{
|
||||||
|
weightFromG: 0,
|
||||||
|
weightToG: null,
|
||||||
|
priceMode: 'FLAT_TICKET',
|
||||||
|
flatAmount: 0,
|
||||||
|
firstWeightG: 0,
|
||||||
|
firstAmount: 0,
|
||||||
|
continuePerKg: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const sorted = [...v.regions].sort(
|
||||||
|
(a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0),
|
||||||
|
);
|
||||||
|
regions.value = sorted.map((r) => ({
|
||||||
|
uid: createRegionUid(),
|
||||||
|
regionName: r.regionName,
|
||||||
|
zoneLabel: r.zoneLabel || '',
|
||||||
|
provinces: r.provinces ? [...r.provinces] : [],
|
||||||
|
isDefault: r.isDefault === 1,
|
||||||
|
bands:
|
||||||
|
r.bands?.length ?
|
||||||
|
r.bands.map((b) => ({
|
||||||
|
weightFromG: b.weightFromG ?? 0,
|
||||||
|
weightToG: b.weightToG ?? null,
|
||||||
|
priceMode: b.priceMode || 'FLAT_TICKET',
|
||||||
|
flatAmount: b.flatAmount ?? 0,
|
||||||
|
firstWeightG: b.firstWeightG ?? 0,
|
||||||
|
firstAmount: b.firstAmount ?? 0,
|
||||||
|
continuePerKg: b.continuePerKg ?? 0,
|
||||||
|
}))
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
weightFromG: 0,
|
||||||
|
weightToG: null,
|
||||||
|
priceMode: 'FLAT_TICKET',
|
||||||
|
flatAmount: 0,
|
||||||
|
firstWeightG: 0,
|
||||||
|
firstAmount: 0,
|
||||||
|
continuePerKg: 0,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadDetail() {
|
||||||
|
loading.value = true;
|
||||||
|
let tabTitle: string | undefined;
|
||||||
|
try {
|
||||||
|
// 省份与详情并行,避免串行拉长转圈
|
||||||
|
const needProvinces = !provinces.value.length;
|
||||||
|
const [provinceList, detail] = await Promise.all([
|
||||||
|
needProvinces ? getExpressProvincesApi() : Promise.resolve(null),
|
||||||
|
quoteId.value
|
||||||
|
? getExpressQuoteDetailApi(quoteId.value)
|
||||||
|
: Promise.resolve(null),
|
||||||
|
]);
|
||||||
|
if (provinceList) {
|
||||||
|
provinces.value = provinceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!detail) {
|
||||||
|
await formApi.resetForm();
|
||||||
|
await formApi.setValues({
|
||||||
|
carrierCode: 'ZTO',
|
||||||
|
billingMode: 'FLAT',
|
||||||
|
status: 1,
|
||||||
|
effectiveFrom: new Date().toISOString().slice(0, 10),
|
||||||
|
flatAmount: 0,
|
||||||
|
unitScope: 'ORDER',
|
||||||
|
volumeDivisor: 6000,
|
||||||
|
useVolumetric: false,
|
||||||
|
weightRound: 'NONE',
|
||||||
|
});
|
||||||
|
billingMode.value = 'FLAT';
|
||||||
|
syncLeftWidthByMode();
|
||||||
|
fillRegionsFromVersion();
|
||||||
|
tabTitle = '新建';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const v = detail.currentVersion;
|
||||||
|
billingMode.value = detail.billingMode;
|
||||||
|
syncLeftWidthByMode();
|
||||||
|
// 先回填表单并结束 loading,再挂大块分区(避免接口已返回仍长时间转圈)
|
||||||
|
await formApi.setValues({
|
||||||
|
code: detail.code,
|
||||||
|
name: detail.name,
|
||||||
|
carrierCode: detail.carrierCode,
|
||||||
|
billingMode: detail.billingMode,
|
||||||
|
status: detail.status,
|
||||||
|
remark: detail.remark || '',
|
||||||
|
effectiveFrom: v?.effectiveFrom || new Date().toISOString().slice(0, 10),
|
||||||
|
flatAmount: v?.flatAmount ?? 0,
|
||||||
|
unitScope: v?.unitScope || 'ORDER',
|
||||||
|
pricePerKg: v?.pricePerKg ?? 0,
|
||||||
|
minAmount: v?.minAmount,
|
||||||
|
volumeDivisor: v?.volumeDivisor ?? 6000,
|
||||||
|
useVolumetric: v?.useVolumetric === 1,
|
||||||
|
weightRound: v?.weightRound || 'NONE',
|
||||||
|
});
|
||||||
|
loading.value = false;
|
||||||
|
await nextTick();
|
||||||
|
fillRegionsFromVersion(v);
|
||||||
|
tabTitle = detail.name;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
message.error('加载报价单失败');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
if (tabTitle != null) {
|
||||||
|
void syncTabTitle(tabTitle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildVersion(
|
||||||
|
values: Record<string, unknown>,
|
||||||
|
): ExpressQuoteDTO.VersionUpsert {
|
||||||
|
const mode = String(values.billingMode);
|
||||||
|
const version: ExpressQuoteDTO.VersionUpsert = {
|
||||||
|
effectiveFrom: String(values.effectiveFrom),
|
||||||
|
volumeDivisor: Number(values.volumeDivisor ?? 6000),
|
||||||
|
useVolumetric: values.useVolumetric ? 1 : 0,
|
||||||
|
weightRound: String(values.weightRound || 'NONE'),
|
||||||
|
remark: values.remark ? String(values.remark) : undefined,
|
||||||
|
};
|
||||||
|
if (mode === 'FLAT') {
|
||||||
|
version.flatAmount = Number(values.flatAmount ?? 0);
|
||||||
|
version.unitScope = String(values.unitScope || 'ORDER');
|
||||||
|
} else if (mode === 'PER_KG') {
|
||||||
|
version.pricePerKg = Number(values.pricePerKg ?? 0);
|
||||||
|
version.minAmount =
|
||||||
|
values.minAmount == null ? undefined : Number(values.minAmount);
|
||||||
|
} else {
|
||||||
|
version.regions = regions.value.map((r, i) => ({
|
||||||
|
regionName: r.regionName.trim() || `分区${i + 1}`,
|
||||||
|
zoneLabel: r.zoneLabel.trim() || undefined,
|
||||||
|
provinces: r.provinces,
|
||||||
|
isDefault: r.isDefault ? 1 : 0,
|
||||||
|
sortOrder: i,
|
||||||
|
bands: r.bands.map((b, bi) => ({
|
||||||
|
weightFromG: b.weightFromG ?? 0,
|
||||||
|
weightToG: b.weightToG,
|
||||||
|
priceMode: b.priceMode,
|
||||||
|
flatAmount: b.priceMode === 'FLAT_TICKET' ? b.flatAmount : undefined,
|
||||||
|
firstWeightG:
|
||||||
|
b.priceMode === 'FIRST_PLUS_KG' ? b.firstWeightG : undefined,
|
||||||
|
firstAmount:
|
||||||
|
b.priceMode === 'FIRST_PLUS_KG' ? b.firstAmount : undefined,
|
||||||
|
continuePerKg:
|
||||||
|
b.priceMode === 'FIRST_PLUS_KG' ? b.continuePerKg : undefined,
|
||||||
|
sortOrder: bi,
|
||||||
|
})),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSubmit() {
|
||||||
|
const { valid } = await formApi.validate();
|
||||||
|
if (!valid) return;
|
||||||
|
const values = await formApi.getValues();
|
||||||
|
if (isRegion.value) {
|
||||||
|
for (const r of regions.value) {
|
||||||
|
if (!r.bands.length) {
|
||||||
|
message.warning(`分区「${r.regionName}」至少一条重量带`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
saving.value = true;
|
||||||
|
try {
|
||||||
|
if (isEdit.value && quoteId.value) {
|
||||||
|
await updateExpressQuoteApi(quoteId.value, {
|
||||||
|
name: String(values.name).trim(),
|
||||||
|
carrierCode: String(values.carrierCode),
|
||||||
|
status: Number(values.status),
|
||||||
|
remark: values.remark ? String(values.remark) : undefined,
|
||||||
|
});
|
||||||
|
await upsertExpressQuoteVersionApi(quoteId.value, buildVersion(values));
|
||||||
|
message.success('已更新');
|
||||||
|
await syncTabTitle(String(values.name));
|
||||||
|
} else {
|
||||||
|
const created = await createExpressQuoteApi({
|
||||||
|
code: String(values.code).trim(),
|
||||||
|
name: String(values.name).trim(),
|
||||||
|
carrierCode: String(values.carrierCode),
|
||||||
|
billingMode: String(values.billingMode),
|
||||||
|
status: Number(values.status),
|
||||||
|
remark: values.remark ? String(values.remark) : undefined,
|
||||||
|
initialVersion: buildVersion(values),
|
||||||
|
});
|
||||||
|
message.success('创建成功');
|
||||||
|
await router.replace(`/ec/warehouse/express-quote/edit/${created.id}`);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
saving.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleBack() {
|
||||||
|
await closeCurrentTab();
|
||||||
|
await router.push('/ec/warehouse/express-quote');
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
void loadDetail();
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.params.id,
|
||||||
|
() => {
|
||||||
|
void loadDetail();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="express-quote-edit-page min-h-0">
|
||||||
|
<ColPage
|
||||||
|
v-model:left-width="leftWidth"
|
||||||
|
auto-content-height
|
||||||
|
:loading="loading"
|
||||||
|
:left-min-width="isRegion ? 22 : 40"
|
||||||
|
:left-max-width="isRegion ? 40 : 72"
|
||||||
|
:right-width="100 - leftWidth"
|
||||||
|
:left-collapsible="false"
|
||||||
|
resizable
|
||||||
|
split-line
|
||||||
|
content-class="!flex !min-h-0 !flex-col !overflow-hidden !p-3"
|
||||||
|
>
|
||||||
|
<template #left>
|
||||||
|
<Card
|
||||||
|
size="small"
|
||||||
|
title="基本信息"
|
||||||
|
class="eq-panel-card flex h-full min-h-0 flex-col overflow-hidden"
|
||||||
|
:body-style="cardBodyScrollStyle"
|
||||||
|
>
|
||||||
|
<BaseForm />
|
||||||
|
</Card>
|
||||||
|
</template>
|
||||||
|
<div class="h-full min-h-0 min-w-0 overflow-hidden">
|
||||||
|
<RegionBandEditor
|
||||||
|
v-if="isRegion"
|
||||||
|
v-model="regions"
|
||||||
|
:province-options="provinceOptions"
|
||||||
|
/>
|
||||||
|
<Card
|
||||||
|
v-else
|
||||||
|
size="small"
|
||||||
|
title="分区报价"
|
||||||
|
class="eq-panel-card flex h-full min-h-0 flex-col overflow-hidden"
|
||||||
|
:body-style="cardBodyScrollStyle"
|
||||||
|
>
|
||||||
|
<Empty
|
||||||
|
class="py-16"
|
||||||
|
description="当前为一口价 / 按千克模式,无需配置目的分区。切换为「分区×重量带」后在此编辑。"
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<div class="flex w-full justify-end gap-2 px-1 py-1">
|
||||||
|
<Button @click="handleBack">返回列表</Button>
|
||||||
|
<Button type="primary" :loading="saving" @click="handleSubmit">
|
||||||
|
保存
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</ColPage>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/**
|
||||||
|
* 内容区高度由 Page autoContentHeight 按「视口 − footer」算出;
|
||||||
|
* 分栏只填满该剩余高度,勿再用 !h-full 盖掉 calc。
|
||||||
|
*/
|
||||||
|
.express-quote-edit-page :deep([data-panel-group]) {
|
||||||
|
height: 100%;
|
||||||
|
min-height: 0;
|
||||||
|
flex: 1 1 0%;
|
||||||
|
}
|
||||||
|
/* 只约束列级面板卡;勿套到右栏内部分区卡,否则 max-height:100% 会裁切并透出半截内容 */
|
||||||
|
.express-quote-edit-page :deep(.eq-panel-card.ant-card) {
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
.express-quote-edit-page :deep(.eq-panel-card > .ant-card-head) {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -4,6 +4,7 @@ import type { ExpressQuoteDTO, ExpressQuoteVO } from '#/api/ec/express-quote';
|
|||||||
import type { PageQueryDTO } from '#/types/common';
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
import { createIconifyIcon } from '@vben/icons';
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
@@ -23,22 +24,27 @@ import {
|
|||||||
} from '#/composables/use-vxe-action-column';
|
} from '#/composables/use-vxe-action-column';
|
||||||
|
|
||||||
import ExpressQuoteDetailDrawer from './components/ExpressQuoteDetailDrawer.vue';
|
import ExpressQuoteDetailDrawer from './components/ExpressQuoteDetailDrawer.vue';
|
||||||
import ExpressQuoteFormModal from './components/ExpressQuoteFormModal.vue';
|
|
||||||
import ExpressQuoteImportModal from './components/ExpressQuoteImportModal.vue';
|
import ExpressQuoteImportModal from './components/ExpressQuoteImportModal.vue';
|
||||||
|
|
||||||
defineOptions({ name: 'ExpressQuoteManagement' });
|
defineOptions({ name: 'ExpressQuoteManagement' });
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const formModalRef = ref<InstanceType<typeof ExpressQuoteFormModal> | null>(
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
const importModalRef = ref<InstanceType<typeof ExpressQuoteImportModal> | null>(
|
const importModalRef = ref<InstanceType<typeof ExpressQuoteImportModal> | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
const detailDrawerRef = ref<InstanceType<
|
const detailDrawerRef = ref<InstanceType<
|
||||||
typeof ExpressQuoteDetailDrawer
|
typeof ExpressQuoteDetailDrawer
|
||||||
> | null>(null);
|
> | null>(null);
|
||||||
|
|
||||||
|
function goCreate() {
|
||||||
|
void router.push('/ec/warehouse/express-quote/edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
function goEdit(row: ExpressQuoteVO.Info) {
|
||||||
|
void router.push(`/ec/warehouse/express-quote/edit/${row.id}`);
|
||||||
|
}
|
||||||
const searchForm = ref({
|
const searchForm = ref({
|
||||||
keywords: '',
|
keywords: '',
|
||||||
billingMode: undefined as string | undefined,
|
billingMode: undefined as string | undefined,
|
||||||
@@ -194,7 +200,7 @@ async function handleDelete(row: ExpressQuoteVO.Info) {
|
|||||||
<Button @click="importModalRef?.open()">导入</Button>
|
<Button @click="importModalRef?.open()">导入</Button>
|
||||||
</PermissionGate>
|
</PermissionGate>
|
||||||
<PermissionGate code="ec:express-quote:create">
|
<PermissionGate code="ec:express-quote:create">
|
||||||
<Button type="primary" @click="formModalRef?.open(false)">
|
<Button type="primary" @click="goCreate">
|
||||||
<PlusIcon />
|
<PlusIcon />
|
||||||
新建报价
|
新建报价
|
||||||
</Button>
|
</Button>
|
||||||
@@ -220,9 +226,7 @@ async function handleDelete(row: ExpressQuoteVO.Info) {
|
|||||||
</Button>
|
</Button>
|
||||||
</PermissionGate>
|
</PermissionGate>
|
||||||
<PermissionGate code="ec:express-quote:update">
|
<PermissionGate code="ec:express-quote:update">
|
||||||
<Button size="small" @click="formModalRef?.open(true, row)">
|
<Button size="small" @click="goEdit(row)">编辑/调价</Button>
|
||||||
编辑/调价
|
|
||||||
</Button>
|
|
||||||
</PermissionGate>
|
</PermissionGate>
|
||||||
<PermissionGate code="ec:express-quote:delete">
|
<PermissionGate code="ec:express-quote:delete">
|
||||||
<Popconfirm title="确定删除?" @confirm="handleDelete(row)">
|
<Popconfirm title="确定删除?" @confirm="handleDelete(row)">
|
||||||
@@ -232,7 +236,6 @@ async function handleDelete(row: ExpressQuoteVO.Info) {
|
|||||||
</Space>
|
</Space>
|
||||||
</template>
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
<ExpressQuoteFormModal ref="formModalRef" @success="gridApi.reload()" />
|
|
||||||
<ExpressQuoteImportModal
|
<ExpressQuoteImportModal
|
||||||
ref="importModalRef"
|
ref="importModalRef"
|
||||||
@success="gridApi.reload()"
|
@success="gridApi.reload()"
|
||||||
|
|||||||
@@ -0,0 +1,334 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 发货仓商品:左栏仓筛选,右栏 SKU 列表与批量分配默认仓。
|
||||||
|
*/
|
||||||
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
|
import type { WarehouseVO } from '#/api/ec/warehouse';
|
||||||
|
import type { ProductSkuVO } from '#/api/ec/product/sku';
|
||||||
|
import type { WarehouseSidebarScope } from '#/views/ec/components/WarehouseSidebarList.vue';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { createIconifyIcon } from '@vben/icons';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
message,
|
||||||
|
Modal,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
} from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
batchAssignWarehouseSkusApi,
|
||||||
|
getEnabledWarehousesApi,
|
||||||
|
getWarehouseSkuPageApi,
|
||||||
|
} from '#/api/ec/warehouse';
|
||||||
|
import { PermissionGate } from '#/components/permission';
|
||||||
|
import {
|
||||||
|
syncVxeGridColumns,
|
||||||
|
useActionColumnVisible,
|
||||||
|
} from '#/composables/use-vxe-action-column';
|
||||||
|
import EcWarehouseColPage from '#/views/ec/components/EcWarehouseColPage.vue';
|
||||||
|
|
||||||
|
defineOptions({ name: 'WarehouseSkuManagement' });
|
||||||
|
|
||||||
|
const AssignIcon = createIconifyIcon('lucide:package-plus');
|
||||||
|
const ClearIcon = createIconifyIcon('lucide:unlink');
|
||||||
|
|
||||||
|
const scope = ref<WarehouseSidebarScope>('all');
|
||||||
|
const selectedWarehouseId = ref<number | undefined>(undefined);
|
||||||
|
const selectedWarehouseName = ref<string | undefined>(undefined);
|
||||||
|
const colPageRef = ref<InstanceType<typeof EcWarehouseColPage> | null>(null);
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
const hasSelected = ref(false);
|
||||||
|
const keywords = ref('');
|
||||||
|
const gridReloadRef = ref<(() => void) | null>(null);
|
||||||
|
|
||||||
|
const assignOpen = ref(false);
|
||||||
|
const assignLoading = ref(false);
|
||||||
|
const assignTargetId = ref<number | undefined>(undefined);
|
||||||
|
const assignWarehouseOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
|
|
||||||
|
const showCheckboxColumn = useActionColumnVisible(['ec:warehouse:update']);
|
||||||
|
|
||||||
|
const titleText = computed(() => {
|
||||||
|
if (scope.value === 'unassigned') return '未分配 SKU';
|
||||||
|
if (scope.value === 'warehouse') {
|
||||||
|
return selectedWarehouseName.value
|
||||||
|
? `发货仓「${selectedWarehouseName.value}」的 SKU`
|
||||||
|
: '发货仓 SKU';
|
||||||
|
}
|
||||||
|
return '全部 SKU';
|
||||||
|
});
|
||||||
|
|
||||||
|
const tableBaseColumns: VxeGridProps<ProductSkuVO.Info>['columns'] = [
|
||||||
|
{ type: 'seq' as const, minWidth: 'auto', title: '序号' },
|
||||||
|
{ field: 'productName', title: '商品', minWidth: 140 },
|
||||||
|
{ field: 'name', title: 'SKU', minWidth: 120 },
|
||||||
|
{ field: 'skuCode', title: '编码', minWidth: 120 },
|
||||||
|
{ field: 'warehouseName', title: '发货仓', minWidth: 120 },
|
||||||
|
{
|
||||||
|
field: 'weightG',
|
||||||
|
title: '实重(g)',
|
||||||
|
minWidth: 90,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const checkboxColumn: NonNullable<
|
||||||
|
VxeGridProps<ProductSkuVO.Info>['columns']
|
||||||
|
>[number] = {
|
||||||
|
type: 'checkbox' as const,
|
||||||
|
width: 48,
|
||||||
|
};
|
||||||
|
|
||||||
|
const tableColumns = computed(() =>
|
||||||
|
showCheckboxColumn.value
|
||||||
|
? [checkboxColumn, ...(tableBaseColumns ?? [])]
|
||||||
|
: (tableBaseColumns ?? []),
|
||||||
|
);
|
||||||
|
|
||||||
|
const formOptions = computed(() => ({
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '商品/SKU/编码',
|
||||||
|
allowClear: true,
|
||||||
|
onChange: (e: Event) => {
|
||||||
|
keywords.value = (e.target as HTMLInputElement).value;
|
||||||
|
},
|
||||||
|
onPressEnter: () => gridReloadRef.value?.(),
|
||||||
|
},
|
||||||
|
fieldName: 'keywords',
|
||||||
|
label: '关键字',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: true,
|
||||||
|
collapsed: true,
|
||||||
|
handleSubmit: async () => gridReloadRef.value?.(),
|
||||||
|
handleReset: async () => {
|
||||||
|
keywords.value = '';
|
||||||
|
gridReloadRef.value?.();
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
function buildFilters() {
|
||||||
|
return {
|
||||||
|
keywords: keywords.value || undefined,
|
||||||
|
warehouseId:
|
||||||
|
scope.value === 'warehouse' ? selectedWarehouseId.value : undefined,
|
||||||
|
unassignedOnly: scope.value === 'unassigned' ? true : undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const gridOptions: VxeGridProps<ProductSkuVO.Info> = {
|
||||||
|
columns: tableColumns.value,
|
||||||
|
height: 'auto',
|
||||||
|
border: true,
|
||||||
|
stripe: true,
|
||||||
|
rowConfig: { keyField: 'id' },
|
||||||
|
checkboxConfig: { highlight: true },
|
||||||
|
pagerConfig: { enabled: true, pageSizes: [10, 20, 50, 100] },
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }) => {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const data = await getWarehouseSkuPageApi({
|
||||||
|
page: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
filters: buildFilters(),
|
||||||
|
});
|
||||||
|
return { items: data.records, total: data.total };
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions,
|
||||||
|
formOptions: formOptions.value,
|
||||||
|
showSearchForm: true,
|
||||||
|
tableTitle: '发货仓商品',
|
||||||
|
gridEvents: {
|
||||||
|
checkboxAll: () => syncSelection(),
|
||||||
|
checkboxChange: () => syncSelection(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
gridReloadRef.value = () => gridApi.reload();
|
||||||
|
syncVxeGridColumns(gridApi, tableColumns);
|
||||||
|
|
||||||
|
function syncSelection() {
|
||||||
|
const vxeTable = gridApi.grid;
|
||||||
|
const rows = vxeTable?.getCheckboxRecords?.() ?? [];
|
||||||
|
hasSelected.value = rows.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSidebarSelect(payload: {
|
||||||
|
scope: WarehouseSidebarScope;
|
||||||
|
warehouse: WarehouseVO.Info | null;
|
||||||
|
}) {
|
||||||
|
scope.value = payload.scope;
|
||||||
|
selectedWarehouseId.value = payload.warehouse?.id;
|
||||||
|
selectedWarehouseName.value = payload.warehouse?.name;
|
||||||
|
hasSelected.value = false;
|
||||||
|
gridApi.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadAssignOptions() {
|
||||||
|
const list = await getEnabledWarehousesApi();
|
||||||
|
assignWarehouseOptions.value = (list ?? []).map((w) => ({
|
||||||
|
label: `${w.name}(${w.code})`,
|
||||||
|
value: w.id,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelectedSkuIds(): number[] {
|
||||||
|
const rows: ProductSkuVO.Info[] =
|
||||||
|
gridApi.grid?.getCheckboxRecords?.() ?? [];
|
||||||
|
return rows.map((r) => r.id).filter((id) => id != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openAssignSelected() {
|
||||||
|
const ids = getSelectedSkuIds();
|
||||||
|
if (!ids.length) {
|
||||||
|
message.warning('请先勾选 SKU');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assignTargetId.value =
|
||||||
|
scope.value === 'warehouse' ? selectedWarehouseId.value : undefined;
|
||||||
|
await loadAssignOptions();
|
||||||
|
assignOpen.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmAssign() {
|
||||||
|
const ids = getSelectedSkuIds();
|
||||||
|
if (!ids.length) {
|
||||||
|
message.warning('请先勾选 SKU');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (assignTargetId.value == null) {
|
||||||
|
message.warning('请选择目标发货仓');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
assignLoading.value = true;
|
||||||
|
try {
|
||||||
|
const res = await batchAssignWarehouseSkusApi({
|
||||||
|
skuIds: ids,
|
||||||
|
warehouseId: assignTargetId.value,
|
||||||
|
});
|
||||||
|
message.success(`已更新 ${res?.updated ?? ids.length} 个 SKU`);
|
||||||
|
assignOpen.value = false;
|
||||||
|
hasSelected.value = false;
|
||||||
|
gridApi.reload();
|
||||||
|
colPageRef.value?.refreshSidebar();
|
||||||
|
} finally {
|
||||||
|
assignLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function clearAssign() {
|
||||||
|
const ids = getSelectedSkuIds();
|
||||||
|
if (!ids.length) {
|
||||||
|
message.warning('请先勾选 SKU');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Modal.confirm({
|
||||||
|
title: '取消发货仓分配',
|
||||||
|
content: `确定将选中的 ${ids.length} 个 SKU 设为未分配?`,
|
||||||
|
okText: '确定',
|
||||||
|
cancelText: '取消',
|
||||||
|
async onOk() {
|
||||||
|
const res = await batchAssignWarehouseSkusApi({
|
||||||
|
skuIds: ids,
|
||||||
|
warehouseId: null,
|
||||||
|
});
|
||||||
|
message.success(`已取消 ${res?.updated ?? ids.length} 个分配`);
|
||||||
|
hasSelected.value = false;
|
||||||
|
gridApi.reload();
|
||||||
|
colPageRef.value?.refreshSidebar();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<EcWarehouseColPage
|
||||||
|
ref="colPageRef"
|
||||||
|
:scope="scope"
|
||||||
|
:selected-warehouse-id="selectedWarehouseId"
|
||||||
|
@select="onSidebarSelect"
|
||||||
|
>
|
||||||
|
<Card
|
||||||
|
class="flex h-full min-h-0 min-w-0 flex-1 flex-col"
|
||||||
|
:body-style="{
|
||||||
|
height: '100%',
|
||||||
|
minHeight: 0,
|
||||||
|
padding: 0,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<span class="text-base font-semibold">{{ titleText }}</span>
|
||||||
|
</template>
|
||||||
|
<template #extra>
|
||||||
|
<Space wrap size="small">
|
||||||
|
<PermissionGate code="ec:warehouse:update">
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
:disabled="!hasSelected"
|
||||||
|
@click="openAssignSelected"
|
||||||
|
>
|
||||||
|
<AssignIcon class="mr-1 h-4 w-4" />
|
||||||
|
批量分配到仓
|
||||||
|
</Button>
|
||||||
|
</PermissionGate>
|
||||||
|
<PermissionGate code="ec:warehouse:update">
|
||||||
|
<Button danger :disabled="!hasSelected" @click="clearAssign">
|
||||||
|
<ClearIcon class="mr-1 h-4 w-4" />
|
||||||
|
取消分配
|
||||||
|
</Button>
|
||||||
|
</PermissionGate>
|
||||||
|
</Space>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<div class="min-h-0 flex-1 overflow-hidden">
|
||||||
|
<Grid :loading="loading" />
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Modal
|
||||||
|
v-model:open="assignOpen"
|
||||||
|
title="批量分配发货仓"
|
||||||
|
:confirm-loading="assignLoading"
|
||||||
|
ok-text="确定分配"
|
||||||
|
destroy-on-close
|
||||||
|
@ok="confirmAssign"
|
||||||
|
>
|
||||||
|
<div class="space-y-3 py-2">
|
||||||
|
<div class="text-sm text-muted-foreground">
|
||||||
|
已选 {{ getSelectedSkuIds().length }} 个 SKU,将设置其默认发货仓。
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="mb-1 text-sm">目标发货仓</div>
|
||||||
|
<Select
|
||||||
|
v-model:value="assignTargetId"
|
||||||
|
class="w-full"
|
||||||
|
show-search
|
||||||
|
option-filter-prop="label"
|
||||||
|
placeholder="选择发货仓"
|
||||||
|
:options="assignWarehouseOptions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</EcWarehouseColPage>
|
||||||
|
</template>
|
||||||
@@ -1,16 +1,25 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 超管账户表单:公司 / 部门 / 职位走列表接口下拉,不必手填 ID。
|
||||||
|
*/
|
||||||
import type { CompanyVO } from '#/api/company/types';
|
import type { CompanyVO } from '#/api/company/types';
|
||||||
|
import type { DepartmentVO } from '#/api/org/department';
|
||||||
|
import type { PositionVO } from '#/api/org/position';
|
||||||
import type {
|
import type {
|
||||||
SuperAccountDTO,
|
SuperAccountDTO,
|
||||||
SuperAccountVO,
|
SuperAccountVO,
|
||||||
} from '#/api/sys/account';
|
} from '#/api/sys/account';
|
||||||
|
import type { PageQueryDTO } from '#/types/common';
|
||||||
|
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
import { Form, Input, message, Select } from 'ant-design-vue';
|
import { Cascader, Form, Input, message, Select } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { getCompanyPageApi } from '#/api/company';
|
||||||
|
import { getDepartmentTreeApi } from '#/api/org/department';
|
||||||
|
import { getPositionPageApi } from '#/api/org/position';
|
||||||
import {
|
import {
|
||||||
super_createAccountApi,
|
super_createAccountApi,
|
||||||
super_updateAccountApi,
|
super_updateAccountApi,
|
||||||
@@ -20,13 +29,25 @@ interface Emits {
|
|||||||
(e: 'success'): void;
|
(e: 'success'): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface DepartmentCascaderOption {
|
||||||
|
children?: DepartmentCascaderOption[];
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PositionSelectOption {
|
||||||
|
departmentId?: number;
|
||||||
|
label: string;
|
||||||
|
value: number;
|
||||||
|
}
|
||||||
|
|
||||||
defineOptions({ name: 'SysAccountFormModal' });
|
defineOptions({ name: 'SysAccountFormModal' });
|
||||||
|
|
||||||
const emit = defineEmits<Emits>();
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
draggable: true,
|
draggable: true,
|
||||||
class: 'w-[500px]',
|
class: 'w-[560px]',
|
||||||
onCancel() {
|
onCancel() {
|
||||||
handleCancel();
|
handleCancel();
|
||||||
},
|
},
|
||||||
@@ -39,7 +60,16 @@ const formRef = ref();
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const isEdit = ref(false);
|
const isEdit = ref(false);
|
||||||
const currentAccountData = ref<null | SuperAccountVO.AccountInfoVO>(null);
|
const currentAccountData = ref<null | SuperAccountVO.AccountInfoVO>(null);
|
||||||
const presetCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
|
||||||
|
const companyOptionsLoading = ref(false);
|
||||||
|
const departmentOptionsLoading = ref(false);
|
||||||
|
const positionOptionsLoading = ref(false);
|
||||||
|
const companyOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
|
const departmentTreeOptions = ref<DepartmentCascaderOption[]>([]);
|
||||||
|
const allPositionOptions = ref<PositionSelectOption[]>([]);
|
||||||
|
const departmentPath = ref<number[]>([]);
|
||||||
|
/** 已加载选项的公司,切换公司时重拉部门/职位 */
|
||||||
|
const loadedOrgCompanyId = ref<number | undefined>(undefined);
|
||||||
|
|
||||||
const formData = ref<
|
const formData = ref<
|
||||||
SuperAccountDTO.SuperCreateAccountDTO & { status?: number }
|
SuperAccountDTO.SuperCreateAccountDTO & { status?: number }
|
||||||
@@ -48,7 +78,7 @@ const formData = ref<
|
|||||||
password: '',
|
password: '',
|
||||||
realName: '',
|
realName: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
companyId: 0,
|
companyId: undefined as unknown as number,
|
||||||
departmentId: undefined,
|
departmentId: undefined,
|
||||||
positionId: undefined,
|
positionId: undefined,
|
||||||
isSuper: 0,
|
isSuper: 0,
|
||||||
@@ -64,13 +94,54 @@ const statusOptions = [
|
|||||||
{ label: '停用', value: 0 },
|
{ label: '停用', value: 0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const positionOptions = computed(() => {
|
||||||
|
const selectedDepartmentId = formData.value.departmentId;
|
||||||
|
if (!selectedDepartmentId) return allPositionOptions.value;
|
||||||
|
return allPositionOptions.value.filter(
|
||||||
|
(item) => !item.departmentId || item.departmentId === selectedDepartmentId,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
function buildDepartmentTreeOptions(
|
||||||
|
departments: DepartmentVO.DepartmentInfoVO[],
|
||||||
|
): DepartmentCascaderOption[] {
|
||||||
|
return departments.map((item) => ({
|
||||||
|
children:
|
||||||
|
item.children && item.children.length > 0
|
||||||
|
? buildDepartmentTreeOptions(item.children)
|
||||||
|
: undefined,
|
||||||
|
label: item.name,
|
||||||
|
value: item.id,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
function findDepartmentPathById(
|
||||||
|
options: DepartmentCascaderOption[],
|
||||||
|
departmentId: number,
|
||||||
|
currentPath: number[] = [],
|
||||||
|
): null | number[] {
|
||||||
|
for (const option of options) {
|
||||||
|
const nextPath = [...currentPath, option.value];
|
||||||
|
if (option.value === departmentId) return nextPath;
|
||||||
|
if (option.children?.length) {
|
||||||
|
const result = findDepartmentPathById(
|
||||||
|
option.children,
|
||||||
|
departmentId,
|
||||||
|
nextPath,
|
||||||
|
);
|
||||||
|
if (result) return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
realName: '',
|
realName: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
companyId: presetCompany.value?.id ?? 0,
|
companyId: undefined as unknown as number,
|
||||||
departmentId: undefined,
|
departmentId: undefined,
|
||||||
positionId: undefined,
|
positionId: undefined,
|
||||||
isSuper: 0,
|
isSuper: 0,
|
||||||
@@ -78,6 +149,7 @@ function resetForm() {
|
|||||||
remark: '',
|
remark: '',
|
||||||
status: 1,
|
status: 1,
|
||||||
};
|
};
|
||||||
|
departmentPath.value = [];
|
||||||
formRef.value?.resetFields();
|
formRef.value?.resetFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,15 +157,147 @@ function handleCancel() {
|
|||||||
modalApi.close();
|
modalApi.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function open(
|
async function loadCompanyOptions() {
|
||||||
|
try {
|
||||||
|
companyOptionsLoading.value = true;
|
||||||
|
const data = await getCompanyPageApi({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 500,
|
||||||
|
filters: {},
|
||||||
|
});
|
||||||
|
companyOptions.value = (data.records || []).map((item) => ({
|
||||||
|
label: item.status === 1 ? item.name : `${item.name}(禁用)`,
|
||||||
|
value: item.id,
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取公司列表失败:', error);
|
||||||
|
message.error('获取公司列表失败');
|
||||||
|
companyOptions.value = [];
|
||||||
|
} finally {
|
||||||
|
companyOptionsLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadDepartmentOptions(companyId: number) {
|
||||||
|
try {
|
||||||
|
departmentOptionsLoading.value = true;
|
||||||
|
const data = await getDepartmentTreeApi(companyId);
|
||||||
|
departmentTreeOptions.value = buildDepartmentTreeOptions(data || []);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取部门树失败:', error);
|
||||||
|
message.error('获取部门树失败');
|
||||||
|
departmentTreeOptions.value = [];
|
||||||
|
} finally {
|
||||||
|
departmentOptionsLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadPositionOptions(companyId: number) {
|
||||||
|
try {
|
||||||
|
positionOptionsLoading.value = true;
|
||||||
|
const params: PageQueryDTO = {
|
||||||
|
page: 1,
|
||||||
|
pageSize: 1000,
|
||||||
|
filters: { companyId, status: 1 },
|
||||||
|
};
|
||||||
|
const data = await getPositionPageApi(params);
|
||||||
|
allPositionOptions.value = (data.records || []).map(
|
||||||
|
(item: PositionVO.PositionInfoVO) => ({
|
||||||
|
departmentId: item.departmentId,
|
||||||
|
label: item.name,
|
||||||
|
value: item.id,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取职位列表失败:', error);
|
||||||
|
message.error('获取职位列表失败');
|
||||||
|
allPositionOptions.value = [];
|
||||||
|
} finally {
|
||||||
|
positionOptionsLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadOrgOptionsForCompany(
|
||||||
|
companyId: number,
|
||||||
|
options?: { clearSelection?: boolean },
|
||||||
|
) {
|
||||||
|
if (!companyId) {
|
||||||
|
departmentTreeOptions.value = [];
|
||||||
|
allPositionOptions.value = [];
|
||||||
|
loadedOrgCompanyId.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
loadedOrgCompanyId.value === companyId &&
|
||||||
|
!options?.clearSelection
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await Promise.all([
|
||||||
|
loadDepartmentOptions(companyId),
|
||||||
|
loadPositionOptions(companyId),
|
||||||
|
]);
|
||||||
|
loadedOrgCompanyId.value = companyId;
|
||||||
|
if (options?.clearSelection) {
|
||||||
|
formData.value.departmentId = undefined;
|
||||||
|
formData.value.positionId = undefined;
|
||||||
|
departmentPath.value = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncDepartmentPathByDepartmentId() {
|
||||||
|
if (!formData.value.departmentId) {
|
||||||
|
departmentPath.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const path = findDepartmentPathById(
|
||||||
|
departmentTreeOptions.value,
|
||||||
|
formData.value.departmentId,
|
||||||
|
);
|
||||||
|
departmentPath.value = path || [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDepartmentChange(value: number[]) {
|
||||||
|
departmentPath.value = value || [];
|
||||||
|
const selectedDepartmentId = departmentPath.value.at(-1);
|
||||||
|
const previousDepartmentId = formData.value.departmentId;
|
||||||
|
formData.value.departmentId = selectedDepartmentId;
|
||||||
|
|
||||||
|
if (
|
||||||
|
previousDepartmentId !== selectedDepartmentId &&
|
||||||
|
formData.value.positionId &&
|
||||||
|
!positionOptions.value.some(
|
||||||
|
(item) => item.value === formData.value.positionId,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
formData.value.positionId = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleCompanyChange(companyId: number | undefined) {
|
||||||
|
formData.value.companyId = companyId as number;
|
||||||
|
if (!companyId) {
|
||||||
|
departmentTreeOptions.value = [];
|
||||||
|
allPositionOptions.value = [];
|
||||||
|
formData.value.departmentId = undefined;
|
||||||
|
formData.value.positionId = undefined;
|
||||||
|
departmentPath.value = [];
|
||||||
|
loadedOrgCompanyId.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await loadOrgOptionsForCompany(companyId, { clearSelection: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
async function open(
|
||||||
accountData?: null | SuperAccountVO.AccountInfoVO,
|
accountData?: null | SuperAccountVO.AccountInfoVO,
|
||||||
company?: CompanyVO.CompanyInfoVO | null,
|
company?: CompanyVO.CompanyInfoVO | null,
|
||||||
) {
|
) {
|
||||||
isEdit.value = !!accountData;
|
isEdit.value = !!accountData;
|
||||||
currentAccountData.value = accountData || null;
|
currentAccountData.value = accountData || null;
|
||||||
presetCompany.value = company || null;
|
loadedOrgCompanyId.value = undefined;
|
||||||
|
|
||||||
resetForm();
|
resetForm();
|
||||||
|
await loadCompanyOptions();
|
||||||
|
|
||||||
if (accountData) {
|
if (accountData) {
|
||||||
formData.value = {
|
formData.value = {
|
||||||
@@ -101,7 +305,7 @@ function open(
|
|||||||
password: '',
|
password: '',
|
||||||
realName: accountData.realName,
|
realName: accountData.realName,
|
||||||
phone: accountData.phone || '',
|
phone: accountData.phone || '',
|
||||||
companyId: accountData.companyId || presetCompany.value?.id || 0,
|
companyId: accountData.companyId as number,
|
||||||
departmentId: accountData.departmentId,
|
departmentId: accountData.departmentId,
|
||||||
positionId: accountData.positionId,
|
positionId: accountData.positionId,
|
||||||
isSuper: accountData.isSuper ?? 0,
|
isSuper: accountData.isSuper ?? 0,
|
||||||
@@ -109,8 +313,13 @@ function open(
|
|||||||
remark: accountData.remark || '',
|
remark: accountData.remark || '',
|
||||||
status: accountData.status ?? 1,
|
status: accountData.status ?? 1,
|
||||||
};
|
};
|
||||||
} else if (presetCompany.value) {
|
} else if (company?.id) {
|
||||||
formData.value.companyId = presetCompany.value.id;
|
formData.value.companyId = company.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formData.value.companyId) {
|
||||||
|
await loadOrgOptionsForCompany(formData.value.companyId);
|
||||||
|
syncDepartmentPathByDepartmentId();
|
||||||
}
|
}
|
||||||
|
|
||||||
modalApi.open();
|
modalApi.open();
|
||||||
@@ -126,7 +335,9 @@ async function handleSubmit() {
|
|||||||
await super_updateAccountApi(currentAccountData.value.id, updateData);
|
await super_updateAccountApi(currentAccountData.value.id, updateData);
|
||||||
message.success('更新成功');
|
message.success('更新成功');
|
||||||
} else {
|
} else {
|
||||||
await super_createAccountApi(formData.value);
|
// CreateSysAccountDTO 无 status,创建时剔除
|
||||||
|
const { status: _status, ...createData } = formData.value;
|
||||||
|
await super_createAccountApi(createData);
|
||||||
message.success('创建成功');
|
message.success('创建成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,12 +357,26 @@ watch(
|
|||||||
() => modalApi.useStore()?.value?.isOpen,
|
() => modalApi.useStore()?.value?.isOpen,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
presetCompany.value = null;
|
loadedOrgCompanyId.value = undefined;
|
||||||
resetForm();
|
resetForm();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => formData.value.departmentId,
|
||||||
|
() => {
|
||||||
|
if (
|
||||||
|
formData.value.positionId &&
|
||||||
|
!positionOptions.value.some(
|
||||||
|
(item) => item.value === formData.value.positionId,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
formData.value.positionId = undefined;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
});
|
});
|
||||||
@@ -165,8 +390,22 @@ defineExpose({
|
|||||||
:label-col="{ span: 6 }"
|
:label-col="{ span: 6 }"
|
||||||
:wrapper-col="{ span: 18 }"
|
:wrapper-col="{ span: 18 }"
|
||||||
>
|
>
|
||||||
<Form.Item v-if="presetCompany" label="所属公司">
|
<Form.Item
|
||||||
<Input :value="presetCompany.name" disabled />
|
label="所属公司"
|
||||||
|
name="companyId"
|
||||||
|
:rules="[{ required: true, message: '请选择所属公司' }]"
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
:value="formData.companyId || undefined"
|
||||||
|
:loading="companyOptionsLoading"
|
||||||
|
:options="companyOptions"
|
||||||
|
show-search
|
||||||
|
option-filter-prop="label"
|
||||||
|
placeholder="请选择公司"
|
||||||
|
allow-clear
|
||||||
|
class="w-full"
|
||||||
|
@change="(v) => handleCompanyChange(v as number | undefined)"
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@@ -211,10 +450,6 @@ defineExpose({
|
|||||||
<Input v-model:value="formData.realName" placeholder="请输入真实姓名" />
|
<Input v-model:value="formData.realName" placeholder="请输入真实姓名" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item label="备注" name="remark">
|
|
||||||
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label="手机号"
|
label="手机号"
|
||||||
name="phone"
|
name="phone"
|
||||||
@@ -226,32 +461,36 @@ defineExpose({
|
|||||||
<Input v-model:value="formData.phone" placeholder="请输入手机号" />
|
<Input v-model:value="formData.phone" placeholder="请输入手机号" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item label="所属部门" name="departmentId">
|
||||||
v-if="!presetCompany"
|
<Cascader
|
||||||
label="公司ID"
|
:value="departmentPath"
|
||||||
name="companyId"
|
:options="departmentTreeOptions"
|
||||||
:rules="[{ required: true, message: '请输入公司ID' }]"
|
:loading="departmentOptionsLoading"
|
||||||
>
|
:disabled="!formData.companyId"
|
||||||
<Input
|
placeholder="请先选择公司"
|
||||||
v-model:value="formData.companyId"
|
:field-names="{
|
||||||
type="number"
|
label: 'label',
|
||||||
placeholder="请输入公司ID"
|
value: 'value',
|
||||||
|
children: 'children',
|
||||||
|
}"
|
||||||
|
change-on-select
|
||||||
|
allow-clear
|
||||||
|
class="w-full"
|
||||||
|
@change="(value) => handleDepartmentChange((value || []) as number[])"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item label="部门ID" name="departmentId">
|
<Form.Item label="职位" name="positionId">
|
||||||
<Input
|
<Select
|
||||||
v-model:value="formData.departmentId"
|
|
||||||
type="number"
|
|
||||||
placeholder="请输入部门ID"
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
<Form.Item label="职位ID" name="positionId">
|
|
||||||
<Input
|
|
||||||
v-model:value="formData.positionId"
|
v-model:value="formData.positionId"
|
||||||
type="number"
|
:loading="positionOptionsLoading"
|
||||||
placeholder="请输入职位ID"
|
:options="positionOptions"
|
||||||
|
:disabled="!formData.companyId || positionOptionsLoading"
|
||||||
|
placeholder="请先选择公司"
|
||||||
|
allow-clear
|
||||||
|
show-search
|
||||||
|
option-filter-prop="label"
|
||||||
|
class="w-full"
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
@@ -270,12 +509,8 @@ defineExpose({
|
|||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item label="头像图片ID" name="avatarImageId">
|
<Form.Item label="备注" name="remark">
|
||||||
<Input
|
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
||||||
v-model:value="formData.avatarImageId"
|
|
||||||
type="number"
|
|
||||||
placeholder="请输入头像图片ID"
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|
||||||
<Form.Item v-if="isEdit" label="状态" name="status">
|
<Form.Item v-if="isEdit" label="状态" name="status">
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
/**
|
||||||
|
* 系统账户:左栏筛公司,右栏用 Vxe 搜索表单 + toolbar 新增(对齐反馈页布局)。
|
||||||
|
*/
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type { CompanyVO } from '#/api/company/types';
|
import type { CompanyVO } from '#/api/company/types';
|
||||||
import type {
|
import type {
|
||||||
@@ -14,10 +17,8 @@ import { createIconifyIcon } from '@vben/icons';
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Card,
|
Card,
|
||||||
Input,
|
|
||||||
message,
|
message,
|
||||||
Popconfirm,
|
Popconfirm,
|
||||||
Select,
|
|
||||||
Space,
|
Space,
|
||||||
Tag,
|
Tag,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
@@ -46,13 +47,6 @@ const accountFormModalRef = ref();
|
|||||||
const selectedCompanyId = ref<number | undefined>(undefined);
|
const selectedCompanyId = ref<number | undefined>(undefined);
|
||||||
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
const currentCompany = ref<CompanyVO.CompanyInfoVO | null>(null);
|
||||||
|
|
||||||
const searchForm = ref({
|
|
||||||
username: undefined as string | undefined,
|
|
||||||
realName: undefined as string | undefined,
|
|
||||||
phone: undefined as string | undefined,
|
|
||||||
status: undefined as number | undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
const statusOptions = [
|
const statusOptions = [
|
||||||
{ label: '正常', value: 1 },
|
{ label: '正常', value: 1 },
|
||||||
{ label: '停用', value: 0 },
|
{ label: '停用', value: 0 },
|
||||||
@@ -146,6 +140,52 @@ const accountTableColumns = computed(() =>
|
|||||||
: (accountTableBaseColumns ?? []),
|
: (accountTableBaseColumns ?? []),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const formOptions = computed(() => ({
|
||||||
|
schema: [
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '登录用户名',
|
||||||
|
},
|
||||||
|
fieldName: 'username',
|
||||||
|
label: '用户名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '真实姓名',
|
||||||
|
},
|
||||||
|
fieldName: 'realName',
|
||||||
|
label: '姓名',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '手机号',
|
||||||
|
},
|
||||||
|
fieldName: 'phone',
|
||||||
|
label: '手机号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '全部',
|
||||||
|
options: statusOptions,
|
||||||
|
},
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '状态',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
showDefaultActions: true,
|
||||||
|
collapsed: true,
|
||||||
|
collapsedRows: 1,
|
||||||
|
submitOnChange: true,
|
||||||
|
}));
|
||||||
|
|
||||||
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||||
columns: accountTableColumns.value,
|
columns: accountTableColumns.value,
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -185,17 +225,17 @@ const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
|||||||
},
|
},
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
query: async ({ page }) => {
|
query: async ({ page }, formValues: Record<string, any> = {}) => {
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const params: PageQueryDTO<SuperAccountDTO.AccountFilterDTO> = {
|
const params: PageQueryDTO<SuperAccountDTO.AccountFilterDTO> = {
|
||||||
page: page.currentPage,
|
page: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
filters: {
|
filters: {
|
||||||
username: searchForm.value.username || undefined,
|
username: formValues.username?.trim() || undefined,
|
||||||
realName: searchForm.value.realName || undefined,
|
realName: formValues.realName?.trim() || undefined,
|
||||||
phone: searchForm.value.phone || undefined,
|
phone: formValues.phone?.trim() || undefined,
|
||||||
status: searchForm.value.status,
|
status: formValues.status,
|
||||||
companyId: currentCompany.value?.id,
|
companyId: currentCompany.value?.id,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -219,7 +259,8 @@ const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
|||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions,
|
gridOptions,
|
||||||
showSearchForm: false,
|
formOptions: formOptions.value,
|
||||||
|
showSearchForm: true,
|
||||||
tableTitle: '账户列表',
|
tableTitle: '账户列表',
|
||||||
});
|
});
|
||||||
syncVxeGridColumns(gridApi, accountTableColumns);
|
syncVxeGridColumns(gridApi, accountTableColumns);
|
||||||
@@ -233,11 +274,8 @@ function refreshTable() {
|
|||||||
gridApi?.reload();
|
gridApi?.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 新增:不必先选左栏公司,表单内自选;左栏有选中时作默认值 */
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
if (!currentCompany.value) {
|
|
||||||
message.warning('请先选择具体公司,或在公司行点击「添加」');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
accountFormModalRef.value?.open(undefined, currentCompany.value);
|
accountFormModalRef.value?.open(undefined, currentCompany.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,71 +348,32 @@ watch(currentCompany, () => {
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<template #title>
|
<template #title>
|
||||||
<span class="text-base font-semibold">账户列表</span>
|
<div class="flex min-w-0 items-center gap-2">
|
||||||
</template>
|
<span class="text-base font-semibold">账户列表</span>
|
||||||
<template #extra>
|
<span class="text-muted-foreground truncate text-xs font-normal">
|
||||||
<Space wrap size="small" class="max-w-[min(100%,48rem)]">
|
当前:{{ selectedCompanyLabel }}
|
||||||
<Input
|
</span>
|
||||||
v-model:value="searchForm.username"
|
|
||||||
allow-clear
|
|
||||||
placeholder="登录用户名"
|
|
||||||
class="w-[120px]"
|
|
||||||
@press-enter="refreshTable"
|
|
||||||
/>
|
|
||||||
<Input
|
|
||||||
v-model:value="searchForm.realName"
|
|
||||||
allow-clear
|
|
||||||
placeholder="姓名"
|
|
||||||
class="w-[100px]"
|
|
||||||
@press-enter="refreshTable"
|
|
||||||
/>
|
|
||||||
<Input
|
|
||||||
v-model:value="searchForm.phone"
|
|
||||||
allow-clear
|
|
||||||
placeholder="手机号"
|
|
||||||
class="w-[120px]"
|
|
||||||
@press-enter="refreshTable"
|
|
||||||
/>
|
|
||||||
<Select
|
|
||||||
v-model:value="searchForm.status"
|
|
||||||
allow-clear
|
|
||||||
placeholder="状态"
|
|
||||||
class="min-w-[88px]"
|
|
||||||
:options="statusOptions"
|
|
||||||
@change="refreshTable"
|
|
||||||
/>
|
|
||||||
<Button size="small" @click="refreshTable">查询</Button>
|
|
||||||
<PermissionGate code="sys:account:create">
|
|
||||||
<Button type="primary" size="small" @click="handleAdd">
|
|
||||||
<PlusIcon class="mr-1 h-4 w-4" />
|
|
||||||
新增账户
|
|
||||||
</Button>
|
|
||||||
</PermissionGate>
|
|
||||||
</Space>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="text-muted-foreground shrink-0 border-t border-border px-4 py-2 text-xs"
|
|
||||||
>
|
|
||||||
当前:{{ selectedCompanyLabel }}
|
|
||||||
<template v-if="currentCompany">
|
|
||||||
<Tag
|
<Tag
|
||||||
class="ml-2"
|
v-if="currentCompany"
|
||||||
|
class="m-0"
|
||||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
||||||
>
|
>
|
||||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||||
</Tag>
|
</Tag>
|
||||||
</template>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-0 sm:px-3 sm:pb-3"
|
class="min-h-0 flex-1 overflow-hidden px-2 pb-2 pt-0 sm:px-3 sm:pb-3"
|
||||||
>
|
>
|
||||||
<Grid :loading="loading" class="h-full min-h-0">
|
<Grid :loading="loading" class="h-full min-h-0">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<span class="text-muted-foreground text-xs">
|
<PermissionGate code="sys:account:create">
|
||||||
左侧筛选公司;表格在区域内滚动
|
<Button type="primary" @click="handleAdd">
|
||||||
</span>
|
<PlusIcon class="mr-1 h-4 w-4" />
|
||||||
|
新增账户
|
||||||
|
</Button>
|
||||||
|
</PermissionGate>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #status="{ row }">
|
<template #status="{ row }">
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "ecom-dmb",
|
||||||
|
"private": true,
|
||||||
|
"description": "根目录仅作开发启动入口,不是 pnpm monorepo;各 app 仍各自装依赖",
|
||||||
|
"packageManager": "pnpm@11.21.0",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "concurrently -k -n web,server,agent -c cyan,green,magenta \"pnpm dev:web\" \"pnpm dev:server\" \"pnpm dev:agent\"",
|
||||||
|
"dev:web-server": "concurrently -k -n web,server -c cyan,green \"pnpm dev:web\" \"pnpm dev:server\"",
|
||||||
|
"dev:web": "pnpm -C apps/web dev",
|
||||||
|
"dev:server": "cd apps/server && ./mvnw spring-boot:run",
|
||||||
|
"dev:agent": "sh -c 'cd apps/agent && test -x .venv/bin/uvicorn || { echo \"[dev:agent] 缺少 .venv,请先: cd apps/agent && python -m venv .venv && .venv/bin/pip install -r requirements.txt\"; exit 1; }; exec .venv/bin/uvicorn api.main:app --reload --host 0.0.0.0 --port 8200'",
|
||||||
|
"deploy:tui": "pnpm -C deploy dev"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"concurrently": "^9.2.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+206
@@ -0,0 +1,206 @@
|
|||||||
|
lockfileVersion: '9.0'
|
||||||
|
|
||||||
|
settings:
|
||||||
|
autoInstallPeers: true
|
||||||
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
|
importers:
|
||||||
|
|
||||||
|
.:
|
||||||
|
devDependencies:
|
||||||
|
concurrently:
|
||||||
|
specifier: ^9.2.1
|
||||||
|
version: 9.2.5
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
ansi-regex@5.0.1:
|
||||||
|
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
ansi-styles@4.3.0:
|
||||||
|
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
chalk@4.1.2:
|
||||||
|
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
|
cliui@8.0.1:
|
||||||
|
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
|
color-convert@2.0.1:
|
||||||
|
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||||
|
engines: {node: '>=7.0.0'}
|
||||||
|
|
||||||
|
color-name@1.1.4:
|
||||||
|
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||||
|
|
||||||
|
concurrently@9.2.5:
|
||||||
|
resolution: {integrity: sha512-YMZlvWrTPQEhjKp60XSmMGt60+pffbv6DyRnOMvVO98+J7aF8w8Ui9FhdcOwvSixc/kyR6SoVvmejcn/2lZBqg==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
|
emoji-regex@8.0.0:
|
||||||
|
resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}
|
||||||
|
|
||||||
|
escalade@3.2.0:
|
||||||
|
resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}
|
||||||
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
|
get-caller-file@2.0.5:
|
||||||
|
resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==}
|
||||||
|
engines: {node: 6.* || 8.* || >= 10.*}
|
||||||
|
|
||||||
|
has-flag@4.0.0:
|
||||||
|
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
is-fullwidth-code-point@3.0.0:
|
||||||
|
resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
require-directory@2.1.1:
|
||||||
|
resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==}
|
||||||
|
engines: {node: '>=0.10.0'}
|
||||||
|
|
||||||
|
rxjs@7.8.2:
|
||||||
|
resolution: {integrity: sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==}
|
||||||
|
|
||||||
|
shell-quote@1.12.0:
|
||||||
|
resolution: {integrity: sha512-PcByqNyT/38F2kDNi006HAMRJaULuBzq/FOsw3qdZvX/GA9W/jamDaRskgHjubHiftXK5sIFxLNkvrXUwcof6Q==}
|
||||||
|
engines: {node: '>= 0.4'}
|
||||||
|
|
||||||
|
string-width@4.2.3:
|
||||||
|
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
strip-ansi@6.0.1:
|
||||||
|
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
supports-color@7.2.0:
|
||||||
|
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
|
||||||
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
|
supports-color@8.1.1:
|
||||||
|
resolution: {integrity: sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
|
tree-kill@1.2.2:
|
||||||
|
resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==}
|
||||||
|
hasBin: true
|
||||||
|
|
||||||
|
tslib@2.8.1:
|
||||||
|
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
|
||||||
|
|
||||||
|
wrap-ansi@7.0.0:
|
||||||
|
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
|
y18n@5.0.8:
|
||||||
|
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
|
||||||
|
yargs-parser@21.1.1:
|
||||||
|
resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
|
yargs@17.7.2:
|
||||||
|
resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
|
||||||
|
snapshots:
|
||||||
|
|
||||||
|
ansi-regex@5.0.1: {}
|
||||||
|
|
||||||
|
ansi-styles@4.3.0:
|
||||||
|
dependencies:
|
||||||
|
color-convert: 2.0.1
|
||||||
|
|
||||||
|
chalk@4.1.2:
|
||||||
|
dependencies:
|
||||||
|
ansi-styles: 4.3.0
|
||||||
|
supports-color: 7.2.0
|
||||||
|
|
||||||
|
cliui@8.0.1:
|
||||||
|
dependencies:
|
||||||
|
string-width: 4.2.3
|
||||||
|
strip-ansi: 6.0.1
|
||||||
|
wrap-ansi: 7.0.0
|
||||||
|
|
||||||
|
color-convert@2.0.1:
|
||||||
|
dependencies:
|
||||||
|
color-name: 1.1.4
|
||||||
|
|
||||||
|
color-name@1.1.4: {}
|
||||||
|
|
||||||
|
concurrently@9.2.5:
|
||||||
|
dependencies:
|
||||||
|
chalk: 4.1.2
|
||||||
|
rxjs: 7.8.2
|
||||||
|
shell-quote: 1.12.0
|
||||||
|
supports-color: 8.1.1
|
||||||
|
tree-kill: 1.2.2
|
||||||
|
yargs: 17.7.2
|
||||||
|
|
||||||
|
emoji-regex@8.0.0: {}
|
||||||
|
|
||||||
|
escalade@3.2.0: {}
|
||||||
|
|
||||||
|
get-caller-file@2.0.5: {}
|
||||||
|
|
||||||
|
has-flag@4.0.0: {}
|
||||||
|
|
||||||
|
is-fullwidth-code-point@3.0.0: {}
|
||||||
|
|
||||||
|
require-directory@2.1.1: {}
|
||||||
|
|
||||||
|
rxjs@7.8.2:
|
||||||
|
dependencies:
|
||||||
|
tslib: 2.8.1
|
||||||
|
|
||||||
|
shell-quote@1.12.0: {}
|
||||||
|
|
||||||
|
string-width@4.2.3:
|
||||||
|
dependencies:
|
||||||
|
emoji-regex: 8.0.0
|
||||||
|
is-fullwidth-code-point: 3.0.0
|
||||||
|
strip-ansi: 6.0.1
|
||||||
|
|
||||||
|
strip-ansi@6.0.1:
|
||||||
|
dependencies:
|
||||||
|
ansi-regex: 5.0.1
|
||||||
|
|
||||||
|
supports-color@7.2.0:
|
||||||
|
dependencies:
|
||||||
|
has-flag: 4.0.0
|
||||||
|
|
||||||
|
supports-color@8.1.1:
|
||||||
|
dependencies:
|
||||||
|
has-flag: 4.0.0
|
||||||
|
|
||||||
|
tree-kill@1.2.2: {}
|
||||||
|
|
||||||
|
tslib@2.8.1: {}
|
||||||
|
|
||||||
|
wrap-ansi@7.0.0:
|
||||||
|
dependencies:
|
||||||
|
ansi-styles: 4.3.0
|
||||||
|
string-width: 4.2.3
|
||||||
|
strip-ansi: 6.0.1
|
||||||
|
|
||||||
|
y18n@5.0.8: {}
|
||||||
|
|
||||||
|
yargs-parser@21.1.1: {}
|
||||||
|
|
||||||
|
yargs@17.7.2:
|
||||||
|
dependencies:
|
||||||
|
cliui: 8.0.1
|
||||||
|
escalade: 3.2.0
|
||||||
|
get-caller-file: 2.0.5
|
||||||
|
require-directory: 2.1.1
|
||||||
|
string-width: 4.2.3
|
||||||
|
y18n: 5.0.8
|
||||||
|
yargs-parser: 21.1.1
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# 仅把本仓库根当作独立 workspace,阻断向上解析到 ~/.
|
||||||
|
# 不把 apps/* 纳入;web/server/agent 仍各自装依赖。
|
||||||
|
packages: []
|
||||||
Reference in New Issue
Block a user