货位看板详情回退修复,删除幽灵卡片。

This commit is contained in:
huziyang@jikimo.com
2025-06-12 15:38:56 +08:00
parent 23dd88b7ba
commit 6321e7ef23

View File

@@ -5,7 +5,7 @@ import { KanbanRenderer } from "@web/views/kanban/kanban_renderer";
import { kanbanView } from "@web/views/kanban/kanban_view";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { useState, onWillStart,onWillUnmount,onMounted } from "@odoo/owl";
import { useState, onWillStart, onWillUnmount, onMounted } from "@odoo/owl";
// 自定义看板渲染器
@@ -30,23 +30,38 @@ class CustomKanbanController extends KanbanController {
let self = this;
// 获取货架分层数据
onWillStart(async () => {
this.searchModel.on('update',self,self._onUpdate);
this.searchModel.on('update', self, self._onUpdate);
await this.loadShelfLayersData();
});
// 组件销毁时移除监听
onWillUnmount(() => {
this.searchModel.off('update',self,self._onUpdate);
this.searchModel.off('update', self, self._onUpdate);
});
// 监听视图切换事件以监控面包屑
onMounted(() => {
this.handleRouteChange()
});
}
handleRouteChange() {
this.render(true);
let domain = this.searchModel.domain;
if (domain.length > 0) {
let shelfDomain = domain.find(item => item[0] === 'shelf_id');
this.onShelfChange(shelfDomain[2]);
} else {
this.setKanbanStyle('sf_kanban_location_style');
}
}
_handleSearchUpdate() {
try {
let domain = this.searchModel.domain;
if(domain.length > 0){
if (domain.length > 0) {
let shelfDomain = domain.find(item => item[0] === 'shelf_id');
if(shelfDomain){
if (shelfDomain) {
let shelfId = shelfDomain[2];
// 如果货架ID存在则设置相应的样式
if (shelfId) {
@@ -74,7 +89,7 @@ class CustomKanbanController extends KanbanController {
});
}
setKanbanStyle(style){
setKanbanStyle(style) {
this.env.services.user.updateContext({
isBaseStyle: style === 'sf_kanban_location_style'
});
@@ -90,8 +105,12 @@ class CustomKanbanController extends KanbanController {
});
// 添加新类
if(isHave)kanbanViewEl.classList.add(style);
if (isHave) kanbanViewEl.classList.add(style);
}
const ghostCards = document.querySelectorAll('.o_kanban_ghost');
ghostCards.forEach(card => {
card.remove();
});
}
updatePagerLimit(limit) {
@@ -120,10 +139,10 @@ class CustomKanbanController extends KanbanController {
isBaseStyle = false;
}
}
if(isBaseStyle){
if (isBaseStyle) {
this.updatePagerLimit(this.defaultPagerLimit);
}
else{
else {
this.updatePagerLimit(500);
}
this.setKanbanStyle(style);