218 lines
9.7 KiB
JavaScript
218 lines
9.7 KiB
JavaScript
let table, form, layer, util,laydate
|
||
let pageNum = 1, limitSize = 30; // 默认第一页,分页数量为10
|
||
$(function () {
|
||
layui.config({
|
||
base: "../../js/layui/", //此处路径请自行处理, 可以使用绝对路径
|
||
}).use(['layer', 'form', 'table', 'util','laydate'], function () {
|
||
layer = layui.layer;
|
||
form = layui.form;
|
||
// laydate = layui.laydate;
|
||
table = layui.table;
|
||
util = layui.util;
|
||
laydate = layui.laydate;
|
||
form.render();
|
||
util.event('lay-active', {
|
||
query: function () {
|
||
pages(1, limitSize);
|
||
},
|
||
reset: function () {
|
||
$('#keyWord').val('');
|
||
$('#betweenTimeCreate').val('');
|
||
$('#betweenTimeUpdate').val('');
|
||
form.render();
|
||
pages(1, limitSize);
|
||
},
|
||
export: function () {
|
||
exportData();
|
||
}
|
||
});
|
||
laydate.render({
|
||
elem: '#betweenTimeCreate',//指定元素 元素选择器
|
||
type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
|
||
trigger: 'click',
|
||
range: true,
|
||
format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
|
||
// btns: ['now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定
|
||
});
|
||
|
||
laydate.render({
|
||
elem: '#betweenTimeUpdate',//指定元素 元素选择器
|
||
type: 'date', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
|
||
trigger: 'click',
|
||
range: true,
|
||
format: 'yyyy-MM-dd', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
|
||
// btns: ['now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定
|
||
});
|
||
|
||
pages(1, 30, 1);
|
||
table.on("rowDouble(classTable)", function (res) {
|
||
let obj = res.data;
|
||
});
|
||
});
|
||
});
|
||
|
||
function pages(pageNum, pageSize) {
|
||
let params = getReqParams(pageNum, pageSize);
|
||
$.ajax({
|
||
headers: {
|
||
"encrypt": sm3(JSON.stringify(params))
|
||
},
|
||
url: dataUrl + "proteam/query/queryManage/getUnitList" + '?token=' + token,
|
||
data: params,
|
||
type: 'POST',
|
||
async: false,
|
||
success: function (result) {
|
||
console.log(result);
|
||
if (result.code === 200) {
|
||
if (result.data) {
|
||
initTable(result.data, limitSize, pageNum)
|
||
laypages(result.count, pageNum, limitSize)
|
||
}
|
||
} 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) {
|
||
layui.use(['laypage'], function () {
|
||
let laypage = layui.laypage;
|
||
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) {
|
||
console.log(dataList);
|
||
table.render({
|
||
elem: "#classTable",
|
||
id: "classTable",
|
||
height: "full-250",
|
||
data: dataList,
|
||
cols: [
|
||
[//表头
|
||
{
|
||
title: "序号",
|
||
width: 100,
|
||
unresize: true,
|
||
align: "center",
|
||
templet: function (d) {
|
||
return (page - 1) * limit + d.LAY_INDEX;
|
||
}
|
||
},
|
||
|
||
{field: "id",title: "id",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "legalReprMobile",title: "法定代表人手机号",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "contactPhone",title: "联系方式",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "unitType",title: "单位类型",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "unitNature",title: "单位性质",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "sysType",title: "系统类型",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "sysCateg",title: "系统分类",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "unitSign",title: "单位标识",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "establishmentDate",title: "成立日期",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "registerCapital",title: "注册资本",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "website",title: "企业网站",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "iscUnitId",title: "基建id",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "province",title: "所在省",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "city",title: "所在市",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "county",title: "所在县",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "address",title: "单位地址",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "mainBusiness",title: "经营范围",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "dataSource",title: "数据来源",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "huvFlag",title: "工程类型",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "provinceCode",title: "网省编码",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "buildUnitCode",title: "建设管理单位编码",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "safetySgcUnitId",title: "安监id",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field:"createrId",title:"创建人id",unresize:false,minWidth:120,sort:true,align:"center"},
|
||
{field:"createTime",title:"创建时间",unresize:false,minWidth:120,sort:true,align:"center"},
|
||
{field:"updaterId",title:"修改人id",unresize:false,minWidth:120,sort:true,align:"center"},
|
||
{field:"updateTime",title:"修改时间",unresize:false,minWidth:120,sort:true,align:"center"},
|
||
{field:"deleteFlag",title:"删除状态",unresize:false,minWidth:120,sort:true,align:"center"},
|
||
{field: "legalIdCard",title: "法人身份证号",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "businessFileId",title: "营业执照照片id",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "unitName",title: "单位全称",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "unitAbbrName",title: "单位简称",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "unitCode",title: "单位编码",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "mainCode",title: "主数据单位编码",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "unifiedSocialCreditId",title: "统一社会信用代码",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
{field: "legalRepr",title: "法定代表人",unresize: false,minWidth: 120,sort: true,align: "center"},
|
||
|
||
],
|
||
],
|
||
limit: limit,
|
||
done: function (res, curr, count) {
|
||
$(".layui-laypage-skip").css("display", "none");
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
// 获取参数
|
||
function getReqParams(page, limit) {
|
||
let obj = {};
|
||
obj = {
|
||
page: page + "",
|
||
limit: limit + "",
|
||
keyWord:$("#keyWord").val(),
|
||
betweenTimeCreate:$("#betweenTimeCreate").val(),
|
||
betweenTimeUpdate:$("#betweenTimeUpdate").val(),
|
||
};
|
||
return obj;
|
||
|
||
}
|
||
|
||
//导出
|
||
function exportData() {
|
||
let loadingMsg = layer.msg("数据导出中,请稍候...", {icon: 16, scrollbar: false, time: 0,});
|
||
let url = dataUrl + "proteam/query/queryManage/exportUnit?" + setData(getReqParams(1, 1000000)) + '&token='+token;
|
||
let xhr = new XMLHttpRequest();
|
||
let a = document.createElement("a");
|
||
xhr.open("get", url, true);
|
||
xhr.responseType = "blob"; // 转换流
|
||
xhr.setRequestHeader("encrypt",
|
||
sm3(JSON.stringify(
|
||
getReqParams(pageNum, limitSize)
|
||
)));
|
||
xhr.setRequestHeader('encryption','encryption');
|
||
xhr.setRequestHeader('token',token);
|
||
xhr.onload = function () {
|
||
layer.close(loadingMsg);
|
||
if (this.status === 200) {
|
||
let url = window.URL.createObjectURL(new Blob([this.response]))
|
||
let link = document.createElement('a')
|
||
link.style.display = 'none'
|
||
link.href = url
|
||
link.setAttribute('download', "基建单位统计.xlsx")
|
||
document.body.appendChild(link)
|
||
link.click()
|
||
// 释放URL对象所占资源
|
||
window.URL.revokeObjectURL(url)
|
||
// 用完即删
|
||
document.body.removeChild(link)
|
||
} else {
|
||
layer.msg("数据发生异常,请稍后重试", {icon: 16, scrollbar: false, time: 2000});
|
||
}
|
||
};
|
||
xhr.send();
|
||
}
|
||
|
||
|
||
|