|
@@ -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"></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}}"><<</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}}">>></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}}"><<</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}}">>></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', //指定元素
|