| | |
| | | <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> |
| | |
| | | clickFun: row => { |
| | | submit(row.id); |
| | | }, |
| | | disabled: row => { |
| | | // 已提交则禁用 |
| | | if (row.inspectState == 1) return true; |
| | | // 如果检验员有值,只有当前登录用户能提交 |
| | | if (row.checkName) { |
| | | return row.checkName !== userStore.nickName; |
| | | } |
| | | return false; |
| | | }, |
| | | disabled: row => !canSubmit(row), |
| | | }, |
| | | { |
| | | name: "分配检验员", |
| | |
| | | const tableData = ref([]); |
| | | const selectedRows = ref([]); |
| | | const tableLoading = ref(false); |
| | | const batchSubmitting = ref(false); |
| | | const currentRow = ref(null); |
| | | const page = reactive({ |
| | | current: 1, |
| | |
| | | // 表格选择数据 |
| | | const handleSelectionChange = selection => { |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | const canSubmit = row => { |
| | | // 已提交则禁用 |
| | | if (row.inspectState == 1) return false; |
| | | // 如果检验员有值,只有当前登录用户能提交 |
| | | if (row.checkName) { |
| | | return row.checkName === userStore.nickName; |
| | | } |
| | | return true; |
| | | }; |
| | | |
| | | // 打开弹框 |
| | |
| | | } |
| | | }; |
| | | |
| | | const handleBatchSubmit = () => { |
| | | if (selectedRows.value.length === 0) { |
| | | proxy.$modal.msgWarning("请选择数据"); |
| | | return; |
| | | } |
| | | |
| | | const submitRows = selectedRows.value.filter(item => canSubmit(item)); |
| | | if (submitRows.length === 0) { |
| | | proxy.$modal.msgWarning("所选数据不可提交"); |
| | | return; |
| | | } |
| | | |
| | | ElMessageBox.confirm( |
| | | `选中的${submitRows.length}条内容将被提交,是否确认提交?`, |
| | | "批量提交", |
| | | { |
| | | 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 (successCount > 0 && failCount === 0) { |
| | | proxy.$modal.msgSuccess("批量提交成功"); |
| | | } else if (successCount > 0) { |
| | | proxy.$modal.msgWarning( |
| | | `成功提交${successCount}条,失败${failCount}条` |
| | | ); |
| | | } else { |
| | | proxy.$modal.msgError("批量提交失败"); |
| | | } |
| | | getList(); |
| | | }) |
| | | .catch(() => { |
| | | proxy.$modal.msg("已取消"); |
| | | }) |
| | | .finally(() => { |
| | | batchSubmitting.value = false; |
| | | }); |
| | | }; |
| | | |
| | | // 关闭弹框 |
| | | const closeDia = () => { |
| | | proxy.resetForm("formRef"); |