houseListMap.jsp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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. $(function() {
  7. $('#houseQueryDataGrid').datagrid({
  8. rownumbers:true,
  9. fit:true,
  10. pageSize:10,
  11. pageList : [ 10, 20, 30, 40, 50 ],
  12. fitColumns:false,
  13. border:false,
  14. singleSelect:true,
  15. sortOrder:'desc',
  16. pagination:true,
  17. idField:'id',
  18. url:whzl.basePath + '/houseAction_listBuilding',
  19. toolbar:'#houseQuerysearchtool',
  20. nowrap:true,
  21. loadFilter:function(result){
  22. if(result.success){
  23. return result.obj;
  24. }else{
  25. $.messager.alert("提示",result.message);
  26. return ;
  27. }
  28. }
  29. }
  30. );
  31. });
  32. /**查询*/
  33. function searchCommuntiyQuery(){
  34. var name = "";
  35. if(trim($('#communityId').combobox("getText")) != ""){
  36. name += trim($('#communityId').combobox("getText"));
  37. }
  38. if(trim($('#zone').combobox("getText")) != ""){
  39. name += " " +trim($('#zone').combobox("getText")) + "区";
  40. if(trim($('#no').combobox("getText")) != ""){
  41. name += trim($('#no').combobox("getText"))+"幢";
  42. }
  43. }else{
  44. if(trim($('#no').combobox("getText")) != ""){
  45. name += " "+trim($('#no').combobox("getText"))+"幢";
  46. }
  47. }
  48. var params = encodeURI("building.name="+ name + "&building.ismap=" + $('#ismap').combobox("getValue")
  49. + "&house.community.id="+$('#communityId').combobox("getValue")
  50. + "&house.communityName="+ $('#communityId').combobox("getText")
  51. + "&house.zone="+ $('#zone').combobox("getValue")
  52. + "&house.no="+ $('#no').combobox("getValue"));
  53. $('#houseQueryDataGrid').datagrid({url:whzl.basePath + '/houseAction_listBuilding?'+params,pageNumber:1});
  54. }
  55. /*清除查询条件**/
  56. function ClearQuery() {
  57. $("#tblQuery").find("input").val("");
  58. $('#communityId').combobox("setValue","");
  59. $('#zone').combobox("setValue","");
  60. $('#no').combobox("setValue","");
  61. $('#ismap').combobox("setValue","");
  62. }
  63. /**编辑*/
  64. var editFormatter = function(value , row , index){
  65. return "<img src='<%=basePath%>/images/pencil.png' title='查看详情' onclick='buildingEdit(" + "\"" + row.name + "\"," + "\"" + row.ismap + "\"," + "\"" + row.maptype + "\")' style='cursor:pointer' />";
  66. };
  67. var buildingEdit = function(name,ismap,maptype){
  68. $('#editBuildingDialog').dialog(
  69. {
  70. maximizable:true,
  71. buttons : [
  72. {
  73. text : '确定',
  74. iconCls : 'icon-ok',
  75. handler : function(){
  76. parent.$.messager.progress({
  77. title : '提示',
  78. text : '保存数据中,请稍候....'
  79. });
  80. //
  81. var unitstr = "";
  82. $("#layer_edit_tb").find("td.unit").each(function(i,n){
  83. var obj = $(n);
  84. if(obj.html() != ""){
  85. unitstr += obj.text() +",";
  86. }
  87. });
  88. //
  89. var houses = "";
  90. $("#layer_edit_tb").find("td.drop").each(function(i,n){
  91. var obj = $(n);
  92. if(obj.html() != ""){
  93. var id = $(n).attr("id");
  94. //楼层;
  95. var floor = id.split('_')[1];
  96. var unit = id.split('_')[2];
  97. //房号Id;
  98. var houseId = $("#"+id).find(".house_item").attr("id");
  99. if(typeof(houseId) != "undefined"){
  100. houses += houseId + "-" + floor + "-" + unit + ",";
  101. }
  102. }
  103. });
  104. var maptype = 0;
  105. if($("#maptype").attr('checked') == "checked"){
  106. maptype = 1;
  107. }
  108. $.ajax({
  109. type: "post",//使用get方法访问后台
  110. dataType: "json",//返回json格式的数据
  111. url: "houseAction_addUnit",//要访问的后台地址
  112. data: "unit.buildingName="+$("#edit_buildingTitle").text()+"&unit.unit="+unitstr + "&houses="+houses + "&remark="+$("#edit_remark").val() + "&building.maptype="+maptype + "&building.floor="+$("#rows").val() + "&building.house="+$("#cols").val(),//要发送的数据
  113. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  114. success: function(data){//msg为返回的数据,在这里做数据绑定
  115. if(data.success){
  116. parent.$.messager.progress('close');
  117. $.messager.alert("提示",data.message);
  118. $("#editBuildingDialog").dialog("close");
  119. searchCommuntiyQuery();
  120. }else{
  121. parent.$.messager.progress('close');
  122. $.messager.alert("提示",data.message);
  123. }
  124. }
  125. });
  126. }
  127. }
  128. ],
  129. onLoad : function(){
  130. $("#edit_buildingTitle").text(name);
  131. buildingDraw($("#edit_buildingTitle").text(),ismap,maptype);
  132. }
  133. }
  134. );
  135. };
  136. /**详细页面对话框*/
  137. var buildingDraw = function(buildingName,ismap,maptype){
  138. $("#layer_edit_tb").empty();
  139. if(ismap == '1'){
  140. $.ajax({
  141. type : "post",//使用get方法访问后台
  142. dataType : "json",//返回json格式的数据
  143. url : "houseAction_findAllQuery",//要访问的后台地址
  144. data : "house.buildingName=" + buildingName,//要发送的数据
  145. complete : function() {
  146. $("#load").hide();
  147. },//AJAX请求完成时隐藏loading提示
  148. success : function(data) {//msg为返回的数据,在这里做数据绑定
  149. if (data.success) {
  150. $("#unitArea").empty();
  151. for(var u = 0;u<data.units.length;u++){
  152. if(data.units[u] != null && data.units[u] != ''){
  153. $("#unitArea").append("<div class='unit_item'>"+data.units[u]+"单元</div>");
  154. }
  155. }
  156. $("#house").empty();
  157. $("#houseTotal").empty();
  158. $("#houseTotal").text(data.objHouse.length + "户");
  159. for(var h = 0;h<data.objHouse.length;h++){
  160. if(data.objHouse[h].unit != null && data.objHouse[h].unit != ""){
  161. $("#house").append("<div class='item' id='"+data.objHouse[h].id+"'>"+data.objHouse[h].unit + "-"+data.objHouse[h].houseNumber+"</div>");
  162. }else{
  163. $("#house").append("<div class='item' id='"+data.objHouse[h].id+"'>"+data.objHouse[h].houseNumber+"</div>");
  164. }
  165. }
  166. var unitsLen = data.unitList.length;
  167. var floorHtml = "";
  168. if (unitsLen > 0) {//有单元
  169. floorHtml = '<tr>';
  170. floorHtml += '<td class="unit_title">&nbsp;</td>';
  171. var t = 0;
  172. for(var uItem = 0; uItem < unitsLen; uItem++) {
  173. var unit = data.unitList[uItem];
  174. t = t + unit.houses;
  175. }
  176. if(t < (data.col-1)){
  177. for(var uItem = 0; uItem < data.col-1; uItem++) {
  178. floorHtml += '<td class="unit" style="font-size:16px;">'+(uItem+1)+'</td>';
  179. }
  180. }else{
  181. for(var uItem = 0; uItem < unitsLen; uItem++) {
  182. var unit = data.unitList[uItem];
  183. for(var t =0;t<unit.houses;t++){
  184. floorHtml += '<td class="unit" style="font-size:16px;"><div class="unit_item unit_assigned">'+unit.unit+'</div></td>';
  185. }
  186. }
  187. }
  188. floorHtml += '</tr>';
  189. }else{
  190. floorHtml = '<tr>';
  191. floorHtml += '<td class="unit_title">&nbsp;</td>';
  192. for(var uItem = 0; uItem < data.col-1; uItem++) {
  193. floorHtml += '<td class="unit" style="font-size:16px;">'+(uItem+1)+'</td>';
  194. }
  195. floorHtml += '</tr>';
  196. }
  197. var layerHtml = "";
  198. $("#rows").val(data.rowMax);
  199. $("#cols").val(data.col-1);
  200. //for ( var row = data.row; row > 0; row--) {,绘制图形
  201. for ( var row = data.rowMax; row >= data.rowMin; row--) {
  202. layerHtml += '<tr>';
  203. if(maptype == "1"){
  204. layerHtml += '<td class="floor">' + row + '</td>';
  205. }else{
  206. layerHtml += '<td class="floor">' + row + '楼</td>';
  207. }
  208. for ( var col = 1; col < data.col; col++) {
  209. layerHtml += '<td id = "floor_'+row + '-' + col+'" class="drop"></td>';
  210. }
  211. layerHtml += '</tr>';
  212. }
  213. $("#layer_edit_tb").append('<table class="building_tb" border=0 style="width:'+(54*(Number(data.col))+Number(data.col))+'px;border-spacing: 1px;">' + floorHtml + layerHtml + '</table>');
  214. for ( var iItem = 0; iItem < data.obj.length; iItem++) {//根据坐标寻找值
  215. var floor = data.obj[iItem].location.split("-")[0];
  216. var x = data.obj[iItem].location.split("-")[1];
  217. var layer = data.obj[iItem].location.split("-")[2];
  218. var col = 0;
  219. if(data.obj[iItem].location.split("-").length == 4){
  220. col = data.obj[iItem].location.split("-")[3];
  221. }
  222. var houseId = data.obj[iItem].houseNumber;
  223. if(data.obj[iItem].unit != null && data.obj[iItem].unit != ''){
  224. houseId = data.obj[iItem].unit + "-" + houseId;
  225. }
  226. if(layer>1 && col>1){
  227. for(var r = 0;r<layer;r++){
  228. for(var c = 0;c<col;c++){
  229. var rowFloor = Number(floor)-r;
  230. var xNo = Number(x)+c;
  231. $("#floor_"+rowFloor+"-"+xNo).append('<div class="house_item" id="'+ data.obj[iItem].id+ '" style="position: static; left: 17px; top: 207px;">'+ houseId+ '</div>');
  232. }
  233. }
  234. }
  235. else if(layer>1){//多层一户
  236. for(var a = 0;a<layer;a++){
  237. var rowFloor = Number(floor)-a;
  238. var loc = rowFloor + "-" + x;
  239. $("#floor_"+loc).append('<div class="house_item" id="'+ data.obj[iItem].id+ '" style="position: static; left: 17px; top: 207px;">'+ houseId+ '</div>');
  240. }
  241. }else if(col>1){//多层一户
  242. for(var a = 0;a<col;a++){
  243. var rowFloor = Number(floor);
  244. var xNo = Number(x)+a;
  245. var loc = rowFloor + "-" + xNo;
  246. $("#floor_"+loc).append('<div class="house_item" id="'+ data.obj[iItem].id+ '" style="position: static; left: 17px; top: 207px;">'+ houseId+ '</div>');
  247. }
  248. }
  249. else{
  250. $("#floor_"+floor+"-"+x).append('<div class="house_item" id="'+ data.obj[iItem].id+ '" style="position: static; left: 17px; top: 207px;">'+ houseId+ '</div>');
  251. }
  252. }
  253. /**单元右边可放置*/
  254. $('.right td.unit').droppable({
  255. accept: '.unit_item',
  256. onDrop:function(e,source){
  257. $(this).removeClass('over');
  258. var c = $(source).clone().addClass('unit_assigned');
  259. //清除原来的,更换新的
  260. $(this).empty().append(c);
  261. c.draggable({
  262. revert:true
  263. });
  264. }
  265. });
  266. /**房号右边可放置*/
  267. $('.right td.drop').droppable({
  268. accept: '.item,.item_copy',
  269. onDragEnter:function(e,source){
  270. $(source).draggable('proxy').css('border','1px solid red');
  271. $(source).removeClass('trash');
  272. },
  273. onDragLeave:function(e,source){
  274. $(source).removeClass('trash');
  275. },
  276. onDrop:function(e,source){
  277. if(($(this).html() == '')){//判断是否重复
  278. $(source).removeClass('item');
  279. $(source).removeClass('item_copy');
  280. $(source).addClass('house_item');
  281. $(this).append(source);
  282. }else{
  283. $("#house").append($(this).html().replace("house_item","item"));
  284. $('.left .item').draggable({
  285. revert:true,
  286. proxy:'clone'
  287. });
  288. $(this).empty();
  289. $(source).removeClass('item');
  290. $(source).addClass('house_item');
  291. $(this).append(source);
  292. }
  293. }
  294. });
  295. //单元可拖拽
  296. $('.house_item').draggable({
  297. revert:true,
  298. proxy:'clone'
  299. });
  300. //单元可拖拽
  301. $('.unit .unit_item').draggable({
  302. revert:true,
  303. proxy:'clone'
  304. });
  305. //房号拖地
  306. $('.left .item').draggable({
  307. revert:true,
  308. proxy:'clone'
  309. });
  310. //房号可放置
  311. $('.left').droppable({
  312. accept:'.assigned , .house_item',
  313. onDragEnter:function(e,source){
  314. $(source).draggable('proxy').css('border','1px solid red');
  315. $(source).removeClass('trash');
  316. },
  317. onDragLeave:function(e,source){
  318. $(source).draggable('options').cursor='not-allowed';
  319. },
  320. onDrop:function(e,source){
  321. $(source).removeClass('house_item');
  322. $(source).addClass('item');
  323. $(this).append(source);
  324. }
  325. });
  326. } else {
  327. $.messager.alert("提示", data.message);
  328. }
  329. }
  330. });
  331. }else{
  332. $.ajax({
  333. type: "post",//使用get方法访问后台
  334. dataType: "json",//返回json格式的数据
  335. url: "houseAction_findAll",//要访问的后台地址
  336. data: "house.buildingName="+buildingName,//要发送的数据
  337. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  338. success: function(data){//msg为返回的数据,在这里做数据绑定
  339. if(data.success){
  340. $("#buildingTitle").empty();
  341. $("#buildingTitle").append(buildingName);
  342. drwaeLayer();
  343. $("#unitArea").empty();
  344. for(var u = 0;u<data.units.length;u++){
  345. $("#unitArea").append("<div class='unit_item'>"+data.units[u]+"单元</div>");
  346. }
  347. $("#house").empty();
  348. $("#houseTotal").empty();
  349. $("#houseTotal").text(data.obj.length + "户");
  350. for(var h = 0;h<data.obj.length;h++){
  351. if(data.obj[h].unit != null && data.obj[h].unit != ""){
  352. $("#house").append("<div class='item' id='"+data.obj[h].id+"'>"+data.obj[h].unit + "-"+data.obj[h].houseNumber+"</div>");
  353. }else{
  354. $("#house").append("<div class='item' id='"+data.obj[h].id+"'>"+data.obj[h].houseNumber+"</div>");
  355. }
  356. }
  357. //单元可拖拽
  358. $('.unit .unit_item').draggable({
  359. revert:true,
  360. proxy:'clone'
  361. });
  362. //单元可拖拽
  363. $('.left .item').draggable({
  364. revert:true,
  365. proxy:'clone'
  366. });
  367. //房号可放置
  368. $('.left').droppable({
  369. accept:'.assigned , .house_item',
  370. onDragLeave:function(e,source){
  371. $(source).draggable('options').cursor='not-allowed';
  372. },
  373. onDrop:function(e,source){
  374. $(source).removeClass('house_item');
  375. $(source).addClass('item');
  376. $(this).append(source);
  377. }
  378. });
  379. }else{
  380. $.messager.alert("提示",data.message);
  381. }
  382. }
  383. });
  384. }
  385. };
  386. var detail = function (id){
  387. $("#detailHouseDialog").dialog(
  388. {
  389. buttons : [
  390. {
  391. text : '确定',
  392. iconCls : 'icon-ok',
  393. handler : function(){
  394. $("#detailHouseDialog").dialog("close");
  395. }
  396. }
  397. ],
  398. onLoad : function(){
  399. house_detail_load(id);
  400. }
  401. }
  402. );
  403. }
  404. /**详细*/
  405. var mapFormatter = function(value , row , index){
  406. if("1" == row.ismap){
  407. if("1" == row.maptype){
  408. return "平面图";
  409. }else{
  410. return "立体图";
  411. }
  412. }else{
  413. return "没有楼型图";
  414. }
  415. };
  416. var viewFormatter = function(value , row , index){
  417. if("1" == row.ismap){
  418. return "<img src='<%=basePath%>/images/details.png' title='查看详情' onclick='buildingView(" + "\"" + row.name + "\"," + "\"" + row.remark + "\"," + "\"" + row.maptype + "\")' style='cursor:pointer' />";
  419. }else{
  420. return "没有楼型图";
  421. }
  422. };
  423. var buildingView = function(name,remark,maptype){
  424. $('#viewBuildingDialog').dialog(
  425. {
  426. maximizable:true,
  427. onLoad : function(){
  428. $("#view_buildingTitle").text(name);
  429. if(typeof(remark) != "undefined"){
  430. $("#remark").text(remark);
  431. }
  432. draw(name,maptype);
  433. }
  434. }
  435. );
  436. };
  437. </script>
  438. <div class="easyui-layout" data-options="fit:true,border:false">
  439. <div data-options="region:'center',border:false">
  440. <div id="houseQuerysearchtool" data-options="region:'north' , border:false">
  441. <div class="clear"></div>
  442. <table id="houseQueryTblQuery" style="width:100%;font-size:12px;">
  443. <tr>
  444. <td align="right"><span>区县</span></td>
  445. <td>
  446. <select id="qx" style="width:120px;">
  447. </select>
  448. <input id="communityId">
  449. <input id="zone" style="width: 60px;">区
  450. <input id="no" style="width: 60px;">幢
  451. &nbsp;&nbsp;楼型图:
  452. <select id="ismap" style="width:120px;">
  453. <option value="">全部</option>
  454. <option value="1">有</option>
  455. <option value="0">无</option>
  456. </select>
  457. </td>
  458. <td>
  459. <a href="javascript:searchCommuntiyQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">查询</a>
  460. <a href="javascript:ClearQuery();" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">清空</a>
  461. </td>
  462. </tr>
  463. </table>
  464. <div class="clear"></div>
  465. </div>
  466. <table id="houseQueryDataGrid">
  467. <thead frozen="true">
  468. <tr>
  469. <th data-options="field:'name',sortable:true,width:200">大楼名称</th>
  470. </tr>
  471. </thead>
  472. <thead>
  473. <tr>
  474. <th data-options="field:'remark',width:100">备注</th>
  475. <th data-options="field:'maptype',width:100,formatter:mapFormatter">楼型</th>
  476. <th data-options="field:'edit',width:70,formatter:editFormatter">编辑楼型图</th>
  477. <th data-options="field:'view',width:70,formatter:viewFormatter">查看楼型图</th>
  478. </tr>
  479. </thead>
  480. </table>
  481. </div>
  482. </div>
  483. <div id="viewBuildingDialog" data-options="title:'&nbsp;楼型图信息',iconCls:'icon-details',width:950,height:400,modal:true,href:'<%=basePath %>/houseAction_toBuildingView'">
  484. </div>
  485. <div id="editBuildingDialog" data-options="title:'&nbsp;编辑楼型图信息',iconCls:'icon-edit',width:900,height:450,modal:true,href:'<%=basePath %>/houseAction_toBuildingEdit'">
  486. </div>
  487. <div id="detailHouseDialog" data-options="title:'&nbsp;户型详细信息',iconCls:'icon-details',width:700,height:450,modal:true,href:'<%=basePath %>/houseAction_toDetail'">
  488. </div>
  489. <div id="detailDialog"></div>
  490. <script type="text/javascript">
  491. $(function(){
  492. parent.$.messager.progress('close');
  493. $('#ismap').combobox({
  494. editable:false
  495. });
  496. $('#qx').combobox({
  497. url: whzl.basePath + '/houseRegisterAction_listChildrenCombobox',
  498. valueField:'value',
  499. textField:'text',
  500. editable:false,
  501. onChange:function (newValue,oldValue) {
  502. $('#communityId').combobox("setValue","");
  503. $('#communityId').combobox('reload',whzl.basePath + '/communityAction_findAll?community.area='+newValue);
  504. }
  505. });
  506. $('#communityId').combobox({
  507. url: whzl.basePath + '/communityAction_findAll',
  508. valueField:'value',
  509. textField:'text',
  510. filter:function(q,row){
  511. var opts=$(this).combobox("options");
  512. return row[opts.textField].indexOf(q)>-1;//将从头位置匹配改为任意匹配
  513. },
  514. onChange:function (newValue,oldValue) {
  515. $('#zone').combobox("setValue","");
  516. $('#no').combobox("setValue","");
  517. $('#zone').combobox('reload',whzl.basePath + '/houseAction_findAllZone?house.community.id='+newValue);
  518. $('#no').combobox('reload',whzl.basePath + '/houseAction_findAllNo?house.community.id='+$('#communityId').combobox("getValue") + '&house.zone='+$('#zone').combobox("getValue"));
  519. }
  520. });
  521. $('#zone').combobox({
  522. //editable:false,
  523. url: whzl.basePath + '/houseAction_findAllZone?house.community.id='+$('#communityId').combobox("getValue"),
  524. valueField:'value',
  525. textField:'text',
  526. filter:function(q,row){
  527. var opts=$(this).combobox("options");
  528. //return row[opts.textField].indexOf(q)==0;//
  529. return row[opts.textField].indexOf(q)>-1;//将从头位置匹配改为任意匹配
  530. },
  531. onChange:function (newValue,oldValue) {
  532. $('#no').combobox("setValue","");
  533. $('#no').combobox('reload',whzl.basePath + '/houseAction_findAllNo?house.community.id='+$('#communityId').combobox("getValue") + '&house.zone='+newValue);
  534. }
  535. });
  536. $('#no').combobox({
  537. //editable:false,
  538. url: whzl.basePath + '/houseAction_findAllNo?house.community.id='+$('#communityId').combobox("getValue") + '&house.zone='+ $('#zone').combobox("getValue"),
  539. valueField:'value',
  540. textField:'text',
  541. filter:function(q,row){
  542. var opts=$(this).combobox("options");
  543. return row[opts.textField].indexOf(q)>-1;//将从头位置匹配改为任意匹配
  544. }
  545. });
  546. });
  547. </script>