basic-hospital.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. var contend = "";
  2. var picVal = "";
  3. var editorOption = {
  4. //这里可以选择自己需要的工具按钮名称,此处仅选择如下五个
  5. toolbars: [[
  6. 'undo', //撤销
  7. 'redo', //重做
  8. 'bold', //加粗
  9. 'indent', //首行缩进
  10. //'snapscreen', //截图
  11. 'italic', //斜体
  12. 'underline', //下划线
  13. // 'strikethrough', //删除线
  14. 'subscript', //下标
  15. 'fontborder', //字符边框
  16. 'superscript', //上标
  17. 'formatmatch', //格式刷
  18. // 'blockquote', //引用
  19. 'pasteplain', //纯文本粘贴模式
  20. 'selectall', //全选
  21. // 'print', //打印
  22. 'insertcode', //代码语言
  23. 'fontfamily', //字体
  24. 'fontsize', //字号
  25. 'paragraph', //段落格式
  26. 'simpleupload', //单图上传
  27. 'insertimage', //多图上传
  28. 'edittable', //表格属性
  29. 'edittd', //单元格属性
  30. 'link', //超链接
  31. //'emotion', //表情
  32. 'spechars', //特殊字符
  33. 'searchreplace', //查询替换
  34. 'horizontal', //分隔线
  35. 'removeformat', //清除格式
  36. 'justifyleft', //居左对齐
  37. 'justifyright', //居右对齐
  38. 'justifycenter', //居中对齐
  39. 'justifyjustify', //两端对齐
  40. 'forecolor', //字体颜色
  41. 'backcolor', //背景色
  42. 'insertorderedlist', //有序列表
  43. 'insertunorderedlist', //无序列表
  44. 'fullscreen', //全屏
  45. 'directionalityltr', //从左向右输入
  46. 'directionalityrtl', //从右向左输入
  47. 'rowspacingtop', //段前距
  48. 'rowspacingbottom', //段后距
  49. 'time', //时间
  50. 'date', //日期
  51. 'unlink', //取消链接
  52. //'anchor', //锚点
  53. 'simpleupload', //单图上传
  54. //'insertimage', //多图上传
  55. 'edittable', //表格属性
  56. 'touppercase', //字母大写
  57. 'tolowercase', //字母小写
  58. 'imagecenter', //居中
  59. //'wordimage', //图片转存
  60. 'edittip ', //编辑提示
  61. 'charts' // 图表
  62. // 'help' //帮助
  63. ]],
  64. //focus时自动清空初始化时的内容
  65. autoClearinitialContent: true,
  66. //关闭elementPath
  67. elementPathEnabled: false,
  68. scaleEnabled:true
  69. };
  70. //点击了编辑之后才能上传1可以,0不能
  71. var uploadFlag = 0;
  72. $(function(){
  73. Commonjs.getJscrollpane.destroy();
  74. $("#cancel").hide();
  75. $('#datetimepicker1,#datetimepicker2').datetimepicker({
  76. yearOffset:0,
  77. lang:'ch',
  78. timepicker:false,
  79. format:'d/m/Y',
  80. formatDate:'Y/m/d',
  81. minDate:'-1970/01/02', // yesterday is minimum date
  82. maxDate:'+1970/01/02' // and tommorow is maximum date calendar
  83. });
  84. $('#layer').click(function(){
  85. var artBox=art.dialog({
  86. lock: true,
  87. icon:'question',
  88. opacity:0.4,
  89. width: 250,
  90. title:'提示',
  91. content: '页面模板会覆盖编辑区域已有组件,是否继续?',
  92. ok: function () {
  93. },
  94. cancel: true
  95. });
  96. });
  97. initImage();
  98. function rightBox (){
  99. $('.doctor-info-fl table.table-form').width($('.container-wrap .scroll-pane').outerWidth(true)-281-40);
  100. $('.doctor-info-fr').height($(window).height()-$('.doctor-info-top').outerHeight(true)-111);
  101. }
  102. rightBox ();
  103. var doctorScroll=$('.doctor-scroll-pane').height($(window).height()-$('.doctor-info-top').outerHeight(true)-111).jScrollPane({"autoReinitialise": true}).data('jsp');
  104. $(window).resize(function(){
  105. Commonjs.getJscrollpane.destroy();
  106. Throttle(rightBox(),50,30);
  107. var doctorScroll=$('.doctor-scroll-pane').height($(window).height()-$('.doctor-info-top').outerHeight(true)-111).jScrollPane({"autoReinitialise": true});
  108. });
  109. $('#cancel').on('click',function(){
  110. uploadFlag = 0;
  111. var $input=$('.table-input'),
  112. $textarea=$('.table-textarea'),
  113. $btn=$('#edit-btns');
  114. $("#showBrief").hide();
  115. $("#showInfo").html(contend);
  116. $("#showInfo").show();
  117. for(var i=0; i<$input.length; i++){
  118. $input.eq(i).html($input.eq(i).find('input').val());
  119. }
  120. for(var j=0; j<$textarea.length; j++){
  121. $textarea.eq(j).html($textarea.eq(j).find('textarea').val());
  122. }
  123. $btn.text('编辑').removeClass('edityes');
  124. $(this).hide();
  125. $("#hosLevel").hide();
  126. $("#_hoslevel").show();
  127. $("#tempImg").show();
  128. $("#updateSmallImg").hide();
  129. });
  130. $('#edit-btns').on('click',function(){
  131. uploadFlag = 1;
  132. $("#cancel").hide();
  133. var $input=$('.table-input'),
  134. $textarea=$('.table-textarea'),
  135. $btn=$(this);
  136. $('.doctor-table-box').toggleClass('table-text');
  137. $("#showBrief").show();
  138. $("#showInfo").hide();
  139. // $("#pic").attr("style","height:600px;position:fixed;top:100px");
  140. $("#tempImg").show();
  141. $("#updateSmallImg").hide();
  142. if($(this).hasClass('edityes')){
  143. $("#hosLevel").hide();
  144. $("#_hoslevel").show();
  145. $("#cancel").hide();
  146. $("#showBrief").hide();
  147. //$("#showInfo").text(UE.getEditor('editor').getContent());
  148. $("#showInfo").show();
  149. $btn.text('编辑').removeClass('edityes');
  150. for(var i=0; i<$input.length; i++){
  151. $input.eq(i).html($input.eq(i).find('input').val());
  152. }
  153. for(var j=0; j<$textarea.length; j++){
  154. $textarea.eq(j).html($textarea.eq(j).find('textarea').val());
  155. }
  156. var temX = clearNoNum($("#hosX").html());
  157. var temY =clearNoNum($("#hosY").html());
  158. if(temX != $("#hosX").html() ){
  159. art.dialog({
  160. lock: true,
  161. width: '300px',
  162. height: '100px',
  163. time: 3,
  164. content: '经度,纬度请输入数字与小数点'
  165. });
  166. return false;
  167. }
  168. if(temY != $("#hosY").html() ){
  169. art.dialog({
  170. lock: true,
  171. width: '300px',
  172. height: '100px',
  173. time: 3,
  174. content: '经度,纬度输入数字与小数点'
  175. });
  176. return false;
  177. }
  178. var Service = {};
  179. var page = {};
  180. var code = 1012;
  181. //alert("<![CDATA["+UE.getEditor('editor').getContent()+"]]>");
  182. Service.HosRoute = $("#hosRoute").html();
  183. Service.HosId = Commonjs.hospitalId;
  184. Service.HosBrief = escape(UE.getEditor('editor').getContent());
  185. Service.Address =$("#hosAddr").html();
  186. Service.Level =$("#hosLevel").val();
  187. Service.LevelName =$("#hosLevel").find("option:selected").text();
  188. Service.HosName =$("#hosName").html();
  189. //Service.Remark =$("#hosRemark").html();
  190. Service.CoordinateX =clearNoNum($("#hosX").html());
  191. Service.CoordinateY =clearNoNum($("#hosY").html());
  192. Service.Province =$("#hosProvince").html();
  193. Service.Tel =$("#hosTel").html();
  194. Service.PhotoUrl ="<![CDATA["+$("#SmallImgV").attr("src")+"]]>";
  195. var param = {};
  196. var params = Commonjs.getParams(code,Service);//获取参数
  197. param.Api = "UpdateHospital";
  198. param.Params = Commonjs.jsonToString(params);
  199. var d = Commonjs.ajax('./basic_callBasicApi.do',param,false);
  200. if(d.RespCode == '10000'){
  201. art.dialog({
  202. lock: true,
  203. width: '300px',
  204. height: '100px',
  205. time: 3,
  206. content: d.RespMessage
  207. });
  208. }else{
  209. art.dialog({
  210. lock: true,
  211. width: '300px',
  212. height: '100px',
  213. time: 3,
  214. content: d.RespMessage
  215. });
  216. }
  217. $("#editor").remove();
  218. hospital.findData();
  219. }else{
  220. $("#tempImg").hide();
  221. $("#updateSmallImg").show();
  222. $("#hosLevel").show();
  223. $("#_hoslevel").hide();
  224. $("#cancel").show();
  225. // $("#pic").attr("style","position:fixed;top:100px;height:500px;");
  226. $btn.text('保存').addClass('edityes');
  227. for(var i=0; i<$input.length; i++){
  228. $input.eq(i).html($input.eq(i).find('textarea').val());
  229. $input.eq(i).html('<input class="text big" style="width:200px" value="'+$input.eq(i).text()+'" />');
  230. if($input.eq(i).hasClass('map')){
  231. $('<a href="http://api.map.baidu.com/lbsapi/getpoint/?qq-pf-to=pcqq.c2c" target="_blank" class="a-maps"><i class="icon icon-map"></i></a>').appendTo($input.eq(i));
  232. }
  233. if($input.eq(i).hasClass('ask')){
  234. $('<span class="ask-wrap"><i class="icon icon-ask"></i><div class="tipBox"><div class="bd">请点击图标通过 <a href="http://api.map.baidu.com/lbsapi/getpoint/?qq-pf-to=pcqq.c2c" target="_blank">百度地图坐标拾取系统</a> 获取经纬度信息</div><div class="hd"><s class="ui-arrow ui-arrow-b"><s></s></s></div></div></span>').appendTo($input.eq(i));
  235. }
  236. $('.ask-wrap').hover(function(){
  237. $('.ask-wrap').find('.tipBox').show();
  238. },function(){
  239. $('.ask-wrap').find('.tipBox').hide();
  240. })
  241. }
  242. for(var j=0; j<$textarea.length; j++){
  243. $textarea.eq(j).html($textarea.eq(j).find('textarea').val());
  244. $textarea.eq(j).html('<textarea class="textarea" style="width:500px; height:'+($textarea.eq(j).height()+50)+'px">'+$textarea.eq(j).text()+'</textarea>');
  245. }
  246. }
  247. });
  248. hospital.findData();
  249. });
  250. function clearNoNum(obj){
  251. obj = obj.replace(/[^\d.]/g,""); //清除“数字”和“.”以外的字符
  252. obj = obj.replace(/^\./g,""); //验证第一个字符是数字而不是.
  253. obj = obj.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的.
  254. obj = obj.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
  255. return obj;
  256. }
  257. function initUe(val){
  258. $("#showBrief").html();
  259. $("#showBrief").append("<script id=\"editor\" type=\"text/plain\" style=\"width:100%;height:150px;\"></script>");
  260. var UE = new baidu.editor.ui.Editor(editorOption);
  261. UE.render('editor');
  262. UE.ready(function() {
  263. //editor_a.hide();//隐藏编辑器
  264. UE.setContent(val);
  265. //赋值给UEditor du.Data.Contents
  266. });
  267. //UE.setHeight(300);
  268. }
  269. function newGuid() {
  270. var guid = "";
  271. for (var i = 1; i <= 32; i++){
  272. var n = Math.floor(Math.random()*16.0).toString(16);
  273. guid += n;
  274. if((i==8)||(i==12)||(i==16)||(i==20))
  275. guid += "-";
  276. }
  277. return guid;
  278. }
  279. function initImage(){
  280. var id = newGuid();
  281. var html = '<div style="margin-top: 2px; position:relative;" class="sel"><input id="'
  282. + id
  283. + '" style="position:absolute;filter:alpha(opacity=0);opacity:0;height:120px;width:120px;cursor: pointer;" title="点击上传图片" value="点击上传图片" onchange=upload("'
  284. + id
  285. + '","SmallImgV"); onpaste="return false;" type="file" name="0"><img id="SmallImgV" src="http://f1.yihuimg.com/TFS/upfile/WBJ/1024727/2014-07-23/003320_1406097193619_fullsize.jpg" style="height:120px;width:120px;" /></div>';
  286. $("#updateSmallImg").empty();
  287. $("#updateSmallImg").append(html);
  288. }
  289. function upload(id,image) {
  290. var filename = $("#"+id).val();
  291. var index = filename.lastIndexOf('.');
  292. var type = filename.substring(index+1,filename.length);
  293. if(type.toLowerCase() != 'jpg' && type.toLowerCase() != 'gif'
  294. && type.toLowerCase() != 'png'&&type.toLowerCase() != 'jpeg'){
  295. YihuUtil.art.warning('注意喔:图片格式必须为.jpeg|.gif|.jpg|.png','warning');
  296. return ;
  297. }
  298. var arrID = [ id ];
  299. $.yihuUpload.ajaxFileUpload( {
  300. url : '/Hos-Process/servlets/UploadFileServlet', // 用于文件上传的服务器端请求地址
  301. secureuri : false,// 一般设置为false
  302. fileElementId : arrID,// 文件上传空间的id属性 <input type="file" id="file"
  303. // name="file" />
  304. dataType : 'json',// 返回值类型 一般设置为json
  305. success : function(data, status) {
  306. var uri = data.url;
  307. uri=uri.replace('fullsize','small');
  308. var name = data.NewFileName;
  309. var fname = data.FileName;
  310. var size = data.Size;
  311. var old = $("#" + id + "_f");
  312. if (image=='SmallImgV') {
  313. $("#SmallImgV").attr("src", uri);
  314. $("#ImgUrl").val(uri);
  315. $("#hidVal").val(uri);
  316. }
  317. },
  318. error : function(data, status, e) {
  319. //YihuUtil.art.warning("图片上传失败:建议您选择不超过1M的图片且在良好的网络环境下继续上传");
  320. }
  321. });
  322. }
  323. var hospital = function(){
  324. var queryHospital = function(){
  325. var Service = {};
  326. var page = {};
  327. var code = 1003;
  328. Service.HosId = Commonjs.hospitalId;
  329. page.PIndex=0;
  330. page.PSize = 100;
  331. Service.Page = page;
  332. var param = {};
  333. var params = Commonjs.getParams(code,Service);//获取参数
  334. param.Api = "QueryHospital";
  335. param.Params = Commonjs.jsonToString(params);
  336. var backData = Commonjs.ajax('./basic_callBasicApi.do',param,false);
  337. $("#showInfo").show();
  338. if(backData.RespCode == 10000){
  339. $("#showInfo").html(unescape(backData.Data.HosBrief));
  340. $("#hosAddr").text(backData.Data.Address);
  341. $("#hosProvince").text(backData.Data.Province);
  342. $("#hosTel").text(backData.Data.Tel);
  343. $("#SmallImgV").attr("src",unescape(backData.Data.PhotoUrl));
  344. picVal = unescape(backData.Data.PhotoUrl);
  345. $("#hosX").text(backData.Data.CoordinateX);
  346. $("#hosY").text(backData.Data.CoordinateY);
  347. $("#hosRoute").text(backData.Data.HosRoute);
  348. $("#hosName").text(backData.Data.HosName);
  349. $("#hosLevel").val(backData.Data.HosLevel);
  350. //$("#hosLevel").text(backData.Data.Level);
  351. $("#hosLevel").hide();
  352. $("#_hoslevel").html(backData.Data.HosLevelName);
  353. $("#tempImg").attr("src",unescape(backData.Data.PhotoUrl));
  354. $("#updateSmallImg").hide();
  355. contend = unescape(backData.Data.HosBrief);
  356. // setTimeout(function(){
  357. // initUe(contend);
  358. // },300);
  359. initUe(contend);
  360. //var val = backData.Data.Level;
  361. // $("#hosLevel option[value='"+val+"']").attr("selected", true);
  362. //$("#hosRemark").text(backData.Hos.Remark);
  363. /*
  364. var editor_a = new baidu.editor.ui.Editor(editorOption);
  365. editor_a.render('editor');
  366. editor_a.ready(function() {
  367. //editor_a.hide();//隐藏编辑器
  368. editor_a.setContent(unescape(backData.Data.HosBrief)); //赋值给UEditor
  369. $("#showInfo").html(unescape(backData.Data.HosBrief));
  370. });
  371. */
  372. }
  373. }
  374. var editInfo = function(){
  375. }
  376. return{
  377. findData : queryHospital,
  378. updateHos : editInfo
  379. }
  380. }();