123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855 |
- var flag1 = false;
- var real_name = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
- var corpName =top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
- var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
- var loginName = top.com.sinosoft.lz.system.user.LoginInfo.getLogin_name();
- var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var real_name = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
- var mobile = top.com.sinosoft.lz.system.user.LoginInfo.getMobile();
- var editingRow = "";
- var isValida=true;
- var dydj = {"list":[
- {"value":"500kV","key":"500kV"},
- {"value":"220kV","key":"220kV"},
- {"value":"110kV","key":"110kV"},
- {"value":"35kV","key":"35kV"}
- ]};
- var huifu = {"list":[
- {"value":"是","key":"是"},
- {"value":"否","key":"否"}
- ]};
- //数据表格
- var g;
- var mycol;
- var mycol1;
- var testdata;
- var flag = false;
- var url = decodeURI(window.location.href);
- //报表类型
- var report_type;
- //报表对应的角色id
- var role_id;
- //单位id
- var comp_id;
- var comp_name;
- //事件类型
- var affair_type;
- //事件类型名称
- var affair_name;
- //记录ID
- var fd_objectid;
- //判断是否有操作列,该页面默认都有操作列
- var rollbackFlag = true;
- //该变量用于保存可编辑的行号
- var rowNumArr = [];
- var update_url= $.pathname() + "/ws/xianlutingyun/XianlutingyunService/updateStat";
- function showData(type,comp,name,role,affair,affairType,alert_id){
- report_type = type=="101"?"2":type;
- role_id = role;
- comp_id = comp;
- comp_name = name;
- affair_type = affair;
- affair_name = affairType;
- fd_objectid = alert_id;
-
- //加载表格
- init();
- getColumns();
- $("#add").text("修改"+comp_name+mycol1);
- $("#affair").text(affairType);
- //若该单位已上报数据
- if(""==fd_objectid){
- //自动汇总下级单位对应填报节点的数据,避免将下级
- getInitialData();
- }else{
- getData();
- }
- addRequire(report_type);
- }
-
- function init(){
- g = null;
- if(report_type=='2'){
- g = $("#maingrid").quiGrid({
- columns : [],
- data : [],
- usePager : false,
- sortName: 'id',
- rownumbers:true,
- enabledEdit: true, //编辑用
- width:"100%",
- multihead:true,
- enabledSort:false,
- excelMode:true,
- alternatingRow:false,
- enabledEdit: true,
- clickToEdit: false,
- toolbar:{
- items:[
- { text: '新增', click: addUser, iconClass: 'add1_tem' },
- { line: true }
- ]
- },
- onAfterSubmitEdit: onAfterSubmitEdit,
- onBeforeSubmitEdit : onBeforeSubmitEdit,
- onAfterEdit : onAfterEdit,
- onBeforeEdit: onBeforeEdit
- });
- }else{
- g = $("#maingrid").quiGrid({
- columns : [],
- data : [],
- usePager : false,
- sortName : 'id',
- rownumbers : true,
- enabledEdit : true, //编辑用
- width : "100%",
- multihead : true,
- enabledSort : false,
- excelMode : true,
- alternatingRow : false,
- onAfterEdit : onAfterEdit,
- onBeforeEdit : onBeforeEdit
- });
- }
- if ($("#maingrid").height() < 400) {
- g.setOptions({
- height : "400px"
- });
- g.resetHeight();
- } else {
- g.setOptions({
- height : "auto"
- });
- g.resetHeight();
- }
- setHight();
- }
- //获取表头
- function getColumns(){
- if(report_type!="100"){
- var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getEditColumns";
- $.ajax({
- url : urls,
- type : 'post',
- async : false,
- data : {
- "affair" : affair_type,
- "report_type" : report_type,
- "comp_id" : comp_id,
- //没有下级填报单位也需要操作列,局本部也需要代填
- "rollbackFlag" : "true"
- },
- dataType : 'text',
- success : function(data) {
- mycol =eval('('+ data+')');
- mycol1=eval('('+data+')')[0].display;
- },
- error : function(e) {
- $.messager.alert('查询表头失败!', '访问服务失败!', 'error');
- }
- });
- }
- }
- function getData(){
- $("body").eq(0).showLoading();
- var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/query";
- $.ajax({
- url : urls,
- type : 'post',
- timeout : 15000,
- data:{
- report_id : fd_objectid,
- comp_id : comp_id,
- report_type : report_type,
- roleId:role_id
- },
- dataType : 'json',
- success : function(data) {
- testdata = data;
- $("body").eq(0).hideLoading();
- },
- error : function(e) {
- $.messager.alert('查询数据失败!', '访问服务失败!', 'error');
- }
- });
- }
- function getInitialData() {
- var urls = $.pathname() + "/ws/baoBiao/BaoBiaoService/getInitialData";
- $.ajax({
- url : urls,
- type : 'post',
- async : false,
- data : {
- comp_id : comp_id,
- comp_name : comp_name,
- report_type : report_type,
- role_id : role_id,
- affair : affair_type
- },
- dataType : 'json',
- success : function(data) {
- g.setOptions({columns:mycol,data:data});
- },
- error : function(e) {
- $.messager.alert('查询行失败!', '访问服务失败!', 'error');
- }
- });
- }
- //根据type加载要求
- function addRequire(type){
- if(type=="1"){
- $("#requires").append("<span>① 单位:受灾地市局</span> <br>" +
- "<span>② 跳闸停电(条数):相应电压等级线路跳闸的总条数,不包含重合闸成功的跳闸线路条数,且同一条线路多次跳闸,只统计为一个跳闸条数。</span><br>"+
- "<span>③ 未恢复:填写相应电压等级线路跳闸后,未恢复成热备用状态的线路条数。</span><br>"+
- "<span>④ 累计跳闸(条次):相应电压等级线路跳闸的总条次数,包含重合闸成功的跳闸线路条数,且同一条线路多次跳闸,统计为多个跳闸条次数。</span><br>"+
- "<span>⑤ 备注:填写未恢复线路名称。</span><br>"+
- "<span>⑥ 损失负荷:电网因灾损失的负荷数。电网发生故障后,在线路重合闸及备用电源自投装置动作完成后系统未恢复的负荷,包括电网减供负荷和低压脱扣负荷。</span><br>"+
- "<span>⑦ 损失占比:损失负荷数占同期电网应有负荷的百分比。</span>");
- }
-
- else if(type=="2"){
- $("#requires").append("<span>① 单位:受灾地市局</span><br>"+
- "<span>② 累计停运(座):灾害过程中发生停运变电站的总座数。</span><br>"+
- "<span>③ 未恢复(座):截止当前时间未恢复变电站的总座数。</span><br>"+
- "<span>④ 备注:发生停运事件的变电站名称及目前状态。例如:XX变电站(已恢复/未恢复)</span>"
- );
- }
-
- else if(type=="3"){
- $("#requires").append("<span>① 单位:受灾地市局。</span><br>"+
- "<span>② 备注:台风登陆期间不用填报。</span><br>"
- /*"<span>② 备注:台风登陆期间不用填报。</span><br>"+
- "<span>③ 其他信息填写说明如下:</span>"*/
-
- );
-
- }
- else if(type=="4"){
- $("#requires").append("<span>① 单位:受灾地市局</span><br>"+
- "<span>② 线路受损:按单相导路(地线)受损长度统计,统计距离为断线或者整条线路损毁时的档距。</span><br>"+
- "<span>③ 线路未恢复:截至当前仍未修复的受损线路长度。</span><br>"+
- "<span>④ 配变受损:发生损害需要修复或更换的配变台数。</span><br>"+
- "<span>⑤ 配变未恢复:截至当前仍未修复或更换的配变台数。</span><br>"+
- "<span>⑥ 备注:台风登陆期间不用填报。</span>"
- );
- }
-
- else if(type=="5"){
- $("#requires").append("<span>① 单位:受灾地市局。</span><br>"+
- "<span>② 台区:一个配变所供负荷区域计作一个台区。</span><br>"+
- "<span>③ 用户数:1)线路重复跳闸时客户停电户数不累加统计,即线路重复跳闸时,停电户数只统计一次。2)线路跳闸重合成功的客户数不统计。</span><br>"+
- "<span>④ 未恢复数:因灾发生停电的用户截至当前还未恢复供电的用户数。</span><br>"+
- "<span>⑤停电占比:停电占比=停电台区(用户)数÷当地台区(用户)总数。</span><br>"+
- "<span>⑥损失电量:灾害期间损失电量的总数。</span>");
- }
-
- else if(type=="6"){
- $("#requires").append("<span>① 单位:受灾地市局。</span><br>"+
- "<span>② 累计全停:灾害发生以来发生全县(区)、全乡镇、全行政村全停的个数。</span><br>"+
- "<span>③ 当前全停:当前仍存在全县(区)、全乡镇、全行政村全停的个数。</span><br>"+
- "<span>④ 备注:台风登陆期间不用填报。</span>"
- );
- }
-
- else if(type=="7"){
- $("#requires").append("<span>① 单位名称:公司、受灾地市局。</span><br>"+
- "<span>② 本单位预警或响应级别:防风防汛X色预警,防风防汛X级响应。</span><br>" +
- "<span>③ 同级政府相关部门名称:例如XX省防总等。</span><br>"+
- "<span>④ 同级政府相关部门预警或响应级别:防风防汛X色预警,防风防汛X级响应。</span><br>"+
- "<span>⑤ 开始时间:例如,9月9日9时30分。</span><br>"+
- "<span>⑥ 结束时间:例如,9月9日9时30分。当处于预警发布或响应启动状态时,结束时间可保持为空。</span><br>"+
- "<span>⑦ 备注:台风登陆期间不用填报。</span>"
- );
- }
-
- else if(type=="8"){
- $("#requires").append("<span>① 单位名称:受灾地市局。</span><br>"+
- "<span>② 抢修人员:填写当日投入抢修人数的最大值。</span><br>"+
- "<span>③ 抢修车辆:填写当日投入抢修车辆数的最大值。</span><br>"+
- "<span>④ 应急发电车:填写当日投入应急发电车数量的最大值。</span><br>"+
- "<span>⑤ 应急发电机:填写当日投入应急发电机数量的最大值。</span><br>"+
- "<span>⑥ 备注:台风登陆期间不用填报。</span>"
- );
- }else {
- $("#requires").hide();
- }
- }
- var oldVal;
- function onBeforeEdit(e){
- if($.inArray(e.rowindex,rowNumArr)==-1){
- return false;
- }
-
- if(e.column["columnname"]=="SWRYMXB_TJ"&&report_type=="10"){
- 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){
- 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;
- }
-
- if(report_type=="10"){
- var RowObj= (g.getRow(e["record"]["__id"]));
- var count = RowObj["SWRYMXB_TJ"]==""||RowObj["SWRYMXB_TJ"]==undefined||RowObj["SWRYMXB_TJ"]=="undefined"?"0":RowObj["SWRYMXB_TJ"];
- var oldCount = count;
- count = parseInt(count,10)+parseInt(e.value,10)-parseInt(oldVal,10);
- g.updateCell("SWRYMXB_TJ",count,RowObj);
- var lastTj = g.getRow(size-1)["SWRYMXB_TJ"]==""?"0":g.getRow(size-1)["SWRYMXB_TJ"] ;
- g.getRow(size-1)["SWRYMXB_TJ"] = parseInt(lastTj,10)+parseInt(count,10)-oldCount;
- }
-
- var updatecolumn = e.column.name;
- var isCount = e.column.isCount;//非统计字段不需要更新总计值
- var row = g.getRow(size - 1);//总计行
- var row1 = g.getRow(e.rowindex);//编辑行
- row1[updatecolumn] = parseFloat(e.value);
- g.updateRow(e.rowindex, row1);
- if(isCount=='0'){
- num1 = g.getRow(size - 1)[updatecolumn] == "" || g.getRow(size - 1)[updatecolumn] == undefined ? "0" : g.getRow(size - 1)[updatecolumn];
- num1 = getZjResult(num1, e.value, oldVal);
- row[updatecolumn] = num1;
- g.updateRow(size - 1, row);
- }
- }
- function getZjResult(arg1, arg2, arg3) {
- var r1, r2, r3, m, n;
- try {
- r1 = arg1.toString().split(".")[1].length;
- } catch (e) {
- r1 = 0;
- }
- try {
- r2 = arg2.toString().split(".")[1].length;
- } catch (e) {
- r2 = 0;
- }
- try {
- r3 = arg3.toString().split(".")[1].length;
- } catch (e) {
- r3 = 0;
- }
- m = Math.pow(10, Math.max(r1, r2, r3));
- // 动态控制精度长度
- n = Math.max(r1, r2, r3);
- return ((arg1 * m + arg2 * m - arg3 * m) / m).toFixed(n);
- }
- //监听回车
- function checkKeyCode(event){
- if(event.keyCode==13){
- g.endEdit();
- }
- }
- function save(){
- flag = false;
- g.endEdit();
- //查询当前时间的被代填单位是否有报表任务
- var planUrl = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getReportPlanTask";
- $.ajax({
- url : planUrl,
- type : "post",
- data : {"report_type":report_type,"affair":affair,"comp_id":compId,"dept_id":deptId,"role_id":role_id,"deptFlag":deptFlag},
- dataType : "json",
- async : false,
- success : function(result){
- if(result.length>0){
- fdIds = "";
- plan_name = "";
- times = "";
- for(var i in result){
- var data = result[i];
- fdIds += data.key+",";
- plan_name += data.value+",";
- times += data.time+",";
- }
- fdIds = fdIds.substring(0, fdIds.lastIndexOf(","));
- plan_name = plan_name.substring(0, plan_name.lastIndexOf(","));
- times = times.substring(0, times.lastIndexOf(","));
- console.log("新增当前任务id:"+fdIds+";当前任务名称:"+plan_name+";当前填报时间:"+times);
- }else{
- draftWrite = "true";//作为草稿,不能上报
- times = report_time==""?"":getServerTime().split(" ")[0]+" "+report_time;
- }
- },
- error : function(){
- $.messager.alert('查询报表任务失败!', '访问服务失败!', 'error');
- }
- });
- var json = JSON.stringify(g.getData());
- saveTable(json,fd_objectid,report_type);
- }
- function saveTable(json,fd_objectid,report_type){
- var urls = $.pathname() + "/ws/baoBiao/BaoBiaoService/update";
- var operateUrl = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/updateOperate";
- var updateParams = {fd_id:fd_objectid,check:"end",table:"report_records"};
- var operateParams = {name:real_name,fd_id:fd_id,report_comp:corpName+deptName,sendStat:"alert","operate":"修改了"};
- var urlParams = {
- json : json,
- fd_id : fd_objectid,
- report_type : report_type,
- comp_id : comp_id
- };
- updateSend(urls,urlParams,operateUrl,operateParams,update_url,updateParams,"修改报表",stat,type);
- }
- function updateSend(url,params,operateUrl,operateParams,update_url,updateParams,msg,stat,type){
- $.ajax({
- url : url,
- type : 'post',
- timeout : 15000,
- async: false,
- data:params,
- dataType : 'json',
- success : function(data) {
- if(data.Msg.sucsess==true){
- updateOperate(operateUrl,operateParams);
- updateOperate(update_url,updateParams);
- var typeChange=type;
- if(comp_level=="2"){
- typeChange = "101";
- }
- var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getChildHzReport";
- $.ajax({
- url : urls,
- type : 'post',
- timeout : 15000,
- async : false,
- data : {
- comp_id:corp_id,
- report_type:typeChange,
- flag:deptFlag,
- roleId:role_id
-
- },
- dataType : 'json',
- success : function(data) {
- gridData.options.data = data;
- gridData.loadData();
- top.document.getElementById("frmright").contentWindow.$(".company").addClass("company-text");
- top.document.getElementById("frmright").contentWindow.$(".company").hover(function(){$(this).addClass("company-hover");},function(){$(this).removeClass("company-hover");});
- top.document.getElementById("frmright").contentWindow.$(".company").attr("title","可编辑数据");
- },
- error : function(e) {
- $.messager.alert('汇总下级数据失败!', '访问服务失败!', 'error');
- }
- });
- top.Dialog.alert(msg+"成功");
- top.document.getElementById("frmright").contentWindow.$("#hzxjsj").click();
- $(parent.document.body).find("#_ButtonClose_0fk").click();
- }else{
- top.Dialog.alert(msg+"失败");
- }
- },
- error : function(e) {
- $.messager.alert('修改失败!', '访问服务失败!', 'error');
- }
- });
- }
-
- function _addStatus(rowdata, rowindex, value, column){
- if(value=='总计'){
- return "<div style='background-color: #f2f2f2'>"+value+"</div>";
- }else{
- return "<div style='background-color: #dde5f0'>"+value+"</div>";
- }
- }
- //获取数据
- function operation (rowdata, rowindex, value){
- var h = "";
- if (!rowdata._editing)
- {
- flag1=false;
- h +="<a onclick='beginEdit(" + rowindex + ")'><span class='icon_edit'>修改</span></a>";
- h += "<a onclick='onDelete(" + rowindex + ")'><span class='icon_delete'>删除</span></a> ";
- }
- else
- {
- flag1=true;
- h += "<a onclick='endEdits(" + rowindex + ")'><span class='icon_ok'>确认</span></a> ";
- h += "<a onclick='onDelete(" + rowindex + ","+JSON.stringify(rowdata)+")'><span class='icon_delete'>取消</span></a> ";
- }
- return h;
- }
- //删除
- function onDelete(rowidx,rowdata){
- if(rowidx!=editingRow && flag1==true){
- top.Dialog.alert("请先完成当前记录的编辑!");
- return false;
- }
- top.Dialog.confirm("确定要删除该记录吗?",function(){
- isValida=false;
- flag1=false;
- g.endEdit(rowidx);
- //删除记录
- if(rowidx==0){
- checkRowObj = false;
- }
- var row = g.getRow(rowidx);
- g.deleteRow(row);
- });
- }
- //编辑
- function beginEdit(rowid) {
- if(flag1){
- top.Dialog.alert("请先完成正在编辑的一行!");
- return;
- //is_edit = true;
- }else{
- g.beginEdit(rowid);
- }
- }
- //取消编辑
- function cancelEdit(rowid) {
- g.cancelEdit(rowid);
- }
-
- //编辑后事件
- function onAfterSubmitEdit(e){
- isNew=false;
- }
- function onBeforeSubmitEdit(e){
- if(isValida && report_type=='2'){
- if(e.newdata.DYDJ == ""){
- top.Dialog.alert("电压等级不能为空");
- return false;
- }
-
- if(e.newdata.BDZMC=="" || validateInput(e.newdata.BDZMC, "^[\" \"]+$")){
- top.Dialog.alert("变电站名称不能为空");
- return false;
- }
-
- if(e.newdata.SFYHF==""){
- top.Dialog.alert("是否已恢复不能为空");
- return false;
- }
-
- if(e.newdata.SFYHF!=""){
- if(e.newdata.SFYHF=="是"){
- if(e.newdata.HFSJ=="" || validateInput(e.newdata.HFSJ, "^[\" \"]+$")){
- top.Dialog.alert("是否已恢复为是,请输入恢复时间");
- return false;
- }
- }
- }
-
- if(e.newdata.TYSJ=="" || validateInput(e.newdata.TYSJ, "^[\" \"]+$")){
- top.Dialog.alert("停运时间不能为空");
- return false;
- }
- if(e.newdata.HFSJ!=""){
- var endTime = e.newdata.HFSJ.replace(new RegExp("-","gm"),"/");
- var startTime = e.newdata.TYSJ.replace(new RegExp("-","gm"),"/");
- if(new Date(startTime).getTime()>new Date(endTime).getTime()){
- top.Dialog.alert("停运时间不能大于恢复时间");
- return false;
- }
- }
- }
- isValida = true;
- }
- var checkRowObj = false;
- //结束编辑
- function endEdits(rowid){
- var textInput = $(".l-grid-body-table").find("input[type='text']");
- var checkNum = 0;
- var len = textInput.length;
- for(var i=0;i<len;i++){
- if( textInput.eq(i).val()=="" || textInput.eq(i).val()=="请选择"){
- checkNum++;
- }
-
- }
- if(checkNum==len){
- if(rowid>0){
- top.Dialog.confirm("不在首行的数据如果为空将会被删除,是否执行?",function(){
- g.endEdit(rowid);
- var rowObj = g.getRow(rowid);
- g.deleteRow(rowObj);
- });
- }
-
- if(rowid==0){
- checkRowObj = true;
- g.endEdit(rowid);
- }
- }else if(len>checkNum ){
- checkRowObj = false;
- g.endEdit(rowid);
- }
-
- }
- //新增
- var num2=0;
- function addUser(){
- if(flag1){
- top.Dialog.alert("请先完成当前记录的编辑!");
- return false;
- }
- // 新增前判断首行是否为空
- if (report_type != '7') {
- var textInput = $("#maingrid").find(".l-grid2").find(".l-grid-body-inner").find("tbody").find("tr");
- if (textInput.eq(0).text().trim() == "修改删除") {
- checkRowObj = true;
- }
- }
- //checkRowObj 判断首行是否有空数据
- if (checkRowObj) {
- top.Dialog.alert("首行数据为空,不能继续添加");
- return false;
- }
- editingRow = 0;
- isNew = true;
- var row = g.getRow(0);
- var rowData={duty_way:0, COMP_ID : comp_id, COMP_NAME : comp_name};
- g.addEditRow(rowData, row, true);
- num2++;
- if ($("#maingrid").height() < 400) {
- g.setOptions({
- height : "400px"
- });
- g.resetHeight();
- } else {
- g.setOptions({
- height : "auto"
- });
- g.resetHeight();
- }
- setHight();
- }
-
- /**
- * appearStat--true:该行数据是上报数据,可以点"修改"按钮进行修改数据
- * appearStat--false:该行数据是未上报数据,代填、催报、修改(代填没有上报的数据,可以再次修改)。区分:代填---该行没有数据,修改---该行有数据
- * dataFlag--true:有数据
- * dataFlag--false:没有数据
- */
- function backspace(rowdata, rowindex, value) {
- var h = "";
- if(rowdata.COMP_NAME != "总计"){
- if(rowdata.appearStat=="true"){
- h += "<a onclick='modifyData(" + rowindex+")'><span class='icon_edit'>修改</span></a>";
- h += "<a onclick='rollback(" + rowindex+")'><span class='retract_tem'>回退</span></a>";
- }else if(rowdata.appearStat=="false"){
- if (!rowdata._editing && rowdata.dataFlag=="false") {
- h += "<a onclick='proxyWrite(" + rowindex + ")'><span class='icon_edit'>代填</span></a>";
- h += "<a onclick='urgeReport(" + rowindex + ")'><span class='sendmsg_tem'>催报</span></a> ";
- }else if(!rowdata._editing && rowdata.dataFlag=="true"){
- h += "<a onclick='modifyData(" + rowindex+")'><span class='icon_edit'>修改</span></a>";
- }else{
- h += "<a onclick='saveRowData(" + rowindex + ")'><span class='icon_ok'>保存</span></a> ";
- h += "<a onclick='cancelRow(" + rowindex + ")'><span class='icon_delete'>取消</span></a> ";
- }
- }
- }
- return h;
- }
- //退回
- function rollback(rowindex) {
- var row = g.getRow(rowindex);
- var fdId = row.REPORT_ID;//记录id
- var writeName = row.REAL_NAME;
- var writeMobile = row.MOBILE;
- var stat = row.appearStat;
- if (stat=="true") {
- rollbackInfo(fdId,writeName,writeMobile);
- } else {
- top.Dialog.alert("该记录无法回退!");
- return;
- }
- }
- //修改
- function modifyData(rowindex){
- var rowdata = g.getRow(rowindex);
- if(rowdata.appearStat=="true"){//修改别人上报的数据
- rowNumArr.push(rowindex);
- rowdata._editing = true;// 设置为可编辑状态
- g.reRender({ rowdata: rowdata });
- }else{
- rowNumArr.push(rowindex);
- rowdata._editing = true;// 设置为可编辑状态
- g.reRender({ rowdata: rowdata });
- }
- }
- // 代填
- function proxyWrite(rowindex){
- var rowdata = g.getRow(rowindex);
- //判断当前时间点是否有填报任务----没有任务也可以填报,记录表中不保存任务id
- var url = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getReportWriteTask";
- var params = {
- "report_type" : report_type,
- "affair" : affair_type,
- "comp_id" : comp_id,
- "role_id" : role_id,
- "data" : JSON.stringify(rowdata)
- };
- var task_id = "";
- var task_name = "";
- var task_time = "";
- $.ajax({
- url : url,
- type : "post",
- data : params,
- dataType : "json",
- async : false,
- success : function(result){
- console.log("代填任务:"+JSON.stringify(result));
- if(result.length>0){
- for(var i in result){
- var data = result[i];
- task_id += data.key+",";
- task_name += data.value+",";
- task_time += data.time+",";
- }
- task_id = task_id.substring(0, task_name.lastIndexOf(","));
- task_name = task_name.substring(0, task_name.lastIndexOf(","));
- task_time = task_time.substring(0, task_time.lastIndexOf(","));
- console.log("代填任务id:"+task_id+";任务名称:"+task_name+";任务时间:"+task_time);
- }
- },
- error : function(){
- $.messager.alert('查询报表任务失败!', '访问服务失败!', 'error');
- }
- });
- rowNumArr.push(rowindex);
- rowdata.TASK_ID = task_id;// 任务id
- rowdata.TASK_NAME = task_name;// 任务名称
- rowdata.TASK_TIME = task_time;
- rowdata._editing = true;// 设置为可编辑状态
- g.reRender({ rowdata: rowdata });
- }
- // 催报
- function urgeReport(rowindex){
- var rowdata = g.getRow(rowindex);
- var url = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/urgeReport";
- var params = {
- "comp_id" : comp_id,
- "role_id" : role_id,
- "report_type" : report_type,
- "affair" : affair_type,
- "data" : JSON.stringify(rowdata)
- };
- $.ajax({
- url : url,
- type : "post",
- data : params,
- dataType : "json",
- success : function(data){
- console.log("催报:"+JSON.stringify(data));
- if(data.Msg.sucsess==true){
- if(data.Msg.data==null){
- top.Dialog.alert(data.Msg.info);//没有催报人员
- }else{
- var name = data.Msg.data.split("&")[0];
- var phone = data.Msg.data.split("&")[1];
- var nameText = data.Msg.data.split("&")[2];//计划
- var wtTime = data.Msg.data.split("&")[3];//填报时间
- addMsg(name,phone,'您好,'+nameText+'计划中的'+mycol1+'在'+wtTime+"填报时间段还没有上报,请您尽快登陆系统进行填写上报");
- }
- }else{
- top.Dialog.alert(data.Msg.info);//当前没有任务
- }
- },
- error : function(){
- $.messager.alert('报表催报失败!', '访问服务失败!', 'error');
- }
- });
- }
- //保存填写的数据
- function saveRowData(rowindex){
- rowNumArr.pop(rowindex);
- var rowdata = g.getRow(rowindex);
- rowdata.USER_ID = user_id;// 用户id
- rowdata.REAL_NAME = real_name;// 用户名
- rowdata.MOBILE = mobile;// 电话
- //保存数据(没有保存入库)
- rowdata.appearStat = "false";
- rowdata.dataFlag = "true";// 将数据状态设置为有数据
- delete rowdata['_editing'];//设置为不可编辑状态
- g.reRender({ rowdata: rowdata });
- }
- //取消填写的数据
- function cancelRow(rowindex){
- g.endEdit();
- rowNumArr.pop(rowindex);
- var rowdata = g.getRow(rowindex);
- var size = g.getData().length;
- var zjRowdata = g.getRow(size-1);//总计行
- var columns = g.columns;
- for(var i=0;i<columns.length;i++){
- if(!columns[i].name){continue;}
- if(columns[i].name=="COMP_NAME" || columns[i].name=="FD_OBJECTID"){continue;}
- // if(!rowdata[columns[i].name]){continue;}
- //rowdata[columns[i].name]==0时也为false
- if(rowdata[columns[i].name]===undefined || rowdata[columns[i].name]===""){continue;}
- if(columns[i].isCount=="0"){//统计列
- console.log(zjRowdata[columns[i].name]);
- var num = getZjResult(zjRowdata[columns[i].name], "0", rowdata[columns[i].name]);
- zjRowdata[columns[i].name] = num;
- }
- delete rowdata[columns[i].name];
- }
- rowdata.dataFlag = "false";// 将数据状态设置为没有数据
- delete rowdata['_editing'];//设置为不可编辑状态
- g.reRender({ rowdata: rowdata });
- //更新总计行数据
- g.updateRow(size - 1, zjRowdata);
- }
-
|