hos.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. var dg;
  2. var dd;
  3. var editRow = undefined;
  4. var method = undefined;
  5. $(document).ready( function(){
  6. searchData();
  7. loadHosAutoComplete('search_hosname','search_hosid','search_hosname_old');
  8. loadHosAutoComplete('search_hosname1','search_hosid1','search_hosname_old1');
  9. dd = $("#dd").dialog({
  10. title: '配置',
  11. width: 280,
  12. height: 210,
  13. closed: true,
  14. cache: false,
  15. modal: true,
  16. buttons:[{
  17. text:'保存',
  18. handler:function(){
  19. var rowData = {};
  20. var basic_hos_info_id = $('#basic_hos_info_id').val();
  21. rowData.hos_id=$('#search_hosid1').val();
  22. rowData.hos_name=$('#search_hosname1').val();
  23. rowData.region_code=$('#region_code').val();
  24. rowData.hop_service=$('#hop_service').val();
  25. rowData.hos_address=$('#hos_address').val();
  26. rowData.password=$('#password').val();
  27. if(Commonjs.isEmpty(basic_hos_info_id)){
  28. Commonjs.ajax("./BasicAction_insertHosInfo.action",rowData,false);
  29. }else{
  30. rowData.basic_hos_info_id=basic_hos_info_id;
  31. Commonjs.ajax("./BasicAction_updateHosInfo.action",rowData,false);
  32. }
  33. refreshData();
  34. dd.dialog('close');
  35. }
  36. },{
  37. text:'关闭',
  38. handler:function(){
  39. $('#basic_hos_info_id').val("");
  40. $('#search_hosname1').val("");
  41. $('#search_hosid1').val("");
  42. $('#search_hosname_old1').val("");
  43. $('#region_code').val("");
  44. $('#hop_service').val("");
  45. $('#hos_address').val("");
  46. $('#password').val("");
  47. dd.dialog('close');
  48. }
  49. }]
  50. });
  51. // $('#provinceID').combobox({
  52. // editable:false,
  53. // valueField:'provinceid',
  54. // textField:'provincename',
  55. // width: 100,
  56. // onSelect: loadCity
  57. // });
  58. // $('#cityID').combobox({
  59. // editable:false,
  60. // valueField:'cityid',
  61. // textField:'cityname',
  62. // width: 120,
  63. // onSelect: loadHos
  64. // });
  65. // $('#orgID').combobox({
  66. // valueField:'hospitalid',
  67. // textField:'hosname',
  68. // panelWidth: 260 ,
  69. // });
  70. // var pd = Commonjs.ajax($.yihu.url,{bizAction:'commonAction.getProvinceByHos'},false).result;
  71. // $('#provinceID').combobox('loadData',pd);
  72. });
  73. function searchData(){
  74. var hosid = 0;
  75. if(!isNull($('#search_hosid').val())){
  76. hosid=$('#search_hosid').val();
  77. }
  78. dg = $('#dg').datagrid(
  79. {
  80. title : '',
  81. url : "BasicAction_queryHosInfo.action",
  82. height : $('#layoutid').layout('panel', 'center').panel(
  83. 'options').height,
  84. columns : dataTableColumns,
  85. queryParams : {
  86. hospitalId : hosid,
  87. },
  88. pagination : true,
  89. pageSize : 15,
  90. pageList : [ 10, 15, 20, 30, 50 ],
  91. fitColumns : true,
  92. singleSelect : true,
  93. loadMsg : "正在加载...",
  94. toolbar:[
  95. {
  96. text:'增加',
  97. iconCls:'icon-add',
  98. handler:function(){
  99. dd.dialog('open');
  100. }
  101. },'-',{
  102. text:'修改',
  103. iconCls:'icon-edit',
  104. handler:function(){
  105. var row = dg.datagrid('getSelections')[0];
  106. $('#basic_hos_info_id').val(row.basic_hos_info_id);
  107. $('#search_hosname1').val(row.hos_name);
  108. $('#search_hosid1').val(row.hosid);
  109. $('#search_hosname_old1').val(row.hos_name);
  110. $('#region_code').val(row.region_code);
  111. $('#hop_service').val(row.hop_service);
  112. $('#hos_address').val(row.hos_address);
  113. $('#password').val(row.password);
  114. dd.dialog('open');
  115. }
  116. },'-',{
  117. text:'删除',
  118. iconCls:'icon-remove',
  119. handler:function(){
  120. var rows = dg.datagrid('getSelections');
  121. var msgMess = '当前已选中'+rows.length+'条记录,删除后无法恢复,是否确定要删除!!';
  122. if(rows.length > 0){
  123. $.messager.confirm('确认',msgMess,function(r){
  124. if(r){
  125. var ids = [];
  126. var rowData = {};
  127. for(var i=0;i<rows.length;i++){
  128. ids.push(rows[i].basic_hos_info_id);
  129. }
  130. rowData.ids = ids.join(',');
  131. Commonjs.ajax("./BasicAction_deleteHosInfo.action",rowData,false);
  132. refreshData();
  133. }
  134. });
  135. }else{
  136. $.messager.alert('提示','请选择要删除的数据!','warning');
  137. }
  138. }
  139. },'-'
  140. ],
  141. loadFilter : function(data) {
  142. var _data={};
  143. if(data==null||data.totalProperty==0) {
  144. _data.total=0;
  145. _data.rows=[];
  146. return _data;
  147. }
  148. _data.total = data.totalProperty;
  149. _data.rows = data.result;
  150. return _data;
  151. },
  152. onBeforeLoad : function(param) {
  153. param.limit = param.rows;
  154. param.start = (param.page - 1) * param.limit;
  155. },
  156. onLoadSuccess : function(data) {
  157. $("#btnEp").linkbutton('enable');
  158. $("#btnEp1").linkbutton('enable');
  159. }
  160. });
  161. }
  162. function isNull(value){
  163. if(value==undefined||value==null||value=='null'||value=='NULL' || value =='undefined' || value=='0' || value==''){
  164. return true;
  165. }else{
  166. return false;
  167. }
  168. }
  169. function refreshData(){
  170. dg.datagrid('load',{
  171. bizAction:'./BasicAction_queryHosInfo.action',
  172. hospitalId:'-1'
  173. });
  174. //当用户处于编辑状态,不点保存或更新按钮,应该把重置编辑状态
  175. editRow = undefined;
  176. method = undefined;
  177. }
  178. function isHosNameChange(o,search_hosname_old,search_hosid){
  179. if(o.value != $('#'+search_hosname_old).val()){
  180. $('#'+search_hosid).val(0);
  181. }
  182. }
  183. //加载医院标签库
  184. function loadHosAutoComplete(id,search_hosid,search_hosname_old)
  185. {
  186. $("#"+id).focus().autocomplete(HospitalData,{
  187. max:15,
  188. scrollHeight: 300,
  189. matchContains: true,
  190. formatItem: function(row, i, max) {
  191. return row.hosname
  192. },
  193. formatMatch: function(row, i, max) {
  194. return row.hosname +"["+row.spells+"]";
  195. },
  196. formatResult: function(row) {
  197. return row.hosname;
  198. }
  199. } );
  200. $("#"+id).result(function(event, data, formatted) {
  201. if (data) {
  202. $('#'+search_hosid).val(data.hospitalid);
  203. $('#'+search_hosname_old).val(data.hosname);
  204. } else {
  205. $('#'+search_hosid).val(0);
  206. }
  207. });
  208. }
  209. //var loadCity = function(node){
  210. // $('#cityID').combobox('loadData',Commonjs.ajax
  211. // ($.yihu.url,{bizAction:'commonAction.getCityByProvince',provinceid:node.provinceid},false).result);
  212. //}
  213. //var loadHos = function(node){
  214. // var provinceid = $('#provinceID').combobox('getValue');
  215. // $('#orgID').combobox('loadData',Commonjs.ajax
  216. // ($.yihu.url,{bizAction:'hospital_Action.queryHospitalCombox',
  217. // isAll:true,provinceid:provinceid,cityId:node.cityid},false).result);
  218. //}
  219. var dataTableColumns = [ [
  220. {
  221. title:'id',
  222. field:'basic_hos_info_id',
  223. checkbox:true
  224. },{
  225. field : 'hos_name',
  226. width : $(this).width() * 0.2,
  227. title : '医院名称'
  228. },
  229. {
  230. field : 'region_code',
  231. width : $(this).width() * 0.1,
  232. title : '区域代码'
  233. },
  234. {
  235. field : 'hop_service',
  236. width : $(this).width() * 0.4,
  237. title : 'wsdl地址'
  238. },
  239. {
  240. field : 'hos_address',
  241. width : $(this).width() * 0.2,
  242. title : '医院地址'
  243. },
  244. {
  245. field : 'password',
  246. width : $(this).width() * 0.1,
  247. title : '密码'
  248. }] ];