curdtools_en.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540
  1. // update--begin--author:zhangjiaqiang date:20170621 for:如何避免console.log引起javascript的兼容问题
  2. if(!window.console){
  3. window.console = {};
  4. }
  5. if(!window.console.log){
  6. window.console.log = function(msg){};
  7. }
  8. // update--end--author:zhangjiaqiang date:20170621 for:如何避免console.log引起javascript的兼容问题
  9. //update-begin--Author:scott --- Date:20170401 --- for:inputclick ajax请求追加根路径,防止深路径访问有问题----
  10. var basePath;
  11. try{
  12. var local = window.location;
  13. var contextPath = local.pathname.split("/")[1];
  14. basePath = local.protocol+"//"+local.host+"/"+contextPath;
  15. //alert(basePath);
  16. }catch(e){}
  17. //update-end--Author:scott --- Date:20170401 --- for:inputclick ajax请求追加根路径,防止深路径访问有问题----
  18. //var jq = jQuery.noConflict();
  19. /**
  20. * 增删改工具栏
  21. */
  22. /*window.onerror = function() {
  23. return true;
  24. };*/
  25. var iframe;// iframe操作对象
  26. var win;//窗口对象
  27. var gridname="";//操作datagrid对象名称
  28. var windowapi;
  29. var W;
  30. try {
  31. windowapi = frameElement.api, W = windowapi.opener;//内容页中调用窗口实例对象接口
  32. } catch (e) {
  33. }
  34. /**
  35. * 设置 window的 zIndex
  36. * @param flag true: 不增量(因为 tip提示经常使用 zIndex, 所以如果是 tip的话 ,则不增量)
  37. * @returns
  38. */
  39. function getzIndex(flag){
  40. var zindexNumber = getCookie("ZINDEXNUMBER");
  41. if(zindexNumber == null){
  42. zindexNumber = 2010;
  43. setCookie("ZINDEXNUMBER",zindexNumber);
  44. //zindexNumber = 1980;
  45. }else{
  46. if(zindexNumber < 2010){
  47. zindexNumber = 2010;
  48. }
  49. var n = flag?zindexNumber:parseInt(zindexNumber) + parseInt(10);
  50. setCookie("ZINDEXNUMBER",n);
  51. }
  52. return zindexNumber;
  53. }
  54. function upload(curform) {
  55. upload();
  56. }
  57. /**
  58. * Add event open window
  59. * @param title
  60. * @param addurl
  61. */
  62. function add(title,addurl,gname,width,height) {
  63. gridname=gname;
  64. createwindow(title, addurl,width,height);
  65. }
  66. /**
  67. * 树列表添加事件打开窗口
  68. * @param title 编辑框标题
  69. * @param addurl//目标页面地址
  70. */
  71. function addTreeNode(title,addurl,gname) {
  72. if (rowid != '') {
  73. addurl += '&id='+rowid;
  74. }
  75. gridname=gname;
  76. createwindow(title, addurl);
  77. }
  78. /**
  79. * 更新事件打开窗口
  80. * @param title 编辑框标题
  81. * @param addurl//目标页面地址
  82. * @param id//主键字段
  83. */
  84. //update-begin--Author:luobaoli Date:20150705 for:增加了一个判断是否需要转换为restful风格URL的参数,如果该参数为true,那么转换为restful风格
  85. function update(title,url, id,width,height,isRestful) {
  86. gridname=id;
  87. var rowsData = $('#'+id).datagrid('getSelections');
  88. if (!rowsData || rowsData.length==0) {
  89. tip('Please select edit item');
  90. return;
  91. }
  92. if (rowsData.length>1) {
  93. tip('Please one item to edit');
  94. return;
  95. }
  96. if(isRestful!='undefined'&&isRestful){
  97. url += '/'+rowsData[0].id;
  98. }else{
  99. url += '&id='+rowsData[0].id;
  100. }
  101. createwindow(title,url,width,height);
  102. }
  103. //update-end--Author:luobaoli Date:20150705 for:增加了一个判断是否需要转换为restful风格URL的参数,如果该参数为true,那么转换为restful风格
  104. /**
  105. * 如果页面是详细查看页面,无效化所有表单元素,只能进行查看
  106. */
  107. $(function(){
  108. if(location.href.indexOf("load=detail")!=-1){
  109. $(":input").attr("disabled","true");
  110. $(".easyui-linkbutton").hide();
  111. $(".requiredIcon").hide();
  112. }
  113. });
  114. /**
  115. * 查看详细事件打开窗口
  116. * @param title 查看框标题
  117. * @param addurl//目标页面地址
  118. * @param id//主键字段
  119. */
  120. function detail(title,url, id,width,height) {
  121. var rowsData = $('#'+id).datagrid('getSelections');
  122. if (!rowsData || rowsData.length == 0) {
  123. tip('Please select view item');
  124. return;
  125. }
  126. if (rowsData.length > 1) {
  127. tip('Please select an item to view');
  128. return;
  129. }
  130. url += '&load=detail&id='+rowsData[0].id;
  131. createdetailwindow(title,url,width,height);
  132. }
  133. /**
  134. * 多记录刪除請求
  135. * @param title
  136. * @param url
  137. * @param gname
  138. * @return
  139. */
  140. function deleteALLSelect(title,url,gname) {
  141. gridname=gname;
  142. var ids = [];
  143. var rows = $("#"+gname).datagrid('getSelections');
  144. if (rows.length > 0) {
  145. $.dialog.setting.zIndex = getzIndex(true);
  146. $.dialog.confirm('Do you want to delete this data for ever?', function(r) {
  147. if (r) {
  148. for ( var i = 0; i < rows.length; i++) {
  149. ids.push(rows[i].id);
  150. }
  151. $.ajax({
  152. url : url,
  153. type : 'post',
  154. data : {
  155. ids : ids.join(',')
  156. },
  157. cache : false,
  158. success : function(data) {
  159. var d = data; // ------ $.parseJSON(data);
  160. if (d.success) {
  161. var msg = d.msg;
  162. tip(msg);
  163. reloadTable();
  164. $("#"+gname).datagrid('unselectAll');
  165. ids='';
  166. }
  167. }
  168. });
  169. }
  170. });
  171. } else {
  172. tip("Please select delete data");
  173. }
  174. }
  175. /**
  176. * 查看时的弹出窗口
  177. *
  178. * @param title
  179. * @param addurl
  180. * @param saveurl
  181. */
  182. function createdetailwindow(title, addurl,width,height) {
  183. width = width?width:700;
  184. height = height?height:400;
  185. if(width=="100%" || height=="100%"){
  186. width = window.top.document.body.offsetWidth;
  187. height =window.top.document.body.offsetHeight-100;
  188. }
  189. if(typeof(windowapi) == 'undefined'){
  190. $.dialog({
  191. content: 'url:'+addurl,
  192. zIndex: getzIndex(),
  193. lock : true,
  194. width:width,
  195. height: height,
  196. title:title,
  197. opacity : 0.3,
  198. cache:false,
  199. cancelVal: 'Close',
  200. cancel: true /*为true等价于function(){}*/
  201. });
  202. }else{
  203. //update-begin--Author:xuelin Date:20170421 for:#1804 【体验】需要选中行数据,点击阅读才弹出页面--------------------
  204. W.$.dialog({
  205. content: 'url:'+addurl,
  206. zIndex: getzIndex(),
  207. lock : true,
  208. width:width,
  209. height: height,
  210. parent:windowapi,
  211. title:title,
  212. opacity : 0.3,
  213. cache:false,
  214. cancelVal: 'Close',
  215. cancel: function(){
  216. windowapi.zindex();
  217. }
  218. //true /*为true等价于function(){}*/
  219. });
  220. //update-end--Author:xuelin Date:20170421 for:#1804 【体验】需要选中行数据,点击阅读才弹出页面----------------------
  221. }
  222. }
  223. /**
  224. * 全屏编辑
  225. * @param title 编辑框标题
  226. * @param addurl//目标页面地址
  227. * @param id//主键字段
  228. */
  229. function editfs(title,url) {
  230. var name=gridname;
  231. if (rowid == '') {
  232. tip('Please select edit item');
  233. return;
  234. }
  235. url += '&id='+rowid;
  236. //update-begin--Author:scott --- Date:20170406 --- for:弹出窗口最大化问题处理----
  237. width = window.top.document.body.offsetWidth;
  238. height =window.top.document.body.offsetHeight-100;
  239. openwindow(title,url,name,width,height);
  240. //update-end--Author:scott --- Date:20170406 --- for:弹出窗口最大化问题处理----
  241. }
  242. // 删除调用函数
  243. function delObj(url,name) {
  244. gridname=name;
  245. createdialog('Delete Confirm ', 'Delete this record, Confirm ?', url,name);
  246. }
  247. // 删除调用函数
  248. function confuploadify(url, id) {
  249. $.dialog.setting.zIndex = getzIndex(true);
  250. $.dialog.confirm('Delete confirm', function(){
  251. deluploadify(url, id);
  252. }, function(){
  253. });
  254. }
  255. /**
  256. * 执行删除附件
  257. *
  258. * @param url
  259. * @param index
  260. */
  261. function deluploadify(url, id) {
  262. $.ajax({
  263. async : false,
  264. cache : false,
  265. type : 'POST',
  266. url : url,// 请求的action路径
  267. error : function() {// 请求失败处理函数
  268. },
  269. success : function(data) {
  270. var d = data; // ------ $.parseJSON(data);
  271. if (d.success) {
  272. $("#" + id).remove();// 移除SPAN
  273. m.remove(id);// 移除MAP对象内字符串
  274. }
  275. }
  276. });
  277. }
  278. // 普通询问操作调用函数
  279. function confirm(url, content,name) {
  280. createdialog('Tip Message ', content, url,name);
  281. }
  282. /**
  283. * Tip Message
  284. */
  285. function tip_old(msg) {
  286. $.dialog.setting.zIndex = getzIndex(true);
  287. $.dialog.tips(msg, 1);
  288. }
  289. /**
  290. * Tip Message
  291. */
  292. function tip(msg) {
  293. try{
  294. $.dialog.setting.zIndex = getzIndex(true);
  295. // $.messager.show({
  296. // title : 'Tip Message',
  297. // msg : msg,
  298. // timeout : 1000 * 6
  299. // });
  300. //update--begin--author:zhangjiaqiang Date:20170227 for:更新提示框
  301. var navigatorName = "Microsoft Internet Explorer";
  302. //update--begin--author:taoYan Date:20170628 for:default/shortcut提示用原风格---
  303. if(navigator.appName == navigatorName||"default,shortcut".indexOf(getCookie("JEECGINDEXSTYLE"))>=0){
  304. //update--end--author:taoYan Date:20170628 for:default/shortcut提示用原风格---
  305. $.messager.show({
  306. title : 'Tip Message',
  307. msg : msg,
  308. timeout : 1000 * 6
  309. });
  310. }else{
  311. var icon = 7;
  312. if(msg.indexOf("success") > -1){
  313. icon = 1;
  314. }else if(msg.indexOf("fail") > -1){
  315. icon = 2;
  316. }
  317. layer.open({
  318. title:'Tip Message',
  319. offset:'rb',
  320. content:msg,
  321. time:3000,
  322. btn:false,
  323. shade:false,
  324. icon:icon,
  325. shift:2
  326. });
  327. }
  328. //update--begin--author:zhangjiaqiang Date:20170227 for:更新提示框
  329. }catch(e){
  330. alertTipTop(msg,'10%');
  331. }
  332. }
  333. /**
  334. * Layer风格alert提示
  335. */
  336. function alerLayerTip(msg) {
  337. if(msg==null || msg==''){
  338. msg = "系统异常,请看系统日志!";
  339. }
  340. try{
  341. var navigatorName = "Microsoft Internet Explorer";
  342. //update--begin--author:zhangjiaqiang date:20170711 for:TASK 2218 shortcut风格 使用jqueryui对话框
  343. if( navigator.appName == navigatorName ||"shortcut".indexOf(getCookie("JEECGINDEXSTYLE"))>=0){
  344. //update--end--author:zhangjiaqiang date:20170711 for:TASK 2218 shortcut风格 使用jqueryui对话框
  345. $.messager.alert('提示信息',msg);
  346. }else{
  347. layer.open({
  348. title:'提示信息',
  349. content:msg,
  350. time:6000,
  351. btn:false,
  352. shade:false,
  353. icon:2
  354. });
  355. }
  356. }catch(e){
  357. alert(msg);
  358. }
  359. }
  360. /**
  361. * Tip Message像alert一样 定位顶部的位置
  362. */
  363. function alertTipTop(msg,top,title) {
  364. $.dialog.setting.zIndex = getzIndex(true);
  365. title = title?title:"Tip Message";
  366. $.dialog({
  367. title:title,
  368. zIndex: getzIndex(),
  369. icon:'tips.gif',
  370. top:top,
  371. content: msg
  372. });
  373. }
  374. /**
  375. * Tip Message像alert一样
  376. */
  377. function alertTip(msg,title) {
  378. $.dialog.setting.zIndex = getzIndex(true);
  379. title = title?title:"Tip Message";
  380. $.dialog({
  381. title:title,
  382. zIndex: getzIndex(),
  383. icon:'tips.gif',
  384. content: msg
  385. });
  386. }
  387. /**
  388. * 创建添加或编辑窗口
  389. *
  390. * @param title
  391. * @param addurl
  392. * @param saveurl
  393. */
  394. function createwindow(title, addurl,width,height) {
  395. width = width?width:700;
  396. height = height?height:400;
  397. if(width=="100%" || height=="100%"){
  398. width = window.top.document.body.offsetWidth;
  399. height =window.top.document.body.offsetHeight-100;
  400. }
  401. //--author:JueYue---------date:20140427---------for:弹出bug修改,设置了zindex()函数
  402. if(typeof(windowapi) == 'undefined'){
  403. $.dialog({
  404. content: 'url:'+addurl,
  405. lock : true,
  406. zIndex: getzIndex(),
  407. width:width,
  408. height:height,
  409. title:title,
  410. opacity : 0.3,
  411. cache:false,
  412. okVal: 'Submit',
  413. ok: function(){
  414. iframe = this.iframe.contentWindow;
  415. saveObj();
  416. return false;
  417. },
  418. cancelVal: 'Close',
  419. cancel: true /*为true等价于function(){}*/
  420. });
  421. }else{
  422. //update-begin--Author:xuelin Date:20170705 for:TASK #2196 【bug】云桌面问题--------------------
  423. /*W.*/$.dialog({//使用W,即为使用顶级页面作为openner,造成打开的次级窗口获取不到关联的主窗口
  424. content: 'url:'+addurl,
  425. lock : true,
  426. width:width,
  427. zIndex: getzIndex(),
  428. height:height,
  429. parent:windowapi,
  430. title:title,
  431. opacity : 0.3,
  432. cache:false,
  433. ok: function(){
  434. iframe = this.iframe.contentWindow;
  435. saveObj();
  436. return false;
  437. },
  438. cancelVal: 'Close',
  439. cancel: true /*为true等价于function(){}*/
  440. });
  441. //update-end--Author:xuelin Date:20170705 for:TASK #2196 【bug】云桌面问题----------------------
  442. }
  443. //--author:JueYue---------date:20140427---------for:弹出bug修改,设置了zindex()函数
  444. }
  445. /**
  446. * 创建上传页面窗口
  447. *
  448. * @param title
  449. * @param addurl
  450. * @param saveurl
  451. */
  452. function openuploadwin(title, url,name,width, height) {
  453. gridname=name;
  454. $.dialog({
  455. content: 'url:'+url,
  456. zIndex: getzIndex(),
  457. cache:false,
  458. button: [
  459. {
  460. name: "Begin Upload",
  461. callback: function(){
  462. iframe = this.iframe.contentWindow;
  463. iframe.upload();
  464. return false;
  465. },
  466. focus: true
  467. },
  468. {
  469. name: "Cancel Upload",
  470. callback: function(){
  471. iframe = this.iframe.contentWindow;
  472. iframe.cancel();
  473. }
  474. }
  475. ]
  476. });
  477. }
  478. /**
  479. * 创建查询页面窗口
  480. *
  481. * @param title
  482. * @param addurl
  483. * @param saveurl
  484. */
  485. function opensearchdwin(title, url, width, height) {
  486. $.dialog({
  487. content: 'url:'+url,
  488. zIndex: getzIndex(),
  489. title : title,
  490. lock : true,
  491. height : height,
  492. cache:false,
  493. width : width,
  494. opacity : 0.3,
  495. button : [ {
  496. name :'Query',
  497. callback : function() {
  498. iframe = this.iframe.contentWindow;
  499. iframe.searchs();
  500. },
  501. focus : true
  502. }, {
  503. name : 'Cancel',
  504. callback : function() {
  505. }
  506. } ]
  507. });
  508. }
  509. /**
  510. * 创建不带按钮的窗口
  511. *
  512. * @param title
  513. * @param addurl
  514. * @param saveurl
  515. */
  516. function openwindow(title, url,name, width, height) {
  517. //update-begin--Author:scott --- Date:20170406 --- for:弹出窗口最大化问题处理----
  518. if(width=="100%" || height=="100%"){
  519. width = window.top.document.body.offsetWidth;
  520. height =window.top.document.body.offsetHeight-100;
  521. }
  522. //update-end--Author:scott --- Date:20170406 --- for:弹出窗口最大化问题处理----
  523. gridname=name;
  524. if (typeof (width) == 'undefined'&&typeof (height) != 'undefined')
  525. {
  526. if(typeof(windowapi) == 'undefined'){
  527. $.dialog({
  528. content: 'url:'+url,
  529. zIndex: getzIndex(),
  530. title : title,
  531. cache:false,
  532. lock : true,
  533. width: 'auto',
  534. height: height
  535. });
  536. }else{
  537. $.dialog({
  538. content: 'url:'+url,
  539. zIndex: getzIndex(),
  540. title : title,
  541. cache:false,
  542. parent:windowapi,
  543. lock : true,
  544. width: 'auto',
  545. height: height
  546. });
  547. }
  548. }
  549. if (typeof (height) == 'undefined'&&typeof (width) != 'undefined')
  550. {
  551. if(typeof(windowapi) == 'undefined'){
  552. $.dialog({
  553. content: 'url:'+url,
  554. zIndex: getzIndex(),
  555. title : title,
  556. lock : true,
  557. width: width,
  558. cache:false,
  559. height: 'auto'
  560. });
  561. }else{
  562. $.dialog({
  563. content: 'url:'+url,
  564. zIndex: getzIndex(),
  565. title : title,
  566. lock : true,
  567. parent:windowapi,
  568. width: width,
  569. cache:false,
  570. height: 'auto'
  571. });
  572. }
  573. }
  574. if (typeof (width) == 'undefined'&&typeof (height) == 'undefined')
  575. {
  576. if(typeof(windowapi) == 'undefined'){
  577. $.dialog({
  578. content: 'url:'+url,
  579. zIndex: getzIndex(),
  580. title : title,
  581. lock : true,
  582. width: 'auto',
  583. cache:false,
  584. height: 'auto'
  585. });
  586. }else{
  587. $.dialog({
  588. content: 'url:'+url,
  589. zIndex: getzIndex(),
  590. title : title,
  591. lock : true,
  592. parent:windowapi,
  593. width: 'auto',
  594. cache:false,
  595. height: 'auto'
  596. });
  597. }
  598. }
  599. if (typeof (width) != 'undefined'&&typeof (height) != 'undefined')
  600. {
  601. if(typeof(windowapi) == 'undefined'){
  602. $.dialog({
  603. width: width,
  604. height:height,
  605. content: 'url:'+url,
  606. zIndex: getzIndex(),
  607. title : title,
  608. cache:false,
  609. lock : true
  610. });
  611. }else{
  612. $.dialog({
  613. width: width,
  614. height:height,
  615. content: 'url:'+url,
  616. zIndex: getzIndex(),
  617. parent:windowapi,
  618. title : title,
  619. cache:false,
  620. lock : true
  621. });
  622. }
  623. }
  624. }
  625. /**
  626. * 创建询问窗口
  627. *
  628. * @param title
  629. * @param content
  630. * @param url
  631. */
  632. function createdialog(title, content, url,name) {
  633. $.dialog.setting.zIndex = getzIndex(true);
  634. //update--begin---author:zhangjiaqiang date:20170301 for:修订提示框
  635. var navigatorName = "Microsoft Internet Explorer";
  636. //update--begin--author:zhangjiaqiang date:20170711 for:TASK 2218 shortcut风格 使用jqueryui对话框
  637. if( navigator.appName == navigatorName ||"shortcut".indexOf(getCookie("JEECGINDEXSTYLE"))>=0){
  638. //update--end--author:zhangjiaqiang date:20170711 for:TASK 2218 shortcut风格 使用jqueryui对话框
  639. $.dialog.confirm(content, function(){
  640. doSubmit(url,name);
  641. rowid = '';
  642. }, function(){
  643. });
  644. }else{
  645. layer.open({
  646. title:title,
  647. content:content,
  648. icon:7,
  649. yes:function(index){
  650. doSubmit(url,name);
  651. rowid = '';
  652. },
  653. btn:['ok','cancel'],
  654. btn2:function(index){
  655. layer.close(index);
  656. }
  657. });
  658. }
  659. //update--end---author:zhangjiaqiang date:20170301 for:修订提示框
  660. }
  661. /**
  662. * 执行保存
  663. *
  664. * @param url
  665. * @param gridname
  666. */
  667. function saveObj() {
  668. $('#btn_sub', iframe.document).click();
  669. }
  670. /**
  671. * 执行AJAX提交FORM
  672. *
  673. * @param url
  674. * @param gridname
  675. */
  676. function ajaxSubForm(url) {
  677. $('#myform', iframe.document).form('submit', {
  678. url : url,
  679. onSubmit : function() {
  680. iframe.editor.sync();
  681. },
  682. success : function(r) {
  683. tip('Cancel');
  684. reloadTable();
  685. }
  686. });
  687. }
  688. /**
  689. * 执行查询
  690. *
  691. * @param url
  692. * @param gridname
  693. */
  694. function search() {
  695. $('#btn_sub', iframe.document).click();
  696. iframe.search();
  697. }
  698. /**
  699. * 执行操作
  700. *
  701. * @param url
  702. * @param index
  703. */
  704. function doSubmit(url,name,data) {
  705. gridname=name;
  706. //--author:JueYue ---------date:20140227---------for:把URL转换成POST参数防止URL参数超出范围的问题
  707. var paramsData = data;
  708. if(!paramsData){
  709. paramsData = new Object();
  710. if (url.indexOf("&") != -1) {
  711. var str = url.substr(url.indexOf("&")+1);
  712. url = url.substr(0,url.indexOf("&"));
  713. var strs = str.split("&");
  714. for(var i = 0; i < strs.length; i ++) {
  715. paramsData[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
  716. }
  717. }
  718. }
  719. //--author:JueYue ---------date:20140227---------for:把URL转换成POST参数防止URL参数超出范围的问题
  720. $.ajax({
  721. async : false,
  722. cache : false,
  723. type : 'POST',
  724. data : paramsData,
  725. url : url,// 请求的action路径
  726. error : function() {// 请求失败处理函数
  727. },
  728. success : function(data) {
  729. var d = data; // ------ $.parseJSON(data);
  730. if (d.success) {
  731. var msg = d.msg;
  732. tip(msg);
  733. reloadTable();
  734. }
  735. }
  736. });
  737. }
  738. /**
  739. * 退出确认框
  740. *
  741. * @param url
  742. * @param content
  743. * @param index
  744. */
  745. function exit(url, content) {
  746. $.dialog.setting.zIndex = getzIndex(true);
  747. $.dialog.confirm(content, function(){
  748. window.location = url;
  749. }, function(){
  750. });
  751. }
  752. /**
  753. * 模板页面ajax提交
  754. *
  755. * @param url
  756. * @param gridname
  757. */
  758. function ajaxdoSub(url, formname) {
  759. $('#' + formname).form('submit', {
  760. url : url,
  761. onSubmit : function() {
  762. editor.sync();
  763. },
  764. success : function(r) {
  765. tip('Cancel');
  766. }
  767. });
  768. }
  769. /**
  770. * ajax提交FORM
  771. *
  772. * @param url
  773. * @param gridname
  774. */
  775. function ajaxdoForm(url, formname) {
  776. $('#' + formname).form('submit', {
  777. url : url,
  778. onSubmit : function() {
  779. },
  780. success : function(r) {
  781. tip('Cancel');
  782. }
  783. });
  784. }
  785. function opensubwin(title, url, saveurl, okbutton, closebutton) {
  786. $.dialog({
  787. content: 'url:'+url,
  788. zIndex: getzIndex(),
  789. title : title,
  790. lock : true,
  791. opacity : 0.3,
  792. button : [ {
  793. name : okbutton,
  794. callback : function() {
  795. iframe = this.iframe.contentWindow;
  796. win = frameElement.api.opener;// 来源页面
  797. $('#btn_sub', iframe.document).click();
  798. return false;
  799. }
  800. }, {
  801. name : closebutton,
  802. callback : function() {
  803. }
  804. } ]
  805. });
  806. }
  807. function openauditwin(title, url, saveurl, okbutton, backbutton, closebutton) {
  808. $.dialog({
  809. content: 'url:'+url,
  810. zIndex: getzIndex(),
  811. title : title,
  812. lock : true,
  813. opacity : 0.3,
  814. button : [ {
  815. name : okbutton,
  816. callback : function() {
  817. iframe = this.iframe.contentWindow;
  818. win = $.dialog.open.origin;// 来源页面
  819. $('#btn_sub', iframe.document).click();
  820. return false;
  821. }
  822. }, {
  823. name : backbutton,
  824. callback : function() {
  825. iframe = this.iframe.contentWindow;
  826. win = frameElement.api.opener;// 来源页面
  827. $('#formobj', iframe.document).form('submit', {
  828. url : saveurl + "&code=exit",
  829. onSubmit : function() {
  830. $('#code').val('exit');
  831. },
  832. success : function(r) {
  833. $.dialog.tips('Cancel', 2);
  834. win.location.reload();
  835. }
  836. });
  837. }
  838. }, {
  839. name : closebutton,
  840. callback : function() {
  841. }
  842. } ]
  843. });
  844. }
  845. /*获取Cookie值*/
  846. function getCookie(c_name)
  847. {
  848. if (document.cookie.length > 0) {
  849. c_start = document.cookie.indexOf(c_name + "=")
  850. if (c_start != -1) {
  851. c_start = c_start + c_name.length + 1
  852. c_end = document.cookie.indexOf(";", c_start)
  853. if (c_end == -1)
  854. c_end = document.cookie.length
  855. return unescape(document.cookie.substring(c_start, c_end))
  856. }
  857. }
  858. return ""
  859. }
  860. /* 设置 cookie */
  861. function setCookie(c_name, value, expiredays){
  862. var exdate=new Date();
  863. exdate.setDate(exdate.getDate() + expiredays);
  864. document.cookie=c_name+ "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
  865. }
  866. function createTabId(str){
  867.     var val="";
  868.     for(var i = 0; i < str.length; i++){
  869.         val += str.charCodeAt(i).toString(16);
  870.     }
  871.     return val;
  872.   }
  873. // 添加标签
  874. function addOneTab(subtitle, url, icon) {
  875. var indexStyle = getCookie("JEECGINDEXSTYLE");
  876. if(indexStyle=='sliding'||indexStyle=='bootstrap'){
  877. //shortcut和bootstrap风格的tab跳转改为直接跳转
  878. window.location.href=url;
  879. }else if(indexStyle=='acele'||indexStyle=='ace'){
  880. var id = "";
  881. //if(url.indexOf("=")!=-1){
  882. // id = url.substring(url.indexOf("=")+1);
  883. //}else{
  884. id = createTabId(subtitle);
  885. //}
  886. window.top.addTabs({id:id,title:subtitle,close: true,url: url});
  887. }else if(indexStyle=='hplus'){
  888. var id = "";
  889. id = createTabId(subtitle);
  890. window.top.addTabs({id:id,title:subtitle,close: true,url: url});
  891. }else{
  892. if (icon == '') {
  893. icon = 'icon folder';
  894. }
  895. window.top.$.messager.progress({
  896. text : 'Page loading...',
  897. interval : 300
  898. });
  899. window.top.$('#maintabs').tabs({
  900. onClose : function(subtitle, index) {
  901. window.top.$.messager.progress('close');
  902. }
  903. });
  904. if (window.top.$('#maintabs').tabs('exists', subtitle)) {
  905. window.top.$('#maintabs').tabs('select', subtitle);
  906. if (url.indexOf('isHref') != -1) {
  907. window.top.$('#maintabs').tabs('update', {
  908. tab : window.top.$('#maintabs').tabs('getSelected'),
  909. options : {
  910. title : subtitle,
  911. href:url,
  912. //content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
  913. closable : true,
  914. icon : icon
  915. }
  916. });
  917. }else {
  918. window.top.$('#maintabs').tabs('update', {
  919. tab : window.top.$('#maintabs').tabs('getSelected'),
  920. options : {
  921. title : subtitle,
  922. content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
  923. //content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
  924. closable : true,
  925. icon : icon
  926. }
  927. });
  928. }
  929. } else {
  930. if (url.indexOf('isHref') != -1) {
  931. window.top.$('#maintabs').tabs('add', {
  932. title : subtitle,
  933. href:url,
  934. closable : true,
  935. icon : icon
  936. });
  937. }else {
  938. window.top.$('#maintabs').tabs('add', {
  939. title : subtitle,
  940. content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
  941. closable : true,
  942. icon : icon
  943. });
  944. }
  945. }
  946. }
  947. }
  948. // 关闭自身TAB刷新父TABgrid
  949. function closetab(title) {
  950. //暂时先不刷新
  951. //window.top.document.getElementById('tabiframe').contentWindow.reloadTable();
  952. //window.top.document.getElementById('maintabs').contentWindow.reloadTable();
  953. window.top.$('#maintabs').tabs('close', title);
  954. //tip("添加成功");
  955. }
  956. //popup
  957. //object: this name:需要选择的列表的字段 code:动态报表的code
  958. function inputClick(obj,name,code) {
  959. if(name==""||code==""){
  960. alert("Popup parameter not prepare");
  961. return;
  962. }
  963. //update-begin--Author:scott --- Date:20170401 --- for:inputclick ajax请求追加根路径,防止深路径访问有问题----
  964. var inputClickUrl = basePath + "/cgReportController.do?popup&id="+code;
  965. //update-end--Author:scott --- Date:20170401 --- for:inputclick ajax请求追加根路径,防止深路径访问有问题----
  966. if(typeof(windowapi) == 'undefined'){
  967. $.dialog({
  968. content: "url:"+inputClickUrl,
  969. zIndex: getzIndex(),
  970. lock : true,
  971. title:"Select",
  972. width:800,
  973. height: 400,
  974. cache:false,
  975. ok: function(){
  976. iframe = this.iframe.contentWindow;
  977. var selected = iframe.getSelectRows();
  978. if (selected == '' || selected == null ){
  979. alert("Please select");
  980. return false;
  981. }else {
  982. var str = "";
  983. $.each( selected, function(i, n){
  984. if (i==0)
  985. str+= n[name];
  986. else
  987. str+= ","+n[name];
  988. });
  989. $(obj).val("");
  990. //$('#myText').searchbox('setValue', str);
  991. $(obj).val(str);
  992. return true;
  993. }
  994. },
  995. cancelVal: 'Close',
  996. cancel: true /*为true等价于function(){}*/
  997. });
  998. }else{
  999. $.dialog({
  1000. content: "url:"+inputClickUrl,
  1001. zIndex: getzIndex(),
  1002. lock : true,
  1003. title:"Select",
  1004. width:800,
  1005. height: 400,
  1006. parent:windowapi,
  1007. cache:false,
  1008. ok: function(){
  1009. iframe = this.iframe.contentWindow;
  1010. var selected = iframe.getSelectRows();
  1011. if (selected == '' || selected == null ){
  1012. alert("Please select");
  1013. return false;
  1014. }else {
  1015. var str = "";
  1016. $.each( selected, function(i, n){
  1017. if (i==0)
  1018. str+= n[name];
  1019. else
  1020. str+= ","+n[name];
  1021. });
  1022. $(obj).val("");
  1023. //$('#myText').searchbox('setValue', str);
  1024. $(obj).val(str);
  1025. return true;
  1026. }
  1027. },
  1028. cancelVal: 'Close',
  1029. cancel: true /*为true等价于function(){}*/
  1030. });
  1031. }
  1032. }
  1033. /*
  1034. 自定义url的弹出
  1035. obj:要填充的控件,可以为多个,以逗号分隔
  1036. name:列表中对应的字段,可以为多个,以逗号分隔(与obj要对应)
  1037. url:弹出页面的Url
  1038. */
  1039. function popClick(obj,name,url) {
  1040. $.dialog.setting.zIndex = getzIndex(true);
  1041. var names = name.split(",");
  1042. var objs = obj.split(",");
  1043. if(typeof(windowapi) == 'undefined'){
  1044. $.dialog({
  1045. content: "url:"+url,
  1046. zIndex: getzIndex(),
  1047. lock : true,
  1048. title:"Select",
  1049. width:700,
  1050. height: 400,
  1051. cache:false,
  1052. ok: function(){
  1053. iframe = this.iframe.contentWindow;
  1054. var selected = iframe.getSelectRows();
  1055. if (selected == '' || selected == null ){
  1056. alert("Please select");
  1057. return false;
  1058. }else {
  1059. for(var i1=0;i1<names.length;i1++){
  1060. var str = "";
  1061. $.each( selected, function(i, n){
  1062. if (i==0)
  1063. str+= n[names[i1]];
  1064. else{
  1065. str+= ",";
  1066. str+=n[names[i1]];
  1067. }
  1068. });
  1069. if($("#"+objs[i1]).length>=1){
  1070. $("#"+objs[i1]).val("");
  1071. $("#"+objs[i1]).val(str);
  1072. }else{
  1073. $("input[name='"+objs[i1]+"']").val("");
  1074. $("input[name='"+objs[i1]+"']").val(str);
  1075. }
  1076. }
  1077. return true;
  1078. }
  1079. },
  1080. cancelVal: 'Close',
  1081. cancel: true /*为true等价于function(){}*/
  1082. });
  1083. }else{
  1084. $.dialog({
  1085. content: "url:"+url,
  1086. zIndex: getzIndex(),
  1087. lock : true,
  1088. title:"Select",
  1089. width:700,
  1090. height: 400,
  1091. parent:windowapi,
  1092. cache:false,
  1093. ok: function(){
  1094. iframe = this.iframe.contentWindow;
  1095. var selected = iframe.getSelectRows();
  1096. if (selected == '' || selected == null ){
  1097. alert("Please select");
  1098. return false;
  1099. }else {
  1100. for(var i1=0;i1<names.length;i1++){
  1101. var str = "";
  1102. $.each( selected, function(i, n){
  1103. if (i==0)
  1104. str+= n[names[i1]];
  1105. else{
  1106. str+= ",";
  1107. str+=n[names[i1]];
  1108. }
  1109. });
  1110. if($("#"+objs[i1]).length>=1){
  1111. $("#"+objs[i1]).val("");
  1112. $("#"+objs[i1]).val(str);
  1113. }else{
  1114. $("[name='"+objs[i1]+"']").val("");
  1115. $("[name='"+objs[i1]+"']").val(str);
  1116. }
  1117. }
  1118. return true;
  1119. }
  1120. },
  1121. cancelVal: 'Close',
  1122. cancel: true /*为true等价于function(){}*/
  1123. });
  1124. }
  1125. }
  1126. /**
  1127. * Jeecg Excel 导出
  1128. * 代入查询条件
  1129. */
  1130. function JeecgExcelExport(url,datagridId){
  1131. var queryParams = $('#'+datagridId).datagrid('options').queryParams;
  1132. $('#'+datagridId+'tb').find('*').each(function() {
  1133. queryParams[$(this).attr('name')] = $(this).val();
  1134. });
  1135. var params = '&';
  1136. $.each(queryParams, function(key, val){
  1137. params+='&'+key+'='+val;
  1138. });
  1139. var fields = '&field=';
  1140. $.each($('#'+ datagridId).datagrid('options').columns[0], function(i, val){
  1141. if(val.field != 'opt'){
  1142. fields+=val.field+',';
  1143. }
  1144. });
  1145. //update-begin--Author:dangzhenghui Date:20170429 for:TASK #1869 【demo】jeecg excel导出 可以导出 指定行的数据
  1146. var id='&id=';
  1147. $.each($('#'+ datagridId).datagrid('getSelections'), function(i, val){
  1148. id+=val.id+",";
  1149. });
  1150. window.location.href = url+ encodeURI(fields+params+id);
  1151. //update-end--Author:dangzhenghui Date:20170429 for:TASK #1869 【demo】jeecg excel导出 可以导出 指定行的数据
  1152. }
  1153. /**
  1154. * 自动完成的解析函数
  1155. * @param data
  1156. * @returns {Array}
  1157. */
  1158. function jeecgAutoParse(data){
  1159. var parsed = [];
  1160. $.each(data.rows,function(index,row){
  1161. parsed.push({data:row,result:row,value:row.id});
  1162. });
  1163. return parsed;
  1164. }
  1165. //add--start--Author:xugj date:20160531 for: TASK #1089 【demo】针对jeecgdemo,实现一个新的页面方式
  1166. /**
  1167. * 更新跳转新页面
  1168. * @param title 编辑框标题 未实现标题改变
  1169. * @param addurl//目标页面地址
  1170. * @param id//主键字段
  1171. */
  1172. function updateNotCreateWin(title,url, id,isRestful) {
  1173. var rowsData = $('#'+id).datagrid('getSelections');
  1174. if (!rowsData || rowsData.length==0) {
  1175. tip('Please select edit item');
  1176. return;
  1177. }
  1178. if (rowsData.length>1) {
  1179. tip('Please one item to edit');
  1180. return;
  1181. }
  1182. if(isRestful!='undefined'&&isRestful){
  1183. url += '/'+rowsData[0].id;
  1184. }else{
  1185. url += '&id='+rowsData[0].id;
  1186. }
  1187. window.location.href=url
  1188. }
  1189. /**
  1190. * 查看详情跳转新页面
  1191. * @param title 编辑框标题 未实现标题改变
  1192. * @param id//主键字段
  1193. */
  1194. function viewNotCreateWin(title,url, id,isRestful)
  1195. {
  1196. var rowsData = $('#'+id).datagrid('getSelections');
  1197. if (!rowsData || rowsData.length==0) {
  1198. tip('Please select edit item');
  1199. return;
  1200. }
  1201. if (rowsData.length>1) {
  1202. tip('Please one item to edit');
  1203. return;
  1204. }
  1205. if(isRestful!='undefined'&&isRestful){
  1206. url += '/'+rowsData[0].id;
  1207. }else{
  1208. url += '&id='+rowsData[0].id;
  1209. }
  1210. window.location.href=url
  1211. }
  1212. //add--end--Author:xugj date:20160531 for: TASK #1089 【demo】针对jeecgdemo,实现一个新的页面方式
  1213. //add--start--Author:gengjiajia date:20160802 for: TASK #1175 批量添加数据的时popup多值的传递
  1214. //popup
  1215. //object: pobj当前操作的文本框. tablefield:对应字典TEXT,要从popup报表中获取的字段.inputnames:对应字典CODE,当前需要回填数据的文本框名称. pcode:动态报表的code
  1216. function popupClick(pobj,tablefield,inputnames,pcode) {
  1217. $.dialog.setting.zIndex = getzIndex(true);
  1218. if(inputnames==""||pcode==""){
  1219. alert("popup参数配置不全");
  1220. return;
  1221. }
  1222. if(typeof(windowapi) == 'undefined'){
  1223. $.dialog({
  1224. content: "url:cgReportController.do?popup&id="+pcode,
  1225. zIndex: getzIndex(),
  1226. lock : true,
  1227. title:"选择",
  1228. width:800,
  1229. height: 400,
  1230. cache:false,
  1231. ok: function(){
  1232. iframe = this.iframe.contentWindow;
  1233. var selected = iframe.getSelectRows();
  1234. if (selected == '' || selected == null ){
  1235. alert("请选择");
  1236. return false;
  1237. }else {
  1238. //对应数据库字段不为空的情况下,根据表单中字典TEXT的值来取popup的值
  1239. if(tablefield != "" && tablefield != null){
  1240. var fields = tablefield.split(",");
  1241. var inputfield = inputnames.split(",");
  1242. for(var i1=0;i1<fields.length;i1++){
  1243. var str = "";
  1244. $.each( selected, function(i, n){
  1245. if (i==0)
  1246. str+= n[fields[i1]];
  1247. else{
  1248. str+= ",";
  1249. str+=n[fields[i1]];
  1250. }
  1251. });
  1252. var inputname = $(pobj).attr("name");
  1253. var inputs = inputname.split(".");
  1254. //判断传入的this格式是否为 "AA[#index#].aa"的形式
  1255. if(str.indexOf("undefined")==-1){
  1256. if(inputs.length>1){
  1257. var inpu = inputs[i1]+"."+inputfield[i1];
  1258. $("input[name='"+inpu+"']").val(str);
  1259. }else{
  1260. $("input[name='"+inputfield[i1]+"']").val(str);
  1261. }
  1262. }else{
  1263. if(inputs.length>1){
  1264. var inpu = inputs[i1]+"."+inputfield[i1];
  1265. $("input[name='"+inpu+"']").val("");
  1266. }else{
  1267. $("input[name='"+inputfield[i1]+"']").val("");
  1268. }
  1269. }
  1270. }
  1271. }else{
  1272. //对应数据库字段为空的情况下并且字典CODE传入多个值时,根据表单中字典CODE的值从popup中来取值
  1273. var inputfield = inputnames.split(",");
  1274. if(inputfield.length>1){
  1275. for(var i1=0;i1<inputfield.length;i1++){
  1276. var str = "";
  1277. $.each( selected, function(i, n){
  1278. if (i==0)
  1279. str+= n[inputfield[i1]];
  1280. else{
  1281. str+= ",";
  1282. str+=n[inputfield[i1]];
  1283. }
  1284. });
  1285. var inputname = $(pobj).attr("name");
  1286. var inputs = inputname.split(".");
  1287. if(str.indexOf("undefined")==-1){
  1288. if(inputs.length>1){
  1289. var inpu = inputs[i1]+"."+inputfield[i1];
  1290. $("input[name='"+inpu+"']").val(str);
  1291. }else{
  1292. $("input[name='"+inputfield[i1]+"']").val(str);
  1293. }
  1294. }else{
  1295. if(inputs.length>1){
  1296. var inpu = inputs[i1]+"."+inputfield[i1];
  1297. $("input[name='"+inpu+"']").val("");
  1298. }else{
  1299. $("input[name='"+inputfield[i1]+"']").val("");
  1300. }
  1301. }
  1302. }
  1303. }else{
  1304. //对应数据库字段为空的情况下并且字典CODE传入一个值时,根据表单中字典TEXT的值从popup中来取值
  1305. var str = "";
  1306. $.each( selected, function(i, n){
  1307. if (i==0)
  1308. str+= n[inputfield];
  1309. else
  1310. str+= ","+n[inputfield];
  1311. });
  1312. var inputname = $(pobj).attr("name");
  1313. var inputs = inputname.split(".");
  1314. if(str.indexOf("undefined")==-1){
  1315. if(inputs.length>1){
  1316. var inpu = inputs[i1]+"."+inputfield[i1];
  1317. $("input[name='"+inpu+"']").val(str);
  1318. }else{
  1319. $("input[name='"+inputfield+"']").val(str);
  1320. }
  1321. }else{
  1322. if(inputs.length>1){
  1323. var inpu = inputs[i1]+"."+inputfield[i1];
  1324. $("input[name='"+inpu+"']").val("");
  1325. }else{
  1326. $("input[name='"+inputfield+"']").val("");
  1327. }
  1328. }
  1329. }
  1330. }
  1331. return true;
  1332. }
  1333. },
  1334. cancelVal: '关闭',
  1335. cancel: true // 为true等价于function(){}
  1336. });
  1337. }else{
  1338. $.dialog({
  1339. content: "url:cgReportController.do?popup&id="+pcode,
  1340. zIndex: getzIndex(),
  1341. lock : true,
  1342. title:"选择",
  1343. width:800,
  1344. height: 400,
  1345. parent:windowapi,
  1346. cache:false,
  1347. ok: function(){
  1348. iframe = this.iframe.contentWindow;
  1349. var selected = iframe.getSelectRows();
  1350. if (selected == '' || selected == null ){
  1351. alert("请选择");
  1352. return false;
  1353. }else {
  1354. //对应数据库字段不为空的情况下,根据表单中字典TEXT的值来取popup的值
  1355. if(tablefield != "" && tablefield != null){
  1356. var fields = tablefield.split(",");
  1357. var inputfield = inputnames.split(",");
  1358. for(var i1=0;i1<fields.length;i1++){
  1359. var str = "";
  1360. $.each( selected, function(i, n){
  1361. if (i==0)
  1362. str+= n[fields[i1]];
  1363. else{
  1364. str+= ",";
  1365. str+=n[fields[i1]];
  1366. }
  1367. });
  1368. var inputname = $(pobj).attr("name");
  1369. var inputs = inputname.split(".");
  1370. //判断传入的this格式是否为 "AA[#index#].aa"的形式
  1371. if(str.indexOf("undefined")==-1){
  1372. if(inputs.length>1){
  1373. var inpu = inputs[i1]+"."+inputfield[i1];
  1374. $("input[name='"+inpu+"']").val(str);
  1375. }else{
  1376. $("input[name='"+inputfield[i1]+"']").val(str);
  1377. }
  1378. }else{
  1379. if(inputs.length>1){
  1380. var inpu = inputs[i1]+"."+inputfield[i1];
  1381. $("input[name='"+inpu+"']").val("");
  1382. }else{
  1383. $("input[name='"+inputfield[i1]+"']").val("");
  1384. }
  1385. }
  1386. }
  1387. }else{
  1388. //对应数据库字段为空的情况下并且字典CODE传入多个值时,根据表单中字典CODE的值从popup中来取值
  1389. var inputfield = inputnames.split(",");
  1390. if(inputfield.length>1){
  1391. for(var i1=0;i1<inputfield.length;i1++){
  1392. var str = "";
  1393. $.each( selected, function(i, n){
  1394. if (i==0)
  1395. str+= n[inputfield[i1]];
  1396. else{
  1397. str+= ",";
  1398. str+=n[inputfield[i1]];
  1399. }
  1400. });
  1401. var inputname = $(pobj).attr("name");
  1402. var inputs = inputname.split(".");
  1403. if(str.indexOf("undefined")==-1){
  1404. if(inputs.length>1){
  1405. var inpu = inputs[i1]+"."+inputfield[i1];
  1406. $("input[name='"+inpu+"']").val(str);
  1407. }else{
  1408. $("input[name='"+inputfield[i1]+"']").val(str);
  1409. }
  1410. }else{
  1411. if(inputs.length>1){
  1412. var inpu = inputs[i1]+"."+inputfield[i1];
  1413. $("input[name='"+inpu+"']").val("");
  1414. }else{
  1415. $("input[name='"+inputfield[i1]+"']").val("");
  1416. }
  1417. }
  1418. }
  1419. }else{
  1420. //对应数据库字段为空的情况下并且字典CODE传入一个值时,根据表单中字典TEXT的值从popup中来取值
  1421. var str = "";
  1422. $.each( selected, function(i, n){
  1423. if (i==0)
  1424. str+= n[inputfield];
  1425. else
  1426. str+= ","+n[inputfield];
  1427. });
  1428. var inputname = $(pobj).attr("name");
  1429. var inputs = inputname.split(".");
  1430. if(str.indexOf("undefined")==-1){
  1431. if(inputs.length>1){
  1432. var inpu = inputs[i1]+"."+inputfield[i1];
  1433. $("input[name='"+inpu+"']").val(str);
  1434. }else{
  1435. $("input[name='"+inputfield+"']").val(str);
  1436. }
  1437. }else{
  1438. if(inputs.length>1){
  1439. var inpu = inputs[i1]+"."+inputfield[i1];
  1440. $("input[name='"+inpu+"']").val("");
  1441. }else{
  1442. $("input[name='"+inputfield+"']").val("");
  1443. }
  1444. }
  1445. }
  1446. }
  1447. return true;
  1448. }
  1449. },
  1450. cancelVal: '关闭',
  1451. cancel: true // 为true等价于function(){}
  1452. });
  1453. }
  1454. }
  1455. //add--end--Author:gengjiajia date:20160802 for: TASK #1175 批量添加数据的时popup多值的传递
  1456. //update--begin--author:zhangjiaqiang date:20170527 for:增加鼠标放在图片上方,显示图片大图
  1457. /*
  1458. * 鼠标放在图片上方,显示大图
  1459. */
  1460. var bigImgIndex = null;
  1461. function tipImg(obj){
  1462. try{
  1463. var navigatorName = "Microsoft Internet Explorer";
  1464. if( navigator.appName != navigatorName ){
  1465. if(obj.nodeName == 'IMG'){
  1466. var e = window.event;
  1467. var x = e.clientX+document.body.scrollLeft + document.documentElement.scrollLeft
  1468. var y = e.clientY+document.body.scrollTop + document.documentElement.scrollTop
  1469. var src = obj.src;
  1470. var width = obj.naturalWidth;
  1471. var height = obj.naturalHeight;
  1472. bigImgIndex = layer.open({
  1473. content:[src,'no'],
  1474. type:2,
  1475. offset:[y+"px",x+"px"],
  1476. title:false,
  1477. area:[width+"px",height+"px"],
  1478. shade:0,
  1479. closeBtn:0
  1480. });
  1481. }
  1482. }
  1483. }catch(e){
  1484. }
  1485. }
  1486. function moveTipImg(){
  1487. try{
  1488. if(bigImgIndex != null){
  1489. layer.close(bigImgIndex);
  1490. }
  1491. }catch(e){
  1492. }
  1493. }
  1494. //update--end--author:zhangjiaqiang date:20170527 for:增加鼠标放在图片上方,显示图片大图