zhangwencui
2026-09-02 58fc2d97304444f46b265a679008149d0761e49e
过程检批量提交
已修改2个文件
83 ■■■■■ 文件已修改
src/views/qualityManagement/finalInspection/index.vue 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/qualityManagement/processInspection/index.vue 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/qualityManagement/finalInspection/index.vue
@@ -308,7 +308,15 @@
          clickFun: row => {
            submit(row.id);
          },
          disabled: row => !canSubmit(row),
          disabled: row => {
            // 已提交则禁用
            if (row.inspectState == 1) return true;
            // 如果检验员有值,只有当前登录用户能提交
            if (row.checkName) {
              return row.checkName !== userStore.nickName;
            }
            return false;
          },
        },
        {
          name: "分配检验员",
src/views/qualityManagement/processInspection/index.vue
@@ -34,6 +34,10 @@
        <el-button type="primary"
                   @click="openForm('add')">新增</el-button>
        <el-button @click="handleOut">导出</el-button>
        <el-button type="primary"
                   plain
                   :loading="batchSubmitting"
                   @click="handleBatchSubmit">批量提交</el-button>
        <el-button type="danger"
                   plain
                   @click="handleDelete">删除</el-button>
@@ -302,6 +306,7 @@
  const tableData = ref([]);
  const selectedRows = ref([]);
  const tableLoading = ref(false);
  const batchSubmitting = ref(false);
  const dialogFormVisible = ref(false);
  const form = ref({
    checkName: "",
@@ -366,6 +371,16 @@
    selectedRows.value = selection;
  };
  const canSubmit = row => {
    // 已提交则禁用
    if (row.inspectState == 1) return false;
    // 如果检验员有值,只有当前登录用户能提交
    if (row.checkName) {
      return row.checkName === userStore.nickName;
    }
    return true;
  };
  // 打开弹框
  const openForm = (type, row) => {
    nextTick(() => {
@@ -392,6 +407,64 @@
      getList();
    }
  };
  const handleBatchSubmit = () => {
    if (selectedRows.value.length === 0) {
      proxy.$modal.msgWarning("请选择数据");
      return;
    }
    const submitRows = selectedRows.value.filter(item => canSubmit(item));
    const skipCount = selectedRows.value.length - submitRows.length;
    if (submitRows.length === 0) {
      proxy.$modal.msgWarning("所选数据均不可提交");
      return;
    }
    const message =
      skipCount > 0
        ? `已选择${selectedRows.value.length}条,其中${submitRows.length}条可提交,${skipCount}条已提交或无权限,将自动跳过。是否确认提交?`
        : `选中的${submitRows.length}条内容将被提交,是否确认提交?`;
    ElMessageBox.confirm(message, "批量提交", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
    })
      .then(async () => {
        batchSubmitting.value = true;
        const results = await Promise.allSettled(
          submitRows.map(item => submitQualityInspect({ id: item.id }))
        );
        const successCount = results.filter(
          item => item.status === "fulfilled" && item.value?.code === 200
        ).length;
        const failCount = submitRows.length - successCount;
        if (failCount === 0 && skipCount === 0) {
          proxy.$modal.msgSuccess("批量提交成功");
        } else if (failCount === 0) {
          proxy.$modal.msgSuccess(
            `成功提交${successCount}条,跳过${skipCount}条`
          );
        } else if (successCount > 0) {
          proxy.$modal.msgWarning(
            `成功提交${successCount}条,失败${failCount}条,跳过${skipCount}条`
          );
        } else {
          proxy.$modal.msgError(
            `批量提交失败,失败${failCount}条,跳过${skipCount}条`
          );
        }
        getList();
      })
      .catch(() => {
        proxy.$modal.msg("已取消");
      })
      .finally(() => {
        batchSubmitting.value = false;
      });
  };
  const open = async row => {
    let userLists = await userListNoPage();
    userList.value = userLists.data;