forked from github/dataease
refactor(系统设置): 模版管理批量操作修改分类是当分类完全相同默认显示分类标签
This commit is contained in:
parent
39acfcea29
commit
fbc7ad6e0f
@ -26,5 +26,6 @@ public interface ExtVisualizationTemplateMapper{
|
||||
Long checkCategoryTemplateName(@Param("templateName") String templateName,@Param("categories") List<String> categories);
|
||||
|
||||
List<String> findTemplateCategories(@Param("templateId") String templateId);
|
||||
List<String> findTemplateArrayCategories(@Param("templateArray") List<String> templateArray);
|
||||
|
||||
}
|
||||
|
@ -26,9 +26,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import static io.dataease.constant.StaticResourceConstants.UPLOAD_URL_PREFIX;
|
||||
|
||||
@ -101,7 +99,7 @@ public class TemplateManageService implements TemplateManageApi {
|
||||
templateCategoryMapper.insert(templateCategory);
|
||||
} else {//模板插入 同名的模板进行覆盖(先删除)
|
||||
// 分类映射删除
|
||||
extTemplateMapper.deleteCategoryMapByTemplate(request.getName(),null);
|
||||
extTemplateMapper.deleteCategoryMapByTemplate(request.getName(), null);
|
||||
// 模板删除
|
||||
QueryWrapper<VisualizationTemplate> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("name", request.getName());
|
||||
@ -139,7 +137,7 @@ public class TemplateManageService implements TemplateManageApi {
|
||||
templateMapper.updateById(template);
|
||||
//更新分类
|
||||
// 分类映射删除
|
||||
extTemplateMapper.deleteCategoryMapByTemplate(null,request.getId());
|
||||
extTemplateMapper.deleteCategoryMapByTemplate(null, request.getId());
|
||||
// 插入分类关系
|
||||
request.getCategories().forEach(categoryId -> {
|
||||
VisualizationTemplateCategoryMap categoryMap = new VisualizationTemplateCategoryMap();
|
||||
@ -254,6 +252,17 @@ public class TemplateManageService implements TemplateManageApi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findCategoriesByTemplateIds(TemplateManageRequest request) throws Exception {
|
||||
if (!CollectionUtils.isEmpty(request.getTemplateArray())) {
|
||||
List<String> result = extTemplateMapper.findTemplateArrayCategories(request.getTemplateArray());
|
||||
if(!CollectionUtils.isEmpty(result) &&result.size() == 1 ){
|
||||
return Arrays.stream(result.get(0).split(",")).toList();
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TemplateManageDTO> find(TemplateManageRequest request) {
|
||||
return extTemplateMapper.findTemplateList(request);
|
||||
@ -263,11 +272,12 @@ public class TemplateManageService implements TemplateManageApi {
|
||||
public List<TemplateManageDTO> findCategories(TemplateManageRequest request) {
|
||||
return extTemplateMapper.findCategories(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchUpdate(TemplateManageBatchRequest request) {
|
||||
request.getTemplateIds().forEach(templateId ->{
|
||||
request.getTemplateIds().forEach(templateId -> {
|
||||
// 分类映射删除
|
||||
extTemplateMapper.deleteCategoryMapByTemplate(null,templateId);
|
||||
extTemplateMapper.deleteCategoryMapByTemplate(null, templateId);
|
||||
// 插入分类关系
|
||||
request.getCategories().forEach(categoryId -> {
|
||||
VisualizationTemplateCategoryMap categoryMap = new VisualizationTemplateCategoryMap();
|
||||
@ -281,7 +291,7 @@ public class TemplateManageService implements TemplateManageApi {
|
||||
|
||||
@Override
|
||||
public void batchDelete(TemplateManageBatchRequest request) {
|
||||
request.getTemplateIds().forEach(templateId ->{
|
||||
request.getTemplateIds().forEach(templateId -> {
|
||||
request.getCategories().forEach(categoryId -> {
|
||||
QueryWrapper<VisualizationTemplateCategoryMap> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("template_id", templateId);
|
||||
|
@ -137,4 +137,18 @@
|
||||
from visualization_template_category_map
|
||||
where template_id = #{templateId}
|
||||
</select>
|
||||
|
||||
<select id="findTemplateArrayCategories" resultType="String">
|
||||
SELECT DISTINCT
|
||||
GROUP_CONCAT( DISTINCT vtcm.category_id ORDER BY vtcm.category_id ) AS selected_subjects
|
||||
FROM
|
||||
visualization_template_category_map vtcm
|
||||
WHERE
|
||||
vtcm.template_id in
|
||||
<foreach collection="templateArray" item="templateId" index="index" open="(" close=")" separator=",">
|
||||
#{templateId}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
vtcm.template_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -75,3 +75,10 @@ export function batchUpdate(data) {
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function findCategoriesByTemplateIds(data) {
|
||||
return request.post({
|
||||
url: '/templateManage/findCategoriesByTemplateIds',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { batchUpdate } from '@/api/template'
|
||||
import { batchUpdate, findCategoriesByTemplateIds } from '@/api/template'
|
||||
import { ElMessage } from 'element-plus-secondary'
|
||||
const emits = defineEmits(['closeBatchEditTemplateDialog', 'refresh'])
|
||||
const { t } = useI18n()
|
||||
@ -65,8 +65,15 @@ const state = reactive({
|
||||
}
|
||||
})
|
||||
|
||||
const initCategories = () => {
|
||||
const params = { templateArray: props.templateIds }
|
||||
findCategoriesByTemplateIds(params).then(rsp => {
|
||||
state.templateInfo.categories = rsp.data
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// showCurrentTemplate(props.pid)
|
||||
initCategories()
|
||||
})
|
||||
|
||||
const cancel = () => {
|
||||
|
@ -32,6 +32,11 @@ public interface TemplateManageApi {
|
||||
@Operation(summary = "明细查询")
|
||||
VisualizationTemplateVO findOne(@PathVariable String templateId) throws Exception;
|
||||
|
||||
@PostMapping("/findCategoriesByTemplateIds")
|
||||
@Operation(summary = "明细查询")
|
||||
List<String> findCategoriesByTemplateIds(@RequestBody TemplateManageRequest request) throws Exception;
|
||||
|
||||
|
||||
@PostMapping("/find")
|
||||
@Operation(summary = "查询")
|
||||
List<TemplateManageDTO> find(@RequestBody TemplateManageRequest request);
|
||||
|
@ -27,6 +27,8 @@ public class TemplateManageRequest extends VisualizationTemplateVO {
|
||||
|
||||
private List<String> categories;
|
||||
|
||||
private List<String> templateArray;
|
||||
|
||||
public TemplateManageRequest() {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user