mirror of https://gitee.com/xiaonuobase/snowy
【更新】字典功能被选中后列表包含自己,且自动区分上下级
parent
18ee9d4ec8
commit
3e28c838ee
|
@ -31,7 +31,7 @@
|
|||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
<a-divider class="m-3 mx-0"/>
|
||||
<a-divider class="m-3 mx-0" />
|
||||
<s-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
|
@ -48,6 +48,10 @@
|
|||
</a-button>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'level'">
|
||||
<a-tag color="blue" v-if="record.level">{{ record.level }}</a-tag>
|
||||
<a-tag color="green" v-else>子级</a-tag>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a @click="form.onOpen(record, 'BIZ')">编辑</a>
|
||||
<a-divider type="vertical" />
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
<a-divider class="m-3 mx-0"/>
|
||||
<a-divider class="m-3 mx-0" />
|
||||
<s-table
|
||||
ref="table"
|
||||
:columns="columns"
|
||||
|
@ -48,8 +48,9 @@
|
|||
</a-button>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'category'">
|
||||
{{ $TOOL.dictTypeData('DICT_CATEGORY', record.category) }}
|
||||
<template v-if="column.dataIndex === 'level'">
|
||||
<a-tag color="blue" v-if="record.level">{{ record.level }}</a-tag>
|
||||
<a-tag color="green" v-else>子级</a-tag>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a @click="form.onOpen(record, 'FRM')">编辑</a>
|
||||
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -63,7 +63,8 @@ public class DevDictServiceImpl extends ServiceImpl<DevDictMapper, DevDict> 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());
|
||||
|
|
Loading…
Reference in New Issue