<!-- ==================== 主表单结构 ==================== -->
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableForm" style="table-layout: fixed;">
<colgroup>
<col width="80" />
<col /><!--hide4phone.start-->
<col width="80" />
<col width="380" /><!--hide4phone.end-->
</colgroup>
<tbody>
<tr>
<td style="text-align: right;"> <span style="color: red;">*</span>Subject:</td>
<td dbf.type="required" id="dbf.subject"> </td>
<!--show4phone.start-->
</tr>
<tr><!--show4phone.end-->
<td style="text-align: right;"> Status:</td>
<td><span id="mapping.dbf.procXSource"> </span> Responsor: <span id="mapping.dbf.responsorSource"> </span> Participants: <span id="mapping.dbf.participantsSource"> </span></td>
</tr>
</tbody>
</table>
<div> </div>
<!-- ==================== 页面标题 ==================== -->
<div style="text-align: center;">
<h1><img src="../common/logo.png" /> [报价历史查询内勤用]</h1>
</div>
<div>[Design form here, based on the template below, or customized by yourself after the template removed]</div>
<!-- ==================== 查询输入区域 ==================== -->
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableListBorder" style="table-layout: fixed; width: 928px;">
<colgroup>
<col width="130" />
<col /><!--hide4phone.start-->
<col width="130" />
<col width="330" /><!--hide4phone.end-->
</colgroup>
<tbody>
<tr>
<td colspan="4" style="background-color: lightyellow;"> </td>
</tr>
<tr>
<td class="fieldLabel" style="text-align: center; width: 147px;"><span style="color: red;">*</span> username</td>
<td id="username" style="width: 210px;"> </td>
<!--show4phone.start-->
</tr>
<tr><!--show4phone.end-->
<td class="fieldLabel" style="text-align: center; width: 63px;"><span style="color: red;">*</span> id</td>
<td id="ID" style="width: 254px;"> </td>
</tr>
<tr>
<td class="fieldLabel" style="text-align: center;">项目名称</td>
<td id="项目名称" style="width: 210px;"> </td>
<td class="fieldLabel" style="text-align: center;">装置名称</td>
<td id="装置名称" style="width: 254px;"> </td>
</tr>
<tr>
<td class="fieldLabel" style="text-align: center;">Customer Name</td>
<td id="CustomerName" style="width: 210px;"> </td>
<td class="fieldLabel" style="text-align: center;">E-NO/序列号</td>
<td id="ENO" style="width: 254px;"> </td>
</tr>
<tr>
<td class="fieldLabel" style="text-align: center;">产品描述</td>
<td id="产品描述" style="width: 210px;"> </td>
<td class="fieldLabel" style="text-align: center;">Remark</td>
<td id="Remark" style="width: 254px;"> </td>
</tr>
</tbody>
</table>
<!-- ==================== 查询结果表格容器 ==================== -->
<div id="resultTableContainer" style="margin-top: 20px; padding: 0 10px;"><!-- 动态表格将插入到这里 --></div>
<!-- ==================== 手机适配区域(可选)==================== -->
<div class="slide4phone">
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableListBorder2" style="table-layout: fixed;">
<colgroup>
<col width="460" />
<col width="140" />
<col />
</colgroup>
</table>
</div>
<!-- ==================== 查询按钮 ==================== -->
<div style="text-align: center; margin: 20px 0;"> <input id="idslist" name="idslist" type="hidden" /> <strong> <input id="check" name="check" onclick="clickData()" type="button" value="check个人记录" /> </strong></div>
<!-- ==================== 移动端表格占位 ==================== -->
<div class="slide4phone2" id="reptable">
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableListBorder2" style="width: 1300px;">
</table>
</div>
<script language="javascript">
function clickData() {
// 获取输入框的值并添加通配符 % 用于模糊查询
var username = '%' + document.getElementById('username').textContent.trim() + '%';
var 项目name = '%' + document.getElementById('项目名称').textContent.trim() + '%';
var 装置name = '%' + document.getElementById('装置名称').textContent.trim() + '%';
var CustomerName = '%' + document.getElementById('CustomerName').textContent.trim() + '%';
var ENO = '%' + document.getElementById('ENO').textContent.trim() + '%';
var Remark = '%' + document.getElementById('Remark').textContent.trim() + '%';
var Product描述 = '%' + document.getElementById('产品描述').textContent.trim() + '%';
// 构建 SQL 查询语句(注意字段名和表名需正确)
var sqlQuery2 =
"SELECT Subject,Status,申请人,申请日期,产品类别,其他,type,内勤,系统,customer,ProjectName,DeviceName,新产品,[E-NO/序列号],目标价,数量,产地,含税报价,HandlerRemark,Remark,描述 " +
"FROM X_BPM_DWH_819 " +
"WHERE ProjectName LIKE '" + 项目name + "' " +
"AND DeviceName LIKE '" + 装置name + "' " +
"AND customer LIKE '" + CustomerName + "' " +
"AND [E-NO/序列号] LIKE '" + ENO + "' " +
"AND Remark LIKE '" + Remark + "' " +
"AND 描述 LIKE '" + Product描述 + "'";
// 调用后台服务获取数据(假设返回的是二维数组)
eval("var arr=" + service("common.js", "getDbsRecords", sqlQuery2, "array"));
// 清空之前的结果
var container = document.getElementById("resultTableContainer");
container.innerHTML = "";
if (!arr || arr.length === 0) {
container.innerHTML = "<p>未找到匹配的数据。</p>";
return;
}
// 创建表格
var table = document.createElement("table");
table.className = "tableListBorder";
table.style.width = "100%";
table.style.tableLayout = "fixed";
table.setAttribute("border", "1");
table.setAttribute("cellpadding", "5");
table.setAttribute("cellspacing", "0");
// 添加表头(使用 arr[0] 的键作为列名,或手动定义)
var thead = document.createElement("thead");
var headerRow = document.createElement("tr");
// 手动定义表头文字(与 SELECT 字段顺序一致)
var headers = [
"Subject", "Status", "申请人", "申请日期", "产品类别", "其他", "类型",
"内勤", "系统", "客户", "项目名称", "装置名称", "新产品",
"E-NO/序列号", "目标价", "数量", "产地", "含税报价", "处理备注", "备注", "描述"
];
headers.forEach(function (text) {
var th = document.createElement("th");
th.style.backgroundColor = "#f0f0f0";
th.style.textAlign = "center";
th.style.fontSize = "14px";
th.textContent = text;
headerRow.appendChild(th);
});
thead.appendChild(headerRow);
table.appendChild(thead);
// 添加数据行
var tbody = document.createElement("tbody");
arr.forEach(function (row) {
var tr = document.createElement("tr");
for (var i = 0; i < row.length; i++) {
var td = document.createElement("td");
td.style.padding = "5px";
td.style.fontSize = "13px";
td.style.wordBreak = "break-word";
td.textContent = row[i] || "";
tr.appendChild(td);
}
tbody.appendChild(tr);
});
table.appendChild(tbody);
// 将表格插入容器
container.appendChild(table);
}
</script>
修改代码 第二次按查询按钮后 会重置生成结果