a60675961c1419ab83cbe36d745ef208ab0f9481.svn-base 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. var flag1 = false;
  2. var real_name = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  3. var corpName =top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
  4. var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
  5. var loginName = top.com.sinosoft.lz.system.user.LoginInfo.getLogin_name();
  6. var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  7. var real_name = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  8. var mobile = top.com.sinosoft.lz.system.user.LoginInfo.getMobile();
  9. var editingRow = "";
  10. var isValida=true;
  11. var dydj = {"list":[
  12. {"value":"500kV","key":"500kV"},
  13. {"value":"220kV","key":"220kV"},
  14. {"value":"110kV","key":"110kV"},
  15. {"value":"35kV","key":"35kV"}
  16. ]};
  17. var huifu = {"list":[
  18. {"value":"是","key":"是"},
  19. {"value":"否","key":"否"}
  20. ]};
  21. //数据表格
  22. var g;
  23. var mycol;
  24. var mycol1;
  25. var testdata;
  26. var flag = false;
  27. var url = decodeURI(window.location.href);
  28. //报表类型
  29. var report_type;
  30. //报表对应的角色id
  31. var role_id;
  32. //单位id
  33. var comp_id;
  34. var comp_name;
  35. //事件类型
  36. var affair_type;
  37. //事件类型名称
  38. var affair_name;
  39. //记录ID
  40. var fd_objectid;
  41. //判断是否有操作列,该页面默认都有操作列
  42. var rollbackFlag = true;
  43. //该变量用于保存可编辑的行号
  44. var rowNumArr = [];
  45. var update_url= $.pathname() + "/ws/xianlutingyun/XianlutingyunService/updateStat";
  46. function showData(type,comp,name,role,affair,affairType,alert_id){
  47. report_type = type=="101"?"2":type;
  48. role_id = role;
  49. comp_id = comp;
  50. comp_name = name;
  51. affair_type = affair;
  52. affair_name = affairType;
  53. fd_objectid = alert_id;
  54. //加载表格
  55. init();
  56. getColumns();
  57. $("#add").text("修改"+comp_name+mycol1);
  58. $("#affair").text(affairType);
  59. //若该单位已上报数据
  60. if(""==fd_objectid){
  61. //自动汇总下级单位对应填报节点的数据,避免将下级
  62. getInitialData();
  63. }else{
  64. getData();
  65. }
  66. addRequire(report_type);
  67. }
  68. function init(){
  69. g = null;
  70. if(report_type=='2'){
  71. g = $("#maingrid").quiGrid({
  72. columns : [],
  73. data : [],
  74. usePager : false,
  75. sortName: 'id',
  76. rownumbers:true,
  77. enabledEdit: true, //编辑用
  78. width:"100%",
  79. multihead:true,
  80. enabledSort:false,
  81. excelMode:true,
  82. alternatingRow:false,
  83. enabledEdit: true,
  84. clickToEdit: false,
  85. toolbar:{
  86. items:[
  87. { text: '新增', click: addUser, iconClass: 'add1_tem' },
  88. { line: true }
  89. ]
  90. },
  91. onAfterSubmitEdit: onAfterSubmitEdit,
  92. onBeforeSubmitEdit : onBeforeSubmitEdit,
  93. onAfterEdit : onAfterEdit,
  94. onBeforeEdit: onBeforeEdit
  95. });
  96. }else{
  97. g = $("#maingrid").quiGrid({
  98. columns : [],
  99. data : [],
  100. usePager : false,
  101. sortName : 'id',
  102. rownumbers : true,
  103. enabledEdit : true, //编辑用
  104. width : "100%",
  105. multihead : true,
  106. enabledSort : false,
  107. excelMode : true,
  108. alternatingRow : false,
  109. onAfterEdit : onAfterEdit,
  110. onBeforeEdit : onBeforeEdit
  111. });
  112. }
  113. if ($("#maingrid").height() < 400) {
  114. g.setOptions({
  115. height : "400px"
  116. });
  117. g.resetHeight();
  118. } else {
  119. g.setOptions({
  120. height : "auto"
  121. });
  122. g.resetHeight();
  123. }
  124. setHight();
  125. }
  126. //获取表头
  127. function getColumns(){
  128. if(report_type!="100"){
  129. var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getEditColumns";
  130. $.ajax({
  131. url : urls,
  132. type : 'post',
  133. async : false,
  134. data : {
  135. "affair" : affair_type,
  136. "report_type" : report_type,
  137. "comp_id" : comp_id,
  138. //没有下级填报单位也需要操作列,局本部也需要代填
  139. "rollbackFlag" : "true"
  140. },
  141. dataType : 'text',
  142. success : function(data) {
  143. mycol =eval('('+ data+')');
  144. mycol1=eval('('+data+')')[0].display;
  145. },
  146. error : function(e) {
  147. $.messager.alert('查询表头失败!', '访问服务失败!', 'error');
  148. }
  149. });
  150. }
  151. }
  152. function getData(){
  153. $("body").eq(0).showLoading();
  154. var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/query";
  155. $.ajax({
  156. url : urls,
  157. type : 'post',
  158. timeout : 15000,
  159. data:{
  160. report_id : fd_objectid,
  161. comp_id : comp_id,
  162. report_type : report_type,
  163. roleId:role_id
  164. },
  165. dataType : 'json',
  166. success : function(data) {
  167. testdata = data;
  168. $("body").eq(0).hideLoading();
  169. },
  170. error : function(e) {
  171. $.messager.alert('查询数据失败!', '访问服务失败!', 'error');
  172. }
  173. });
  174. }
  175. function getInitialData() {
  176. var urls = $.pathname() + "/ws/baoBiao/BaoBiaoService/getInitialData";
  177. $.ajax({
  178. url : urls,
  179. type : 'post',
  180. async : false,
  181. data : {
  182. comp_id : comp_id,
  183. comp_name : comp_name,
  184. report_type : report_type,
  185. role_id : role_id,
  186. affair : affair_type
  187. },
  188. dataType : 'json',
  189. success : function(data) {
  190. g.setOptions({columns:mycol,data:data});
  191. },
  192. error : function(e) {
  193. $.messager.alert('查询行失败!', '访问服务失败!', 'error');
  194. }
  195. });
  196. }
  197. //根据type加载要求
  198. function addRequire(type){
  199. if(type=="1"){
  200. $("#requires").append("<span>① 单位:受灾地市局</span> &nbsp;<br>" +
  201. "<span>② 跳闸停电(条数):相应电压等级线路跳闸的总条数,不包含重合闸成功的跳闸线路条数,且同一条线路多次跳闸,只统计为一个跳闸条数。</span><br>"+
  202. "<span>③ 未恢复:填写相应电压等级线路跳闸后,未恢复成热备用状态的线路条数。</span><br>"+
  203. "<span>④ 累计跳闸(条次):相应电压等级线路跳闸的总条次数,包含重合闸成功的跳闸线路条数,且同一条线路多次跳闸,统计为多个跳闸条次数。</span><br>"+
  204. "<span>⑤ 备注:填写未恢复线路名称。</span><br>"+
  205. "<span>⑥ 损失负荷:电网因灾损失的负荷数。电网发生故障后,在线路重合闸及备用电源自投装置动作完成后系统未恢复的负荷,包括电网减供负荷和低压脱扣负荷。</span><br>"+
  206. "<span>⑦ 损失占比:损失负荷数占同期电网应有负荷的百分比。</span>");
  207. }
  208. else if(type=="2"){
  209. $("#requires").append("<span>① 单位:受灾地市局</span><br>"+
  210. "<span>② 累计停运(座):灾害过程中发生停运变电站的总座数。</span><br>"+
  211. "<span>③ 未恢复(座):截止当前时间未恢复变电站的总座数。</span><br>"+
  212. "<span>④ 备注:发生停运事件的变电站名称及目前状态。例如:XX变电站(已恢复/未恢复)</span>"
  213. );
  214. }
  215. else if(type=="3"){
  216. $("#requires").append("<span>① 单位:受灾地市局。</span><br>"+
  217. "<span>② 备注:台风登陆期间不用填报。</span><br>"
  218. /*"<span>② 备注:台风登陆期间不用填报。</span><br>"+
  219. "<span>③ 其他信息填写说明如下:</span>"*/
  220. );
  221. }
  222. else if(type=="4"){
  223. $("#requires").append("<span>① 单位:受灾地市局</span><br>"+
  224. "<span>② 线路受损:按单相导路(地线)受损长度统计,统计距离为断线或者整条线路损毁时的档距。</span><br>"+
  225. "<span>③ 线路未恢复:截至当前仍未修复的受损线路长度。</span><br>"+
  226. "<span>④ 配变受损:发生损害需要修复或更换的配变台数。</span><br>"+
  227. "<span>⑤ 配变未恢复:截至当前仍未修复或更换的配变台数。</span><br>"+
  228. "<span>⑥ 备注:台风登陆期间不用填报。</span>"
  229. );
  230. }
  231. else if(type=="5"){
  232. $("#requires").append("<span>① 单位:受灾地市局。</span><br>"+
  233. "<span>② 台区:一个配变所供负荷区域计作一个台区。</span><br>"+
  234. "<span>③ 用户数:1)线路重复跳闸时客户停电户数不累加统计,即线路重复跳闸时,停电户数只统计一次。2)线路跳闸重合成功的客户数不统计。</span><br>"+
  235. "<span>④ 未恢复数:因灾发生停电的用户截至当前还未恢复供电的用户数。</span><br>"+
  236. "<span>⑤停电占比:停电占比=停电台区(用户)数÷当地台区(用户)总数。</span><br>"+
  237. "<span>⑥损失电量:灾害期间损失电量的总数。</span>");
  238. }
  239. else if(type=="6"){
  240. $("#requires").append("<span>① 单位:受灾地市局。</span><br>"+
  241. "<span>② 累计全停:灾害发生以来发生全县(区)、全乡镇、全行政村全停的个数。</span><br>"+
  242. "<span>③ 当前全停:当前仍存在全县(区)、全乡镇、全行政村全停的个数。</span><br>"+
  243. "<span>④ 备注:台风登陆期间不用填报。</span>"
  244. );
  245. }
  246. else if(type=="7"){
  247. $("#requires").append("<span>① 单位名称:公司、受灾地市局。</span><br>"+
  248. "<span>② 本单位预警或响应级别:防风防汛X色预警,防风防汛X级响应。</span><br>" +
  249. "<span>③ 同级政府相关部门名称:例如XX省防总等。</span><br>"+
  250. "<span>④ 同级政府相关部门预警或响应级别:防风防汛X色预警,防风防汛X级响应。</span><br>"+
  251. "<span>⑤ 开始时间:例如,9月9日9时30分。</span><br>"+
  252. "<span>⑥ 结束时间:例如,9月9日9时30分。当处于预警发布或响应启动状态时,结束时间可保持为空。</span><br>"+
  253. "<span>⑦ 备注:台风登陆期间不用填报。</span>"
  254. );
  255. }
  256. else if(type=="8"){
  257. $("#requires").append("<span>① 单位名称:受灾地市局。</span><br>"+
  258. "<span>② 抢修人员:填写当日投入抢修人数的最大值。</span><br>"+
  259. "<span>③ 抢修车辆:填写当日投入抢修车辆数的最大值。</span><br>"+
  260. "<span>④ 应急发电车:填写当日投入应急发电车数量的最大值。</span><br>"+
  261. "<span>⑤ 应急发电机:填写当日投入应急发电机数量的最大值。</span><br>"+
  262. "<span>⑥ 备注:台风登陆期间不用填报。</span>"
  263. );
  264. }else {
  265. $("#requires").hide();
  266. }
  267. }
  268. var oldVal;
  269. function onBeforeEdit(e){
  270. if($.inArray(e.rowindex,rowNumArr)==-1){
  271. return false;
  272. }
  273. if(e.column["columnname"]=="SWRYMXB_TJ"&&report_type=="10"){
  274. top.Dialog.alert("此列不能编辑",null,null,null,-1);
  275. return false;
  276. }
  277. if(e.value!=null&&e.value!=""){
  278. oldVal = e.value;
  279. }else{
  280. oldVal = 0;
  281. }
  282. }
  283. var num1 = 0;
  284. function onAfterEdit(e){
  285. var size=g.getData().length;
  286. if(e.value==null||e.value==""){
  287. e.value="0";
  288. flag = false;
  289. }
  290. if(e.value!=null&&e.value!=""&&e.value!="0"){
  291. //判断该单元格是否有值
  292. flag = true;
  293. }
  294. if(report_type=="10"){
  295. var RowObj= (g.getRow(e["record"]["__id"]));
  296. var count = RowObj["SWRYMXB_TJ"]==""||RowObj["SWRYMXB_TJ"]==undefined||RowObj["SWRYMXB_TJ"]=="undefined"?"0":RowObj["SWRYMXB_TJ"];
  297. var oldCount = count;
  298. count = parseInt(count,10)+parseInt(e.value,10)-parseInt(oldVal,10);
  299. g.updateCell("SWRYMXB_TJ",count,RowObj);
  300. var lastTj = g.getRow(size-1)["SWRYMXB_TJ"]==""?"0":g.getRow(size-1)["SWRYMXB_TJ"] ;
  301. g.getRow(size-1)["SWRYMXB_TJ"] = parseInt(lastTj,10)+parseInt(count,10)-oldCount;
  302. }
  303. var updatecolumn = e.column.name;
  304. var isCount = e.column.isCount;//非统计字段不需要更新总计值
  305. var row = g.getRow(size - 1);//总计行
  306. var row1 = g.getRow(e.rowindex);//编辑行
  307. row1[updatecolumn] = parseFloat(e.value);
  308. g.updateRow(e.rowindex, row1);
  309. if(isCount=='0'){
  310. num1 = g.getRow(size - 1)[updatecolumn] == "" || g.getRow(size - 1)[updatecolumn] == undefined ? "0" : g.getRow(size - 1)[updatecolumn];
  311. num1 = getZjResult(num1, e.value, oldVal);
  312. row[updatecolumn] = num1;
  313. g.updateRow(size - 1, row);
  314. }
  315. }
  316. function getZjResult(arg1, arg2, arg3) {
  317. var r1, r2, r3, m, n;
  318. try {
  319. r1 = arg1.toString().split(".")[1].length;
  320. } catch (e) {
  321. r1 = 0;
  322. }
  323. try {
  324. r2 = arg2.toString().split(".")[1].length;
  325. } catch (e) {
  326. r2 = 0;
  327. }
  328. try {
  329. r3 = arg3.toString().split(".")[1].length;
  330. } catch (e) {
  331. r3 = 0;
  332. }
  333. m = Math.pow(10, Math.max(r1, r2, r3));
  334. // 动态控制精度长度
  335. n = Math.max(r1, r2, r3);
  336. return ((arg1 * m + arg2 * m - arg3 * m) / m).toFixed(n);
  337. }
  338. //监听回车
  339. function checkKeyCode(event){
  340. if(event.keyCode==13){
  341. g.endEdit();
  342. }
  343. }
  344. function save(){
  345. flag = false;
  346. g.endEdit();
  347. //查询当前时间的被代填单位是否有报表任务
  348. var planUrl = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getReportPlanTask";
  349. $.ajax({
  350. url : planUrl,
  351. type : "post",
  352. data : {"report_type":report_type,"affair":affair,"comp_id":compId,"dept_id":deptId,"role_id":role_id,"deptFlag":deptFlag},
  353. dataType : "json",
  354. async : false,
  355. success : function(result){
  356. if(result.length>0){
  357. fdIds = "";
  358. plan_name = "";
  359. times = "";
  360. for(var i in result){
  361. var data = result[i];
  362. fdIds += data.key+",";
  363. plan_name += data.value+",";
  364. times += data.time+",";
  365. }
  366. fdIds = fdIds.substring(0, fdIds.lastIndexOf(","));
  367. plan_name = plan_name.substring(0, plan_name.lastIndexOf(","));
  368. times = times.substring(0, times.lastIndexOf(","));
  369. console.log("新增当前任务id:"+fdIds+";当前任务名称:"+plan_name+";当前填报时间:"+times);
  370. }else{
  371. draftWrite = "true";//作为草稿,不能上报
  372. times = report_time==""?"":getServerTime().split(" ")[0]+" "+report_time;
  373. }
  374. },
  375. error : function(){
  376. $.messager.alert('查询报表任务失败!', '访问服务失败!', 'error');
  377. }
  378. });
  379. var json = JSON.stringify(g.getData());
  380. saveTable(json,fd_objectid,report_type);
  381. }
  382. function saveTable(json,fd_objectid,report_type){
  383. var urls = $.pathname() + "/ws/baoBiao/BaoBiaoService/update";
  384. var operateUrl = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/updateOperate";
  385. var updateParams = {fd_id:fd_objectid,check:"end",table:"report_records"};
  386. var operateParams = {name:real_name,fd_id:fd_id,report_comp:corpName+deptName,sendStat:"alert","operate":"修改了"};
  387. var urlParams = {
  388. json : json,
  389. fd_id : fd_objectid,
  390. report_type : report_type,
  391. comp_id : comp_id
  392. };
  393. updateSend(urls,urlParams,operateUrl,operateParams,update_url,updateParams,"修改报表",stat,type);
  394. }
  395. function updateSend(url,params,operateUrl,operateParams,update_url,updateParams,msg,stat,type){
  396. $.ajax({
  397. url : url,
  398. type : 'post',
  399. timeout : 15000,
  400. async: false,
  401. data:params,
  402. dataType : 'json',
  403. success : function(data) {
  404. if(data.Msg.sucsess==true){
  405. updateOperate(operateUrl,operateParams);
  406. updateOperate(update_url,updateParams);
  407. var typeChange=type;
  408. if(comp_level=="2"){
  409. typeChange = "101";
  410. }
  411. var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getChildHzReport";
  412. $.ajax({
  413. url : urls,
  414. type : 'post',
  415. timeout : 15000,
  416. async : false,
  417. data : {
  418. comp_id:corp_id,
  419. report_type:typeChange,
  420. flag:deptFlag,
  421. roleId:role_id
  422. },
  423. dataType : 'json',
  424. success : function(data) {
  425. gridData.options.data = data;
  426. gridData.loadData();
  427. top.document.getElementById("frmright").contentWindow.$(".company").addClass("company-text");
  428. top.document.getElementById("frmright").contentWindow.$(".company").hover(function(){$(this).addClass("company-hover");},function(){$(this).removeClass("company-hover");});
  429. top.document.getElementById("frmright").contentWindow.$(".company").attr("title","可编辑数据");
  430. },
  431. error : function(e) {
  432. $.messager.alert('汇总下级数据失败!', '访问服务失败!', 'error');
  433. }
  434. });
  435. top.Dialog.alert(msg+"成功");
  436. top.document.getElementById("frmright").contentWindow.$("#hzxjsj").click();
  437. $(parent.document.body).find("#_ButtonClose_0fk").click();
  438. }else{
  439. top.Dialog.alert(msg+"失败");
  440. }
  441. },
  442. error : function(e) {
  443. $.messager.alert('修改失败!', '访问服务失败!', 'error');
  444. }
  445. });
  446. }
  447. function _addStatus(rowdata, rowindex, value, column){
  448. if(value=='总计'){
  449. return "<div style='background-color: #f2f2f2'>"+value+"</div>";
  450. }else{
  451. return "<div style='background-color: #dde5f0'>"+value+"</div>";
  452. }
  453. }
  454. //获取数据
  455. function operation (rowdata, rowindex, value){
  456. var h = "";
  457. if (!rowdata._editing)
  458. {
  459. flag1=false;
  460. h +="<a onclick='beginEdit(" + rowindex + ")'><span class='icon_edit'>修改</span></a>";
  461. h += "<a onclick='onDelete(" + rowindex + ")'><span class='icon_delete'>删除</span></a> ";
  462. }
  463. else
  464. {
  465. flag1=true;
  466. h += "<a onclick='endEdits(" + rowindex + ")'><span class='icon_ok'>确认</span></a> ";
  467. h += "<a onclick='onDelete(" + rowindex + ","+JSON.stringify(rowdata)+")'><span class='icon_delete'>取消</span></a> ";
  468. }
  469. return h;
  470. }
  471. //删除
  472. function onDelete(rowidx,rowdata){
  473. if(rowidx!=editingRow && flag1==true){
  474. top.Dialog.alert("请先完成当前记录的编辑!");
  475. return false;
  476. }
  477. top.Dialog.confirm("确定要删除该记录吗?",function(){
  478. isValida=false;
  479. flag1=false;
  480. g.endEdit(rowidx);
  481. //删除记录
  482. if(rowidx==0){
  483. checkRowObj = false;
  484. }
  485. var row = g.getRow(rowidx);
  486. g.deleteRow(row);
  487. });
  488. }
  489. //编辑
  490. function beginEdit(rowid) {
  491. if(flag1){
  492. top.Dialog.alert("请先完成正在编辑的一行!");
  493. return;
  494. //is_edit = true;
  495. }else{
  496. g.beginEdit(rowid);
  497. }
  498. }
  499. //取消编辑
  500. function cancelEdit(rowid) {
  501. g.cancelEdit(rowid);
  502. }
  503. //编辑后事件
  504. function onAfterSubmitEdit(e){
  505. isNew=false;
  506. }
  507. function onBeforeSubmitEdit(e){
  508. if(isValida && report_type=='2'){
  509. if(e.newdata.DYDJ == ""){
  510. top.Dialog.alert("电压等级不能为空");
  511. return false;
  512. }
  513. if(e.newdata.BDZMC=="" || validateInput(e.newdata.BDZMC, "^[\" \"]+$")){
  514. top.Dialog.alert("变电站名称不能为空");
  515. return false;
  516. }
  517. if(e.newdata.SFYHF==""){
  518. top.Dialog.alert("是否已恢复不能为空");
  519. return false;
  520. }
  521. if(e.newdata.SFYHF!=""){
  522. if(e.newdata.SFYHF=="是"){
  523. if(e.newdata.HFSJ=="" || validateInput(e.newdata.HFSJ, "^[\" \"]+$")){
  524. top.Dialog.alert("是否已恢复为是,请输入恢复时间");
  525. return false;
  526. }
  527. }
  528. }
  529. if(e.newdata.TYSJ=="" || validateInput(e.newdata.TYSJ, "^[\" \"]+$")){
  530. top.Dialog.alert("停运时间不能为空");
  531. return false;
  532. }
  533. if(e.newdata.HFSJ!=""){
  534. var endTime = e.newdata.HFSJ.replace(new RegExp("-","gm"),"/");
  535. var startTime = e.newdata.TYSJ.replace(new RegExp("-","gm"),"/");
  536. if(new Date(startTime).getTime()>new Date(endTime).getTime()){
  537. top.Dialog.alert("停运时间不能大于恢复时间");
  538. return false;
  539. }
  540. }
  541. }
  542. isValida = true;
  543. }
  544. var checkRowObj = false;
  545. //结束编辑
  546. function endEdits(rowid){
  547. var textInput = $(".l-grid-body-table").find("input[type='text']");
  548. var checkNum = 0;
  549. var len = textInput.length;
  550. for(var i=0;i<len;i++){
  551. if( textInput.eq(i).val()=="" || textInput.eq(i).val()=="请选择"){
  552. checkNum++;
  553. }
  554. }
  555. if(checkNum==len){
  556. if(rowid>0){
  557. top.Dialog.confirm("不在首行的数据如果为空将会被删除,是否执行?",function(){
  558. g.endEdit(rowid);
  559. var rowObj = g.getRow(rowid);
  560. g.deleteRow(rowObj);
  561. });
  562. }
  563. if(rowid==0){
  564. checkRowObj = true;
  565. g.endEdit(rowid);
  566. }
  567. }else if(len>checkNum ){
  568. checkRowObj = false;
  569. g.endEdit(rowid);
  570. }
  571. }
  572. //新增
  573. var num2=0;
  574. function addUser(){
  575. if(flag1){
  576. top.Dialog.alert("请先完成当前记录的编辑!");
  577. return false;
  578. }
  579. // 新增前判断首行是否为空
  580. if (report_type != '7') {
  581. var textInput = $("#maingrid").find(".l-grid2").find(".l-grid-body-inner").find("tbody").find("tr");
  582. if (textInput.eq(0).text().trim() == "修改删除") {
  583. checkRowObj = true;
  584. }
  585. }
  586. //checkRowObj 判断首行是否有空数据
  587. if (checkRowObj) {
  588. top.Dialog.alert("首行数据为空,不能继续添加");
  589. return false;
  590. }
  591. editingRow = 0;
  592. isNew = true;
  593. var row = g.getRow(0);
  594. var rowData={duty_way:0, COMP_ID : comp_id, COMP_NAME : comp_name};
  595. g.addEditRow(rowData, row, true);
  596. num2++;
  597. if ($("#maingrid").height() < 400) {
  598. g.setOptions({
  599. height : "400px"
  600. });
  601. g.resetHeight();
  602. } else {
  603. g.setOptions({
  604. height : "auto"
  605. });
  606. g.resetHeight();
  607. }
  608. setHight();
  609. }
  610. /**
  611. * appearStat--true:该行数据是上报数据,可以点"修改"按钮进行修改数据
  612. * appearStat--false:该行数据是未上报数据,代填、催报、修改(代填没有上报的数据,可以再次修改)。区分:代填---该行没有数据,修改---该行有数据
  613. * dataFlag--true:有数据
  614. * dataFlag--false:没有数据
  615. */
  616. function backspace(rowdata, rowindex, value) {
  617. var h = "";
  618. if(rowdata.COMP_NAME != "总计"){
  619. if(rowdata.appearStat=="true"){
  620. h += "<a onclick='modifyData(" + rowindex+")'><span class='icon_edit'>修改</span></a>";
  621. h += "<a onclick='rollback(" + rowindex+")'><span class='retract_tem'>回退</span></a>";
  622. }else if(rowdata.appearStat=="false"){
  623. if (!rowdata._editing && rowdata.dataFlag=="false") {
  624. h += "<a onclick='proxyWrite(" + rowindex + ")'><span class='icon_edit'>代填</span></a>";
  625. h += "<a onclick='urgeReport(" + rowindex + ")'><span class='sendmsg_tem'>催报</span></a> ";
  626. }else if(!rowdata._editing && rowdata.dataFlag=="true"){
  627. h += "<a onclick='modifyData(" + rowindex+")'><span class='icon_edit'>修改</span></a>";
  628. }else{
  629. h += "<a onclick='saveRowData(" + rowindex + ")'><span class='icon_ok'>保存</span></a> ";
  630. h += "<a onclick='cancelRow(" + rowindex + ")'><span class='icon_delete'>取消</span></a> ";
  631. }
  632. }
  633. }
  634. return h;
  635. }
  636. //退回
  637. function rollback(rowindex) {
  638. var row = g.getRow(rowindex);
  639. var fdId = row.REPORT_ID;//记录id
  640. var writeName = row.REAL_NAME;
  641. var writeMobile = row.MOBILE;
  642. var stat = row.appearStat;
  643. if (stat=="true") {
  644. rollbackInfo(fdId,writeName,writeMobile);
  645. } else {
  646. top.Dialog.alert("该记录无法回退!");
  647. return;
  648. }
  649. }
  650. //修改
  651. function modifyData(rowindex){
  652. var rowdata = g.getRow(rowindex);
  653. if(rowdata.appearStat=="true"){//修改别人上报的数据
  654. rowNumArr.push(rowindex);
  655. rowdata._editing = true;// 设置为可编辑状态
  656. g.reRender({ rowdata: rowdata });
  657. }else{
  658. rowNumArr.push(rowindex);
  659. rowdata._editing = true;// 设置为可编辑状态
  660. g.reRender({ rowdata: rowdata });
  661. }
  662. }
  663. // 代填
  664. function proxyWrite(rowindex){
  665. var rowdata = g.getRow(rowindex);
  666. //判断当前时间点是否有填报任务----没有任务也可以填报,记录表中不保存任务id
  667. var url = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getReportWriteTask";
  668. var params = {
  669. "report_type" : report_type,
  670. "affair" : affair_type,
  671. "comp_id" : comp_id,
  672. "role_id" : role_id,
  673. "data" : JSON.stringify(rowdata)
  674. };
  675. var task_id = "";
  676. var task_name = "";
  677. var task_time = "";
  678. $.ajax({
  679. url : url,
  680. type : "post",
  681. data : params,
  682. dataType : "json",
  683. async : false,
  684. success : function(result){
  685. console.log("代填任务:"+JSON.stringify(result));
  686. if(result.length>0){
  687. for(var i in result){
  688. var data = result[i];
  689. task_id += data.key+",";
  690. task_name += data.value+",";
  691. task_time += data.time+",";
  692. }
  693. task_id = task_id.substring(0, task_name.lastIndexOf(","));
  694. task_name = task_name.substring(0, task_name.lastIndexOf(","));
  695. task_time = task_time.substring(0, task_time.lastIndexOf(","));
  696. console.log("代填任务id:"+task_id+";任务名称:"+task_name+";任务时间:"+task_time);
  697. }
  698. },
  699. error : function(){
  700. $.messager.alert('查询报表任务失败!', '访问服务失败!', 'error');
  701. }
  702. });
  703. rowNumArr.push(rowindex);
  704. rowdata.TASK_ID = task_id;// 任务id
  705. rowdata.TASK_NAME = task_name;// 任务名称
  706. rowdata.TASK_TIME = task_time;
  707. rowdata._editing = true;// 设置为可编辑状态
  708. g.reRender({ rowdata: rowdata });
  709. }
  710. // 催报
  711. function urgeReport(rowindex){
  712. var rowdata = g.getRow(rowindex);
  713. var url = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/urgeReport";
  714. var params = {
  715. "comp_id" : comp_id,
  716. "role_id" : role_id,
  717. "report_type" : report_type,
  718. "affair" : affair_type,
  719. "data" : JSON.stringify(rowdata)
  720. };
  721. $.ajax({
  722. url : url,
  723. type : "post",
  724. data : params,
  725. dataType : "json",
  726. success : function(data){
  727. console.log("催报:"+JSON.stringify(data));
  728. if(data.Msg.sucsess==true){
  729. if(data.Msg.data==null){
  730. top.Dialog.alert(data.Msg.info);//没有催报人员
  731. }else{
  732. var name = data.Msg.data.split("&")[0];
  733. var phone = data.Msg.data.split("&")[1];
  734. var nameText = data.Msg.data.split("&")[2];//计划
  735. var wtTime = data.Msg.data.split("&")[3];//填报时间
  736. addMsg(name,phone,'您好,'+nameText+'计划中的'+mycol1+'在'+wtTime+"填报时间段还没有上报,请您尽快登陆系统进行填写上报");
  737. }
  738. }else{
  739. top.Dialog.alert(data.Msg.info);//当前没有任务
  740. }
  741. },
  742. error : function(){
  743. $.messager.alert('报表催报失败!', '访问服务失败!', 'error');
  744. }
  745. });
  746. }
  747. //保存填写的数据
  748. function saveRowData(rowindex){
  749. rowNumArr.pop(rowindex);
  750. var rowdata = g.getRow(rowindex);
  751. rowdata.USER_ID = user_id;// 用户id
  752. rowdata.REAL_NAME = real_name;// 用户名
  753. rowdata.MOBILE = mobile;// 电话
  754. //保存数据(没有保存入库)
  755. rowdata.appearStat = "false";
  756. rowdata.dataFlag = "true";// 将数据状态设置为有数据
  757. delete rowdata['_editing'];//设置为不可编辑状态
  758. g.reRender({ rowdata: rowdata });
  759. }
  760. //取消填写的数据
  761. function cancelRow(rowindex){
  762. g.endEdit();
  763. rowNumArr.pop(rowindex);
  764. var rowdata = g.getRow(rowindex);
  765. var size = g.getData().length;
  766. var zjRowdata = g.getRow(size-1);//总计行
  767. var columns = g.columns;
  768. for(var i=0;i<columns.length;i++){
  769. if(!columns[i].name){continue;}
  770. if(columns[i].name=="COMP_NAME" || columns[i].name=="FD_OBJECTID"){continue;}
  771. // if(!rowdata[columns[i].name]){continue;}
  772. //rowdata[columns[i].name]==0时也为false
  773. if(rowdata[columns[i].name]===undefined || rowdata[columns[i].name]===""){continue;}
  774. if(columns[i].isCount=="0"){//统计列
  775. console.log(zjRowdata[columns[i].name]);
  776. var num = getZjResult(zjRowdata[columns[i].name], "0", rowdata[columns[i].name]);
  777. zjRowdata[columns[i].name] = num;
  778. }
  779. delete rowdata[columns[i].name];
  780. }
  781. rowdata.dataFlag = "false";// 将数据状态设置为没有数据
  782. delete rowdata['_editing'];//设置为不可编辑状态
  783. g.reRender({ rowdata: rowdata });
  784. //更新总计行数据
  785. g.updateRow(size - 1, zjRowdata);
  786. }