huangyan 1 år sedan
förälder
incheckning
d5bfa3418a
5 ändrade filer med 264 tillägg och 147 borttagningar
  1. 38 21
      controllers/DeviceController.go
  2. 11 0
      models/Device/Device.go
  3. 31 20
      models/Warning/Warning.go
  4. 4 0
      routers/DeviceRouter.go
  5. 180 106
      views/Device/DeviceWarning.html

+ 38 - 21
controllers/DeviceController.go

@@ -326,23 +326,12 @@ func (c *DeviceController) DeviceWarning_List_html() {
 	//if Class_1 > 0 {
 	//	T_Title = Device.Read_DeviceWarningList_ById(Class_1).T_name
 	//}
-	var pageSizes struct {
-		PageSize string `json:"pageSize"`
-	}
-	json.Unmarshal(c.Ctx.Input.RequestBody, &pageSizes)
-
 	pageSize := c.GetString("pageSize", "100")
 	pageSizeInt, _ := strconv.Atoi(pageSize)
-	atoi, _ := strconv.Atoi(pageSizes.PageSize)
-	if atoi == 0 {
-		atoi = pageSizeInt
-	} else {
-		pageSizeInt = atoi
-	}
+	//atoi, _ := strconv.Atoi(pageSizes.PageSize)
 
 	var cnt int64
 	DeviceWarning_List, cnt := Warning.Read_Warning_List(admin_r.T_pid, bindSN, tpList, Time_start, Time_end, page, pageSizeInt)
-
 	c.Data["List"] = DeviceWarning_List
 	page_size := math.Ceil(float64(cnt) / float64(pageSizeInt))
 	c.Data["Page"] = page
@@ -353,6 +342,8 @@ func (c *DeviceController) DeviceWarning_List_html() {
 
 	c.TplName = "Device/DeviceWarning.html"
 }
+
+// GetWarningtype 获取报警类型
 func (c *DeviceController) GetWarningtype() {
 	var results []struct {
 		Key   int
@@ -393,6 +384,7 @@ func (c *DeviceController) DeviceWarning_() {
 	c.TplName = "Device/DeviceWarning-.html"
 }
 
+// DeviceWarning_Post 添加报警
 func (c *DeviceController) DeviceWarning_Post() {
 	// 验证登录
 	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
@@ -438,6 +430,8 @@ func (c *DeviceController) DeviceWarning_Post() {
 	c.ServeJSON()
 	return
 }
+
+// DeviceWarning_Del 删除报警
 func (c *DeviceController) DeviceWarning_Del() {
 	// 验证登录
 	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
@@ -457,7 +451,7 @@ func (c *DeviceController) DeviceWarning_Del() {
 	return
 }
 
-// 批量删除
+// DeviceWarning_DelS 批量删除
 func (c *DeviceController) DeviceWarning_DelS() {
 	// 验证登录
 	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
@@ -520,7 +514,7 @@ func (c *DeviceController) Device_Copy() {
 // DeviceWarningUpdate 修改报警
 func (c *DeviceController) DeviceWarningUpdate() {
 	// 验证登录
-	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
 	if !b_ {
 		c.Ctx.Redirect(302, "Login")
 		return
@@ -530,13 +524,43 @@ func (c *DeviceController) DeviceWarningUpdate() {
 		NewValue   string `json:"newValue"`
 		RowId      string `json:"rowId"`
 		T_Ut       string `json:"T_Ut"`
+		SN         string `json:"sn"`
 	}
 	json.Unmarshal(c.Ctx.Input.RequestBody, &data)
+	log.Println(admin_r.T_pid)
 	Warning.Update_DeviceParameter_Warning(data.ColumnName, data.NewValue, data.RowId, data.T_Ut)
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "设置成功", Data: data}
 	c.ServeJSON()
 }
 
+// GetDeviceALLSN 根据pid获取所有sn
+func (c *DeviceController) GetDeviceALLSN() {
+	// 验证登录
+	b_, admin_r := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Ctx.Redirect(302, "Login")
+		return
+	}
+	r := Device.Read_Device_All_SN(admin_r.T_pid)
+	log.Println(r)
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r}
+	c.ServeJSON()
+}
+
+// GetDeviceALLTID  根据SN获取所有探头
+func (c *DeviceController) GetDeviceALLTID() {
+	// 验证登录
+	b_, _ := lib.Verification(c.Ctx.GetCookie("User_tokey"), c.GetString("User_tokey"))
+	if !b_ {
+		c.Ctx.Redirect(302, "Login")
+		return
+	}
+	getString := c.GetString("sn")
+	r := Device.Get_DeviceSensor_Tid_ByT_sn(getString)
+	c.Data["json"] = lib.JSONS{Code: 200, Msg: "设置成功", Data: r}
+	c.ServeJSON()
+}
+
 // DeviceWarningAdd 复制添加报警
 func (c *DeviceController) DeviceWarningAdd() {
 	// 验证登录
@@ -565,13 +589,6 @@ func (c *DeviceController) DeviceWarningAdd() {
 		c.ServeJSON()
 		return
 	}
-	// 获取 传感器 参数
-	//DeviceSensor_r, is := Device.Read_DeviceSensor_ByT_sn(r_Device.T_sn, atoi)
-	//if !is {
-	//	c.Data["json"] = lib.JSONS{Code: 201, Msg: "E!", Data: "编号 错误!!!"}
-	//	c.ServeJSON()
-	//	return
-	//}
 	T_tp := Warning.Read_WarningType(data.T_tp_name)
 	t1, _ := time.ParseInLocation("2006-01-02 15:04:05", data.T_Ut, time.Local) // +8  时差
 	t_c := Warning.Warning{

+ 11 - 0
models/Device/Device.go

@@ -313,6 +313,17 @@ func Read_Device_ALL_T_Type_Count(T_pid int, T_type int) (cnt int64) {
 	return cnt
 }
 
+// Read_Device_All_SN 根据pid获取sn
+func Read_Device_All_SN(T_pid int) (r []Device) {
+	o := orm.NewOrm()
+	qs := o.QueryTable(new(Device))
+	_, err := qs.Filter("T_pid", T_pid).Filter("T_State", 1).All(&r)
+	if err != nil {
+		logs.Error(lib.FuncName(), err)
+	}
+	return r
+}
+
 func Read_Device_List_ByT_model(T_model string) (r []Device) {
 
 	o := orm.NewOrm()

+ 31 - 20
models/Warning/Warning.go

@@ -8,7 +8,6 @@ import (
 	"github.com/beego/beego/v2/adapter/orm"
 	orm2 "github.com/beego/beego/v2/client/orm"
 	_ "github.com/go-sql-driver/mysql"
-	"log"
 	"strconv"
 	"strings"
 	"time"
@@ -322,27 +321,39 @@ func Update_DeviceParameter_Warning(columnName, newValue, rowId, T_Ut string) {
 	}
 	now := time.Now()
 	interval := now.Sub(parse)
-	if columnName == "t__d_name,t_sn" {
-		splits := strings.Split(columnName, ",")
-		Value := strings.Split(newValue, ",")
-		log.Printf(splits[0], splits[1], Value[0], Value[1])
+	//if columnName == "t__d_name,t_sn" {
+	//	splits := strings.Split(columnName, ",")
+	//	Value := strings.Split(newValue, ",")
+	//	log.Printf(splits[0], splits[1], Value[0], Value[1])
+	//	if interval.Hours() > 40*24 {
+	//		o.Raw("UPDATE "+Wtab+" SET `"+splits[0]+"` = ?, `"+splits[1]+"` = ? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
+	//	} else {
+	//		o.Raw("UPDATE "+Wtab+" SET `"+splits[0]+"` = ?, `"+splits[1]+"` = ? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
+	//		o.Raw("UPDATE warning SET `"+splits[0]+"` = ?,`"+splits[1]+"`=? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
+	//	}
+	//	return
+	//}
+	//if columnName == "t__d_s_name,t_id" {
+	//	splits := strings.Split(columnName, ",")
+	//	Value := strings.Split(newValue, ",")
+	//	log.Printf(splits[0], splits[1], Value[0], Value[1])
+	//	if interval.Hours() > 40*24 {
+	//		o.Raw("UPDATE "+Wtab+" SET `"+splits[0]+"` = ?, `"+splits[1]+"` = ? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
+	//	} else {
+	//		o.Raw("UPDATE "+Wtab+" SET `"+splits[0]+"` = ?, `"+splits[1]+"` = ? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
+	//		o.Raw("UPDATE warning SET `"+splits[0]+"` = ?,`"+splits[1]+"`=? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
+	//	}
+	//	return
+	//}
+	if columnName == "t_sn" {
+		var t__d_name string
+		sql := "SELECT t__d_name FROM " + Wtab + " WHERE t_sn=" + newValue + " LIMIT 1"
+		o.Raw(sql).QueryRow(&t__d_name)
 		if interval.Hours() > 40*24 {
-			o.Raw("UPDATE "+Wtab+" SET `"+splits[0]+"` = ?, `"+splits[1]+"` = ? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
+			o.Raw("UPDATE "+Wtab+" SET `"+columnName+"` = ?  SET `t__d_name` = ?  WHERE `ID` = ?", newValue, t__d_name, rowId).Exec()
 		} else {
-			o.Raw("UPDATE "+Wtab+" SET `"+splits[0]+"` = ?, `"+splits[1]+"` = ? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
-			o.Raw("UPDATE warning SET `"+splits[0]+"` = ?,`"+splits[1]+"`=? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
-		}
-		return
-	}
-	if columnName == "t__d_s_name,t_id" {
-		splits := strings.Split(columnName, ",")
-		Value := strings.Split(newValue, ",")
-		log.Printf(splits[0], splits[1], Value[0], Value[1])
-		if interval.Hours() > 40*24 {
-			o.Raw("UPDATE "+Wtab+" SET `"+splits[0]+"` = ?, `"+splits[1]+"` = ? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
-		} else {
-			o.Raw("UPDATE "+Wtab+" SET `"+splits[0]+"` = ?, `"+splits[1]+"` = ? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
-			o.Raw("UPDATE warning SET `"+splits[0]+"` = ?,`"+splits[1]+"`=? WHERE `ID` = ?", Value[0], Value[1], rowId).Exec()
+			o.Raw("UPDATE "+Wtab+" SET `"+columnName+"` = ?  SET `t__d_name` = ?  WHERE `ID` = ?", newValue, t__d_name, rowId).Exec()
+			o.Raw("UPDATE warning SET `"+columnName+"` = ?  SET `t__d_name` = ?   WHERE `ID` = ?", newValue, t__d_name, rowId).Exec()
 		}
 		return
 	}

+ 4 - 0
routers/DeviceRouter.go

@@ -40,5 +40,9 @@ func init() {
 	beego.Router("/Device/DeviceWarning_Post", &controllers.DeviceController{}, "*:DeviceWarning_Post") // 获取未读消息
 	//beego.Router("/Device/DeviceWarning_Data_Excel", &controllers.DeviceController{}, "*:DeviceWarning_Data_Excel")       // 获取未读消息
 	beego.Router("/Device/DeviceWarning_Del", &controllers.DeviceController{}, "*:DeviceWarning_Del") // 获取未读消息
+	//根据pid获取sn
+	beego.Router("/Device/DeviceWarning_ALL_SN", &controllers.DeviceController{}, "*:GetDeviceALLSN")
+	//根据sn获取tid
+	beego.Router("/Device/DeviceWarning_ALL_TID", &controllers.DeviceController{}, "*:GetDeviceALLTID")
 	//beego.Router("/Device/DeviceWarningListT_Tips", &controllers.DeviceController{}, "*:DeviceWarningList_T_Tips")        // 获取未读消息
 }

+ 180 - 106
views/Device/DeviceWarning.html

@@ -58,26 +58,27 @@
                     <table class="layui-table layui-form">
                         <thead>
                         <tr>
-                            <th>选择</th>
-                            <th>报警类型</th>
-                            <th>主机</th>
-                            <th>设备</th>
-                            <th>采集内容</th>
-                            <th>状态</th>
-                            <th>采集时间</th>
-                            <th>操作</th>
+                            <th style="width: 10px;">选择</th>
+                            <th style="width: 120px;">报警类型</th>
+                            <th style="width: 100px;">主机</th>
+                            <th style="width: 90px;">设备</th>
+                            <th style="width: 150px;">采集内容</th>
+                            <th style="width: 70px;">状态</th>
+                            <th style="width: 130px;">采集时间</th>
+                            <th style="width: 100px;">操作</th>
                         </tr>
                         </thead>
                         <tbody>
                         {{range $index, $elem := .List}}
                         <tr {{if eq $elem.T_State 0 }} style="background-color: rgba(0,0,0,0.26)" {{end}}>
-                            <td><input type="checkbox" class="layui-checkbox" name="checkbox" lay-skin="primary"
-                                       value="{{$elem.Id}}"></td>
+                            <td style="width: 5px"><input style="width: 5px" type="checkbox" class="layui-checkbox" name="checkbox"
+                                                           lay-skin="primary"
+                                                           value="{{$elem.Id}}"></td>
 
                             <td type="text" name="T_tp_name">{{$elem.T_tp_name}}
                             </td>
-                            <td name="t__d_name,t_sn" sn="{{$elem.T_sn}}">{{$elem.T_D_name}},{{$elem.T_sn}}</td>
-                            <td name="t__d_s_name,t_id" t_id="{{$elem.T_id}}">{{$elem.T_DS_name}},{{$elem.T_id}}</td>
+                            <td name="t_sn" sn="{{$elem.T_sn}}">{{$elem.T_sn}}</td>
+                            <td name="t_id" t_id="{{$elem.T_id}}">{{$elem.T_id}}</td>
                             <td name="t__remark">{{$elem.T_Remark}}</td>
 
                             <td name="t__state">
@@ -99,7 +100,7 @@
                                     <i class="layui-icon">&#xe640;</i>删除
                                 </button>
                                 <button class="layui-btn-normal layui-btn layui-btn-xs copy-add-btn" id="copy-add-btn"
-                                        data-id="{{$elem.Id}},{{$elem.T_Ut}}" >复制添加
+                                        data-id="{{$elem.Id}},{{$elem.T_Ut}}">复制添加
                                 </button>
 
 
@@ -109,54 +110,56 @@
                         {{end}}
 
 
-                                </tbody>
+                        </tbody>
                         <div class="layui-form layui-border-box layui-row layui-col-space10 layui-form-item">
                             <button class="layui-btn layui-btn-sm" id="selectAll">全选</button>
                             <button class="layui-btn layui-btn-sm" id="unselectAll">全不选</button>
                             <button class="layui-btn layui-btn-sm" id="invertSelect">反选</button>
                             <button class="layui-btn layui-btn-sm layui-btn-danger" id="batchDelete">批量删除</button>
                         </div>
-                            </table>
-                        </div>
-                        <div class="layui-card-body ">
-                            <select id="pageSizeSelector">
-                                <option value="100">100 条/页</option>
-                                <option value="200">200 条/页</option>
-                                <option value="500">500 条/页</option>
-                                <option value="1000">1000 条/页</option>
-                            </select>
-                            <div class="page">
-                                <div>
-
-                                    {{range $index, $elem := .Pages}}
-                                        {{if eq $elem.A 1}}
-                                        <a class="prev" href="?page={{$elem.V}}&T_sn={{$.T_sn}}&Time_start={{$.Time_start}}&Time_end={{$.Time_end}}">&lt;&lt;</a>
-                                        {{end}}
-                                        {{if eq $elem.A 2}}
-                                        <a class="num" href="?page={{$elem.V}}&T_sn={{$.T_sn}}&Time_start={{$.Time_start}}&Time_end={{$.Time_end}}">{{$elem.V}}</a>
-                                        {{end}}
-                                        {{if eq $elem.A 3}}
-                                        <span class="current">{{$elem.V}}</span>
-                                        {{end}}
-                                        {{if eq $elem.A 4}}
-                                        <a class="num" href="?page={{$elem.V}}&T_sn={{$.T_sn}}&Time_start={{$.Time_start}}&Time_end={{$.Time_end}}">{{$elem.V}}</a>
-                                        {{end}}
-                                        {{if eq $elem.A 5}}
-                                        <a class="next" href="?page={{$elem.V}}&T_sn={{$.T_sn}}&Time_start={{$.Time_start}}&Time_end={{$.Time_end}}">&gt;&gt;</a>
-                                        {{end}}
-
-
-
-                                    {{end}}
-
-
-
-                                </div>
-                                当前页:{{.Page}}-
-                                总页数:{{.Page_size}}-
-                                总条数:{{.cnt}}
-                            </div>
+                    </table>
+                </div>
+                <div class="layui-card-body ">
+                    <select id="pageSizeSelector">
+                        <option value="100">100 条/页</option>
+                        <option value="200">200 条/页</option>
+                        <option value="500">500 条/页</option>
+                        <option value="1000">1000 条/页</option>
+                    </select>
+                    <div class="page">
+                        <div>
+
+                            {{range $index, $elem := .Pages}}
+                            {{if eq $elem.A 1}}
+                            <a class="prev"
+                               href="?page={{$elem.V}}&T_sn={{$.T_sn}}&Time_start={{$.Time_start}}&Time_end={{$.Time_end}}">&lt;&lt;</a>
+                            {{end}}
+                            {{if eq $elem.A 2}}
+                            <a class="num"
+                               href="?page={{$elem.V}}&T_sn={{$.T_sn}}&Time_start={{$.Time_start}}&Time_end={{$.Time_end}}">{{$elem.V}}</a>
+                            {{end}}
+                            {{if eq $elem.A 3}}
+                            <span class="current">{{$elem.V}}</span>
+                            {{end}}
+                            {{if eq $elem.A 4}}
+                            <a class="num"
+                               href="?page={{$elem.V}}&T_sn={{$.T_sn}}&Time_start={{$.Time_start}}&Time_end={{$.Time_end}}">{{$elem.V}}</a>
+                            {{end}}
+                            {{if eq $elem.A 5}}
+                            <a class="next"
+                               href="?page={{$elem.V}}&T_sn={{$.T_sn}}&Time_start={{$.Time_start}}&Time_end={{$.Time_end}}">&gt;&gt;</a>
+                            {{end}}
+
+
+                            {{end}}
+
+
                         </div>
+                        当前页:{{.Page}}-
+                        总页数:{{.Page_size}}-
+                        总条数:{{.cnt}}
+                    </div>
+                </div>
 
 
             </div>
@@ -166,15 +169,14 @@
 
 </body>
 <script>
-    document.addEventListener('DOMContentLoaded', function() {
+    document.addEventListener('DOMContentLoaded', function () {
         // 初始化pageSize,先从localStorage读取,如果没有则使用默认值
-        var pageSize = localStorage.getItem('pageSize') || 10;
+        var pageSize = localStorage.getItem('pageSize') || 100;
         document.getElementById('pageSizeSelector').value = pageSize; // 设置选择框的默认选中项
         // 监听选择框变化
-        document.getElementById('pageSizeSelector').addEventListener('change', function(event) {
+        document.getElementById('pageSizeSelector').addEventListener('change', function (event) {
             var newPageSize = event.target.value;
             localStorage.setItem('pageSize', newPageSize); // 更新localStorage中的pageSize
-
             // 调用函数更新分页链接
             updatePageLinks(newPageSize);
             sendPageSizeToBackend(newPageSize);
@@ -182,35 +184,54 @@
         // 页面加载时执行一次,确保初始状态正确
         updatePageLinks(pageSize);
     });
+    document.getElementById('pageSizeSelector').addEventListener('change', function (event) {
+        var newPageSize = event.target.value;
+        localStorage.setItem('pageSize', newPageSize); // 更新localStorage中的pageSize
+        console.log("更改:", newPageSize);
+        // 调用函数更新分页链接
+        sendPageSizeToBackend(newPageSize);
+        updatePageLinks(newPageSize);
+
+    });
 
     // 更新所有分页链接的函数
     function updatePageLinks(pageSize) {
-        console.log("Updating page links with pageSize:", pageSize);
         var links = document.querySelectorAll('.num');
         for (var i = 0; i < links.length; i++) {
             var href = links[i].getAttribute('href');
             href = href.replace(/pageSize\s*=\s*\d+/, 'pageSize=' + encodeURIComponent(pageSize)); // 替换pageSize参数
-            links[i].setAttribute('href', href+"&pageSize="+pageSize);
+            links[i].setAttribute('href', href + "&pageSize=" + pageSize);
             // window.location.href = links[0].href;
-
         }
-        console.log("Updated link:", links[0].href);
     }
+
     // 新增函数:向后端发送pageSize
     function sendPageSizeToBackend(pageSize) {
-        fetch('/Device/DeviceWarning_page', { // 替换为你的后端接口地址
-            method: 'POST', // 或者根据你的后端接口要求使用'PUT'、'PATCH'等
-            headers: {
-                'Content-Type': 'application/json',
-            },
-            body: JSON.stringify({ pageSize: pageSize }), // 将pageSize作为JSON对象发送
-        })
-            .then(response => {
-                console.log('Sending pageSize to the server:', response);
-                if (!response.ok) {
-                    throw new Error(`Network response was not ok: ${response.statusText}`);
-                }
-            })
+        // 获取开始日的值
+        var startTime = document.getElementById('Time_start').value;
+
+        // 获取截止日的值
+        var endTime = document.getElementById('Time_end').value;
+
+        // 获取Sn的值
+        var snValue = document.getElementsByName('T_sn')[0].value;
+
+        const url = `?page=1&T_sn=${encodeURIComponent(snValue)}&Time_start=${encodeURIComponent(startTime)}&Time_end=${encodeURIComponent(endTime)}&pageSize=${encodeURIComponent(pageSize)}`; // 将pageSize作为查询参数添加到URL
+        console.log("发送的URL:", url);
+        window.location.href = url;
+        // fetch(url, { // 使用调整后的URL
+        //     method: 'GET', // 保持GET方法,既然这是根据需求设定的
+        // })
+        //     .then(response => {
+        //         if (!response.ok) {
+        //             throw new Error(`网络响应异常: ${response.statusText}`);
+        //         }
+        //         // 可能需要处理响应数据,这里假设不需要返回数据处理
+        //     })
+        //     .catch(error => {
+        //         console.error('发送pageSize至后端时发生错误:', error);
+        //         // 可能还需要通知用户发生了错误
+        //     });
     }
 
     layui.use(['layer', 'laydate', 'form'],
@@ -263,7 +284,6 @@
                     layer.msg('请至少选择一项进行删除!', {icon: 5, time: 2000});
                     return;
                 }
-                console.log(selectedIds);
                 layer.confirm('您确定要删除选定的 ' + selectedIds.length + ' 条数据吗?', {
                     icon: 3,
                     title: '确认删除',
@@ -280,7 +300,7 @@
                         success: function (response) {
                             if (response.Code === 200) {
                                 layer.msg('删除成功! 已删除 ' + selectedIds.length + ' 条数据', {icon: 1, time: 2000});
-                                // location.reload();
+                                location.reload();
                             } else {
                                 layer.msg('删除失败,请重试!', {icon: 5, time: 2000});
                             }
@@ -295,7 +315,7 @@
                 });
             });
             // 绑定复制添加按钮的点击事件
-            $('body').on('click', '.copy-add-btn', function(){
+            $('body').on('click', '.copy-add-btn', function () {
                 var btn = $(this);
                 var row = btn.parents('tr'); // 获取当前按钮所在行
                 var checkbox = row.find('input[type="checkbox"]'); // 找到本行的复选框
@@ -304,7 +324,7 @@
                 var attr = sn.attr('sn');
                 var t_id = row.find('td[t_id]');
                 var t_idV = t_id.attr('t_id');
-                console.log(attr);
+                // console.log(attr);
                 // 复制当前行并在其下方插入
                 var newRow = row.clone(true);
                 newRow.insertAfter(row);
@@ -318,7 +338,7 @@
                     sn: attr,
                     t_id: t_idV
                 };
-                newRow.find("td:not(:first):not(:last)").each(function(index, cell){
+                newRow.find("td:not(:first):not(:last)").each(function (index, cell) {
                     // 假设除了第一列和最后一列外,其他列的数据都需要提交
                     rowData[`column${index + 1}`] = $(cell).text().trim(); // 动态生成键名以避免覆盖
                 });
@@ -330,22 +350,22 @@
                     data: JSON.stringify(rowData),
                     contentType: "application/json;charset=utf-8",
                     dataType: "json",
-                    success: function(response){
-                        if(response.Code === 200){
+                    success: function (response) {
+                        if (response.Code === 200) {
                             layer.msg('复制并添加成功!', {icon: 1, time: 2000});
                         } else {
                             layer.msg('添加失败,请重试!', {icon: 5, time: 2000});
                             newRow.remove(); // 如果后端返回失败,移除新行
                         }
                     },
-                    error: function(xhr, status, error){
+                    error: function (xhr, status, error) {
                         layer.msg('请求错误,请检查网络连接!', {icon: 5, time: 2000});
                         newRow.remove(); // 发生错误时移除新行
                     }
                 });
             });
             // 绑定所有可编辑列的双击事件
-            $('tbody').on('dblclick', 'td:not(:last-child)', function(e){ // 排除最后一列的按钮
+            $('tbody').on('dblclick', 'td:not(:last-child)', function (e) { // 排除最后一列的按钮
                 var cell = $(this);
                 var row = cell.closest('tr'); // 获取当前行
                 var checkbox = row.find('input[type="checkbox"]'); // 找到本行的复选框
@@ -354,41 +374,58 @@
                 var originalText = cell.text().trim(); // 保存原始文本内容
                 var T_Ut_cell = row.find('td[name="t__ut"]');
                 var T_Ut_value = T_Ut_cell.text().trim();
+                var sn = row.find('td[sn]');
+                var attr = sn.attr('sn');
 
                 // 检查是否是第一列或第五列
-                if (columnName === 'T_tp_name' || columnName === 't__state') {
+                if (columnName === 'T_tp_name' || columnName === 't__state' || columnName === 't_sn'|| columnName === 't_id') {
                     cell.html('<select style="display:block;"></select>');
+                    cell.append('<button class="confirm-btn">确认</button>');
+
                     var selectBox = cell.find('select');
                     console.log(selectBox);
                     // 调用方法动态填充下拉选项
-                    populateSelectOptions(selectBox, columnName);
+                    populateSelectOptions(selectBox, columnName,attr);
 
                     selectBox.val(originalText);
                     selectBox.focus();
 
-                    selectBox.change(function() {
+                    selectBox.change(function () {
                         var newValue = $(this).val();
                         if (newValue !== '') {
                             cell.html(newValue);
-                            submitUpdate(rowId, columnName, newValue,T_Ut_value);
+                            submitUpdate(rowId, columnName, newValue, T_Ut_value,attr);
                             selectBox.off('change'); // 清理事件监听
                         } else {
                             cell.text(originalText);
                         }
                     });
-                }else{
+                    // 给确认按钮绑定点击事件
+                    cell.find('.confirm-btn').on('click', function() {
+                        var newValue = selectBox.val();
+                        if (newValue !== '') {
+                            cell.html(newValue);
+                            submitUpdate(rowId, columnName, newValue, T_Ut_value, attr);
+                            // 清理,比如移除确认按钮和selectBox
+                            $(this).remove();
+                            selectBox.off('change').remove();
+                        } else {
+                            cell.text(originalText);
+                        }
+                    });
+                } else {
                     // 将当前单元格内容替换为<input>元素
                     cell.html('<input type="text" class="layui-input inline-edit-input" value="' + originalText + '">');
                     // 自动聚焦到新创建的输入框
                     cell.find('.inline-edit-input').focus();
                     // 监听输入框的失焦事件,以便在用户完成编辑后保存更改
-                    cell.find('.inline-edit-input').blur(function(){
+                    cell.find('.inline-edit-input').blur(function () {
                         var newValue = $(this).val().trim();
-                        if(newValue !== ''){ // 确保输入不为空
+                        if (newValue !== '') { // 确保输入不为空
                             cell.html(newValue); // 用新值替换输入框
 
                             // 提交更改到后端,包含列名
-                            submitUpdate(rowId, columnName, newValue,T_Ut_value);
+                            submitUpdate(rowId, columnName, newValue, T_Ut_value,attr);
 
                         } else {
                             // 如果用户清空了输入框,则恢复原始内容
@@ -400,12 +437,13 @@
             });
 
             // 定义提交更新到后端的函数
-            function submitUpdate(rowId, columnName, newValue,T_Ut_value) {
+            function submitUpdate(rowId, columnName, newValue, T_Ut_value,attr) {
                 var dataToSubmit = {
                     rowId: rowId,
                     columnName: columnName,
                     newValue: newValue,
-                    T_Ut: T_Ut_value
+                    T_Ut: T_Ut_value,
+                    sn: attr,
                 };
 
                 // 发起POST请求到后端
@@ -415,38 +453,36 @@
                     data: JSON.stringify(dataToSubmit),
                     contentType: "application/json;charset=utf-8",
                     dataType: "json",
-                    success: function(response){
+                    success: function (response) {
                         console.log(response);
-                        if(response.Code === 200){
+                        if (response.Code === 200) {
                             layer.msg('更新成功!', {icon: 1, time: 2000});
-                            // location.reload()
+                            location.reload()
                         } else {
                             layer.msg('更新失败,请重试!', {icon: 5, time: 2000});
                         }
                     },
-                    error: function(xhr, status, error){
+                    error: function (xhr, status, error) {
                         layer.msg('请求错误,请检查网络连接!', {icon: 5, time: 2000});
                     }
                 });
             }
-            function populateSelectOptions(selectBox, columnName) {
-                // 这里只是一个示例逻辑,根据实际情况动态生成或从服务端获取选项
-                switch(columnName) {
+
+            function populateSelectOptions(selectBox, columnName,attr) {
+                switch (columnName) {
                     case 'T_tp_name':
                         fetch("/Device/DeviceWarning_waraning")
                             .then(response => {
                                 if (!response.ok) {
                                     throw new Error('Network response was not ok');
                                 }
-                                return response.json(); // 假设后端返回的是JSON格式的数据
+                                return response.json();
                             })
                             .then(data => {
-                                // const selectBox = document.getElementById('selectBox');
-                                console.log(data.Data);
-                                // 假设data是一个对象数组,每个对象有Key和Value属性
                                 data.Data.forEach(item => {
                                     console.log(item.Key);
-                                    selectBox.append(`<option value='${item.Key}'>${item.Value}</option>`);                                });
+                                    selectBox.append(`<option value='${item.Key}'>${item.Value}</option>`);
+                                });
                             })
                             .catch(error => {
                                 console.error('There has been a problem with your fetch operation:', error);
@@ -458,11 +494,49 @@
                         selectBox.append('<option value=2>已处理</option>');
                         selectBox.append('<option value=3>未处理</option>');
                         break;
+                    case 't_sn':
+                        fetch("/Device/DeviceWarning_ALL_SN")
+                            .then(response => {
+                                if (!response.ok) {
+                                    throw new Error('Network response was not ok');
+                                }
+                                return response.json();
+                            })
+                            .then(data => {
+                                data.Data.forEach(item => {
+                                    selectBox.append(`<option value='${item.T_sn}'>${item.T_sn}</option>`);
+                                });
+                            })
+                            .catch(error => {
+                                console.error('There has been a problem with your fetch operation:', error);
+                            });
+                        break;
+                    case 't_id':
+                        console.log(attr);
+                        const url = `/Device/DeviceWarning_ALL_TID?sn=${encodeURIComponent(attr)}`;
+                        fetch(url)
+                            .then(response => {
+                                if (!response.ok) {
+                                    throw new Error('Network response was not ok');
+                                }
+                                return response.json();
+                            })
+                            .then(data => {
+                                data.Data.forEach(item => {
+                                    console.log(data.Data);
+                                    selectBox.append(`<option value='${item.T_id}'>${item.T_id}</option>`);
+                                });
+                            })
+                            .catch(error => {
+                                console.error('There has been a problem with your fetch operation:', error);
+                            });
+                        break;
                     default:
                         // 万一其他列也需要处理,可以在这里扩展
                         break;
                 }
             }
+
             //执行一个laydate实例
                 laydate.render({
                     elem: '#Time_start', //指定元素