src/views/mes/workbench/index.vue
@@ -17,6 +17,7 @@
} from '#/api/mes/pro/workrecord';
import { getPendingFeedbackPage } from '#/api/mes/pro/task';
import { router } from '#/router';
import { useAccess } from '@vben/access';
import TaskListPanel from './components/TaskListPanel.vue';
import WorkstationPanel from './components/WorkstationPanel.vue';
@@ -33,16 +34,36 @@
// --- Tab 配置 ---
const tabItems: WorkbenchTabItem[] = [
  { key: 'detail', label: '工单详情', icon: 'lucide:file-text' },
  { key: 'feedback', label: '报工', icon: 'lucide:edit-3' },
  { key: 'history', label: '报工记录', icon: 'lucide:history' },
  { key: 'feedback', label: '报工', icon: 'lucide:edit-3', auth: ['mes:pro-feedback:create'] },
  { key: 'history', label: '报工记录', icon: 'lucide:history' ,auth: ['mes:pro-feedback:query']},
  { key: 'record-param', label: '生产记录参数', icon: 'lucide:file-cog' },
  { key: 'product-issue', label: '领料', icon: 'lucide:clipboard-list' },
  { key: 'return-issue', label: '退料', icon: 'lucide:rotate-ccw' },
];
const { hasAccessByCodes } = useAccess();
const availableTabs = computed(() => {
  return tabItems.filter((tab) => {
    if (!tab.auth || tab.auth.length === 0) return true;
    return hasAccessByCodes(tab.auth);
  });
});
const activeTab = ref<WorkbenchTabKey>('detail');
const activeTabLabel = computed(
  () => tabItems.find((t) => t.key === activeTab.value)?.label ?? '',
  () => availableTabs.value.find((t) => t.key === activeTab.value)?.label ?? '',
);
// 当可用 tab 变化时,如果当前选中的 tab 不可用,则自动选择第一个可用的 tab
watch(
  availableTabs,
  (tabs) => {
    if (tabs.length > 0 && !tabs.find((t) => t.key === activeTab.value)) {
      activeTab.value = tabs[0]!.key;
    }
  },
  { immediate: true },
);
// --- 工作站 ---
@@ -176,7 +197,7 @@
      <nav class="workbench-nav">
        <button
          v-for="tab in tabItems"
          v-for="tab in availableTabs"
          :key="tab.key"
          type="button"
          class="workbench-nav__item"