209 lines
8.0 KiB
Plaintext
209 lines
8.0 KiB
Plaintext
let form, laypage, layer, table, laydate, typeParam, titleName, orgList = getOrgSelect();
|
||
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10
|
||
function setParams(type) {
|
||
typeParam = type;
|
||
if (type === '1') {
|
||
titleName = '开工工程明细'
|
||
} else if (type === '2') {
|
||
titleName = '投产工程明细'
|
||
}
|
||
$('.title').find('p').html(titleName)
|
||
layui.use(['form', 'layer', 'table', 'laypage', 'laydate'], function () {
|
||
form = layui.form;
|
||
table = layui.table;
|
||
layer = layui.layer;
|
||
laypage = layui.laypage;
|
||
laydate = layui.laydate;
|
||
laydate.render({
|
||
elem: '#year', //指定元素 元素选择器
|
||
type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
|
||
trigger: 'click',
|
||
format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
|
||
btns: ['clear', 'now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定
|
||
done: function (value, date) { //时间回调
|
||
}
|
||
});
|
||
$('#year').val(getNowTime().substring(0, 4)+"-01-01")
|
||
setOrg();
|
||
layui.form.render();
|
||
pages(1, 10, 1);
|
||
})
|
||
}
|
||
|
||
function pages(pageNum, pageSize, typeNum) {
|
||
let params = getReqParams(pageNum, pageSize, typeNum);
|
||
$.ajax({
|
||
headers: {
|
||
"encrypt": sm3(JSON.stringify(params))
|
||
},
|
||
url: dataUrl + "proteam/pot/tysj/getProPlanList?token=" + token,
|
||
data: params,
|
||
type: 'POST',
|
||
async: false,
|
||
success: function (result) {
|
||
if (result.code === 200) {
|
||
if (result.data) {
|
||
console.log(result)
|
||
initTable(result.data, result.limit, result.curr,result.totalRow)
|
||
laypages(result.count, result.curr, result.limit)
|
||
$('#totalProNum').html(result.tj.prjName);
|
||
$('#lineLength').html(result.tj.lineLength);
|
||
$('#subCap').html(result.tj.subCap);
|
||
}
|
||
} else if (result.code === 500) {
|
||
layer.alert(result.msg, {icon: 2})
|
||
} else if (result.code === 401) {
|
||
logout(1);
|
||
}
|
||
}, error: function () {
|
||
}
|
||
});
|
||
}
|
||
|
||
function laypages(total, page, limit) {
|
||
laypage.render({
|
||
elem: 'voi-page',
|
||
count: total,
|
||
curr: page,
|
||
limit: limit,
|
||
limits: [10, 20, 50, 100, 200, 500],
|
||
layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
|
||
groups: 5,
|
||
jump: function (obj, first) {
|
||
if (!first) {
|
||
pageNum = obj.curr, limitSize = obj.limit;
|
||
pages(obj.curr, obj.limit, null);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
// 变电表格
|
||
function initTable(dataList, limit, page,totalRow) {
|
||
table.render({
|
||
elem: "#proTable",
|
||
id: "proTable",
|
||
height: "full-240",
|
||
data: dataList,
|
||
totalRow: totalRow,
|
||
limit: limit,
|
||
cols: [setTableCol(page, limit)],
|
||
done: function (res, curr, count) {
|
||
table.resize("proTable");
|
||
count || this.elem.next(".layui-table-view").find(".layui-table-header").css("display", "inline-block");
|
||
count || this.elem.next(".layui-table-view").find(".layui-table-box").css("overflow", "auto");
|
||
/* 处理total放在第一行 开始 */
|
||
var tableView = this.elem.next();
|
||
var fixedLeft = tableView.find(".layui-table-fixed.layui-table-fixed-l");
|
||
var fixedRight = tableView.find(".layui-table-fixed.layui-table-fixed-r");
|
||
var mainBox = tableView.find(".layui-table-box");
|
||
|
||
var totalElem = tableView.find(".layui-table-total:not(.layui-table-total-clone)"); // 找到原始的统计行
|
||
|
||
var totalLeft = totalElem.clone();
|
||
fixedLeft.find(".layui-table-total").remove();
|
||
totalLeft.find("th.layui-table-patch").remove(); // 左右固定列中不需要补丁
|
||
fixedLeft.children(".layui-table-header").after(totalLeft.addClass("layui-table-total-clone"));
|
||
totalLeft.find("td").each(function (index, item) {
|
||
if (!fixedLeft.children(".layui-table-header").find('th[data-key="' + item.dataset.key + '"]').length) {
|
||
item.remove();
|
||
}
|
||
});
|
||
|
||
var totalMain = totalElem;
|
||
if (!mainBox.children(".layui-table-header").next(".layui-table-total").length) {
|
||
// 已经移动了就不做处理
|
||
mainBox.children(".layui-table-header").after(totalMain.removeClass("layui-hide"));
|
||
}
|
||
var totalRight = totalElem.clone();
|
||
fixedRight.find(".layui-table-total").remove();
|
||
totalRight.find("th.layui-table-patch").remove();
|
||
fixedRight.children(".layui-table-header").after(totalRight.addClass("layui-table-total-clone"));
|
||
totalRight.find("td").each(function (index, item) {
|
||
if (!fixedRight.children(".layui-table-header").find('th[data-key="' + item.dataset.key + '"]').length) {
|
||
item.remove();
|
||
}
|
||
});
|
||
/* 处理total放在第一行 结束 */
|
||
},
|
||
});
|
||
}
|
||
|
||
function setTableCol(page, limit) {
|
||
let tableCol = [
|
||
{
|
||
title: "序号", width: 100, unresize: true, align: "center", totalRowText: '合计:', templet: function (d) {
|
||
return (page - 1) * limit + d.LAY_INDEX;
|
||
}
|
||
},
|
||
{field: "prjName", title: "项目名称", unresize: true, align: "center", totalRow: true},
|
||
{field: "voltage", title: "电压等级(千伏)", unresize: true, align: "center"},
|
||
{field: "subCap", title: "变电容量<br>(万千伏安)", unresize: true, align: "center", totalRow: true},
|
||
{field: "lineLength", title: "线路长度(千米)", unresize: true, align: "center", totalRow: true},
|
||
];
|
||
if (typeParam === '1') {
|
||
tableCol.push({field: "gwPlanCompDate", title: "开工完成时间", unresize: true, align: "center"})
|
||
tableCol.push({field: "startDate", title: "计划开工时间", unresize: true, align: "center"})
|
||
tableCol.push({field: "fineDate", title: "计划投产时间", unresize: true, align: "center"})
|
||
} else {
|
||
tableCol.push({field: "startDate", title: "投产完成时间", unresize: true, align: "center"})
|
||
tableCol.push({field: "fineDate", title: "计划投产时间", unresize: true, align: "center"})
|
||
}
|
||
return tableCol;
|
||
}
|
||
|
||
// 获取参数
|
||
function getReqParams(page, limit, type) {
|
||
let obj = {};
|
||
if (!type) {
|
||
obj = {
|
||
page: page + "",
|
||
limit: limit + "",
|
||
orgId: $('#buildCode').val(),
|
||
prjName: $('#proName').val(),
|
||
year: $('#year').val(),
|
||
// voltageLevel: $('#voltageLevel').val(),
|
||
type: typeParam
|
||
};
|
||
} else {
|
||
obj = {
|
||
page: '1',
|
||
limit: '10',
|
||
orgId: '',
|
||
prjName: '',
|
||
year: $('#year').val(),
|
||
// voltageLevel: '',
|
||
type: typeParam
|
||
};
|
||
}
|
||
return obj;
|
||
}
|
||
|
||
// 查询/重置
|
||
function query(type) {
|
||
let pattern = new RegExp("[%_<>]");
|
||
if (pattern.test($("#proName").val())) {
|
||
$("#proName").val('');
|
||
return layer.msg('工程名称查询包含特殊字符,请重新输入', {
|
||
icon: 2,
|
||
time: 2000 //2秒关闭(如果不配置,默认是3秒)
|
||
});
|
||
}
|
||
pages(1, limitSize, false);
|
||
}
|
||
|
||
/*建管单位赋值*/
|
||
function setOrg() {
|
||
let html = '<option value="">全部</option>';
|
||
$.each(orgList, function (index, item) {
|
||
html += '<option value="' + item.code + '">' + item.name + '</option>';
|
||
})
|
||
$('#buildCode').empty().append(html);
|
||
layui.form.render();
|
||
}
|
||
|
||
// 关闭页面
|
||
function closePage(type) {
|
||
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
|
||
parent.layer.close(index); //再执行关闭
|
||
} |