js遍历json数组给html td赋值,怎么用js遍历jsonArray的值?

这是一份详细的录像回放记录,涵盖了多个时间段,从2018年7月16日至18日,包括了具体开始和结束的时间点。

@竜咚咚:

回放成功!录像搜索成功:{"FileList":[{"EndTime":"2018-07-16 10:13:11","StartTime":"2018-07-16 10:12:13"},{"EndTime":"2018-07-16 10:27:58","StartTime":"2018-07-16 10:27:03"},{"EndTime":"2018-07-16 10:35:53","StartTime":"2018-07-16 10:35:00"},{"EndTime":"2018-07-16 10:55:46","StartTime":"2018-07-16 10:54:54"},{"EndTime":"2018-07-16 11:14:10","StartTime":"2018-07-16 11:13:16"},{"EndTime":"2018-07-16 11:19:45","StartTime":"2018-07-16 11:18:49"},{"EndTime":"2018-07-16 12:30:45","StartTime":"2018-07-16 12:29:54"},{"EndTime":"2018-07-16 15:10:50","StartTime":"2018-07-16 15:09:37"},{"EndTime":"2018-07-16 15:51:52","StartTime":"2018-07-16 15:50:19"},{"EndTime":"2018-07-16 15:53:25","StartTime":"2018-07-16 15:52:21"},{"EndTime":"2018-07-16 19:15:54","StartTime":"2018-07-16 19:15:02"},{"EndTime":"2018-07-16 19:27:48","StartTime":"2018-07-16 19:26:16"},{"EndTime":"2018-07-16 19:29:07","StartTime":"2018-07-16 19:28:18"},{"EndTime":"2018-07-16 19:30:25","StartTime":"2018-07-16 19:29:34"},{"EndTime":"2018-07-16 19:32:56","StartTime":"2018-07-16 19:32:03"},{"EndTime":"2018-07-17 05:27:55","StartTime":"2018-07-17 05:27:02"},{"EndTime":"2018-07-17 05:33:42","StartTime":"2018-07-17 05:32:49"},{"EndTime":"2018-07-17 05:39:01","StartTime":"2018-07-17 05:38:04"},{"EndTime":"2018-07-17 08:11:06","StartTime":"2018-07-17 08:10:13"},{"EndTime":"2018-07-17 08:44:02","StartTime":"2018-07-17 08:42:39"},{"EndTime":"2018-07-17 08:46:54","StartTime":"2018-07-17 08:46:03"},{"EndTime":"2018-07-17 09:10:51","StartTime":"2018-07-17 09:10:39"},{"EndTime":"2018-07-17 09:11:33","StartTime":"2018-07-17 09:10:51"},{"EndTime":"2018-07-17 09:22:04","StartTime":"2018-07-17 09:21:09"},{"EndTime":"2018-07-17 09:31:09","StartTime":"2018-07-17 09:30:16"},{"EndTime":"2018-07-17 14:56:51","StartTime":"2018-07-17 14:55:46"},{"EndTime":"2018-07-17 15:39:56","StartTime":"2018-07-17 15:37:40"},{"EndTime":"2018-07-17 15:41:52","StartTime":"2018-07-17 15:40:57"},{"EndTime":"2018-07-17 15:56:22","StartTime":"2018-07-17 15:55:15"},{"EndTime":"2018-07-17 16:00:52","StartTime":"2018-07-17 15:59:59"},{"EndTime":"2018-07-17 17:42:07","StartTime":"2018-07-17 17:41:15"},{"EndTime":"2018-07-17 18:22:51","StartTime":"2018-07-17 18:21:57"},{"EndTime":"2018-07-17 18:27:39","StartTime":"2018-07-17 18:26:46"},{"EndTime":"2018-07-17 19:26:24","StartTime":"2018-07-17 19:24:51"},{"EndTime":"2018-07-17 19:27:37","StartTime":"2018-07-17 19:26:45"},{"EndTime":"2018-07-17 19:28:42","StartTime":"2018-07-17 19:27:51"},{"EndTime":"2018-07-17 19:30:23","StartTime":"2018-07-17 19:29:32"},{"EndTime":"2018-07-17 22:37:42","StartTime":"2018-07-17 22:36:52"},{"EndTime":"2018-07-17 22:39:45","StartTime":"2018-07-17 22:38:17"},{"EndTime":"2018-07-17 22:40:28","StartTime":"2018-07-17 22:39:45"},{"EndTime":"2018-07-17 22:41:44","StartTime":"2018-07-17 22:40:54"},{"EndTime":"2018-07-17 22:45:14","StartTime":"2018-07-17 22:43:59"},{"EndTime":"2018-07-17 22:46:17","StartTime":"2018-07-17 22:45:25"},{"EndTime":"2018-07-17 22:48:25","StartTime":"2018-07-17 22:47:32"},{"EndTime":"2018-07-17 22:54:03","StartTime":"2018-07-17 22:53:12"},{"EndTime":"2018-07-17 22:55:28","StartTime":"2018-07-17 22:54:38"},{"EndTime":"2018-07-17 22:57:37","StartTime":"2018-07-17 22:56:47"},{"EndTime":"2018-07-17 23:07:38","StartTime":"2018-07-17 23:06:48"},{"EndTime":"2018-07-18 02:34:18","StartTime":"2018-07-18 02:33:26"},{"EndTime":"2018-07-18 02:36:01","StartTime":"2018-07-18 02:35:09"},{"EndTime":"2018-07-18 02:37:13","StartTime":"2018-07-18 02:36:24"},{"EndTime":"2018-07-18 02:41:57","StartTime":"2018-07-18 02:41:04"},{"EndTime":"2018-07-18 05:36:04","StartTime":"2018-07-18 05:35:07"},{"EndTime":"2018-07-18 05:39:30","StartTime":"2018-07-18 05:38:30"},{"EndTime":"2018-07-18 05:55:14","StartTime":"2018-07-18 05:54:18"},{"EndTime":"2018-07-18 05:57:00","StartTime":"2018-07-18 05:55:52"},{"EndTime":"2018-07-18 06:01:31","StartTime":"2018-07-18 06:00:29"},{"EndTime":"2018-07-18 06:15:45","StartTime":"2018-07-18 06:14:28"},{"EndTime":"2018-07-18 08:03:57","StartTime":"2018-07-18 08:02:50"},{"EndTime":"2018-07-18 08:06:46","StartTime":"2018-07-18 08:05:01"},{"EndTime":"2018-07-18 08:11:35","StartTime":"2018-07-18 08:10:40"},{"EndTime":"2018-07-18 08:16:04","StartTime":"2018-07-18 08:14:48"},{"EndTime":"2018-07-18 08:21:02","StartTime":"2018-07-18 08:19:45"},{"EndTime":"2018-07-18 08:24:49","StartTime":"2018-07-18 08:21:02"},{"EndTime":"2018-07-18 08:26:39","StartTime":"2018-07-18 08:25:06"},{"EndTime":"2018-07-18 08:30:01","StartTime":"2018-07-18 08:27:56"},{"EndTime":"2018-07-18 08:32:02","StartTime":"2018-07-18 08:30:13"},{"EndTime":"2018-07-18 08:33:21","StartTime":"2018-07-18 08:32:06"},{"EndTime":"2018-07-18 08:40:45","StartTime":"2018-07-18 08:39:56"},{"EndTime":"2018-07-18 08:42:37","StartTime":"2018-07-18 08:41:23"},{"EndTime":"2018-07-18 08:44:28","StartTime":"2018-07-18 08:43:41"},{"EndTime":"2018-07-18 08:58:17","StartTime":"2018-07-18 08:56:47"},{"EndTime":"2018-07-18 09:02:55","StartTime":"2018-07-18 09:02:05"},{"EndTime":"2018-07-18 09:07:37","StartTime":"2018-07-18 09:06:49"},{"EndTime":"2018-07-18 09:08:34","StartTime":"2018-07-18 09:08:04"},{"EndTime":"2018-07-18 09:08:53","StartTime":"2018-07-18 09:08:34"},{"EndTime":"2018-07-18 09:09:42","StartTime":"2018-07-18 09:08:54"},{"EndTime":"2018-07-18 09:18:00","StartTime":"2018-07-18 09:14:17"},{"EndTime":"2018-07-18 09:21:55","StartTime":"2018-07-18 09:19:44"},{"EndTime":"2018-07-18 09:22:42","StartTime":"2018-07-18 09:21:55"},{"EndTime":"2018-07-18 09:23:54","StartTime":"2018-07-18 09:23:01"},{"EndTime":"2018-07-18 09:25:32","StartTime":"2018-07-18 09:23:54"},{"EndTime":"2018-07-18 09:32:59","StartTime":"2018-07-18 09:26:24"},{"EndTime":"2018-07-18 09:33:36","StartTime":"2018-07-18 09:32:59"},{"EndTime":"2018-07-18 09:36:19","StartTime":"2018-07-18 09:35:07"},{"EndTime":"2018-07-18 09:37:42","StartTime":"2018-07-18 09:36:24"},{"EndTime":"2018-07-18 09:42:15","StartTime":"2018-07-18 09:38:57"},{"EndTime":"2018-07-18 09:44:06","StartTime":"2018-07-18 09:43:17"},{"EndTime":"2018-07-18 09:46:13","StartTime":"2018-07-18 09:45:24"},{"EndTime":"2018-07-18 09:47:11","StartTime":"2018-07-18 09:46:23"},{"EndTime":"2018-07-18 09:48:08","StartTime":"2018-07-18 09:47:22"},{"EndTime":"2018-07-18 09:51:12","StartTime":"2018-07-18 09:50:23"},{"EndTime":"2018-07-18 09:52:45","StartTime":"2018-07-18 09:51:25"},{"EndTime":"2018-07-18 09:54:06","StartTime":"2018-07-18 09:53:20"},{"EndTime":"2018-07-18 09:56:34","StartTime":"2018-07-18 09:55:02"},{"EndTime":"2018-07-18 09:57:29","StartTime":"2018-07-18 09:56:40"},{"EndTime":"2018-07-18 10:00:19","StartTime":"2018-07-18 09:57:29"},{"EndTime":"2018-07-18 10:03:27","StartTime":"2018-07-18 10:00:19"},{"EndTime":"2018-07-18 10:04:20","StartTime":"2018-07-18 10:03:27"},{"EndTime":"2018-07-18 10:09:58","StartTime":"2018-07-18 10:06:05"},{"EndTime":"2018-07-18 10:12:03","StartTime":"2018-07-18 10:11:16"},{"EndTime":"2018-07-18 10:13:43","StartTime":"2018-07-18 10:12:06"},{"EndTime":"2018-07-18 10:15:55","StartTime":"2018-07-18 10:14:22"},{"EndTime":"2018-07-18 10:22:06","StartTime":"2018-07-18 10:18:27"},{"EndTime":"2018-07-18 10:24:17","StartTime":"2018-07-18 10:23:29"},{"EndTime":"2018-07-18 10:25:03","StartTime":"2018-07-18 10:24:17"},{"EndTime":"2018-07-18 10:26:49","StartTime":"2018-07-18 10:25:03"},{"EndTime":"2018-07-18 10:28:06","StartTime":"2018-07-18 10:27:11"},{"EndTime":"2018-07-18 10:33:05","StartTime":"2018-07-18 10:30:21"},{"EndTime":"2018-07-18 10:34:50","StartTime":"2018-07-18 10:33:06"},{"EndTime":"2018-07-18 10:35:59","StartTime":"2018-07-18 10:35:10"},{"EndTime":"2018-07-18 10:40:12","StartTime":"2018-07-18 10:39:21"},{"EndTime":"2018-07-18 10:40:55","StartTime":"2018-07-18 10:40:12"},{"EndTime":"2018-07-18 10:44:26","StartTime":"2018-07-18 10:42:41"},{"EndTime":"2018-07-18 10:49:29","StartTime":"2018-07-18 10:44:50"},{"EndTime":"2018-07-18 10:51:18","StartTime":"2018-07-18 10:50:12"},{"EndTime":"2018-07-18 10:52:04","StartTime":"2018-07-18 10:51:25"},{"EndTime":"2018-07-18 10:53:52","StartTime":"2018-07-18 10:52:33"},{"EndTime":"2018-07-18 10:55:22","StartTime":"2018-07-18 10:53:53"},{"EndTime":"2018-07-18 10:59:47","StartTime":"2018-07-18 10:58:22"},{"EndTime":"2018-07-18 11:05:08","StartTime":"2018-07-18 11:04:19"},{"EndTime":"2018-07-18 11:06:49","StartTime":"2018-07-18 11:05:47"},{"EndTime":"2018-07-18 11:11:23","StartTime":"2018-07-18 11:09:22"},{"EndTime":"2018-07-18 11:17:28","StartTime":"2018-07-18 11:16:05"},{"EndTime":"2018-07-18 11:24:21","StartTime":"2018-07-18 11:17:38"},{"EndTime":"2018-07-18 11:26:13","StartTime":"2018-07-18 11:24:21"},{"EndTime":"2018-07-18 11:27:10","StartTime":"2018-07-18 11:26:21"},{"EndTime":"2018-07-18 11:48:29","StartTime":"2018-07-18 11:47:36"},{"EndTime":"2018-07-18 11:50:30","StartTime":"2018-07-18 11:48:29"},{"EndTime":"2018-07-18 11:54:35","StartTime":"2018-07-18 11:53:25"},{"EndTime":"2018-07-18 11:55:34","StartTime":"2018-07-18 11:54:46"},{"EndTime":"2018-07-18 11:58:54","StartTime":"2018-07-18 11:57:28"},{"EndTime":"2018-07-18 12:02:59","StartTime":"2018-07-18 12:02:08"},{"EndTime":"2018-07-18 12:04:27","StartTime":"2018-07-18 12:02:59"},{"EndTime":"2018-07-18 12:08:13","StartTime":"2018-07-18 12:04:27"},{"EndTime":"2018-07-18 12:10:09","StartTime":"2018-07-18 12:08:15"},{"EndTime":"2018-07-18 12:10:52","StartTime":"2018-07-18 12:10:09"},{"EndTime":"2018-07-18 12:13:05","StartTime":"2018-07-18 12:10:52"},{"EndTime":"2018-07-18 12:15:10","StartTime":"2018-07-18 12:13:06"},{"EndTime":"2018-07-18 12:18:13","StartTime":"2018-07-18 12:15:16"},{"EndTime":"2018-07-18 12:23:11","StartTime":"2018-07-18 12:21:39"},{"EndTime":"2018-07-18 12:30:57","StartTime":"2018-07-18 12:23:44"},{"EndTime":"2018-07-18 12:41:24","StartTime":"2018-07-18 12:30:57"},{"EndTime":"2018-07-18 12:43:13","StartTime":"2018-07-18 12:41:53"},{"EndTime":"2018-07-18 12:45:56","StartTime":"2018-07-18 12:43:39"},{"EndTime":"2018-07-18 12:46:41","StartTime":"2018-07-18 12:45:56"},{"EndTime":"2018-07-18 12:47:28","StartTime":"2018-07-18 12:46:41"},{"EndTime":"2018-07-18 12:49:41","StartTime":"2018-07-18 12:48:07"},{"EndTime":"2018-07-18 12:50:20","StartTime":"2018-07-18 12:49:41"},{"EndTime":"2018-07-18 12:53:27","StartTime":"2018-07-18 12:52:13"},{"EndTime":"2018-07-18 12:57:10","StartTime":"2018-07-18 12:53:27"},{"EndTime":"2018-07-18 12:58:25","StartTime":"2018-07-18 12:57:12"},{"EndTime":"2018-07-18 13:01:06","StartTime":"2018-07-18 12:59:58"},{"EndTime":"2018-07-18 13:10:18","StartTime":"2018-07-18 13:01:32"},{"EndTime":"2018-07-18 13:18:25","StartTime":"2018-07-18 13:10:18"},{"EndTime":"2018-07-18 13:21:11","StartTime":"2018-07-18 13:18:46"},{"EndTime":"2018-07-18 13:23:44","StartTime":"2018-07-18 13:22:05"},{"EndTime":"2018-07-18 13:26:22","StartTime":"2018-07-18 13:24:17"},{"EndTime":"2018-07-18 13:27:55","StartTime":"2018-07-18 13:26:22"},{"EndTime":"2018-07-18 13:28:53","StartTime":"2018-07-18 13:27:59"},{"EndTime":"2018-07-18 13:29:20","StartTime":"2018-07-18 13:28:53"},{"EndTime":"2018-07-18 13:31:58","StartTime":"2018-07-18 13:31:05"},{"EndTime":"2018-07-18 13:34:28","StartTime":"2018-07-18 13:33:40"},{"EndTime":"2018-07-18 13:38:50","StartTime":"2018-07-18 13:37:55"},{"EndTime":"2018-07-18 13:39:44","StartTime":"2018-07-18 13:38:52"},{"EndTime":"2018-07-18 13:44:52","StartTime":"2018-07-18 13:40:14"},{"EndTime":"2018-07-18 14:09:45","StartTime":"2018-07-18 14:07:57"}],"FileSize":167}

