编辑 | blame | 历史 | 原始文档

生产报工拆分(开始报工/结束报工)及工人权限过滤

涉及页面

  • 生产工单列表页(可报工工单筛选)
  • 生产报工页(开始报工 / 结束报工)
  • 报工台账页(实际工时展示)

API

新增接口

方法 路径 说明
POST /productionProductMain/startWork 开始报工

请求参数:

参数 类型 必填 说明
productionOperationTaskId Long 生产工单ID
userId Long 报工人员ID

响应: { "code": 200, "msg": "操作成功", "data": true }

变更接口

POST /productionProductMain/addProductMain(结束报工)

入参增加:

参数 类型 必填 说明
id Long 开始报工返回的 ProductionProductMain ID

GET /productionOperationTask/page/productionOperationTask/list

新增查询参数:

参数 类型 必填 说明
filterMine Boolean 为 true 时仅返回当前用户被指派的工单

响应字段变更

GET /productionProductMain/listPage/page/{id}

新增响应字段:

参数 类型 说明
actualStartTime String 实际开始时间 (yyyy-MM-dd HH:mm:ss)
actualEndTime String 实际结束时间 (yyyy-MM-dd HH:mm:ss)

前端修改点

1. 生产报工页 — 拆分为两步操作

开始报工按钮:

<el-button type="primary" @click="handleStartWork">开始报工</el-button>
handleStartWork() {
  this.$confirm('确认开始报工?', '提示', { type: 'info' }).then(() => {
    startWork({
      productionOperationTaskId: this.taskId,
      userId: this.selectedUserId
    }).then(res => {
      this.startRecordId = res.data; // 保存返回的报工记录ID,供结束报工使用
      this.$message.success('开始报工成功');
      this.refreshTaskStatus();
    });
  });
}

结束报工按钮(原报工提交按钮改造):

<el-button type="success" @click="handleFinishWork" :disabled="!startRecordId">结束报工</el-button>
handleFinishWork() {
  this.$refs.form.validate(valid => {
    if (valid) {
      addProductMain({
        id: this.startRecordId, // 必须传入开始报工记录ID
        quantity: this.form.quantity,
        scrapQty: this.form.scrapQty,
        userId: this.selectedUserId,
        productionOperationParamList: this.paramList
      }).then(() => {
        this.$message.success('结束报工成功');
        this.resetForm();
      });
    }
  });
}

2. 工单列表页 — 权限过滤

增加"仅看我的"筛选开关:

<el-switch v-model="filterMine" active-text="仅看我的" @change="handleFilterChange" />
data() {
  return {
    filterMine: false,
  }
},
methods: {
  handleFilterChange(val) {
    this.loadTaskList();
  },
  loadTaskList() {
    const params = { ...this.queryParams };
    if (this.filterMine) {
      params.filterMine = true;
    }
    listTask(params).then(res => {
      this.taskList = res.rows;
    });
  }
}

3. 报工台账页 — 展示实际工时

台账中的 workHour 字段现在基于实际开始/结束时间自动计算(以小时为单位),前端直接展示即可,无需额外处理。

注意事项

  • 报工流程变为两步:先调用 /startWork 开始,再调用 /addProductMain(传入开始报工返回的 id)结束
  • 开始报工后工单状态变为"生产中",结束报工后才创建产出品、投入品和核算记录
  • 实际工时 = actualEndTime - actualStartTime,自动计算(也可手动传入 workHour 覆盖)
  • 工单未指派(userIds 为空或 [])时所有工人可操作;已指派时仅被指派人可操作
  • 前端需缓存 startRecordId(开始报工返回的 ID),结束报工时传入
  • 如果用户关闭页面后重新打开,需要查询 status=0 的进行中报工记录来恢复 startRecordId