From 3e28c838ee9232072e2b31fd3ef3b07830e4fd9f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E8=AF=BA?= <1253070437@qq.com>
Date: Fri, 14 Apr 2023 00:25:35 +0800
Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=9B=B4=E6=96=B0=E3=80=91=E5=AD=97?=
=?UTF-8?q?=E5=85=B8=E5=8A=9F=E8=83=BD=E8=A2=AB=E9=80=89=E4=B8=AD=E5=90=8E?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8C=85=E5=90=AB=E8=87=AA=E5=B7=B1=EF=BC=8C?=
=?UTF-8?q?=E4=B8=94=E8=87=AA=E5=8A=A8=E5=8C=BA=E5=88=86=E4=B8=8A=E4=B8=8B?=
=?UTF-8?q?=E7=BA=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/views/dev/dict/category/bizIndex.vue | 43 +++++++++++++++--
.../src/views/dev/dict/category/frmIndex.vue | 46 +++++++++++++++----
.../dict/service/impl/DevDictServiceImpl.java | 3 +-
3 files changed, 78 insertions(+), 14 deletions(-)
diff --git a/snowy-admin-web/src/views/dev/dict/category/bizIndex.vue b/snowy-admin-web/src/views/dev/dict/category/bizIndex.vue
index 8bb02bbd..58c5d19e 100644
--- a/snowy-admin-web/src/views/dev/dict/category/bizIndex.vue
+++ b/snowy-admin-web/src/views/dev/dict/category/bizIndex.vue
@@ -31,7 +31,7 @@
-
+
+
+ {{ record.level }}
+ 子级
+
编辑
@@ -70,11 +74,13 @@
const columns = [
{
title: '字典名称',
- dataIndex: 'dictLabel'
+ dataIndex: 'dictLabel',
+ width: 350
},
{
title: '字典值',
- dataIndex: 'dictValue'
+ dataIndex: 'dictValue',
+ width: 350
},
{
title: '排序',
@@ -103,8 +109,27 @@
const loadData = (parameter) => {
loadTreeData()
parameter.category = 'BIZ'
- return dictApi.dictPage(Object.assign(parameter, searchFormState)).then((res) => {
- return res
+ return dictApi.dictPage(Object.assign(parameter, searchFormState)).then((data) => {
+ if (data.records) {
+ if (searchFormState.parentId) {
+ let dataArray = []
+ data.records.forEach((item) => {
+ const obj = data.records.find((f) => f.id === item.parentId)
+ if (!obj) {
+ dataArray.push(item)
+ }
+ })
+ if (dataArray.length === 1) {
+ data.records.forEach((item) => {
+ if (item.id === dataArray[0].id) {
+ item.level = '上级'
+ }
+ })
+ }
+ dataArray = []
+ }
+ }
+ return data
})
}
// 重置
@@ -127,8 +152,16 @@
const treeSelect = (selectedKeys) => {
if (selectedKeys && selectedKeys.length > 0) {
searchFormState.parentId = selectedKeys.toString()
+ if (!columns.find((f) => f.title === '层级')) {
+ columns.splice(2, 0, {
+ title: '层级',
+ dataIndex: 'level',
+ width: 100
+ })
+ }
} else {
delete searchFormState.parentId
+ columns.splice(2, 1)
}
table.value.refresh(true)
}
diff --git a/snowy-admin-web/src/views/dev/dict/category/frmIndex.vue b/snowy-admin-web/src/views/dev/dict/category/frmIndex.vue
index b62685d0..80eee097 100644
--- a/snowy-admin-web/src/views/dev/dict/category/frmIndex.vue
+++ b/snowy-admin-web/src/views/dev/dict/category/frmIndex.vue
@@ -31,7 +31,7 @@
-
+
-
- {{ $TOOL.dictTypeData('DICT_CATEGORY', record.category) }}
+
+ {{ record.level }}
+ 子级
编辑
@@ -66,14 +67,17 @@
import dictApi from '@/api/dev/dictApi'
import Form from './form.vue'
const { proxy } = getCurrentInstance()
+ let searchFormState = reactive({})
const columns = [
{
title: '字典名称',
- dataIndex: 'dictLabel'
+ dataIndex: 'dictLabel',
+ width: 350
},
{
title: '字典值',
- dataIndex: 'dictValue'
+ dataIndex: 'dictValue',
+ width: 350
},
{
title: '排序',
@@ -90,7 +94,6 @@
const table = ref(null)
const form = ref()
const searchFormRef = ref()
- let searchFormState = reactive({})
// 默认展开的节点
let defaultExpandedKeys = ref([])
const treeData = ref([])
@@ -102,8 +105,27 @@
const loadData = (parameter) => {
loadTreeData()
parameter.category = 'FRM'
- return dictApi.dictPage(Object.assign(parameter, searchFormState)).then((res) => {
- return res
+ return dictApi.dictPage(Object.assign(parameter, searchFormState)).then((data) => {
+ if (data.records) {
+ if (searchFormState.parentId) {
+ let dataArray = []
+ data.records.forEach((item) => {
+ const obj = data.records.find((f) => f.id === item.parentId)
+ if (!obj) {
+ dataArray.push(item)
+ }
+ })
+ if (dataArray.length === 1) {
+ data.records.forEach((item) => {
+ if (item.id === dataArray[0].id) {
+ item.level = '上级'
+ }
+ })
+ }
+ dataArray = []
+ }
+ }
+ return data
})
}
// 重置
@@ -126,8 +148,16 @@
const treeSelect = (selectedKeys) => {
if (selectedKeys && selectedKeys.length > 0) {
searchFormState.parentId = selectedKeys.toString()
+ if (!columns.find((f) => f.title === '层级')) {
+ columns.splice(2, 0, {
+ title: '层级',
+ dataIndex: 'level',
+ width: 100
+ })
+ }
} else {
delete searchFormState.parentId
+ columns.splice(2, 1)
}
table.value.refresh(true)
}
diff --git a/snowy-plugin/snowy-plugin-dev/src/main/java/vip/xiaonuo/dev/modular/dict/service/impl/DevDictServiceImpl.java b/snowy-plugin/snowy-plugin-dev/src/main/java/vip/xiaonuo/dev/modular/dict/service/impl/DevDictServiceImpl.java
index 059ee9ae..bca9f044 100644
--- a/snowy-plugin/snowy-plugin-dev/src/main/java/vip/xiaonuo/dev/modular/dict/service/impl/DevDictServiceImpl.java
+++ b/snowy-plugin/snowy-plugin-dev/src/main/java/vip/xiaonuo/dev/modular/dict/service/impl/DevDictServiceImpl.java
@@ -63,7 +63,8 @@ public class DevDictServiceImpl extends ServiceImpl impl
queryWrapper.lambda().select(DevDict::getId, DevDict::getParentId, DevDict::getCategory, DevDict::getDictLabel,
DevDict::getDictValue, DevDict::getSortCode);
if (ObjectUtil.isNotEmpty(devDictPageParam.getParentId())) {
- queryWrapper.lambda().eq(DevDict::getParentId, devDictPageParam.getParentId());
+ queryWrapper.lambda().eq(DevDict::getParentId, devDictPageParam.getParentId())
+ .or().eq(DevDict::getId, devDictPageParam.getParentId());
}
if (ObjectUtil.isNotEmpty(devDictPageParam.getCategory())) {
queryWrapper.lambda().eq(DevDict::getCategory, devDictPageParam.getCategory());