|
@@ -8,6 +8,7 @@ import {
|
|
|
reactive,
|
|
|
onActivated,
|
|
|
nextTick,
|
|
|
+ onBeforeUnmount,
|
|
|
onUnmounted,
|
|
|
} from "vue";
|
|
|
import request from "@/api/axios.js";
|
|
@@ -126,8 +127,9 @@ const funCurrentChange = async ({ current, currentNode }) => {
|
|
|
//拿取表格数据
|
|
|
const res = await request.post(
|
|
|
"/rest/sql",
|
|
|
- `SELECT tbname as point,description,ts,val,station,category,facility,uniformcode,rate,remark FROM ${myData.nxxy}.${myData.nxxy1} limit 99;`
|
|
|
+ `SELECT tbname as point,description,ts,val,station,category,facility,uniformcode,rate,remark FROM ${databaseName}.${tableName} limit 99;`
|
|
|
);
|
|
|
+
|
|
|
//映射数组里的数据
|
|
|
let newdata = [];
|
|
|
const map = {
|
|
@@ -146,10 +148,16 @@ const funCurrentChange = async ({ current, currentNode }) => {
|
|
|
let dateItem = {};
|
|
|
for (let key in ele) {
|
|
|
dateItem[map[key]] = ele[key];
|
|
|
+
|
|
|
}
|
|
|
dateItem.databaseName = databaseName;
|
|
|
dateItem.tableName = tableName;
|
|
|
newdata.push(dateItem);
|
|
|
+ newdata.forEach((ele)=>{
|
|
|
+let utcTimeStr = ele.ts
|
|
|
+const formattedDateTime = utcTimeStr.replace("T", " ").replace(".000Z", "");
|
|
|
+ ele.ts=formattedDateTime
|
|
|
+ })
|
|
|
});
|
|
|
// console.log(999999,newdata);
|
|
|
|
|
@@ -240,6 +248,11 @@ const nbsubmit = async () => {
|
|
|
// dateItem.databaseName = databaseName;
|
|
|
// dateItem.tableName = tableName;
|
|
|
newdata.push(dateItem);
|
|
|
+ newdata.forEach((ele)=>{
|
|
|
+let utcTimeStr = ele.ts
|
|
|
+const formattedDateTime = utcTimeStr.replace("T", " ").replace(".000Z", "");
|
|
|
+ ele.ts=formattedDateTime
|
|
|
+ })
|
|
|
});
|
|
|
console.log('665', newdata);
|
|
|
tableData.value = newdata;
|
|
@@ -275,7 +288,6 @@ const funSubmit = async (params) => {
|
|
|
let pagenumber = ref(1); //当前的页数
|
|
|
let pagenb = ref(99); //当前的条数
|
|
|
|
|
|
-console.log('667', pagenumber.value);
|
|
|
const left1 = async () => {
|
|
|
pagenumber.value -= 1;
|
|
|
|
|
@@ -306,6 +318,11 @@ const left1 = async () => {
|
|
|
dateItem[map[key]] = ele[key];
|
|
|
}
|
|
|
newdata.push(dateItem);
|
|
|
+ newdata.forEach((ele)=>{
|
|
|
+let utcTimeStr = ele.ts
|
|
|
+const formattedDateTime = utcTimeStr.replace("T", " ").replace(".000Z", "");
|
|
|
+ ele.ts=formattedDateTime
|
|
|
+ })
|
|
|
});
|
|
|
tableData.value = newdata;
|
|
|
};
|
|
@@ -339,6 +356,11 @@ const right1 = async () => {
|
|
|
dateItem[map[key]] = ele[key];
|
|
|
}
|
|
|
newdata.push(dateItem);
|
|
|
+ newdata.forEach((ele)=>{
|
|
|
+let utcTimeStr = ele.ts
|
|
|
+const formattedDateTime = utcTimeStr.replace("T", " ").replace(".000Z", "");
|
|
|
+ ele.ts=formattedDateTime
|
|
|
+ })
|
|
|
});
|
|
|
tableData.value = newdata;
|
|
|
};
|
|
@@ -375,16 +397,19 @@ const startTimer = async () => {
|
|
|
dateItem[map[key]] = ele[key];
|
|
|
}
|
|
|
newdata.push(dateItem);
|
|
|
+ newdata.forEach((ele)=>{
|
|
|
+let utcTimeStr = ele.ts
|
|
|
+const formattedDateTime = utcTimeStr.replace("T", " ").replace(".000Z", "");
|
|
|
+ ele.ts=formattedDateTime
|
|
|
+ })
|
|
|
});
|
|
|
tableData.value = newdata;
|
|
|
- console.log('8686',tableData.value )
|
|
|
- }else{
|
|
|
- clearInterval()
|
|
|
+ // console.log('8686',tableData.value )
|
|
|
}
|
|
|
};
|
|
|
|
|
|
// 实时刷新数据
|
|
|
-setInterval(() => {
|
|
|
+const timerId=setInterval(() => {
|
|
|
startTimer();
|
|
|
console.log("刷新");
|
|
|
}, 3000);
|
|
@@ -402,7 +427,10 @@ onMounted(() => {
|
|
|
});
|
|
|
});
|
|
|
onUnmounted(() => {
|
|
|
- clearInterval()
|
|
|
+ clearInterval(timerId)
|
|
|
+});
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ clearInterval(timerId)
|
|
|
});
|
|
|
|
|
|
/**activated */
|