接手别人的代码,前端基本都写在了js中
下方置顶按钮写在了循环中,本身写的点击置顶layer.open一个下拉框,需要改为layer.open一个日期选择器
或者别的方式点击置顶能弹出来一个日期选择器求指点!
/**
* 门户基本信息保存、删除、更多页面js
*/
$(function () {
// 分页divID
var dataTabId = "dataPageTab";
var dataType="dataPageType";
// 分页查询按钮ID
var dataTabSearchId = "pageTabSearch";
var editBtn = "edit";
//上移
var upBtnName = "up";
//下移
var downBtnName = "down";
// 发布url
var addUrl = BASE_PATH + ACTION_BASE_PATH + "/editData";
// 数据查询Url
var searchDataUrl = BASE_PATH + "/sl/info/getPage";
var pageT = null;
// 更多查询
if ($("#" + dataTabId).size() > 0) {
debugger;
pageT = new PageTable(dataTabId, "div");
// 设置表格头
pageT.setHead("");
// 设置列个数
pageT.headCount = 1;
// 设置查询方法
pageT.searchFunction = function (toPage) {
pageSearchData(toPage);
findType (toPage);
};
// 展示页码按钮
pageT.pageNumberListShow = true;
pageT.searchFunctionAfter = function () {
$("[name='" + upBtnName + "']").each(function () {
var $this = $(this);
$this.on("click", function () {
up($this.attr("biid"));
});
});
$("[name='" + downBtnName + "']").each(function () {
var $this = $(this);
$this.on("click", function () {
down($this.attr("biid"));
});
});
};
// 创建实体
pageT.create();
// 增加查询按钮
$("#" + dataTabSearchId).on("click", function () {
pageT.search(1);
});
}
$("#type").change(function () {
pageT.search(1);
});
// 分页查询方法
function pageSearchData(toPage) {
debugger;
var infoType = $("#infoType").find("option:selected").val();
var typeName = $("#tab").find("option:selected").text();
if (toPage == null || toPage == undefined) {
toPage = 1;
}
var data = {
"pageNum": toPage,
infoType: infoType,
typeName: typeName
};
MFW.AjaxUtil.syncPost(searchDataUrl, data, function (result) {
var pageFlag = false;
if (result != null && result != undefined) {
if (result.success) {
var pageInfo = result.data;
if (pageInfo != null) {
var resultData = pageInfo.data;
if (resultData != null && resultData.length > 0) {
var dataInfoOne = "";
var dataInfo = "";
dataInfoOne += "<table class='sx_cxda_table' style='margin-bottom:0px'>";
dataInfoOne += "<tr>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='38px' align='center'>序号</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>标题</td>";
dataInfoOne += "<td class='' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>类型</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>问题类型</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>问题标签</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>创建时间</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>操作</td>";
dataInfoOne += "</tr>";
dataInfoOne += "</table>";
dataInfo += '<table class="sx_cxda_table" style="margin-top:0px">';
for (var i = 0; i < resultData.length; i++) {
var itemData = resultData[i];
if (itemData != null) {
dataInfo += "<tr>";
var number = i + 1;
dataInfo += '<td align="center" style="width: 38px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + number + '</a></td>';
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + itemData.infoTitle + '</a></td>';
let type;
if ("0" == itemData.infoType) {
type = "常见问题";
} else if ("1" == itemData.infoType) {
type = "信息安全";
}
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + type + '</a></td>';
let tab;
if (null == itemData.tabName) {
tab = "-";
} else {
tab = itemData.tabName;
}
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + tab + '</a></td>';
let label;
if (null == itemData.labelName) {
label = "-";
} else {
label = itemData.labelName;
}
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + label + '</a></td>';
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + itemData.createTime + '</a></td>';
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7">';
dataInfo += '<p><a target="_blank" href=' + BASE_PATH + 'sl/info/dataInfoEdit?id=' + itemData.id + ' style="color:red;" id="' + editBtn + '" name="' + editBtn + '">编辑</a>';
dataInfo += ' <a href="javascript:void(0);" style="color:red;" onclick="del(\'' + itemData.id + '\');">删除</a>';
dataInfo += ' <a href="javascript:void(0);" style="color:red;" onclick="isUp(\'' + itemData.id + '\');">置顶</a>';
dataInfo += '</td>';
}
dataInfo += "</tr>";
}
dataInfo += "</table>";
// 设置表格头
pageT.setHead(dataInfoOne);
// 设置数据内容
pageT.setData(dataInfo);
// 设置总条数
pageT.total = pageInfo.count;
// 设置当前页码
pageT.pageNumber = pageInfo.code;
pageFlag = true;
}
}
}
if (!pageFlag) {
pageT.setData(null);
pageT.pageNumber = 1;
pageT.total = 0;
}
}
});
}
function findType(toPage){
if (toPage == null || toPage == undefined) {
toPage = 1;
}
$(document).on("click", '#chaxun', function () {
var infoType = $("#infoType").find("option:selected").val();
var typeName = $("#tab").find("option:selected").text();
var pageFlag = false;
var data={
"pageNum": toPage,
infoType: infoType,
typeName: typeName
}
MFW.AjaxUtil.syncPost(searchDataUrl, data, function (result) {
debugger;
var pageFlag = false;
if (result != null && result != undefined) {
if (result.success) {
var pageInfo = result.data;
if (pageInfo != null) {
var resultData = pageInfo.data;
if (resultData != null && resultData.length > 0) {
var dataInfoOne = "";
var dataInfo = "";
dataInfoOne += "<table class='sx_cxda_table' style='margin-bottom:0px'>";
dataInfoOne += "<tr>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='38px' align='center'>序号</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>标题</td>";
dataInfoOne += "<td class='' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>类型</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>问题类型</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>问题标签</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>创建时间</td>";
dataInfoOne += "<td class='sx_cxda_table_data' style='border-bottom:1px solid #e5e5e5;' width='80px' align='center'>操作</td>";
dataInfoOne += "</tr>";
dataInfoOne += "</table>";
dataInfo += '<table class="sx_cxda_table" style="margin-top:0px">';
for (var i = 0; i < resultData.length; i++) {
var itemData = resultData[i];
if (itemData != null) {
dataInfo += "<tr>";
var number = i + 1;
dataInfo += '<td align="center" style="width: 38px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + number + '</a></td>';
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + itemData.infoTitle + '</a></td>';
let type;
if ("0" == itemData.infoType) {
type = "常见问题";
} else if ("1" == itemData.infoType) {
type = "信息安全";
}
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + type + '</a></td>';
let tab;
if (null == itemData.tabName) {
tab = "-";
} else {
tab = itemData.tabName;
}
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + tab + '</a></td>';
let label;
if (null == itemData.labelName) {
label = "-";
} else {
label = itemData.labelName;
}
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + label + '</a></td>';
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7"><span style="font-family:microsoft yahei;color:#000000;">' + itemData.createTime + '</a></td>';
dataInfo += '<td align="center" style="width: 80px; border: 1px solid #d7d7d7">';
dataInfo += '<p><a target="_blank" href=' + BASE_PATH + 'sl/info/dataInfoEdit?id=' + itemData.id + ' style="color:red;" id="' + editBtn + '" name="' + editBtn + '">编辑</a>';
dataInfo += ' <a href="javascript:void(0);" style="color:red;" onclick="del(\'' + itemData.id + '\');">删除</a>';
dataInfo += ' <a href="javascript:void(0);" style="color:red;" onclick="isUp(\'' + itemData.id + '\');">置顶</a>';
dataInfo += '</td>';
}
dataInfo += "</tr>";
}
dataInfo += "</table>";
// 设置表格头
pageT.setHead(dataInfoOne);
// 设置数据内容
pageT.setData(dataInfo);
// 设置总条数
pageT.total = pageInfo.count;
// 设置当前页码
pageT.pageNumber = pageInfo.code;
pageFlag = true;
}
}
}
if (!pageFlag) {
pageT.setData(null);
pageT.pageNumber = 1;
pageT.total = 0;
}
}
});
pageT.refresh();
});
}
function up(id) {
let firstT = $("#type option:selected").val();
$.ajax({
url: BASE_PATH + '/sl/dataInfo/upDataOrder',
type: "post",
data: {
"id": id,
firstT: firstT
},
success: function (result) {
pageT.search(1);
}
})
}
function down(id) {
let firstT = $("#type option:selected").val();
$.ajax({
url: BASE_PATH + '/sl/dataInfo/downDataOrder',
type: "post",
data: {
"id": id,
firstT: firstT
},
success: function (result) {
pageT.search(1);
}
})
}
});
//删除
function del(id) {
var isDel = "1";
if (CommonUtil.nullToEmptyStr(id) != "") {
// 校验
layer.confirm("你确定要删除此条数据吗?", function () {
var data = {
"isDel": isDel,
"id": id,
};
var url = BASE_PATH + "/sl/info/edit";
MFW.AjaxUtil.syncPost(url, data, function (result) {
if (result != null && result != undefined) {
if (result) {
var _alert = layer.alert("删除成功!", function () {
parent.layer.close(_alert);
window.location.reload();
});
} else {
layer.alert("删除失败!");
}
} else {
layer.alert("删除失败!");
}
});
});
} else {
var _alert = layer.alert("操作失败!", function () {
parent.layer.close(_alert);
pageT.searchThisPage();
});
}
}
//置顶
function isUp(id) {
if (CommonUtil.nullToEmptyStr(id) != "") {
// layer.open({
// title: '置顶天数当日零点起算'
// , btn: ['确定']
// , content: '<div class="layui-form-item">' +
// '<label class="layui-form-label">置顶天数</label>' +
// '<div class="layui-input-block">' +
// '<select name="range" id="range" lay-filter="range">' +
// '<option value="1">一天</option>' +
// '<option value="3">三天</option>' +
// '<option value="5">五天</option>' +
// '<option value="7">七天</option>' +
// '</select>' +
// '</div>' +
// '</div>',
//
// yes: function (index, layero) {
// var day = $("#range").find("option:selected").val();
// var data = {
// "id": id,
// "day": day
// };
// var url = BASE_PATH + "/sl/info/IsUp";
// MFW.AjaxUtil.syncPost(url, data, function (result) {
// if (result != null && result != undefined) {
// if (result) {
// var _alert = layer.alert("置顶成功!", function () {
// parent.layer.close(_alert);
// window.location.reload();
// });
// } else {
// layer.alert("置顶失败!");
// }
// } else {
// layer.alert("置顶失败!");
// }
// });
// }
// });
}