layui.config({ base: '../../js/layuiModules/', // 第三方模块所在目录 version: 'v1.6.4' // 插件版本号 }).extend({ soulTable: 'notice,layNotify', // 模块 }); let form; var tree; var table; var notice; var layNotify; let pers = checkPermission(); const token = localStorage.getItem("token"); $("#resetBt").click(function(){ table.reload('menuTable', { url: ctxPath + '/personnel/getSubcontractorList' , method: 'post' //方式默认是get , page: true , where: { keyWord: "", subId: "", dictKey: "", } //设定异步数据接口的额外参数 }); $("#keyWord").val(""); getSub(form,""); $("#dictKey").val(""); // getProcessEquipments(form,""); }) $("#searchBt").click(function(){ table.reload('menuTable', { url: ctxPath + '/personnel/getSubcontractorList' , method: 'post' //方式默认是get , page: true , where: { keyWord: $("#keyWord").val(), dictKey: $("#dictKey").val(), subId: $("#subId").val(), } //设定异步数据接口的额外参数 }); }) $("#addBt").click(function(){ localStorage.setItem("id",'') localStorage.setItem("subId",'') localStorage.setItem("personName",'') localStorage.setItem("sex",'') localStorage.setItem("nation",'') localStorage.setItem("isEmploymentAgreement",'') localStorage.setItem("isSocialSecurity",'') localStorage.setItem("isSalaryPaymentCertificate",'') layerOpenFormForSencond("新增","./subcontractorForm.html"); }) $("#exportBt").click(function(){ keyWord = $("#keyWord").val(); dictKey = $("#dictKey").val(); subId = $("#subId").val(); window.location.href = ctxPath + "/personnel/exportSubcontractorResult?" +"keyWord=" + keyWord + "&dictKey=" + dictKey + "&subId=" + subId + "&type=" + '1' + "&token=" + token; //下载文件 }) $("#importBt").click(function(){ toLeadInto("导入","../toLeadInto/subcontractorImport.html"); }) layui.use(['table', 'form','notice', 'layNotify','element'], function () { table = layui.table; form = layui.form; tree = layui.tree; notice = layui.notice; layNotify = layui.layNotify; var element = layui.element; if ($.inArray('sysSubcontractor:add', pers) < 0) { document.getElementById('addDiv').remove(); } getSub(form,""); // getProcessEquipments(form,""); //渲染表格 table.render({ elem: '#demo' , url: ctxPath + '/personnel/getSubcontractorList' //数据接口 , method: 'post' //方式默认是get , toolbar: 'default' //开启工具栏,此处显示默认图标,可以自定义模板,详见文档 , where: {} //post请求必须加where ,post请求需要的参数 , cellMinWidth: 80 , cols: [[ //表头 { field: 'number', width:80,title: '序号', align: 'center', type: 'numbers' } , {field: 'subName', align: 'center', title: '分包商'} , {field: 'managePersonName', align: 'center', title: '岗位'} , {field: 'personName', align: 'center', title: '姓名'} , {field: 'sex', align: 'center', title: '性别'} , {field: 'nation', align: 'center', title: '民族'} , {field: 'id', align: 'center', title: '身份证',templet:d=>{ if(d.id){ if(d.id.length>18){ return decrypt(d.id) } } return d.id; }} , {field: 'certificate', align: 'center', title: '持证情况'} , {field: 'level', align: 'center', title: '职称/技能等级'} , {field: 'proName', align: 'center', title: '所在项目'} , {field: 'subTeamType', align: 'center', title: '工序'} , {field: 'subTeamName', align: 'center', title: '班组名称'} , {field: 'status', align: 'center', title: '状态', templet: '#switchTpl'} , { fixed: 'right', width:180, title: '操作', align: 'center', templet: d => { let text = ""; text +='详情'; if ($.inArray('sysSubcontractor:update', pers) >= 0) { text +=' | '; text +='修改'; } if ($.inArray('sysSubcontractor:del', pers) >= 0) { text +=' | '; text +='删除'; } return text; } } ]] ,done: function (res, curr, count) { element.render(); } , id: 'menuTable' , page: true //开启分页 , loading: true //数据加载中。。。 , limits: [5, 10, 20, 100] //一页选择显示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('tool(test)', function (obj) { var data = obj.data; //当前行数据 var rowIndex = obj.index; var layEvent = obj.event; //当前点击的事件名 localStorage.setItem("id",data.id) localStorage.setItem("subId",data.subId) localStorage.setItem("subName",data.subName) localStorage.setItem("personName",data.personName) localStorage.setItem("sex",data.sex) localStorage.setItem("nation",data.nation) localStorage.setItem("isEmploymentAgreement",data.isEmploymentAgreement) localStorage.setItem("isSocialSecurity",data.isSocialSecurity) localStorage.setItem("isSalaryPaymentCertificate",data.isSalaryPaymentCertificate) localStorage.setItem("managePersonName",data.managePersonName) localStorage.setItem("subTeamName",data.subTeamName) localStorage.setItem("subTeamType",data.subTeamType) localStorage.setItem("proName",data.proName) localStorage.setItem("status",data.status) localStorage.setItem("certificate",data.certificate) localStorage.setItem("level",data.level) if (layEvent === 'view') { layerOpenProgressView("详情","./subcontractorView.html"); }else if (layEvent === 'update') { layerOpenFormForSencond("修改","./subcontractorForm.html"); }else if (layEvent === 'del') { layer.confirm('确定要删除吗?', { btn : [ '确定', '取消' ] }, function(index) { ajaxCommonMethod('/personnel/delSubcontractorById',{'id': data.id},"删除成功","删除失败"); layer.close(index); table.reload('menuTable'); }); } }); //权限判断 form.on('switch(statusSwitch)', function(data){ var isChecked = data.elem.checked; // 获取复选框的当前状态 var value = data.value; // 获取复选框的值 let status = isChecked ? 1 : 0; $.ajax({ url: ctxPath + '/personnel/subcontractorSwitchListen', type: 'POST', data: { id: value, status: status }, success: function(res) { layer.msg('状态更新成功'); }, error: function() { layer.msg('更新状态失败'); } }); }); }); function layerOpenProgressView(title,contentUrl){ var index = layer.open({ title: [title, 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'], type: 2, content: contentUrl, area: ['90%', '95%'], maxmin: false, cancel:function (){ table.reload('menuTable', { url: ctxPath + '/personnel/getSubcontractorList' , method: 'post' //方式默认是get , page: true , where: { keyWord: "", orgId: "", voltageLevel: "", } //设定异步数据接口的额外参数 }); } }); }