|
|
@@ -433,8 +433,6 @@ export default {
|
|
|
pageNum: 1,
|
|
|
pageSize: 10,
|
|
|
totalSize: 0,
|
|
|
- analysisState: "",
|
|
|
- errState: "",
|
|
|
},
|
|
|
tableData: [],
|
|
|
rowInfo: {},
|
|
|
@@ -442,46 +440,86 @@ export default {
|
|
|
viewerInstance: null, // PDF 文件 URL
|
|
|
dialogReportVisible: false,
|
|
|
pdfUrl: "",
|
|
|
+ isPolling: false, // 轮询状态标识
|
|
|
+ firstLoad: true, // 是否是第一次加载
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
+ window.addEventListener("message", this.handleMessage); //江
|
|
|
this.getTableList();
|
|
|
- window.addEventListener("message", this.handleMessage);//江
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
+ this.stopPolling();
|
|
|
// 销毁消息监听器
|
|
|
- window.removeEventListener("message", this.handleMessage);//江
|
|
|
+ window.removeEventListener("message", this.handleMessage); //江
|
|
|
},
|
|
|
methods: {
|
|
|
-
|
|
|
//江
|
|
|
- handleMessage(event) {
|
|
|
- // 确保消息来自当前域
|
|
|
- if (event.origin !== window.location.origin) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ // handleMessage(event) {
|
|
|
+ // // 确保消息来自当前域
|
|
|
+ // if (event.origin !== window.location.origin) {
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // // 获取传递的参数
|
|
|
+ // const { fieldName, analysisState, errState } = event.data;
|
|
|
|
|
|
- // 获取传递的参数
|
|
|
- const { fieldName, analysisState, errState } = event.data;
|
|
|
+ // // 更新表单字段并调用查询
|
|
|
+ // if (fieldName !== undefined) {
|
|
|
+ // this.formInline.fieldName = fieldName;
|
|
|
+ // console.log(fieldName, "0");
|
|
|
+ // }
|
|
|
+ // if (analysisState !== undefined) {
|
|
|
+ // this.formInline.analysisState = analysisState;
|
|
|
+ // console.log(analysisState, "2");
|
|
|
+ // }
|
|
|
+ // if (errState !== undefined) {
|
|
|
+ // this.formInline.errState = errState;
|
|
|
+ // console.log(errState, "1");
|
|
|
+ // }
|
|
|
|
|
|
- // 更新表单字段并调用查询
|
|
|
- if (fieldName !== undefined) {
|
|
|
- this.formInline.fieldName = fieldName;
|
|
|
- console.log(fieldName, "0");
|
|
|
- }
|
|
|
- if (analysisState !== undefined) {
|
|
|
- this.formInline.analysisState = analysisState;
|
|
|
- console.log(analysisState, "2");
|
|
|
- }
|
|
|
- if (errState !== undefined) {
|
|
|
- this.formInline.errState = errState;
|
|
|
- console.log(errState, "1");
|
|
|
- }
|
|
|
-
|
|
|
- // 调用查询方法
|
|
|
- this.getTableList();
|
|
|
+ // // 调用查询方法
|
|
|
+ // this.getTableList();
|
|
|
+ // },
|
|
|
+ // 创建分析时请求
|
|
|
+ async addRuleFormSubmit() {
|
|
|
+ this.$refs.addRuleForm.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ try {
|
|
|
+ const res = await addAnalysisResult(this.addRuleForm);
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "创建成功",
|
|
|
+ });
|
|
|
+ this.addDialogVisible = false;
|
|
|
+ this.getTableList();
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ console.error(err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
+ AddHandleCloses(done) {
|
|
|
+ this.$confirm("确认关闭?")
|
|
|
+ .then((_) => {
|
|
|
+ done();
|
|
|
+ })
|
|
|
+ .catch((_) => {});
|
|
|
+ },
|
|
|
+ //获取风场列表
|
|
|
+ async getQueryCodeNumList() {
|
|
|
+ this.loading = true;
|
|
|
+ try {
|
|
|
+ const result = await queryCodeNum();
|
|
|
+ this.fieldCodeList = result.data.fieldCodeList;
|
|
|
+ this.loading = false;
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error);
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
handleCloses(done) {
|
|
|
this.$confirm("确认关闭?")
|
|
|
.then((_) => {
|
|
|
@@ -571,40 +609,95 @@ export default {
|
|
|
handleConfirm() {
|
|
|
this.dialogVisible = false;
|
|
|
},
|
|
|
- //分页数据切换
|
|
|
+ // 页码变化时才触发查询
|
|
|
handleCurrentChange(val) {
|
|
|
this.formInline.pageNum = val;
|
|
|
this.getTableList();
|
|
|
},
|
|
|
|
|
|
- // 江修改部分
|
|
|
+ // 修改 getTableList 方法,避免重复请求
|
|
|
async getTableList() {
|
|
|
+ // 如果正在请求中,跳过此次调用
|
|
|
+ if (this.loading || this.isPolling) return;
|
|
|
+
|
|
|
+ this.loading = true;
|
|
|
try {
|
|
|
- this.loading = true;
|
|
|
const params = { ...this.formInline, totalSize: undefined };
|
|
|
|
|
|
- // 如果 analysisState 存在,传递 analysisState 参数
|
|
|
+ // 传递条件参数
|
|
|
if (this.formInline.analysisState !== undefined) {
|
|
|
params.analysisState = this.formInline.analysisState;
|
|
|
}
|
|
|
-
|
|
|
- // 如果 errState 存在,传递 errState 参数
|
|
|
if (this.formInline.errState !== undefined) {
|
|
|
params.errState = this.formInline.errState;
|
|
|
}
|
|
|
|
|
|
- // 发起请求
|
|
|
- const result = await getAnalysisResultList(params);
|
|
|
+ const result = await analysisResultList(params);
|
|
|
this.tableData = result.data.list;
|
|
|
this.formInline.totalSize = result.data.totalSize;
|
|
|
- this.loading = false;
|
|
|
} catch (error) {
|
|
|
this.$message({
|
|
|
type: "error",
|
|
|
message: "请检查是否连接网络",
|
|
|
});
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 改进 handleMessage,避免频繁请求
|
|
|
+ handleMessage(event) {
|
|
|
+ // 确保消息来自当前域
|
|
|
+ if (event.origin !== window.location.origin) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const { fieldName, analysisState, errState } = event.data;
|
|
|
+
|
|
|
+ // 更新表单字段
|
|
|
+ if (fieldName !== undefined) {
|
|
|
+ this.formInline.fieldName = fieldName;
|
|
|
+ console.log(fieldName, "0");
|
|
|
+ }
|
|
|
+ if (analysisState !== undefined) {
|
|
|
+ this.formInline.analysisState = analysisState;
|
|
|
+ console.log(analysisState, "2");
|
|
|
+ }
|
|
|
+ if (errState !== undefined) {
|
|
|
+ this.formInline.errState = errState;
|
|
|
+ console.log(errState, "1");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果当前没有请求中,才调用 getTableList
|
|
|
+ if (!this.loading) {
|
|
|
+ this.getTableList();
|
|
|
}
|
|
|
},
|
|
|
+ // async getTableList() {
|
|
|
+ // try {
|
|
|
+ // this.loading = true;
|
|
|
+ // const params = { ...this.formInline, totalSize: undefined };
|
|
|
+
|
|
|
+ // // 如果 analysisState 存在,传递 analysisState 参数
|
|
|
+ // if (this.formInline.analysisState !== undefined) {
|
|
|
+ // params.analysisState = this.formInline.analysisState;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // 如果 errState 存在,传递 errState 参数
|
|
|
+ // if (this.formInline.errState !== undefined) {
|
|
|
+ // params.errState = this.formInline.errState;
|
|
|
+ // }
|
|
|
+ // const result = await analysisResultList(params);
|
|
|
+ // this.tableData = result.data.list;
|
|
|
+ // this.formInline.totalSize = result.data.totalSize;
|
|
|
+ // this.loading = false;
|
|
|
+ // } catch (error) {
|
|
|
+ // this.$message({
|
|
|
+ // type: "error",
|
|
|
+ // message: "请检查是否连接网络",
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // },
|
|
|
rowStyle() {
|
|
|
return "text-align:center";
|
|
|
},
|
|
|
@@ -615,11 +708,9 @@ export default {
|
|
|
// 重置
|
|
|
reset(formName) {
|
|
|
this.$refs[formName].resetFields();
|
|
|
- this.formInline.fieldName=""
|
|
|
- this.formInline.analysisState=""
|
|
|
- this.formInline.errState=""
|
|
|
this.getTableList();
|
|
|
},
|
|
|
+ // fetchData 方法在轮询中调用
|
|
|
async fetchData() {
|
|
|
try {
|
|
|
const result = await analysisResultList({
|
|
|
@@ -635,39 +726,78 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ // async fetchData() {
|
|
|
+ // try {
|
|
|
+ // const result = await analysisResultList({
|
|
|
+ // ...this.formInline,
|
|
|
+ // totalSize: undefined,
|
|
|
+ // });
|
|
|
+ // this.tableData = result.data.list;
|
|
|
+ // this.formInline.totalSize = result.data.totalSize;
|
|
|
+ // } catch (error) {
|
|
|
+ // this.$message({
|
|
|
+ // type: "error",
|
|
|
+ // message: "请检查是否连接网络",
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // stopPolling() {
|
|
|
+ // if (this.intervalId) {
|
|
|
+ // clearInterval(this.intervalId);
|
|
|
+ // this.intervalId = null;
|
|
|
+ // }
|
|
|
+ // },
|
|
|
stopPolling() {
|
|
|
if (this.intervalId) {
|
|
|
clearInterval(this.intervalId);
|
|
|
this.intervalId = null;
|
|
|
}
|
|
|
+ this.isPolling = false;
|
|
|
},
|
|
|
+
|
|
|
+ // 启动轮询时,避免重复请求
|
|
|
startPolling() {
|
|
|
this.startTime = new Date().getTime();
|
|
|
+ this.isPolling = true;
|
|
|
+
|
|
|
this.intervalId = setInterval(() => {
|
|
|
const currentTime = new Date().getTime();
|
|
|
if (currentTime - this.startTime >= this.maxPollingTime) {
|
|
|
this.stopPolling();
|
|
|
} else {
|
|
|
- // 轮询
|
|
|
- // this.fetchData();
|
|
|
+ // 轮询期间不重复请求,检查是否可以调用 fetchData
|
|
|
+ if (!this.loading) {
|
|
|
+ this.fetchData();
|
|
|
+ }
|
|
|
}
|
|
|
- }, 10000); // 每10秒调用一次
|
|
|
+ }, 10000); // 每10秒检查一次
|
|
|
},
|
|
|
+ // startPolling() {
|
|
|
+ // this.startTime = new Date().getTime();
|
|
|
+ // this.intervalId = setInterval(() => {
|
|
|
+ // const currentTime = new Date().getTime();
|
|
|
+ // if (currentTime - this.startTime >= this.maxPollingTime) {
|
|
|
+ // this.stopPolling();
|
|
|
+ // } else {
|
|
|
+ // // 轮询
|
|
|
+ // // this.fetchData();
|
|
|
+ // }
|
|
|
+ // }, 10000); // 每10秒调用一次
|
|
|
+ // },
|
|
|
//创建分析
|
|
|
Newanalyse() {
|
|
|
this.addDialogVisible = true;
|
|
|
this.getQueryCodeNumList();
|
|
|
},
|
|
|
examine() {
|
|
|
- window.open(this.$router.resolve({ path: "/transition" }).href, "_blank");
|
|
|
+ this.$router.push({
|
|
|
+ path: "/home/transition/index",
|
|
|
+ });
|
|
|
},
|
|
|
},
|
|
|
mounted() {
|
|
|
this.startPolling();
|
|
|
},
|
|
|
- beforeDestroy() {
|
|
|
- this.stopPolling();
|
|
|
- },
|
|
|
};
|
|
|
</script>
|
|
|
|