209 lines
6.9 KiB
Plaintext
209 lines
6.9 KiB
Plaintext
let form, laypage,layer, table, formSelects, orgList, chooseTypeParam; // chooseTypeParam 1.在建 2.在施 3.停工
|
||
let pageNum = 1, limitSize = 50; // 默认第一页,分页数量为10
|
||
function setParams(chooseType, proStatus, proType) {
|
||
$('#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: "buildUnit", title: "建管单位", width: 120, unresize: true, align: "center",sort:true},
|
||
{field: "bidName", title: "单项工程名称", unresize: true, align: "center",sort: true},
|
||
{field: "proType", title: "工程类型",width: 120, unresize: true, align: "center",sort: true},
|
||
{field: "jlUnit", title: "监理单位", unresize: true, align: "center",sort: true},
|
||
{field: "workUnit", 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(),
|
||
type: chooseTypeParam
|
||
};
|
||
} else {
|
||
obj = {
|
||
page: '1',
|
||
limit: '50',
|
||
buildCode: '',
|
||
bidName: '',
|
||
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/getOrgNumAndRateByPro?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 + ")",
|
||
"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); //再执行关闭
|
||
} |