hurx 4 dias atrás
pai
commit
423d45b6e7
1 arquivos alterados com 25 adições e 9 exclusões
  1. 25 9
      src/views/dataUpload/index.vue

+ 25 - 9
src/views/dataUpload/index.vue

@@ -50,13 +50,13 @@
             </el-dropdown>
           </el-col>
           <el-col :span="1.5">
-            <el-button type="primary" icon="Top" @click="handleCustomerExport">
+            <el-button type="primary" icon="Top" :loading="buttonLoading" @click="handleCustomerExport">
               导出客户
               <el-icon class="el-icon--right"> </el-icon>
             </el-button>
           </el-col>
           <el-col :span="1.5">
-            <el-button type="primary" icon="Top" @click="handleSupplierExport">
+            <el-button type="primary" icon="Top" :loading="buttonLoading" @click="handleSupplierExport">
               导出供应商
               <el-icon class="el-icon--right"> </el-icon>
             </el-button>
@@ -88,6 +88,7 @@
         :disabled="upload.isUploading"
         :on-progress="handleFileUploadProgress"
         :on-success="handleFileSuccess"
+        :on-error="handleFileUploadError"
         :auto-upload="false"
         drag
       >
@@ -107,8 +108,8 @@
       </el-upload>
       <template #footer>
         <div class="dialog-footer">
-          <el-button type="primary" @click="submitFileForm">确 定</el-button>
-          <el-button @click="upload.open = false">取 消</el-button>
+          <el-button type="primary" :loading="upload.isUploading" @click="submitFileForm">确 定</el-button>
+          <el-button :disabled="upload.isUploading" @click="upload.open = false">取 消</el-button>
         </div>
       </template>
     </el-dialog>
@@ -202,18 +203,33 @@ const handleSupplierImport = () => {
 };
 
 /** 客户导出按钮操作 */
-const handleCustomerExport = () => {
-  proxy?.download('customer/customerInfo/exportTemplateData', {}, `客户导出_${new Date().getTime()}.xlsx`);
+const handleCustomerExport = async () => {
+  buttonLoading.value = true;
+  try {
+    await proxy?.download('customer/customerInfo/exportTemplateData', {}, `客户导出_${new Date().getTime()}.xlsx`);
+  } finally {
+    buttonLoading.value = false;
+  }
 };
-/** 客户导出按钮操作 */
-const handleSupplierExport = () => {
-  proxy?.download('customer/info/exportTemplateData', {}, `供应商导出_${new Date().getTime()}.xlsx`);
+/** 供应商导出按钮操作 */
+const handleSupplierExport = async () => {
+  buttonLoading.value = true;
+  try {
+    await proxy?.download('customer/info/exportTemplateData', {}, `供应商导出_${new Date().getTime()}.xlsx`);
+  } finally {
+    buttonLoading.value = false;
+  }
 };
 
 /**文件上传中处理 */
 const handleFileUploadProgress = () => {
   upload.isUploading = true;
 };
+/** 文件上传失败处理 */
+const handleFileUploadError = () => {
+  upload.isUploading = false;
+  ElMessage.error('文件上传失败,请联系管理员!');
+};
 /** 文件上传成功处理 */
 const handleFileSuccess = (response: any, file: UploadFile) => {
   upload.open = false;