From 82e27d0cadbddfc73e8b978e778b802dc8e51fa1 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期五, 29 三月 2024 10:51:36 +0800
Subject: [PATCH] 报工入参修改和工序ID修改

---
 src/views/dashboard/components/TaskControl.vue |  118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 112 insertions(+), 6 deletions(-)

diff --git a/src/views/dashboard/components/TaskControl.vue b/src/views/dashboard/components/TaskControl.vue
index ea82cb1..6967381 100644
--- a/src/views/dashboard/components/TaskControl.vue
+++ b/src/views/dashboard/components/TaskControl.vue
@@ -22,7 +22,20 @@
       </BigButton>
       <template v-if="task?.Procedure.Status === 2 || task?.Procedure.Status === 3">
         <BigButton class="btn" bg-color="#ff9933" :disabled="task?.Procedure.Status === 3">鎵撳嵃</BigButton>
-        <BigButton class="btn" bg-color="#00cc33" :disabled="task?.Procedure.Status === 3" @click="openReportModal">
+        <BigButton
+          v-if="task?.ShowCheck"
+          class="btn"
+          bg-color="#00cc33"
+          :disabled="task?.Procedure.Status === 3"
+          @click="openQualityModal"
+          >璐ㄦ</BigButton
+        >
+        <BigButton
+          class="btn"
+          :bg-color="task?.ShowCheck ? '#0066ff' : '#00cc33'"
+          :disabled="task?.Procedure.Status === 3"
+          @click="openReportModal"
+        >
           鎶ュ伐
         </BigButton>
         <el-popconfirm
@@ -47,10 +60,21 @@
   <TaskControlModal v-model="showTaskControlModal" :task="task" @produce-start="onProduceStart"></TaskControlModal>
   <ReportProductionModal
     v-model="showReportModal"
+    :model-title="modelTitle"
     :amount="plcInfo?.finishNumber ?? 0"
     @close="showReportModal = false"
     @submit="onReportProduction"
   ></ReportProductionModal>
+  <ReportProductionModal1
+    v-model="showReportModal1"
+    :model-title="modelTitle"
+    :amount="plcInfo?.finishNumber ?? 0"
+    :pass-amount="passAmount"
+    :rework-amount="reworkAmount"
+    :scrapped-amount="scrappedAmount"
+    @close="showReportModal1 = false"
+    @submit="onReportCheck"
+  ></ReportProductionModal1>
 </template>
 <script setup lang="ts">
 import type { Task, Worker } from '@/api/task'
@@ -59,9 +83,10 @@
 import { useDateFormat } from '@vueuse/core'
 import TaskControlModal from '@/views/dashboard/components/TaskControlModal.vue'
 import { CircleCloseFilled } from '@element-plus/icons-vue'
-import { apiReportWork, procedureUpdate } from '@/api'
+import { apiReportWork, procedureUpdate, bulletinReport, bulletinQualityInspection, getQualityInspection } from '@/api'
 import { ElMessage } from 'element-plus'
 import ReportProductionModal from '@/views/dashboard/components/ReportProductionModal.vue'
+import ReportProductionModal1 from '@/views/dashboard/components/ReportProductionModal1.vue'
 import { usePLCStore } from '@/stores/plc'
 import { storeToRefs } from 'pinia'
 
@@ -76,6 +101,10 @@
 }>()
 
 const showTaskControlModal = ref(false)
