buildingEdit.jsp 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
  2. <%String basePath = request.getScheme()+ "://" + request.getServerName() + ":" +request.getServerPort() + request.getContextPath(); %>
  3. <style>
  4. .left {
  5. width: 378px;
  6. height:150px;
  7. overflow:hidden;
  8. border:1px solid #898989;
  9. float: left;
  10. }
  11. .right {
  12. float: left;
  13. margin-left: 10px;
  14. }
  15. .unit_item {
  16. float:left;
  17. margin:2px;
  18. height: 30px;
  19. line-height: 30px;
  20. font-size: 12px; font-family : arial, "Microsoft Yahei", sans-serif;
  21. text-align : center; background : #528B8B;
  22. color: #444;
  23. width: 50px;
  24. background: #528B8B;
  25. font-family: arial, "Microsoft Yahei", sans-serif;
  26. text-align: center;
  27. }
  28. .house_item {
  29. float:left;
  30. margin:2px;
  31. height: 30px;
  32. line-height: 30px;
  33. font-size: 12px;
  34. font-family: arial, "Microsoft Yahei", sans-serif;
  35. text-align: center;
  36. background: #5CACEE;
  37. color: #444;
  38. width: 50px;
  39. }
  40. .item {
  41. float:left;
  42. margin:2px;
  43. height: 30px;
  44. line-height: 30px;
  45. font-size: 12px;
  46. font-family: arial, "Microsoft Yahei", sans-serif;
  47. text-align: center;
  48. background: #5CACEE;
  49. color: #444;
  50. width: 50px;
  51. }
  52. .right td {
  53. height: 34px;
  54. width: 54px;
  55. line-height: 34px;
  56. font-size: 12px;
  57. font-family: arial, "Microsoft Yahei", sans-serif;
  58. background: #ddd;
  59. color: #444;
  60. text-align: center;
  61. padding: 0px;
  62. }
  63. .right td.drop {
  64. background: #ddd;
  65. width: 50px;
  66. }
  67. .floor {
  68. width: 50px;
  69. height: 34px;
  70. }
  71. .drop {
  72. width: 50px;
  73. height: 34px;
  74. }
  75. .item_copy {
  76. float:left;
  77. margin:2px;
  78. height: 30px;
  79. line-height: 30px;
  80. font-size: 12px;
  81. font-family: arial, "Microsoft Yahei", sans-serif;
  82. text-align: center;
  83. background: #5CACEE;
  84. color: #444;
  85. width: 50px;
  86. }
  87. </style>
  88. <div style="float:left;margin-top:10px;margin-left:10px;width: 378px; margin-right: 10px;font-size: 12px;font-family: arial,'Microsoft Yahei', sans-serif;">
  89. <div style="height: 35px;line-height: 35px;border:1px solid #898989;float: left;background-color: #f0f0f0;width: 378px;font-size: 12px;">
  90. <div style="float: left;margin-left: 10px;">层数<input type="text" id="rows" style="width:50px;" value="5"></div>
  91. <div style="float: left;margin-left: 10px;">每层最大户数<input type="text" id="cols" style="width:50px;" value="6"></div>
  92. <div style="float: left;margin-left: 10px;">平面图<input type="checkbox" id="maptype"></div>
  93. <div style="float: left;margin-left: 10px;height: 35px;line-height: 35px;margin-top: 8px;"><input type="button" id="layer_btn" value="生成表格"></div>
  94. </div>
  95. <div style="margin-top:10px;color:#636363;margin-left: auto;margin-right: auto;width:100%;text-align: center;height: 34px; line-height:34px; font-size: 16px;font-weight: bolder;border:1px solid #898989;border-bottom:0px; float: left;background-color: #f0f0f0;">
  96. <span style="background-image: url('images/building_1.png'); background-repeat: no-repeat; width: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
  97. <span>单元</span>
  98. </div>
  99. <div id="unitArea" class="unit" style="width: 378px;min-height:34px;border:1px solid #898989;float: left;background-color: #f0f0f0;">
  100. </div>
  101. <div style="color:#636363; margin-top:15px;margin-left: auto;margin-right: auto;width:100%;text-align: center;height: 34px; line-height:34px; font-size: 16px;font-weight: bolder;border:1px solid #898989;border-bottom:0px; float: left;background-color: #f0f0f0;">
  102. <span>房号(<span id="houseTotal"></span>)</span>
  103. </div>
  104. <div id="house" class="left">
  105. </div>
  106. <div class="copy" style="width: 378px;min-height:34px;border:1px solid #898989;float: left;margin-top: 10px;">
  107. </div>
  108. </div>
  109. <div class="right">
  110. <div style="margin-top:10px; margin-left: auto;margin-right: auto;height:34px;line-height:34px; text-align: center;font-size: 16px;font-weight: bolder;color:#636363;background-color: #f0f0f0;border:1px solid #898989;font-family: arial, 'Microsoft Yahei', sans-serif;">
  111. <span style="background-image: url('images/building_1.png'); background-repeat: no-repeat; width: 18px;">&nbsp;&nbsp;&nbsp;&nbsp;</span>
  112. <span id="edit_buildingTitle"></span>楼型图
  113. </div>
  114. <div id="layer_edit_tb" style="width:420px;height:280px; overflow: scroll;border:1px solid #898989;border-top:0px;"></div>
  115. <div>
  116. <span style="font-family: arial, 'Microsoft Yahei', sans-serif;font-size: 14px;font-weight: bolder;">备注:</span>
  117. <textarea id="edit_remark" rows="2" cols="50" style="border:1px solid #898989;margin-top: 5px;">左东右西</textarea>
  118. </div>
  119. </div>
  120. <script type="text/javascript">
  121. //绘制楼层图
  122. function drwaeLayer(maptype){
  123. $("#layer_edit_tb").find("td.drop").each(function(i,n){
  124. var obj = $(n);
  125. if(obj.html() != ""){
  126. $("#house").append(obj.html().replace("house_item","item"));
  127. $('.left .item').draggable({
  128. revert:true,
  129. proxy:'clone'
  130. });
  131. }
  132. });
  133. $("#layer_edit_tb").empty();
  134. $("#unit_tb").empty();
  135. var rows = $("#rows").val();
  136. var cols = $("#cols").val();
  137. var tableHtml = "";
  138. for(var i =Number(rows)+1;i>=1;i--){
  139. tableHtml +='<tr>';
  140. for(var j =1;j<=Number(cols)+1;j++){
  141. if(i == (Number(rows)+1)){
  142. if(j>1){
  143. tableHtml +='<td class="unit" id=unit_'+(j-1)+'>'+(j-1)+'</td>';
  144. }else{
  145. tableHtml +='<td></td>';
  146. }
  147. }else{
  148. if(i>0 && j ==1){
  149. if(maptype == 1){
  150. tableHtml +='<td class="floor">'+i+'</td>';
  151. }else{
  152. tableHtml +='<td class="floor">'+i+'楼</td>';
  153. }
  154. }else{
  155. tableHtml +='<td class="drop" id=floor_'+ i +'_'+(j-1)+' ></td>';
  156. }
  157. }
  158. }
  159. tableHtml +='</tr>';
  160. }
  161. $("#layer_edit_tb").append(
  162. '<table style="width:'+(54*(Number(cols)+1)+Number(cols)+1)+'px;border-spacing: 1px;">'+
  163. tableHtml+
  164. '</table>'
  165. );
  166. /**单元右边可放置*/
  167. $('.right td.unit').droppable({
  168. accept: '.unit_item',
  169. onDrop:function(e,source){
  170. $(this).removeClass('over');
  171. var c = $(source).clone().addClass('unit_assigned');
  172. //清除原来的,更换新的
  173. $(this).empty().append(c);
  174. c.draggable({
  175. revert:true
  176. });
  177. }
  178. });
  179. /**房号右边可放置*/
  180. $('.right td.drop').droppable({
  181. accept: '.item,.item_copy',
  182. onDragEnter:function(e,source){
  183. $(source).draggable('proxy').css('border','1px solid red');
  184. $(source).removeClass('trash');
  185. },
  186. onDragLeave:function(e,source){
  187. $(source).removeClass('trash');
  188. },
  189. onDrop:function(e,source){
  190. if(($(this).html() == '')){//判断是否重复
  191. $(source).removeClass('item');
  192. $(source).removeClass('item_copy');
  193. $(source).addClass('house_item');
  194. $(this).append(source);
  195. }else{
  196. $("#house").append($(this).html().replace("house_item","item"));
  197. $('.left .item').draggable({
  198. revert:true,
  199. proxy:'clone'
  200. });
  201. $(this).empty();
  202. $(source).removeClass('item');
  203. $(source).addClass('house_item');
  204. $(this).append(source);
  205. }
  206. }
  207. });
  208. }
  209. $(function(){
  210. //单元可拖拽
  211. $('.unit .unit_item').draggable({
  212. revert:true,
  213. proxy:'clone'
  214. });
  215. //房号拖地
  216. $('.left .item').draggable({
  217. revert:true,
  218. proxy:'clone'
  219. });
  220. //单元可放置
  221. $('.unit').droppable({
  222. accept:'.unit_assigned',
  223. onDrop:function(e,source){
  224. $(source).remove();
  225. }
  226. });
  227. //复制区域可放置
  228. $('.copy').droppable({
  229. accept:'.item',
  230. onDrop:function(e,source){
  231. var c = $(source).clone().removeClass("item").addClass('item_copy');
  232. $(this).append(c);
  233. $('.copy .item_copy').draggable({
  234. revert:true,
  235. proxy:'clone'
  236. });
  237. }
  238. });
  239. //房号可放置
  240. $('.left').droppable({
  241. accept:'.assigned , .house_item',
  242. onDragEnter:function(e,source){
  243. $(source).draggable('proxy').css('border','1px solid red');
  244. $(source).removeClass('trash');
  245. },
  246. onDragLeave:function(e,source){
  247. $(source).draggable('options').cursor='not-allowed';
  248. },
  249. onDrop:function(e,source){
  250. $(source).removeClass('house_item');
  251. $(source).addClass('item');
  252. $(this).append(source);
  253. }
  254. });
  255. drwaeLayer();
  256. $("#layer_btn").click(function(){
  257. var maptype = 0;
  258. if($("#maptype").attr('checked') == "checked"){
  259. maptype = 1;
  260. }
  261. drwaeLayer(maptype);
  262. });
  263. });
  264. </script>