Ver código fonte

feat: 添加标准工时输入功能并同步更新计划完成时间

xieyong 3 semanas atrás
pai
commit
a444c76313

+ 76 - 0
src/views/productionPlan/components/newFactoryProductionScheduling/TaskConfigPanel.vue

@@ -338,6 +338,32 @@
                 </el-tooltip>
               </template>
             </el-table-column>
+            <el-table-column
+              v-if="isDispatchColumnVisible('standardHours')"
+              label="标准工时(小时)"
+              align="center"
+              min-width="120"
+            >
+              <template slot-scope="{ row }">
+                <el-tooltip
+                  :disabled="!isDeviceSnapshotLocked(row)"
+                  content="该工序已制定设备类型"
+                  placement="top"
+                  popper-class="dispatch-device-lock-tooltip"
+                >
+                  <span class="dispatch-disabled-field">
+                    <el-input
+                      :value="row.standardHours"
+                      placeholder="请输入标准工时"
+                      :disabled="isDispatchRowControlDisabled(row)"
+                      type="number"
+                      class="config-table-control"
+                      @input="(value) => handleDispatchRowStandardHoursChange(row, value)"
+                    />
+                  </span>
+                </el-tooltip>
+              </template>
+            </el-table-column>
             <el-table-column
               v-if="isDispatchColumnVisible('startTime')"
               label="计划开始时间"
@@ -858,6 +884,7 @@
           { key: 'assetCategoryLevelPath', label: '设备类型' },
           { key: 'status', label: '状态' },
           { key: 'quantity', label: '数量' },
+          { key: 'standardHours', label: '标准工时(小时)' },
           { key: 'startTime', label: '计划开始时间' },
           { key: 'endTime', label: '计划完成时间' },
           { key: 'action', label: '操作' }
@@ -872,6 +899,7 @@
           assetCategoryLevelPath: true,
           status: true,
           quantity: true,
+          standardHours: true,
           startTime: true,
           endTime: true,
           action: true
@@ -1001,6 +1029,10 @@
                   : assignment
                   ? this.formatDispatchRowQuantity(assignment.quantity)
                   : '',
+              standardHours:
+                draft.standardHours !== undefined
+                  ? draft.standardHours
+                  : task?.standardHours || '',
               executionStartTime:
                 draft.executionStartTime !== undefined
                   ? draft.executionStartTime
@@ -2230,6 +2262,49 @@
           executionEndTime: row.executionEndTime
         });
       },
+      handleDispatchRowStandardHoursChange(row, value) {
+        if (!row || this.isDispatchRowControlDisabled(row)) {
+          return;
+        }
+        // 同步输入值:el-input 的 :value 已展示 row.standardHours,这里以参数兜底
+        if (value !== undefined && value !== null) {
+          this.$set(row, 'standardHours', value);
+        }
+        const hours = this.parseStandardHours(row.standardHours);
+        if (hours === null) {
+          this.updateDispatchRowDraft(row, { standardHours: row.standardHours });
+          return;
+        }
+        const startTimeText = row.executionStartTime;
+        if (!startTimeText) {
+          this.$message.warning('请先填写计划开始时间');
+          this.updateDispatchRowDraft(row, { standardHours: row.standardHours });
+          return;
+        }
+        const startMs = this.parseDispatchTime(startTimeText);
+        if (startMs === null) {
+          this.$message.warning('计划开始时间格式不合法');
+          this.updateDispatchRowDraft(row, { standardHours: row.standardHours });
+          return;
+        }
+        const endDate = new Date(startMs + hours * 60 * 60 * 1000);
+        const formatted = this.formatExecutionEndTime(endDate);
+        const task = this.ensureDispatchObjectSelected(row);
+        if (task) {
+          this.$set(task, 'standardHours', row.standardHours);
+          this.$set(task, 'executionEndTime', formatted);
+        }
+        this.$set(row, 'executionEndTime', formatted);
+        this.updateDispatchRowDraft(row, {
+          standardHours: row.standardHours,
+          executionStartTime: row.executionStartTime,
+          executionEndTime: formatted
+        });
+        if (task) {
+          this.$emit('time-change', task, 'executionEndTime');
+        }
+        this.$forceUpdate();
+      },
       handleCurrentPageDispatchCheckChange(checked) {
         if (this.readonlyMode) {
           return;
@@ -2244,6 +2319,7 @@
         return {
           ...row,
           quantity: task?.quantity ?? row.quantity,
+          standardHours: task?.standardHours ?? row.standardHours,
           executionStartTime:
             task?.executionStartTime ?? row.executionStartTime,
           executionEndTime: task?.executionEndTime ?? row.executionEndTime,