add:增加全局loading

This commit is contained in:
chenpingsen
2024-08-22 16:00:04 +08:00
parent ca74de5b37
commit 7b4f22222d
18 changed files with 401 additions and 251 deletions

View File

@@ -269,7 +269,7 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { DownOutlined, UpOutlined, StopOutlined } from '@ant-design/icons-vue';
import { message } from 'ant-design-vue';
import { message, Modal } from 'ant-design-vue';
// 请求
import { http } from '/nerv-lib/util/http';
import { airConditionControl } from '/@/api/airConditionControlSystem';
@@ -736,47 +736,47 @@
if (!changeList.value.length && !lockList.value.length) {
return message.info('未产生任何修改');
}
state.setLoading(true);
http
.get(planManage.getRunningPlan, {
deviceType: 2,
ctrlType: 2,
projectId: state.projectId,
siteId: state.siteId,
})
.then((res) => {
// 如果有计划正在执行
if (res.data && res.data.length) {
state.setLoading(false);
// 此处框架本身存在问题弹出层在本地环境无法关闭暂时使用浏览器自带的confirm方法
// Modal.confirm({
// title: '提示信息',
// content: '有计划正在执行,点击"确定"将暂停当前计划',
// onOk() {
// return new Promise((resolve, reject) => {
// });
// },
// onCancel() { },
// });
let flag = window.confirm('有计划正在执行,点击"确定"将暂停当前计划');
if (flag) {
// 如果点击了确定,将先终止所有进行中的计划
http
.post(airConditionControl.submitChangeList, {
projectId: state.projectId,
siteId: state.siteId,
lockList: [],
sceneList: [],
})
.then((res) => {
console.log(res, '成功');
// 如果重置成功,则获取修改前后对比数据
if (res.retcode == 0) {
sendChangeList();
// 未成功提示
} else {
message.error('关闭进行中的任务操作失败,请重新尝试');
}
});
}
Modal.confirm({
title: '提示信息',
content: '有计划正在执行,点击"确定"将暂停当前计划',
onOk() {
state.setLoading(true);
// 如果点击了确定,将先终止所有进行中的计划
http
.post(airConditionControl.submitChangeList, {
projectId: state.projectId,
siteId: state.siteId,
lockList: [],
sceneList: [],
})
.then((res) => {
// 如果重置成功,则获取修改前后对比数据
if (res.retcode == 0) {
sendChangeList();
// 未成功提示
} else {
state.setLoading(false);
message.error('关闭进行中的任务操作失败,请重新尝试');
}
})
.catch(() => {
state.setLoading(false);
});
},
onCancel() {},
});
// 没有计划正在执行,则直接请求
} else {
sendChangeList();
@@ -793,6 +793,7 @@
siteId: state.siteId,
})
.then((res) => {
state.setLoading(false);
if (res.retcode == 0) {
diffList.value = res.data;
executeVisible.value = true;
@@ -800,7 +801,9 @@
message.warning('获取修改内容失败');
}
})
.catch(() => {});
.catch(() => {
state.setLoading(false);
});
};
// 通用取消
const changeCancel = () => {};