package com.example.client.service;
|
|
|
import com.example.client.dto.ColumnDto;
|
import com.example.client.utils.CommonTable;
|
import com.example.client.utils.GBC;
|
import com.example.client.utils.WaitUtil;
|
import com.example.server.DataSync.dto.DataExportDto;
|
import com.example.server.DataSync.service.DataSyncService;
|
import com.example.server.utils.CacheUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.stereotype.Service;
|
|
import javax.swing.*;
|
import java.awt.*;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
@Service
|
public class DataExportManageService {
|
@Autowired
|
DataSyncService dataSyncService;
|
@Autowired
|
ImportDataService importDataService;
|
|
public JPanel createTable(Integer width, Integer height, JFrame jFrame) {
|
JPanel panel = new JPanel(new BorderLayout()); // 使用 BorderLayout
|
panel.setPreferredSize(new Dimension(width - 10, height));
|
|
JPanel left = new JPanel(new BorderLayout()); // 为 left 设置布局
|
left.setPreferredSize(new Dimension((width - 10) / 2, height));
|
|
JPanel right = new JPanel(new BorderLayout()); // 为 right 设置布局
|
right.setPreferredSize(new Dimension((width - 10) / 2, height));
|
|
JButton btnExport = new JButton("导出");
|
JPanel top = new JPanel(new FlowLayout(FlowLayout.LEFT)); // 为 left 设置布局
|
top.add(btnExport);
|
|
JLabel label1 = new JLabel("提示信息");
|
JTextArea tips = new JTextArea(7, 30);
|
tips.setEnabled(false);
|
tips.setLineWrap(true);
|
|
JPanel center = new JPanel(new BorderLayout()); // 为 left 设置布局
|
center.setPreferredSize(new Dimension((width - 10) / 2, height-50));
|
center.add(label1,BorderLayout.NORTH);
|
center.add(tips,BorderLayout.CENTER);
|
|
left.add(top, BorderLayout.NORTH);
|
left.add(center, BorderLayout.CENTER);
|
|
JLabel label2 = new JLabel("导出记录");
|
List<DataExportDto> list = new ArrayList<>();
|
List<ColumnDto> columnDto = new ArrayList<>();
|
columnDto.add(new ColumnDto("序号", "", 265, "autoCreate", false, null, null));
|
columnDto.add(new ColumnDto("导出时间", "exportDate", 265, null, false, null, null));
|
columnDto.add(new ColumnDto("导出人", "importStaff", 265, null, false, null, null));
|
JTable table = CommonTable.createCommonTable(list, columnDto);
|
table.setRowHeight(25);
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
|
right.add(label2, BorderLayout.NORTH);
|
right.add(new JScrollPane(table), BorderLayout.CENTER); // 将 table 包装在 JScrollPane 中
|
|
panel.add(left, BorderLayout.WEST);
|
panel.add(right, BorderLayout.CENTER); // 将 right 添加到 CENTER 区域
|
|
btnExport.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
dataSyncService.export();
|
}
|
});
|
|
return panel;
|
}
|
}
|