common_survey.js 50 KB

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