common.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. /**
  2. * 增加命名空间方法<br>
  3. * <p>
  4. * 用法:$.namespace("a.b.c"); a.b.c.testFunction=function(...);
  5. */
  6. $.extend($, {
  7. namespace : function() {
  8. var o, d;
  9. for (var i = 0, len = arguments.length; i < len; i++) {
  10. d = arguments[i].split(".");
  11. o = window[d[0]] = window[d[0]] || {};
  12. var left = d.slice(1);
  13. for (var i = 0, len = left.length; i < len; i++) {
  14. o = o[left[i]] = o[left[i]] || {};
  15. }
  16. }
  17. return o;
  18. },
  19. SUCCESS : "success",
  20. ERROR : "error",
  21. BLANK_UUID : "00"
  22. });
  23. //供左侧菜单使用
  24. function iFrameHeight(){
  25. var screen =$(window).height()-59;
  26. var left = $('#sidebar').height();
  27. var main = $('#content').height();
  28. if(left<screen){
  29. left = screen;
  30. }
  31. if(main<screen){
  32. main=screen;
  33. }
  34. if(left>main){
  35. main=left;
  36. }else{
  37. left = main;
  38. }
  39. $('#mainContent').height(left);
  40. $('#sidebar').height(left);
  41. $('#content').height(main-5);
  42. }
  43. //供iframe使用
  44. function iFrameHeightIframe(menucode){
  45. var h = $(window.parent.document).find('#content').height();
  46. if(menucode!=null&&menucode!=''){
  47. $(window.parent.document).find('#'+menucode).height(h-36-30);
  48. }
  49. if($(window.parent.document).find('#_my97DP')){
  50. // $(window.parent.document).find('#_my97DP iframe').css("width","202px");
  51. // $(window.parent.document).find('#_my97DP iframe').css("height","217px");
  52. // alert("w");
  53. }
  54. }
  55. //供iframe内的iframe使用
  56. function tabiFrameHeightIframe(menucode){
  57. var h = $(window.document).find('#mycontent').height();
  58. $(window.parent.document).find('#'+menucode+'iframe').height(h-230);
  59. }
  60. //分页共通
  61. function pageinfo(form){
  62. $("#pagesize").change(function() {
  63. $("#pagejump").val(1);
  64. form.submit();
  65. });
  66. $("#pagesize").val($("#pagesize").attr("num"));
  67. $("#pagefirst").click(function() {
  68. if ($("#pagecur").val() == 1) {
  69. $.alert({
  70. title: '提示',
  71. content: '已到第一页'
  72. });
  73. return;
  74. }
  75. else {
  76. $("#pagejump").val(1);
  77. form.submit();
  78. }
  79. });
  80. $("#pageprev").click(function() {
  81. if ($("#pagecur").val() == 1) {
  82. $.alert({
  83. title: '提示',
  84. content: '已到第一页'
  85. });
  86. return;
  87. }
  88. else {
  89. $("#pagejump").val(parseInt($("#pagecur").val()) - 1);
  90. form.submit();
  91. }
  92. });
  93. $("#pagejump").keydown(
  94. function(event, p) {
  95. if (event.keyCode == 13) {
  96. if ($.isNumeric($("#pagejump").val()) && (parseInt($("#pagejump").val()) >= 1)
  97. && (parseInt($("#pagejump").val()) <= parseInt($("#pagetotal").val()))) {
  98. }
  99. else {
  100. $.alert({
  101. title: '提示',
  102. content: '请输入有效数字'
  103. });
  104. return false;
  105. }
  106. form.submit();
  107. }
  108. });
  109. $("#pagenext").click(function() {
  110. if(parseInt($("#pagetotal").val())<=1){
  111. $.alert({
  112. title: '提示',
  113. content: '已到最后一页'
  114. });
  115. return;
  116. }
  117. if ($("#pagecur").val() == $("#pagetotal").val()) {
  118. $.alert({
  119. title: '提示',
  120. content: '已到最后一页'
  121. });
  122. return;
  123. }
  124. else {
  125. $("#pagejump").val(parseInt($("#pagecur").val()) + 1);
  126. form.submit();
  127. }
  128. });
  129. $("#pagelast").click(function() {
  130. if(parseInt($("#pagetotal").val())<=1){
  131. $.alert({
  132. title: '提示',
  133. content: '已到最后一页'
  134. });
  135. return;
  136. }
  137. if ($("#pagecur").val() == $("#pagetotal").val()) {
  138. $.alert({
  139. title: '提示',
  140. content: '已到最后一页'
  141. });
  142. return;
  143. }
  144. else {
  145. $("#pagejump").val($("#pagetotal").val());
  146. form.submit();
  147. }
  148. });
  149. $("#pagenow").click(function() {
  150. if ($.isNumeric($("#pagejump").val()) && (parseInt($("#pagejump").val()) >= 1)
  151. && (parseInt($("#pagejump").val()) <= parseInt($("#pagetotal").val()))) {
  152. }
  153. else {
  154. $.alert({
  155. title: '提示',
  156. content: '请输入有效数字'
  157. });
  158. return false;
  159. }
  160. form.submit();
  161. });
  162. }
  163. //构建所在地的下拉
  164. //参数说明依次,1(必须)存放下拉的div的id,2(非必须)下拉初始选中的值,没有传没有传空字符串,3(非必须)下拉change事件,根据需要添加4(必须)下拉框的长度
  165. //此下拉如果跟着form一起提交后台的话,对应的是szd属性,
  166. function initszdSelect(divid,existVal,changefunc,width,jyr){
  167. var jsonJyr = null;
  168. if(jyr!=null&&jyr!=''){
  169. jsonJyr = $.parseJSON(jyr);
  170. }
  171. $.post($.app + "/selectSzd", {
  172. }, function(data) {
  173. var str = "";
  174. if(changefunc!=null&&changefunc!=""){
  175. if(jyr!=null&&jyr!=''){
  176. str+="<select disabled class='szdselectpicker' name='szdid' onchange='"+changefunc+"()' id='szdid'>";
  177. }else{
  178. str+="<select class='szdselectpicker' name='szdid' onchange='"+changefunc+"()' id='szdid'>";
  179. }
  180. }else{
  181. if(jyr!=null&&jyr!=''){
  182. str+="<select disabled class='szdselectpicker' name='szdid' id='szdid'>";
  183. }else{
  184. str+="<select class='szdselectpicker' name='szdid' id='szdid'>";
  185. }
  186. }
  187. str+="<option></option>";
  188. if(data){
  189. for(var i=0;i<data.length;i++){
  190. var szd = data[i];
  191. if(szd.val==existVal||szd.id==(jsonJyr!=null?jsonJyr.szd:'')){
  192. str+=" <option selected='selected' value='"+szd.id+"' >"+szd.text+"</option>";
  193. }else{
  194. str+=" <option value='"+szd.id+"' >"+szd.text+"</option>";
  195. }
  196. }
  197. }
  198. str+="</select>";
  199. $("#"+divid).empty();
  200. $("#"+divid).append(str);
  201. $('.szdselectpicker').selectpicker({
  202. width:width
  203. });
  204. }, "json");
  205. }
  206. //构建港口的下拉
  207. //参数说明依次,1(必须)存放下拉的div的id,2(非必须)下拉初始选中的值,没有传空字符串,3(非必须)参数,根据所在地过滤结果,一般级联需要4(非必须)下拉change事件5(必须)下拉框的长度
  208. //此下拉如果跟着form一起提交后台的话,对应的是szd属性,
  209. function initgkSelect(divid,existVal,szd,changefunc,width,jyr){
  210. var jsonJyr = null;
  211. if(jyr!=null&&jyr!=''){
  212. jsonJyr = $.parseJSON(jyr);
  213. szd=jsonJyr.szd;
  214. }
  215. $.post($.app + "/selectGk", {
  216. szd:szd
  217. }, function(data) {
  218. var str = "";
  219. if(changefunc!=null&&changefunc!=""){
  220. if(jyr!=null&&jyr!=''){
  221. str+="<select disabled class='gkselectpicker' name='szgkid' onchange='"+changefunc+"()' id='szgkid'>";
  222. }else{
  223. str+="<select class='gkselectpicker' name='szgkid' onchange='"+changefunc+"()' id='szgkid'>";
  224. }
  225. }else{
  226. if(jyr!=null&&jyr!=''){
  227. str+="<select disabled class='gkselectpicker' name='szgkid' id='szgkid'>";
  228. }else{
  229. str+="<select class='gkselectpicker' name='szgkid' id='szgkid'>";
  230. }
  231. }
  232. str+="<option></option>";
  233. if(data){
  234. for(var i=0;i<data.length;i++){
  235. var gk = data[i];
  236. if(gk.id==existVal||gk.id==(jsonJyr!=null?jsonJyr.szgk:'')){
  237. str+=" <option id='"+gk.zyid+"' selected='selected' value='"+gk.id+"' >"+gk.gkmc+"</option>";
  238. }else{
  239. str+=" <option id='"+gk.zyid+"' value='"+gk.id+"' >"+gk.gkmc+"</option>";
  240. }
  241. }
  242. }
  243. str+="</select>";
  244. $("#"+divid).empty();
  245. $("#"+divid).append(str);
  246. $('.gkselectpicker').selectpicker({
  247. width:width
  248. });
  249. //如果所在地选择为空,重置港区select;
  250. }, "json");
  251. }
  252. //构建港区的下拉
  253. //参数说明依次,1(必须)存放下拉的div的id,2(非必须)下拉初始选中的值,没有传空字符串,3(非必须)参数,根据所在地过滤结果,一般级联需要4(非必须)下拉change事件5(必须)下拉框的长度
  254. //此下拉如果跟着form一起提交后台的话,对应的是szd属性,
  255. function initgqSelect(divid,existVal,szd,gk,changefunc,width,jyr){
  256. var jsonJyr = null;
  257. if(jyr!=null&&jyr!=''){
  258. jsonJyr = $.parseJSON(jyr);
  259. szd=jsonJyr.szd;
  260. gk = jsonJyr.szgk;
  261. }
  262. $.post($.app + "/selectGq", {
  263. szd:szd,
  264. szgk:gk
  265. }, function(data) {
  266. var str = "";
  267. if(changefunc!=null&&changefunc!=""){
  268. if(jyr!=null&&jyr!=''){
  269. str+="<select disabled class='gqselectpicker' name='szgqid' onchange='"+changefunc+"()' id='szgqid'>";
  270. }else{
  271. str+="<select class='gqselectpicker' name='szgqid' onchange='"+changefunc+"()' id='szgqid'>";
  272. }
  273. }else{
  274. if(jyr!=null&&jyr!=''){
  275. str+="<select disabled class='gqselectpicker' name='szgqid' id='szgqid'>";
  276. }else{
  277. str+="<select class='gqselectpicker' name='szgqid' id='szgqid'>";
  278. }
  279. }
  280. str+="<option></option>";
  281. if(data){
  282. for(var i=0;i<data.length;i++){
  283. var gq = data[i];
  284. if(gq.id==existVal||gq.id==(jsonJyr!=null?jsonJyr.szgq:'')){
  285. str+=" <option id='"+gq.zyid+"' selected='selected' value='"+gq.id+"' >"+gq.gqmc+"</option>";
  286. }else{
  287. str+=" <option id='"+gq.zyid+"' value='"+gq.id+"' >"+gq.gqmc+"</option>";
  288. }
  289. }
  290. }
  291. str+="</select>";
  292. $("#"+divid).empty();
  293. $("#"+divid).append(str);
  294. $('.gqselectpicker').selectpicker({
  295. width:width
  296. });
  297. }, "json");
  298. }
  299. //经营人共通选择,需要调用的页面必须引入jyrselect.jsp,
  300. //传入回调方法的名称
  301. function jyrselpop(selectFunc,flag){
  302. // if(isEmpty($('#szgqid').val())){
  303. // $.alert({
  304. // title: '提示',
  305. // content: '港区不能为空!',
  306. // });
  307. // return false;
  308. // }
  309. if(!isEmpty(flag)){
  310. $("#pagejump").val(1);
  311. }
  312. pageinfo2();
  313. $('#jyrselectmaskdiv').fadeIn(100);
  314. $('#jyrselectdiv').slideDown(0);
  315. var gkjyr=$('#gkjyrmc').val();
  316. var szd = $('.szdselectpicker').val();
  317. var szgk = $('.gkselectpicker').val();
  318. var szgq = $('.gqselectpicker').val();
  319. $.ajax({
  320. url:$.app+"/selectJyr",
  321. type:"post",
  322. data:{
  323. szd:szd,
  324. szgk:szgk,
  325. szgq:szgq,
  326. gkjyr:gkjyr,
  327. page:$('#pagejump').val()
  328. },
  329. dataType:"json",
  330. success:function(data){//ajax返回的数据
  331. if (data) {
  332. var str="";
  333. for(var i=0;i<data.attrs.list.length;i++){
  334. var jyr = data.attrs.list[i];
  335. str+="<tr>";
  336. str+="<td>"+(i+1)+"</td>";
  337. str+="<td>"+jyr.gkjyr+"</td>";
  338. str+="<td > " +
  339. "<a class='btn btn-default btn-xs' href='#' onclick=\""+selectFunc+"('"+jyr.id+"')\">"+
  340. "<i class='glyphicon glyphicon-wrench'></i>选择</a> "+
  341. "</td>";
  342. str+="</tr>";
  343. }
  344. $("#jyr").empty();
  345. $("#jyr").append(str);
  346. $("#pagejump").val(data.attrs.page);
  347. $("#gongpage").html(data.attrs.gongpage);
  348. $("#nowshow").html(data.attrs.nowshow);
  349. $("#gongsize").html(data.attrs.gongsize);
  350. $("#pagecur").val(data.attrs.page);
  351. $("#pagetotal").val(data.attrs.totalpage);
  352. $("#pagesort").val(data.attrs.sort);
  353. $("#pageorder").val(data.attrs.order);
  354. }else {
  355. $.alert({
  356. title: '提示',
  357. content: data.message,
  358. confirm: function(){
  359. }
  360. });
  361. }
  362. }
  363. });
  364. }
  365. //流程历史
  366. function hisList(data,lx){
  367. $.ajax({
  368. url:$.app+"/hisList",
  369. type:"post",
  370. data:{
  371. id:data,
  372. lx:lx
  373. },
  374. dataType:"json",
  375. success:function(data){//ajax返回的数据
  376. if (data) {
  377. var str="";
  378. for(var i=0;i<data.length;i++){
  379. var task = data[i];
  380. str+="<tr>";
  381. str+="<td>"+(i+1)+"</td>";
  382. str+="<td >"+task.auditUsername +"</td>";
  383. str+="<td >"+task.auditTime +"</td>";
  384. str+="<td>"+task.currName+"</td>";
  385. if(task.auditResult =="true"){
  386. str+="<td>同意</td>";
  387. } else if(task.auditResult == "false"){
  388. str+="<td>退回</td>";
  389. }else{
  390. str+="<td></td>";
  391. }
  392. str+="<td>"+task.auditMsg+"</td>";
  393. str+="</tr>";
  394. }
  395. $("#hisList").empty();
  396. $("#hisList").append(str);
  397. $('.theme-popover-mask').fadeIn(100);
  398. $('.theme-popover').slideDown(0);
  399. }else {
  400. $.alert({
  401. title: '提示',
  402. content: data.message,
  403. confirm: function(){
  404. }
  405. });
  406. }
  407. }
  408. });
  409. }
  410. //关闭选择经营人的弹出框
  411. function guanbipop(){
  412. $('#jyrselectmaskdiv').fadeOut(100);
  413. $('#jyrselectdiv').slideUp(0);
  414. }
  415. //关闭选择船名的弹出框
  416. function cbguanbipop(){
  417. $('#cbselectmaskdiv').fadeOut(100);
  418. $('#cbselectdiv').slideUp(0);
  419. }
  420. /**
  421. * 匹配中文 数字 字母 下划线
  422. */
  423. function checkInput(str) {
  424. var pattern = /^[\w\u4e00-\u9fa5]+$/gi;
  425. if (pattern.test(str)) { return false; }
  426. return true;
  427. }
  428. // 备注长度限制
  429. function limitTextArea(field) {
  430. var maxlimit = 250;
  431. if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
  432. }
  433. // 根据数据库中字段的长度要求截取文本输入框中输入的字符串
  434. function limitTextArea(field, maxLength) {
  435. if (field.value.length > maxLength) field.value = field.value.substring(0, maxLength);
  436. }
  437. // 判断页面中是否存在重复的ID的方法
  438. function checkDuplicate() {
  439. var i = 0;
  440. var duplicateIds = new Array();
  441. $("body [id]").each(function() {
  442. var id = $(this).attr("id");
  443. if (id != "" && $("body [id=" + id + "]").length >= 2) {
  444. // 判断是否已记录重复的值
  445. if (!contains(duplicateIds, id)) {
  446. duplicateIds[i] = id;
  447. $.messager.alert("提示", "id为" + id + "的重复了。");
  448. }
  449. }
  450. i++;
  451. });
  452. if (duplicateIds.length == 0) {
  453. $.messager.alert("提示", "HTML DOM中没有重复的ID");
  454. }
  455. return duplicateIds;
  456. }
  457. function scrolldate(){
  458. if($(window.parent.document).find('#_my97DP')){
  459. $(window.parent.document).find('#_my97DP').css("display","none");
  460. }
  461. }
  462. // 判断某个e元素是否存在于数组a中
  463. function contains(a, e) {
  464. for (var j = 0; j < a.length; j++)
  465. if (a[j] == e) return true;
  466. return false;
  467. }
  468. //作业区选择
  469. function initzyqSelect(divid,zyqid,gkid,changefunc,width){
  470. $.post($.app+"/zyq/selZyq",{
  471. gkid:gkid
  472. },function(data) {
  473. var str="";
  474. if(changefunc!=null&&changefunc!=""){
  475. str+="<select class='zyqselectpicker' name='zyqid' onchange='"+changefunc+"()' id='zyqid'>";
  476. }else{
  477. str+="<select class='zyqselectpicker' name='zyqid' id='zyqid' >";
  478. }
  479. str+="<option></option>";
  480. if(data){
  481. for(var i=0;i<data.length;i++){
  482. var zyq = data[i];
  483. if(zyqid == zyq.id){
  484. str+=" <option id='"+zyq.zyid+"' selected value='"+zyq.id+"' >"+zyq.zyqmc+"</option>";
  485. }else{
  486. str+=" <option id='"+zyq.zyid+"' value='"+zyq.id+"' >"+zyq.zyqmc+"</option>";
  487. }
  488. }
  489. }
  490. str+="</select>";
  491. $("#"+divid).empty();
  492. $("#"+divid).append(str);
  493. $('.zyqselectpicker').selectpicker({
  494. width:width
  495. });
  496. }, "json");
  497. }
  498. //泊位选择
  499. function initbwSelect(divid,bwid,jyrid,changefunc,width){
  500. $.post($.app+"/bw/selBw",{
  501. jyrid:jyrid
  502. },function(data) {
  503. var str="";
  504. if(changefunc!=null&&changefunc!=""){
  505. str+="<select class='bwselectpicker' name='bwid' onchange='"+changefunc+"()' id='bwid'>";
  506. }else{
  507. str+="<select class='bwselectpicker' name='bwid' id='bwid' >";
  508. }
  509. str+="<option></option>";
  510. if(data){
  511. for(var i=0;i<data.length;i++){
  512. var bw = data[i];
  513. if(bwid == bw.id){
  514. str+=" <option id='"+bw.zyid+"' selected value='"+bw.id+"' >"+bw.bwmc+"</option>";
  515. }else{
  516. str+=" <option id='"+bw.zyid+"' value='"+bw.id+"' >"+bw.bwmc+"</option>";
  517. }
  518. }
  519. }
  520. str+="</select>";
  521. $("#"+divid).empty();
  522. $("#"+divid).append(str);
  523. $('.bwselectpicker').selectpicker({
  524. width:width
  525. });
  526. }, "json");
  527. }
  528. //码头选择
  529. function initmtSelect(divid,mtid,jyrid,changefunc,width){
  530. $.post($.app+"/mt/selMt",{
  531. jyrid:jyrid
  532. },function(data) {
  533. var str="";
  534. if(changefunc!=null&&changefunc!=""){
  535. str+="<select class='mtselectpicker' name='mtid' onchange='"+changefunc+"()' id='mtid'>";
  536. }else{
  537. str+="<select class='mtselectpicker' name='mtid' id='mtid' >";
  538. }
  539. str+="<option></option>";
  540. if(data){
  541. for(var i=0;i<data.length;i++){
  542. var mt = data[i];
  543. if(mtid == mt.id){
  544. str+=" <option id='"+mt.zyid+"' selected value='"+mt.id+"' >"+mt.mtmc+"</option>";
  545. }else{
  546. str+=" <option id='"+mt.zyid+"' value='"+mt.id+"' >"+mt.mtmc+"</option>";
  547. }
  548. }
  549. }
  550. str+="</select>";
  551. $("#"+divid).empty();
  552. $("#"+divid).append(str);
  553. $('.mtselectpicker').selectpicker({
  554. width:width
  555. });
  556. }, "json");
  557. }
  558. //让HTML元素的字符内容保留换行和添加滚动条
  559. function newLine(){
  560. var idname= arguments[0] ||'#bzhh';
  561. var elements = $(idname);
  562. for(var i=0;i<elements.length;i++){
  563. var userStr=elements.eq(i).text();
  564. //showEachCode(userStr);
  565. userStr=trimBoth(userStr);
  566. //showEachCode(userStr);
  567. userStr=userStr.replace(/\n/g,"<br>&nbsp;");
  568. //showEachCode(userStr);
  569. elements.eq(i).html("<div style='height:80px;overflow:auto;padding:30px 0;'></div>");
  570. elements.eq(i).children('div').html(userStr);
  571. }
  572. };
  573. //显示每个字符
  574. function showEachCode(userStr){
  575. var temp="";
  576. for(var i=0;i<userStr.length;i++){
  577. temp+="第"+i+"个字符("+userStr[i]+")的编码是:"+userStr.charCodeAt(i)+"\n";
  578. }
  579. alert(temp);
  580. }
  581. //去除前后空白符(空白符:空格或者换行)
  582. function trimBoth(userStr){
  583. return userStr.replace(/(^\s*)|(\s*$)/g, "");
  584. }
  585. //提示
  586. ts = function(message,element){
  587. $.alert({
  588. title: '提示',
  589. content: message,
  590. confirm: function(){
  591. //如果元素是select,就获取其父元素的子元素button
  592. if(element){
  593. if(element[0].tagName=="SELECT"){
  594. element=element.parent().find("button");
  595. }
  596. }
  597. //让元素获取焦点
  598. element.focus();
  599. }
  600. });
  601. };
  602. function pageinfo2(){
  603. $("#pagesize").change(function() {
  604. $("#pagejump").val(1);
  605. jyrselpop('jyrSel');
  606. });
  607. $("#pagesize").val($("#pagesize").attr("num"));
  608. $("#pagefirst").click(function() {
  609. if ($("#pagecur").val() == 1) {
  610. $.alert({
  611. title: '提示',
  612. content: '已到第一页'
  613. });
  614. return;
  615. }
  616. else {
  617. $("#pagejump").val(1);
  618. jyrselpop('jyrSel');
  619. }
  620. });
  621. $("#pageprev").click(function() {
  622. if ($("#pagecur").val() == 1) {
  623. $.alert({
  624. title: '提示',
  625. content: '已到第一页'
  626. });
  627. return;
  628. }
  629. else {
  630. $("#pagejump").val(parseInt($("#pagecur").val()) - 1);
  631. jyrselpop('jyrSel');
  632. }
  633. });
  634. $("#pagejump").keydown(
  635. function(event, p) {
  636. if (event.keyCode == 13) {
  637. if ($.isNumeric($("#pagejump").val()) && (parseInt($("#pagejump").val()) >= 1)
  638. && (parseInt($("#pagejump").val()) <= parseInt($("#pagetotal").val()))) {
  639. }
  640. else {
  641. $.alert({
  642. title: '提示',
  643. content: '请输入有效数字'
  644. });
  645. return false;
  646. }
  647. jyrselpop('jyrSel');
  648. }
  649. });
  650. $("#pagenext").click(function() {
  651. if(parseInt($("#pagetotal").val())<=1){
  652. $.alert({
  653. title: '提示',
  654. content: '已到最后一页'
  655. });
  656. return;
  657. }
  658. if ($("#pagecur").val() == $("#pagetotal").val()) {
  659. $.alert({
  660. title: '提示',
  661. content: '已到最后一页'
  662. });
  663. return;
  664. }
  665. else {
  666. $("#pagejump").val(parseInt($("#pagecur").val()) + 1);
  667. jyrselpop('jyrSel');
  668. }
  669. });
  670. $("#pagelast").click(function() {
  671. if(parseInt($("#pagetotal").val())<=1){
  672. $.alert({
  673. title: '提示',
  674. content: '已到最后一页'
  675. });
  676. return;
  677. }
  678. if ($("#pagecur").val() == $("#pagetotal").val()) {
  679. $.alert({
  680. title: '提示',
  681. content: '已到最后一页'
  682. });
  683. return;
  684. }
  685. else {
  686. $("#pagejump").val($("#pagetotal").val());
  687. jyrselpop('jyrSel');
  688. }
  689. });
  690. }
  691. function mapApprove(zyid){
  692. // 保存审批意见及状态
  693. $('#mapiframe')[0].contentWindow.gis.edit.syncDataLayer();
  694. guanbipopmap();
  695. }
  696. function mapReject(zyid){
  697. // 保存审批意见及状态
  698. guanbipopmap();
  699. }
  700. function getValues(){
  701. var zyarray=[];
  702. zyarray.push({type:"gk",zyid:''});
  703. zyarray.push({type:"gq",zyid:''});
  704. zyarray.push({type:"jyr",zyid:''});
  705. var obj = document.getElementById("szgkid");
  706. if(!isEmpty(obj)){
  707. var m=obj.options[obj.selectedIndex].id;
  708. if(isEmpty(m)){
  709. m='';
  710. }
  711. zyarray[0].zyid = m;
  712. }
  713. var obj = document.getElementById("szgqid");
  714. if(!isEmpty(obj)){
  715. var m=obj.options[obj.selectedIndex].id;
  716. if(isEmpty(m)){
  717. m='';
  718. }
  719. zyarray[1].zyid = m;
  720. }
  721. if(!isEmpty($('#jyrzyid').val())){
  722. zyarray[2].zyid=$('#jyrzyid').val();
  723. }
  724. return zyarray;
  725. }
  726. function map(editType,zyid){
  727. var flag = $('#mapflag').val();
  728. $('#spDiv').css("display","none");
  729. $('#mapiframe').attr("width","100%");
  730. $('#mapdivmask').fadeIn(100);
  731. $('#mapdiv').slideDown(0);
  732. if(flag == 0){
  733. var url = $.app+"/editgis/gisiframe.html?model=gis&treeType=ty&editType="+editType+"&id="+zyid
  734. $("#mapiframe").attr("src",url);
  735. $('#mapflag').val("1");
  736. }
  737. }
  738. function auditMap(editType,zyid,sp){
  739. map(editType,zyid);
  740. if(sp){
  741. $('#spDiv').removeAttr("style");
  742. $('#spDiv').css("width","50%");
  743. $('#spDiv').css("float","left");
  744. $('#mapiframe').attr("width","50%");
  745. $('#audit').val("");
  746. $('#approve').attr("onclick","mapApprove('"+zyid+"')");
  747. $('#reject').attr("onclick","mapReject('"+zyid+"')");
  748. }
  749. }
  750. function guanbipopmap(){
  751. /*iframeObj=document.getElementById("mapiframe");
  752. iframeObj.contentWindow.gis.edit.submitToService();*/
  753. $('#mapdivmask').fadeOut(100);
  754. $('#mapdiv').slideUp(0);
  755. }
  756. function jyrhide(){
  757. if(($('.szdselectpicker').val()!='')&&($('.gkselectpicker').val()!='')&&($('.gqselectpicker').val()!='')){
  758. $('#ajyrselect').css('display','inline');
  759. }else{
  760. $('#ajyrselect').css('display','none');
  761. }
  762. }
  763. //传入回调方法的名称
  764. function cbselpop(selectFunc){
  765. pageinfo3();
  766. $('#cbselectmaskdiv').fadeIn(100);
  767. $('#cbselectdiv').slideDown(0);
  768. var zwcm=$('#zwcm').val();
  769. $.ajax({
  770. url:$.app+"/selectCb",
  771. type:"post",
  772. data:{
  773. zwcm:zwcm,
  774. page:$('#pagejump').val()
  775. },
  776. dataType:"json",
  777. success:function(data){//ajax返回的数据
  778. if (data) {
  779. var str="";
  780. for(var i=0;i<data.attrs.list.length;i++){
  781. var cb = data.attrs.list[i];
  782. str+="<tr>";
  783. str+="<td>"+(i+1)+"</td>";
  784. str+="<td>"+cb.zwcm+"</td>";
  785. str+="<td>"+cb.ywcm+"</td>";
  786. str+="<td > " +
  787. "<a class='btn btn-default btn-xs' href='#' onclick=\""+selectFunc+"('"+cb.id+"')\">"+
  788. "<i class='glyphicon glyphicon-wrench'></i>选择</a> "+
  789. "</td>";
  790. str+="</tr>";
  791. }
  792. $("#cb").empty();
  793. $("#cb").append(str);
  794. $("#pagejump").val(data.attrs.page);
  795. $("#gongpage").html(data.attrs.gongpage);
  796. $("#nowshow").html(data.attrs.nowshow);
  797. $("#gongsize").html(data.attrs.gongsize);
  798. $("#pagecur").val(data.attrs.page);
  799. $("#pagetotal").val(data.attrs.totalpage);
  800. $("#pagesort").val(data.attrs.sort);
  801. $("#pageorder").val(data.attrs.order);
  802. }else {
  803. $.alert({
  804. title: '提示',
  805. content: data.message,
  806. confirm: function(){
  807. }
  808. });
  809. }
  810. }
  811. });
  812. }
  813. function pageinfo3(){
  814. $("#pagesize").change(function() {
  815. $("#pagejump").val(1);
  816. cbselpop('cbSel');
  817. });
  818. $("#pagesize").val($("#pagesize").attr("num"));
  819. $("#pagefirst").click(function() {
  820. if ($("#pagecur").val() == 1) {
  821. $.alert({
  822. title: '提示',
  823. content: '已到第一页'
  824. });
  825. return;
  826. }
  827. else {
  828. $("#pagejump").val(1);
  829. cbselpop('cbSel');
  830. }
  831. });
  832. $("#pageprev").click(function() {
  833. if ($("#pagecur").val() == 1) {
  834. $.alert({
  835. title: '提示',
  836. content: '已到第一页'
  837. });
  838. return;
  839. }
  840. else {
  841. $("#pagejump").val(parseInt($("#pagecur").val()) - 1);
  842. cbselpop('cbSel');
  843. }
  844. });
  845. $("#pagejump").keydown(
  846. function(event, p) {
  847. if (event.keyCode == 13) {
  848. if ($.isNumeric($("#pagejump").val()) && (parseInt($("#pagejump").val()) >= 1)
  849. && (parseInt($("#pagejump").val()) <= parseInt($("#pagetotal").val()))) {
  850. }
  851. else {
  852. $.alert({
  853. title: '提示',
  854. content: '请输入有效数字'
  855. });
  856. return false;
  857. }
  858. cbselpop('cbSel');
  859. }
  860. });
  861. $("#pagenext").click(function() {
  862. if(parseInt($("#pagetotal").val())<=1){
  863. $.alert({
  864. title: '提示',
  865. content: '已到最后一页'
  866. });
  867. return;
  868. }
  869. if ($("#pagecur").val() == $("#pagetotal").val()) {
  870. $.alert({
  871. title: '提示',
  872. content: '已到最后一页'
  873. });
  874. return;
  875. }
  876. else {
  877. $("#pagejump").val(parseInt($("#pagecur").val()) + 1);
  878. cbselpop('cbSel');
  879. }
  880. });
  881. $("#pagelast").click(function() {
  882. if(parseInt($("#pagetotal").val())<=1){
  883. $.alert({
  884. title: '提示',
  885. content: '已到最后一页'
  886. });
  887. return;
  888. }
  889. if ($("#pagecur").val() == $("#pagetotal").val()) {
  890. $.alert({
  891. title: '提示',
  892. content: '已到最后一页'
  893. });
  894. return;
  895. }
  896. else {
  897. $("#pagejump").val($("#pagetotal").val());
  898. cbselpop('cbSel');
  899. }
  900. });
  901. }