f70d9703473a62693b66eed7f1d9442871c42ffa.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  6. <title>保供电查询统计明细表</title>
  7. <!--引入QUI框架js -->
  8. <%@include file="list_add_need.jsp"%>
  9. <script type="text/javascript" src="<%=path%>/scripts/setiframeheight.js"></script>
  10. <script>
  11. var fd_id ="<%=request.getParameter("fd_id")%>";
  12. var listid=fd_id;
  13. var parentId = top.com.sinosoft.lz.system.user.LoginInfo.getParent_ids();
  14. var flag=false;
  15. var isNew=false; //是否是新增记录
  16. var isNewSave=true; //新增记录是否保存
  17. var editingRow; // 双击的当前编辑行
  18. var isValida=true; //是否需要验证
  19. var g;
  20. function initComplete(){
  21. $("#fd_objectid").val(fd_id);
  22. $("#task_name").initYewuSelect("610","FD_OBJECTID","PROGRAM_NAME");//保供电任务名称
  23. $("#level").initCanstSelect('BM_GPS_PROGRAM_MANAGE_GPS_LEVEL');//级别
  24. var deptUrl = $.pathname() + '/ws/dept/DeptService/getDepartTree';
  25. $.post(deptUrl,{id:parentId,name:''},function(data){
  26. $("#dept").data("data",data);
  27. $("#dept").render();
  28. $("#write_dept").data("data",data);
  29. $("#write_dept").render();
  30. }, "json");
  31. if((window.location.href).indexOf('?')>-1){
  32. var url = $.pathname() + "/ws/saveList/BGDmingxibiaoaddService/getListById/";
  33. var params = {
  34. listid : listid
  35. };
  36. $.ajax({
  37. url : url,
  38. type : 'post',
  39. timeout : 15000,
  40. data : params,
  41. dataType : 'json',
  42. success : function(data){
  43. $('#listForm').ajaxWrite({data:data});
  44. },
  45. error : function(e){
  46. top.Dialog.alert("访问服务失败!");
  47. }
  48. });
  49. };
  50. initGrid(listid);
  51. };
  52. function initGrid(listid){
  53. g = $("#maingrid").quiGrid({
  54. columns: [
  55. { display: '任务时间',name: 'task_time', align: 'center', width: "25%",editor: { type: 'date',dateFmt:'yyyy-MM-dd HH:mm:ss' }},
  56. { display: '投入人员(人次)', name: 'input_men', align: 'center', width: "25%",editor: { type: 'text',tip:'只能输入数字',inputMode:'numberOnly'}},
  57. { display: '投入车辆(车次)', name: 'input_car', align: 'center', width: "25%",editor: { type: 'text',tip:'只能输入数字',inputMode:'numberOnly'}},
  58. { display: '操作', isSort: false, width: "15%", render: function (rowdata, rowindex, value){
  59. var h = "";
  60. if (!rowdata._editing){
  61. flag=false;
  62. h += "<a onclick='onDelete(" + rowindex + ")'><span class='icon_delete'>删除</span></a> ";
  63. }else{
  64. flag=true;
  65. h += "<a onclick='endEdit(" + rowindex + ")'><span class='icon_ok'>确认</span></a> ";
  66. h += "<a onclick='onDelete(" + rowindex + ")'><span class='icon_delete'>取消</span></a> ";
  67. };
  68. return h;
  69. }
  70. }
  71. ],
  72. url: $.pathname() + '/ws/saveList/BGDmingxibiaoaddService/queryList2ByListId',
  73. params :{"listid":listid,"is_del":0},
  74. rownumbers:true,
  75. usePager: false,
  76. percentWidthMode : true,
  77. height: '100%',
  78. width:'100%',
  79. enabledEdit: true,
  80. clickToEdit: false,
  81. onDblClickRow:function(rowdata, rowindex){
  82. if(flag){
  83. top.Dialog.alert("请先完成当前记录的编辑!");
  84. return;
  85. };
  86. editingRow=parseInt(rowindex.slice(1))-1001;
  87. g.beginEdit(rowindex);
  88. },
  89. onBeforeEdit: onBeforeEdit,
  90. onBeforeSubmitEdit: onBeforeSubmitEdit,
  91. onAfterSubmitEdit: onAfterSubmitEdit,
  92. toolbar:{
  93. items: [
  94. { text: '新增', click: addUser, iconClass: 'icon_add' },
  95. { line: true }
  96. ]
  97. }
  98. });
  99. };
  100. //删除
  101. function onDelete(rowidx){
  102. if(rowidx!=editingRow && flag==true){
  103. top.Dialog.alert("请先完成当前记录的编辑!");
  104. return;
  105. };
  106. if(rowidx != editingRow){
  107. top.Dialog.confirm("此删除操作将无法撤回,是否继续?",function(){
  108. //删除记录
  109. var row = g.getRow(rowidx);
  110. //删除操作
  111. //$.post($.pathname() + '/ws/duty/DutyRecordsService/delDetailByID',
  112. $.post($.pathname() + '/ws/saveList/BGDmingxibiaoaddService/delList2ByID',
  113. /* {"fd_objectid":row.fd_objectid}, */
  114. function(result){
  115. if (result.Msg.sucsess == true) {
  116. top.Dialog.alert("删除成功!");
  117. g.loadData();
  118. } else {
  119. top.Dialog.alert("删除失败!");
  120. }
  121. },
  122. "json");
  123. });
  124. }else if(isNew){
  125. top.Dialog.confirm("确定要删除该记录吗?",function(){
  126. isNewSave=false;
  127. isValida=false;
  128. endEdit(rowidx);
  129. //删除记录
  130. var row = g.getRow(rowidx);
  131. //删除操作
  132. g.deleteRow(row);
  133. });
  134. }else{
  135. isNewSave=false;
  136. isValida=false;
  137. endEdit(rowidx);
  138. g.loadData();
  139. };
  140. };
  141. //编辑
  142. function beginEdit(rowid) {
  143. if(flag){
  144. top.Dialog.alert("请先完成当前记录的编辑!");
  145. return;
  146. };
  147. g.beginEdit(rowid);
  148. }
  149. //结束编辑
  150. function endEdit(rowid){
  151. //editingRow='';
  152. g.endEdit(rowid);
  153. };
  154. //新增(一行)
  155. function addUser(){
  156. if(flag){
  157. top.Dialog.alert("请先完成当前记录的编辑!");
  158. return;
  159. }
  160. editingRow=0;
  161. isNew=true;
  162. var row = g.getRow(0);
  163. var rowData={};
  164. g.addEditRow(rowData, row, true);
  165. //在这里做新增处理
  166. };
  167. //删除后的提示
  168. function handleResult(result){
  169. if(result == 1){
  170. top.Dialog.alert("删除成功!",null,null,null,1);
  171. g.loadData();
  172. }else{
  173. top.Dialog.alert("删除失败!");
  174. };
  175. };
  176. //全部确认修改
  177. function endAllEdit(){
  178. g.endEdit();
  179. };
  180. //全部取消修改
  181. function cancelAllEdit(){
  182. g.cancelEdit();
  183. };
  184. //编辑前事件
  185. function onBeforeEdit(e){};
  186. //编辑提交前事件
  187. function onBeforeSubmitEdit(e){
  188. if(isValida){
  189. if(e.newdata.task_time == ""){
  190. top.Dialog.alert("任务时间列有输入值为空!");
  191. return false;
  192. };
  193. if(e.newdata.input_men == ""){
  194. top.Dialog.alert("投入人员(人次)列有输入值为空!");
  195. return false;
  196. };
  197. if(e.newdata.input_car == ""){
  198. top.Dialog.alert("投入车辆(台次)列有输入值为空");
  199. return false;
  200. };
  201. };
  202. isValida=true;
  203. };
  204. //编辑后事件 (保存修改后的第二张表)
  205. function onAfterSubmitEdit(e){
  206. //isNew=false;
  207. if(isNewSave){
  208. var fd_Objectid1 = e.record.fd_objectid;
  209. var rowData = e.newdata;
  210. var row = JSON.stringify(rowData);
  211. row += "#"+listid+"#"+fd_Objectid1;
  212. //ajax方式提交数据到数据库
  213. // $.post($.pathname() + '/ws/duty/DutyRecordsService/saveDetail',row,function(data){
  214. // g.loadData();
  215. // },"json");
  216. $.ajax({
  217. //url : $.pathname() + '/ws/duty/DutyRecordsService/saveDetail',
  218. url:$.pathname() + '/ws/savelist/BGDmingxibiaoaddService/savelList2',
  219. type : 'post',
  220. timeout : 15000,
  221. data : row,
  222. dataType : 'text',
  223. success : function(result){
  224. top.Dialog.alert("保存成功!");
  225. isNew=false;
  226. },
  227. error : function(e){
  228. top.Dialog.alert("保存失败");
  229. }
  230. });
  231. };
  232. isNewSave=true;
  233. };
  234. var token = 0;//???????????????????????????????????????????????????????????
  235. function saveList(validaFormId){
  236. if(flag){
  237. top.Dialog.alert("请先完成当前记录的编辑!");
  238. return;
  239. };
  240. var valid=$(validaFormId).validationEngine({returnIsValid: true});
  241. // CHECKREDBOX='请检查标红输入框!';
  242. if(!valid){
  243. //top.Dialog.alert(CHECKREDBOX);
  244. if($("#task_name").setValue() == undefined){
  245. top.Dialog.alert("请先填写任务名称!");
  246. return;
  247. }else if($("#dept").setValue() == undefined){
  248. top.Dialog.alert("请先填写部门!");
  249. return;
  250. }else if($("#level").setValue() == undefined){
  251. top.Dialog.alert("请先填写任务级别!");
  252. return;
  253. }else if($("#writer").html() == ""){
  254. top.Dialog.alert("请先填写填报人员!");
  255. return;
  256. }else if($("#write_dept").setValue() == undefined){
  257. top.Dialog.alert("请先填写填报部门!");
  258. return;
  259. }else if($("#write_time").html() == ""){
  260. top.Dialog.alert("请先填写填报时间!");
  261. return;
  262. };
  263. };
  264. if(valid){
  265. if(token>0){
  266. top.Dialog.alert("已经保存过!");
  267. return;
  268. };
  269. token++;
  270. var rows = g.getData();
  271. var rowsjson=JSON.stringify(rows);
  272. var forms = $('#listForm').serialize();
  273. forms =forms +"#;#"+rowsjson;
  274. $.ajax({
  275. /* url : $.pathname() + '/ws/duty/DutyRecordsService/saveDuty', */
  276. url : $.pathname() + '/ws/saveList/BGDmingxibiaoaddService/updateList',
  277. type : 'post',
  278. timeout : 15000,
  279. data : forms,
  280. dataType : 'json',
  281. success : function(result){
  282. if (result.Msg.sucsess == true) {
  283. top.Dialog.alert("保存成功!");
  284. history.go(-1);//???????????????????????????????????????????????????????????
  285. } else {
  286. top.Dialog.alert("保存失败!");
  287. };
  288. },
  289. error : function(e){
  290. top.Dialog.alert("保存失败");
  291. }
  292. });
  293. };
  294. };
  295. //重置----重新加载页面
  296. function resetList(){
  297. window.location.href="List_edit.jsp";
  298. };
  299. function goback(){
  300. //top.Dialog.confirm("您已修改了表单,是否需要离开?|离开", function() {
  301. var url = "/nwyj/page/business/gps/queryStatistics/list/List.jsp";
  302. top.parent.document.getElementById("frmright").setAttribute("src", ""+encodeURI(url));
  303. //});
  304. };
  305. </script>
  306. </head>
  307. <body style="height: 650px;overflow:auto; overflow-x:hidden;background-color:white">
  308. <div style="height: 50px;background: #F8F8F8;" align="center">
  309. <a href="javascript:;">
  310. <img align="left" alt="返回" src="/nwyj/images/temp/back.png" onclick="goback()" />
  311. </a>
  312. <font style="font-weight: bold;font-size: 20px;line-height: 45px;">特级、一级保供电任务明细表修改</font>
  313. </div>
  314. <form id="listForm" method="post">
  315. <input name="classid" value="615" type="hidden"/>
  316. <input name="fd_objectid" id="fd_objectid" type="hidden"/>
  317. <table width="100%" border='0'>
  318. <tr>
  319. <td colspan="6" align="right">
  320. <input type="button" onclick="javascript:saveList('#listForm');" value="保存" />
  321. <input type="button" onclick="javascript:resetList();" value="重置" />
  322. </td>
  323. </tr>
  324. <tr>
  325. <td width="10%" align="right"><span class="star">*</span>任务名称:</td>
  326. <td width="20%"><select id="task_name" name="task_name" type="text" prompt="请选择" maxlength="15" class="validate[required]"></select></td>
  327. <td width="10%" align="right"><span class="star">*</span>部门:</td>
  328. <td width="20%"><div class="selectTree validate[required]" id="dept" name="dept" selWidth="200" boxHeight="260"></div></td>
  329. <td width="10%" align="right"><span class="star">*</span>级别:</td>
  330. <td width="20%"><select id="level" name="level" class="validate[required]" prompt="请选择"></select></td>
  331. </tr>
  332. <tr>
  333. <td align="right"><span class="star">*</span>填报人员:</td>
  334. <td>
  335. <input name="writer" id="writer" maxlength="15" style="width:192px" type="text" class="validate[required]">
  336. </td>
  337. <td align="right"><span class="star">*</span>填报部门:</td>
  338. <td>
  339. <div class="selectTree validate[required]" id="write_dept" name="write_dept" selWidth="200" boxHeight="260"></div>
  340. </td>
  341. <td align="right"><span class="star">*</span>填报时间:</td>
  342. <td><input readonly="readonly" name="write_time" id="write_time" style="width:192px" type="text" class="date validate[required]" dateFmt="yyyy-MM-dd HH:mm"></td>
  343. </tr>
  344. </table>
  345. </form>
  346. <div>
  347. <div class="padding_right5">
  348. <div id="maingrid"></div>
  349. </div>
  350. </div>
  351. </div>
  352. </body>
  353. </html>