tuqin
2026-09-24 dc3fc550fe292043cc452dc9aeb0c8a1eeab3b30
src/views/customerService/expiryAfterSales/index.vue
@@ -34,10 +34,13 @@
            >重置</el-button
            >
         </div>
         <div class="table_actions">
            <el-button type="primary" @click="openForm('add')">新增</el-button>
            <el-button type="danger" @click="handleDelete">删除</el-button>
         </div>
      </div>
      <div class="table_header" style="display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding-bottom: 10px;">
         <el-button type="primary" @click="openForm('add')">新增</el-button>
         <el-button type="info" plain icon="Upload" @click="handleImport">导入</el-button>
         <el-button @click="handleExport">导出</el-button>
         <el-button type="danger" @click="handleDelete">删除</el-button>
      </div>
      <div class="table_list">
@@ -65,6 +68,28 @@
         </PIMTable>
      </div>
      <form-dia ref="formDia" @close="handleQuery"></form-dia>
      <!-- 临期售后导入对话框 -->
      <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
         <el-upload ref="uploadRef" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url"
            :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess"
            :on-error="handleFileError" :auto-upload="false" drag>
            <el-icon class="el-icon--upload"><upload-filled /></el-icon>
            <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
            <template #tip>
               <div class="el-upload__tip text-center">
                  <span>仅允许导入 xls、xlsx 格式文件。</span>
                  <el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
                     @click="importTemplate">下载模板</el-link>
               </div>
            </template>
         </el-upload>
         <template #footer>
            <div class="dialog-footer">
               <el-button type="primary" @click="submitFileForm">确 定</el-button>
               <el-button @click="upload.open = false">取 消</el-button>
            </div>
         </template>
      </el-dialog>
   </div>
</template>
@@ -75,6 +100,7 @@
import {ElMessageBox} from "element-plus";
import {expiryAfterSalesDelete, expiryAfterSalesListPage} from "@/api/customerService/index.js";
import useUserStore from "@/store/modules/user.js";
import { getToken } from "@/utils/auth.js";
const { proxy } = getCurrentInstance();
const userStore = useUserStore()
@@ -263,6 +289,68 @@
      });
};
// 导出
const handleExport = () => {
   ElMessageBox.confirm("是否确认导出全部临期售后数据?", "导出", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
   }).then(() => {
      proxy.download("/afterSalesNearExpiryService/export", {}, "临期售后管理.xlsx");
   }).catch(() => {
      proxy.$modal.msg("已取消");
   });
};
// 导入
const uploadRef = ref();
const upload = reactive({
   open: false,
   title: "",
   isUploading: false,
   headers: { Authorization: "Bearer " + getToken() },
   url: import.meta.env.VITE_APP_BASE_API + "/afterSalesNearExpiryService/import",
});
const handleImport = () => {
   upload.title = "临期售后导入";
   upload.open = true;
};
const importTemplate = () => {
   proxy.download("/afterSalesNearExpiryService/importTemplate", {}, "临期售后管理导入模板.xlsx");
};
const submitFileForm = () => {
   upload.isUploading = true;
   uploadRef.value.submit();
};
const handleFileUploadProgress = () => {
   upload.isUploading = true;
};
const handleFileSuccess = (response) => {
   upload.isUploading = false;
   upload.open = false;
   uploadRef.value.clearFiles();
   if (response.code === 200) {
      const failCount = response.failCount || 0;
      if (failCount > 0) {
         const errors = Array.isArray(response.errors) ? response.errors : [];
         proxy.$modal.alert(`${response.msg}\n\n${errors.join("\n")}`, "导入结果", {
            confirmButtonText: "知道了",
         }).then(() => {
            getList();
         });
      } else {
         proxy.$modal.msgSuccess(response.msg || "导入成功");
         getList();
      }
   } else {
      proxy.$modal.msgError(response.msg || "导入失败");
   }
};
const handleFileError = () => {
   upload.isUploading = false;
   proxy.$modal.msgError("文件上传失败");
};
onMounted(() => {
   getList();
});