+const modelTitle = ref('')
+const passAmount = ref(0)
+const reworkAmount = ref(0)
+const scrappedAmount = ref(0)
 
 /**
  * 寮�濮嬬敓浜�
@@ -108,7 +137,7 @@
       isProcessing: false,
       workOrderProcedureID: Number(task!.value.Procedure.ID)
     }).then(
-      (res) => {
+      (res: any) => {
         ElMessage({
           message: '鎿嶄綔鎴愬姛锛�',
           type: 'success'
@@ -151,6 +180,10 @@
 const { plcInfo } = storeToRefs(plcStore)
 // 鎶ュ伐
 const showReportModal = ref(false)
+// 鎶ュ伐
+const showReportModal1 = ref(false)
+const reprotIds = ref([])
+const passCount = ref(0)
 function openReportModal() {
   // 鏈変汉鍛樻墠鍙互鎶ュ伐
   if (!workers.value || workers.value.length == 0) {
@@ -179,6 +212,39 @@
   }
 
   if (workers.value[0].workerId) {
+    modelTitle.value = '鐢熶骇鎶ュ伐'
+    if (task?.value?.ShowCheck) {
+      getQualityInspection({
+        procedureId: task.value?.Procedure?.procedure.procedureId,
+        workOrderId: task.value?.Order.workOrderId
+      }).then((res: any) => {
+        console.log(res, '999999')
+        passAmount.value = res.data.passAmount
+        passCount.value = res.data.passAmount
+        reworkAmount.value = res.data.reworkAmount
+        scrappedAmount.value = res.data.scrappedAmount
+        reprotIds.value = res.data.ids || []
+        showReportModal1.value = true
+      })
+    } else {
+      showReportModal.value = true
+    }
+  }
+}
+
+// 璐ㄦ
+function openQualityModal() {
+  // 鏈変汉鍛樻墠鍙互鎶ュ伐
+  if (!workers.value || workers.value.length == 0) {
+    ElMessage({
+      message: '娌℃湁浜哄憳淇℃伅涓嶅厑璁歌川妫�锛�',
+      type: 'error',
+      duration: 3000
+    })
+    return true
+  }
+  if (workers.value[0].workerId) {
+    modelTitle.value = '鎻愪氦璐ㄦ'
     showReportModal.value = true
   }
 }
@@ -193,20 +259,60 @@
   }
   // 鏈変汉鍛樻墠鍙互鎶ュ伐
   if (workers.value[0].workerId) {
-    apiReportWork({
+    let requestUrl = task?.value.ShowCheck ? bulletinQualityInspection : apiReportWork
+    let tipStr = task?.value.ShowCheck ? '璐ㄦ' : '鎶ュ伐'
+    requestUrl({
       workOrderProcedureID: Number(task.value?.Procedure.ID),
       reportAmount: amount,
       workerID: workers.value[0].workerId,
       workerName: workers.value[0].workerName
     })
-      .then((res) => {
+      .then((res: any) => {
+        if (res.code === 200) {
+          ElMessage({
+            message: `${tipStr}鎴愬姛`,
+            type: 'success',
+            duration: 2000
+          })
+          showReportModal.value = false
+        } else {
+          ElMessage({
+            message: `${tipStr}澶辫触`,
+            type: 'error',
+            duration: 3000
+          })
+        }
+      })
+      .catch((err) => {
+        console.error(err)
+      })
+  }
+}
+/**
+ * 璐ㄦ鍚庣殑涓婃姤鍔犲伐鏁�
+ * @param amount 鍔犲伐鏁�
+ */
+function onReportCheck(amount: number) {
+  if (!task?.value) {
+    return
+  }
+  // 鏈変汉鍛樻墠鍙互鎶ュ伐
+  if (workers.value[0].workerId) {
+    bulletinReport({
+      workOrderProcedureID: Number(task.value?.Procedure.ID),
+      reportAmount: passCount.value,
+      workerID: workers.value[0].workerId,
+      workerName: workers.value[0].workerName,
+      ids: reprotIds.value
+    })
+      .then((res: any) => {
         if (res.code === 200) {
           ElMessage({
             message: '鎶ュ伐鎴愬姛',
             type: 'success',
             duration: 2000
           })
-          showReportModal.value = false
+          showReportModal1.value = false
         } else {
           ElMessage({
             message: '鎶ュ伐澶辫触',

--
Gitblit v1.8.0