m0_70156489 1 month ago
parent
commit
9e636a8e10
2 changed files with 150 additions and 4 deletions
  1. 114 2
      src/view/SalaryManage/SalaryList.vue
  2. 36 2
      src/view/performance/chafengbaogong.vue

+ 114 - 2
src/view/SalaryManage/SalaryList.vue

@@ -282,7 +282,7 @@
             />
           </template>
         </el-table-column>
-        <el-table-column label="工序编号" prop="工序编号" width="90" align="center" />
+        <el-table-column label="工序号" prop="工序编号" width="90" align="center" />
         <el-table-column label="工序名称" prop="工序名称" min-width="280"/>
         <el-table-column label="小组" prop="设备编号" width="105" align="center">
           <template #header>
@@ -316,9 +316,10 @@
         <el-table-column label="标准工时(秒)" prop="标准工时" width="120" align="center" />
         <el-table-column label="标准总工时(秒)" prop="生产工时" width="150" align="center" />
         <!-- <el-table-column label="生产总工分" prop="生产分数" width="100" align="center" /> -->
-        <el-table-column label="操作" width="90" align="center" fixed="right">
+        <el-table-column label="操作" width="140" align="center" fixed="right">
           <template #default="{ row }">
             <el-button type="primary" link size="small" @click="openEditQty(row)">修改</el-button>
+            <el-button type="danger" link size="small" @click="deleteReportingWork(row)">删除</el-button>
           </template>
         </el-table-column>
 
@@ -339,10 +340,16 @@
       title="修改数量"
       width="420px"
       append-to-body
+      align-center
       destroy-on-close
       :close-on-click-modal="false"
+      modal-class="salary-action-dialog-modal"
+      class="salary-action-dialog"
     >
       <el-form label-width="88px">
+        <el-form-item label="工序号">
+          <el-input :model-value="editQtyForm.工序号" disabled />
+        </el-form-item>
         <el-form-item label="工序名称">
           <el-input :model-value="editQtyForm.工序名称" disabled />
         </el-form-item>
@@ -362,6 +369,36 @@
         <el-button type="primary" :loading="editQtyLoading" @click="submitEditQty">确定</el-button>
       </template>
     </el-dialog>
+
+    <!-- 删除确认 -->
+    <el-dialog
+      v-model="deleteConfirmVisible"
+      title="提示"
+      width="420px"
+      append-to-body
+      align-center
+      destroy-on-close
+      :close-on-click-modal="false"
+      modal-class="salary-action-dialog-modal"
+      class="salary-action-dialog"
+    >
+      <div class="salary-delete-msg">
+        <div>确定要删除这条报工记录吗?</div>
+        <div class="salary-delete-msg__row">
+          工序号:<strong>{{ deleteConfirmForm.工序号 }}</strong>
+        </div>
+        <div class="salary-delete-msg__row">
+          工序名称:<strong>{{ deleteConfirmForm.工序名称 }}</strong>
+        </div>
+        <div class="salary-delete-msg__row">
+          数量:<strong>{{ deleteConfirmForm.数量 }}</strong>
+        </div>
+      </div>
+      <template #footer>
+        <el-button @click="deleteConfirmVisible = false">取消</el-button>
+        <el-button type="danger" :loading="deleteLoading" @click="confirmDeleteReportingWork">确定</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -374,6 +411,7 @@ import {
   GetStaffSalaryList,
   GetStaffSalaryDetail,
   UpdateReportingWork,
+  DeleteReportingWork,
 } from '@/api/mes/job'
 import ProcessProduction from '@/view/SalaryManage/ProcessProduction.vue'
 import TableColumnFilterHeader from '@/view/SalaryManage/TableColumnFilterHeader.vue'
