IntelligentRecognition/ah-jjsp-web/.svn/pristine/bf/bf0de9bdbab990f56e779a4bd1c...

279 lines
8.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let form, layer, table, tableIns, formSelects, voiTypeList,rate;
let pageNum = 1, limitSize = 10; // 默认第一页分页数量为10
let id,bidCodeParam;
function setParams(bidCode) {
bidCodeParam=bidCode;
console.log(bidCode);
layui.config({
base: "../../../js/layui/", //此处路径请自行处理, 可以使用绝对路径
}).extend({
formSelects: 'formSelects-v4'
}).use(['form','rate', 'layer', 'table', 'formSelects'], function () {
form = layui.form;
rate = layui.rate;
layer = layui.layer;
table = layui.table;
formSelects = layui.formSelects;
voiTypeList = getRiskLevelSelect('voi_category')
setVoiType();
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/newPro/getProWorkTeam?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: [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) {
tableIns = table.render({
elem: "#teamTable",
id: "teamTable",
height: "full-150",
data: dataList,
limit: limit,
cols: [
[
//表头
{title: "序号", width: '110', unresize: true, align: "center",
templet: function (d) {
return (page - 1) * limit + d.LAY_INDEX;
}
},
{field: "fzrName", title: "班组长", width: '350', unresize: true, align: "center", sort:true},
{field: "zhpj", title: "班组评价", width: '350', unresize: true, align: "center", sort:true,
templet: function (d) {
return '<div id="test' + d.LAY_TABLE_INDEX + '"></div>'
}},
{field: "status", title: "施工状态", width: '350', unresize: true, align: "center", sort:true,
templet: function (d) {
if(d.status=='01'){
return '正常';
}else if(d.status=='02'){
return '解散';
}else{
return '未施工';
}
}
},
{field: "phone", title: "班组长手机号", width: '350', unresize: true, align: "center", sort:true},
{field: "importTeam", title: "是否是重点关注班组", width: '350', unresize: true, align: "center", sort:true,
templet: function (d) {
if(d.importTeam=='1'){
return "<span style='color: red;cursor: pointer;'>" + 是+ "</span>";
}else{
return '否';
}
}
}
],
],
done: function (res, curr, count) {
table.resize("vioTypeTable");
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");
$(".layui-laypage-skip").css("display", "none");
data = res.data;
for (let i = 0; i < res.data.length; i++) {
rate.render({
elem: '#test' + i
, value: res.data[i].zhpj / 2
, readonly: true
, half: true,
theme: '#2F82FB'
});
table.render()
}
},
});
table.on("sort(teamTable)", function (obj) {
for (let i = 0; i < data.length; i++) {
rate.render({
elem: '#test' + i
, value: data[i].zhpj / 2
, readonly: true
, half: true,
theme: '#2F82FB'
});
table.render()
}
});
}
// 获取参数
function getReqParams(page, limit, type) {
let obj = {};
if (!type) {
obj = {
page: page + "",
limit: limit + "",
keyWord:$("#keyWord").val(),
bidCode:bidCodeParam
};
} else {
obj = {
page: '1',
limit: '10',
keyWord:$("#keyWord").val(),
bidCode:bidCodeParam
};
}
return obj;
}
// 查询/重置
function query() {
pageNum = 1;
pages(1, limitSize)
}
/*新增违章类别*/
function addVioType(id) {
let title = '新增违章类别';
if (id) {
title = '修改违章类别';
}
let layerIndex = parent.layer.open({
id: "addVioTypes",
title: ['<div style="border-left: 3px solid #2F82FB;display: flex;align-items: center;height: 20px;padding: 0 10px;">' + title + '</div>', 'font-size:16px;background-color:#f0f0f0;display: flex;align-items: center;'],
type: 2,
maxmin: false,
content: '../dutyTask/vioType/vioTypeForm.html',
area: ['664px', '444px'],
move: false,
success: function (layero, index) {
let iframeWin = parent.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({
params:id
}))
},
url: dataUrl + 'proteam/pot/superStatistics/delVoiTypeById?token=' + token,
data: {
params: id,
},
type: 'post',
async: true,
success: function (result) {
layer.close(loadingMsg); // 关闭提示层
if (result.code === 200) {
layer.msg('删除成功', {icon: 1})
voiTypeList = getRiskLevelSelect('voi_category')
setVoiType();
query()
} 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 vioBasis(id) {
let layerIndex = parent.layer.open({
id: "vioBasis",
title: false,
type: 2,
maxmin: false,
content: '../dutyTask/vioType/vioBasis.html',
area: ['100%', '100%'],
move: false,
closeBtn: false,
success: function (layero, index) {
let iframeWin = parent.window["layui-layer-iframe" + layerIndex];
iframeWin.setParams(id);
}
});
}
/*刷新页面数据*/
function reloadData() {
voiTypeList = getRiskLevelSelect('voi_category')
setVoiType();
pages(pageNum, limitSize);
}
/* 违章类别赋值 */
function setVoiType() {
let keys = [];
$.each(voiTypeList, function (index, item) {
let temp = {
"name": item.name,
"value": item.code
};
keys.push(temp);
})
formSelects.data('code', 'local', {
arr: keys
});
layui.form.render();
}
// 关闭页面
function closePage() {
let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引
parent.layer.close(index); //再执行关闭
}