diff --git a/src/axios.js b/src/axios.js
index e11e0d45..ba7f4820 100644
--- a/src/axios.js
+++ b/src/axios.js
@@ -17,7 +17,8 @@ import 'nprogress/nprogress.css'; // 进度条样式
import { Base64 } from 'js-base64'; // Base64编码工具
import { baseUrl } from '@/config/env'; // API基础URL
import crypto from '@/utils/crypto'; // 加密工具,可能用于加密Token等
-
+import {ref} from 'vue';
+let msg = ref(''); // 错误信息
// 存储待取消的HTTP请求的键值对,用于取消重复的请求
const pendingRequests = new Map();
@@ -131,13 +132,21 @@ axios.interceptors.response.use(
// 如果response的状态码不是200,则显示消息提示,并返回Promise的reject状态
if (status !== 200) {
- ElMessage({
- message: message,
- type: 'error',
- });
+ if(!msg.value){
+ ElMessage({
+ message: message,
+ type: 'error',
+ });
+ }
+ if(msg.value && (msg.value != message)){
+ setTimeout(() => {
+ msg.value = '';
+ }, 0);
+ }else{
+ msg.value=message
+ }
return Promise.reject(new Error(message));
}
-
// 正常状态返回responseData
return res;
},
diff --git a/src/main.js b/src/main.js
index bc615af3..7c5c59b1 100644
--- a/src/main.js
+++ b/src/main.js
@@ -25,6 +25,7 @@ import flowDesign from './components/flow-design/main.vue';
import tablecmt from './components/tablecmt/tablecmt.vue';
import SelectBox from './components/SelectBox/SelectBox.vue';
import edittablehead from './components/edittablehead/index.vue';
+import {message } from './utils/resetMessage'
import App from './App.vue';
import 'animate.css';
import dayjs from 'dayjs';
@@ -64,6 +65,7 @@ app.use(router);
app.use(ElementPlus, {
locale: messages[language],
});
+app.config.globalProperties.$message = message;//解决重复弹窗
app.use(Avue, {
axios,
calcHeight: 10,
diff --git a/src/utils/resetMessage.js b/src/utils/resetMessage.js
new file mode 100644
index 00000000..5b770889
--- /dev/null
+++ b/src/utils/resetMessage.js
@@ -0,0 +1,23 @@
+import { ElMessage } from 'element-plus';
+
+let messageInstance = null;
+const resetMessage = (options) => {
+ if (messageInstance) {
+ messageInstance.close();
+ }
+ messageInstance = ElMessage(options);
+};
+
+['error', 'success', 'info', 'warning'].forEach((type) => {
+ resetMessage[type] = (options) => {
+ if (typeof options === 'string') {
+ options = {
+ message: options,
+ };
+ }
+ options.type = type;
+ return resetMessage(options);
+ };
+});
+
+export const message = resetMessage;
\ No newline at end of file
diff --git a/src/views/distribution/deliverylist/distributionDeliveryListedt.vue b/src/views/distribution/deliverylist/distributionDeliveryListedt.vue
index bd6a0dba..41a40936 100644
--- a/src/views/distribution/deliverylist/distributionDeliveryListedt.vue
+++ b/src/views/distribution/deliverylist/distributionDeliveryListedt.vue
@@ -261,6 +261,7 @@
>