fix: 以图搜图跳转物料页面用 watch 接管查询,防止 URL 参数残留
This commit is contained in:
@ -642,7 +642,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, nextTick, computed } from 'vue';
|
import { ref, reactive, onMounted, nextTick, computed, watch } from 'vue';
|
||||||
import { Plus, Document, Refresh, Setting, Rank, Camera, Link, Download, Bell, CircleCheck, Files, ZoomIn, Delete, Picture } from '@element-plus/icons-vue';
|
import { Plus, Document, Refresh, Setting, Rank, Camera, Link, Download, Bell, CircleCheck, Files, ZoomIn, Delete, Picture } from '@element-plus/icons-vue';
|
||||||
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus';
|
import { ElMessage, ElMessageBox, ElLoading } from 'element-plus';
|
||||||
import type { FormInstance, FormRules } from 'element-plus';
|
import type { FormInstance, FormRules } from 'element-plus';
|
||||||
@ -1736,17 +1736,27 @@ const resetAdvancedFilter = () => {
|
|||||||
getList();
|
getList();
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
// 以图搜图跳转:监听路由 keyword 参数,自动搜索并清理 URL
|
||||||
// 1. 修复背景联动:直接对 reactive 对象赋值
|
watch(
|
||||||
if (route.query.keyword) {
|
() => route.query.keyword,
|
||||||
queryParams.keyword = route.query.keyword as string;
|
(newKeyword) => {
|
||||||
|
if (newKeyword) {
|
||||||
|
queryParams.keyword = newKeyword as string;
|
||||||
queryParams.searchField = 'all';
|
queryParams.searchField = 'all';
|
||||||
}
|
|
||||||
|
|
||||||
// 先根据权限初始化列显示状态
|
|
||||||
initColumnPermissions();
|
|
||||||
// 此时 getList 会带着正确的 keyword 向后端请求过滤后的数据
|
|
||||||
getList();
|
getList();
|
||||||
|
// 清理 URL 参数,防止刷新后重复触发搜索
|
||||||
|
router.replace({ path: route.path, query: {} });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initColumnPermissions();
|
||||||
|
// 无外部 keyword 参数时执行默认查询;有 keyword 则由上方的 watch 接管
|
||||||
|
if (!route.query.keyword) {
|
||||||
|
getList();
|
||||||
|
}
|
||||||
getOptionsList();
|
getOptionsList();
|
||||||
|
|
||||||
// 2. 修复弹窗锁定逻辑
|
// 2. 修复弹窗锁定逻辑
|
||||||
|
|||||||
Reference in New Issue
Block a user