rentAdd.jsp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%@ taglib prefix="s" uri="/struts-tags" %>
  3. <script>
  4. //人员类型
  5. var personTypeObj_add = null;
  6. var personType_array_add = null;
  7. //户型
  8. var roomTypeObj_add = null;
  9. var roomType_array_add = null;
  10. //从合同中添加
  11. function addFromLeaseContract(){
  12. $('#leaseContractSelectDialog').dialog(
  13. {
  14. buttons : [
  15. {
  16. text : '确定',
  17. iconCls : 'icon-ok',
  18. handler : function(){
  19. var leaseContractId = select_submit();
  20. $("#leaseContractId_add").val(leaseContractId);
  21. $.ajax({
  22. type: "post",//使用post方法访问后台
  23. dataType: "json",//返回json格式的数据
  24. url: "leaseContractAction_findById",//要访问的后台地址
  25. data:{"leaseContract.id":leaseContractId },
  26. success: function(msg){//msg为返回的数据,在这里做数据绑定
  27. if(msg.success){
  28. $("#securityPersonIdCard_add").val(msg.obj.securityPerson.idCard);
  29. $("#securityPersonName_add").val(msg.obj.securityPerson.name);
  30. $("#leaseContractId_add").val(msg.obj.id);
  31. $("#securityPersonId_add").val(msg.obj.securityPerson.id);
  32. $("#houseId_add").val(msg.obj.house.id);
  33. $("#rentMonthMoney_add").numberbox('setValue', msg.obj.moneyActual);
  34. $("#startDate_add").datebox('setValue', msg.obj.rentDate);
  35. $("#leaseContract_startDate_add").datebox('setValue', msg.obj.startDate);
  36. $("#leaseContract_endDate_add").datebox('setValue', msg.obj.endDate);
  37. $("#personType_add").val(msg.obj.securityPerson.personType);
  38. $("#securityNum_add").numberbox('setValue', msg.obj.securityPerson.securityNum);
  39. $("#houseAddress_add").val(msg.obj.houseAddress);
  40. $("#roomType_add").val(msg.obj.house.roomType);
  41. $("#contractNo_add").val(msg.obj.contractNo);
  42. $("#contractName_add").val(msg.obj.contractName);
  43. var houseArea = msg.obj.houseArea;
  44. if(houseArea == null){
  45. houseArea = 0;
  46. }
  47. $("#houseArea_add").numberbox('setValue', houseArea);
  48. var garageArea = msg.obj.garageArea;
  49. if(garageArea == null){
  50. garageArea = 0;
  51. }
  52. $("#garageArea_add").numberbox('setValue', garageArea);
  53. }
  54. }
  55. });
  56. $("#leaseContractSelectDialog").dialog("close");
  57. }
  58. },
  59. {
  60. text : '取消',
  61. iconCls : 'icon-cancel',
  62. handler : function(){
  63. $("#leaseContractSelectDialog").dialog("close");
  64. }
  65. }
  66. ],
  67. onLoad : function(){
  68. select_load();
  69. }
  70. }
  71. );
  72. }
  73. //空值转换
  74. var dealNull = function(value){
  75. if(value == ""){
  76. return 0;
  77. }
  78. else{
  79. return value;
  80. }
  81. }
  82. //月份加减函数
  83. function addMoth(d,m){
  84. var ds=d.split('-'),_d=ds[2]-0;
  85. var nextM=new Date( ds[0],ds[1]-1+m+1, 0 );
  86. var max=nextM.getDate();
  87. d=new Date( ds[0],ds[1]-1+m,_d>max? max:_d );
  88. return d.toLocaleDateString().match(/\d+/g).join('-')
  89. }
  90. //日期加减函数
  91. function addDate(dd,dadd){
  92. var a = new Date(dd)
  93. a = a.valueOf()
  94. a = a + dadd * 24 * 60 * 60 * 1000
  95. a = new Date(a)
  96. return a;
  97. }
  98. //日期格式化
  99. Date.prototype.Format = function (fmt) { //author: meizz
  100. var o = {
  101. "M+": this.getMonth() + 1, //月份
  102. "d+": this.getDate(), //日
  103. "h+": this.getHours(), //小时
  104. "m+": this.getMinutes(), //分
  105. "s+": this.getSeconds(), //秒
  106. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  107. "S": this.getMilliseconds() //毫秒
  108. };
  109. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  110. for (var k in o)
  111. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  112. return fmt;
  113. }
  114. //计算金额和租金
  115. var countMoney = function(){
  116. var rentMonth_add = dealNull($("#rentMonth_add").numberbox('getValue'));
  117. var rentMonthMoney_add = dealNull($("#rentMonthMoney_add").numberbox('getValue'));
  118. var rentMoney1_add = rentMonth_add * rentMonthMoney_add;
  119. $("#rentMoney1_add").numberbox('setValue', rentMoney1_add );
  120. var startDate = $("#startDate_add").datebox('getValue');
  121. $("#endDate_add").datebox('setValue', addMoth(addDate(startDate,-1).Format("yyyy-MM-dd"),parseInt(rentMonth_add)) );//需要转换为int型,然后再做日期的月份加减
  122. }
  123. var add_load = function(){
  124. $('#rentMonth_add').numberbox({
  125. onChange: function () {
  126. countMoney();
  127. }
  128. });
  129. //人员类别
  130. $.ajax({
  131. type: "post",//使用post方法访问后台
  132. dataType: "json",//返回json格式的数据
  133. url: "aa10Action_listAa10All",//要访问的后台地址
  134. data:{"aa10.letter":"personType" ,"aa10.name":"保障人员类别" },
  135. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  136. success: function(msg){//msg为返回的数据,在这里做数据绑定
  137. if(msg.success){
  138. personTypeObj_add = msg.obj.rows;
  139. var select_arr = [];
  140. var data = personTypeObj_add;
  141. for(var nItem = 0; nItem < data.length; nItem++ ){
  142. select_arr.push("<option value="+data[nItem].code+">"+data[nItem].value+"</option>");
  143. }
  144. personType_array_add = select_arr.join("");
  145. $("#personType_add").append(personType_array_add);
  146. }
  147. }
  148. });
  149. //户型
  150. $.ajax({
  151. type: "post",//使用post方法访问后台
  152. dataType: "json",//返回json格式的数据
  153. url: "aa10Action_listAa10All",//要访问的后台地址
  154. data:{"aa10.letter":"roomType" ,"aa10.name":"户型" },
  155. complete :function(){$("#load").hide();},//AJAX请求完成时隐藏loading提示
  156. success: function(msg){//msg为返回的数据,在这里做数据绑定
  157. if(msg.success){
  158. roomTypeObj_add = msg.obj.rows;
  159. var select_arr = [];
  160. var data = roomTypeObj_add;
  161. for(var nItem = 0; nItem < data.length; nItem++ ){
  162. select_arr.push("<option value="+data[nItem].code+">"+data[nItem].value+"</option>");
  163. }
  164. roomType_array_add = select_arr.join("");
  165. $("#roomType_add").append(roomType_array_add);
  166. }
  167. }
  168. });
  169. }
  170. var add_submit = function(){
  171. $('#addRentForm').form('submit',{
  172. url : whzl.basePath+'/rentAction_addRent',
  173. success : function(result){
  174. var parseResult = $.parseJSON(result);
  175. if(parseResult.success){
  176. //parent.$.messager.progress('close');
  177. $('#rentDataGrid').datagrid('reload');
  178. }
  179. }
  180. }
  181. );
  182. }
  183. </script>
  184. <div class="easyui-tabs" id="tabs_add">
  185. <div title="基本信息" id="jbxx_detail">
  186. <table class="mytable" style="width: 100%;" >
  187. <tr>
  188. <th>
  189. <a href="javascript:addFromLeaseContract();" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">从租赁合同中选择</a>
  190. </th>
  191. </tr>
  192. </table>
  193. <form id="addRentForm" method="post" enctype="multipart/form-data">
  194. <table class="mytable" style="width: 100%;">
  195. <tr>
  196. <th width="20%">交租人身份证号</th>
  197. <td width="30%" >
  198. <input class="easyui-validatebox" readonly="readonly" style="width:150px" required="true" type="text" id="securityPersonIdCard_add" />
  199. <input type="hidden" id="securityPersonId_add" name="rent.securityPerson.id" />
  200. <input type="hidden" id="houseId_add" name="rent.house.id" />
  201. <input type="hidden" id="leaseContractId_add" name="rent.leaseContract.id" />
  202. </td>
  203. <th width="20%">交租人姓名</th>
  204. <td width="30%" >
  205. <input class="easyui-validatebox" readonly="readonly" style="width:150px" required="true" type="text" id="securityPersonName_add" />
  206. </td>
  207. </tr>
  208. <tr>
  209. <th width="20%">交租月数</th>
  210. <td width="30%" >
  211. <input id="rentMonth_add" name="rent.rentMonth" class="easyui-numberbox" required="true"/>
  212. </td>
  213. <th width="20%">月应交租金(减免后)</th>
  214. <td width="30%" >
  215. <input id="rentMonthMoney_add" precision="2" name="rent.rentMonthMoney" class="easyui-numberbox" required="true"/>
  216. </td>
  217. </tr>
  218. <tr>
  219. <th width="20%">应交租总金额</th>
  220. <td width="30%" >
  221. <input id="rentMoney1_add" precision="2" readonly="readonly" class="easyui-numberbox" required="true"/>
  222. </td>
  223. <th width="20%">实际交租总金额</th>
  224. <td width="30%" >
  225. <input id="rentMoney_add" precision="2" name="rent.rentMoney" class="easyui-numberbox" required="true"/>
  226. </td>
  227. </tr>
  228. <tr>
  229. <th width="20%">本次租金交纳开始时间</th>
  230. <td width="30%" >
  231. <input id="startDate_add" name="rent.startDate" class="easyui-datebox" required="true"/>
  232. </td>
  233. <th width="20%">本次租金交纳结束时间</th>
  234. <td width="30%" >
  235. <input id="endDate_add" name="rent.endDate" class="easyui-datebox" required="true"/>
  236. </td>
  237. </tr>
  238. <tr>
  239. <th width="20%">合同租房开始时间</th>
  240. <td width="30%" >
  241. <input id="leaseContract_startDate_add" class="easyui-datebox" />
  242. </td>
  243. <th width="20%">合同租房结束时间</th>
  244. <td width="30%" >
  245. <input id="leaseContract_endDate_add" class="easyui-datebox" />
  246. </td>
  247. </tr>
  248. <tr>
  249. <th width="20%">房屋地址</th>
  250. <td width="30%" >
  251. <input class="easyui-validatebox" readonly="readonly" style="width:150px" required="true" type="text" id="houseAddress_add" >
  252. </td>
  253. <th width="20%">户型</th>
  254. <td width="30%" >
  255. <select id="roomType_add" readonly="readonly" class="easyui-validatebox" required="true">
  256. <option value="">请选择</option>
  257. </select>
  258. </td>
  259. </tr>
  260. <tr>
  261. <th width="20%">合同编号</th>
  262. <td width="30%" >
  263. <input class="easyui-validatebox" style="width:150px" required="true" type="text" id="contractNo_add" readonly="readonly" >
  264. </td>
  265. <th width="20%">合同名称</th>
  266. <td width="30%" >
  267. <input class="easyui-validatebox" style="width:150px" required="true" type="text" id="contractName_add" >
  268. </td>
  269. </tr>
  270. <tr>
  271. <th width="20%">家庭情况</th>
  272. <td width="30%" >
  273. <select id="personType_add" readonly="readonly" class="easyui-validatebox" required="true">
  274. <option value="">请选择</option>
  275. </select>
  276. </td>
  277. <th width="20%">保障人口数量</th>
  278. <td width="30%" >
  279. <input class="easyui-numberbox" readonly="readonly" style="width:150px" required="true" type="text" id="securityNum_add" >
  280. </td>
  281. </tr>
  282. <tr>
  283. <th width="20%">房屋面积</th>
  284. <td width="30%" >
  285. <input class="easyui-numberbox" precision="2" readonly="readonly" style="width:150px" required="true" type="text" id="houseArea_add" >
  286. </td>
  287. <th width="20%">车库面积</th>
  288. <td width="30%" >
  289. <input class="easyui-numberbox" precision="2" readonly="readonly" style="width:150px" type="text" id="garageArea_add" >
  290. </td>
  291. </tr>
  292. </table>
  293. </form>
  294. </div>
  295. <!--<div title="凭证上传" id="fyxx_detail">
  296. </div>-->
  297. </div>