Compare commits

...
2 Commits
Author SHA1 Message Date
wc24 701ed957ef feat(role): 跳转带的 ?filter={_id} 在角色列表里自动选中那条
role 是自定义 master-detail 页(非 ShrimpTable、不做服务端过滤),原 onMounted 默认选第一个,
无视 relation 跳转带的 _id。现全量加载后按 URL filter._id 客户端选中目标角色,解析不出走默认。
2026-06-29 21:00:07 +08:00
wc24 0b75f8c6f2 fix(filter): 用户搜索/改筛选时清掉 relation 跳转的隐形 _id pin
跳转用 ?filter={_id} 锁单条,但 _id 不在筛选抽屉里、且抽屉 confirm 会把它原样带回,
导致用户再搜索/筛选时被看不见的 _id 一直 AND 着、结果莫名为空。
onSearch + handleFilterConfirm 现在都剥掉 _id(重置本就清空)。
2026-06-29 20:54:19 +08:00
3 changed files with 30 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "shrimp-admin", "name": "shrimp-admin",
"version": "0.3.4", "version": "0.3.6",
"private": true, "private": true,
"description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现", "description": "Shrimp 框架前端 — 消费 ShrimpServer + ShrimpTable 契约的经典 Vue3 + Element Plus 实现",
"main": "src/index.ts", "main": "src/index.ts",
+12 -1
View File
@@ -132,8 +132,18 @@ const {
const searchVisible = ref(false) const searchVisible = ref(false)
// relation 跳转用 ?filter={_id} 锁定单条;_id 是隐形 pin(不在筛选抽屉里),
// 用户一旦搜索/改筛选就清掉它,避免被看不见的 _id 一直 AND 着导致结果莫名为空
function stripJumpPin() {
if ('_id' in filterData.value) {
const { _id, ...rest } = filterData.value
filterData.value = rest
}
}
function onSearch() { function onSearch() {
searchKeyword.value = keyword.value searchKeyword.value = keyword.value
stripJumpPin()
currentPage.value = 1 currentPage.value = 1
refresh() refresh()
} }
@@ -151,7 +161,8 @@ const hasFilter = computed(() => {
}) })
async function handleFilterConfirm(newFilterData: Record<string, any>) { async function handleFilterConfirm(newFilterData: Record<string, any>) {
filterData.value = newFilterData const { _id, ...rest } = newFilterData // 确认筛选 → 丢弃跳转 pin
filterData.value = rest
currentPage.value = 1 currentPage.value = 1
await refresh() await refresh()
} }
+17 -1
View File
@@ -50,6 +50,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useRoute } from 'vue-router'
import { vueAdmin } from '../VueAdmin' import { vueAdmin } from '../VueAdmin'
import { IRole, IRoleProto, WithId, ILabel } from '../IShrimpType' import { IRole, IRoleProto, WithId, ILabel } from '../IShrimpType'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
@@ -61,12 +62,24 @@ interface IPowerItem {
} }
const { t } = useI18n() const { t } = useI18n()
const route = useRoute()
const props = defineProps<{ const props = defineProps<{
moduleKey: string moduleKey: string
events?: string[] events?: string[]
}>() }>()
// relation 跳转落到 role 页时带 ?filter={"_id":...}。role 是自定义 master-detail 页(非 ShrimpTable、
// 不做服务端过滤),全量加载后按这个 _id 在列表里选中那条;解析不出就走默认(选第一个)。
function jumpTargetId(): string {
try {
const f = route.query.filter ? JSON.parse(String(route.query.filter)) : null
return f && typeof f === 'object' ? String(f._id || '') : ''
} catch {
return ''
}
}
const roleApi = vueAdmin.getModule<IRoleProto>('role') const roleApi = vueAdmin.getModule<IRoleProto>('role')
const roleList = ref<WithId<IRole>[]>([]) const roleList = ref<WithId<IRole>[]>([])
@@ -138,7 +151,10 @@ async function handleDelete() {
onMounted(async () => { onMounted(async () => {
allPowers.value = await roleApi.allPower() allPowers.value = await roleApi.allPower()
await loadRoles() await loadRoles()
if (roleList.value.length > 0) { const jumpId = jumpTargetId()
if (jumpId && roleList.value.some(r => r._id === jumpId)) {
onSelect(jumpId)
} else if (roleList.value.length > 0) {
onSelect(roleList.value[0]._id) onSelect(roleList.value[0]._id)
} }
}) })