@@ -1273,6 +1311,7 @@ const editQtyLoading = ref(false)
 const editQtyForm = ref({
   id: '',
   number: '',
+  工序号: '',
   工序名称: '',
   标准工时: '',
   标准分数: '',
@@ -1280,6 +1319,15 @@ const editQtyForm = ref({
   生产分数: '',
 })
 
+const deleteConfirmVisible = ref(false)
+const deleteLoading = ref(false)
+const deleteConfirmForm = ref({
+  id: '',
+  工序号: '-',
+  工序名称: '-',
+  数量: '-',
+})
+
 function openEditQty(row) {
   const id = row?.id ?? row?.ID
   if (id === undefined || id === null || id === '') {
@@ -1289,6 +1337,7 @@ function openEditQty(row) {
   editQtyForm.value = {
     id,
     number: String(row['数量'] ?? ''),
+    工序号: String(row['工序编号'] ?? row['工序号'] ?? row.process_code ?? ''),
     工序名称: String(row['工序名称'] ?? ''),
     标准工时: row['标准工时'],
     标准分数: row['标准分数'],
@@ -1298,6 +1347,46 @@ function openEditQty(row) {
   editQtyVisible.value = true
 }
 
+function deleteReportingWork(row) {
+  const deleteId = row?.id ?? row?.ID
+  if (deleteId === undefined || deleteId === null || deleteId === '') {
+    ElMessage.warning('缺少报工记录ID,无法删除')
+    return
+  }
+  deleteConfirmForm.value = {
+    id: deleteId,
+    工序号: String(row['工序编号'] ?? row['工序号'] ?? row.process_code ?? '') || '-',
+    工序名称: String(row['工序名称'] ?? row.process_name ?? '') || '-',
+    数量: String(row['数量'] ?? row.number ?? '') || '-',
+  }
+  deleteConfirmVisible.value = true
+}
+
+async function confirmDeleteReportingWork() {
+  const deleteId = deleteConfirmForm.value.id
+  if (deleteId === undefined || deleteId === null || deleteId === '') {
+    ElMessage.warning('缺少报工记录ID,无法删除')
+    return
+  }
+  deleteLoading.value = true
+  try {
+    const response = await DeleteReportingWork({ id: deleteId })
+    if (response.code === 0) {
+      ElMessage.success(response.msg || '删除成功')
+      deleteConfirmVisible.value = false
+      await loadDetailRows()
+      if (hasQueryCondition.value) await loadStaffList()
+    } else {
+      ElMessage.error(response.msg || '删除失败')
+    }
+  } catch (error) {
+    console.error('删除报工记录失败:', error)
+    ElMessage.error(error?.response?.data?.msg || error?.message || '删除失败')
+  } finally {
+    deleteLoading.value = false
+  }
+}
+
 async function submitEditQty() {
   const numberStr = String(editQtyForm.value.number ?? '').trim()
   const qty = Number(numberStr)
@@ -1348,6 +1437,7 @@ async function submitEditQty() {
 function onDetailClosed() {
   detailRowsAll.value = []
   editQtyVisible.value = false
+  deleteConfirmVisible.value = false
   detailOrderNoFilterCtrl.clear()
   detailStyleNoFilterCtrl.clear()
   detailProductNameFilterCtrl.clear()
@@ -1699,4 +1789,26 @@ onMounted(() => {
   min-width: 56px;
   font-weight: 500;
 }
+
+/* 修改/删除:固定居中,避免默认 15vh 与 MessageBox 位置不一致 */
+.salary-action-dialog-modal .el-overlay-dialog {
+  display: flex !important;
+  align-items: center !important;
+  justify-content: center !important;
+}
+.salary-action-dialog.el-dialog {
+  margin: 0 !important;
+  --el-dialog-margin-top: 0;
+}
+.salary-delete-msg {
+  line-height: 1.7;
+  color: var(--el-text-color-regular);
+}
+.salary-delete-msg__row {
+  margin-top: 6px;
+}
+.salary-delete-msg__row strong {
+  color: #f56c6c;
+  font-weight: 600;
+}
 </style>

+ 36 - 2
src/view/performance/chafengbaogong.vue

@@ -236,6 +236,13 @@
 								</el-button>
 							</template>
 						</el-table-column>
+
+						<!-- 包数:当天报工序号,按报工时间从早到晚 1、2、3... -->
+						<el-table-column align="center" label="包数" width="80">
+							<template #default="scope">
+								{{ scope.row.包数 ?? '—' }}
+							</template>
+						</el-table-column>
 					
 						<!-- 报工时间 -->
 						<el-table-column align="center" label="报工时间" prop="sys_rq" width="150" />
@@ -623,6 +630,33 @@ const showPdf = async (row) => {
 
 	//历史记录表格
 	const add_tableData = reactive([]);
+
+/** 包数按自然日独立编号:每天从 1 开始;合计行不参与编号 */
+const isReportHistoryRow = (row) => !!(row?.sys_rq && row?.组别 && row?.serial)
+const assignDailyBagNo = (records) => {
+	const list = Array.isArray(records) ? records : []
+	const byDay = new Map()
+	list.forEach((row, i) => {
+		if (!isReportHistoryRow(row)) {
+			row.包数 = ''
+			return
+		}
+		const raw = String(row?.sys_rq ?? '')
+		const day = raw.slice(0, 10) || 'unknown'
+		const t = Date.parse(raw.replace(/-/g, '/')) || 0
+		if (!byDay.has(day)) byDay.set(day, [])
+		byDay.get(day).push({ row, i, t })
+	})
+	byDay.forEach((items) => {
+		items.sort((a, b) => a.t - b.t || a.i - b.i)
+		items.forEach((item, idx) => {
+			item.row.包数 = idx + 1
+		})
+	})
+	return list
+}
+
+
 	//全局获取颜色款式款号
 	const _yskskh = ref('')
 	//全局获取新增流水号
@@ -678,7 +712,7 @@ const showPdf = async (row) => {
 			}
 			// console.log(getSpotLists)
 			sizeDatas.splice(0, getSpotLists.data.headers.length, ...getSpotLists.data.headers); //型号数据
-			add_tableData.splice(0, add_tableData.length, ...getSpotLists.data.records); //表格数据
+			add_tableData.splice(0, add_tableData.length, ...assignDailyBagNo(getSpotLists.data.records)); //表格数据
 			_list.value = getSpotLists.data.list
 			
 			if (!add_searchInfo.value.includes('-') && getSpotLists.data.records.length === 0) {
@@ -889,7 +923,7 @@ const add_Dialog = async () => {
 				sys_sbID: add_formData['机台号']
 			});
 			sizeDatas.splice(0, getSpotLists.data.headers.length, ...getSpotLists.data.headers);
-			add_tableData.splice(0, add_tableData.length, ...getSpotLists.data.records);
+			add_tableData.splice(0, add_tableData.length, ...assignDailyBagNo(getSpotLists.data.records));
 			add_printxp();
 
 			search.value = '';