Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bba08dadcc | ||
|
|
701ed957ef | ||
|
|
0b75f8c6f2 |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "shrimp-admin",
|
"name": "shrimp-admin",
|
||||||
"version": "0.3.4",
|
"version": "0.3.7",
|
||||||
"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",
|
||||||
|
|||||||
@@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
/>
|
/>
|
||||||
<el-date-picker v-else :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" :disabled="disabled"
|
<el-date-picker v-else :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" :disabled="disabled"
|
||||||
type="datetime" style="width: 100%" />
|
type="datetime" :clearable="!field.required" style="width: 100%" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
>
|
>
|
||||||
<el-option v-for="opt in options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
<el-option v-for="opt in options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
<el-select v-else :model-value="stringValue" @update:model-value="$emit('update:modelValue', $event)" :disabled="disabled" :multiple="field.multiple" filterable remote :remote-method="onSearch" :loading="loading" style="width: 100%">
|
<el-select v-else :model-value="stringValue" @update:model-value="onEdit" :disabled="disabled" :multiple="field.multiple" :clearable="!field.required" filterable remote :remote-method="onSearch" :loading="loading" style="width: 100%">
|
||||||
<el-option v-for="opt in options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
<el-option v-for="opt in options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
@@ -35,10 +35,15 @@ const props = defineProps<{
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineEmits<{
|
const emit = defineEmits<{
|
||||||
'update:modelValue': [value: any]
|
'update:modelValue': [value: any]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
// 编辑态清空:el-select 单选清空发 '',但 relation 是 ObjectId,存 '' 会 cast 报错 → 归一成 null(取消关联)
|
||||||
|
function onEdit(v: any) {
|
||||||
|
emit('update:modelValue', v === '' ? null : v)
|
||||||
|
}
|
||||||
|
|
||||||
const options = ref<{ label: string; value: string }[]>([])
|
const options = ref<{ label: string; value: string }[]>([])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
@update:model-value="$emit('update:modelValue', $event)"
|
@update:model-value="$emit('update:modelValue', $event)"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:multiple="field.multiple"
|
:multiple="field.multiple"
|
||||||
|
:clearable="!field.required"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<el-option v-for="opt in resolvedOptions" :key="opt.value" :label="vueAdmin.t(opt.label)" :value="opt.value" />
|
<el-option v-for="opt in resolvedOptions" :key="opt.value" :label="vueAdmin.t(opt.label)" :value="opt.value" />
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
<el-input v-model="inputValue" @keyup.enter="addTag" @blur="addTag" :placeholder="$t('base.pressEnter')" />
|
<el-input v-model="inputValue" @keyup.enter="addTag" @blur="addTag" :placeholder="$t('base.pressEnter')" />
|
||||||
</div>
|
</div>
|
||||||
<el-input v-else :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" :disabled="disabled" clearable />
|
<el-input v-else :model-value="modelValue" @update:model-value="$emit('update:modelValue', $event)" :disabled="disabled" :clearable="!field.required" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
:model-value="modelValue"
|
:model-value="modelValue"
|
||||||
@update:model-value="$emit('update:modelValue', $event)"
|
@update:model-value="$emit('update:modelValue', $event)"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
clearable
|
:clearable="!field.required"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
+17
-1
@@ -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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user