diff --git a/src/main/java/com/vxnet/pms/repository/DictRepository.java b/src/main/java/com/vxnet/pms/repository/DictRepository.java index eafb126..e3a7b0c 100644 --- a/src/main/java/com/vxnet/pms/repository/DictRepository.java +++ b/src/main/java/com/vxnet/pms/repository/DictRepository.java @@ -25,11 +25,15 @@ public interface DictRepository extends R2dbcRepository { ) Flux findRootDicts(String organization, @Param("params") Map params, Pageable pageable); - @Query("SELECT * FROM jhi_dict WHERE parent_number = :parentNumber ORDER BY sort_no ASC") - Flux findByParentNumber(@Param("parentNumber") String parentNumber); + @Query( + "SELECT * FROM jhi_dict WHERE (:#{#organization} = '*' OR organization = :#{#organization}) AND parent_number = :parentNumber ORDER BY sort_no ASC" + ) + Flux findByParentNumber(String organization, @Param("parentNumber") String parentNumber); - @Query("SELECT COUNT(*) FROM jhi_dict WHERE parent_number = :parentNumber") - Mono countChildren(@Param("parentNumber") String parentNumber); + @Query( + "SELECT COUNT(*) FROM jhi_dict WHERE (:#{#organization} = '*' OR organization = :#{#organization}) AND parent_number = :parentNumber" + ) + Mono countChildren(String organization, @Param("parentNumber") String parentNumber); @Query( "SELECT * FROM jhi_dict WHERE (:#{#organization} = '*' OR organization = :#{#organization}) " + diff --git a/src/main/java/com/vxnet/pms/service/DictService.java b/src/main/java/com/vxnet/pms/service/DictService.java index 7558570..1412862 100644 --- a/src/main/java/com/vxnet/pms/service/DictService.java +++ b/src/main/java/com/vxnet/pms/service/DictService.java @@ -48,7 +48,7 @@ public class DictService { .findById(id) .flatMap(dict -> dictRepository - .countChildren(dict.getNumber()) + .countChildren(dict.getOrganization(), dict.getNumber()) .flatMap(count -> { if (count > 0) { return Mono.error(new IllegalStateException("Cannot delete dict with children")); @@ -63,7 +63,7 @@ public class DictService { .findById(id) .flatMap(dict -> Mono.just(dict) - .zipWith(getChildren(dict.getNumber()).collectList()) + .zipWith(getChildren(dict.getOrganization(), dict.getNumber()).collectList()) .map(tuple -> { dict.setChildren(tuple.getT2()); return dict; @@ -83,7 +83,7 @@ public class DictService { .flatMapMany(rootDicts -> rootDicts.flatMap(rootDict -> Mono.just(rootDict) - .zipWith(getChildren(rootDict.getNumber()).collectList()) + .zipWith(getChildren(rootDict.getOrganization(), rootDict.getNumber()).collectList()) .map(tuple -> { rootDict.setChildren(tuple.getT2()); return rootDict; @@ -92,12 +92,12 @@ public class DictService { ); } - private Flux getChildren(String number) { + private Flux getChildren(String organization, String number) { return dictRepository - .findByParentNumber(number) + .findByParentNumber(organization, number) .flatMap(dict -> Mono.just(dict) - .zipWith(getChildren(dict.getNumber()).collectList()) + .zipWith(getChildren(dict.getOrganization(), dict.getNumber()).collectList()) .map(tuple -> { dict.setChildren(tuple.getT2()); return dict; diff --git a/src/main/webapp/app/entities/dict/dict-edit.component.ts b/src/main/webapp/app/entities/dict/dict-edit.component.ts index 7bd6a78..1be7b45 100644 --- a/src/main/webapp/app/entities/dict/dict-edit.component.ts +++ b/src/main/webapp/app/entities/dict/dict-edit.component.ts @@ -25,6 +25,7 @@ export default defineComponent({ property: '', remark: '', sortNo: 0, + status: '', version: 0, }); diff --git a/src/main/webapp/app/entities/dict/dict-edit.vue b/src/main/webapp/app/entities/dict/dict-edit.vue index 7033ec2..aa694e6 100644 --- a/src/main/webapp/app/entities/dict/dict-edit.vue +++ b/src/main/webapp/app/entities/dict/dict-edit.vue @@ -57,10 +57,17 @@
- - + + +
+
+ + +
+
+ +
-
diff --git a/src/main/webapp/app/entities/dict/dict.component.ts b/src/main/webapp/app/entities/dict/dict.component.ts index e7e2dbb..f1ab460 100644 --- a/src/main/webapp/app/entities/dict/dict.component.ts +++ b/src/main/webapp/app/entities/dict/dict.component.ts @@ -20,6 +20,14 @@ export default defineComponent({ const isFetching = ref(false); const dicts = ref([]); + const showFilter = ref(false); + const filterParams = ref({ + number: null, + name: null, + parentNumber: null, + status: null, + }); + const dict = ref({ id: null, number: '', @@ -43,52 +51,59 @@ export default defineComponent({ { label: t$('jewpmsApp.dict.number'), prop: 'number', - width: '120px', - minWidth: '100px', }, { label: t$('jewpmsApp.dict.name'), prop: 'name', - width: '150px', - minWidth: '120px', }, { label: t$('jewpmsApp.dict.property'), prop: 'property', - width: '200px', - minWidth: '150px', + }, + { + label: t$('jewpmsApp.dict.status'), + prop: 'status', }, { label: t$('jewpmsApp.dict.remark'), prop: 'remark', - width: '200px', - minWidth: '150px', }, { label: t$('jewpmsApp.dict.sortNo'), prop: 'sortNo', - width: '80px', - minWidth: '60px', }, { label: t$('entity.action.actions'), type: 'template', template: 'actions', - width: '120px', - fixed: 'right', }, ]; + const handleFilter = () => { + showFilter.value = !showFilter.value; + page.value = 1; // 重置页码 + handleSyncList(); + }; + const handleSyncList = async () => { isFetching.value = true; try { + const processedParams = showFilter.value + ? Object.entries(filterParams.value).reduce((acc, [key, value]) => { + acc[key] = value === '' ? null : value; + return acc; + }, {}) + : {}; + // 获取分页数据 const paginationQuery = { page: page.value - 1, size: itemsPerPage.value, sort: 'sortNo,asc', }; - const dictsRes = await axios.get(`api/dicts/tree?${buildPaginationQueryOpts(paginationQuery)}`); + const dictsRes = await axios.get(`api/dicts/tree?${buildPaginationQueryOpts(paginationQuery)}`, { + params: processedParams, + }); dicts.value = dictsRes.data; // 从响应头中获取总条数,如果响应头中没有,则使用数据长度作为总条数 const headerCount = dictsRes.headers['x-total-count']; @@ -127,14 +142,6 @@ export default defineComponent({ } }; - const goToCreate = () => { - router.push({ name: 'DictCreate' }); - }; - - const goToEdit = (row: any) => { - router.push({ name: 'DictEdit', params: { id: row.id } }); - }; - handleSyncList(); return { @@ -151,8 +158,9 @@ export default defineComponent({ handlePageChange, prepareDelete, deleteDict, - goToCreate, - goToEdit, + showFilter, + filterParams, + handleFilter, }; }, }); diff --git a/src/main/webapp/app/entities/dict/dict.vue b/src/main/webapp/app/entities/dict/dict.vue index 7213899..dfa7266 100644 --- a/src/main/webapp/app/entities/dict/dict.vue +++ b/src/main/webapp/app/entities/dict/dict.vue @@ -8,6 +8,10 @@
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
@@ -85,4 +111,5 @@ diff --git a/src/main/webapp/i18n/zh-cn/dict.json b/src/main/webapp/i18n/zh-cn/dict.json index 010c50d..d40f960 100644 --- a/src/main/webapp/i18n/zh-cn/dict.json +++ b/src/main/webapp/i18n/zh-cn/dict.json @@ -24,6 +24,7 @@ "value": "键值", "company": "所属公司", "property": "属性", + "status": "状态", "remark": "备注", "sortNo": "排序号", "createdBy": "创建人", diff --git a/src/main/webapp/i18n/zh-cn/global.json b/src/main/webapp/i18n/zh-cn/global.json index 475c7ef..ea478f4 100644 --- a/src/main/webapp/i18n/zh-cn/global.json +++ b/src/main/webapp/i18n/zh-cn/global.json @@ -118,7 +118,7 @@ "delete": "删除", "search": "搜索", "refresh": "刷新", - "filter": "过滤", + "filter": "筛选", "edit": "编辑", "open": "打开", "save": "保存",