cc-jjsp-web/bns/js/dutyTask/externalPro.js

200 lines
6.2 KiB
JavaScript
Raw Normal View History

2025-09-23 09:28:02 +08:00
let form, layer, table, tableIns;
let pageNum = 1, limitSize = 20; // 默认第一页分页数量为20
layui.use(['form', 'layer', 'table'], function () {
form = layui.form;
layer = layui.layer;
table = layui.table;
pages(1, 20, 1);
})
function pages(pageNum, pageSize, typeNum) {
let params = getReqParams(pageNum, pageSize, typeNum);
$.ajax({
url: dataUrl + "proteam/pot/externalPro/getExternalPros?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) {
layui.use(['laypage'], function () {
let laypage = layui.laypage;
laypage.render({
elem: 'voi-page',
count: total,
curr: page,
limit: limit,
limits: [20, 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, });
tableIns = table.render({
id: 'todayTaskTable',
elem: "#todayTaskTable",
height: "full-150",
data: dataList,
cols: [
[
//表头
{
title: "序号",
width: '8%',
unresize: true,
align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_NUM;
}
},
{
field: "proName",
title: "工程名称",
width: '30%',
unresize: false,
align: "center",
},
{
field: "workManager",
title: "班组长",
width: '20%',
unresize: false,
align: "center",
},
{
field: "sgUnit",
title: "施工单位",
width: '20%',
unresize: false,
align: "center",
},
{
title: "视频监控",
width: '12%',
unresize: false,
align: "center",
templet: function (d) {
let html = '';
if (d.dataList) {
$.each(d.dataList, function (index, item) {
if (item.online === '1') {
html += '<img src="../../img/common-icon/ball-online.png">'
} else {
html += '<img src="../../img/common-icon/ball-offline.png">'
}
});
}
return html;
}
},
{
title: "操作",
width: '10%',
unresize: false,
align: "center",
templet: function (d) {
return "<a onclick='addData(" + JSON.stringify(d) + ",2)'>修改</a><div>|</div>" +
"<a onclick=\"delData('" + d.id + '\')" style="color:#EB3330;">删除</a>';
}
},
],
],
limit: limit,
done: function (res, curr, count) {
layer.close(loadingMsg);
},
});
table.on('rowDouble(todayTaskTable)', function (obj) {
openIframeByParamObj5("operExternalPro", false, "externalProView.html", "100%", "100%", obj.data);
});
}
// 获取参数
function getReqParams(page, limit, type) {
let obj = {};
if (!type) {
obj = {
page: page + "",
limit: limit + "",
sgUnit: $('#sgUnit').val(),
workManager: $('#workManager').val(),
proName: $('#proName').val(),
};
} else {
obj = {
page: 1,
limit: limit,
sgUnit: $('#sgUnit').val(),
workManager: $('#workManager').val(),
proName: $('#proName').val(),
};
}
return obj;
}
// 查询
function query() {
pages(1, limitSize);
}
// 新增/修改 系统外工程
function addData(params, type) {
let title = '';
if (type === 1) {
title = '新增'
params = {};
} else {
title = '修改';
}
openIframeByParamObj("operExternalPro", title, "externalProForm.html", "42%", "70%", params);
}
// 删除数据
function delData(id) {
layer.confirm('确定删除吗此条数据吗?', function () {
let loadingMsg = layer.msg('正在删除,请稍等...', { icon: 16, shade: 0.01, time: '0' });
let url = dataUrl + "proteam/pot/externalPro/delData";
let params = { id: id };
ajaxRequest2(url, "POST", params, true, function (result) {
layer.close(loadingMsg); // 关闭提示层
if (result.code === 200) {
parent.layer.msg(result.msg, { icon: 1 })
query(1);
} else {
layer.msg(result.msg, { icon: 2 })
}
}, function (xhr) {
layer.close(loadingMsg); // 关闭提示层
error(xhr)
}, null, token);
})
}