Compare commits

7 Commits
25 changed files with 853 additions and 309 deletions
+7 -16
View File
@@ -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)
+5 -7
View File
@@ -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,
+29 -11
View File
@@ -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
@@ -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")
@@ -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());
} }
@@ -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);
@@ -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());
@@ -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);
} }
} }
@@ -22,4 +22,9 @@ public class DepartmentFilterDTO {
* 状态 * 状态
*/ */
private Integer status; private Integer status;
/**
* 公司ID(仅超管可跨公司查询)
*/
private Long companyId;
} }
@@ -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);
/** /**
* 为指定公司创建部门(用于初始化) * 为指定公司创建部门(用于初始化)
* *
@@ -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<>();
} }
@@ -17,4 +17,9 @@ public class PositionFilterDTO {
* 状态 * 状态
*/ */
private Integer status; private Integer status;
/**
* 公司ID(仅超管可跨公司查询)
*/
private Long companyId;
} }
@@ -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;
} }
/** /**
@@ -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 = "用户姓名不能为空")
@@ -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 } },
); );
} }
@@ -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;
} }
} }
@@ -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;
} }
@@ -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('加载报价详情失败');
@@ -1,11 +1,16 @@
<script lang="ts" setup> <script lang="ts" setup>
/** /**
* 分区×重量带编辑:动态嵌套用 antd Card/Table;左侧 Anchor 快速跳转分区。 * 分区×重量带编辑:左侧分区导航(可选进入拖拽排序)+ 右侧分区卡片。
* 排序落库用数组下标 → sortOrder(表字段已有)。
*/ */
import { computed, nextTick, ref } from 'vue'; import type { Sortable } from '@vben/hooks';
import { computed, nextTick, onBeforeUnmount, ref } from 'vue';
import { useSortable } from '@vben/hooks';
import { createIconifyIcon } from '@vben/icons';
import { import {
Anchor,
Button, Button,
Card, Card,
Input, Input,
@@ -17,23 +22,10 @@ import {
message, message,
} from 'ant-design-vue'; } from 'ant-design-vue';
export interface BandRow { import { createRegionUid, type BandRow, type RegionRow } from './region-band';
weightFromG: number;
weightToG: number | null;
priceMode: string;
flatAmount: number;
firstWeightG: number;
firstAmount: number;
continuePerKg: number;
}
export interface RegionRow { /** 分区导航拖拽手柄 */
regionName: string; const GripVerticalIcon = createIconifyIcon('lucide:grip-vertical');
zoneLabel: string;
provinces: string[];
isDefault: boolean;
bands: BandRow[];
}
const props = defineProps<{ const props = defineProps<{
modelValue: RegionRow[]; modelValue: RegionRow[];
@@ -47,24 +39,24 @@ const emit = defineEmits<{
defineOptions({ name: 'RegionBandEditor' }); defineOptions({ name: 'RegionBandEditor' });
const scrollRef = ref<HTMLElement | null>(null); 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({ const regions = computed({
get: () => props.modelValue, get: () => props.modelValue,
set: (v) => emit('update:modelValue', v), set: (v) => emit('update:modelValue', v),
}); });
const anchorItems = computed(() => /** 导航列表数据源:排序中用草稿,否则用正式数据 */
regions.value.map((r, i) => ({ const navRegions = computed(() =>
key: `region-${i}`, sorting.value ? draftRegions.value : regions.value,
href: `#quote-region-${i}`,
title: r.zoneLabel || r.regionName || `分区${i + 1}`,
})),
); );
function getScrollContainer() {
return scrollRef.value || window;
}
const bandColumnDefs = [ const bandColumnDefs = [
{ title: '从(克)', key: 'from', width: 110 }, { title: '从(克)', key: 'from', width: 110 },
{ title: '到(克)', key: 'to', width: 110 }, { title: '到(克)', key: 'to', width: 110 },
@@ -85,11 +77,87 @@ function emptyBand(fromG = 0): BandRow {
}; };
} }
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() { function addRegion() {
if (sorting.value) return;
const uid = createRegionUid();
const nextIndex = regions.value.length; const nextIndex = regions.value.length;
regions.value = [ regions.value = [
...regions.value, ...regions.value,
{ {
uid,
regionName: `分区${nextIndex + 1}`, regionName: `分区${nextIndex + 1}`,
zoneLabel: '', zoneLabel: '',
provinces: [], provinces: [],
@@ -97,14 +165,11 @@ function addRegion() {
bands: [emptyBand(0)], bands: [emptyBand(0)],
}, },
]; ];
void nextTick(() => { void nextTick(() => scrollToRegion(uid));
document
.getElementById(`quote-region-${nextIndex}`)
?.scrollIntoView({ behavior: 'smooth', block: 'start' });
});
} }
function removeRegion(idx: number) { function removeRegion(idx: number) {
if (sorting.value) return;
if (regions.value.length <= 1) { if (regions.value.length <= 1) {
message.warning('至少保留一个分区'); message.warning('至少保留一个分区');
return; return;
@@ -149,17 +214,13 @@ function patchBand(ri: number, bi: number, patch: Partial<BandRow>) {
const bands = region.bands.map((b, i) => (i === bi ? { ...b, ...patch } : b)); const bands = region.bands.map((b, i) => (i === bi ? { ...b, ...patch } : b));
patchRegion(ri, { bands }); patchRegion(ri, { bands });
} }
function onAnchorClick(e: Event) {
e.preventDefault();
}
</script> </script>
<template> <template>
<Card <Card
size="small" size="small"
title="目的分区 × 重量带" title="目的分区 × 重量带"
class="flex h-full min-h-0 flex-col overflow-hidden" class="eq-panel-card flex h-full min-h-0 flex-col overflow-hidden"
:body-style="{ :body-style="{
flex: '1 1 0%', flex: '1 1 0%',
minHeight: 0, minHeight: 0,
@@ -170,31 +231,93 @@ function onAnchorClick(e: Event) {
}" }"
> >
<template #extra> <template #extra>
<Button size="small" type="dashed" @click="addRegion">添加分区</Button> <Button
</template> size="small"
<div class="flex min-h-0 flex-1 gap-3"> type="dashed"
<aside :disabled="sorting"
class="w-36 shrink-0 overflow-y-auto border-r border-border pr-2 pt-1" @click="addRegion"
> >
<div class="mb-2 text-xs text-muted-foreground">分区导航</div> 添加分区
<Anchor </Button>
:affix="false" </template>
:items="anchorItems" <div class="flex min-h-0 flex-1 gap-3 overflow-hidden">
:get-container="getScrollContainer" <aside
@click="onAnchorClick" 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> </aside>
<div ref="scrollRef" class="min-h-0 min-w-0 flex-1 overflow-y-auto"> <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 <Card
v-for="(region, ri) in regions" v-for="(region, ri) in regions"
:id="`quote-region-${ri}`" :id="`quote-region-${region.uid}`"
:key="ri" :key="region.uid"
size="small" size="small"
class="mb-3 shrink-0 scroll-mt-2" class="shrink-0 scroll-mt-2"
:title="region.regionName || `分区${ri + 1}`" :title="region.regionName || `分区${ri + 1}`"
> >
<template #extra> <template #extra>
<Button type="link" danger size="small" @click="removeRegion(ri)"> <Button
type="link"
danger
size="small"
:disabled="sorting"
@click="removeRegion(ri)"
>
删除分区 删除分区
</Button> </Button>
</template> </template>
@@ -250,7 +373,7 @@ function onAnchorClick(e: Event) {
:pagination="false" :pagination="false"
:columns="bandColumnDefs" :columns="bandColumnDefs"
:data-source="region.bands" :data-source="region.bands"
:row-key="(_r: BandRow, i: number) => `${ri}-${i}`" :row-key="(_r: BandRow, i?: number) => `${region.uid}-${i ?? 0}`"
> >
<template #bodyCell="{ column, index }"> <template #bodyCell="{ column, index }">
<template v-if="column.key === 'from'"> <template v-if="column.key === 'from'">
@@ -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)}`;
}
@@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ExpressQuoteDTO, ExpressQuoteVO } from '#/api/ec/express-quote'; import type { ExpressQuoteDTO, ExpressQuoteVO } from '#/api/ec/express-quote';
import { computed, onMounted, ref, watch } from 'vue'; import { computed, nextTick, onMounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { ColPage } from '@vben/common-ui'; import { ColPage } from '@vben/common-ui';
@@ -20,9 +20,8 @@ import {
} from '#/api/ec/express-quote'; } from '#/api/ec/express-quote';
import { formatOverviewTabTitle } from '#/utils/overview-tab-title'; import { formatOverviewTabTitle } from '#/utils/overview-tab-title';
import RegionBandEditor, { import RegionBandEditor from './components/RegionBandEditor.vue';
type RegionRow, import { createRegionUid, type RegionRow } from './components/region-band';
} from './components/RegionBandEditor.vue';
defineOptions({ name: 'ExpressQuoteEdit' }); defineOptions({ name: 'ExpressQuoteEdit' });
@@ -43,6 +42,7 @@ const pageTitle = ref('快递报价单编辑「新建」');
const provinces = ref<ExpressQuoteVO.ProvinceOption[]>([]); const provinces = ref<ExpressQuoteVO.ProvinceOption[]>([]);
const regions = ref<RegionRow[]>([ const regions = ref<RegionRow[]>([
{ {
uid: createRegionUid(),
regionName: '默认区', regionName: '默认区',
zoneLabel: '', zoneLabel: '',
provinces: [], provinces: [],
@@ -246,6 +246,8 @@ const [BaseForm, formApi] = useVbenForm({
fieldName: 'useVolumetric', fieldName: 'useVolumetric',
label: '启用体积重', label: '启用体积重',
defaultValue: false, defaultValue: false,
// 覆盖 commonConfig 的 w-full,避免开关被拉成整栏宽
componentProps: { class: 'w-auto' },
}, },
{ {
component: 'InputNumber', component: 'InputNumber',
@@ -278,6 +280,7 @@ function fillRegionsFromVersion(v?: ExpressQuoteVO.Version) {
if (!v?.regions?.length) { if (!v?.regions?.length) {
regions.value = [ regions.value = [
{ {
uid: createRegionUid(),
regionName: '默认区', regionName: '默认区',
zoneLabel: '', zoneLabel: '',
provinces: [], provinces: [],
@@ -297,7 +300,11 @@ function fillRegionsFromVersion(v?: ExpressQuoteVO.Version) {
]; ];
return; return;
} }
regions.value = v.regions.map((r) => ({ const sorted = [...v.regions].sort(
(a, b) => (a.sortOrder ?? 0) - (b.sortOrder ?? 0),
);
regions.value = sorted.map((r) => ({
uid: createRegionUid(),
regionName: r.regionName, regionName: r.regionName,
zoneLabel: r.zoneLabel || '', zoneLabel: r.zoneLabel || '',
provinces: r.provinces ? [...r.provinces] : [], provinces: r.provinces ? [...r.provinces] : [],
@@ -329,11 +336,21 @@ function fillRegionsFromVersion(v?: ExpressQuoteVO.Version) {
async function loadDetail() { async function loadDetail() {
loading.value = true; loading.value = true;
let tabTitle: string | undefined;
try { try {
if (!provinces.value.length) { // 省份与详情并行,避免串行拉长转圈
provinces.value = await getExpressProvincesApi(); 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 (!quoteId.value) {
if (!detail) {
await formApi.resetForm(); await formApi.resetForm();
await formApi.setValues({ await formApi.setValues({
carrierCode: 'ZTO', carrierCode: 'ZTO',
@@ -347,13 +364,16 @@ async function loadDetail() {
weightRound: 'NONE', weightRound: 'NONE',
}); });
billingMode.value = 'FLAT'; billingMode.value = 'FLAT';
syncLeftWidthByMode();
fillRegionsFromVersion(); fillRegionsFromVersion();
await syncTabTitle('新建'); tabTitle = '新建';
return; return;
} }
const detail = await getExpressQuoteDetailApi(quoteId.value);
billingMode.value = detail.billingMode;
const v = detail.currentVersion; const v = detail.currentVersion;
billingMode.value = detail.billingMode;
syncLeftWidthByMode();
// 先回填表单并结束 loading,再挂大块分区(避免接口已返回仍长时间转圈)
await formApi.setValues({ await formApi.setValues({
code: detail.code, code: detail.code,
name: detail.name, name: detail.name,
@@ -370,15 +390,19 @@ async function loadDetail() {
useVolumetric: v?.useVolumetric === 1, useVolumetric: v?.useVolumetric === 1,
weightRound: v?.weightRound || 'NONE', weightRound: v?.weightRound || 'NONE',
}); });
loading.value = false;
await nextTick();
fillRegionsFromVersion(v); fillRegionsFromVersion(v);
await syncTabTitle(detail.name); tabTitle = detail.name;
} catch (error) { } catch (error) {
console.error(error); console.error(error);
message.error('加载报价单失败'); message.error('加载报价单失败');
} finally { } finally {
syncLeftWidthByMode();
loading.value = false; loading.value = false;
} }
if (tabTitle != null) {
void syncTabTitle(tabTitle);
}
} }
function buildVersion( function buildVersion(
@@ -501,13 +525,13 @@ watch(
<Card <Card
size="small" size="small"
title="基本信息" title="基本信息"
class="flex h-full min-h-0 flex-col overflow-hidden" class="eq-panel-card flex h-full min-h-0 flex-col overflow-hidden"
:body-style="cardBodyScrollStyle" :body-style="cardBodyScrollStyle"
> >
<BaseForm /> <BaseForm />
</Card> </Card>
</template> </template>
<div class="h-full min-h-0 min-w-0"> <div class="h-full min-h-0 min-w-0 overflow-hidden">
<RegionBandEditor <RegionBandEditor
v-if="isRegion" v-if="isRegion"
v-model="regions" v-model="regions"
@@ -517,7 +541,7 @@ watch(
v-else v-else
size="small" size="small"
title="分区报价" title="分区报价"
class="flex h-full min-h-0 flex-col overflow-hidden" class="eq-panel-card flex h-full min-h-0 flex-col overflow-hidden"
:body-style="cardBodyScrollStyle" :body-style="cardBodyScrollStyle"
> >
<Empty <Empty
@@ -548,10 +572,11 @@ watch(
min-height: 0; min-height: 0;
flex: 1 1 0%; flex: 1 1 0%;
} }
.express-quote-edit-page :deep(.ant-card) { /* 只约束列级面板卡;勿套到右栏内部分区卡,否则 max-height:100% 会裁切并透出半截内容 */
.express-quote-edit-page :deep(.eq-panel-card.ant-card) {
max-height: 100%; max-height: 100%;
} }
.express-quote-edit-page :deep(.ant-card-head) { .express-quote-edit-page :deep(.eq-panel-card > .ant-card-head) {
flex-shrink: 0; flex-shrink: 0;
} }
</style> </style>
@@ -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 }">