From 2e77330d87341624c88301562fd137b58f9a101a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 25 十二月 2025 10:57:35 +0800
Subject: [PATCH] 1.海川开心-录入日期都默认当天,封装公用组件和方法

---
 src/views/productionManagement/operationScheduling/components/formDia.vue |   53 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/src/views/productionManagement/operationScheduling/components/formDia.vue b/src/views/productionManagement/operationScheduling/components/formDia.vue
index e0aa92d..4733a6e 100644
--- a/src/views/productionManagement/operationScheduling/components/formDia.vue
+++ b/src/views/productionManagement/operationScheduling/components/formDia.vue
@@ -24,6 +24,23 @@
 						<el-input v-model="scope.row.process" placeholder="璇疯緭鍏ュ伐搴�" />
           </template>
         </el-table-column>
+		<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="璇疯緭鍏ュ崟浣�" />
@@ -110,6 +127,7 @@
 import {userListNoPageByTenantId} from "@/api/system/user.js";
 import {processScheduling} from "@/api/productionManagement/operationScheduling.js";
 const { proxy } = getCurrentInstance()
+import dayjs from "dayjs";
 const { work_step } = proxy.useDict("work_step")
 const emit = defineEmits(['close'])
 
@@ -123,6 +141,13 @@
 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) => {
@@ -140,21 +165,29 @@
 		if (sunqianUser) {
 			sunqianUserId.value = sunqianUser.userId;
 		}
-		// 鍦ㄧ敤鎴峰垪琛ㄥ姞杞藉畬鎴愬悗鍒涘缓琛屾暟鎹�
-		tableData.value = [createRow()];
+		// 鍦ㄧ敤鎴峰垪琛ㄥ姞杞藉畬鎴愬悗鍒涘缓琛屾暟鎹紝骞跺皢浜х嚎鏁版嵁甯﹀叆
+		tableData.value = [createRow(row, { defaultNum: pendingNum.value })];
 	});
 }
 
-const createRow = () => ({
+const getToday = () => dayjs().format("YYYY-MM-DD");
+const getRemaining = () => {
+	const used = tableData.value.reduce((sum, row) => sum + Number(row.schedulingNum || 0), 0);
+	const remain = Number(pendingNum.value || 0) - used;
+	return remain > 0 ? remain : 0;
+};
+
+const createRow = (row, options = {}) => ({
 	id: idFromRow.value,
 	process: '鍖呰',
-	schedulingDate: '',
-	schedulingNum: null,
+	schedulingDate: getToday(), // 榛樿褰撳ぉ
+	schedulingNum: options.defaultNum ?? null, // 榛樿鐢ㄥ墿浣欐暟閲忓~婊�
 	schedulingUserId: sunqianUserId.value, // 榛樿璁剧疆涓哄瓩鍊╃殑鐢ㄦ埛ID
 	workHours: null,
 	unit: unitFromRow.value,
 	remark: '',
 	type: specificationModelFromRow.value,
+	productionLine: row?.productionLine ?? '', // 浠庤鏁版嵁涓幏鍙栦骇绾夸俊鎭�
 });
 
 const submitForm = () => {
@@ -167,7 +200,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;
@@ -213,7 +247,12 @@
 });
 
 const addRow = () => {
-  tableData.value.push(createRow());
+	const remaining = getRemaining();
+	if (remaining <= 0) {
+		proxy.$modal.msgWarning('宸叉帓婊★紝鏃犲墿浣欐暟閲�');
+		return;
+	}
+  tableData.value.push(createRow({}, { defaultNum: remaining }));
 };
 const removeRow = (index) => {
   tableData.value.splice(index, 1);

--
Gitblit v1.9.3