mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
Compare commits
7
Commits
e47f76c22a
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e183ed7a6 | ||
|
|
2f60efb8ef | ||
|
|
fb05b47d46 | ||
|
|
abe75f87aa | ||
|
|
7781f53d8a | ||
|
|
5427b3830c | ||
|
|
f382ba9bd7 |
@@ -17,35 +17,26 @@ async def load_tools_for_turn(
|
||||
scene: str = SCENE_GENERAL,
|
||||
client_tools: list[Any] | None = None,
|
||||
) -> list[Any]:
|
||||
"""general:builtin + memory + 全部 MCP;发布场景:builtin + 目录/拼多多 MCP + 前端 ui_ 工具。"""
|
||||
"""各场景均挂 memory_*;general 全量 MCP,发布场景仅目录/拼多多 + 前端 ui_。"""
|
||||
from agent.tools.builtin import builtin_tools
|
||||
from agent.tools.memory import memory_tools
|
||||
from infrastructure.mcp.client import load_mcp_tools
|
||||
|
||||
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:
|
||||
mcp_tools = await load_mcp_tools(
|
||||
settings,
|
||||
company_id=actor.company_id,
|
||||
user_id=actor.user_id,
|
||||
)
|
||||
# 发布场景:目录 + 拼多多渠道;不挂经营 BI
|
||||
mcp_tools = [
|
||||
t
|
||||
for t in mcp_tools
|
||||
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)
|
||||
if client_tools:
|
||||
tools.extend(client_tools)
|
||||
|
||||
@@ -87,13 +87,11 @@ class ChatService:
|
||||
session.llm_response_chain = None
|
||||
await self._session_repo.update(session)
|
||||
|
||||
just_saved = None
|
||||
memory_count = 0
|
||||
if scene == "general":
|
||||
just_saved = await self._memory.maybe_capture_from_user(
|
||||
actor, thread_id=thread_id, text=text
|
||||
)
|
||||
memory_count = await self._memory.count_active(actor)
|
||||
# 各 scene 均可按需 memory_*;显式「记住」也会 maybe_capture
|
||||
just_saved = await self._memory.maybe_capture_from_user(
|
||||
actor, thread_id=thread_id, text=text
|
||||
)
|
||||
memory_count = await self._memory.count_active(actor)
|
||||
|
||||
system_prompt = build_system_prompt(
|
||||
memory_count=memory_count,
|
||||
|
||||
@@ -57,9 +57,28 @@ _PUBLISH_SYSTEM = (
|
||||
"不要复述工具名、回执原文、字数统计、查了几条、竞品标题全文或改写策略,除非用户问为什么这样改。"
|
||||
"不要主动列 SKU 编码表,不要给没问过的下一版备选,不要让用户刷新、核对,或说「如果还是旧的再告诉我」。"
|
||||
"禁止向用户索要或复述数字 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(
|
||||
*,
|
||||
memory_count: int = 0,
|
||||
@@ -73,16 +92,15 @@ def build_system_prompt(
|
||||
# 控制体积,避免拖垮上下文
|
||||
if len(snap_text) > 12000:
|
||||
snap_text = snap_text[:12000] + "…(截断)"
|
||||
return (
|
||||
f"{_PUBLISH_SYSTEM}\n\n【当前发布表单】\n{snap_text}"
|
||||
system = 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
|
||||
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
|
||||
return _append_memory_status(
|
||||
_BASE_SYSTEM,
|
||||
memory_count=memory_count,
|
||||
memory_just_saved=memory_just_saved,
|
||||
)
|
||||
|
||||
+4
-2
@@ -74,8 +74,10 @@ public class ExpressQuoteController {
|
||||
|
||||
@GetMapping("/detail/{id}")
|
||||
@RequirePermission(value = "ec:express-quote:read", description = "报价详情", allowSuper = true)
|
||||
public ApiResponse<ExpressQuoteVO> detail(@PathVariable Long id) {
|
||||
return ApiResponse.success("获取成功", expressQuoteService.detail(id));
|
||||
public ApiResponse<ExpressQuoteVO> detail(
|
||||
@PathVariable Long id,
|
||||
@RequestParam(value = "withHistory", defaultValue = "false") boolean withHistory) {
|
||||
return ApiResponse.success("获取成功", expressQuoteService.detail(id, withHistory));
|
||||
}
|
||||
|
||||
@PostMapping("/{quoteId}/version")
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class ExpressQuoteImportService {
|
||||
}
|
||||
expressQuoteService.requireCompanyQuote(params.getQuoteId());
|
||||
expressQuoteService.upsertVersion(params.getQuoteId(), toVersionDto(draft));
|
||||
return expressQuoteService.detail(params.getQuoteId());
|
||||
return expressQuoteService.detail(params.getQuoteId(), false);
|
||||
}
|
||||
throw new BusinessException("不支持的导入模式: " + params.getMode());
|
||||
}
|
||||
|
||||
+6
-1
@@ -21,7 +21,12 @@ public interface ExpressQuoteService {
|
||||
|
||||
List<ExpressQuoteVO> listEnabled();
|
||||
|
||||
ExpressQuoteVO detail(Long id);
|
||||
/**
|
||||
* 报价详情。
|
||||
*
|
||||
* @param withHistory true=加载全部版本的分区/重量带(详情抽屉);false=仅当前版本明细(编辑页)
|
||||
*/
|
||||
ExpressQuoteVO detail(Long id, boolean withHistory);
|
||||
|
||||
ExpressQuotePO requireCompanyQuote(Long id);
|
||||
|
||||
|
||||
+76
-18
@@ -35,7 +35,9 @@ import top.xyquan.ecomdmbbackend.utils.CurrentUserContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -91,7 +93,7 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
||||
if (dto.getInitialVersion() != null) {
|
||||
upsertVersionInternal(po, dto.getInitialVersion());
|
||||
}
|
||||
return detail(po.getId());
|
||||
return detail(po.getId(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,7 +109,7 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
||||
po.setUpdateBy(currentUserContext.getCurrentUserId());
|
||||
updateById(po);
|
||||
markDirtyForQuote(po.getId(), null);
|
||||
return detail(id);
|
||||
return detail(id, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,20 +168,58 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressQuoteVO detail(Long id) {
|
||||
public ExpressQuoteVO detail(Long id, boolean withHistory) {
|
||||
ExpressQuotePO po = requireCompanyQuote(id);
|
||||
ExpressQuoteVO vo = toBriefVo(po);
|
||||
ExpressQuoteVO vo = new ExpressQuoteVO();
|
||||
BeanCopyUtils.copyProperties(po, vo);
|
||||
|
||||
List<ExpressQuoteVersionPO> versions = versionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteVersionPO>()
|
||||
.eq(ExpressQuoteVersionPO::getQuoteId, id)
|
||||
.orderByDesc(ExpressQuoteVersionPO::getEffectiveFrom));
|
||||
List<ExpressQuoteVO.VersionVO> versionVos = new ArrayList<>();
|
||||
.orderByDesc(ExpressQuoteVersionPO::getEffectiveFrom)
|
||||
.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) {
|
||||
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);
|
||||
if (!versionVos.isEmpty()) {
|
||||
vo.setCurrentVersion(versionVos.get(0));
|
||||
}
|
||||
vo.setCurrentVersion(versionVos.get(0));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -459,20 +499,38 @@ public class ExpressQuoteServiceImpl extends ServiceImpl<ExpressQuoteMapper, Exp
|
||||
}
|
||||
|
||||
private ExpressQuoteVO.VersionVO toVersionVo(ExpressQuoteVersionPO v, boolean withRegions) {
|
||||
ExpressQuoteVO.VersionVO vo = new ExpressQuoteVO.VersionVO();
|
||||
BeanCopyUtils.copyProperties(v, vo);
|
||||
if (!withRegions) {
|
||||
ExpressQuoteVO.VersionVO vo = new ExpressQuoteVO.VersionVO();
|
||||
BeanCopyUtils.copyProperties(v, vo);
|
||||
return vo;
|
||||
}
|
||||
List<ExpressQuoteRegionPO> regions = regionMapper.selectList(new LambdaQueryWrapper<ExpressQuoteRegionPO>()
|
||||
.eq(ExpressQuoteRegionPO::getVersionId, v.getId())
|
||||
.orderByAsc(ExpressQuoteRegionPO::getSortOrder));
|
||||
List<ExpressQuoteBandPO> bands = bandMapper.selectList(new LambdaQueryWrapper<ExpressQuoteBandPO>()
|
||||
.eq(ExpressQuoteBandPO::getVersionId, v.getId())
|
||||
.orderByAsc(ExpressQuoteBandPO::getSortOrder)
|
||||
.orderByAsc(ExpressQuoteBandPO::getWeightFromG));
|
||||
var bandsByRegion = bands.stream().collect(Collectors.groupingBy(ExpressQuoteBandPO::getRegionId));
|
||||
List<ExpressQuoteVO.RegionVO> regionVos = new ArrayList<>();
|
||||
List<Long> regionIds = regions.stream().map(ExpressQuoteRegionPO::getId).toList();
|
||||
Map<Long, List<ExpressQuoteBandPO>> bandsByRegion = Map.of();
|
||||
if (!regionIds.isEmpty()) {
|
||||
List<ExpressQuoteBandPO> bands = bandMapper.selectList(new LambdaQueryWrapper<ExpressQuoteBandPO>()
|
||||
.in(ExpressQuoteBandPO::getRegionId, regionIds)
|
||||
.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) {
|
||||
ExpressQuoteVO.RegionVO rv = new ExpressQuoteVO.RegionVO();
|
||||
rv.setId(r.getId());
|
||||
|
||||
+6
-4
@@ -60,15 +60,17 @@ public class DepartmentController {
|
||||
|
||||
@GetMapping("/all")
|
||||
@RequirePermission(value = "org:department:read", description = "查询全部部门", allowSuper = true)
|
||||
public ApiResponse<List<DepartmentVO>> getAllDepartments() {
|
||||
List<DepartmentVO> result = departmentService.getAllDepartments();
|
||||
public ApiResponse<List<DepartmentVO>> getAllDepartments(
|
||||
@RequestParam(required = false) Long companyId) {
|
||||
List<DepartmentVO> result = departmentService.getAllDepartments(companyId);
|
||||
return ApiResponse.success("获取全部部门成功", result);
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@RequirePermission(value = "org:department:read", description = "查询部门树", allowSuper = true)
|
||||
public ApiResponse<List<DepartmentVO>> getDepartmentTree() {
|
||||
List<DepartmentVO> result = departmentService.getDepartmentTree();
|
||||
public ApiResponse<List<DepartmentVO>> getDepartmentTree(
|
||||
@RequestParam(required = false) Long companyId) {
|
||||
List<DepartmentVO> result = departmentService.getDepartmentTree(companyId);
|
||||
return ApiResponse.success("获取部门树成功", result);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -22,4 +22,9 @@ public class DepartmentFilterDTO {
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 公司ID(仅超管可跨公司查询)
|
||||
*/
|
||||
private Long companyId;
|
||||
}
|
||||
|
||||
+16
@@ -55,6 +55,14 @@ public interface DepartmentService extends IService<DepartmentPO> {
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* 获取指定公司部门树(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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析查询用公司ID:超管可传 companyId 跨公司;否则强制当前公司。
|
||||
*/
|
||||
private Long resolveCompanyId(Long requestedCompanyId) {
|
||||
if (requestedCompanyId == null) {
|
||||
return currentUserContext.getCurrentCompanyId();
|
||||
}
|
||||
if (!currentUserContext.isCurrentUserSuper()) {
|
||||
throw new BusinessException("无权跨公司查询部门");
|
||||
}
|
||||
return requestedCompanyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门分页列表
|
||||
* @param pageQueryDTO 分页查询DTO
|
||||
@@ -165,14 +178,11 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<DepartmentVO> getDepartmentPage(PageQueryDTO<DepartmentFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
DepartmentFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
Long companyId = resolveCompanyId(queryDTO != null ? queryDTO.getCompanyId() : null);
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<DepartmentPO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加过滤条件
|
||||
DepartmentFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
if (queryDTO != null) {
|
||||
if (queryDTO.getName() != null && StringUtils.hasText(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());
|
||||
}
|
||||
}
|
||||
// 强制添加公司ID过滤条件
|
||||
wrapper.eq(DepartmentPO::getCompanyId, companyId);
|
||||
|
||||
// 排序
|
||||
wrapper.orderByAsc(DepartmentPO::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
Page<DepartmentPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<DepartmentPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<DepartmentVO> records = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.toList();
|
||||
PageResultVO<DepartmentVO> result = PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||
return PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||
pageQueryDTO.getPageSize());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前公司全部部门
|
||||
*
|
||||
* @return 部门列表
|
||||
*/
|
||||
@Override
|
||||
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<>();
|
||||
wrapper.eq(DepartmentPO::getCompanyId, companyId)
|
||||
wrapper.eq(DepartmentPO::getCompanyId, resolvedCompanyId)
|
||||
.orderByAsc(DepartmentPO::getCreateTime);
|
||||
|
||||
return this.list(wrapper).stream()
|
||||
@@ -224,12 +233,18 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
||||
|
||||
/**
|
||||
* 获取当前公司部门树
|
||||
*
|
||||
* @return 部门树
|
||||
*/
|
||||
@Override
|
||||
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()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
+5
@@ -17,4 +17,9 @@ public class PositionFilterDTO {
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 公司ID(仅超管可跨公司查询)
|
||||
*/
|
||||
private Long companyId;
|
||||
}
|
||||
|
||||
+16
-13
@@ -147,6 +147,19 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
||||
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
|
||||
@@ -154,14 +167,11 @@ public class PositionServiceImpl extends ServiceImpl<PositionMapper, PositionPO>
|
||||
*/
|
||||
@Override
|
||||
public PageResultVO<PositionVO> getPositionPage(PageQueryDTO<PositionFilterDTO> pageQueryDTO) {
|
||||
// 从token中获取公司ID
|
||||
Long companyId = currentUserContext.getCurrentCompanyId();
|
||||
PositionFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
Long companyId = resolveCompanyId(queryDTO != null ? queryDTO.getCompanyId() : null);
|
||||
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<PositionPO> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 添加过滤条件
|
||||
PositionFilterDTO queryDTO = pageQueryDTO.getFilters();
|
||||
if (queryDTO != null) {
|
||||
if (queryDTO.getName() != null && StringUtils.hasText(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());
|
||||
}
|
||||
}
|
||||
// 强制添加公司ID过滤条件
|
||||
wrapper.eq(PositionPO::getCompanyId, companyId);
|
||||
|
||||
// 排序
|
||||
wrapper.orderByAsc(PositionPO::getCreateTime);
|
||||
|
||||
// 分页查询
|
||||
Page<PositionPO> page = new Page<>(pageQueryDTO.getPage(), pageQueryDTO.getPageSize());
|
||||
IPage<PositionPO> pageResult = this.page(page, wrapper);
|
||||
|
||||
// 转换为VO
|
||||
List<PositionVO> records = pageResult.getRecords().stream()
|
||||
.map(this::convertToVO)
|
||||
.toList();
|
||||
PageResultVO<PositionVO> result = PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||
return PageResultVO.create(records, pageResult.getTotal(), pageQueryDTO.getPage(),
|
||||
pageQueryDTO.getPageSize());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class CreateSysAccountDTO {
|
||||
private String username;
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
@Size(min = 8, max = 20, message = "密码长度必须在8-20个字符之间")
|
||||
@Size(min = 6, max = 20, message = "密码长度必须在6-20个字符之间")
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "用户姓名不能为空")
|
||||
|
||||
@@ -23,9 +23,14 @@ export async function getEnabledExpressQuotesApi() {
|
||||
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>(
|
||||
`/ec/express-quote/detail/${id}`,
|
||||
{ params: { withHistory } },
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,15 +53,19 @@ export async function deleteDepartmentApi(id: number) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部部门
|
||||
* 获取全部部门(超管可传 companyId 跨公司)
|
||||
*/
|
||||
export async function getAllDepartmentsApi() {
|
||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/all');
|
||||
export async function getAllDepartmentsApi(companyId?: number) {
|
||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/all', {
|
||||
params: companyId == null ? undefined : { companyId },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门树
|
||||
* 获取部门树(超管可传 companyId 跨公司)
|
||||
*/
|
||||
export async function getDepartmentTreeApi() {
|
||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/tree');
|
||||
export async function getDepartmentTreeApi(companyId?: number) {
|
||||
return requestClient.get<DepartmentVO.DepartmentInfoVO[]>('/department/tree', {
|
||||
params: companyId == null ? undefined : { companyId },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,5 +35,7 @@ export namespace DepartmentDTO {
|
||||
parentId?: number;
|
||||
/** 状态 */
|
||||
status?: number;
|
||||
/** 公司ID(仅超管可跨公司) */
|
||||
companyId?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,7 @@ export namespace PositionDTO {
|
||||
name?: string;
|
||||
/** 状态 */
|
||||
status?: number;
|
||||
/** 公司ID(仅超管可跨公司) */
|
||||
companyId?: number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,7 +964,8 @@ void loadEnabledModels().then(() => refreshSessions());
|
||||
class="mt-24"
|
||||
description="开始提问吧(需先在「模型管理」配置 API)"
|
||||
/>
|
||||
<div class="mx-auto max-w-[760px]">
|
||||
<!-- w-full:避免仅 max-w 时在 flex 列里被内容撑成窄条,短气泡左右贴中间 -->
|
||||
<div class="mx-auto w-full max-w-[760px]">
|
||||
<ChatItem
|
||||
v-for="item in bubbleViews"
|
||||
:key="item.id"
|
||||
@@ -1086,18 +1087,21 @@ html.dark .agent-session-item--active,
|
||||
}
|
||||
|
||||
.agent-td-item {
|
||||
/* ChatItem 根节点即 .t-chat__inner,样式打在本类上 */
|
||||
/* ChatItem 根节点即 .t-chat__inner;行必须拉满,短文案才能各贴左右 */
|
||||
display: flex;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
margin-bottom: 16px;
|
||||
padding-inline: 20px;
|
||||
}
|
||||
|
||||
/* 内容区占满行宽,气泡用 align-items 贴边;勿对 content 用 fit-content(会把左右挤到中间) */
|
||||
.agent-td-item :deep(.t-chat__content) {
|
||||
flex: 0 1 auto !important;
|
||||
width: fit-content !important;
|
||||
max-width: min(680px, 100%);
|
||||
flex: 1 1 auto !important;
|
||||
width: 100% !important;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
justify-content: flex-start !important;
|
||||
}
|
||||
|
||||
@@ -1106,30 +1110,31 @@ html.dark .agent-session-item--active,
|
||||
}
|
||||
|
||||
.agent-td-item--assistant :deep(.t-chat__content) {
|
||||
align-self: flex-start;
|
||||
align-items: flex-start !important;
|
||||
margin-right: auto;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.agent-td-item--user {
|
||||
/* 无头像时关掉 TDesign row-reverse,避免与左右对齐打架 */
|
||||
flex-direction: row !important;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.agent-td-item--user :deep(.t-chat__content) {
|
||||
align-self: flex-end;
|
||||
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) {
|
||||
width: fit-content;
|
||||
max-width: 100%;
|
||||
max-width: min(680px, 100%);
|
||||
margin-inline: 0;
|
||||
}
|
||||
|
||||
.agent-td-item :deep(.t-chat__text__name) {
|
||||
.agent-td-item :deep(.t-chat__name) {
|
||||
opacity: 0.55;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ async function open(id: number) {
|
||||
loading.value = true;
|
||||
detail.value = null;
|
||||
try {
|
||||
detail.value = await getExpressQuoteDetailApi(id);
|
||||
detail.value = await getExpressQuoteDetailApi(id, true);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.error('加载报价详情失败');
|
||||
|
||||
+180
-57
@@ -1,11 +1,16 @@
|
||||
<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 {
|
||||
Anchor,
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
@@ -17,23 +22,10 @@ import {
|
||||
message,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
export interface BandRow {
|
||||
weightFromG: number;
|
||||
weightToG: number | null;
|
||||
priceMode: string;
|
||||
flatAmount: number;
|
||||
firstWeightG: number;
|
||||
firstAmount: number;
|
||||
continuePerKg: number;
|
||||
}
|
||||
import { createRegionUid, type BandRow, type RegionRow } from './region-band';
|
||||
|
||||
export interface RegionRow {
|
||||
regionName: string;
|
||||
zoneLabel: string;
|
||||
provinces: string[];
|
||||
isDefault: boolean;
|
||||
bands: BandRow[];
|
||||
}
|
||||
/** 分区导航拖拽手柄 */
|
||||
const GripVerticalIcon = createIconifyIcon('lucide:grip-vertical');
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: RegionRow[];
|
||||
@@ -47,24 +39,24 @@ const emit = defineEmits<{
|
||||
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 anchorItems = computed(() =>
|
||||
regions.value.map((r, i) => ({
|
||||
key: `region-${i}`,
|
||||
href: `#quote-region-${i}`,
|
||||
title: r.zoneLabel || r.regionName || `分区${i + 1}`,
|
||||
})),
|
||||
/** 导航列表数据源:排序中用草稿,否则用正式数据 */
|
||||
const navRegions = computed(() =>
|
||||
sorting.value ? draftRegions.value : regions.value,
|
||||
);
|
||||
|
||||
function getScrollContainer() {
|
||||
return scrollRef.value || window;
|
||||
}
|
||||
|
||||
const bandColumnDefs = [
|
||||
{ title: '从(克)', key: 'from', 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() {
|
||||
if (sorting.value) return;
|
||||
const uid = createRegionUid();
|
||||
const nextIndex = regions.value.length;
|
||||
regions.value = [
|
||||
...regions.value,
|
||||
{
|
||||
uid,
|
||||
regionName: `分区${nextIndex + 1}`,
|
||||
zoneLabel: '',
|
||||
provinces: [],
|
||||
@@ -97,14 +165,11 @@ function addRegion() {
|
||||
bands: [emptyBand(0)],
|
||||
},
|
||||
];
|
||||
void nextTick(() => {
|
||||
document
|
||||
.getElementById(`quote-region-${nextIndex}`)
|
||||
?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
void nextTick(() => scrollToRegion(uid));
|
||||
}
|
||||
|
||||
function removeRegion(idx: number) {
|
||||
if (sorting.value) return;
|
||||
if (regions.value.length <= 1) {
|
||||
message.warning('至少保留一个分区');
|
||||
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));
|
||||
patchRegion(ri, { bands });
|
||||
}
|
||||
|
||||
function onAnchorClick(e: Event) {
|
||||
e.preventDefault();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Card
|
||||
size="small"
|
||||
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="{
|
||||
flex: '1 1 0%',
|
||||
minHeight: 0,
|
||||
@@ -170,31 +231,93 @@ function onAnchorClick(e: Event) {
|
||||
}"
|
||||
>
|
||||
<template #extra>
|
||||
<Button size="small" type="dashed" @click="addRegion">添加分区</Button>
|
||||
</template>
|
||||
<div class="flex min-h-0 flex-1 gap-3">
|
||||
<aside
|
||||
class="w-36 shrink-0 overflow-y-auto border-r border-border pr-2 pt-1"
|
||||
<Button
|
||||
size="small"
|
||||
type="dashed"
|
||||
:disabled="sorting"
|
||||
@click="addRegion"
|
||||
>
|
||||
<div class="mb-2 text-xs text-muted-foreground">分区导航</div>
|
||||
<Anchor
|
||||
:affix="false"
|
||||
:items="anchorItems"
|
||||
:get-container="getScrollContainer"
|
||||
@click="onAnchorClick"
|
||||
/>
|
||||
添加分区
|
||||
</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="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
|
||||
v-for="(region, ri) in regions"
|
||||
:id="`quote-region-${ri}`"
|
||||
:key="ri"
|
||||
:id="`quote-region-${region.uid}`"
|
||||
:key="region.uid"
|
||||
size="small"
|
||||
class="mb-3 shrink-0 scroll-mt-2"
|
||||
class="shrink-0 scroll-mt-2"
|
||||
:title="region.regionName || `分区${ri + 1}`"
|
||||
>
|
||||
<template #extra>
|
||||
<Button type="link" danger size="small" @click="removeRegion(ri)">
|
||||
<Button
|
||||
type="link"
|
||||
danger
|
||||
size="small"
|
||||
:disabled="sorting"
|
||||
@click="removeRegion(ri)"
|
||||
>
|
||||
删除分区
|
||||
</Button>
|
||||
</template>
|
||||
@@ -250,7 +373,7 @@ function onAnchorClick(e: Event) {
|
||||
:pagination="false"
|
||||
:columns="bandColumnDefs"
|
||||
: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 v-if="column.key === 'from'">
|
||||
|
||||
+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)}`;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
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 { ColPage } from '@vben/common-ui';
|
||||
@@ -20,9 +20,8 @@ import {
|
||||
} from '#/api/ec/express-quote';
|
||||
import { formatOverviewTabTitle } from '#/utils/overview-tab-title';
|
||||
|
||||
import RegionBandEditor, {
|
||||
type RegionRow,
|
||||
} from './components/RegionBandEditor.vue';
|
||||
import RegionBandEditor from './components/RegionBandEditor.vue';
|
||||
import { createRegionUid, type RegionRow } from './components/region-band';
|
||||
|
||||
defineOptions({ name: 'ExpressQuoteEdit' });
|
||||
|
||||
@@ -43,6 +42,7 @@ const pageTitle = ref('快递报价单编辑「新建」');
|
||||
const provinces = ref<ExpressQuoteVO.ProvinceOption[]>([]);
|
||||
const regions = ref<RegionRow[]>([
|
||||
{
|
||||
uid: createRegionUid(),
|
||||
regionName: '默认区',
|
||||
zoneLabel: '',
|
||||
provinces: [],
|
||||
@@ -246,6 +246,8 @@ const [BaseForm, formApi] = useVbenForm({
|
||||
fieldName: 'useVolumetric',
|
||||
label: '启用体积重',
|
||||
defaultValue: false,
|
||||
// 覆盖 commonConfig 的 w-full,避免开关被拉成整栏宽
|
||||
componentProps: { class: 'w-auto' },
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
@@ -278,6 +280,7 @@ function fillRegionsFromVersion(v?: ExpressQuoteVO.Version) {
|
||||
if (!v?.regions?.length) {
|
||||
regions.value = [
|
||||
{
|
||||
uid: createRegionUid(),
|
||||
regionName: '默认区',
|
||||
zoneLabel: '',
|
||||
provinces: [],
|
||||
@@ -297,7 +300,11 @@ function fillRegionsFromVersion(v?: ExpressQuoteVO.Version) {
|
||||
];
|
||||
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,
|
||||
zoneLabel: r.zoneLabel || '',
|
||||
provinces: r.provinces ? [...r.provinces] : [],
|
||||
@@ -329,11 +336,21 @@ function fillRegionsFromVersion(v?: ExpressQuoteVO.Version) {
|
||||
|
||||
async function loadDetail() {
|
||||
loading.value = true;
|
||||
let tabTitle: string | undefined;
|
||||
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.setValues({
|
||||
carrierCode: 'ZTO',
|
||||
@@ -347,13 +364,16 @@ async function loadDetail() {
|
||||
weightRound: 'NONE',
|
||||
});
|
||||
billingMode.value = 'FLAT';
|
||||
syncLeftWidthByMode();
|
||||
fillRegionsFromVersion();
|
||||
await syncTabTitle('新建');
|
||||
tabTitle = '新建';
|
||||
return;
|
||||
}
|
||||
const detail = await getExpressQuoteDetailApi(quoteId.value);
|
||||
billingMode.value = detail.billingMode;
|
||||
|
||||
const v = detail.currentVersion;
|
||||
billingMode.value = detail.billingMode;
|
||||
syncLeftWidthByMode();
|
||||
// 先回填表单并结束 loading,再挂大块分区(避免接口已返回仍长时间转圈)
|
||||
await formApi.setValues({
|
||||
code: detail.code,
|
||||
name: detail.name,
|
||||
@@ -370,15 +390,19 @@ async function loadDetail() {
|
||||
useVolumetric: v?.useVolumetric === 1,
|
||||
weightRound: v?.weightRound || 'NONE',
|
||||
});
|
||||
loading.value = false;
|
||||
await nextTick();
|
||||
fillRegionsFromVersion(v);
|
||||
await syncTabTitle(detail.name);
|
||||
tabTitle = detail.name;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.error('加载报价单失败');
|
||||
} finally {
|
||||
syncLeftWidthByMode();
|
||||
loading.value = false;
|
||||
}
|
||||
if (tabTitle != null) {
|
||||
void syncTabTitle(tabTitle);
|
||||
}
|
||||
}
|
||||
|
||||
function buildVersion(
|
||||
@@ -501,13 +525,13 @@ watch(
|
||||
<Card
|
||||
size="small"
|
||||
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"
|
||||
>
|
||||
<BaseForm />
|
||||
</Card>
|
||||
</template>
|
||||
<div class="h-full min-h-0 min-w-0">
|
||||
<div class="h-full min-h-0 min-w-0 overflow-hidden">
|
||||
<RegionBandEditor
|
||||
v-if="isRegion"
|
||||
v-model="regions"
|
||||
@@ -517,7 +541,7 @@ watch(
|
||||
v-else
|
||||
size="small"
|
||||
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"
|
||||
>
|
||||
<Empty
|
||||
@@ -548,10 +572,11 @@ watch(
|
||||
min-height: 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%;
|
||||
}
|
||||
.express-quote-edit-page :deep(.ant-card-head) {
|
||||
.express-quote-edit-page :deep(.eq-panel-card > .ant-card-head) {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 超管账户表单:公司 / 部门 / 职位走列表接口下拉,不必手填 ID。
|
||||
*/
|
||||
import type { CompanyVO } from '#/api/company/types';
|
||||
import type { DepartmentVO } from '#/api/org/department';
|
||||
import type { PositionVO } from '#/api/org/position';
|
||||
import type {
|
||||
SuperAccountDTO,
|
||||
SuperAccountVO,
|
||||
} from '#/api/sys/account';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
||||
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 {
|
||||
super_createAccountApi,
|
||||
super_updateAccountApi,
|
||||
@@ -20,13 +29,25 @@ interface Emits {
|
||||
(e: 'success'): void;
|
||||
}
|
||||
|
||||
interface DepartmentCascaderOption {
|
||||
children?: DepartmentCascaderOption[];
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
interface PositionSelectOption {
|
||||
departmentId?: number;
|
||||
label: string;
|
||||
value: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'SysAccountFormModal' });
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[500px]',
|
||||
class: 'w-[560px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
@@ -39,7 +60,16 @@ const formRef = ref();
|
||||
const loading = ref(false);
|
||||
const isEdit = ref(false);
|
||||
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<
|
||||
SuperAccountDTO.SuperCreateAccountDTO & { status?: number }
|
||||
@@ -48,7 +78,7 @@ const formData = ref<
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
companyId: 0,
|
||||
companyId: undefined as unknown as number,
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
isSuper: 0,
|
||||
@@ -64,13 +94,54 @@ const statusOptions = [
|
||||
{ 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() {
|
||||
formData.value = {
|
||||
username: '',
|
||||
password: '',
|
||||
realName: '',
|
||||
phone: '',
|
||||
companyId: presetCompany.value?.id ?? 0,
|
||||
companyId: undefined as unknown as number,
|
||||
departmentId: undefined,
|
||||
positionId: undefined,
|
||||
isSuper: 0,
|
||||
@@ -78,6 +149,7 @@ function resetForm() {
|
||||
remark: '',
|
||||
status: 1,
|
||||
};
|
||||
departmentPath.value = [];
|
||||
formRef.value?.resetFields();
|
||||
}
|
||||
|
||||
@@ -85,15 +157,147 @@ function handleCancel() {
|
||||
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,
|
||||
company?: CompanyVO.CompanyInfoVO | null,
|
||||
) {
|
||||
isEdit.value = !!accountData;
|
||||
currentAccountData.value = accountData || null;
|
||||
presetCompany.value = company || null;
|
||||
loadedOrgCompanyId.value = undefined;
|
||||
|
||||
resetForm();
|
||||
await loadCompanyOptions();
|
||||
|
||||
if (accountData) {
|
||||
formData.value = {
|
||||
@@ -101,7 +305,7 @@ function open(
|
||||
password: '',
|
||||
realName: accountData.realName,
|
||||
phone: accountData.phone || '',
|
||||
companyId: accountData.companyId || presetCompany.value?.id || 0,
|
||||
companyId: accountData.companyId as number,
|
||||
departmentId: accountData.departmentId,
|
||||
positionId: accountData.positionId,
|
||||
isSuper: accountData.isSuper ?? 0,
|
||||
@@ -109,8 +313,13 @@ function open(
|
||||
remark: accountData.remark || '',
|
||||
status: accountData.status ?? 1,
|
||||
};
|
||||
} else if (presetCompany.value) {
|
||||
formData.value.companyId = presetCompany.value.id;
|
||||
} else if (company?.id) {
|
||||
formData.value.companyId = company.id;
|
||||
}
|
||||
|
||||
if (formData.value.companyId) {
|
||||
await loadOrgOptionsForCompany(formData.value.companyId);
|
||||
syncDepartmentPathByDepartmentId();
|
||||
}
|
||||
|
||||
modalApi.open();
|
||||
@@ -126,7 +335,9 @@ async function handleSubmit() {
|
||||
await super_updateAccountApi(currentAccountData.value.id, updateData);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await super_createAccountApi(formData.value);
|
||||
// CreateSysAccountDTO 无 status,创建时剔除
|
||||
const { status: _status, ...createData } = formData.value;
|
||||
await super_createAccountApi(createData);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
@@ -146,12 +357,26 @@ watch(
|
||||
() => modalApi.useStore()?.value?.isOpen,
|
||||
(newVal) => {
|
||||
if (!newVal) {
|
||||
presetCompany.value = null;
|
||||
loadedOrgCompanyId.value = undefined;
|
||||
resetForm();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
watch(
|
||||
() => formData.value.departmentId,
|
||||
() => {
|
||||
if (
|
||||
formData.value.positionId &&
|
||||
!positionOptions.value.some(
|
||||
(item) => item.value === formData.value.positionId,
|
||||
)
|
||||
) {
|
||||
formData.value.positionId = undefined;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
});
|
||||
@@ -165,8 +390,22 @@ defineExpose({
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item v-if="presetCompany" label="所属公司">
|
||||
<Input :value="presetCompany.name" disabled />
|
||||
<Form.Item
|
||||
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
|
||||
@@ -211,10 +450,6 @@ defineExpose({
|
||||
<Input v-model:value="formData.realName" placeholder="请输入真实姓名" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="手机号"
|
||||
name="phone"
|
||||
@@ -226,32 +461,36 @@ defineExpose({
|
||||
<Input v-model:value="formData.phone" placeholder="请输入手机号" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
v-if="!presetCompany"
|
||||
label="公司ID"
|
||||
name="companyId"
|
||||
:rules="[{ required: true, message: '请输入公司ID' }]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="formData.companyId"
|
||||
type="number"
|
||||
placeholder="请输入公司ID"
|
||||
<Form.Item label="所属部门" name="departmentId">
|
||||
<Cascader
|
||||
:value="departmentPath"
|
||||
:options="departmentTreeOptions"
|
||||
:loading="departmentOptionsLoading"
|
||||
:disabled="!formData.companyId"
|
||||
placeholder="请先选择公司"
|
||||
:field-names="{
|
||||
label: 'label',
|
||||
value: 'value',
|
||||
children: 'children',
|
||||
}"
|
||||
change-on-select
|
||||
allow-clear
|
||||
class="w-full"
|
||||
@change="(value) => handleDepartmentChange((value || []) as number[])"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="部门ID" name="departmentId">
|
||||
<Input
|
||||
v-model:value="formData.departmentId"
|
||||
type="number"
|
||||
placeholder="请输入部门ID"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="职位ID" name="positionId">
|
||||
<Input
|
||||
<Form.Item label="职位" name="positionId">
|
||||
<Select
|
||||
v-model:value="formData.positionId"
|
||||
type="number"
|
||||
placeholder="请输入职位ID"
|
||||
:loading="positionOptionsLoading"
|
||||
:options="positionOptions"
|
||||
:disabled="!formData.companyId || positionOptionsLoading"
|
||||
placeholder="请先选择公司"
|
||||
allow-clear
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
class="w-full"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
@@ -270,12 +509,8 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="头像图片ID" name="avatarImageId">
|
||||
<Input
|
||||
v-model:value="formData.avatarImageId"
|
||||
type="number"
|
||||
placeholder="请输入头像图片ID"
|
||||
/>
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input v-model:value="formData.remark" placeholder="请输入备注" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item v-if="isEdit" label="状态" name="status">
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
/**
|
||||
* 系统账户:左栏筛公司,右栏用 Vxe 搜索表单 + toolbar 新增(对齐反馈页布局)。
|
||||
*/
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { CompanyVO } from '#/api/company/types';
|
||||
import type {
|
||||
@@ -14,10 +17,8 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
message,
|
||||
Popconfirm,
|
||||
Select,
|
||||
Space,
|
||||
Tag,
|
||||
} from 'ant-design-vue';
|
||||
@@ -46,13 +47,6 @@ const accountFormModalRef = ref();
|
||||
const selectedCompanyId = ref<number | undefined>(undefined);
|
||||
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 = [
|
||||
{ label: '正常', value: 1 },
|
||||
{ label: '停用', value: 0 },
|
||||
@@ -146,6 +140,52 @@ const accountTableColumns = computed(() =>
|
||||
: (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> = {
|
||||
columns: accountTableColumns.value,
|
||||
height: '100%',
|
||||
@@ -185,17 +225,17 @@ const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
},
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
query: async ({ page }, formValues: Record<string, any> = {}) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<SuperAccountDTO.AccountFilterDTO> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
username: searchForm.value.username || undefined,
|
||||
realName: searchForm.value.realName || undefined,
|
||||
phone: searchForm.value.phone || undefined,
|
||||
status: searchForm.value.status,
|
||||
username: formValues.username?.trim() || undefined,
|
||||
realName: formValues.realName?.trim() || undefined,
|
||||
phone: formValues.phone?.trim() || undefined,
|
||||
status: formValues.status,
|
||||
companyId: currentCompany.value?.id,
|
||||
},
|
||||
};
|
||||
@@ -219,7 +259,8 @@ const gridOptions: VxeGridProps<SuperAccountVO.AccountInfoVO> = {
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
showSearchForm: false,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '账户列表',
|
||||
});
|
||||
syncVxeGridColumns(gridApi, accountTableColumns);
|
||||
@@ -233,11 +274,8 @@ function refreshTable() {
|
||||
gridApi?.reload();
|
||||
}
|
||||
|
||||
/** 新增:不必先选左栏公司,表单内自选;左栏有选中时作默认值 */
|
||||
function handleAdd() {
|
||||
if (!currentCompany.value) {
|
||||
message.warning('请先选择具体公司,或在公司行点击「添加」');
|
||||
return;
|
||||
}
|
||||
accountFormModalRef.value?.open(undefined, currentCompany.value);
|
||||
}
|
||||
|
||||
@@ -310,71 +348,32 @@ watch(currentCompany, () => {
|
||||
}"
|
||||
>
|
||||
<template #title>
|
||||
<span class="text-base font-semibold">账户列表</span>
|
||||
</template>
|
||||
<template #extra>
|
||||
<Space wrap size="small" class="max-w-[min(100%,48rem)]">
|
||||
<Input
|
||||
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">
|
||||
<div class="flex min-w-0 items-center gap-2">
|
||||
<span class="text-base font-semibold">账户列表</span>
|
||||
<span class="text-muted-foreground truncate text-xs font-normal">
|
||||
当前:{{ selectedCompanyLabel }}
|
||||
</span>
|
||||
<Tag
|
||||
class="ml-2"
|
||||
v-if="currentCompany"
|
||||
class="m-0"
|
||||
:color="currentCompany.status === 1 ? 'green' : 'red'"
|
||||
>
|
||||
{{ currentCompany.status === 1 ? '启用' : '禁用' }}
|
||||
</Tag>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div
|
||||
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">
|
||||
<template #toolbar-tools>
|
||||
<span class="text-muted-foreground text-xs">
|
||||
左侧筛选公司;表格在区域内滚动
|
||||
</span>
|
||||
<PermissionGate code="sys:account:create">
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-1 h-4 w-4" />
|
||||
新增账户
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</template>
|
||||
|
||||
<template #status="{ row }">
|
||||
|
||||
Reference in New Issue
Block a user