IntelligentRecognition/ah-jjsp-web/.svn/pristine/22/227088f30a289c0f131d1094fb0...

223 lines
7.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let form, laypage,layer, table, formSelects, orgList, chooseTypeParam,years; // chooseTypeParam 1.在建 2.在施 3.停工
let pageNum = 1, limitSize = 50; // 默认第一页分页数量为10
function setParams(chooseType, proStatus, proType,type) {
if(type==1){
var date=new Date();
years=date.getFullYear();
}else{
years="";
}
console.log(years);
$('#proType').val(proType);
chooseTypeParam = chooseType + '';
layui.config({
base: "../../../js/layui/", //此处路径请自行处理, 可以使用绝对路径
}).extend({
formSelects: 'formSelects-v4'
}).use(['form', 'layer', 'table', 'formSelects', 'laypage'], function () {
form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
table = layui.table;
layer = layui.layer;
formSelects = layui.formSelects;
laypage = layui.laypage; //分页
orgList = getOrgNumAndRate(1);
setOrg();
layui.form.render();
pages(1, 50, 1);
})
}
function pages(pageNum, pageSize, typeNum) {
let params = getReqParams(pageNum, pageSize, typeNum);
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + "proteam/pot/home/getProListByType?token=" + token,
data: params,
type: 'POST',
async: false,
success: function (result) {
if (result.code === 200) {
if (result.data) {
initTable(result.data, result.limit, result.curr)
laypages(result.count, result.curr, result.limit)
}
} 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: [30,50,100],
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) {
let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
table.render({
elem: "#proTable",
id: "proTable",
height: "full-220",
data: dataList,
limit: limit,
cols: [
[
//表头
{
title: "序号", width: 100, unresize: true, align: "center", templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{field: "yearDate", title: "年份", width: 120, unresize: true, align: "center",sort:true},
{field: "orgName", title: "建管单位", width: 120, unresize: true, align: "center",sort:true},
{field: "proName", title: "工程名称", unresize: true, align: "center",sort: true},
{field: "voltageLevel", title: "电压等级", unresize: true, align: "center",sort: true},
{field: "singType", title: "工程类型", unresize: true, align: "center",sort: true},
{field: "buildScale", title: "建设规模", unresize: true, align: "center",sort: true},
{field: "physicalQuantity", title: "实物量",width: 120, unresize: true, align: "center",sort: true},
{field: "kgTime", title: "开工时间", unresize: true, align: "center",sort: true},
{field: "tcTime", title: "投产时间", unresize: true, align: "center",sort: true}
],
],
done: function (res, curr, count) {
layer.close(loadingMsg);
$(".layui-laypage-skip").css("display", "none");
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");
let that = this.elem.next();
if (res.data) {
res.data.forEach(function (item, index) {
if (index % 2 === 0) {
let tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css('background-color', '#06182E')
} else {
let tr = that.find(".layui-table-box tbody tr[data-index='" + index + "']").css('background-color', '#1F2F43')
}
})
}
},
});
}
// 获取参数
function getReqParams(page, limit, type) {
let obj = {};
if (!type) {
obj = {
page: page + "",
limit: limit + "",
buildCode: formSelects.value('buildCode', 'val').toString(),
bidName: $("#bidName").val(),
proType: $("#proType").val(),
yearDate:years,
type: chooseTypeParam
};
} else {
obj = {
page: '1',
limit: '50',
buildCode: '',
bidName: '',
yearDate:years,
proType: $("#proType").val(),
type: chooseTypeParam
};
}
return obj;
}
// 查询/重置
function query(type) {
let pattern = new RegExp("[%_<>]");
if (pattern.test($("#bidName").val())) {
$("#bidName").val('');
return layer.msg('单项工程名称查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
if (type === 2) {
resetForm();
}
let buildCode = formSelects.value('buildCode', 'val');
orgList = getOrgNumAndRate();
setOrg();
formSelects.value('buildCode', buildCode)
pages(1, limitSize, false);
}
// 地市工程数量和占比
function getOrgNumAndRate(type) {
let dataList = [];
let params = getReqParams(null, null, type);
$.ajax({
url: dataUrl + 'proteam/pot/home/getOrgNumAndRateByProNew?token=' + token,
data: params,
headers: {
"encrypt": sm3(JSON.stringify(params))
},
type: 'POST',
async: false,
success: function (result) {
if (result.code === 200) {
let data = result.data;
if (data && data.length > 0) {
$.each(data, function (index, item) {
dataList.push(item)
})
}
} else if (result.code === 500) {
return layer.alert(result.msg, {icon: 2})
} else {
logout(1);
}
}, error: function () {
}
});
return dataList;
}
/*建管单位赋值*/
function setOrg() {
let keys = [];
$.each(orgList, function (index, item) {
let temp = {
// "name": item.name + "" + item.num + "" + item.rate + "",
"name": item.name,
"value": item.code,
"titleName": item.name
};
keys.push(temp);
})
formSelects.data('buildCode', 'local', {
arr: keys
});
layui.form.render();
}
// 关闭页面
function closePage(type) {
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
}