货位看板详情回退修复,删除幽灵卡片。
This commit is contained in:
@@ -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";
|
||||
|
||||
|
||||
// 自定义看板渲染器
|
||||
@@ -23,30 +23,45 @@ class CustomKanbanController extends KanbanController {
|
||||
this._onUpdate = (payload) => {
|
||||
this._handleSearchUpdate(payload);
|
||||
};
|
||||
|
||||
|
||||
this.env.services.user.updateContext({
|
||||
isBaseStyle: true
|
||||
});
|
||||
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) {
|
||||
@@ -60,7 +75,7 @@ class CustomKanbanController extends KanbanController {
|
||||
this.setKanbanStyle('sf_kanban_location_style');
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 加载所有货架的层数数据
|
||||
@@ -68,13 +83,13 @@ class CustomKanbanController extends KanbanController {
|
||||
this.shelfLayersMap = {};
|
||||
const shelfIds = await this.orm.search('sf.shelf', []);
|
||||
const shelves = await this.orm.read('sf.shelf', shelfIds, ['id', 'layer_capacity']);
|
||||
|
||||
|
||||
shelves.forEach(shelf => {
|
||||
this.shelfLayersMap[shelf.id] = shelf.layer_capacity;
|
||||
});
|
||||
}
|
||||
|
||||
setKanbanStyle(style){
|
||||
setKanbanStyle(style) {
|
||||
this.env.services.user.updateContext({
|
||||
isBaseStyle: style === 'sf_kanban_location_style'
|
||||
});
|
||||
@@ -88,10 +103,14 @@ class CustomKanbanController extends KanbanController {
|
||||
isHave = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 添加新类
|
||||
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) {
|
||||
@@ -111,7 +130,7 @@ class CustomKanbanController extends KanbanController {
|
||||
const [shelf] = await this.orm.read('sf.shelf', [shelfId], ['layer_capacity']);
|
||||
this.shelfLayersMap[shelfId] = shelf.layer_capacity;
|
||||
}
|
||||
|
||||
|
||||
// 获取该货架的层数
|
||||
const layerCapacity = this.shelfLayersMap[shelfId];
|
||||
// 根据层数设置不同的样式
|
||||
@@ -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);
|
||||
@@ -135,12 +154,12 @@ class CustomKanbanController extends KanbanController {
|
||||
getSystemDefaultLimit() {
|
||||
// 方法1:从用户服务获取默认值
|
||||
const userService = this.env.services.user;
|
||||
|
||||
|
||||
// 获取用户配置的默认分页大小
|
||||
if (userService && userService.user_context && userService.user_context.limit) {
|
||||
return userService.user_context.limit;
|
||||
}
|
||||
|
||||
|
||||
// 方法3:使用Odoo核心默认值(通常为80)
|
||||
return 80;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user