149 lines
4.7 KiB
Plaintext
149 lines
4.7 KiB
Plaintext
let form, laypage, layer, table, typeParam, proTypeParam, orgList = getOrgSelect();
|
||
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10
|
||
|
||
function setParams(type, proType) { // type 1 在建 2 在施 3 停工
|
||
typeParam = type;
|
||
proTypeParam = proType;
|
||
console.log(typeParam)
|
||
console.log(proTypeParam)
|
||
layui.use(['form', 'layer', 'table', 'laypage'], function () {
|
||
form = layui.form;
|
||
table = layui.table;
|
||
layer = layui.layer;
|
||
laypage = layui.laypage; //分页
|
||
$('#proType').val(proTypeParam)
|
||
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/getProListByType?token=" + token,
|
||
data: params,
|
||
type: 'POST',
|
||
async: false,
|
||
success: function (result) {
|
||
console.log(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: [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) {
|
||
table.render({
|
||
elem: "#proTable",
|
||
id: "proTable",
|
||
height: "full-200",
|
||
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"},
|
||
{field: "bidName", title: "工程名称", unresize: true, align: "center"},
|
||
{field: "proType", title: "工程类型", width: 120, unresize: true, align: "center"},
|
||
{field: "jlUnit", title: "监理单位", width: 120, unresize: true, align: "center"},
|
||
{field: "workUnit", title: "施工单位", unresize: true, align: "center"}
|
||
],
|
||
],
|
||
done: function (res, curr, count) {
|
||
$(".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");
|
||
},
|
||
});
|
||
}
|
||
|
||
// 获取参数
|
||
function getReqParams(page, limit, type) {
|
||
let obj = {};
|
||
if (!type) {
|
||
obj = {
|
||
page: page + "",
|
||
limit: limit + "",
|
||
buildCode: $('#buildCode').val(),
|
||
bidName: $('#bidName').val(),
|
||
proType: $('#proType').val(),
|
||
type: typeParam
|
||
};
|
||
} else {
|
||
obj = {
|
||
page: '1',
|
||
limit: '10',
|
||
buildCode: '',
|
||
bidName: '',
|
||
proType: proTypeParam,
|
||
type: typeParam
|
||
};
|
||
}
|
||
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秒)
|
||
});
|
||
}
|
||
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); //再执行关闭
|
||
} |