From 889d8ddf4c13c1b1bdbabd04c2d80b904020151e Mon Sep 17 00:00:00 2001
From: hsy <1029150275@qq.com>
Date: 星期三, 19 八月 2026 12:49:24 +0800
Subject: [PATCH] 生产订单与报工模块改造汇总 (Git Commit 文档) feat(mes-pro): 生产订单及报工模块审批流与批次填报改造 1. 生产订单功能增强 (Work Order)
---
src/views/mes/workbench/index.vue | 97 +++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 87 insertions(+), 10 deletions(-)
diff --git a/src/views/mes/workbench/index.vue b/src/views/mes/workbench/index.vue
index 2d9072b..3661475 100644
--- a/src/views/mes/workbench/index.vue
+++ b/src/views/mes/workbench/index.vue
@@ -2,14 +2,22 @@
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
import type { PendingTask, WorkbenchTabItem, WorkbenchTabKey } from './types';
-import { computed, ref, watch } from 'vue';
+import { computed, onMounted, ref, watch } from 'vue';
+import { confirm } from '@vben/common-ui';
+import { MesProWorkRecordTypeEnum } from '@vben/constants';
import { IconifyIcon } from '@vben/icons';
-import { Button } from 'ant-design-vue';
+import { Button, message } from 'ant-design-vue';
+import {
+ clockInWorkRecord,
+ clockOutWorkRecord,
+ getMyWorkRecord,
+} 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';
@@ -26,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 },
);
// --- 宸ヤ綔绔� ---
@@ -51,6 +79,43 @@
function handleWorkstationSelect(ws: MesMdWorkstationApi.Workstation) {
workstation.value = ws;
}
+
+// --- 涓婂伐/涓嬪伐 ---
+const isClockIn = ref(false);
+
+async function loadClockStatus() {
+ const record = await getMyWorkRecord();
+ isClockIn.value = record?.type === MesProWorkRecordTypeEnum.CLOCK_IN;
+}
+
+/** 涓婂伐锛氶粯璁や娇鐢ㄥ綋鍓嶉�変腑鐨勫伐浣滅珯锛屽脊绐楃‘璁� */
+async function handleClockIn() {
+ if (!workstationId.value) return;
+ try {
+ await confirm(
+ `纭涓婂伐鍒板綋鍓嶅伐浣滅珯銆�${workstation.value?.code} - ${workstation.value?.name}銆嶏紵`,
+ );
+ } catch {
+ return;
+ }
+ await clockInWorkRecord(workstationId.value);
+ message.success('涓婂伐鎴愬姛');
+ isClockIn.value = true;
+}
+
+/** 涓嬪伐 */
+async function handleClockOut() {
+ try {
+ await confirm('纭涓嬪伐褰撳墠宸ヤ綔绔欙紵');
+ } catch {
+ return;
+ }
+ await clockOutWorkRecord();
+ message.success('涓嬪伐鎴愬姛');
+ isClockIn.value = false;
+}
+
+onMounted(loadClockStatus);
// --- 浠诲姟鍒楄〃 ---
const taskList = ref<PendingTask[]>([]);
@@ -132,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"
@@ -159,7 +224,10 @@
<!-- 宸ヤ綔绔欓�夋嫨闈㈡澘 -->
<WorkstationPanel
:workstation="workstation"
+ :is-clock-in="isClockIn"
@change="openWorkstationSelect"
+ @clock-in="handleClockIn"
+ @clock-out="handleClockOut"
/>
<!-- 宸ュ崟鍒楄〃 -->
@@ -167,8 +235,8 @@
:list="taskList"
:selected-id="selectedTask?.id"
:loading="taskLoading"
- :process-name="workstation?.processName"
@select="handleSelectTask"
+ @refresh="loadTaskList"
/>
</aside>
@@ -181,8 +249,8 @@
<main class="workbench-main">
<div class="workbench-main__head">
<span class="workbench-main__tab-title">{{ activeTabLabel }}</span>
- <span v-if="selectedTask?.workOrderCode" class="workbench-main__context">
- 宸ュ崟 {{ selectedTask.workOrderCode }}
+ <span v-if="selectedTask?.code" class="workbench-main__context">
+ 宸ュ崟 {{ selectedTask.code }}
</span>
</div>
<div class="workbench-main__body">
@@ -204,16 +272,25 @@
/>
<RecordParamTab
v-else-if="activeTab === 'record-param'"
- :work-order-id="selectedTask?.workOrderId"
+ :task-id="selectedTask?.id"
+ :work-order-id="selectedTask?.id"
:workstation-id="workstationId"
/>
<ProductIssueTab
v-else-if="activeTab === 'product-issue'"
+ :task-id="selectedTask?.id"
+ :task-code="selectedTask?.code"
+ :task-name="selectedTask?.name"
+ :work-order-id="selectedTask?.workOrderId"
:workstation-id="workstationId"
:workstation-name="workstationName"
/>
<ReturnIssueTab
v-else-if="activeTab === 'return-issue'"
+ :task-id="selectedTask?.id"
+ :task-code="selectedTask?.code"
+ :task-name="selectedTask?.name"
+ :work-order-id="selectedTask?.workOrderId"
:workstation-id="workstationId"
:workstation-name="workstationName"
/>
--
Gitblit v1.9.3