From 644f9b827ac28d39f32c626712d5c574fe9acbf1 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 16 十二月 2025 17:23:01 +0800
Subject: [PATCH] 1.海川开心-入库管理-成品入库添加一个删除功能

---
 src/views/productionManagement/operationScheduling/components/formDia.vue |  130 ++++++++++++++++++++++++++++++++----------
 1 files changed, 98 insertions(+), 32 deletions(-)

diff --git a/src/views/productionManagement/operationScheduling/components/formDia.vue b/src/views/productionManagement/operationScheduling/components/formDia.vue
index ad37c4b..06b46ac 100644
--- a/src/views/productionManagement/operationScheduling/components/formDia.vue
+++ b/src/views/productionManagement/operationScheduling/components/formDia.vue
@@ -8,27 +8,47 @@
     >
       <el-button type="primary" @click="addRow" style="margin-bottom: 10px;">鏂板</el-button>
 			<span style="font-size: 18px;margin-left: 10px">寰呮帓浜ф暟閲忥細{{pendingNum}}</span>
+<!--			<div style="margin-bottom: 10px; margin-left: 10px;">-->
+<!--				<el-form-item label="棰嗙敤锛�" style="margin-bottom: 0;">-->
+<!--					<el-input v-model="receive" placeholder="璇疯緭鍏ラ鐢�" style="width: 200px;" />-->
+<!--				</el-form-item>-->
+<!--			</div>-->
       <el-table :data="tableData" border style="width: 100%" :summary-method="summarizeMainTable" show-summary :row-key="row => row.id">
-        <el-table-column label="搴忓彿" width="60">
+        <el-table-column label="搴忓彿" width="60" align="center">
           <template #default="scope">
             {{ scope.$index + 1 }}
           </template>
         </el-table-column>
-        <el-table-column label="宸ュ簭" prop="process">
+        <el-table-column label="宸ュ簭" prop="process" width="150">
           <template #default="scope">
-						<el-select v-model="scope.row.process" placeholder="璇烽�夋嫨" clearable style="width: 100%">
-							<el-option
-								v-for="dict in work_step"
-								:key="dict.value"
-								:label="dict.label"
-								:value="dict.value"
-							/>
-						</el-select>
+						<el-input v-model="scope.row.process" placeholder="璇疯緭鍏ュ伐搴�" />
           </template>
         </el-table-column>
-        <el-table-column label="鍗曚綅" prop="unit">
+		<el-table-column label="浜х嚎" prop="productionLine" width="150">
+          <template #default="scope">
+            <el-select
+              v-model="scope.row.productionLine"
+              placeholder="閫夋嫨浜х嚎"
+              style="width: 100%;"
+              clearable
+            >
+              <el-option
+                v-for="line in productionLines"
+                :key="line.value"
+                :label="line.label"
+                :value="line.value"
+              />
+            </el-select>
+          </template>
+        </el-table-column>
+        <el-table-column label="鍗曚綅" prop="unit" width="90">
           <template #default="scope">
             <el-input v-model="scope.row.unit" placeholder="璇疯緭鍏ュ崟浣�" />
+          </template>
+        </el-table-column>
+        <el-table-column label="鍙e懗/鍝佸悕/瑙勬牸" prop="type" width="150">
+          <template #default="scope">
+            <el-input v-model="scope.row.type" placeholder="璇疯緭鍏�" />
           </template>
         </el-table-column>
         <el-table-column label="鎺掍骇鏁伴噺" width="200" prop="schedulingNum">
@@ -57,17 +77,20 @@
 						/>
           </template>
         </el-table-column>
-        <el-table-column label="鎺掍骇鏃ユ湡" prop="schedulingDate">
+        <el-table-column label="鎺掍骇鏃ユ湡" prop="schedulingDate" width="200">
           <template #default="scope">
             <el-date-picker v-model="scope.row.schedulingDate" type="date" placeholder="閫夋嫨鏃ユ湡" style="width: 100%;" value-format="YYYY-MM-DD" format="YYYY-MM-DD"/>
           </template>
         </el-table-column>
-        <el-table-column label="鎺掍骇浜�" prop="schedulingUserId">
+        <el-table-column label="鎺掍骇浜�" prop="schedulingUserId" width="150">
           <template #default="scope">
 						<el-select
 							v-model="scope.row.schedulingUserId"
 							placeholder="閫夋嫨浜哄憳"
 							style="width: 100%;"
+              filterable
+              default-first-option
+              :reserve-keyword="false"
 						>
 							<el-option
 								v-for="user in userList"
@@ -76,6 +99,11 @@
 								:value="user.userId"
 							/>
 						</el-select>
+          </template>
+        </el-table-column>
+        <el-table-column label="澶囨敞" prop="remark" width="200">
+          <template #default="scope">
+            <el-input v-model="scope.row.remark" placeholder="璇疯緭鍏ュ娉�" />
           </template>
         </el-table-column>
         <el-table-column label="鎿嶄綔" width="80">
@@ -95,7 +123,7 @@
 </template>
 
 <script setup>
