package com.example.client.service; import com.example.client.dto.ColumnDto; import com.example.client.dto.JComboBoxItem; import com.example.client.utils.CommonTable; import com.example.client.utils.Compute; import com.example.client.utils.GBC; import com.example.server.progressTrack.model.DjJdgzTrackRecord; import com.example.server.progressTrack.service.DjJdgzTrackRecordService; import com.example.server.teamGroup.service.SysTeamGroupClassService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.List; @Service public class ProgressPromptService { @Autowired private DjJdgzTrackRecordService djJdgzTrackRecordService; private JTable table; private List list; @Autowired private SysTeamGroupClassService sysTeamGroupClassService; public void createTable(JFrame jFrame,Long level1NetworkId) { JFrame frame1 = new JFrame("进度检查"); frame1.setSize(1200, 700); frame1.setResizable(false); frame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame1.setLocationRelativeTo(null); frame1.setVisible(true); frame1.addWindowListener(new WindowAdapter() { //添加第二个界面的关闭事件: public void windowClosing(WindowEvent e) { //添加事件: jFrame.setEnabled(true);//将主界面再设置为可操作的 } }); JPanel topJpanel = new JPanel(); GridBagLayout layout = new GridBagLayout(); topJpanel.setLayout(layout); topJpanel.setPreferredSize(new Dimension(1200 - 20, 40)); topJpanel.setBackground(Color.WHITE); JPanel centerJpanel = new JPanel(); centerJpanel.setPreferredSize(new Dimension(1200 - 20,700-40)); centerJpanel.setBackground(Color.WHITE); frame1.add(topJpanel, BorderLayout.NORTH); frame1.add(centerJpanel, BorderLayout.CENTER); JComboBoxItem[] deptList = sysTeamGroupClassService.getDeptList(); JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(null); JLabel JLabel1 = new JLabel("部门"); JComboBox comboBox1 = new JComboBox<>(deptList); comboBox1.setPreferredSize(new Dimension(140, 28)); comboBox1.setMaximumSize(new Dimension(140, 28)); JComboBoxItem[] teamList1 = sysTeamGroupClassService.getTeamList(deptList[0].getId()); JLabel JLabel2 = new JLabel("专业"); JComboBox comboBox2 = new JComboBox<>(teamList1); comboBox2.setPreferredSize(new Dimension(140, 28)); comboBox2.setMaximumSize(new Dimension(140, 28)); JTextField sb = new JTextField(16); sb.setPreferredSize(new Dimension(140, 28)); sb.setMaximumSize(new Dimension(140, 28)); JButton query = new JButton("查询"); query.setPreferredSize(new Dimension(90, 28)); topJpanel.add(JLabel1, new GBC(0, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); topJpanel.add(comboBox1, new GBC(1, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); topJpanel.add(JLabel2, new GBC(3, 0, 1, 1).setAnchor(GBC.SOUTHEAST).setInsets(5)); topJpanel.add(comboBox2, new GBC(4, 0, 2, 1).setAnchor(GBC.SOUTHWEST).setInsets(5)); topJpanel.add(sb, new GBC(8, 0, 3, 1).setInsets(5)); topJpanel.add(query, new GBC(15, 0, 1, 1).setInsets(5)); List columnDto = new ArrayList<>(); list = djJdgzTrackRecordService.prompt(level1NetworkId, null, null, null); //columnDto.add(new ColumnDto("ID", "id", -1, null,false)); columnDto.add(new ColumnDto("工程名称", "ProjectName", 280, null, false, null,null)); columnDto.add(new ColumnDto("班组专业", "teamgroupName", 150, null, false, null,null)); columnDto.add(new ColumnDto("一级节点", "level1NodeName", 150, null, false, null,null)); columnDto.add(new ColumnDto("二级节点", "level2NodeName", 150, null, false, null,null)); columnDto.add(new ColumnDto("项目名称", "level3NetworkName", 150, null, false, null,null)); columnDto.add(new ColumnDto("当前节点", "level3NodeName", 150, null, false, null,null)); columnDto.add(new ColumnDto("状态", "status", 150, null, false, null,null)); table = CommonTable.createCommonTable(list, columnDto); table.setRowHeight(25); comboBox1.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent event) { JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem(); Long deptId = dept.getId(); JComboBoxItem[] teamList = sysTeamGroupClassService.getTeamList(deptId); comboBox2.setModel(new DefaultComboBoxModel<>(teamList)); JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem(); list = djJdgzTrackRecordService.prompt(level1NetworkId,deptId,team.getId(),null); CommonTable.refreshTable(list, columnDto, table); table.setRowHeight(25); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); } }); comboBox2.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent event) { JComboBoxItem dept = (JComboBoxItem) comboBox1.getSelectedItem(); JComboBoxItem team = (JComboBoxItem) comboBox2.getSelectedItem(); list = djJdgzTrackRecordService.prompt(level1NetworkId,dept.getId(),team.getId(),null); CommonTable.refreshTable(list, columnDto, table); table.setRowHeight(25); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); } }); query.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { list = djJdgzTrackRecordService.prompt(level1NetworkId, null, null,sb.getText()); CommonTable.refreshTable(list, columnDto, table); table.setRowHeight(25); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); } }); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); JScrollPane scrollTable = new JScrollPane(table); scrollTable.setPreferredSize(new Dimension(1200 - 20,700-40)); centerJpanel.add(scrollTable); frame1.setVisible(true); } }