fix(缺陷管理): 导出的缺陷顺序与列表选中顺序一致
--bug=1036200 --user=宋昌昌 【缺陷管理】缺陷管理列表-导出缺陷时选中所有字段导出缺陷内容和自定义字段打开显示异常 https://www.tapd.cn/55049933/s/1471411
This commit is contained in:
parent
cafcfe198b
commit
ac3d4bf576
|
@ -168,6 +168,7 @@ public class BugController {
|
|||
@RequiresPermissions(PermissionConstants.PROJECT_BUG_EXPORT)
|
||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||
public ResponseEntity<byte[]> export(@Validated @RequestBody BugExportRequest request) throws Exception {
|
||||
request.setSort(StringUtils.isNotBlank(request.getSortString()) ? request.getSortString() : "pos desc");
|
||||
request.setUseTrash(false);
|
||||
return bugService.export(request);
|
||||
}
|
||||
|
|
|
@ -14,4 +14,7 @@ public class BugBatchRequest extends TableBatchProcessDTO {
|
|||
|
||||
@Schema(description = "是否回收站")
|
||||
private boolean useTrash;
|
||||
|
||||
@Schema(description = "排序参数")
|
||||
private String sort;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,43 @@
|
|||
package io.metersphere.bug.dto.request;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import io.metersphere.bug.dto.BugExportColumn;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class BugExportRequest extends BugBatchRequest {
|
||||
|
||||
@Schema(description = "导出的字段", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotEmpty(message = "{bug.system_columns.not_empty}")
|
||||
private List<BugExportColumn> exportColumns;
|
||||
|
||||
@Schema(description = "排序字段(model中的字段 : asc/desc)")
|
||||
private Map<@Valid @Pattern(regexp = "^[A-Za-z]+$") String, @Valid @NotBlank String> exportSort;
|
||||
|
||||
public String getSortString() {
|
||||
if (MapUtils.isEmpty(exportSort)) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : exportSort.entrySet()) {
|
||||
String column = CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, entry.getKey());
|
||||
sb.append(column)
|
||||
.append(StringUtils.SPACE)
|
||||
.append(StringUtils.equalsIgnoreCase(entry.getValue(), "desc") ? "desc" : "asc")
|
||||
.append(",");
|
||||
}
|
||||
return sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,10 @@ public interface ExtBugMapper {
|
|||
* 缺陷列表查询
|
||||
*
|
||||
* @param request 请求查询参数
|
||||
* @param sort 排序参数
|
||||
* @return 缺陷列表
|
||||
*/
|
||||
List<BugDTO> list(@Param("request") BugPageRequest request);
|
||||
List<BugDTO> list(@Param("request") BugPageRequest request, @Param("sort") String sort);
|
||||
|
||||
/**
|
||||
* 缺陷列表查询
|
||||
|
@ -33,9 +34,10 @@ public interface ExtBugMapper {
|
|||
* 根据ID列表查询缺陷
|
||||
*
|
||||
* @param ids 缺陷ID集合
|
||||
* @param sort 排序参数
|
||||
* @return 缺陷列表
|
||||
*/
|
||||
List<BugDTO> listByIds(@Param("ids") List<String> ids);
|
||||
List<BugDTO> listByIds(@Param("ids") List<String> ids, @Param("sort") String sort);
|
||||
|
||||
/**
|
||||
* 获取缺陷业务ID
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
select b.id, b.num, b.title, b.handle_user, b.create_user, b.create_time, b.update_user, b.update_time, b.delete_user, b.delete_time,
|
||||
b.project_id, b.template_id, b.platform, b.status, b.tags from bug b
|
||||
<include refid="queryWhereCondition"/>
|
||||
<if test="sort != null and sort != ''">
|
||||
order by ${sort}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getIdsByPageRequest" resultType="java.lang.String">
|
||||
|
@ -25,25 +28,28 @@
|
|||
</select>
|
||||
|
||||
<select id="listByIds" resultMap="BugDTO">
|
||||
select b.id,
|
||||
b.num,
|
||||
b.title,
|
||||
b.handle_user,
|
||||
b.create_user,
|
||||
b.create_time,
|
||||
b.update_time,
|
||||
b.delete_time,
|
||||
b.delete_user,
|
||||
b.project_id,
|
||||
b.template_id,
|
||||
b.platform,
|
||||
b.status,
|
||||
b.tags
|
||||
from bug b
|
||||
WHERE b.id IN
|
||||
select id,
|
||||
num,
|
||||
title,
|
||||
handle_user,
|
||||
create_user,
|
||||
create_time,
|
||||
update_time,
|
||||
delete_time,
|
||||
delete_user,
|
||||
project_id,
|
||||
template_id,
|
||||
platform,
|
||||
status,
|
||||
tags
|
||||
from bug
|
||||
where id in
|
||||
<foreach collection="ids" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
<if test="sort != null and sort != ''">
|
||||
order by ${sort}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getMaxNum" resultType="java.lang.Long">
|
||||
|
|
|
@ -168,7 +168,7 @@ public class BugService {
|
|||
* @return 缺陷列表
|
||||
*/
|
||||
public List<BugDTO> list(BugPageRequest request) {
|
||||
List<BugDTO> bugs = extBugMapper.list(request);
|
||||
List<BugDTO> bugs = extBugMapper.list(request, null);
|
||||
if (CollectionUtils.isEmpty(bugs)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
@ -1391,7 +1391,7 @@ public class BugService {
|
|||
BugPageRequest bugPageRequest = new BugPageRequest();
|
||||
BeanUtils.copyBean(bugPageRequest, request);
|
||||
bugPageRequest.setUseTrash(false);
|
||||
List<BugDTO> allBugs = extBugMapper.list(bugPageRequest);
|
||||
List<BugDTO> allBugs = extBugMapper.list(bugPageRequest, request.getSort());
|
||||
if (CollectionUtils.isNotEmpty(request.getExcludeIds())) {
|
||||
allBugs.removeIf(bug -> request.getExcludeIds().contains(bug.getId()));
|
||||
}
|
||||
|
@ -1401,7 +1401,7 @@ public class BugService {
|
|||
if (CollectionUtils.isEmpty(request.getSelectIds())) {
|
||||
throw new MSException(Translator.get("no_bug_select"));
|
||||
}
|
||||
return extBugMapper.listByIds(request.getSelectIds());
|
||||
return extBugMapper.listByIds(request.getSelectIds(), request.getSort());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<MsCard simple>
|
||||
<MsAdvanceFilter
|
||||
v-model:keyword="keyword"
|
||||
:searchPlaceholder="t('caseManagement.featureCase.searchByIdAndName')"
|
||||
:search-placeholder="t('caseManagement.featureCase.searchByIdAndName')"
|
||||
:filter-config-list="filterConfigList"
|
||||
:row-count="filterRowCount"
|
||||
@keyword-search="fetchData"
|
||||
|
@ -26,6 +26,7 @@
|
|||
:action-config="tableBatchActions"
|
||||
v-on="propsEvent"
|
||||
@batch-action="handleTableBatch"
|
||||
@sorter-change="saveSort"
|
||||
>
|
||||
<!-- ID -->
|
||||
<template #num="{ record, rowIndex }">
|
||||
|
@ -198,6 +199,8 @@
|
|||
const customFields = ref<BugEditCustomField[]>([]);
|
||||
// 当前选择的条数
|
||||
const currentSelectParams = ref<BatchActionQueryParams>({ selectAll: false, currentSelectCount: 0 });
|
||||
// 排序
|
||||
const sort = ref<{ [key: string]: string }>({});
|
||||
|
||||
const syncObject = reactive({
|
||||
time: 0,
|
||||
|
@ -410,6 +413,7 @@
|
|||
...params,
|
||||
exportColumns: option.map((item) => item),
|
||||
projectId: appStore.currentProjectId,
|
||||
exportSort: sort.value,
|
||||
});
|
||||
downloadByteFile(blob, `${t('bugManagement.exportBug')}.zip`);
|
||||
exportVisible.value = false;
|
||||
|
@ -600,6 +604,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
function saveSort(sortObj: { [key: string]: string }) {
|
||||
sort.value = sortObj;
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
setProps({ heightUsed: heightUsed.value });
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue