gugu 3 周之前
父节点
当前提交
312ae53317

+ 129 - 0
src/main/java/org/example/controller/TerminalController.java

@@ -0,0 +1,129 @@
+package org.example.controller;
+
+import org.example.entity.Terminal;
+import org.example.service.TerminalService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("/api/terminals")
+public class TerminalController {
+
+    @Autowired
+    private TerminalService terminalService;
+
+    /**
+     * 获取所有设备列表
+     * @return 设备列表
+     */
+    @GetMapping
+    public List<Terminal> getAllTerminals(
+            @RequestParam(required = false) String terminalType,
+            @RequestParam(required = false) String deptCode,
+            @RequestParam(required = false) String wardCode,
+            @RequestParam(required = false) Boolean isOnline,
+            @RequestParam(required = false) String terminalDesc) {
+        List<Terminal> terminals;
+        if (terminalType != null) {
+            terminals = terminalService.findByTerminalTypeContaining(terminalType);
+        } else if (deptCode != null) {
+            terminals = terminalService.findByDeptCodeContaining(deptCode);
+        } else if (wardCode != null) {
+            terminals = terminalService.findByWardCodeContaining(wardCode);
+        } else if (isOnline != null) {
+            terminals = terminalService.findByIsOnline(isOnline);
+        } else if (terminalDesc != null) {
+            terminals = terminalService.findByTerminalDescContaining(terminalDesc);
+        } else {
+            // 否则返回所有设备
+            terminals = terminalService.findAllTerminals();
+        }
+        return terminals;
+    }
+
+    /**
+     * 根据设备编号获取设备信息
+     * @param terminalNumber 设备编号
+     * @return 设备信息
+     */
+    @GetMapping("/{terminalNumber}")
+    public Map<String, Object> getTerminalByNumber(@PathVariable String terminalNumber) {
+        Map<String, Object> result = new HashMap<>();
+        try {
+            Terminal terminal = terminalService.findByTerminalNumber(terminalNumber);
+            if (terminal != null) {
+                result.put("success", true);
+                result.put("data", terminal);
+            } else {
+                result.put("success", false);
+                result.put("message", "设备不存在");
+            }
+        } catch (Exception e) {
+            result.put("success", false);
+            result.put("message", "查询设备信息失败: " + e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * 添加新设备
+     * @param terminal 设备信息
+     * @return 操作结果
+     */
+    @PostMapping
+    public Map<String, Object> addTerminal(@RequestBody Terminal terminal) {
+        Map<String, Object> result = new HashMap<>();
+        try {
+            terminalService.addTerminal(terminal);
+            result.put("success", true);
+            result.put("message", "设备添加成功");
+        } catch (Exception e) {
+            result.put("success", false);
+            result.put("message", "设备添加失败: " + e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * 更新设备信息
+     * @param terminalNumber 设备编号
+     * @param terminal 设备信息
+     * @return 操作结果
+     */
+    @PutMapping("/{terminalNumber}")
+    public Map<String, Object> updateTerminal(@PathVariable String terminalNumber, @RequestBody Terminal terminal) {
+        Map<String, Object> result = new HashMap<>();
+        try {
+            terminalService.updateTerminal(terminalNumber, terminal);
+            result.put("success", true);
+            result.put("message", "设备更新成功");
+        } catch (Exception e) {
+            result.put("success", false);
+            result.put("message", "设备更新失败: " + e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * 删除设备
+     * @param terminalNumber 设备编号
+     * @return 操作结果
+     */
+    @DeleteMapping("/{terminalNumber}")
+    public Map<String, Object> deleteTerminal(@PathVariable String terminalNumber) {
+        Map<String, Object> result = new HashMap<>();
+        try {
+            terminalService.deleteTerminal(terminalNumber);
+            result.put("success", true);
+            result.put("message", "设备删除成功");
+        } catch (Exception e) {
+            result.put("success", false);
+            result.put("message", "设备删除失败: " + e.getMessage());
+        }
+        return result;
+    }
+}

+ 139 - 0
src/main/java/org/example/entity/Terminal.java

@@ -0,0 +1,139 @@
+package org.example.entity;
+
+public class Terminal {
+    private Long id;              // 主键ID
+    private String terminalType;  // 设备类型
+    private String terminalNumber;// 设备编码
+    private String terminalDesc;  // 设备名称
+    private String deptCode;      // 所属科室
+    private String wardCode;      // 所属病区
+    private String ipAddress;     // IP地址
+    private String subnetMask;    // 子网掩码
+    private String gatewayAddress;// 默认网关
+    private String macAddress;    // Mac地址
+    private Boolean isOnline;     // 在线状态
+
+    // Constructors
+    public Terminal() {}
+
+    public Terminal(String terminalType, String terminalNumber, String terminalDesc, String deptCode,
+                   String wardCode, String ipAddress, String subnetMask, String gatewayAddress,
+                   String macAddress, Boolean isOnline) {
+        this.terminalType = terminalType;
+        this.terminalNumber = terminalNumber;
+        this.terminalDesc = terminalDesc;
+        this.deptCode = deptCode;
+        this.wardCode = wardCode;
+        this.ipAddress = ipAddress;
+        this.subnetMask = subnetMask;
+        this.gatewayAddress = gatewayAddress;
+        this.macAddress = macAddress;
+        this.isOnline = isOnline;
+    }
+
+    // Getters and Setters
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getTerminalType() {
+        return terminalType;
+    }
+
+    public void setTerminalType(String terminalType) {
+        this.terminalType = terminalType;
+    }
+
+    public String getTerminalNumber() {
+        return terminalNumber;
+    }
+
+    public void setTerminalNumber(String terminalNumber) {
+        this.terminalNumber = terminalNumber;
+    }
+
+    public String getTerminalDesc() {
+        return terminalDesc;
+    }
+
+    public void setTerminalDesc(String terminalDesc) {
+        this.terminalDesc = terminalDesc;
+    }
+
+    public String getDeptCode() {
+        return deptCode;
+    }
+
+    public void setDeptCode(String deptCode) {
+        this.deptCode = deptCode;
+    }
+
+    public String getWardCode() {
+        return wardCode;
+    }
+
+    public void setWardCode(String wardCode) {
+        this.wardCode = wardCode;
+    }
+
+    public String getIpAddress() {
+        return ipAddress;
+    }
+
+    public void setIpAddress(String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    public String getSubnetMask() {
+        return subnetMask;
+    }
+
+    public void setSubnetMask(String subnetMask) {
+        this.subnetMask = subnetMask;
+    }
+
+    public String getGatewayAddress() {
+        return gatewayAddress;
+    }
+
+    public void setGatewayAddress(String gatewayAddress) {
+        this.gatewayAddress = gatewayAddress;
+    }
+
+    public String getMacAddress() {
+        return macAddress;
+    }
+
+    public void setMacAddress(String macAddress) {
+        this.macAddress = macAddress;
+    }
+
+    public Boolean getIsOnline() {
+        return isOnline;
+    }
+
+    public void setIsOnline(Boolean isOnline) {
+        this.isOnline = isOnline;
+    }
+
+    @Override
+    public String toString() {
+        return "Terminal{" +
+                "id=" + id +
+                ", terminalType='" + terminalType + '\'' +
+                ", terminalNumber='" + terminalNumber + '\'' +
+                ", terminalDesc='" + terminalDesc + '\'' +
+                ", deptCode='" + deptCode + '\'' +
+                ", wardCode='" + wardCode + '\'' +
+                ", ipAddress='" + ipAddress + '\'' +
+                ", subnetMask='" + subnetMask + '\'' +
+                ", gatewayAddress='" + gatewayAddress + '\'' +
+                ", macAddress='" + macAddress + '\'' +
+                ", isOnline=" + isOnline +
+                '}';
+    }
+}

+ 77 - 0
src/main/java/org/example/mapper/TerminalMapper.java

@@ -0,0 +1,77 @@
+package org.example.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.example.entity.Terminal;
+
+import java.util.List;
+
+@Mapper
+public interface TerminalMapper {
+    /**
+     * 查询所有设备信息
+     * @return 设备列表
+     */
+    List<Terminal> findAll();
+
+    /**
+     * 根据设备编号查询设备信息
+     * @param terminalNumber 设备编号
+     * @return 设备信息
+     */
+    Terminal findByTerminalNumber(String terminalNumber);
+
+    /**
+     * 根据设备类型模糊查询设备列表
+     * @param terminalType 设备类型
+     * @return 设备列表
+     */
+    List<Terminal> findByTerminalTypeContaining(String terminalType);
+
+    /**
+     * 根据所属科室模糊查询设备列表
+     * @param deptCode 所属科室
+     * @return 设备列表
+     */
+    List<Terminal> findByDeptCodeContaining(String deptCode);
+
+    /**
+     * 根据所属病区模糊查询设备列表
+     * @param wardCode 所属病区
+     * @return 设备列表
+     */
+    List<Terminal> findByWardCodeContaining(String wardCode);
+
+    /**
+     * 根据在线状态查询设备列表
+     * @param isOnline 在线状态
+     * @return 设备列表
+     */
+    List<Terminal> findByIsOnline(Boolean isOnline);
+
+    /**
+     * 根据设备名称模糊查询设备列表
+     * @param terminalDesc 设备名称
+     * @return 设备列表
+     */
+    List<Terminal> findByTerminalDescContaining(String terminalDesc);
+
+    /**
+     * 插入新设备
+     * @param terminal 设备信息
+     */
+    void insert(Terminal terminal);
+
+    /**
+     * 更新设备信息
+     * @param terminal 设备信息
+     * @param terminalNumber 设备编号
+     */
+    void update(@Param("terminal") Terminal terminal, @Param("terminalNumber") String terminalNumber);
+
+    /**
+     * 删除设备
+     * @param terminalNumber 设备编号
+     */
+    void deleteByTerminalNumber(String terminalNumber);
+}

+ 102 - 0
src/main/java/org/example/service/TerminalService.java

@@ -0,0 +1,102 @@
+package org.example.service;
+
+import org.example.entity.Terminal;
+import org.example.mapper.TerminalMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class TerminalService {
+
+    @Autowired
+    private TerminalMapper terminalMapper;
+
+    /**
+     * 查询所有设备信息
+     * @return 设备列表
+     */
+    public List<Terminal> findAllTerminals() {
+        return terminalMapper.findAll();
+    }
+
+    /**
+     * 根据设备编号查询设备信息
+     * @param terminalNumber 设备编号
+     * @return 设备信息
+     */
+    public Terminal findByTerminalNumber(String terminalNumber) {
+        return terminalMapper.findByTerminalNumber(terminalNumber);
+    }
+
+    /**
+     * 根据设备类型模糊查询设备列表
+     * @param terminalType 设备类型
+     * @return 设备列表
+     */
+    public List<Terminal> findByTerminalTypeContaining(String terminalType) {
+        return terminalMapper.findByTerminalTypeContaining(terminalType);
+    }
+
+    /**
+     * 根据所属科室模糊查询设备列表
+     * @param deptCode 所属科室
+     * @return 设备列表
+     */
+    public List<Terminal> findByDeptCodeContaining(String deptCode) {
+        return terminalMapper.findByDeptCodeContaining(deptCode);
+    }
+
+    /**
+     * 根据所属病区模糊查询设备列表
+     * @param wardCode 所属病区
+     * @return 设备列表
+     */
+    public List<Terminal> findByWardCodeContaining(String wardCode) {
+        return terminalMapper.findByWardCodeContaining(wardCode);
+    }
+
+    /**
+     * 根据在线状态查询设备列表
+     * @param isOnline 在线状态
+     * @return 设备列表
+     */
+    public List<Terminal> findByIsOnline(Boolean isOnline) {
+        return terminalMapper.findByIsOnline(isOnline);
+    }
+
+    /**
+     * 根据设备名称模糊查询设备列表
+     * @param terminalDesc 设备名称
+     * @return 设备列表
+     */
+    public List<Terminal> findByTerminalDescContaining(String terminalDesc) {
+        return terminalMapper.findByTerminalDescContaining(terminalDesc);
+    }
+
+    /**
+     * 添加新设备
+     * @param terminal 设备信息
+     */
+    public void addTerminal(Terminal terminal) {
+        terminalMapper.insert(terminal);
+    }
+
+    /**
+     * 更新设备信息
+     * @param terminalNumber 原始设备编号
+     * @param terminal 设备信息
+     */
+    public void updateTerminal(String terminalNumber, Terminal terminal) {
+        terminalMapper.update(terminal, terminalNumber);
+    }
+
+    /**
+     * 删除设备
+     * @param terminalNumber 设备编号
+     */
+    public void deleteTerminal(String terminalNumber) {
+        terminalMapper.deleteByTerminalNumber(terminalNumber);
+    }
+}

+ 94 - 0
src/main/resources/mapper/TerminalMapper.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.example.mapper.TerminalMapper">
+
+    <resultMap id="TerminalResultMap" type="org.example.entity.Terminal">
+        <id property="id" column="id"/>
+        <result property="terminalType" column="terminal_type"/>
+        <result property="terminalNumber" column="terminal_number"/>
+        <result property="terminalDesc" column="terminal_desc"/>
+        <result property="deptCode" column="dept_code"/>
+        <result property="wardCode" column="ward_code"/>
+        <result property="ipAddress" column="ip_address"/>
+        <result property="subnetMask" column="subnet_mask"/>
+        <result property="gatewayAddress" column="gateway_address"/>
+        <result property="macAddress" column="mac_address"/>
+        <result property="isOnline" column="is_online"/>
+    </resultMap>
+
+    <!-- 查询所有设备 -->
+    <select id="findAll" resultMap="TerminalResultMap">
+        SELECT id, terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online
+        FROM tb_terminal
+    </select>
+
+    <!-- 根据设备编号查询设备 -->
+    <select id="findByTerminalNumber" parameterType="string" resultMap="TerminalResultMap">
+        SELECT id, terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online
+        FROM tb_terminal
+        WHERE terminal_number = #{terminalNumber} LIMIT 1
+    </select>
+
+    <!-- 根据设备类型模糊查询设备列表 -->
+    <select id="findByTerminalTypeContaining" parameterType="string" resultMap="TerminalResultMap">
+        SELECT id, terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online
+        FROM tb_terminal
+        WHERE terminal_type LIKE CONCAT('%', #{terminalType}, '%')
+    </select>
+
+    <!-- 根据所属科室模糊查询设备列表 -->
+    <select id="findByDeptCodeContaining" parameterType="string" resultMap="TerminalResultMap">
+        SELECT id, terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online
+        FROM tb_terminal
+        WHERE dept_code LIKE CONCAT('%', #{deptCode}, '%')
+    </select>
+
+    <!-- 根据所属病区模糊查询设备列表 -->
+    <select id="findByWardCodeContaining" parameterType="string" resultMap="TerminalResultMap">
+        SELECT id, terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online
+        FROM tb_terminal
+        WHERE ward_code LIKE CONCAT('%', #{wardCode}, '%')
+    </select>
+
+    <!-- 根据在线状态查询设备列表 -->
+    <select id="findByIsOnline" parameterType="boolean" resultMap="TerminalResultMap">
+        SELECT id, terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online
+        FROM tb_terminal
+        WHERE is_online = #{isOnline}
+    </select>
+
+    <!-- 根据设备名称模糊查询设备列表 -->
+    <select id="findByTerminalDescContaining" parameterType="string" resultMap="TerminalResultMap">
+        SELECT id, terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online
+        FROM tb_terminal
+        WHERE terminal_desc LIKE CONCAT('%', #{terminalDesc}, '%')
+    </select>
+
+    <!-- 插入新设备 -->
+    <insert id="insert" parameterType="org.example.entity.Terminal">
+        INSERT INTO tb_terminal(terminal_type, terminal_number, terminal_desc, dept_code, ward_code, ip_address, subnet_mask, gateway_address, mac_address, is_online)
+        VALUES(#{terminalType}, #{terminalNumber}, #{terminalDesc}, #{deptCode}, #{wardCode}, #{ipAddress}, #{subnetMask}, #{gatewayAddress}, #{macAddress}, #{isOnline})
+    </insert>
+
+    <!-- 更新设备信息 -->
+    <update id="update" parameterType="map">
+        UPDATE tb_terminal
+        SET terminal_type = #{terminal.terminalType},
+            terminal_number = #{terminal.terminalNumber},
+            terminal_desc = #{terminal.terminalDesc},
+            dept_code = #{terminal.deptCode},
+            ward_code = #{terminal.wardCode},
+            ip_address = #{terminal.ipAddress},
+            subnet_mask = #{terminal.subnetMask},
+            gateway_address = #{terminal.gatewayAddress},
+            mac_address = #{terminal.macAddress},
+            is_online = #{terminal.isOnline}
+        WHERE terminal_number = #{terminalNumber}
+    </update>
+
+    <!-- 删除设备 -->
+    <delete id="deleteByTerminalNumber" parameterType="string">
+        DELETE FROM tb_terminal WHERE terminal_number = #{terminalNumber}
+    </delete>
+
+</mapper>

+ 528 - 29
src/main/resources/static/home.html

@@ -1685,50 +1685,139 @@
                     
                 case 'equipmentInfo':
                     pageTitle.textContent = '设备信息';
-                    breadcrumb.textContent = '首页 > 设备管理 > 设信息';
+                    breadcrumb.textContent = '首页 > 设备管理 > 设信息';
                     mainContent.innerHTML = `
                         <div style="background: white; padding: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.1);">
-                            <div style="margin-bottom: 20px; display: flex; justify-content: space-between;">
-                                <div>
-                                    <button class="btn btn-success" onclick="showAddEquipmentForm()">新增设备</button>
-                                    <button class="btn btn-primary" onclick="loadContent('equipmentQuery')">查询</button>
-                                    <button class="btn btn-warning" onclick="loadContent('equipmentEdit')">编辑</button>
-                                    <button class="btn btn-danger" onclick="loadContent('equipmentDelete')">删除</button>
+                            <div style="margin-bottom: 20px;">
+                                <div style="display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 15px; align-items: center;">
+                                    <div>
+                                        <label>设备名称:</label>
+                                        <input type="text" id="equipmentName" placeholder="设备名称" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
+                                    </div>
+                                    <div>
+                                        <label>设备类型:</label>
+                                        <select id="equipmentType" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
+                                            <option value="">全部</option>
+                                            <option value="监护设备">监护设备</option>
+                                            <option value="治疗设备">治疗设备</option>
+                                            <option value="检验设备">检验设备</option>
+                                        </select>
+                                    </div>
+                                    <div>
+                                        <label>所属科室:</label>
+                                        <select id="equipmentDepartment" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
+                                            <option value="">全部</option>
+                                            <option value="内科">内科</option>
+                                            <option value="外科">外科</option>
+                                        </select>
+                                    </div>
+                                    <div>
+                                        <label>所属病区:</label>
+                                        <select id="equipmentWard" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
+                                            <option value="">全部</option>
+                                            <option value="第一病区">第一病区</option>
+                                            <option value="第二病区">第二病区</option>
+                                        </select>
+                                    </div>
+                                    <div>
+                                        <label>在线状态:</label>
+                                        <select id="equipmentStatus" style="padding: 6px; border: 1px solid #ddd; border-radius: 4px; width: 120px;">
+                                            <option value="">全部</option>
+                                            <option value="在线">在线</option>
+                                            <option value="离线">离线</option>
+                                            <option value="故障">故障</option>
+                                        </select>
+                                    </div>
                                 </div>
-                                <div>
-                                    <input type="text" placeholder="搜索设备..." style="padding: 8px; border: 1px solid #ddd; border-radius: 4px;">
+                                <div style="display: flex; gap: 10px;">
+                                    <button class="btn btn-primary" onclick="searchEquipment()">查询</button>
+                                    <button class="btn btn-secondary" onclick="clearEquipmentSearch()">重置</button>
+                                    <button class="btn btn-success" onclick="showAddEquipmentForm()">新增</button>
                                 </div>
                             </div>
-                            <table class="data-table">
+                            <table class="data-table" id="equipmentTable">
                                 <thead>
                                     <tr>
-                                        <th>设备编号</th>
-                                        <th>设备名称</th>
                                         <th>设备类型</th>
-                                        <th>所在科室</th>
-                                        <th>状态</th>
-                                        <th>购买日期</th>
+                                        <th>设备编码</th>
+                                        <th>设备名称</th>
+                                        <th>所属科室</th>
+                                        <th>所属病区</th>
+                                        <th>IP地址</th>
+                                        <th>子网掩码</th>
+                                        <th>默认网关</th>
+                                        <th>Mac地址</th>
+                                        <th>在线状态</th>
                                         <th>操作</th>
                                     </tr>
                                 </thead>
-                                <tbody>
-                                    <tr>
-                                        <td>E001</td>
-                                        <td>心电监护仪</td>
-                                        <td>监护设备</td>
-                                        <td>内科</td>
-                                        <td>正常</td>
-                                        <td>2023-01-15</td>
-                                        <td>
-                                            <button class="btn btn-primary">详情</button>
-                                            <button class="btn btn-warning">编辑</button>
-                                            <button class="btn btn-danger">删除</button>
-                                        </td>
-                                    </tr>
+                                <tbody id="equipmentTableBody">
+                                    <!-- 数据将通过JS动态加载 -->
                                 </tbody>
                             </table>
                         </div>
+                        
+                        <!-- 设备详情模态框 -->
+                        <div id="equipmentModal" style="display:none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.4); overflow: auto; padding: 50px 0;">
+                            <div style="background-color: #fff; margin: 0 auto; padding: 0; border: 1px solid #888; width: 80%; max-width: 600px; border-radius: 5px; max-height: 80%; display: flex; flex-direction: column;">
+                                <div style="padding: 20px; border-bottom: 1px solid #eee;">
+                                    <h2 style="margin-top: 0;" id="modalTitle">设备详情</h2>
+                                </div>
+                                <div style="overflow-y: auto; flex: 1; padding: 15px;">
+                                    <input type="hidden" id="modalTerminalNumber">
+                                    <div class="form-group">
+                                        <label>设备类型:</label>
+                                        <input type="text" id="modalTerminalType" style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>设备编码:</label>
+                                        <input type="text" id="modalTerminalNumberDisplay" readonly style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>设备名称:</label>
+                                        <input type="text" id="modalTerminalDesc" style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>所属科室:</label>
+                                        <input type="text" id="modalDeptCode" style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>所属病区:</label>
+                                        <input type="text" id="modalWardCode" style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>IP地址:</label>
+                                        <input type="text" id="modalIpAddress" style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>子网掩码:</label>
+                                        <input type="text" id="modalSubnetMask" style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>默认网关:</label>
+                                        <input type="text" id="modalGatewayAddress" style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>Mac地址:</label>
+                                        <input type="text" id="modalMacAddress" style="width: 100%; padding: 6px;">
+                                    </div>
+                                    <div class="form-group">
+                                        <label>在线状态:</label>
+                                        <select id="modalIsOnline" style="width: 100%; padding: 6px;">
+                                            <option value="true">在线</option>
+                                            <option value="false">离线</option>
+                                        </select>
+                                    </div>
+                                </div>
+                                <div style="padding: 20px; border-top: 1px solid #eee; text-align: right;">
+                                    <button class="btn btn-success" onclick="saveEquipment()" id="saveEquipmentBtn" style="display: none;">保存</button>
+                                    <button class="btn btn-secondary" onclick="closeEquipmentModal()">关闭</button>
+                                </div>
+                            </div>
+                        </div>
                     `;
+                    // 加载设备数据
+                    loadEquipmentData();
                     break;
                     
                 case 'equipmentQuery':
@@ -2265,6 +2354,12 @@
             document.getElementById('enabled').value = '';
             loadDepartmentData();
         }
+        
+        // 清空设备查询条件
+        function clearEquipmentSearch() {
+            // 在这里添加清空设备查询条件的逻辑
+            alert('重置查询条件');
+        }
         // 查看科室详情
         function viewDepartment(code) {
             // 获取科室数据
@@ -2638,6 +2733,373 @@
         });
         
         // 点击弹窗外部关闭弹窗
+        window.onclick = function(event) {
+            const wardModal = document.getElementById('wardModal');
+            const wardCodeSettingModal = document.getElementById('wardCodeSettingModal');
+            const departmentModal = document.getElementById('departmentModal');
+            const roomModal = document.getElementById('roomModal');
+            const roomCodeSettingModal = document.getElementById('roomCodeSettingModal');
+            const bedModal = document.getElementById('bedModal');
+            const patientModal = document.getElementById('patientModal');
+            
+            if (event.target === wardModal) {
+                wardModal.style.display = 'none';
+            } else if (event.target === wardCodeSettingModal) {
+                wardCodeSettingModal.style.display = 'none';
+            } else if (event.target === departmentModal) {
+                departmentModal.style.display = 'none';
+            } else if (event.target === roomModal) {
+                roomModal.style.display = 'none';
+            } else if (event.target === roomCodeSettingModal) {
+                roomCodeSettingModal.style.display = 'none';
+            } else if (event.target === bedModal) {
+                bedModal.style.display = 'none';
+            } else if (event.target === patientModal) {
+                patientModal.style.display = 'none';
+            }
+        };
+        
+        // 加载设备数据
+        function loadEquipmentData() {
+            fetch('/shixian/api/terminals')
+            .then(response => response.json())
+            .then(data => {
+                const tbody = document.getElementById('equipmentTableBody');
+                tbody.innerHTML = '';
+                
+                data.forEach(terminal => {
+                    const row = document.createElement('tr');
+                    const statusText = terminal.isOnline ? '在线' : '离线';
+                    
+                    row.innerHTML = `
+                        <td>${terminal.terminalType || ''}</td>
+                        <td>${terminal.terminalNumber || ''}</td>
+                        <td>${terminal.terminalDesc || ''}</td>
+                        <td>${terminal.deptCode || ''}</td>
+                        <td>${terminal.wardCode || ''}</td>
+                        <td>${terminal.ipAddress || ''}</td>
+                        <td>${terminal.subnetMask || ''}</td>
+                        <td>${terminal.gatewayAddress || ''}</td>
+                        <td>${terminal.macAddress || ''}</td>
+                        <td>${statusText}</td>
+                        <td>
+                            <button class="btn btn-primary" onclick="viewEquipment('${terminal.terminalNumber}')">详情</button>
+                            <button class="btn btn-warning" onclick="editEquipment('${terminal.terminalNumber}')">编辑</button>
+                            <button class="btn btn-danger" onclick="deleteEquipment('${terminal.terminalNumber}')">删除</button>
+                        </td>
+                    `;
+                    tbody.appendChild(row);
+                });
+            })
+            .catch(error => {
+                console.error('加载设备数据失败:', error);
+                alert('加载设备数据失败');
+            });
+        }
+        
+        // 查询设备
+        function searchEquipment() {
+            const terminalDesc = document.getElementById('equipmentName').value;
+            const terminalType = document.getElementById('equipmentType').value;
+            const deptCode = document.getElementById('equipmentDepartment').value;
+            const wardCode = document.getElementById('equipmentWard').value;
+            const isOnline = document.getElementById('equipmentStatus').value;
+            
+            let url = '/shixian/api/terminals?';
+            const params = [];
+            
+            if (terminalDesc) params.push(`terminalDesc=${encodeURIComponent(terminalDesc)}`);
+            if (terminalType) params.push(`terminalType=${encodeURIComponent(terminalType)}`);
+            if (deptCode) params.push(`deptCode=${encodeURIComponent(deptCode)}`);
+            if (wardCode) params.push(`wardCode=${encodeURIComponent(wardCode)}`);
+            if (isOnline !== '') {
+                // 将中文状态转换为布尔值
+                const isOnlineValue = isOnline === '在线' ? 'true' : 'false';
+                params.push(`isOnline=${isOnlineValue}`);
+            }
+            
+            url += params.join('&');
+            
+            fetch(url)
+            .then(response => response.json())
+            .then(data => {
+                const tbody = document.getElementById('equipmentTableBody');
+                tbody.innerHTML = '';
+                
+                // 确保处理后端返回的不同格式
+                const terminals = Array.isArray(data) ? data : (data.content || data);
+                
+                terminals.forEach(terminal => {
+                    const row = document.createElement('tr');
+                    const statusText = terminal.isOnline ? '在线' : '离线';
+                    
+                    row.innerHTML = `
+                        <td>${terminal.terminalType || ''}</td>
+                        <td>${terminal.terminalNumber || ''}</td>
+                        <td>${terminal.terminalDesc || ''}</td>
+                        <td>${terminal.deptCode || ''}</td>
+                        <td>${terminal.wardCode || ''}</td>
+                        <td>${terminal.ipAddress || ''}</td>
+                        <td>${terminal.subnetMask || ''}</td>
+                        <td>${terminal.gatewayAddress || ''}</td>
+                        <td>${terminal.macAddress || ''}</td>
+                        <td>${statusText}</td>
+                        <td>
+                            <button class="btn btn-primary" onclick="viewEquipment('${terminal.terminalNumber}')">详情</button>
+                            <button class="btn btn-warning" onclick="editEquipment('${terminal.terminalNumber}')">编辑</button>
+                            <button class="btn btn-danger" onclick="deleteEquipment('${terminal.terminalNumber}')">删除</button>
+                        </td>
+                    `;
+                    tbody.appendChild(row);
+                });
+            })
+            .catch(error => {
+                console.error('查询设备数据失败:', error);
+                alert('查询失败,请稍后重试');
+            });
+        }
+        
+        // 清空设备查询条件
+        function clearEquipmentSearch() {
+            document.getElementById('equipmentName').value = '';
+            document.getElementById('equipmentType').value = '';
+            document.getElementById('equipmentDepartment').value = '';
+            document.getElementById('equipmentWard').value = '';
+            document.getElementById('equipmentStatus').value = '';
+            loadEquipmentData();
+        }
+        
+        // 查看设备详情
+        function viewEquipment(terminalNumber) {
+            fetch(`/shixian/api/terminals/${terminalNumber}`)
+            .then(response => response.json())
+            .then(data => {
+                if (data.success) {
+                    const terminal = data.data;
+                    
+                    // 填充弹窗内容
+                    document.getElementById('modalTitle').textContent = '设备详情';
+                    document.getElementById('modalTerminalNumber').value = terminal.terminalNumber || '';
+                    document.getElementById('modalTerminalNumberDisplay').value = terminal.terminalNumber || '';
+                    document.getElementById('modalTerminalType').value = terminal.terminalType || '';
+                    document.getElementById('modalTerminalDesc').value = terminal.terminalDesc || '';
+                    document.getElementById('modalDeptCode').value = terminal.deptCode || '';
+                    document.getElementById('modalWardCode').value = terminal.wardCode || '';
+                    document.getElementById('modalIpAddress').value = terminal.ipAddress || '';
+                    document.getElementById('modalSubnetMask').value = terminal.subnetMask || '';
+                    document.getElementById('modalGatewayAddress').value = terminal.gatewayAddress || '';
+                    document.getElementById('modalMacAddress').value = terminal.macAddress || '';
+                    document.getElementById('modalIsOnline').value = terminal.isOnline ? 'true' : 'false';
+                    
+                    // 设置为只读模式
+                    document.getElementById('modalTerminalType').readOnly = true;
+                    document.getElementById('modalTerminalDesc').readOnly = true;
+                    document.getElementById('modalDeptCode').readOnly = true;
+                    document.getElementById('modalWardCode').readOnly = true;
+                    document.getElementById('modalIpAddress').readOnly = true;
+                    document.getElementById('modalSubnetMask').readOnly = true;
+                    document.getElementById('modalGatewayAddress').readOnly = true;
+                    document.getElementById('modalMacAddress').readOnly = true;
+                    document.getElementById('modalIsOnline').disabled = true;
+                    document.getElementById('saveEquipmentBtn').style.display = 'none';
+                    
+                    // 显示弹窗
+                    document.getElementById('equipmentModal').style.display = 'block';
+                } else {
+                    alert('获取设备信息失败: ' + data.message);
+                }
+            })
+            .catch(error => {
+                console.error('获取设备信息失败:', error);
+                alert('获取设备信息失败,请稍后重试');
+            });
+        }
+        
+        // 编辑设备
+        function editEquipment(terminalNumber) {
+            fetch(`/shixian/api/terminals/${terminalNumber}`)
+            .then(response => response.json())
+            .then(data => {
+                if (data.success) {
+                    const terminal = data.data;
+                    
+                    // 填充弹窗内容
+                    document.getElementById('modalTitle').textContent = '编辑设备';
+                    document.getElementById('modalTerminalNumber').value = terminal.terminalNumber || '';
+                    document.getElementById('modalTerminalNumberDisplay').value = terminal.terminalNumber || '';
+                    document.getElementById('modalTerminalType').value = terminal.terminalType || '';
+                    document.getElementById('modalTerminalDesc').value = terminal.terminalDesc || '';
+                    document.getElementById('modalDeptCode').value = terminal.deptCode || '';
+                    document.getElementById('modalWardCode').value = terminal.wardCode || '';
+                    document.getElementById('modalIpAddress').value = terminal.ipAddress || '';
+                    document.getElementById('modalSubnetMask').value = terminal.subnetMask || '';
+                    document.getElementById('modalGatewayAddress').value = terminal.gatewayAddress || '';
+                    document.getElementById('modalMacAddress').value = terminal.macAddress || '';
+                    document.getElementById('modalIsOnline').value = terminal.isOnline ? 'true' : 'false';
+                    
+                    // 设置为可编辑模式
+                    document.getElementById('modalTerminalType').readOnly = false;
+                    document.getElementById('modalTerminalDesc').readOnly = false;
+                    document.getElementById('modalDeptCode').readOnly = false;
+                    document.getElementById('modalWardCode').readOnly = false;
+                    document.getElementById('modalIpAddress').readOnly = false;
+                    document.getElementById('modalSubnetMask').readOnly = false;
+                    document.getElementById('modalGatewayAddress').readOnly = false;
+                    document.getElementById('modalMacAddress').readOnly = false;
+                    document.getElementById('modalIsOnline').disabled = false;
+                    document.getElementById('saveEquipmentBtn').style.display = 'inline-block';
+                    
+                    // 显示弹窗
+                    document.getElementById('equipmentModal').style.display = 'block';
+                } else {
+                    alert('获取设备信息失败: ' + data.message);
+                }
+            })
+            .catch(error => {
+                console.error('获取设备信息失败:', error);
+                alert('获取设备信息失败,请稍后重试');
+            });
+        }
+        
+        // 新增设备
+        function showAddEquipmentForm() {
+            // 清空弹窗内容
+            document.getElementById('modalTitle').textContent = '新增设备';
+            document.getElementById('modalTerminalNumber').value = '';
+            document.getElementById('modalTerminalNumberDisplay').value = '';
+            document.getElementById('modalTerminalType').value = '';
+            document.getElementById('modalTerminalDesc').value = '';
+            document.getElementById('modalDeptCode').value = '';
+            document.getElementById('modalWardCode').value = '';
+            document.getElementById('modalIpAddress').value = '';
+            document.getElementById('modalSubnetMask').value = '';
+            document.getElementById('modalGatewayAddress').value = '';
+            document.getElementById('modalMacAddress').value = '';
+            document.getElementById('modalIsOnline').value = 'true';
+            
+            // 设置为可编辑模式
+            document.getElementById('modalTerminalType').readOnly = false;
+            document.getElementById('modalTerminalDesc').readOnly = false;
+            document.getElementById('modalDeptCode').readOnly = false;
+            document.getElementById('modalWardCode').readOnly = false;
+            document.getElementById('modalIpAddress').readOnly = false;
+            document.getElementById('modalSubnetMask').readOnly = false;
+            document.getElementById('modalGatewayAddress').readOnly = false;
+            document.getElementById('modalMacAddress').readOnly = false;
+            document.getElementById('modalIsOnline').disabled = false;
+            document.getElementById('saveEquipmentBtn').style.display = 'inline-block';
+            
+            // 显示弹窗
+            document.getElementById('equipmentModal').style.display = 'block';
+        }
+        
+        // 保存设备(新增或更新)
+        function saveEquipment() {
+            const terminalNumber = document.getElementById('modalTerminalNumber').value;
+            const terminalData = {
+                terminalType: document.getElementById('modalTerminalType').value,
+                terminalNumber: document.getElementById('modalTerminalNumberDisplay').value,
+                terminalDesc: document.getElementById('modalTerminalDesc').value,
+                deptCode: document.getElementById('modalDeptCode').value,
+                wardCode: document.getElementById('modalWardCode').value,
+                ipAddress: document.getElementById('modalIpAddress').value,
+                subnetMask: document.getElementById('modalSubnetMask').value,
+                gatewayAddress: document.getElementById('modalGatewayAddress').value,
+                macAddress: document.getElementById('modalMacAddress').value,
+                isOnline: document.getElementById('modalIsOnline').value === 'true'
+            };
+            
+            let url, method;
+            if (terminalNumber) {
+                // 更新设备
+                url = `/shixian/api/terminals/${terminalNumber}`;
+                method = 'PUT';
+            } else {
+                // 新增设备
+                url = '/shixian/api/terminals';
+                method = 'POST';
+            }
+            
+            fetch(url, {
+                method: method,
+                headers: {
+                    'Content-Type': 'application/json'
+                },
+                body: JSON.stringify(terminalData)
+            })
+            .then(response => response.json())
+            .then(data => {
+                if (data.success) {
+                    alert(terminalNumber ? '设备更新成功' : '设备新增成功');
+                    closeEquipmentModal();
+                    loadEquipmentData(); // 重新加载数据
+                } else {
+                    alert(terminalNumber ? '设备更新失败: ' + data.message : '设备新增失败: ' + data.message);
+                }
+            })
+            .catch(error => {
+                console.error('保存设备失败:', error);
+                alert('保存设备失败,请稍后重试');
+            });
+        }
+        
+        // 删除设备
+        function deleteEquipment(terminalNumber) {
+            if (confirm('确定要删除该设备吗?')) {
+                fetch(`/shixian/api/terminals/${terminalNumber}`, {
+                    method: 'DELETE'
+                })
+                .then(response => response.json())
+                .then(data => {
+                    if (data.success) {
+                        alert('删除成功');
+                        loadEquipmentData(); // 重新加载数据
+                    } else {
+                        alert('删除失败: ' + data.message);
+                    }
+                })
+                .catch(error => {
+                    console.error('删除设备失败:', error);
+                    alert('删除失败,请稍后重试');
+                });
+            }
+        }
+        
+        // 关闭设备详情弹窗
+        function closeEquipmentModal() {
+            document.getElementById('equipmentModal').style.display = 'none';
+        }
+        
+        // 点击弹窗外部关闭弹窗
+        window.onclick = function(event) {
+            const wardModal = document.getElementById('wardModal');
+            const wardCodeSettingModal = document.getElementById('wardCodeSettingModal');
+            const departmentModal = document.getElementById('departmentModal');
+            const roomModal = document.getElementById('roomModal');
+            const roomCodeSettingModal = document.getElementById('roomCodeSettingModal');
+            const bedModal = document.getElementById('bedModal');
+            const patientModal = document.getElementById('patientModal');
+            const equipmentModal = document.getElementById('equipmentModal');
+            
+            if (event.target === wardModal) {
+                wardModal.style.display = 'none';
+            } else if (event.target === wardCodeSettingModal) {
+                wardCodeSettingModal.style.display = 'none';
+            } else if (event.target === departmentModal) {
+                departmentModal.style.display = 'none';
+            } else if (event.target === roomModal) {
+                roomModal.style.display = 'none';
+            } else if (event.target === roomCodeSettingModal) {
+                roomCodeSettingModal.style.display = 'none';
+            } else if (event.target === bedModal) {
+                bedModal.style.display = 'none';
+            } else if (event.target === patientModal) {
+                patientModal.style.display = 'none';
+            } else if (event.target === equipmentModal) {
+                equipmentModal.style.display = 'none';
+            }
+        };
+        
         window.onclick = function(event) {
             const departmentModal = document.getElementById('departmentModal');
             const wardModal = document.getElementById('wardModal');
@@ -4266,6 +4728,43 @@
             }
         }
         
+        // 设备查询功能
+        /*
+        function searchEquipment() {
+            const equipmentName = document.getElementById('equipmentName').value;
+            const equipmentType = document.getElementById('equipmentType').value;
+            const equipmentDepartment = document.getElementById('equipmentDepartment').value;
+            const equipmentWard = document.getElementById('equipmentWard').value;
+            const equipmentStatus = document.getElementById('equipmentStatus').value;
+            
+            // 这里应该发送请求到后端查询设备数据
+            // 示例代码:
+            // fetch(`/api/equipment?name=${equipmentName}&type=${equipmentType}&department=${equipmentDepartment}&ward=${equipmentWard}&status=${equipmentStatus}`)
+            //     .then(response => response.json())
+            //     .then(data => {
+            //         // 更新表格数据
+            //     })
+            
+            alert(`查询条件:
+设备名称: ${equipmentName}
+设备类型: ${equipmentType}
+所属科室: ${equipmentDepartment}
+所属病区: ${equipmentWard}
+在线状态: ${equipmentStatus}`);
+        }
+        */
+        
+        // 清空设备查询条件
+        /*
+        function clearEquipmentSearch() {
+            document.getElementById('equipmentName').value = '';
+            document.getElementById('equipmentType').value = '';
+            document.getElementById('equipmentDepartment').value = '';
+            document.getElementById('equipmentWard').value = '';
+            document.getElementById('equipmentStatus').value = '';
+        }
+        */
+        
     </script>
 </body>
 </html>