249 lines
9.7 KiB
JavaScript
249 lines
9.7 KiB
JavaScript
layui.config({
|
||
base: '../../js/layuiModules/', // 第三方模块所在目录
|
||
version: 'v1.6.4' // 插件版本号
|
||
}).extend({
|
||
soulTable: 'notice,layNotify', // 模块
|
||
});
|
||
let form;
|
||
var tree;
|
||
var table;
|
||
var notice;
|
||
var layNotify;
|
||
const token = localStorage.getItem("czl-token");
|
||
$("#resetBt").click(function(){
|
||
table.reload('menuTable', {
|
||
url: czl_ht_url + '/owmTeamQuery/getowmTeamQueryTeamsList'
|
||
, method: 'post' //方式默认是get
|
||
, page: true
|
||
, where: {
|
||
keyWord: "",
|
||
status: "",
|
||
branchId: "",
|
||
} //设定异步数据接口的额外参数
|
||
});
|
||
$("#keyWord").val("");
|
||
$("#statusId").val("");
|
||
getOrgName(form,"");
|
||
})
|
||
$("#searchBt").click(function(){
|
||
table.reload('menuTable', {
|
||
url: czl_ht_url + '/owmTeamQuery/getowmTeamQueryTeamsList'
|
||
, method: 'post' //方式默认是get
|
||
, page: true
|
||
, where: {
|
||
keyWord: $("#keyWord").val(),
|
||
status: $("#statusId").val(),
|
||
branchId: $("#orgId").val(),
|
||
} //设定异步数据接口的额外参数
|
||
});
|
||
})
|
||
$("#bindBt").click(function(){
|
||
layerOpenViewForSencond("班组工程绑定","./teamEngineerBindForm.html");
|
||
})
|
||
$("#exportBt").click(function(){
|
||
keyWord = $("#keyWord").val();
|
||
status = $("#statusId").val();
|
||
branchId = $("#orgId").val();
|
||
window.location.href = czl_ht_url + "/owmTeamQuery/exportPhysicalCheckResult?"
|
||
+"keyWord=" + keyWord
|
||
+ "&status=" + status
|
||
+ "&branchId=" + branchId
|
||
+ "&type=" + '1'
|
||
+ "&token=" + token; //下载文件
|
||
})
|
||
|
||
layui.use(['table', 'form','notice', 'layNotify'], function () {
|
||
table = layui.table;
|
||
form = layui.form;
|
||
tree = layui.tree;
|
||
notice = layui.notice;
|
||
layNotify = layui.layNotify;
|
||
//渲染表格
|
||
table.render({
|
||
elem: '#demo'
|
||
, url: czl_ht_url + '/owmTeamQuery/getowmTeamQueryTeamsList' //数据接口
|
||
|
||
, method: 'post' //方式默认是get
|
||
, toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
|
||
, where: {} //post请求必须加where ,post请求需要的参数
|
||
, cellMinWidth: 80
|
||
, cols: [[ //表头
|
||
{
|
||
field: 'number', width:80,title: '序号', align: 'center', type: 'numbers'
|
||
}
|
||
, {field: 'orgName', align: 'center', title: '分公司'}
|
||
, {field: 'ownOrgName', align: 'center', title: '班组名称'}
|
||
, {field: 'ownTeamType', align: 'center', title: '班组名称'}
|
||
// , {
|
||
// field: 'ownTeamType', align: 'center', title: '工序', templet: d => {
|
||
// if (d.ownTeamType === "1") {
|
||
// return "基础";
|
||
// } else if (d.ownTeamType === "2") {
|
||
// return "杆塔";
|
||
// } else if (d.ownTeamType === "3") {
|
||
// return "架线";
|
||
// }
|
||
// }
|
||
// }
|
||
, {
|
||
field: 'ownTeamNum', title: '团队人数', align: 'center', templet: d => {
|
||
return text ="<span style='color: blue;cursor:pointer;' onclick='openTeamForm(\"" + d.id +"\",\"" + d.teamTypeId +"\",\"" + d.voltageLevelId +"\",\"" + d.teamName +"\")'>"+d.ownTeamNum+"</span>";
|
||
}
|
||
}
|
||
, {
|
||
field: 'ownTeamStatus', title: '状态', align: 'center', templet: d => {
|
||
let text = "";
|
||
if (d.ownTeamStatus === "1") {
|
||
text = "<span class='layui-badge-dot layui-bg-green'></span>已投入";
|
||
} else if (d.ownTeamStatus === "0") {
|
||
text = "<span class='layui-badge-dot'></span>闲置中";
|
||
}
|
||
return text;
|
||
}
|
||
}
|
||
, {
|
||
field: 'proName', title: '所属项目', align: 'center', templet: d => {
|
||
if (isEmpty(d.proName) && (d.orgName != '' && d.orgName != null)) {
|
||
console.log(d.ownOrgId)
|
||
return "<span style='color: blue;cursor:pointer;' onclick='openForm()'>去绑定工程</span>";
|
||
}else if (d.orgName == '' || d.orgName == null)
|
||
{
|
||
return " ";
|
||
}else {
|
||
return d.proName;
|
||
}
|
||
}
|
||
}
|
||
, {field: 'bindPerson', align: 'center', title: '分配人'}
|
||
, {field: 'bindTime', align: 'center', title: '分配时间'}
|
||
]]
|
||
, id: 'menuTable'
|
||
, page: true //开启分页
|
||
, loading: true //数据加载中。。。
|
||
, limits: [5, 10, 20] //一页选择显示3,5或10条数据
|
||
, limit: 10 //一页显示5条数据
|
||
, response: {
|
||
statusCode: 200 //规定成功的状态码,默认:0
|
||
}, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据,res为从url中get到的数据
|
||
let result;
|
||
if (res.data !== '' && res.data != null && res.data !== "null") {
|
||
if (this.page.curr) {
|
||
result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
|
||
} else {
|
||
result = res.data.slice(0, this.limit);
|
||
}
|
||
}
|
||
return {
|
||
"code": res.code, //解析接口状态
|
||
"msg": res.msg, //解析提示文本
|
||
"count": res.count, //解析数据长度
|
||
"data": result, //解析数据列表
|
||
};
|
||
},
|
||
toolbar: "#toolbar"
|
||
});
|
||
|
||
// 单元格编辑事件
|
||
table.on('edit(test)', function (obj) {
|
||
var field = obj.field; // 得到字段
|
||
var value = obj.value; // 得到修改后的值
|
||
var oldValue = obj.oldValue;
|
||
var data = obj.data; // 得到所在行所有键值
|
||
var update = {};
|
||
|
||
// 值的校验
|
||
if (field === 'idNumber') {
|
||
if (value.length != 18) {
|
||
update[field] = oldValue;
|
||
obj.update(update);
|
||
layer.tips('输入的身份证不正确,请重新编辑', this, {tips: 1});
|
||
return obj.reedit(); // 重新编辑 -- v2.8.0 新增
|
||
} else {
|
||
update[field] = value;
|
||
obj.update(update);
|
||
}
|
||
}
|
||
// 编辑后续操作,如提交更新请求,以完成真实的数据更新
|
||
// …
|
||
layer.msg('编辑成功', {icon: 1});
|
||
});
|
||
getOrgName(form,null);
|
||
});
|
||
|
||
function openTeamForm(id,teamTypeId,voltageLevelId,teamName){
|
||
localStorage.setItem('id',id);
|
||
localStorage.setItem('teamTypeId',teamTypeId);
|
||
localStorage.setItem('voltageLevelId',voltageLevelId);
|
||
localStorage.setItem('teamName',teamName);
|
||
layerOpenFormTeamMember("团队成员","./FreeInQuiryForm.html");
|
||
}
|
||
|
||
function openForm(){
|
||
layerOpenViewForSencond("班组工程绑定","./teamEngineerBindForm.html");
|
||
}
|
||
|
||
/**
|
||
* 合并行方法
|
||
**/
|
||
function merge(res) {
|
||
var data = res.data;
|
||
var mergeIndex = 0;//定位需要添加合并属性的行数
|
||
var mark = 1; //这里涉及到简单的运算,mark是计算每次需要合并的格子数
|
||
var columsName = ['postName'];//需要合并的列名称 ['business_tenant_name','land','contract_begin','contract_end','history_arrears','period'];
|
||
var columsIndex = [0];//需要合并的列索引值 [2,3,5,6,14,15];
|
||
for (var k = 0; k < columsName.length; k++) { //这里循环所有要合并的列
|
||
var trArr = $(".layui-table-body>.layui-table").find("tr");//所有行
|
||
for (var i = 1; i < res.data.length; i++) { //这里循环表格当前的数据
|
||
var tdCurArr = trArr.eq(i).find("td").eq(columsIndex[k]);//获取当前行的当前列
|
||
var tdPreArr = trArr.eq(mergeIndex).find("td").eq(columsIndex[k]);//获取相同列的第一列
|
||
if (data[i][columsName[0]] === data[i - 1][columsName[0]]) {
|
||
layui.hint().error(i);
|
||
if (data[i][columsName[k]] === data[i - 1][columsName[k]]) { //后一行的值与前一行的值做比较,相同就需要合并
|
||
mark += 1;
|
||
tdPreArr.each(function () {//相同列的第一列增加rowspan属性
|
||
$(this).attr("rowspan", mark);
|
||
});
|
||
tdCurArr.each(function () {//当前行隐藏
|
||
$(this).css("display", "none");
|
||
});
|
||
}
|
||
} else {
|
||
mergeIndex = i;
|
||
mark = 1;//一旦前后两行的值不一样了,那么需要合并的格子数mark就需要重新计算
|
||
}
|
||
}
|
||
mergeIndex = 0;
|
||
mark = 1;
|
||
}
|
||
|
||
}
|
||
|
||
function ajaxCommonMethod(url,data,success,error){
|
||
$.ajax({
|
||
type: 'POST',
|
||
async: false, // 默认异步true,false表示同步
|
||
url: czl_ht_url + url,// 请求地址
|
||
contentType: "application/x-www-form-urlencoded",
|
||
dataType: 'json', // 服务器返回数据类型
|
||
data: data, //获取提交的表单字段
|
||
success: function (data) {
|
||
var resMsg = data.resMsg;
|
||
if ("数据获取成功" == resMsg) {
|
||
reloadTip("删除",success,'success');
|
||
setTimeout(function(){
|
||
window.location.reload();
|
||
}, 2000);
|
||
}else {
|
||
reloadTip("删除",error,"error");
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
function reloadTip(tip,message,type){
|
||
layNotify.notice({
|
||
title: tip+"提示",
|
||
type: type,
|
||
message: message
|
||
});
|
||
} |