refactor(material-center): 添加提交加载状态并优化删除按钮样式

- 在 `add-raw-material-drawer` 中添加了 `submitLoading` 状态,确保在提交过程中显示加载状态
- 在 `delete-file-modal` 中添加了 `loading` 状态,并更新了删除按钮的样式以显示加载状态
This commit is contained in:
rd
2025-09-22 11:26:28 +08:00
parent d4f82dbc3e
commit fcacd6fc1c
2 changed files with 36 additions and 24 deletions

View File

@ -259,6 +259,8 @@ export default defineComponent({
}; };
const onConfirm = async () => { const onConfirm = async () => {
try {
submitLoading.value = true;
const hasUploading = uploadData.value.some((item) => item.uploadStatus === EnumUploadStatus.uploading); const hasUploading = uploadData.value.some((item) => item.uploadStatus === EnumUploadStatus.uploading);
if (hasUploading) { if (hasUploading) {
modalRef.value = Modal.warning({ modalRef.value = Modal.warning({
@ -277,6 +279,9 @@ export default defineComponent({
emit('update'); emit('update');
onClose(); onClose();
} }
} finally {
submitLoading.value = false;
}
}; };
const openDeleteModal = (file) => { const openDeleteModal = (file) => {
modalRef.value = Modal.warning({ modalRef.value = Modal.warning({

View File

@ -6,7 +6,7 @@
</div> </div>
<template #footer> <template #footer>
<Button size="medium" @click="onClose">取消</Button> <Button size="medium" @click="onClose">取消</Button>
<Button type="primary" class="ml-16px" danger size="medium" @click="onDelete">确认删除</Button> <Button :loading="loading" class="ml-16px" danger size="medium" type="primary" @click="onDelete">确认删除</Button>
</template> </template>
</Modal> </Modal>
</template> </template>
@ -24,12 +24,14 @@ const emits = defineEmits(['update', 'batchUpdate']);
const visible = ref(false); const visible = ref(false);
const fileId = ref(null); const fileId = ref(null);
const fileName = ref(''); const fileName = ref('');
const loading = ref(false);
const isBatch = computed(() => Array.isArray(fileId.value)); const isBatch = computed(() => Array.isArray(fileId.value));
function onClose() { function onClose() {
visible.value = false; visible.value = false;
fileId.value = null; fileId.value = null;
loading.value = false;
fileName.value = ''; fileName.value = '';
} }
@ -42,6 +44,8 @@ const open = (record) => {
}; };
async function onDelete() { async function onDelete() {
try {
loading.value = true;
const _fn = isBatch.value ? batchDeleteRawMaterials : deleteRawMaterial; const _fn = isBatch.value ? batchDeleteRawMaterials : deleteRawMaterial;
const _params = isBatch.value ? { ids: fileId.value } : fileId.value; const _params = isBatch.value ? { ids: fileId.value } : fileId.value;
const { code } = await _fn(_params); const { code } = await _fn(_params);
@ -51,6 +55,9 @@ async function onDelete() {
onClose(); onClose();
} }
} finally {
loading.value = false;
}
} }
defineExpose({ open }); defineExpose({ open });