var fun = { init: function () { //获取异常类型 fn.getInspectDeviceType(fun.getInspectDeviceType); fn.getInspectDeviceUnusualTypePDA(fun.getInspectDeviceUnusualTypePDA); fn.getInspectDeviceMainTeance(fun.getInspectDeviceMainTeance); fn.getInspectEmployeeOutRule(fun.getInspectEmployeeOutRule); fn.getInspectBerthUnusualType(fun.getInspectBerthUnusualType); fn.getInspectDeviceUnusualTypePrinter(fun.getInspectDeviceUnusualTypePrinter); fn.getInspectDeviceUnusualTypeEQP(fun.getInspectDeviceUnusualTypeEQP); commSelect.plName_select("#insreport-transSelectPark",true,null,null,3); $('#insreport-taskType').selectpicker('refresh'); fun.dateInit(); fun.createTableData(); }, dateInit:function () { /**日 时间初始化*/ $('#daydaterange-btnsta').val(moment().subtract('days', 0).format('YYYY-MM-DD')); $('#daydaterange-btnend').val(moment().subtract('days', 0).format('YYYY-MM-DD')); //开始日期 $("#daydaterange-btnsta").datetimepicker({ endDate: moment().subtract('days', 0).format('YYYY-MM-DD'), format: 'yyyy-mm-dd', autoclose: true, startView: 2, //maxDate:moment().subtract('months', 3), minView: 2, forceParse: false, locale: "zh-CN", language: 'zh-CN', pickerPosition: "bottom-right" }) //结束日期 $("#daydaterange-btnend").datetimepicker({ endDate: moment().subtract('days', 0).format('YYYY-MM-DD'), format: 'yyyy-mm-dd', autoclose: true, startView: 2, //maxDate:moment().subtract('months', 3), minView: 2, forceParse: false, locale: "zh-CN", language: 'zh-CN', pickerPosition: "bottom-right" }) }, //默认生成表格数据 createTableData:function () { $('#insreport-billtable').bootstrapTable('destroy').bootstrapTable({ striped: true,//表格显示条纹 pagination: true, //启动分页 pageNumber: 1, //当前第几页 pageSize: 10, //每页显示的记录数 pageList: [10, 15, 20], //记录数可选列表 sidePagination: 'server',//表示服务端分页 queryParamsType: 'limit', // sortable: true, //是否启用排序 // sortOrder: "asc", method: 'POST',//请求方法 paginationPreText: '<', paginationNextText: '>', ajax: feetableLoadRequest,//自定义ajax加载数据 // uniqueId:'id', columns: [ {field: 'plName', title: '车场名称', width: '15%', align: "left",formatter:commonObj.replacenull}, { field: 'parkAreaName', title: '泊位区间', width: '15%', align: "left", formatter:commonObj.replacenull // sortable: true }, { field: 'inspectType', title: '任务类型', width: '15%', align: "left", formatter: function(value){ if (undefined != value && null != value) { if (value == '1') { return '车位巡查' } else if (value == '2') { return '设备巡查'; }else if (value == '3') { return '人员巡查'; } } else { return '-'; } } }, { field: 'inspectName', title: '巡查员', width: '15%', align: "left", formatter:commonObj.replacenull }, { field: 'unusualType', title: '异常信息', width: '10%', align: "left", formatter:fun.unusualInformationFormatter }, { field: 'createTime', title: '上报时间', width: '15%', align: "left", formatter:commonObj.timeFormatter }, { field: 'poptype', title: '操作', width: '15%', align: "left", formatter:fun.popFormater }, ] }); }, getInspectDeviceType: function (data) { if (null == data) { return; } InspectDeviceTypes = []; $.each(data, function (index, item) { var InspectDeviceType={}; InspectDeviceType.value = item.codeValue; InspectDeviceType.name = item.codeValueName; InspectDeviceTypes.push(InspectDeviceType); }); }, getInspectDeviceUnusualTypePDA: function (data) { if (null == data) { return; } InspectDeviceUnusualTypePDAs = []; $.each(data, function (index, item) { var InspectDeviceUnusualTypePDA={}; InspectDeviceUnusualTypePDA.value = item.codeValue; InspectDeviceUnusualTypePDA.name = item.codeValueName; InspectDeviceUnusualTypePDAs.push(InspectDeviceUnusualTypePDA); }); }, getInspectDeviceMainTeance: function (data) { if (null == data) { return; } InspectDeviceMainTeances = []; $.each(data, function (index, item) { var InspectDeviceMainTeance={}; InspectDeviceMainTeance.value = item.codeValue; InspectDeviceMainTeance.name = item.codeValueName; InspectDeviceMainTeances.push(InspectDeviceMainTeance); }); }, getInspectEmployeeOutRule: function (data) { if (null == data) { return; } InspectEmployeeOutRules = []; $.each(data, function (index, item) { var InspectEmployeeOutRule={}; InspectEmployeeOutRule.value = item.codeValue; InspectEmployeeOutRule.name = item.codeValueName; InspectEmployeeOutRules.push(InspectEmployeeOutRule); }); }, getInspectBerthUnusualType: function (data) { if (null == data) { return; } InspectBerthUnusualTypes = []; $.each(data, function (index, item) { var InspectBerthUnusualType={}; InspectBerthUnusualType.value = item.codeValue; InspectBerthUnusualType.name = item.codeValueName; InspectBerthUnusualTypes.push(InspectBerthUnusualType); }); }, getInspectDeviceUnusualTypePrinter: function (data) { if (null == data) { return; } InspectDeviceUnusualTypePrinters = []; $.each(data, function (index, item) { var InspectDeviceUnusualTypePrinter={}; InspectDeviceUnusualTypePrinter.value = item.codeValue; InspectDeviceUnusualTypePrinter.name = item.codeValueName; InspectDeviceUnusualTypePrinters.push(InspectDeviceUnusualTypePrinter); }); }, getInspectDeviceUnusualTypeEQP: function (data) { if (null == data) { return; } InspectDeviceUnusualTypeEQPs = []; $.each(data, function (index, item) { var InspectDeviceUnusualTypeEQP={}; InspectDeviceUnusualTypeEQP.value = item.codeValue; InspectDeviceUnusualTypeEQP.name = item.codeValueName; InspectDeviceUnusualTypeEQPs.push(InspectDeviceUnusualTypeEQP); }); }, deviceTypeFormatter:function(value){ var deviceType = "无"; if(value == null){ return deviceType; } $.each(InspectDeviceTypes, function(index,item) { if(value == item.value){ deviceType = item.name; } }); return deviceType; }, //异常信息转换 unusualInformationFormatterStr:function(value,row,index){ var unusualInformation = ""; if(row == null){ return unusualInformation } if(row.inspectType == null){ return unusualInformation }else if(row.inspectType == 1){//车位巡查 if(row.unusualType == null){ return unusualInformation } $.each(InspectBerthUnusualTypes,function(index,item){ if(row.unusualType == item.value){ unusualInformation = item.name; } }); return unusualInformation }else if(row.inspectType == 2){//设备巡查 if(row.unusualType == null){ return unusualInformation } if(row.deviceType == null){ return unusualInformation } if(row.deviceType == 1){//设备-PDA $.each(InspectDeviceUnusualTypePDAs,function(index,item){ if(row.unusualType == item.value){ unusualInformation = item.name; } }); } if(row.deviceType == 2){//设备-地磁 $.each(InspectDeviceUnusualTypeEQPs,function(index,item){ if(row.unusualType == item.value){ unusualInformation = item.name; } }); } if(row.deviceType == 3){//设备-打印机 $.each(InspectDeviceUnusualTypePrinters,function(index,item){ if(row.unusualType == item.value){ unusualInformation = item.name; } }); } return unusualInformation }else if(row.inspectType == 3){//人员巡查 if(row.outRuleType == null){ return '
'+unusualInformation+'
'; } $.each(InspectEmployeeOutRules,function(index,item){ $.each(JSON.parse("["+row.outRuleType+"]"), function(_index,_item) { if(_item == item.value){ unusualInformation = (unusualInformation + item.name + "、"); } }); }); unusualInformation = unusualInformation.substr(0,(unusualInformation.length-1)); // return unusualInformation; return unusualInformation } }, unusualInformationFormatter:function(value,row,index){ var unusualInformation = ""; if(row == null){ return '
'+unusualInformation+'
'; } if(row.inspectType == null){ return '
'+unusualInformation+'
'; }else if(row.inspectType == 1){//车位巡查 if(row.unusualType == null){ return '
'+unusualInformation+'
'; } $.each(InspectBerthUnusualTypes,function(index,item){ if(row.unusualType == item.value){ unusualInformation = item.name; } }); return '
'+unusualInformation+'
'; }else if(row.inspectType == 2){//设备巡查 if(row.unusualType == null){ return '
'+unusualInformation+'
'; } if(row.deviceType == null){ return '
'+unusualInformation+'
'; } if(row.deviceType == 1){//设备-PDA $.each(InspectDeviceUnusualTypePDAs,function(index,item){ if(row.unusualType == item.value){ unusualInformation = item.name; } }); } if(row.deviceType == 2){//设备-地磁 $.each(InspectDeviceUnusualTypeEQPs,function(index,item){ if(row.unusualType == item.value){ unusualInformation = item.name; } }); } if(row.deviceType == 3){//设备-打印机 $.each(InspectDeviceUnusualTypePrinters,function(index,item){ if(row.unusualType == item.value){ unusualInformation = item.name; } }); } return '
'+unusualInformation+'
'; }else if(row.inspectType == 3){//人员巡查 if(row.outRuleType == null){ return '
'+unusualInformation+'
'; } $.each(InspectEmployeeOutRules,function(index,item){ $.each(JSON.parse("["+row.outRuleType+"]"), function(_index,_item) { if(_item == item.value){ unusualInformation = (unusualInformation + item.name + "、"); } }); }); unusualInformation = unusualInformation.substr(0,(unusualInformation.length-1)); // return unusualInformation; return '
'+unusualInformation+'
'; } }, //时间 strFormatter: function (value, row, index) { if (value==null||value==undefined||value=='') { return ""; } else { return value+""; } }, popFormater:function (value, row, index) { console.log(index) console.log(value) console.log(row) return "查看"; }, /*获取查询参数*/ feegetQueryParam: function () { var plNos = JSON.parse($("#insreport-transSelectPark").val()); var inspectTypes = JSON.parse($("#insreport-taskType").val()); var beginTime = $("#daydaterange-btnsta").val(); beginTime = new Date(beginTime+" 00:00:00"); var endTime = $("#daydaterange-btnend").val(); endTime = new Date(endTime+" 23:59:59"); var req = { inspectTypes:inspectTypes, plNos: plNos, beginTime:beginTime, endTime:endTime, sysCode: sysComm.sysCode } return req; }, }; fun.init(); //查询 documentBindFunc.on('click', '#insreport-QueryBtn', function () { fun.createTableData(); }); documentBindFunc.on('click', '.popClick', function (element) { var rowStr = $(this).attr('data-row'); var row = JSON.parse(rowStr); var _index = $(this).attr('data-index'); console.log(_index) //弹窗初始化 $("[id^='inspect']").text(""); $("#imgUrl").attr("src",''); $("#imgUrl").attr("data-img",''); $("#inspectPlName").text(fun.strFormatter(row.plName)); $("#inspectParkAreaName").text(fun.strFormatter(row.parkAreaName)); $("#inspectChargerName").text(fun.strFormatter(row.chargerName)); $("#inspectBerthNo").text(fun.strFormatter(row.berthNo)); $("#inspectName").text(fun.strFormatter(row.inspectName)); $("#inspectDeviceType").text(fun.deviceTypeFormatter(row.deviceType)); $("#inspectUnusualInformation").text(fun.unusualInformationFormatterStr(null,row)); if(row.inspectImgUrl !=null && row.inspectImgUrl != ""){ $("#imgUrl").attr("src",row.inspectImgUrl); $("#imgUrl").attr("title","点击查看原图"); $("#imgUrl").attr("data-img",row.inspectImgUrl); }else{ $("#imgUrl").attr("src",'../../assets/pages/scripts/inspectionFile/inspectionreport/patrol-con-wrap-pic.png'); } $('#detailmodel').modal('show'); }); documentBindFunc.on('click', "#imgUrl", function (item) { var imgs = $('#imgUrl').attr('data-img'); if(imgs==null||imgs==''||imgs==undefined){ return false; } window.open(imgs, "_blank"); }); /** * 默认table 函数 * 自定义table AJAX请求 * @param {Object} params */ function feetableLoadRequest(params) { var req = fun.feegetQueryParam(); //设置请求参数 var pageNum = (params.data.offset / params.data.limit) + 1; //条件查询 req.baseRequest = { pageNum: pageNum, pageSize: params.data.limit }; var opt = { method: 'post', url: dataUrl.util.queryInspectSituationForPage(), data: JSON.stringify(req), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (res) { if (res.code == '8888') { params.success(res.data); console.log(res.data) $("[data-toggle='tooltip']").tooltip(); } } }; sysAjax(opt); }