<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="weaver.general.Util"%> <%@page import="weaver.conn.RecordSet"%> <%@page import="com.alibaba.fastjson.JSONObject"%> <%@page import="com.alibaba.fastjson.JSONArray"%> <%@page import="java.net.URLEncoder"%> <% request.setCharacterEncoding("UTF-8"); // 基础参数 String pddhRaw = Util.null2String(request.getParameter("PDDH")); String pddh = "0"; try { pddh = String.valueOf(Integer.parseInt(pddhRaw)); } catch(Exception e){ pddh = "0"; } // 查询参数(做简单清洗,避免注入/通配符滥用) String q_zcbm = Util.null2String(request.getParameter("q_zcbm")).replaceAll("[%'_]", ""); String q_syr = Util.null2String(request.getParameter("q_syr")).replaceAll("[%'_]", ""); String q_sybm = Util.null2String(request.getParameter("q_sybm")).replaceAll("[%'_]", ""); // 组装 SQL StringBuilder sql = new StringBuilder(); sql.append("select zcmc,zcbm,zcqc,zcgz,zclz,zcfl,ppxh,syr,sybm,rkrq,pdbz,zczt,pdsj,zcgs ") .append("from uf_CKBGQD where pddh=").append(pddh); if(q_zcbm.length()>0){ sql.append(" and zcbm like '%").append(q_zcbm).append("%'"); } if(q_syr.length()>0 ){ sql.append(" and syr like '%").append(q_syr ).append("%'"); } if(q_sybm.length()>0){ sql.append(" and sybm like '%").append(q_sybm).append("%'"); } // 查询 JSONArray jsonArray = new JSONArray(); RecordSet rs = new RecordSet(); rs.execute(sql.toString()); while(rs.next()){ JSONObject row = new JSONObject(); row.put("zcmc", rs.getString("zcmc")); row.put("zcbm", rs.getString("zcbm")); row.put("zcqc", rs.getString("zcqc")); row.put("zcgz", rs.getString("zcgz")); row.put("zclz", rs.getString("zclz")); row.put("zcfl", rs.getString("zcfl")); row.put("ppxh", rs.getString("ppxh")); row.put("syr", rs.getString("syr")); row.put("sybm", rs.getString("sybm")); // 使用部门 row.put("rkrq", rs.getString("rkrq")); row.put("pdbz", rs.getString("pdbz")); row.put("zczt", rs.getString("zczt")); row.put("pdsj", rs.getString("pdsj")); row.put("zcgs", rs.getString("zcgs")); // 资产归属 jsonArray.add(row); } // 把数据输出给前端 JS 使用(便于导出/前端处理) String dataJson = jsonArray.toJSONString(); %> <!DOCTYPE html> <html> <head> <title>查看报告</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"> <link rel="stylesheet" href="/cloudstore/resource/pc/com/v1/index.min.css?v=1715806801819"> <link rel="stylesheet" href="/cloudstore/resource/pc/com/v1/ecCom.min.css?v=1715806801819"> <script type="text/javascript" src="/js/My97DatePicker/WdatePicker.js" charset="gb2312"></script> <script type="text/javascript" src="/js/jquery/jquery-3.7.1.min.js"></script> <style> .toolbar { display:flex; gap:8px; align-items:center; padding:10px 0; flex-wrap:wrap; } .toolbar input { height:32px; padding:0 8px; } .toolbar .btn { height:32px; padding:0 12px; border:1px solid #d9d9d9; border-radius:4px; background:#fff; cursor:pointer; } .toolbar .btn.primary { background:#1677ff; color:#fff; border-color:#1677ff; } .action-link { color:#1677ff; cursor:pointer; } </style> </head> <body style="width:100%; height:100%;"> <div id="container"> <div class="coms-mode-docker coms-mode-search"> <div id="cube_search_9"> <div class="ant-spin-nested-loading"> <div class="ant-spin-container"> <div style="height: 100%;"> <div class="wea-new-top-content" style="height: 691.175px; overflow-y: hidden;"> <div class="cube-list-wrapper"> <!-- 查询工具条 & 导出 --> <form id="queryForm" method="get" class="toolbar"> <input type="hidden" name="PDDH" value="<%=pddh%>" /> <label>物料编码:</label> <input type="text" name="q_zcbm" value="<%=q_zcbm%>" placeholder="支持模糊查询"> <label>使用人:</label> <input type="text" name="q_syr" value="<%=q_syr%>" placeholder="支持模糊查询"> <label>使用部门:</label> <input type="text" name="q_sybm" value="<%=q_sybm%>" placeholder="支持模糊查询"> <button type="submit" class="btn primary">查询</button> <button type="button" class="btn" id="btnReset">重置</button> <button type="button" class="btn" id="btnExport">导出当前结果</button> </form> <div class="wea-new-table cube-list-table pageAutoWrap"> <div style="width: 100%; height: 100%;"> <div class="cube-list-table clearfix"> <div class="ant-spin-nested-loading"> <div class="ant-spin-container"> <div class="ant-table ant-table-large ant-table-fixed-header ant-table-scroll-position-left"> <div class="ant-table-content" style="padding-left: 0px; padding-right: 0px;"> <div class="ant-table-scroll"> <span> <div class="ant-table-header" style="overflow-x: scroll; margin-bottom: 0px !important; padding-bottom: 0px !important;"> <table class="ant-table-fixed" style="width: 100%;"> <colgroup> <col style="width: 14%"> <col style="width: 10%"> <col style="width: 14%"> <col style="width: 8%"> <col style="width: 8%"> <col style="width: 8%"> <col style="width: 10%"> <col style="width: 8%"> <col style="width: 10%"> <col style="width: 8%"> <col style="width: 8%"> <col style="width: 10%"> </colgroup> <thead class="ant-table-thead"> <tr style="height: 41.6px;"> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">物料编码</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">资产名称</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">资产全称</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">资产类属</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">资产归属</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">资产分类</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">品牌/型号</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">使用人</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">使用部门</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">入库日期</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">资产状态</span></th> <th class="react-resizable"><span class="ant-table-column-sorterN text-elli">操作</span></th> </tr> </thead> </table> </div> <div class="ant-table-body" style="overflow: auto scroll; max-height: 600px; min-height: auto;"> <table class="ant-table-fixed" style="width: 100%;" id="dataTable"> <colgroup> <col style="width: 14%"> <col style="width: 10%"> <col style="width: 14%"> <col style="width: 8%"> <col style="width: 8%"> <col style="width: 8%"> <col style="width: 10%"> <col style="width: 8%"> <col style="width: 10%"> <col style="width: 8%"> <col style="width: 8%"> <col style="width: 10%"> </colgroup> <tbody class="ant-table-tbody"> <% if(jsonArray.size()>0){ for(int i=0;i<jsonArray.size();i++){ %> <tr class="ant-table-row ant-table-row-level-0"> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("zcbm")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("zcmc")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("zcqc")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("zclz")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("zcgs")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("zcfl")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("ppxh")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("syr")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("sybm")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("rkrq")%></span></td> <td class="react-resizable"><span class="wea-url"><%=jsonArray.getJSONObject(i).getString("zczt")%></span></td> <td class="react-resizable"> <span class="action-link" onclick="onDelete(this)">删除</span> </td> </tr> <% } } %> </tbody> </table> </div> </span> </div> </div> </div> </div> </div> <!-- ant-spin-container --> </div> </div> </div> <!-- table wrap --> </div> </div> </div> </div> </div> <!-- spin --> </div> </div> </div> <script> // 前端可用数据(用于导出) const tableData = <%=dataJson%>; // 重置查询 $("#btnReset").on("click", function(){ const base = location.pathname + "?PDDH=<%=pddh%>"; location.href = base; }); // 一键导出(把当前结果导成 CSV) $("#btnExport").on("click", function(){ if(!tableData || tableData.length === 0){ alert("没有可导出的数据"); return; } const headers = ["物料编码","资产名称","资产全称","资产类属","资产归属","资产分类","品牌/型号","使用人","使用部门","入库日期","资产状态","盘点备注","盘点时间"]; const keys = ["zcbm","zcmc","zcqc","zclz","zcgs","zcfl","ppxh","syr","sybm","rkrq","zczt","pdbz","pdsj"]; // CSV 内容,含 BOM 以防中文乱码(Excel 友好) let csv = "\uFEFF" + headers.join(",") + "\n"; tableData.forEach(r=>{ const row = keys.map(k=>{ let val = (r[k] ?? "").toString().replace(/"/g,'""'); // 若包含逗号/引号/换行,按 CSV 规范用引号包裹 if(/[",\n]/.test(val)){ val = `"${val}"`; } return val; }).join(","); csv += row + "\n"; }); const blob = new Blob([csv], {type: "text/csv;charset=utf-8;"}); const url = URL.createObjectURL(blob); const a = document.createElement("a"); const ts = new Date(); const pad = n=> String(n).padStart(2,"0"); const name = `盘点清单_${ts.getFullYear()}${pad(ts.getMonth()+1)}${pad(ts.getDate())}_${pad(ts.getHours())}${pad(ts.getMinutes())}${pad(ts.getSeconds())}.csv`; a.href = url; a.download = name; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); }); // 删除:把该行的“物料编码”传给后端 function onDelete(el){ const $tr = $(el).closest("tr"); const zcbm = $tr.find("td").eq(0).text().trim(); // 第1列就是物料编码 if(!zcbm){ alert("未找到物料编码"); return; } if(!confirm("确认删除物料编码为【"+zcbm+"】的记录吗?")) return; // // TODO: 把 URL 换成你后端实际的删除接口 // $.ajax({ // url: "/api/ckbgqd/delete", // 例如:新建一个 Servlet/JSP 接口去处理删除 // type: "POST", // data: { zcbm: zcbm, pddh: "<%=pddh%>" }, // success: function(res){ // // 这里按你的后端返回格式调整 // // 假设返回 {success:true,msg:"ok"} // try{ // const r = typeof res === "string" ? JSON.parse(res) : res; // if(r.success){ // $tr.remove(); // }else{ // alert(r.msg || "删除失败"); // } // }catch(e){ // // 如果不是 JSON,就当成功处理 // $tr.remove(); // } // }, // error: function(){ // alert("请求失败,请稍后重试"); // } // }); var pddh = "<%=pddh%>"; <% String sql = "delete from uf_CKBGQD where pddh ='"<%=pddh%>"' and zcbm ="+"'"+zcbm+"'"; RecordSet rs1 = new RecordSet(); rs1.execute(rs1); %> } </script> </body> </html> 这个有错误,帮修复一下
最新发布
10-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值