-import {ref} from "vue";
+import {ref, getCurrentInstance} from "vue";
 import {userListNoPageByTenantId} from "@/api/system/user.js";
 import {processScheduling} from "@/api/productionManagement/operationScheduling.js";
 const { proxy } = getCurrentInstance()
@@ -104,33 +132,56 @@
 
 const dialogFormVisible = ref(false);
 const operationType = ref('')
-const tableData = ref([
-	{ process: '', schedulingDate: '', schedulingNum: '', schedulingUserId: '', workHours: '', unit: '' }
-]);
+const tableData = ref([]);
 const unitFromRow = ref('');
 const idFromRow = ref('');
-const pendingNum = ref('');
+const specificationModelFromRow = ref('');
+const pendingNum = ref(0);
 const userList = ref([])
+const receive = ref('')
+const sunqianUserId = ref('')
+// 浜х嚎閫夐」
+const productionLines = ref([
+  { label: '浜х嚎1', value: '浜х嚎1' },
+  { label: '浜х嚎2', value: '浜х嚎2' },
+  { label: '浜х嚎3', value: '浜х嚎3' },
+  { label: '浜х嚎4', value: '浜х嚎4' }
+])
 
 // 鎵撳紑寮规
 const openDialog = (type, row) => {
   operationType.value = type;
   dialogFormVisible.value = true;
+	pendingNum.value = row?.pendingNum ?? 0;
+	unitFromRow.value = row?.unit ?? '';
+	idFromRow.value = row?.id ?? '';
+	specificationModelFromRow.value = row?.specificationModel ?? '';
+	
 	userListNoPageByTenantId().then((res) => {
 		userList.value = res.data;
+		// 鎵惧埌瀛欏�╃殑鐢ㄦ埛ID骞惰缃负榛樿鍊�
+		const sunqianUser = userList.value.find(user => user.nickName === '瀛欏��');
+		if (sunqianUser) {
+			sunqianUserId.value = sunqianUser.userId;
+		}
+		// 鍦ㄧ敤鎴峰垪琛ㄥ姞杞藉畬鎴愬悗鍒涘缓琛屾暟鎹紝骞跺皢浜х嚎鏁版嵁甯﹀叆
+		tableData.value = [createRow(row)];
 	});
-	pendingNum.value = row.pendingNum
-  if (row && row.unit !== undefined) {
-    unitFromRow.value = row.unit;
-    idFromRow.value = row.id;
-    tableData.value.forEach(item => {
-      item.unit = row.unit;
-      item.id = row.id;
-    });
-  } else {
-    unitFromRow.value = '';
-  }
 }
+
+const createRow = (row) => ({
+	id: idFromRow.value,
+	process: '鍖呰',
+	schedulingDate: '',
+	schedulingNum: null,
+	schedulingUserId: sunqianUserId.value, // 榛樿璁剧疆涓哄瓩鍊╃殑鐢ㄦ埛ID
+	workHours: null,
+	unit: unitFromRow.value,
+	remark: '',
+	type: specificationModelFromRow.value,
+	productionLine: row?.productionLine ?? '', // 浠庤鏁版嵁涓幏鍙栦骇绾夸俊鎭�
+});
+
 const submitForm = () => {
 	// 1. 妫�鏌ユ瘡涓�琛屾槸鍚﹀~鍐欏畬鏁�
 	for (let i = 0; i < tableData.value.length; i++) {
@@ -141,7 +192,8 @@
 			row.schedulingNum === '' || row.schedulingNum === null ||
 			!row.schedulingUserId ||
 			row.workHours === '' || row.workHours === null ||
-			!row.unit
+			!row.unit ||
+			!row.productionLine
 		) {
 			proxy.$modal.msgError(`绗�${i + 1}琛屾暟鎹湭濉啓瀹屾暣`);
 			return;
@@ -155,7 +207,15 @@
 		proxy.$modal.msgError('鎺掍骇鏁伴噺鍚堣涓嶈兘瓒呰繃寰呮帓浜ф暟閲�');
 		return;
 	}
-	processScheduling(tableData.value).then((res) => {
+	// 3. 灏� receive 瀛楁娣诲姞鍒版瘡鏉℃暟鎹腑锛屽苟绉婚櫎 loss 瀛楁
+	const submitData = tableData.value.map(row => {
+		const { loss, ...rest } = row;
+		return {
+			...rest,
+			receive: receive.value
+		};
+	});
+	processScheduling(submitData).then((res) => {
 		proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
 		closeDia();
 	})
@@ -166,6 +226,12 @@
 // 鍏抽棴寮规
 const closeDia = () => {
   dialogFormVisible.value = false;
+  receive.value = '';
+  tableData.value = [];
+  unitFromRow.value = '';
+  idFromRow.value = '';
+  specificationModelFromRow.value = '';
+  pendingNum.value = 0;
   emit('close')
 };
 defineExpose({
@@ -173,7 +239,7 @@
 });
 
 const addRow = () => {
-  tableData.value.push({ id: idFromRow.value, process: '', unit: unitFromRow.value, schedulingNum: '', workHours: '', schedulingDate: '', schedulingUserId: '' });
+  tableData.value.push(createRow());
 };
 const removeRow = (index) => {
   tableData.value.splice(index, 1);

--
Gitblit v1.9.3