|
@@ -63,6 +63,8 @@
|
|
|
lazy
|
|
|
:load="load"
|
|
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
|
|
+ ref="table"
|
|
|
+ @expand-change="handleExpandChange"
|
|
|
>
|
|
|
<!-- Table Columns -->
|
|
|
<el-table-column prop="fieldName" label="风场名称" min-width="200">
|
|
@@ -552,6 +554,7 @@ export default {
|
|
|
intervalId: null,
|
|
|
startTime: null,
|
|
|
maxPollingTime: 5 * 60 * 1000, //轮询最大时间
|
|
|
+ expandedKeys: new Set(), // 用于存储展开行的唯一标识
|
|
|
loading: false,
|
|
|
forPltFrom: {},
|
|
|
editTransferStateForm: {
|
|
@@ -630,10 +633,19 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
- this.getTableList();
|
|
|
+ this.fetchData();
|
|
|
this.getBatchCodeList();
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 处理行展开和收起事件
|
|
|
+ handleExpandChange(row, expandedRows) {
|
|
|
+ console.log("row", row);
|
|
|
+ if (expandedRows) {
|
|
|
+ this.expandedKeys.add(row.uniqueCode); // 添加到展开列表
|
|
|
+ } else {
|
|
|
+ this.expandedKeys.delete(row.uniqueCode); // 从展开列表中删除
|
|
|
+ }
|
|
|
+ },
|
|
|
load(tree, treeNode, resolve) {
|
|
|
console.log(tree, "tree");
|
|
|
const { batchCode } = tree; // 假设每行都有唯一的 id
|
|
@@ -648,6 +660,59 @@ export default {
|
|
|
resolve([]); // 确保 resolve 被调用
|
|
|
});
|
|
|
},
|
|
|
+ async fetchData() {
|
|
|
+ try {
|
|
|
+ const result = await queryDataTransferGroup({
|
|
|
+ ...this.formInline,
|
|
|
+ totalSize: undefined,
|
|
|
+ });
|
|
|
+ this.tableData = result.data.list.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ hasChildren: true,
|
|
|
+ uniqueCode: item.batchCode + item.fieldCode,
|
|
|
+ children: [],
|
|
|
+ };
|
|
|
+ });
|
|
|
+ this.formInline.totalSize = result.data.totalSize;
|
|
|
+ // 恢复展开状态
|
|
|
+ console.log(this.expandedKeys, "this.expandedKeys");
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.tableData.forEach((row) => {
|
|
|
+ if (this.expandedKeys.has(row.uniqueCode)) {
|
|
|
+ this.$refs.table.toggleRowExpansion(row, true);
|
|
|
+ // 手动触发子节点加载
|
|
|
+ this.load(row, {}, (children) => {
|
|
|
+ row.children = children;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "请检查是否连接网络",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ stopPolling() {
|
|
|
+ if (this.intervalId) {
|
|
|
+ clearInterval(this.intervalId);
|
|
|
+ this.intervalId = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 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秒调用一次
|
|
|
+ },
|
|
|
handleCloses(done) {
|
|
|
this.$confirm("确认关闭?")
|
|
|
.then((_) => {
|
|
@@ -716,7 +781,7 @@ export default {
|
|
|
type: "success",
|
|
|
});
|
|
|
this.$refs.forPltRef.reset("fromPlt");
|
|
|
- this.getTableList();
|
|
|
+ this.fetchData();
|
|
|
this.editstateCancel();
|
|
|
})
|
|
|
.catch((error) => {
|
|
@@ -783,7 +848,7 @@ export default {
|
|
|
this.editNuedialog = false;
|
|
|
this.loadingViewEdit = false;
|
|
|
if (!name) {
|
|
|
- this.getTableList();
|
|
|
+ this.fetchData();
|
|
|
}
|
|
|
this.getBatchCodeList();
|
|
|
},
|
|
@@ -861,12 +926,12 @@ export default {
|
|
|
},
|
|
|
// 查询
|
|
|
onSubmit() {
|
|
|
- this.getTableList();
|
|
|
+ this.fetchData();
|
|
|
},
|
|
|
// 重置
|
|
|
reset(formName) {
|
|
|
this.$refs[formName].resetFields();
|
|
|
- this.getTableList();
|
|
|
+ this.fetchData();
|
|
|
},
|
|
|
// 新增
|
|
|
newly(formName) {
|
|
@@ -879,7 +944,7 @@ export default {
|
|
|
message: "新增成功",
|
|
|
type: "success",
|
|
|
});
|
|
|
- this.getTableList();
|
|
|
+ this.fetchData();
|
|
|
this.cancel();
|
|
|
this.loadingView = false;
|
|
|
})
|
|
@@ -907,33 +972,11 @@ export default {
|
|
|
alert("弹出窗口已被阻止!请允许弹出式窗口访问本网站。");
|
|
|
}
|
|
|
},
|
|
|
- async getTableList() {
|
|
|
- try {
|
|
|
- this.loading = true;
|
|
|
- const result = await queryDataTransferGroup({
|
|
|
- ...this.formInline,
|
|
|
- totalSize: undefined,
|
|
|
- });
|
|
|
- this.tableData = result.data.list.map((item) => {
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- hasChildren: true,
|
|
|
- children: [],
|
|
|
- };
|
|
|
- });
|
|
|
- this.formInline.totalSize = result.data.totalSize;
|
|
|
- this.loading = false;
|
|
|
- } catch (error) {
|
|
|
- this.$message({
|
|
|
- type: "error",
|
|
|
- message: "请检查是否连接网络",
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
+
|
|
|
//分页数据切换
|
|
|
handleCurrentChange(val) {
|
|
|
this.formInline.pageNum = val;
|
|
|
- this.getTableList();
|
|
|
+ this.fetchData();
|
|
|
},
|
|
|
//新增按钮
|
|
|
addData() {
|
|
@@ -977,45 +1020,6 @@ export default {
|
|
|
this.loading = false;
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
- async fetchData() {
|
|
|
- try {
|
|
|
- const result = await queryDataTransferGroup({
|
|
|
- ...this.formInline,
|
|
|
- totalSize: undefined,
|
|
|
- });
|
|
|
- this.tableData = result.data.list.map((item) => {
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- hasChildren: true,
|
|
|
- children: [],
|
|
|
- };
|
|
|
- });
|
|
|
- this.formInline.totalSize = result.data.totalSize;
|
|
|
- } catch (error) {
|
|
|
- this.$message({
|
|
|
- type: "error",
|
|
|
- message: "请检查是否连接网络",
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- stopPolling() {
|
|
|
- if (this.intervalId) {
|
|
|
- clearInterval(this.intervalId);
|
|
|
- this.intervalId = null;
|
|
|
- }
|
|
|
- },
|
|
|
- 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秒调用一次
|
|
|
- },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.startPolling();
|