common.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666
  1. var session = null;
  2. var MenuBtnMap = null;//按钮权限
  3. var url = document.location.pathname;
  4. var itmp = url.indexOf("/", 1);
  5. var webpath = itmp < 0 ? url : url.substr(0, itmp);
  6. if (webpath.indexOf('/') == -1) {
  7. webpath = '/' + webpath;
  8. }
  9. Commonjs = {
  10. /**
  11. * 医院ID
  12. * @return {}
  13. */
  14. hospitalId : '1001',
  15. hospitalName: '健康之路演示医院',
  16. /**
  17. *
  18. * @param {Object} url
  19. * @param {Object} param
  20. * @param {Object} flag
  21. * @return {TypeName}
  22. */
  23. getRootPath : window.location.protocol + '//' + window.location.host + webpath,
  24. getRoot : window.location.protocol + '//' + window.location.host,
  25. ajax :function (url,param,flag){
  26. var obj = null;
  27. $.ajax({
  28. type: 'POST',
  29. url: url+'?v='+(new Date()),
  30. data: param,
  31. async: flag,
  32. timeout : 6000,
  33. cache : false,
  34. dataType: 'json',
  35. success: function(data){
  36. obj = data;
  37. }
  38. });
  39. if(!flag) return obj;
  40. },
  41. trim : function(str) {
  42. return str.replace(/(^\s*)|(\s*$)/g, "");
  43. },
  44. getUrlParam : function (val) {
  45. var uri = window.location.search;
  46. var re = new RegExp("" +val+ "\=([^\&\?]*)", "ig");
  47. return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);
  48. },
  49. isEmpty : function(s){
  50. if(s == undefined){
  51. return true;
  52. }else{
  53. if(s == null || s == '' || s == 'undefined'
  54. || s == 'null' || s.length < 1){
  55. return true;
  56. }
  57. }
  58. return false;
  59. },
  60. getUrl : function(model){
  61. if(!this.isEmpty(model)){
  62. return '../'+model+'_doAll.do';
  63. }else{
  64. return '';
  65. }
  66. },
  67. getParams : function(headCode,Service,page){
  68. var params = {};
  69. params.Req = {};
  70. params.Req.Service = {};
  71. if(!this.isEmpty(headCode)){
  72. params.Req.TransactionCode = headCode;
  73. }else return null;
  74. if(!this.isEmpty(Service)){
  75. params.Req.Service = Service;
  76. if(!this.isEmpty(page)){
  77. params.Req.Service.Page = {};
  78. params.Req.Service.Page = page;
  79. }
  80. }else return null;
  81. return params;
  82. },
  83. jsonToString : function(obj){
  84. var THIS = this;
  85. switch(typeof(obj)){
  86. case 'string':
  87. return '"' + obj.replace(/(["\\])/g, '\\$1') + '"';
  88. case 'array':
  89. return '[' + obj.map(THIS.jsonToString).join(',') + ']';
  90. case 'object':
  91. if(obj instanceof Array){
  92. var strArr = [];
  93. var len = obj.length;
  94. for(var i=0; i<len; i++){
  95. strArr.push(THIS.jsonToString(obj[i]));
  96. }
  97. return '[' + strArr.join(',') + ']';
  98. }else if(obj==null){
  99. return 'null';
  100. }else{
  101. var string = [];
  102. for (var property in obj) string.push(THIS.jsonToString(property) + ':' + THIS.jsonToString(obj[property]));
  103. return '{' + string.join(',') + '}';
  104. }
  105. case 'number': return obj;
  106. case false: return obj;
  107. }
  108. },
  109. /**
  110. * 获取渠道下拉列表
  111. * @param {Object} elementid (select的id)
  112. * @param {Object} selval (选中值)
  113. * @return {TypeName}
  114. */
  115. loadChannelSelect : function(elementid, selval) {
  116. var param = {};
  117. var Service = {};
  118. Service.key = "";
  119. var code = 91000;
  120. var params = Commonjs.getParams(code,Service);//获取参数
  121. param.Api = "GetChannelSelect";
  122. param.Params = Commonjs.jsonToString(params);
  123. var d = Commonjs.ajax('./channel_callDemoApi.do',param,false);
  124. if(d.RespCode != 10000){
  125. return;
  126. }
  127. var options = '';
  128. options += "<option value=''>--请选择--</option>";
  129. $.each(d.Data,function(i,item){
  130. options += "<option value='" + item.ChannelId + "'>" + item.ChannelName + "</option>";
  131. });
  132. $("#"+elementid).empty();
  133. $("#"+elementid).append(options);
  134. if(!Commonjs.isEmpty(selval)) {
  135. $("#"+elementid).val(selval);
  136. }
  137. },
  138. resizeAllPage : function() {
  139. var winHeight=$(window).height();
  140. $(".aside .scroll-pane").height(winHeight-61).jScrollPane({"autoReinitialise": true,"overflow":true});
  141. if (!($.browser.msie && ($.browser.version == "6.0") && !$.support.style)) {
  142. $(".container-wrap>.scroll-pane").height(winHeight-111).jScrollPane({"autoReinitialise": true});
  143. }else{
  144. $(".container-wrap>.scroll-pane").height(winHeight-111).width($(window).width()-195);
  145. }
  146. },
  147. getDate : function(day) {
  148. var today = new Date();
  149. var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
  150. today.setTime(targetday_milliseconds); // 注意,这行是关键代码
  151. var tYear = today.getFullYear();
  152. var tMonth = today.getMonth();
  153. var tDate = today.getDate();
  154. tMonth = Commonjs.doHandleMonth(tMonth + 1);
  155. tDate = Commonjs.doHandleMonth(tDate);
  156. return tYear + "-" + tMonth + "-" + tDate;
  157. },
  158. doHandleMonth : function(month){
  159. var m = month;
  160. if (month.toString().length == 1) {
  161. m = "0" + month;
  162. }
  163. return m;
  164. },
  165. /**
  166. * icon不传则为提示错误信息, 成功icon传add
  167. *
  168. * @param {Object} msg
  169. * @param {Object} icon
  170. */
  171. alert: function(msg,icon) {
  172. var ic = icon;
  173. if(icon==undefined||Commonjs.isEmpty(icon)) {
  174. ic = 'error';
  175. }
  176. art.dialog({
  177. lock : true,
  178. artIcon : ic,
  179. opacity : 0.4,
  180. width : 250,
  181. title : '提示',
  182. time : 3,
  183. content : msg,
  184. ok : function() {
  185. }
  186. });
  187. },
  188. /**
  189. * 获取客户端操作系统
  190. * @return {TypeName}
  191. */
  192. getOS : function() {
  193. var sUserAgent = navigator.userAgent;
  194. var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
  195. var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
  196. if (isMac) return "Mac";
  197. var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
  198. if (isUnix) return "Unix";
  199. var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
  200. var bIsAndroid = sUserAgent.toLowerCase().match(/android/i) == "android";
  201. if (isLinux) {
  202. if(bIsAndroid) return "Android";
  203. else return "Linux";
  204. }
  205. if (isWin) {
  206. var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
  207. if (isWin2K) return "Win2000";
  208. var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 ||
  209. sUserAgent.indexOf("Windows XP") > -1;
  210. if (isWinXP) return "WinXP";
  211. var isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
  212. if (isWin2003) return "Win2003";
  213. var isWinVista= sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
  214. if (isWinVista) return "WinVista";
  215. var isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;
  216. if (isWin7) return "Win7";
  217. }
  218. return "other";
  219. },
  220. checkOS : function() {
  221. var os = Commonjs.getOS();
  222. if(os=='Win2000'||os=='WinXP'||os=='Win2003')
  223. return true;
  224. return false;
  225. },
  226. /**
  227. * 滚动条对象
  228. *
  229. * @param {Object} formId
  230. */
  231. getJscrollpane : null,
  232. /**
  233. * @param {Object} menuId
  234. * 设置改界面按钮的状态,建议在$(function(){最后代码添加})、还有在手动js生成html的时候添加
  235. */
  236. btnPermissionControl:function(menuId){
  237. if ( MenuBtnMap == null ){
  238. //加载按钮数据
  239. var map = {};
  240. var menuData = Commonjs.getSession().Data;
  241. if(menuData.length!=undefined) {
  242. for(var i = 0; i < menuData.length; i++){
  243. var btnArray = menuData[i].BtnPermissionData;
  244. if(btnArray!=undefined && btnArray.length>0){
  245. var tempMenuId = btnArray[0].MenuId;
  246. map[tempMenuId] = btnArray;
  247. }
  248. // btnJson = btnJson.substring(9,btnJson.length);
  249. // btnJson = btnJson.substring(0,btnJson.length-3);
  250. // var btnArray = eval('(' + btnJson + ')');
  251. // if(btnArray.length>0){
  252. // var menuId = btnArray[0].menuId;
  253. // map[menuId] = btnArray;
  254. // }
  255. }
  256. }
  257. MenuBtnMap = map;
  258. }
  259. //循环判断
  260. if( MenuBtnMap[menuId].length>0 ){
  261. for(var i = 0; i < MenuBtnMap[menuId].length; i++){
  262. var btn = MenuBtnMap[menuId][i];
  263. if(btn.State == 0){
  264. $("[btnPermission='"+btn.ButtonType+"']").unbind('click');
  265. $("[btnPermission='"+btn.ButtonType+"']").removeAttr('onclick');
  266. }
  267. }
  268. }
  269. }
  270. }
  271. //////////////////////////////////////////// huangql添加部分 //////////////////////////////////
  272. ComWbj = {
  273. //表单验证:验证单个控件,不符合弹出红色浮动提示框
  274. checkOne:function(formId){
  275. $("#"+formId).validationEngine();
  276. },
  277. //整个表单验证:点击提交按钮时才触发验证规则
  278. checkFormAll:function(formId){
  279. var v = $("#"+formId).validationEngine("validate");
  280. if(v==false){
  281. return;
  282. $("#"+formId).submit(function(){return false;});
  283. }
  284. },
  285. telCheck:function(id){ /* 电话号码没有中杠号时,把电话号码的区号后面,自动添加一个空格号*/
  286. var num = $("#"+id).val(); var str = "";
  287. //var reg_3 = /^(010|02[0-9]|852|853)([0-9]{4}|[0-9]{5}|[0-9]{7}|[0-9]{8})$/; //验证电话号码区号为3位
  288. var reg_3 = /^(010|02[0-9]|852|853)([0-9]{3}|[0-9]{4}|[0-9]{5}|[0-9]{6}|[0-9]{7}|[0-9]{8})$/; //验证电话号码区号为3位
  289. if( reg_3.test(num) & (num.indexOf("-") == -1 || num.indexOf("—")) ){
  290. str = num.substr(0,3).replace(num.substr(0,3), num.substr(0,3)+' ');
  291. $("#"+id).val(str+num.substr(3,num.length));
  292. }
  293. var reg_4 = /^(0[3-9][0-9][0-9])([0-9]{3}|[0-9]{4}|[0-9]{5}|[0-9]{6}|[0-9]{7}|[0-9]{8})$/; //验证电话号码区号为4位
  294. if( reg_4.test(num) & (num.indexOf("-") == -1|| num.indexOf("—")) ){
  295. str = num.substr(0,4).replace(num.substr(0,4), num.substr(0,4)+' ');
  296. $("#"+id).val(str+num.substr(4,num.length));
  297. }
  298. },
  299. /**
  300. 清空特殊字符、自动清空null和undefined
  301. *@param id:input控件的ID号
  302. *@param objStr:过滤的对象:name或者address或者time或者all
  303. *@use 姓名过滤:<input type="text" onBlur="ComWbj.stripStr('deptName','name');" id="deptName" />
  304. *@use 地址过滤:<input type="text" onBlur="ComWbj.stripStr('address','address');" id="address" />
  305. *@use 过滤全部:<textarea onblur="ComWbj.stripStr('deptIntro','all')" id="deptIntro" cols="40" rows="5"></textarea>
  306. */
  307. stripStr:function(id, objStr) {
  308. var val=$("#"+id).val();
  309. var containSpecial = "";
  310. var rs = "";
  311. if(val == "null" || val == "undefined"){
  312. rs="";
  313. }else{
  314. if(objStr == "name") containSpecial = RegExp(/[(\1)(\2)(\3)(\4)(\5)(\6)(\7)(\8)(\9)(\0)(\A)(\B)(\C)(\D)(\E)(\F)(\G)(\H)(\I)(\J)(\K)(\L)(\M)(\N)(\O)(\P)(\Q)(\R)(\S)(\T)(\U)(\V)(\W)(\X)(\Y)(\Z)(\T)(\U)(\V)(\W)(\Z)(\a)(\b)(\c)(\d)(\e)(\f)(\g)(\h)(\i)(\j)(\k)(\l)(\m)(\n)(\o)(\p)(\q)(\r)(\s)(\t)(\u)(\v)(\w)(\x)(\y)(\z)(\ )(\~)(\!)(\!)(\@)(\#)(\$)(\¥)(\*)(\&)(\。)(\,)(\;)(\:)(\%)(\^)(\&)(\*)(\-)(\_)(\+)(\=)(\|)(\\)(\;)(\:)(\`)(\')(\")(\‘)(\’)(\“)(\”)(\,)(\.)(\/)(\?)(\?)]+/);
  315. else if(objStr == "address") containSpecial = RegExp(/[(\1)(\2)(\3)(\4)(\5)(\6)(\7)(\8)(\9)(\0)(\A)(\B)(\C)(\D)(\E)(\F)(\G)(\H)(\I)(\J)(\K)(\L)(\M)(\N)(\O)(\P)(\Q)(\R)(\S)(\T)(\U)(\V)(\W)(\X)(\Y)(\Z)(\T)(\U)(\V)(\W)(\Z)(\a)(\b)(\c)(\d)(\e)(\f)(\g)(\h)(\i)(\j)(\k)(\l)(\m)(\n)(\o)(\p)(\q)(\r)(\s)(\t)(\u)(\v)(\w)(\x)(\y)(\z)(\ )(\~)(\!)(\!)(\@)(\$)(\¥)(\&)(\。)(\%)(\^)(\&)(\_)(\+)(\=)(\|)(\\)(\;)(\;)(\:)(\')(\")(\‘)(\“)(\?)(\?)]+/);
  316. else if(objStr == "time") containSpecial = RegExp(/[(\1)(\2)(\3)(\4)(\5)(\6)(\7)(\8)(\9)(\0)(\A)(\B)(\C)(\D)(\E)(\F)(\G)(\H)(\I)(\J)(\K)(\L)(\M)(\N)(\O)(\P)(\Q)(\R)(\S)(\T)(\U)(\V)(\W)(\X)(\Y)(\Z)(\T)(\U)(\V)(\W)(\Z)(\a)(\b)(\c)(\d)(\e)(\f)(\g)(\h)(\i)(\j)(\k)(\l)(\m)(\n)(\o)(\p)(\q)(\r)(\s)(\t)(\u)(\v)(\w)(\x)(\y)(\z)(\ )(\~)(\!)(\@)(\#)(\$)(\¥)(\……)(\*)(\&)(\()(\))(\【)(\】)(\。)(\,)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=)(\[)(\])(\{)(\})(\|)(\\)(\;)(\')(\")(\,)(\.)(\<)(\>)(\?)(\)]+/);
  317. else containSpecial = RegExp(/[(\1)(\2)(\3)(\4)(\5)(\6)(\7)(\8)(\9)(\0)(\A)(\B)(\C)(\D)(\E)(\F)(\G)(\H)(\I)(\J)(\K)(\L)(\M)(\N)(\O)(\P)(\Q)(\R)(\S)(\T)(\U)(\V)(\W)(\X)(\Y)(\Z)(\T)(\U)(\V)(\W)(\Z)(\a)(\b)(\c)(\d)(\e)(\f)(\g)(\h)(\i)(\j)(\k)(\l)(\m)(\n)(\o)(\p)(\q)(\r)(\s)(\t)(\u)(\v)(\w)(\x)(\y)(\z)(\ )(\~)(\!)(\@)(\#)(\$)(\¥)(\……)(\*)(\&)(\()(\))(\【)(\】)(\。)(\,)(\%)(\^)(\&)(\*)(\()(\))(\-)(\—)(\_)(\+)(\=)(\[)(\])(\{)(\})(\|)(\\)(\;)(\:)(\:)(\“)(\”)(\‘)(\’)(\`)(\《)(\》)(\!)(\')(\")(\,)(\、)(\.)(\●)(\/)(\<)(\>)(\?)(\?)]+/);
  318. for (var i = 0; i < val.length; i++) { rs = rs + val.substr(i, 1).replace(containSpecial, ''); }
  319. }
  320. return $("#"+id).val(rs);
  321. },
  322. /**
  323. 清空指定的特殊字符
  324. *@param id:input控件的ID号
  325. *@param str:指定的特殊字符(中间以(\)分隔,比如要删除# +,写成:(\#)(\+))
  326. *@use 比如需要清空+ & #:<textarea onblur="stripOutStr(this,'[$\']')" id="deptIntro" cols="40" rows="5"></textarea>
  327. */
  328. stripOutStr:function(id,str) {
  329. var pattern = new RegExp(str)
  330. var s=$(id).val();
  331. var rs = "";
  332. for (var i = 0; i < s.length; i++) { rs = rs + s.substr(i, 1).replace(pattern, ''); }
  333. },
  334. /**
  335. * 功能:将浮点数四舍五入,取小数点后2位
  336. * 用法: changeTwoDecimal(3.1415926) 返回 3.14
  337. * changeTwoDecimal(3.1475926) 返回 3.15
  338. */
  339. changeTwoDecimal:function(x) {
  340. var f_x = parseFloat(x);
  341. if (isNaN(f_x)){
  342. ComWbj.alertIconNo("提示","function:changeTwoDecimal->parameter error","warning");
  343. return false;
  344. }
  345. var f_x = Math.round(x*100)/100;
  346. return f_x;
  347. },
  348. trim:function(id){ $("#"+id).val($("#"+id).val().replace(/(^\s*)|(\s*$)/g, "")); }, //去除input输入框的首尾空格
  349. trimStr:function(str){ return str.replace(/(^\s*)|(\s*$)/g, ""); }, //去除字符串首尾空格
  350. /**
  351. 截取字符串
  352. *@param str:被截取的字符串
  353. *@param start:从start位开始截取
  354. **@param end:从end位结束
  355. */
  356. subStrChar:function(str,start,end){ return str.substr(start,end); },
  357. getSex:function(sex){ //根据数字1和2判断男女
  358. var s ='';
  359. switch (parseInt(sex)){
  360. case 1: s='男'; break;
  361. case 2: s='女'; break;
  362. default: s='未知'; break;
  363. }
  364. return s;
  365. },
  366. getDoctorType:function(type){ //根据数字1和2判断男女
  367. var s ='';
  368. switch (parseInt(type)){
  369. case 1: s='医生'; break;
  370. case 2: s='药师'; break;
  371. case 3: s='技师'; break;
  372. case 3: s='护士'; break;
  373. default: s='其他'; break;
  374. }
  375. return s;
  376. },
  377. isNull:function(param){ //判断对象是否为空
  378. if(typeof(param) == undefined || typeof(param) == 'undefined' || param == null || param == '')
  379. return true;
  380. else
  381. return false;
  382. },
  383. strIsNull:function(str){ //判断字符串是否为空
  384. if(str == null || str == undefined){
  385. return '';
  386. }else{
  387. return str;
  388. }
  389. },
  390. isNotNull:function(param){ return !ComWbj.isNull(param); }, //判断对象是否不为空
  391. clearArry:function(arry){ //清空数组中的空值
  392. for(var f = 0 ;f < arry.length; f++){
  393. if(arry[f] == "" || typeof(arry[f]) == "undefined"){ arry.splice(f,1); f= f-1;}
  394. }
  395. },
  396. /*************************************** 弹窗 ****************************************************/
  397. /*关闭弹窗*/
  398. closePop:function(id){
  399. $('#'+id).hide();
  400. },
  401. /*显示弹窗*/
  402. showPop:function(id){
  403. $('#'+id).show();
  404. },
  405. //开启消息正在加载提示
  406. openPG:function(){
  407. YihuUtil.dialog({
  408. title:'消息正在加载....',
  409. content : '<img src="../yygh/pg1.gif"/>',
  410. lock : true,
  411. padding : 0,
  412. id: 'pg'
  413. });
  414. },
  415. //结束消息正在加载
  416. closePG:function(){
  417. YihuUtil.wid().art.dialog.list["pg"].close();
  418. },
  419. //打开进度条
  420. openProgress:function(){
  421. $.messager.progress({
  422. title:'进度',
  423. msg:'正在提交,请稍等...'
  424. });
  425. },
  426. //关闭进度条
  427. closeProgress:function(){
  428. $.messager.progress('close');
  429. },
  430. //确定提示: 调用:alertMsg('导入成功20条数据','');
  431. alertMsg:function(msg,action){
  432. YihuUtil.dialog({
  433. title:"提示",
  434. content: msg,
  435. button : [{
  436. name : '确定',
  437. callback : action
  438. }]
  439. });
  440. },
  441. //自定义弹出框
  442. alertMsgOk:function(a, b) {
  443. YihuUtil.dialog( {
  444. title : a,
  445. id : 'alertMsgOk',
  446. content : b,
  447. lock : true,
  448. button : [ {
  449. name : 'OK',
  450. focus : true
  451. } ]
  452. })
  453. },
  454. //自定义弹出框3,带icon标志符号(关闭时不会自动刷新当前页面)
  455. alertIconNo:function(a, b,icon) {
  456. YihuUtil.dialog( {
  457. title : a,
  458. id : 'alertIconNoReload',
  459. content : b,
  460. icon:icon,
  461. close:function(){
  462. },
  463. lock : true,
  464. button : [ {
  465. name : 'OK',
  466. focus : true
  467. } ]
  468. })
  469. },
  470. //自定义弹出框,带icon标志符号(关闭会刷新当前页面)
  471. alertIcon:function(a, b,icon) {
  472. YihuUtil.dialog( {
  473. title : a,
  474. id : 'alertIcon',
  475. content : b,
  476. icon:icon,
  477. close:function(){
  478. window.location.reload();
  479. },
  480. lock : true,
  481. button : [ {
  482. name : 'OK',
  483. focus : true
  484. } ]
  485. })
  486. },
  487. alertAutoClose:function(a, b, icon, url) { //未使用
  488. YihuUtil.dialog( {
  489. title : a,
  490. id : 'alertAutoClose',
  491. content : b,
  492. icon:icon,
  493. time: 3000,
  494. close:function(){
  495. location.href = url;
  496. },
  497. lock : true
  498. })
  499. },
  500. alertClose:function() { //未使用
  501. YihuUtil.dialog( {
  502. time: 3000
  503. })
  504. },
  505. /**
  506. * 短暂提示,自动关闭
  507. * @param content {String} 提示内容
  508. * @param time {Number} 显示时间 (默认1.5秒)
  509. * @param url {String} 要跳转的地址,不需要跳转时可以写成null
  510. */
  511. artTips:function (title, icon, content, time, url) {
  512. return artDialog({
  513. id: 'Tips',
  514. title: title,
  515. icon: icon,
  516. cancel: false,
  517. fixed: true,
  518. lock: true,
  519. ok: false,
  520. close: function(){
  521. if(url != null){
  522. location.href = url;
  523. }
  524. }
  525. })
  526. .content('<div style="padding: 20px;font-size:14px;">' + content + '</div>')
  527. .time(time || 1);
  528. },
  529. /**
  530. * 短暂提示,自动关闭
  531. * @param content {String} 提示内容
  532. * @param time {Number} 显示时间 (默认1.5秒)
  533. * @param url {String} 自定义 by wuyiqing
  534. */
  535. sofunartTips:function (title, icon, content, time,fun) {
  536. return artDialog({
  537. id: 'Tips',
  538. title: title,
  539. icon: icon,
  540. cancel: false,
  541. fixed: true,
  542. lock: true,
  543. ok: false,
  544. close: function(){
  545. fun();
  546. }
  547. })
  548. .content('<div style="padding: 20px;font-size:14px;">' + content + '</div>')
  549. .time(time || 1);
  550. },
  551. /**
  552. 删除提示框
  553. * @param message: 删除提示信息
  554. * @param action: do操作的地址
  555. * @param param: 删除需要的具体参数数组
  556. * @return
  557. */
  558. alertDel:function(message,action,param){
  559. alertify.confirm(message, function (e) {
  560. if(e) {//确认删除
  561. doAjaxLoadData(action, param, function(resp) {
  562. if(resp.Code == 10000){
  563. window.location.reload();
  564. alertify.success("已删除成功!");
  565. }
  566. });
  567. }
  568. });
  569. },
  570. /**
  571. 删除提示框(存在特定不允许删除的条件时,弹出不可删除的提示信息)
  572. * @param url: do操作的地址
  573. * @param param: 删除需要的具体参数数组
  574. * @EX
  575. */
  576. alertDelTwo:function(url, params){
  577. YihuUtil.dialog({
  578. title:"提示",
  579. content: '确认要删除么?',
  580. button : [{
  581. name: '确认',
  582. callback: function () {
  583. doAjaxLoadData(url, params, function(result) {
  584. if (result.code == -1) {
  585. ComWbj.alertIconNo("提示",result.message,"error");
  586. } else {
  587. ComWbj.alertIcon("提示","删除成功!","succeed");
  588. }
  589. });
  590. }
  591. },
  592. {
  593. name: '取消'
  594. }]
  595. });
  596. },
  597. //页面弹出:写有html的层
  598. alertHtml:function(title,id,fun) {
  599. YihuUtil.dialog( {
  600. title : title,
  601. id : 'testID',
  602. padding: '0px 0px',
  603. content : document.getElementById(id),
  604. lock : true,
  605. close : function() {
  606. },
  607. button : [
  608. {
  609. name: '确定',
  610. //callback: function () {
  611. callback: function fun() {
  612. Demo_getVal(this.DOM.dialog[0]);
  613. return true;
  614. },
  615. focus: true
  616. },
  617. {
  618. name: '确定2',
  619. callback: function () {
  620. }
  621. },
  622. {
  623. name: '取消'
  624. }
  625. ]
  626. /*button : [
  627. {
  628. name: '确定',
  629. callback: function () {
  630. Demo_getVal(this.DOM.dialog[0]);
  631. return false;
  632. },
  633. focus: true
  634. },
  635. {
  636. name: '不同意',
  637. callback: function () {
  638. alert('你不同意')
  639. }
  640. },
  641. {
  642. name: '无效按钮',
  643. disabled: true
  644. },
  645. {
  646. name: '关闭我'
  647. }
  648. ]*/
  649. });
  650. },
  651. /*设置弹窗垂直居中*/
  652. popBoxMiddle:function(id){
  653. popbox=$("#"+id);
  654. for(i=0;i<popbox.length;i++){
  655. popbox.eq(i).css("margin-top",function(){
  656. return "-"+$(this).height()/2+"px";
  657. })
  658. }
  659. },
  660. //打开遮罩界面 (dialogName:弹窗的名称;title:标题;id:iframe的ID)
  661. pocmessage:function(dialogName,id,title,o,index,val) {
  662. YihuUtil.dialog( {
  663. title : title, id : dialogName, padding: '0', content : document.getElementById(id), lock : true,
  664. close : function() {
  665. if(o){
  666. if(index == 3){
  667. loadDeptSelect(o.id);
  668. }else if(index == 2 && val != null && val != 0){
  669. loadDoctorSelect(val,o.id);
  670. }
  671. ComWbj.closePop(dialogName);
  672. }else window.location.reload();
  673. },
  674. button : [ ]
  675. });
  676. },
  677. closeDiaLog:function(id){ YihuUtil.wid().art.dialog.list[id].close(); }, //关闭YihuUtil.dialog弹出框
  678. /****************************************** 复选框操作 **************************************************/
  679. /**
  680. 复选框全选
  681. * @param checkAll: 勾选全选的复选框的name属性名称
  682. * @param checkChild: 列表中被选中的复选框name属性名称
  683. */
  684. checkAll:function(checkAll,checkChild){
  685. var checked= $("input[name='"+checkAll+"']").attr('checked');
  686. if(checked!='checked') checked=false;
  687. $.each($("input[name='"+checkChild+"']"),function(i,item){
  688. $(this).attr('checked',checked);
  689. });
  690. },
  691. /**
  692. 获取复选框选中项的值
  693. * @param name: 列表中被选中的复选框name属性名称
  694. */
  695. getChecks:function(name){
  696. var hy='';
  697. var hys=[];
  698. $.each($("input[name='"+checks+"']:checked"),function(i,item){
  699. hys.push(item.value);
  700. });
  701. hy=hys.toString();
  702. return hy;
  703. },
  704. /**
  705. 下拉列表框中有多个复选框:点击后下拉框可多选,若选择多个,中间用“,”隔开;若选择太多,框内无法显示,则以“…”号表示
  706. * @param name: 列表中被选中的复选框name属性名称
  707. * @param textId: 显示内容的文本框ID
  708. * @param selectDivId: 装载复选框的DIV的ID
  709. */
  710. setSelectChecks:function(name,textId,selectDivId){
  711. var strText = $("#"+textId).text(); //文本框最终要显示的内容
  712. $("#"+textId).live('click', function() { //点击时,显示select列表
  713. $("#"+selectDivId).slideDown();
  714. })
  715. $("input[name='"+ name +"']").live('click', function() { //选中复选框的值
  716. var strSplit = strText.split(",");
  717. if($(this).attr('checked') == "checked"){
  718. strText = strText + ',' + $(this).val();
  719. }else{
  720. if($(this).val() == strSplit[strSplit.length-1]){ //如果是最后个词,是没有逗号
  721. strText = strText.replace( "," + $(this).val() , "");
  722. }else{
  723. strText = strText.replace( $(this).val() + "," , "");
  724. }
  725. if(strSplit.length == 1){
  726. strText = strText.replace( $(this).val() , "--请选择--");
  727. }
  728. }
  729. if(strText.substr(0,1) == ","){
  730. $("#"+textId).text(ComWbj.subStrChar(strText,1,strText.length));
  731. }else if(strText.substr(0,8) == "--请选择--,"){
  732. $("#"+textId).text(ComWbj.subStrChar(strText,8,strText.length));
  733. }else{
  734. $("#"+textId).text(ComWbj.subStrChar(strText,0,strText.length));
  735. }
  736. });
  737. $("#"+selectDivId).live('mouseover', function() { //显示
  738. $(this).show();
  739. });
  740. $("#"+selectDivId).live('mouseout', function() { //隐藏
  741. $(this).hide();
  742. });
  743. },
  744. /****************************************** 下拉列表操作 **************************************************/
  745. /**
  746. 设置下拉列表框的值
  747. *@param id:select 的 id
  748. *@param list:select 的 list值
  749. *@param itemId:option 的 value值
  750. *@param itemName:option 的 name值
  751. */
  752. setSelectVal:function(id,list,itemId,itemName){
  753. var options = '';
  754. options += "<option value=''>--请选择--</option>";
  755. $.each(list,function(i,item){
  756. options += "<option value='" + itemId + "'>" + itemName + "</option>";
  757. });
  758. $("#"+id).empty();
  759. $("#"+id).append(options);
  760. },
  761. /****************************************** 单选按钮操作 **************************************************/
  762. radioIsChecked:function(n){ //判断一组中的某个单选按钮是否选中
  763. alert($(":radio[name='ReplyType']").eq(n).is(":checked"));
  764. },
  765. /*************************** 排序 医生信息->医生排序;科室信息->科室排序 ***************************************/
  766. ZH:function(list,i,fs){ //重排序
  767. if(fs==1){
  768. var dd={};
  769. dd=list[i];
  770. list[i]=list[i-1];
  771. list[i-1]=dd;
  772. }else if(fs==2){
  773. var dd={};
  774. dd=list[i];
  775. list[i]=list[i+1];
  776. list[i+1]=dd;
  777. }else{
  778. var dd={};
  779. dd=list[i];
  780. for(var j=i;j>0;){
  781. list[j]=list[j-1]
  782. j=j-1;
  783. }
  784. list[0]=dd;
  785. }
  786. return list;
  787. },
  788. goUp:function(i){ //上移
  789. if(i==0){ return false; }
  790. SORTLIST = ComWbj.ZH(SORTLIST,i,1); //SORTLIST是全局变量
  791. PlayV();
  792. },
  793. goFirst:function(i){ //置顶
  794. if(i==0){ return false; }
  795. SORTLIST = ComWbj.ZH(SORTLIST,i,3); //SORTLIST是全局变量
  796. PlayV();
  797. },
  798. goDown:function(i){ //下移
  799. if(i==(SORTLIST.length-1)){
  800. return false;
  801. }
  802. SORTLIST = ComWbj.ZH(SORTLIST,i,2); //SORTLIST是全局变量
  803. PlayV();
  804. },
  805. /**
  806. * 快捷:向上
  807. * */
  808. fastUpZH:function(list,i,fs,num){ //list是要排序的列表;i是当前对象;fs是向上或者向下排序;num是共跳转多少行
  809. var temp = []; //要排序的列表
  810. var rr = []; var ss = []; var a; var z; var x; var y; var j;
  811. var s = []; //上
  812. var ff = []; //中
  813. var b = []; //下
  814. if(fs==11){ //之前
  815. for(var j=i-num;j<=i;j++){ temp[j] = list[j]; } //要排序的列表
  816. ComWbj.clearArry(temp); //清空数组空值
  817. for(a=0;a<=num;a++){ //重新生成正确的排序
  818. if(a != num) rr[a] = temp[a];
  819. else ss[0] = temp[a];
  820. }
  821. for(z=0;z<i-num;z++){ s[z] = list[z]; } //要排序的列表
  822. ff = $.merge(ss, rr); //将正确的排序保存到数组
  823. y=0;
  824. for(x=i*1+1*1;x<list.length;x++){ b[y] = list[x]; y++; } //要排序的列表
  825. list = $.merge( $.merge(s,ff), b); //将正确的排序保存到数组
  826. }else{ //之后
  827. for(j=i*1-num*1+1*1;j<=i;j++){ temp[j] = list[j]; } //要排序的列表
  828. ComWbj.clearArry(temp); //清空数组空值
  829. for(a=0;a<num;a++){ //重新生成正确的排序
  830. if(a !=num*1-1*1 ) rr[a] = temp[a];
  831. else ss[0] = temp[a];
  832. }
  833. for(z=0;z<i*1-num*1+1*1;z++){ s[z] = list[z]; } //要排序的列表
  834. ff = $.merge(ss,rr); //将正确的排序保存到数组
  835. y=0;
  836. for(x=i*1+1*1;x<list.length;x++){ b[y] = list[x]; y++; } //要排序的列表
  837. list = $.merge( $.merge(s,ff), b); //将正确的排序保存到数组
  838. }
  839. return list;
  840. },
  841. /**
  842. * 快捷:向下
  843. * */
  844. fastDownZH:function(list,i,fs,num){ //list是要排序的列表;i是当前对象;fs是向上或者向下排序;num是共跳转多少行
  845. var temp = []; //要排序的列表
  846. var rr = []; var ss = []; var a; var z; var x; var y; var j;
  847. var s = []; //上
  848. var ff = []; //中
  849. var b = []; //下
  850. if(fs==11){ //之前
  851. for(var j=i-num;j<=i;j++){ temp[j] = list[j]; } //要排序的列表
  852. ComWbj.clearArry(temp); //清空数组空值
  853. for(a=0;a<=num;a++){ //重新生成正确的排序
  854. if(a != num) rr[a] = temp[a];
  855. else ss[0] = temp[a];
  856. }
  857. for(z=0;z<i-num;z++){ s[z] = list[z]; } //要排序的列表
  858. ff = $.merge(ss, rr); //将正确的排序保存到数组
  859. y=0;
  860. for(x=i*1+1*1;x<list.length;x++){ b[y] = list[x]; y++; } //要排序的列表
  861. list = $.merge( $.merge(s,ff), b); //将正确的排序保存到数组
  862. }else{ //之后
  863. for(j=i;j<=i*1+num*1;j++){ temp[j] = list[j]; } //要排序的列表
  864. ComWbj.clearArry(temp); //清空数组空值
  865. for(a=0;a<=num;a++){ //重新生成正确的排序
  866. if(a >0 ) rr[a] = temp[a];
  867. else ss[0] = temp[a];
  868. }
  869. for(z=0;z<i;z++){ s[z] = list[z]; } //要排序的列表
  870. ff = $.merge(rr,ss); //将正确的排序保存到数组
  871. y=0;
  872. for(x=i*1+1*1+num*1;x<list.length;x++){ b[y] = list[x]; y++; } //要排序的列表
  873. list = $.merge( $.merge(s,ff), b); //将正确的排序保存到数组
  874. ComWbj.clearArry(list); //清空数组空值
  875. }
  876. return list;
  877. },
  878. /**** 具体查看:user/js/zwqxsz.js:function init() *****/
  879. //在li集合中向上移动
  880. up:function(obj){
  881. var _div = $(obj).parent().parent(),
  882. _divp = _div.parent() ,
  883. _divs = _divp.children("li") ,
  884. _divindex = _divs.index(_div);
  885. if(_divindex>0){
  886. _divs.eq(_divindex-1).before(_div);
  887. }
  888. },
  889. //在li集合中向下移动
  890. down:function(obj){
  891. var _div = $(obj).parent().parent() ,
  892. _divp = _div.parent() ,
  893. _divs = _divp.children("li") ,
  894. _divindex = _divs.index(_div);
  895. if(_divindex<_divs.length-1){
  896. _divs.eq(_divindex+1).after(_div);
  897. }
  898. },
  899. vagueDate:function(id,Diseasejson){
  900. $("#"+id).focus(function(){
  901. return false;
  902. }).autocomplete(Diseasejson,{
  903. max:15,
  904. scrollHeight: 300,
  905. matchContains: true,
  906. formatItem: function(row, i, max){ return row.name },
  907. formatMatch: function(row, i, max) { return row.name + "[" + row.sname+"]"; },
  908. formatResult: function(row) { return row.name; }
  909. });
  910. $("#"+id).click().autocomplete(Diseasejson,{
  911. max:15,
  912. scrollHeight: 300,
  913. matchContains: true,
  914. formatItem: function(row, i, max){ return row.name },
  915. formatMatch: function(row, i, max) { return row.name + "[" + row.sname+"]"; },
  916. formatResult: function(row) { return row.name; }
  917. });
  918. $("#"+id).result(function(event, data, formatted){
  919. if(data){
  920. $("#"+id).val(data.id); $("#"+id).val(data.name); $("#"+id).val(data.name);
  921. }else{
  922. $("#"+id).val(0); $("#"+id).val(''); $("#"+id).val('');
  923. }
  924. });
  925. },
  926. /**
  927. 仿芒果网智能提示
  928. *@param TopOrgName:第一次点击时,展示出来的列表对象
  929. *@param FindOrdName:用户输入值时,匹配好的列表对象
  930. *@param inputID:隐藏域ID
  931. */
  932. suggestComplete:function(TopOrgName,FindOrdName,inputID){
  933. },
  934. /*************************** 跟时间有关 ***************************************/
  935. /**
  936. 比较日期
  937. *@param stattime:开始时间
  938. *@param endtime:结束时间
  939. *@param str:提示的信息
  940. *@use if(!compareDate($('#DateTimeStart').val(),$('#DateTimeEnd').val())){
  941. ComWbj.alertMessage('开始时间不能比结束时间大','');
  942. return;
  943. }
  944. */
  945. compareDate:function(stattime,endtime,str){
  946. var start=new Date(stattime.replace("-", "/").replace("-", "/"));
  947. var endTime=$("#endTime").val();
  948. var end=new Date(endtime.replace("-", "/").replace("-", "/"));
  949. if(end<start){
  950. ComWbj.alertIconNo("提示",str,"warning");
  951. return;
  952. }
  953. },
  954. /**
  955. 返回N天[前或者后]当前日期的字符串格式(-或者/格式)
  956. *@param Nday: 多少天后
  957. *@param str: 字符串格式(-或者/格式)
  958. *@调用EX getDateStr(7,'/');
  959. */
  960. getDateStr:function(Nday,str,opt) {
  961. var dd = new Date();
  962. if(opt == "+") dd.setDate(dd.getDate()+Nday);//获取Nday天前的日期
  963. else dd.setDate(dd.getDate()-Nday);//获取Nday天后的日期
  964. var y = dd.getFullYear();
  965. var m = dd.getMonth()+1;//获取当前月份的日期
  966. var d = dd.getDate();
  967. if(m < 10) m = "0"+m;
  968. if(d<10) d = "0"+d;
  969. if(str == "-") return y+"-"+m+"-"+d;
  970. else if(str == "/") return y+"/"+m+"/"+d;
  971. },
  972. //获取完整的时间,返回EX:2014年07月18日 10:21:16 星期五
  973. clockOn:function() {
  974. var now = new Date();
  975. var year = now.getFullYear();
  976. var month = now.getMonth();
  977. var date = now.getDate();
  978. var day = now.getDay();
  979. var hour = now.getHours();
  980. var minu = now.getMinutes();
  981. var sec = now.getSeconds();
  982. var week;
  983. month = month + 1;
  984. if (month < 10) month = "0" + month;
  985. if (date < 10) date = "0" + date;
  986. if (hour < 10) hour = "0" + hour;
  987. if (minu < 10) minu = "0" + minu;
  988. if (sec < 10) sec = "0" + sec;
  989. var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
  990. week = arr_week[day];
  991. var time = "";
  992. time = year + "年" + month + "月" + date + "日" + " " + hour + ":" + minu + ":" + sec + " " + week;
  993. $("#bgclock").html(time);
  994. var timer = setTimeout("clockon()", 200);
  995. },
  996. //根据数字:1、2、3,返回字符串时段(上午、下午、晚上)
  997. getTime:function(timeID){
  998. var time='';
  999. switch (parseInt(timeID)){
  1000. case 1: time='上午'; break;
  1001. case 2: time='下午'; break;
  1002. case 3: time='晚上'; break;
  1003. default: break;
  1004. }
  1005. return time;
  1006. },
  1007. getSubstrTime:function(time){
  1008. if(time == null || time == undefined){
  1009. return '';
  1010. }else{
  1011. return time.substring(0,11);
  1012. }
  1013. },
  1014. //根据数字:1、2、3、4、5、6、7,设置字符串星期值
  1015. getWeek:function(weekID){
  1016. var xq='未知';
  1017. switch (weekID) {
  1018. case 0: xq='星期日'; break;
  1019. case 1: xq='星期一'; break;
  1020. case 2: xq='星期二'; break;
  1021. case 3: xq='星期三'; break;
  1022. case 4: xq='星期四'; break;
  1023. case 5: xq='星期五'; break;
  1024. case 6: xq='星期六'; break;
  1025. default: break;
  1026. }
  1027. return xq;
  1028. },
  1029. //根据系统当前时间获取星期几
  1030. chinaWeek:function(){
  1031. var weekDay = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  1032. var myDate = new Date(Date.parse(v.replace(/-/g, "/")));
  1033. return weekDay[myDate.getDay()];
  1034. },
  1035. /*************************** 点击input时,弹出树 ***************************************/
  1036. /**
  1037. 在input下面弹出装载树的层
  1038. * @param mainId: 要弹出层的控件的ID
  1039. * @param divId: 装载内容的控件的ID名
  1040. */
  1041. showMenu:function(mainId,divId){
  1042. var divObj = $("#"+mainId);
  1043. var divOffset = $("#"+mainId).offset();
  1044. $("#"+divId).css( { left : divOffset.left + "px",
  1045. top : divOffset.top + divObj.outerHeight() + "px"
  1046. }).slideDown("fast");
  1047. },
  1048. /**
  1049. * @param divId: 弹出的层内容的ID
  1050. */
  1051. hideMenu:function(divId){ $("#"+divId).fadeOut("fast"); },
  1052. /**
  1053. 选中弹出层里面的值
  1054. * @param mainId: 要弹出层的控件的ID
  1055. * @param divId: 装载内容的控件的ID名
  1056. */
  1057. changeMenu:function(mainId,divId){
  1058. $("#"+mainId).mouseout(function(event){
  1059. var div = document.getElementById(divId);
  1060. var x=event.pageX;
  1061. var y=event.pageY;
  1062. var divx1 = div.offsetLeft;
  1063. var divy1 = div.offsetTop;
  1064. var divx2 = div.offsetLeft + div.offsetWidth;
  1065. var divy2 = div.offsetTop + div.offsetHeight;
  1066. if( x < divx1 || x > divx2 || y < divy1 || y > divy2){
  1067. ComWbj.hideMenu(divId);
  1068. }
  1069. })
  1070. $("#"+divId).mouseout(function(event){
  1071. var div = document.getElementById(divId);
  1072. var x=event.pageX;
  1073. var y=event.pageY;
  1074. var divx1 = div.offsetLeft;
  1075. var divy1 = div.offsetTop;
  1076. var divx2 = div.offsetLeft + div.offsetWidth;
  1077. var divy2 = div.offsetTop + div.offsetHeight;
  1078. if( x < divx1 || x > divx2 || y < divy1 || y > divy2){
  1079. ComWbj.hideMenu(divId);
  1080. }
  1081. })
  1082. },
  1083. /*************************** 图片相关 ***************************************/
  1084. /**
  1085. 查看图片:放大、缩小
  1086. * @param url: 大图的url
  1087. */
  1088. lookImg:function(url){
  1089. YihuUtil.dialog( {
  1090. title : '查看图片',
  1091. id : 'lookImg',
  1092. padding: '0px 0px',
  1093. content : '<div style=" width:500px; height:500px;overflow:auto;"><img src="'+url+'" id="lookImg" style="width:500px; height:500px;" /></div>',
  1094. lock : true,
  1095. button : [ {
  1096. name : '放大',
  1097. focus : true,
  1098. callback:function(){
  1099. var doc = this.DOM.dialog[0];
  1100. var t1=$(doc).find("#lookImg");
  1101. var width=t1.css('width');
  1102. t1.css('width',parseInt(width)*1.1+'px');
  1103. var height=t1.css('height');
  1104. t1.css('height',parseInt(height)*1.1+'px');
  1105. return false;
  1106. }
  1107. },{
  1108. name : '缩小',
  1109. callback:function(){
  1110. var doc = this.DOM.dialog[0];
  1111. var t1=$(doc).find("#lookImg");
  1112. var width=t1.css('width');
  1113. t1.css('width',parseInt(width)/1.1+'px');
  1114. var height=t1.css('height');
  1115. t1.css('height',parseInt(height)/1.1+'px');
  1116. return false;
  1117. }
  1118. } ]
  1119. })
  1120. },
  1121. /*************************** 跟页面显示有关(css) ***************************************/
  1122. /**
  1123. 颜色区分:设置一种不同颜色
  1124. * @param val: 列表显示的值
  1125. * @param name: 要显示不同颜色,所匹配的名称
  1126. * @param color: 设置的样式名
  1127. * @调用EX setColor_1(name,"待接收","c_djs");
  1128. */
  1129. setColor_1:function(val,name,color){
  1130. if(val==name){
  1131. return "class='"+color+"'";
  1132. }
  1133. },
  1134. /**
  1135. 颜色区分:设置俩种不同颜色
  1136. * @param val: 列表显示的值
  1137. * @param name1: 要显示不同颜色,所匹配的名称
  1138. * @param color1: 设置的颜色值
  1139. *
  1140. * @param name2: 要显示不同颜色,所匹配的名称
  1141. * @param color2: 设置的样式名
  1142. * @调用EX setColor_1(name,"待接收","c_djs","待就诊","c_jz");
  1143. */
  1144. setColor_2:function(val,name1,color1,name2,color2){
  1145. if(val==name1){
  1146. return "class='"+color1+"'";
  1147. }else if(val==name2){
  1148. return "class='"+color2+"'";
  1149. }
  1150. },
  1151. /**
  1152. 选项卡:tab切换
  1153. *@param tabconId:装载内容的层的ID名
  1154. *@param menuId: 装载li的Ul的ID名
  1155. *@use tabs('tabcon','tabmenu');
  1156. *注意 :要定义样式名:tab-con,用于控制显示和隐藏div
  1157. */
  1158. tabs:function(tabconId,menuId){
  1159. $tabcon = $("#"+tabconId);
  1160. $tabcon.find(".tab-con:first-child").show();
  1161. $("#"+menuId).delegate(
  1162. "li",
  1163. "click",
  1164. function() {
  1165. var i = $(this).index();
  1166. $("#"+menuId).find("li").removeClass("on");
  1167. $(this).addClass("on");
  1168. $tabcon.find(".tab-con").hide().end().find(
  1169. ".tab-con:eq(" + i + ")").show();
  1170. })
  1171. },
  1172. setScreenAutoHeight:function(id){ //根据桌面可视范围设置高度
  1173. var h = window.screen.availHeight;
  1174. $("#"+id).css("height",h-400);
  1175. },
  1176. /*********************************************** 页面常用的辅助功能 ***************************************/
  1177. /**
  1178. 新窗口预览
  1179. *@param url:预览要跳转的页面地址
  1180. */
  1181. preview:function(url){
  1182. if( $.browser.msie && ( $.browser.version == '8.0' || $.browser.version == '7.0' || $.browser.version == '6.0') ){
  1183. alert("为了让您看到更好的展示效果,请您在最新版本的IE,或者火狐、谷歌浏览器中预览您的微官网!");
  1184. }else{
  1185. window.open(url,'','width=380px,height=600px');
  1186. }
  1187. },
  1188. /**
  1189. 打印
  1190. *@param url:打印结果页面地址
  1191. *@param data:要传给打印结果页面的数据
  1192. */
  1193. printHtml:function(url,data){
  1194. var k=window.showModalDialog(url,data,"dialogWidth=750px;dialogHeight=500px;status:no;location=No;");// toolbar=No代表新窗口不显示工具栏(设置为yes则相反) location=No窗口不显示地址栏(同上) status=No窗口不显示状态栏(同上) membar=No窗口不显示菜单(同上) scrollbars=auto表示窗口滚动条自动显示 resizable=yes表示窗口可以用鼠标调整大小 width=500设置窗口宽度 height=500设置窗口高度。
  1195. },
  1196. isPC:function () { //判断是PC还是手机
  1197. var userAgentInfo = navigator.userAgent;
  1198. var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
  1199. var flag = true;
  1200. for (var v = 0; v < Agents.length; v++) {
  1201. if (userAgentInfo.indexOf(Agents[v]) > 0) {
  1202. flag = false;
  1203. break;
  1204. }
  1205. }
  1206. return flag;
  1207. },
  1208. copyText: function (id) { //复制文本内容
  1209. var targetText = document.getElementById(id);
  1210. try {
  1211. var clipText = targetText.createTextRange();
  1212. clipText.execCommand("Copy");
  1213. ComWbj.alertIconNo('提示','复制成功,可以按Ctrl+V粘贴','succeed');
  1214. } catch(e) {
  1215. ComWbj.alertIconNo('提示','您的浏览器不支持剪贴板复制,请手工复制文本框内容!','warning');
  1216. targetText.focus();//获得焦点
  1217. targetText.select();//选中文本
  1218. }
  1219. },
  1220. /*********************************************** 页面常用的控件 ***************************************/
  1221. /**
  1222. 百度的富文本编辑器:Ueditor
  1223. *@param id:装载富文本编辑器的div的ID
  1224. *@use ue1=ComWbj.baiduUeditor('content1');
  1225. ue2=ComWbj.baiduUeditor('content2'); //一个页面可以定义多个富文本编辑器
  1226. 取值:var GeContent1=ue1.getContent();
  1227. var GeContent2=ue2.getContent();
  1228. */
  1229. baiduUeditor:function(id){
  1230. //var ue = UE.getEditor(id,{ autoHeight: false ,
  1231. return UE.getEditor(id,{ autoHeight: false ,
  1232. autoClearinitialContent :false,
  1233. autoFloatEnabled: false,
  1234. catchRemoteImageEnable:false,
  1235. toolbars: [ [
  1236. 'undo', //撤销
  1237. 'redo', //重做
  1238. 'bold', //加粗
  1239. 'indent', //首行缩进
  1240. 'italic', //斜体
  1241. 'underline', //下划线
  1242. 'strikethrough', //删除线
  1243. 'subscript', //下标
  1244. 'fontborder', //字符边框
  1245. 'superscript', //上标
  1246. 'formatmatch', //格式刷
  1247. 'blockquote', //引用
  1248. 'pasteplain', //纯文本粘贴模式
  1249. 'selectall', //全选
  1250. 'horizontal', //分隔线
  1251. 'removeformat', //清除格式
  1252. 'time', //时间
  1253. 'date', //日期
  1254. 'unlink', //取消链接
  1255. 'inserttable', //插入表格
  1256. 'insertrow', //前插入行
  1257. 'insertcol', //前插入列
  1258. 'mergeright', //右合并单元格
  1259. 'mergedown', //下合并单元格
  1260. 'deleterow', //删除行
  1261. 'deletecol', //删除列
  1262. 'splittorows', //拆分成行
  1263. 'splittocols', //拆分成列
  1264. 'splittocells', //完全拆分单元格
  1265. 'deletecaption', //删除表格标题
  1266. 'inserttitle', //插入标题
  1267. 'mergecells', //合并多个单元格
  1268. 'deletetable', //删除表格
  1269. 'cleardoc', //清空文档
  1270. 'insertparagraphbeforetable', //"表格前插入行"
  1271. 'insertcode', //代码语言
  1272. 'fontfamily', //字体
  1273. 'fontsize', //字号
  1274. 'paragraph', //段落格式
  1275. 'simpleupload', //单图上传
  1276. 'insertimage', //多图上传
  1277. 'insertvideo',//插入视频
  1278. 'edittable', //表格属性
  1279. 'edittd', //单元格属性
  1280. 'link', //超链接
  1281. 'spechars', //特殊字符
  1282. 'searchreplace', //查询替换
  1283. 'map', //Baidu地图
  1284. 'gmap', //Google地图
  1285. 'justifyleft', //居左对齐
  1286. 'justifyright', //居右对齐
  1287. 'justifycenter', //居中对齐
  1288. 'justifyjustify', //两端对齐
  1289. 'forecolor', //字体颜色
  1290. 'backcolor', //背景色
  1291. 'insertorderedlist', //有序列表
  1292. 'insertunorderedlist', //无序列表
  1293. 'fullscreen', //全屏
  1294. 'directionalityltr', //从左向右输入
  1295. 'directionalityrtl', //从右向左输入
  1296. 'rowspacingtop', //段前距
  1297. 'rowspacingbottom', //段后距
  1298. 'pagebreak', //分页
  1299. 'imagecenter', //居中
  1300. 'lineheight', //行间距
  1301. 'edittip ', //编辑提示
  1302. 'customstyle', //自定义标题
  1303. 'autotypeset', //自动排版
  1304. 'touppercase', //字母大写
  1305. 'tolowercase', //字母小写
  1306. 'drafts', // 从草稿箱加载
  1307. 'charts', // 图表
  1308. 'source', //源代码
  1309. 'preview', //预览
  1310. 'help' //帮助
  1311. ]]
  1312. });
  1313. },
  1314. /**
  1315. 分页控件
  1316. *@param totalcounts:列表总数
  1317. *@param pagecount:一共多少页
  1318. *@param pagesize:页面展示数量
  1319. */
  1320. allPages: function (totalcounts, pagecount, pagesize) {
  1321. $("#pager").pager( {
  1322. totalcounts : totalcounts,
  1323. pagesize : pagesize,
  1324. pagenumber : $("#pagenumber").val(),
  1325. pagecount : pagecount,
  1326. buttonClickCallback : function(a) {
  1327. $("#pagenumber").val(a);
  1328. init();
  1329. }
  1330. });
  1331. },
  1332. getTotalPage:function(total,pagesize){ //hql 2014-8-5:获取多少页
  1333. var ys=total%pagesize; var zs=total/pagesize;
  1334. if(ys==0) return parseInt(zs);
  1335. else return parseInt(zs)+1;
  1336. },
  1337. /**
  1338. * 初始化树.
  1339. * @param treedata
  1340. * @param treeoption
  1341. * @return
  1342. */
  1343. initTree:function(treedata,treeoption){
  1344. var htmls = '<ul>';
  1345. $.each(treedata,function(index,val){
  1346. var formatli = null;
  1347. if(treeoption.formatli){ formatli = treeoption.formatli; }
  1348. if(formatli){
  1349. var li = formatli(index,treedata,val);
  1350. var children = val.children;
  1351. if(children.length > 0){ li += initTree(children,treeoption,true); }
  1352. htmls += li;
  1353. }
  1354. });
  1355. htmls += '</ul>';
  1356. $("#"+treeoption.id).html(htmls);
  1357. $("#"+treeoption.id).SimpleTree({
  1358. click: treeoption.onclick
  1359. });
  1360. return htmls;
  1361. },
  1362. /**
  1363. * 生成树要用的数据类型 *
  1364. * @param data 数据集
  1365. * @param attrpid 父级id的属性名称
  1366. * @param attrpidv 父级id的属性名称的值是多少表示改对象是父级对象
  1367. * @param id 主键属性名称
  1368. * @return
  1369. */
  1370. initTreeData:function(data,attrpid,attrpidv,id){
  1371. var treedate = [];
  1372. var chdata = {};
  1373. $.each(data,function(index,val){
  1374. if(val[attrpid] == attrpidv) treedate.push(val);
  1375. val.children = [];
  1376. chdata[val[id]]=val;
  1377. });
  1378. $.each(data,function(index,val){
  1379. if(val[attrpid] != attrpidv){
  1380. if(chdata[val[attrpid]]!=undefined) chdata[val[attrpid]].children.push(val);
  1381. }
  1382. });
  1383. return treedate;
  1384. },
  1385. //hql 2014-8-6: 点击新增坐诊科室,弹出树
  1386. clickTreeInput: function(treeData,treeUl,treeInput,treeDiv, setTreeNode){
  1387. var setting = {
  1388. view : { showIcon : false, showLine : false },
  1389. data: { key: {
  1390. name: "deptName"
  1391. }
  1392. },
  1393. callback : {
  1394. onAsyncSuccess : function() { },
  1395. onClick : setTreeNode
  1396. }
  1397. };
  1398. $.fn.zTree.init($("#"+treeUl), setting, treeData);
  1399. ComWbj.showMenu(treeInput,treeDiv);
  1400. },
  1401. /**
  1402. 图片上传
  1403. *@param id:点击触发上传事件的file控件的ID号
  1404. *@param imgID:用于显示上传好的img控件的ID号
  1405. *@use <div class="xd"><!--请注意:btn-gray-l这个class名,input和button要一致-->
  1406. <input id="up" onchange="uploadImg('up','disImg');" class="cs jd iefa btn-gray-l" type="file"/>
  1407. <input type="button" class="btn-gray-l" value="上传图片"></input>
  1408. </div>
  1409. */
  1410. upLoadImg:function(id, imgID) {
  1411. var filename = $("#" + id).val();
  1412. if (filename == null || filename == '') return;
  1413. if(filename.indexOf(".")>-1){
  1414. var p=filename.lastIndexOf(".");
  1415. var strp=filename.substring(p,filename.length)+'|';
  1416. if(".jpeg|.gif|.jpg|.png|.bmp|.pic|".indexOf(strp.toLowerCase())==-1){
  1417. ComWbj.alertIconNo('图片选择错误提示','图片格式必须为.jpeg|.jpg|.gif|.png','warning');
  1418. return;
  1419. }
  1420. }
  1421. var arrID = [ id ];
  1422. $.yihuUpload.ajaxFileUpload( {
  1423. url : '/WbjUI/servlet/UploadFileServlet?param={hosid:' + YihuUtil.getSession().orgid
  1424. + '}&File=true&filename=' + filename + "&Api=WBJ", // 用于文件上传的服务器端请求地址
  1425. secureuri : false,// 一般设置为false
  1426. fileElementId : arrID,// 文件上传空间的id属性 <input type="file" id="file" name="file" />
  1427. dataType : 'json',// 返回值类型 一般设置为json
  1428. success : function(data, status) {
  1429. var uri = data.Uri;
  1430. var name = data.NewFileName;
  1431. var fname = data.FileName;
  1432. var size = data.Size;
  1433. var old = $("#" + id + "_f");
  1434. $("#" + imgID).attr("src", uri);
  1435. },
  1436. error : function(data, status, e) {
  1437. ComWbj.alertIconNo("提示","上传失败!",'error');
  1438. }
  1439. });
  1440. },
  1441. /**
  1442. * 设置数据表格的参数
  1443. *
  1444. * @param tableId:表格ID
  1445. * @param url:ajax请求地址
  1446. * @param columns:表格具体的列
  1447. */
  1448. dataTable:function(tableId,url,columns){
  1449. $("#" + tableId).dataTable({
  1450. "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",//定义DataTable布局的一个强大属性
  1451. "sPaginationType": "bootstrap",//分页样式使用bootstrap
  1452. "sScrollX": "100%", //表格的宽度
  1453. "sScrollXInner": "100%", //表格的内容宽度
  1454. "bScrollCollapse": true, //当显示的数据不足以支撑表格的默认的高度时,依然显示纵向的滚动条。(默认是false)
  1455. "bPaginate": true, //是否显示分页
  1456. "bLengthChange": true, //每页显示的记录数
  1457. "bFilter": true, //搜索栏
  1458. "bSort": true, //是否支持排序功能
  1459. "bInfo": true, //显示表格信息
  1460. "bAutoWidth": true, //自适应宽度
  1461. //"sAjaxDataProp":data, //sAjaxDataProp
  1462. "sAjaxSource": url,
  1463. //"fnServerData": executeQuery,
  1464. "fnServerParams": function (aoData) {
  1465. aoData.push({"name": "conds", "value": data});
  1466. }, //ajax请求地址
  1467. "aaSorting": [[1, "asc"]], //设置默认的列——排序 ,第一个参数表示数组 (由0开始)。1 表示Browser列。第二个参数为 desc或是asc
  1468. "aoColumns": columns,//列设置,表有几列,数组就有几项
  1469. "bProcessing": true,
  1470. "bStateSave": true, //保存状态到cookie *************** 很重要 , 当搜索的时候页面一刷新会导致搜索的消失。使用这个属性就可避免了
  1471. "sPaginationType": "full_numbers", //分页,一共两种样式,full_numbers和two_button(默认)
  1472. "oLanguage": {
  1473. "sLengthMenu": "每页显示 _MENU_ 条记录",
  1474. "sZeroRecords": "Sorry~ 未找到!您可以试试搜索其他词",
  1475. "sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录",
  1476. "sInfoEmtpy": "喔喔...查询不到相关数据了",
  1477. "sInfoFiltered": "数据表中共有 _MAX_ 条记录)",
  1478. "sProcessing": "正在加载中...",
  1479. "sSearch": "搜索",
  1480. "sUrl": "", //多语言配置文件,可将oLanguage的设置放在一个txt文件中,例:Javascript/datatable/dtCH.txt
  1481. "oPaginate": {
  1482. "sFirst": "首页",
  1483. "sPrevious": " 上一页 ",
  1484. "sNext": " 下一页 ",
  1485. "sLast": "尾页 "
  1486. }
  1487. }, //多语言配置
  1488. "bJQueryUI": false, //可以添加 jqury的ui theme 需要添加css
  1489. "aLengthMenu": [[10, 25, 50, -1], ["每页10条", "每页25条", "每页50条", "显示所有数据"]] //设置每页显示记录的下拉菜单
  1490. });
  1491. },
  1492. /**
  1493. 仿芒果网智能提示
  1494. *@param orgNameId:搜索机构名称的输入框ID
  1495. *@param hiddenOrdId:
  1496. *@param listDivId:展示查询结果的div的ID
  1497. *@param orgId:对应机构id
  1498. */
  1499. getAllOrgName:function(orgNameId,hiddenOrdId,listDivId,orgId){
  1500. //智能联想提示
  1501. var TopOrgName = new Array();
  1502. var FindOrdName = new Array();
  1503. var params = {};
  1504. params.start = 0;
  1505. params.limit = 10;
  1506. if(orgId!=null){
  1507. params.orgid = orgId;
  1508. }else{
  1509. params.orgid = session.orgid;
  1510. }
  1511. params.status = 1 // :开启,-1:关闭,0待审核
  1512. //params.medicalorgtype = $('#medicalorgtype').val(); //机构类别 1 医院 2 社区
  1513. //params.provinceid = $('#sheng').val(); //省份
  1514. //params.cityid = $('#shi').val(); //城市id
  1515. $.post('/WbjUI/wbj2/business/web/ReferralZcsq_queryReferralPath.do', params, function (result) {
  1516. if(result.Code==10000){
  1517. $.each(result.Result,function(i,item){
  1518. if( result.Result.length > 10){
  1519. if(i < 10){
  1520. TopOrgName[i] = new Array('','' + item.hospitalname + '','','');
  1521. }
  1522. }else{
  1523. TopOrgName[i] = new Array('','' + item.hospitalname + '','','');
  1524. }
  1525. FindOrdName[i] = new Array('','' + item.hospitalname + '','','');
  1526. });
  1527. }else {
  1528. ComWbj.alertIconNo('提示',result.Message,'error');
  1529. }
  1530. }, "json");
  1531. $("#"+orgNameId).suggest(
  1532. FindOrdName,
  1533. {
  1534. hot_list:TopOrgName,
  1535. dataContainer:'#'+hiddenOrdId,
  1536. onSelect:function(){
  1537. //$("#city2").click();
  1538. },
  1539. attachObject:'#'+listDivId
  1540. },"机构"
  1541. );
  1542. ComWbj.suggestComplete(TopOrgName,FindOrdName,"hidden_ordId"); //智能提示插件
  1543. },
  1544. /**
  1545. 仿芒果网智能提示
  1546. *@param orgNameId:搜索机构名称的输入框ID
  1547. *@param hiddenOrdId:
  1548. *@param listDivId:展示查询结果的div的ID
  1549. */
  1550. getAllDoctorName:function(doctorNameId,hiddenDoctorId,listDivId){
  1551. //智能联想提示
  1552. var TopDoctorName = new Array();
  1553. var FindDoctorName = new Array();
  1554. var params = {};
  1555. var pa = "{'orgId':" + session.orgid + ",'pageIndex':1,'userTypes':'1,3,4','pageSize':100}";
  1556. param.Param=pa;
  1557. param.Api = "baseinfo.DepartUserApi.queryUserInfoList";
  1558. doAjaxLoadData("../bmry_doAll.do", param,function(resp) {
  1559. if (resp.Code == '10000') {
  1560. $.each(resp.Result,function(i,item){
  1561. if( resp.Result.length > 10){
  1562. if(i < 10){
  1563. TopDoctorName[i] = new Array('','' + item.userName + '','','');
  1564. }
  1565. }else{
  1566. TopDoctorName[i] = new Array('','' + item.userName + '','','');
  1567. }
  1568. FindDoctorName[i] = new Array('','' + item.userName + '','','');
  1569. });
  1570. }else {
  1571. ComWbj.alertIconNo('提示',resp.Message,'error');
  1572. }
  1573. }, "json");
  1574. $("#"+doctorNameId).suggest(
  1575. FindDoctorName,
  1576. {
  1577. hot_list:TopDoctorName,
  1578. dataContainer:'#'+hiddenDoctorId,
  1579. onSelect:function(){
  1580. //$("#city2").click();
  1581. },
  1582. attachObject:'#'+listDivId
  1583. },"医生"
  1584. );
  1585. ComWbj.suggestComplete(TopDoctorName,FindDoctorName,"hidden_ordId"); //智能提示插件
  1586. },
  1587. suggest:function(input, options) {}
  1588. }