Преглед изворни кода

优化导入电话发送短信的功能

cgp пре 1 месец
родитељ
комит
726624d5b0
1 измењених фајлова са 36 додато и 6 уклоњено
  1. 36 6
      src/views/qw/acquisitionAssistant/index.vue

+ 36 - 6
src/views/qw/acquisitionAssistant/index.vue

@@ -396,6 +396,7 @@
       :close-on-click-modal="false"
       :close-on-press-escape="false"
       :show-close="!uploadPhoneDialog.loading"
+      @close="closeUploadPhoneDialog"
     >
       <div v-loading="uploadPhoneDialog.loading" element-loading-text="处理中...">
         <p style="color: #909399; font-size: 14px; margin-bottom: 20px;">
@@ -1556,21 +1557,49 @@ export default {
       this.hasMoreUsers = true
       this.resetForm('form')
     },
+    /**
+     * 处理导入电话号码按钮点击事件
+     */
     /**
      * 处理导入电话号码按钮点击事件
      */
     handleUploadPhones(row) {
-      this.uploadPhoneDialog.rowData = row;
-      this.uploadPhoneDialog.visible = true;
+      // 先重置上传组件的文件列表
+      this.$nextTick(() => {
+        if (this.$refs.upload) {
+          // 清空上传组件的文件列表
+          this.$refs.upload.clearFiles()
+          // 重置上传组件的内部状态
+          this.$refs.upload.uploadFiles = []
+        }
+      })
+
+      this.uploadPhoneDialog.rowData = row
+      this.uploadPhoneDialog.visible = true
       // 重置加载状态,防止上次上传的loading状态残留
-      this.uploadPhoneDialog.loading = false;
+      this.uploadPhoneDialog.loading = false
     },
+    /**
+     * 关闭导入电话号码弹窗
+     */
+    closeUploadPhoneDialog() {
+      // 清空上传组件的文件列表
+      if (this.$refs.upload) {
+        this.$refs.upload.clearFiles()
+        this.$refs.upload.uploadFiles = []
+      }
+      this.uploadPhoneDialog.visible = false
+      this.uploadPhoneDialog.loading = false
+      this.uploadPhoneDialog.rowData = null
+    },
+
     /**
      * 自定义上传方法,供 el-upload 调用
      */
     handleHttpRequest(options) {
       this.uploadFile(options);
     },
+
     /**
      * 上传文件到后端
      */
@@ -1587,15 +1616,16 @@ export default {
         const response = await batchCreateMessageLink(formData);
         if (response.code === 200) {
           this.$message.success(response.msg || '生成短链成功!');
-          this.uploadPhoneDialog.visible = false;
+          // 上传成功后关闭弹窗并清理
+          this.closeUploadPhoneDialog();
         } else {
           this.$message.error(response.msg || '操作失败');
+          // 上传失败不清空文件,但关闭加载状态
+          this.uploadPhoneDialog.loading = false;
         }
       } catch (error) {
         console.error('上传文件请求失败:', error);
         this.$message.error(error.message || '上传失败,请稍后重试');
-      } finally {
-        // 5. 结束加载状态
         this.uploadPhoneDialog.loading = false;
       }
     },