communityList.jsp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
  2. <jsp:include page="../../common/include.jsp" />
  3. <%String basePath = request.getScheme()+ "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath(); %>
  4. <script type="text/javascript">
  5. //区
  6. var areaObj = null;
  7. var area_array = null;
  8. //获取区
  9. $.ajax({
  10. type: "post",//使用post方法访问后台
  11. dataType: "json",//返回json格式的数据
  12. url: "houseRegisterAction_listChildren",//要访问的后台地址
  13. //data:{"id":id},
  14. success: function(msg){//msg为返回的数据,在这里做数据绑定
  15. if(msg.success){
  16. areaObj = msg.obj.rows;
  17. var select_arr = [];
  18. var data = areaObj;
  19. for(var nItem = 0; nItem < data.length; nItem++ ){
  20. select_arr.push("<option value="+data[nItem].id+">"+data[nItem].name+"</option>");
  21. }
  22. area_array = select_arr.join("");
  23. $("#area").append(area_array);
  24. }
  25. }
  26. });
  27. /**小区显示区*/
  28. $(function() {
  29. $('#communityDataGrid').datagrid({
  30. rownumbers:true,
  31. fit:true,
  32. pageSize:10,
  33. pageList : [ 10, 20, 30, 40, 50 ],
  34. fitColumns:false,
  35. border:false,
  36. sortOrder:'desc',
  37. pagination:true,
  38. idField:'id',
  39. url:whzl.basePath + '/communityAction_listCommunity',
  40. toolbar:'#searchtool',
  41. checkOnSelect:true,
  42. selectOnCheck:false,
  43. nowrap:true,
  44. loadFilter:function(result){
  45. if(result.success){
  46. return result.obj;
  47. }else{
  48. $.messager.alert("提示",result.message);
  49. return ;
  50. }
  51. }
  52. });
  53. });
  54. /**查询*/
  55. function searchFun(){
  56. $("#communityDataGrid").datagrid("load", {
  57. "community.name":trim($("#name").val()),
  58. "community.area":$("#tblQuery").find("select[id='area']").val()
  59. });
  60. }
  61. /*清除查询条件**/
  62. function ClearQuery() {
  63. $("#tblQuery").find("input").val("");
  64. $("#tblQuery").find("select").val("-1");
  65. }
  66. /**详细*/
  67. var detailsFormatter = function(value , row , index){
  68. return "<img src='<%=basePath%>/js/easyui/themes/itemicon/detail.png' title='查看详情' onclick=communityDetails(" + row.id + ") style='cursor:pointer' />";
  69. };
  70. /**创建人*/
  71. var createByFormatter = function(value , row , index){
  72. return row.createdUser.fullName;
  73. };
  74. /**修改人*/
  75. var modifiedByFormatter = function(value , row , index){
  76. if(row.modifiedUser != null){
  77. return row.modifiedUser.fullName;
  78. }
  79. };
  80. /**区域*/
  81. var areaFormatter = function(value , row , index){
  82. for(var nItem = 0; nItem < areaObj.length; nItem++ ){
  83. if(areaObj[nItem].id == value){
  84. return areaObj[nItem].name;
  85. break;
  86. }
  87. }
  88. };
  89. /**详细页面对话框*/
  90. var communityDetails = function(id){
  91. $("#detailCommunityDialog").dialog(
  92. {
  93. buttons : [
  94. {
  95. text : '确定',
  96. iconCls : 'icon-ok',
  97. handler : function(){
  98. $("#detailCommunityDialog").dialog("close");
  99. }
  100. }
  101. ],
  102. onLoad : function(){
  103. $.ajax({
  104. type: "post",//使用get方法访问后台
  105. dataType: "json",//返回json格式的数据
  106. url: "communityAction_findById",//要访问的后台地址
  107. data: "community.id="+id,//要发送的数据
  108. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  109. success: function(msg){//msg为返回的数据,在这里做数据绑定
  110. $("#name_detail").text(msg.obj.name);
  111. $("#phone_detail").text(msg.obj.phone);
  112. $("#contacts_detail").text(msg.obj.contacts);
  113. $("#address_detail").text(msg.obj.address);
  114. $("#remark_detail").text(msg.obj.remark);
  115. $("#createBy_detail").text(msg.obj.createdUser.fullName);
  116. $("#createOn_detail").text(msg.obj.createdOn);
  117. $("#abbreviation_detail").text(msg.obj.abbreviation);
  118. $("#price_detail").text(msg.obj.price);
  119. $("#garagePrice_detail").text(msg.obj.garagePrice);
  120. if (typeof(msg.obj.modifiedOn) != "undefined") {
  121. $("#modifiedBy_tr").show();
  122. $("#modifiedOn_detail").text(msg.obj.modifiedOn);
  123. $("#modifiedBy_detail").text(msg.obj.modifiedUser.fullName);
  124. }
  125. for(var nItem = 0; nItem < areaObj.length; nItem++ ){
  126. if(areaObj[nItem].id == msg.obj.area){
  127. $("#area_detail").text(areaObj[nItem].name);
  128. }
  129. }
  130. }
  131. });
  132. $.ajax({
  133. type: "post",//使用get方法访问后台
  134. dataType: "json",//返回json格式的数据
  135. url: "communityAction_workRecord",//要访问的后台地址
  136. data: "community.id="+id,//要发送的数据
  137. complete :function(){$("#load").hide();}
  138. })
  139. }
  140. }
  141. );
  142. };
  143. /**更新*/
  144. var updateFormatter = function(value , row , index){
  145. return "<img src='<%=basePath%>/images/pencil.png' title='修改' onclick=updateRow(" + row.id + ") style='cursor:pointer' />";
  146. };
  147. /**更新事件*/
  148. function updateRow(){
  149. var row = $('#communityDataGrid').datagrid('getSelected');
  150. if(row == null){
  151. $.messager.alert("提示","请先选择要修改的房源!");
  152. }
  153. var id = row.id;
  154. $('#updateCommunityDialog').dialog(
  155. {
  156. buttons : [
  157. {
  158. text : '提交',
  159. iconCls : 'icon-ok',
  160. handler : function(){
  161. $('#updateCommunityForm').form('submit',
  162. {
  163. url : whzl.basePath+'/communityAction_updateCommunity',
  164. success : function(result){
  165. var parseResult = $.parseJSON(result);
  166. if(parseResult.success){
  167. $("#updateCommunityDialog").dialog("close");
  168. $('#communityDataGrid').datagrid('reload');
  169. }else{
  170. $.messager.alert("提示",parseResult.message);
  171. }
  172. }
  173. }
  174. );
  175. }
  176. },
  177. {
  178. text : '取消',
  179. iconCls : 'icon-cancel',
  180. handler : function(){
  181. $("#updateCommunityDialog").dialog("close");
  182. }
  183. }
  184. ],
  185. onLoad : function(){
  186. $("#area_update").append(area_array);
  187. $.ajax({
  188. type: "post",//使用get方法访问后台
  189. dataType: "json",//返回json格式的数据
  190. url: "communityAction_findById",//要访问的后台地址
  191. data: "community.id="+id,//要发送的数据
  192. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  193. success: function(msg){//msg为返回的数据,在这里做数据绑定
  194. $("#id_update").val(msg.obj.id);
  195. $("#name_update").val(msg.obj.name);
  196. $("#area_update").val(msg.obj.area);
  197. $("#address_update").val(msg.obj.address);
  198. $("#contacts_update").val(msg.obj.contacts);
  199. $("#phone_update").val(msg.obj.phone);
  200. $("#remark_update").val(msg.obj.remark);
  201. $("#abbreviation_update").val(msg.obj.abbreviation);
  202. $("#price_update").numberbox('setValue', msg.obj.price);
  203. $("#garagePrice_update").numberbox('setValue', msg.obj.garagePrice);
  204. $("#btprice1_update").numberbox('setValue', msg.obj.btprice1);
  205. $("#btprice2_update").numberbox('setValue', msg.obj.btprice2);
  206. $("#btprice3_update").numberbox('setValue', msg.obj.btprice3);
  207. $("#ssprice1_update").numberbox('setValue', msg.obj.ssprice1);
  208. $("#ssprice2_update").numberbox('setValue', msg.obj.ssprice2);
  209. $("#ssprice3_update").numberbox('setValue', msg.obj.ssprice3);
  210. }
  211. });
  212. }
  213. }
  214. );
  215. }
  216. /**删除*/
  217. var delFormatter = function(value , row , index){
  218. return "<img src='<%=basePath%>/images/edit_remove.png' title='删除' onclick=deleteRow(" + row.id+",'"+row.name + "') style='cursor:pointer' />";
  219. };
  220. /**删除功能*/
  221. function deleteRow(){
  222. var row = $('#communityDataGrid').datagrid('getSelected');
  223. var id = row.id;
  224. var name = row.name;
  225. $.messager.confirm('删除提示', '确定删除这条记录吗?', function(r){
  226. if (r){
  227. $.ajax({
  228. type: "post",//使用get方法访问后台
  229. dataType: "json",//返回json格式的数据
  230. url: "communityAction_deleteCommunity",//要访问的后台地址
  231. data: "community.id="+id,//要发送的数据
  232. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  233. success: function(msg){//msg为返回的数据,在这里做数据绑定
  234. if(msg.success){
  235. $.messager.alert('提示','删除成功!');
  236. $('#communityDataGrid').datagrid('reload');
  237. }else{
  238. $.messager.alert('提示',msg.message);
  239. }
  240. }
  241. });
  242. }
  243. });
  244. }
  245. /**增加小区*/
  246. function communityAdd(){
  247. $('#addCommunityDialog').dialog(
  248. {
  249. closable: false,
  250. buttons : [
  251. {
  252. text : '提交',
  253. iconCls : 'icon-ok',
  254. handler : function(){
  255. parent.$.messager.progress({
  256. title : '提示',
  257. text : '保存中,请稍后....'
  258. });
  259. $('#addCommunityForm').form('submit',
  260. {
  261. url : whzl.basePath+'/communityAction_addCommunity',
  262. onSubmit: function(){
  263. var isValid =$('#addCommunityForm').form('validate');
  264. if(isValid == false){
  265. parent.$.messager.progress('close');
  266. }
  267. return isValid;
  268. },
  269. success : function(result){
  270. parent.$.messager.progress('close');
  271. var parseResult = $.parseJSON(result);
  272. if(parseResult.success){
  273. $("#addCommunityDialog").dialog("close");
  274. searchFun();
  275. }else{
  276. $.messager.alert("提示",parseResult.message);
  277. }
  278. }
  279. }
  280. );
  281. }
  282. },
  283. {
  284. text : '取消',
  285. iconCls : 'icon-cancel',
  286. handler : function(){
  287. $("#addCommunityDialog").dialog("close");
  288. }
  289. }
  290. ],
  291. onLoad : function(){
  292. $("#area_add").append(area_array);
  293. }
  294. }
  295. );
  296. }
  297. function showTree(){
  298. $('#treeDialog').dialog(
  299. {
  300. title: '选择小区',
  301. href : whzl.basePath + '/communityAction_toTree.do',
  302. width: 600,
  303. height: 400
  304. }
  305. );
  306. }
  307. </script>
  308. <div class="easyui-layout" data-options="fit:true,border:false">
  309. <div data-options="region:'center',border:false">
  310. <div id="searchtool" data-options="region:'north' , border:false">
  311. <div class="clear"></div>
  312. <table id="tblQuery" style="width:100%;font-size:12px;">
  313. <tr>
  314. <td align="right" width="80px"><span>县区</span></td>
  315. <td width="100px">
  316. <select id="area" style="width:100px">
  317. <option value="">全部</option>
  318. </select>
  319. </td>
  320. <td align="right"><span>小区名称</span></td>
  321. <td width="250px"><input id="name" name="community.name" type="text"/></td>
  322. <td align="left">
  323. <a href="javascript:searchFun();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
  324. <a href="javascript:ClearQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-emptied',plain:true">清空</a>
  325. <a href="javascript:communityAdd();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">增加</a>
  326. <a href="javascript:updateRow();" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改</a>
  327. <a href="javascript:deleteRow();" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除</a>
  328. </td>
  329. </tr>
  330. </table>
  331. <div class="clear"></div>
  332. </div>
  333. <table id="communityDataGrid">
  334. <thead frozen="true">
  335. <tr>
  336. <th data-options="field:'id',checkbox:true,width:30">ID</th>
  337. </tr>
  338. </thead>
  339. <thead>
  340. <tr>
  341. <th data-options="field:'name',sortable:true,width:150">小区名称</th>
  342. <th data-options="field:'address',sortable:true,width:200">小区地址</th>
  343. <th data-options="field:'price',sortable:true,width:100">小区单价(元)</th>
  344. <th data-options="field:'garagePrice',sortable:true,width:100">车库单价(元)</th>
  345. <th data-options="field:'details',align:'center',width:60,formatter:detailsFormatter">查看详情</th>
  346. <th data-options="field:'update',align:'center',width:38,formatter:updateFormatter">修改</th>
  347. <th data-options="field:'delete',align:'center',width:38,formatter:delFormatter">删除</th>
  348. </tr>
  349. </thead>
  350. </table>
  351. </div>
  352. </div>
  353. <div id="detailCommunityDialog" data-options="title:'&nbsp;小区详细信息',iconCls:'icon-details',width:700,height:350,modal:true,href:'<%=basePath %>/communityAction_toDetail'">
  354. </div>
  355. <div id="updateCommunityDialog" data-options="title:'&nbsp;修改小区信息',iconCls:'icon-edit',width:700,height:350,modal:true,href:'<%=basePath %>/communityAction_toUpdate'">
  356. </div>
  357. <div id="addCommunityDialog" data-options="title:'&nbsp;增加小区信息',iconCls:'icon-add',width:700,height:350,modal:true,href:'<%=basePath %>/communityAction_toAdd'">
  358. </div>
  359. <div id="setCommunityDialog" data-options="title:'&nbsp;个性化设置',iconCls:'icon-cog',width:500,height:370,modal:true,href:'<%=basePath %>/columnSetAction_toSet?tname=community'">
  360. </div>
  361. <script type="text/javascript">
  362. <!--
  363. $(function(){
  364. parent.$.messager.progress('close');
  365. });
  366. //-->
  367. </script>