123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542 |
- // 获取用户部门
- var dept_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- // 获取公司
- var comp_id=top.com.sinosoft.lz.system.user.LoginInfo.getParent_ids();
- var mycol1;
- // 获取用户Id
- var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- //获取用户角色
- var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
- var dept_name = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
- var mycol;
- var testData;
- //初始化时的报表类型
- var report_types = "";
- //初始化下拉框
- var selecta ="";
- var require="";
- //初始化方法
- $(function(){
- getRole(getRole_id(role_id));
- getColumns();
- getRows($("#sel").val());
- init(testData);
- getReportNumber();
- $("#add").text(dept_name+mycol1+"导入");
- });
- // 初始化表格
- function init(data) {
- g = $("#maingrid").quiGrid({
- columns : mycol,
- data : data,
- usePager:false,
- sortName : 'id',
- rownumbers : true,
- enabledSort:false,
- enabledEdit : true, // 编辑用
- width : "100%",
- multihead : true,
- onBeforeEdit:onBeforeEdit,
- onAfterEdit:onAfterEdit
- });
- }
-
- var oldVal;
- function onBeforeEdit(e){
- var len = g.getData().length;
- if(e.rowindex==len-1){
- top.Dialog.alert("此行不能编辑",null,null,null,-1);
- return false;
- }
-
- if(e.value!=null&&e.value!=""){
- oldVal = e.value;
- }else{
- oldVal = 0;
- }
-
- }
-
-
- var num1 = 0;
- function onAfterEdit(e){
- if(e.column.isCount!=0){
- return false;
- }
- var size=g.getData().length;
- if(e.value==null||e.value==""){
- e.value="0";
- flag = false;
- }
- if(e.value!=null&&e.value!=""&&e.value!="0"){
- flag = true;
- }
- var updatecolumn=e.column.name;
- num1=g.getRow(size-1)[updatecolumn]==""?"0":g.getRow(size-1)[updatecolumn];
- num1=Math.round((parseFloat(num1)+parseFloat(e.value)-oldVal)*100)/100;
- row=g.getRow(size-1);
- row[updatecolumn]=num1;
- g.updateRow(size-1,row);
-
-
-
-
- //取消事件冒泡
- return false;
- }
-
-
-
-
-
-
-
-
- //返回主页面
- function goback(){
- window.parent.document.getElementById("frmright").setAttribute("src", "/nwyj/page/business/em/report/Report_main.jsp");
- }
-
-
- // 获取(表头)
- function getColumns() {
- var urls = $.pathname()
- + "/ws/xianlutingyun/XianlutingyunService/getEditColumns";
- $.ajax({
- url : urls,
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- "report_type" : getType(getRole_id(role_id)),
- },
- dataType : 'text',
- success : function(data) {
- mycol =eval('('+ data+')');
- mycol1=eval('('+data+')')[0].display;
- },
- error : function(e) {
- $.messager.alert('查询失败!', '访问服务失败!', 'error');
- }
- });
- }
- // 获取行
- function getRows(value) {
- var urls = $.pathname()
- + "/ws/xianlutingyun/XianlutingyunService/getRowName";
- $.ajax({
- url : urls,
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- comp_id : dept_id,
- report_type:value
- },
- dataType : 'json',
- success : function(data) {
- testData = data;
- },
- error : function(e) {
- $.messager.alert('查询行失败!', '访问服务失败!', 'error');
- }
- });
- }
-
- // 根据下拉框的选择,动态获取表头
- function change() {
- var val = $("#sel").val();
- var urls = $.pathname()
- + "/ws/xianlutingyun/XianlutingyunService/getEditColumns";
-
- $.ajax({
- url : urls,
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- "report_type" : val,
- },
- dataType : 'text',
- success : function(data) {
- mycol = eval('('+data+')');
- mycol1 = eval('('+data+')')[0].display;
- },
- error : function(e) {
- $.messager.alert('查询失败!', '访问服务失败!', 'error');
- }
- });
- g.endEdit();
- getRows(val);
- init(testData);
- changeRequireByVal(val);
- $("#add").text("新增"+dept_name+mycol1);
- }
- //导入后保存
- // 新增报表
- function save() {
- g.endEdit();
- var value =$("#sel").val();
- var sel = $("#warning").val();
- var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/create";
- var row = g.getData();
- var json=JSON.stringify(row);
-
- $.ajax({
- url : urls,
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- json:json,
- user_id:user_id,
- report_type:value,
- comp_id : dept_id,
- report_id:sel
- },
- dataType : 'json',
- success : function(data) {
- if(data.Msg.sucsess==true){
- top.Dialog.alert("新增报表成功");
- goback();
- }else{
- top.Dialog.alert("新增报表失败");
- }
- },
- error : function(e) {
- $.messager.alert('保存报表失败!', '访问服务失败!', 'error');
- }
- });
-
- }
-
- function clear_msg(){
- top.Dialog.confirm("确定要重置?填写的信息会全部清除,请慎重选择|重置", function() {
- g.endEdit();
- getRows($("#sel").val());
- init(testData);
- });
- }
-
-
- //根据用户登录时的不同角色初始化下拉框
- function getRole(id){
-
-
- if(id=="R002105430210"){
- selecta = {"list":[
- {"value":"1","key":"线路停运及恢复情况表"},
- {"value":"2","key":"变电站停运及恢复情况表"}]};
-
- $("#requires").append("<span>① 单位:受灾地市局</span> <br>" +
- "<span>② 跳闸停电(条数):相应电压等级线路跳闸的总条数,不包含重合闸成功的跳闸线路条数,且同一条线路多次跳闸,只统计为一个跳闸条数。</span><br>"+
- "<span>③ 未恢复:填写相应电压等级线路跳闸后,未恢复成热备用状态的线路条数。</span><br>"+
- "<span>④ 累计跳闸(条次):相应电压等级线路跳闸的总条次数,包含重合闸成功的跳闸线路条数,且同一条线路多次跳闸,统计为多个跳闸条次数。</span><br>"+
- "<span>⑤ 备注:填写未恢复线路名称。</span><br>"+
- "<span>⑥ 损失负荷:电网因灾损失的负荷数。电网发生故障后,在线路重合闸及备用电源自投装置动作完成后系统未恢复的负荷,包括电网减供负荷和低压脱扣负荷。</span><br>"+
- "<span>⑦ 损失占比:损失负荷数占同期电网应有负荷的百分比。</span>");
-
- $("#changerequire").append("<span>① 单位:受灾地市局</span><br>"+
- "<span>② 累计停运(座):灾害过程中发生停运变电站的总座数。</span><br>"+
- "<span>③ 未恢复(座):截止当前时间未恢复变电站的总座数。</span><br>"+
- "<span>④ 备注:发生停运事件的变电站名称及目前状态。例如:XX变电站(已恢复/未恢复)</span>"
- );
- }
- if(id=="R002105430213"){
- selecta = {"list":[
- {"value":"8","key":"应急资源情况表"}]};
-
-
- $("#requires").append("<span>① 单位名称:受灾地市局。</span><br>"+
- "<span>② 抢修人员:填写当日投入抢修人数的最大值。</span><br>"+
- "<span>③ 抢修车辆:填写当日投入抢修车辆数的最大值。</span><br>"+
- "<span>④ 应急发电车:填写当日投入应急发电车数量的最大值。</span><br>"+
- "<span>⑤ 应急发电机:填写当日投入应急发电机数量的最大值。</span><br>"+
- "<span>⑥ 备注:台风登陆期间不用填报。</span>"
- );
- }
- if(id=="R002105430211"){
- selecta = {"list":[
- {"value":"3","key":"线路倒杆情况统计表"},
- {"value":"4","key":"线路及配变受损情况"}]};
-
- $("#requires").append("<span>① 单位:受灾地市局。</span><br>"+
- "<span>② 备注:台风登陆期间不用填报。</span><br>"+
- "<span>② 备注:台风登陆期间不用填报。</span><br>"+
- "<span>③ 其他信息填写说明如下:</span>"
-
- );
- $("#changerequire").append("<span>① 单位:受灾地市局</span><br>"+
- "<span>② 线路受损:按单相导路(地线)受损长度统计,统计距离为断线或者整条线路损毁时的档距。</span><br>"+
- "<span>③ 线路未恢复:截至当前仍未修复的受损线路长度。</span><br>"+
- "<span>④ 配变受损:发生损害需要修复或更换的配变台数。</span><br>"+
- "<span>⑤ 配变未恢复:截至当前仍未修复或更换的配变台数。</span><br>"+
- "<span>⑥ 备注:台风登陆期间不用填报。</span>"
- );
- }
- if(id=="R002105430212"){
- selecta = {"list":[
- {"value":"5","key":"供电损失及客户停电情况表"},
- {"value":"6","key":"行政区域停电情况表"}]};
-
- $("#requires").append("<span>① 单位:受灾地市局。</span><br>"+
- "<span>② 台区:一个配变所供负荷区域计作一个台区。</span><br>"+
- "<span>③ 用户数:1)线路重复跳闸时客户停电户数不累加统计,即线路重复跳闸时,停电户数只统计一次。2)线路跳闸重合成功的客户数不统计。</span><br>"+
- "<span>④ 未恢复数:因灾发生停电的用户截至当前还未恢复供电的用户数。</span><br>"+
- "<span>⑤停电占比:停电占比=停电台区(用户)数÷当地台区(用户)总数。</span><br>"+
- "<span>⑥损失电量:灾害期间损失电量的总数。</span>");
-
-
- $("#changerequire").append("<span>① 单位:受灾地市局。</span><br>"+
- "<span>② 累计全停:灾害发生以来发生全县(区)、全乡镇、全行政村全停的个数。</span><br>"+
- "<span>③ 当前全停:当前仍存在全县(区)、全乡镇、全行政村全停的个数。</span><br>"+
- "<span>④ 备注:台风登陆期间不用填报。</span>"
- );
- }
-
- $("#sel").data("data",selecta);
- $("#sel").render();
- }
- //根据用户角色登录,返回report_type 的默认值
- function getType(id){
-
-
-
- if(id=="R002105430210"){
- report_types="1";
- }
- if(id=="R002105430213"){
- report_types="8";
- }
- if(id=="R002105430211"){
- report_types="3";
- }
- if(id=="R002105430212"){
- report_types="5";
-
- }
- return report_types;
- }
-
- //获取预警或响应编号
- function getReportNumber(){
-
- var url = $.pathname() + '/ws/xianlutingyun/XianlutingyunService/getReportNumber/';
- $.post(url,{dept_id :dept_id},function(data){
- $("#warning").data("data",data);
- $("#warning").render();
- }, "json");
- }
-
- //通过选择预警或响应编号来显示报表计划要求
- function getPlan(){
- g.endEdit();
- $("#sysDept").html("");
- $("#equipmentDept").html("");
- $("#markingDept").html("");
- $("#safeyDept").html("");
- var number = $("#warning").val();
-
- if(number){
- var datas = getPlanRequires(number);
- $("#star_time").html(datas.rows[0].START_TIME);
- $("#end_time").html(datas.rows[0].END_TIME);
- $("#type").html(datas.rows[0].FILL_IN_SCHEDULE);
- if(datas.rows[0].FILL_IN_SCHEDULE=="周期性"){
- $("#round").html(datas.rows[0].ROUND_TIME);
- $(".round_time").show();
- $(".temporary_time").hide();
- }
- if(datas.rows[0].FILL_IN_SCHEDULE=="临时性"){
- $("#temporary").html(datas.rows[0].TEMPORARY_TIME);
- $(".temporary_time").show();
- $(".round_time").hide();
- }
- $("#showplan").show();
- $("#showRequire").show();
- $("#showRequire").find("a").html("隐藏报表填报要求");
-
- var message = datas.rows[0].DEPT_NAME.split(":");
- var planMessage = message[1].split("|");
- var depts="";
- for(var i=0;i<planMessage.length;i++){
- depts = planMessage[i].split(";");
- if(depts[0]=="R002105430210"){
-
- $("#sysDept").html(depts[1]);
- }
- if(depts[0]=="R002105430211"){
-
- $("#equipmentDept").html(depts[1]);
- }
- if(depts[0]=="R002105430212"){
-
- $("#markingDept").html(depts[1]);
- }
- if(depts[0]=="R002105430213"){
-
- $("#safeyDept").html(depts[1]);
- }
- }
- }else{
- $("#showplan").hide();
- $("#showRequire").hide();
- $("#showRequire").find("a").html("隐藏报表填报要求");
- }
-
- }
- function getPlanRequires(value){
- $.ajax({
- url : $.pathname() + '/ws/getPlanRequires/getPlanRequireService/getPlanRequire/',
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- comp:dept_id,
- warning_number:value,
- },
- dataType : 'json',
- success : function(data) {
- require = data;
- },
- error : function(e) {
- $.messager.alert('查询报表计划失败!', '访问服务失败!', 'error');
- }
- });
- return require;
- }
- function showTable(){
- $("#showplan").toggle();
- var show = $("#showplan").css("display");
- if(show=="none"){
- $("#showRequire").find("a").html("显示报表填报要求");
- }else{
- $("#showRequire").find("a").html("隐藏报表填报要求");
- }
- }
-
- function getModels(){
-
- var sel = $("#sel").val();
-
- var Columns = findColumn(sel);
- var columns_sub = Columns.substring(0, Columns.lastIndexOf(","));
- var condition = '1=1';
- var sql = {
- "flag":"muban",
- "listId" :findId(sel),
- "condition":condition,
- "id":dept_id,
- "report_type":sel
- };
- baoBiaoExcelExport(findId(sel),sql,mycol1+"模版",['FD_OBJECTID','REPORT_ID','TEST','COMP_ID',columns_sub]);
- }
-
-
- //根据选中记录查找classId
- function findId(type){
- var classId="";
- $.ajax({
- url : $.pathname() + "/ws/getReportId/ExportExcelService/getReportClassId",
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- report_type:type
- },
- dataType : 'json',
- success : function(data) {
- classId = data.rows[0].CLASSID;
- },
- error : function(e) {
- $.messager.alert('获取ID失败!', '访问服务失败!', 'error');
- }
- });
- return classId;
- }
- //过滤没用的列
- function findColumn(type){
- //把首次导入的清除
- var column="";
- $.ajax({
- url : $.pathname() + "/ws/getReportId/ExportExcelService/getColumn",
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- report_type:type
- },
- dataType : 'json',
- success : function(data) {
- for(var i=0;i<data.rows.length;i++){
- column += data.rows[i].TABLE_COLUMN+",";
- }
- },
-
- error : function(e) {
- $.messager.alert('获取列失败!', '访问服务失败!', 'error');
- }
- });
- return column;
- }
-
- function changeRequireByVal(value){
- if(value=="1"){
- $("#requires").show();
- $("#changerequire").hide();
- }
- if(value=="2"){
- $("#requires").hide();
- $("#changerequire").show();
- }
-
- if(value=="3"){
- $("#changerequire").hide();
- $("#requires").show();
- }
- if(value=="4"){
- $("#requires").hide();
- $("#changerequire").show();
- }
- if(value=="5"){
- $("#changerequire").hide();
- $("#requires").show();
- }
- if(value=="6"){
- $("#requires").hide();
- $("#changerequire").show();
- }
- if(value=="8"){
- $("#changerequire").hide();
- $("#requires").show();
- }
-
- }
-
-
-
- function getRole_id(id){
- if(id.indexOf(",")!=-1){
- var role_ids = id.split(",");
- for(var i=0;i<role_ids.length;i++){
- if(role_ids[i]=="R002105430210"||role_ids[i]=="R002105430211"||role_ids[i]=="R002105430212"||role_ids[i]=="R002105430213"){
- return role_ids[i];
- }
- }
- }else{
- return id;
- }
-
- }
-
- window.onload = function (){
- $(".selectbox").attr("readonly","readonly");
- };
|