IntelligentRecognition/ah-jjsp-web/.svn/pristine/33/33343211857cba31a9365f46f8b...

462 lines
15 KiB
Plaintext
Raw Permalink Normal View History

2024-05-24 16:09:40 +08:00
let form, layer, table, laypage, laydate;
let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为
layui.use(['form', 'layer', 'table', 'laypage', 'laydate'], function () {
form = layui.form;
table = layui.table;
laypage = layui.laypage;
layer = layui.layer;
laydate = layui.laydate;
laydate.render({
elem: '#years', //指定元素 元素选择器
type: 'year', //选择时间类型 可选值:year(年) month(年月) date(年月日) time(时分秒) datetime(年月日时分秒)
trigger: 'click',
format: 'yyyy', //时间格式 常用时间格式:yyyy-MM-dd HH:mm:ss
btns: ['clear', 'now', 'confirm'], //选择框右下角显示的按钮 清除-现在-确定
done: function (value, date) { //时间回调
}
});
layui.form.render();
pages(1, 10, 1);
})
function reloadData() {
pages(1, limitSize);
}
function pages(pageNum, pageSize, typeNum) {
let params = getReqParams(pageNum, pageSize, typeNum);
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify(params))
},
url: dataUrl + "proteam/pot/tysj/getSjNumList?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: [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: "#table",
id: "table",
height: "full-160",
data: dataList,
limit: limit,
cols: [
[
{
type: 'checkbox',
unresize: true,
width: 60,
align: "center",
},
//表头
{
title: "序号", width: 100, unresize: true, align: "center", templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{
field: "org",
title: "省公司",
unresize: true,
width: 120,
align: "center",
},
{
field: "proName",
title: "输变电工程名称",
unresize: true,
width: 200,
align: "center",
},
{
field: "signName",
title: "单项工程名称",
unresize: true,
width: 200,
align: "center",
},
{
field: "voltage",
title: "输变电工程电压等级(kV)",
unresize: true,
width: 200,
align: "center",
},
{
field: "proType",
title: "工程类型",
unresize: true,
width: 200,
align: "center",
},
{
field: "sjUnit",
title: "设计单位",
unresize: true,
width: 200,
align: "center",
},
{
field: "psUnit",
title: "评审单位",
unresize: true,
width: 200,
align: "center",
},
{
field: "psYjTime",
title: "评审意见印发时间",
unresize: true,
width: 200,
align: "center",
},
{
field: "isSjzlQ",
title: "是否发生设计质量问题",
unresize: true,
width: 200,
align: "center",
},
{
field: "isQ",
title: "是否问题库内问题",
unresize: true,
width: 200,
align: "center",
},
{
field: "sjzlQName",
title: "设计质量问题名称",
unresize: true,
width: 200,
align: "center",
},
{
field: "wtkNum",
title: "问题库编号",
unresize: true,
width: 200,
align: "center",
},
{
field: "wtType",
title: "问题类别",
unresize: true,
width: 200,
align: "center",
},
{
field: "wtXz",
title: "问题性质",
unresize: true,
width: 200,
align: "center",
},
{
field: "sjjd",
title: "设计阶段",
unresize: true,
width: 200,
align: "center",
},
{
field: "sszy",
title: "所属专业",
unresize: true,
width: 200,
align: "center",
},
{
field: "sfzg",
title: "是否整改",
unresize: true,
width: 200,
align: "center",
},
{
field: "wtjs",
title: "问题简述",
unresize: true,
width: 200,
align: "center",
templet: function (d) {
if (d.wtjs) {
if (d.wtjs.length > 60) {
return '<span title="' + d.wtjs + '">' + d.wtjs.substring(0, 60) + '...</span>'
} else {
return '<span title="' + d.wtjs + '">' + d.wtjs + '</span>'
}
} else {
return '';
}
}
},
{
title: "问题分析",
unresize: true,
width: 200,
align: "center",
templet: function (d) {
if (d.wtfx) {
if (d.wtfx.length > 60) {
return '<span title="' + d.wtfx + '">' + d.wtfx.substring(0, 60) + '...</span>'
} else {
return '<span title="' + d.wtfx + '">' + d.wtfx + '</span>'
}
} else {
return '';
}
}
},
{
field: "jycqcs",
title: "建议采取措施",
unresize: true,
width: 200,
align: "center",
templet: function (d) {
if (d.jycqcs) {
if (d.jycqcs.length > 60) {
return '<span title="' + d.jycqcs + '">' + d.jycqcs.substring(0, 60) + '...</span>'
} else {
return '<span title="' + d.jycqcs + '">' + d.jycqcs + '</span>'
}
} else {
return '';
}
}
},
{
title: "操作",
width: 180,
unresize: true,
align: "center",
templet: function (d) {
let html = '';
html += "<a style='color: #fff;font-size: 13px;' onclick=\"editData('" + d.id + "')\">修改</a>" +
"<div>|</div><a style='color: #fff;font-size: 13px;' onclick=\"delData('" + d.id + "')\">删除</a>";
return html;
}
},
],
],
done: function (res, curr, count) {
table.resize("table");
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 + "",
keyWord: $('#keyWord').val(),
isSjzlQ: $('#isSjzlQ').val()
};
} else {
obj = {
page: '1',
limit: '10',
keyWord: '',
isSjzlQ: ''
};
}
return obj;
}
// 查询
function query(type) {
let pattern = new RegExp("[%_<>]");
if (pattern.test($("#keyWord").val())) {
$("#keyWord").val('');
return layer.msg('关键字查询包含特殊字符,请重新输入', {
icon: 2,
time: 2000 //2秒关闭如果不配置默认是3秒
});
}
pages(1, limitSize)
}
// 关闭页面
function closePage(type) {
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
}
/*新增*/
function addData() {
let id = "";
let layerIndex = layer.open({
id: "addVio",
title: false,
type: 2,
maxmin: false,
skin: "my-skin child-skin",
content: 'designProblemForm.html',
area: ["860px", "564px"],
shade: 0,
closeBtn: 0,
success: function (layero, index) {
let iframeWin = window["layui-layer-iframe" + layerIndex];
iframeWin.setParams(id);
}
});
}
/*修改*/
function editData(id) {
let layerIndex = layer.open({
id: "editVio",
title: false,
type: 2,
maxmin: false,
skin: "my-skin child-skin",
content: 'designProblemForm.html',
area: ["860px", "564px"],
shade: 0,
closeBtn: 0,
success: function (layero, index) {
let iframeWin = window["layui-layer-iframe" + layerIndex];
iframeWin.setParams(id);
}
});
}
/*删除*/
function delData(id) {
layer.confirm("确定删除吗?", function () {
let loadingMsg = layer.msg('数据删除中,请稍候...', {icon: 16, scrollbar: false, time: 0});
$.ajax({
headers: {
"encrypt": sm3(JSON.stringify({
id: id
}))
},
url: dataUrl + 'proteam/pot/tysj/deleteSjNum?token=' + token,
data: {
id: id,
},
type: 'post',
async: true,
success: function (result) {
console.log(result)
layer.close(loadingMsg); // 关闭提示层
if (result.code === '200') {
layer.msg('删除成功', {icon: 1})
pages(1, 20);
top.reloadHomeData(2);
} else if (result.code === '500') {
layer.alert(result.msg, {icon: 2})
} else if (result.code === 401) {
logout(1)
}
}, error: function () {
layer.close(loadingMsg); // 关闭提示层
layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
}
});
})
}
/*设计问题数数据模板下载*/
function modelDownLoad() {
let loadingMsg = layer.msg('模板下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
let url = dataUrl + 'proteam/pot/tysj/downloadExcel?token=' + token;
let xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader("encrypt",
sm3(JSON.stringify({})));
xhr.onload = function () {
layer.close(loadingMsg); // 关闭提示层
if (this.status === 200) {
let blob = this.response;
var a = document.createElement("a");
var url = window.URL.createObjectURL(blob);
a.href = url;
a.download = "设计问题数-导入模板.xlsx"; // 文件名
} else {
layer.msg('服务异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
}
a.click()
window.URL.revokeObjectURL(url)
};
xhr.send();
}
/*设计问题数数据导入*/
function chooseFile() {
$("#import-excel").trigger("click");
}
$("#import-excel").change(function () {
if ($(this).val()) {
let files = $(this)[0].files[0];
let fileType = files.name.substring(
files.name.lastIndexOf(".") + 1,
files.name.length
);
if (fileType === "xlsx" || fileType === "xls") {
excelUpload4(this, dataUrl + "proteam/pot/tysj/importExcel?token=" + token)
} else {
layer.msg("仅支持上传文件格式为xlx、xlsx", {icon: 5,});
$("#import-excel").val("");
}
}
});
// 批量删除
function batchDel() {
let selectData = layui.table.checkStatus('table').data;
let idList = [];
if (selectData.length > 0) {
$.each(selectData,function (index,item){
idList.push(item.id);
})
delData(idList.toString().replaceAll(',','@'));
} else {
return layer.msg('请选择要删除的数据', {icon: 7, time: 2000})
}
}