houseRenting_info.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. /**
  2. * 初始化租房申请详情对话框
  3. */
  4. var HouseRentingInfoDlg = {
  5. houseRentingInfoData : {},
  6. validateFields: {
  7. talentId: {validators: {notEmpty: {message: '申报对象不能为空'}}},
  8. email: {validators: {notEmpty: {message: '电子邮箱不能为空'}}},
  9. houseType: {validators: {notEmpty: {message: '拟申请租住人才社区不能为空'}}},
  10. cardType: {validators: {notEmpty: {message: '证件类型不能为空'}}},
  11. idCard: {validators: {notEmpty: {message: '证件号码不能为空'}}},
  12. marryStatus: {validators: {notEmpty: {message: '婚姻状态不能为空'}}},
  13. }
  14. };
  15. /**
  16. * 清除数据
  17. */
  18. HouseRentingInfoDlg.clearData = function() {
  19. this.houseRentingInfoData = {};
  20. }
  21. /**
  22. * 设置对话框中的数据
  23. *
  24. * @param key 数据的名称
  25. * @param val 数据的具体值
  26. */
  27. HouseRentingInfoDlg.set = function(key, val) {
  28. this.houseRentingInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  29. return this;
  30. }
  31. /**
  32. * 设置对话框中的数据
  33. *
  34. * @param key 数据的名称
  35. * @param val 数据的具体值
  36. */
  37. HouseRentingInfoDlg.get = function(key) {
  38. return $("#" + key).val();
  39. }
  40. /**
  41. * 关闭此对话框
  42. */
  43. HouseRentingInfoDlg.close = function() {
  44. parent.layer.close(window.parent.HouseRenting.layerIndex);
  45. }
  46. /**
  47. * 收集数据
  48. */
  49. HouseRentingInfoDlg.collectData = function() {
  50. this
  51. .set('id')
  52. .set('type')
  53. .set('talentId')
  54. .set('phone')
  55. .set('email')
  56. .set('marryStatus')
  57. .set('spouseName')
  58. .set('spouseSex')
  59. .set('spouseCardType')
  60. .set('spouseIdCard')
  61. .set('spouseTalentArrange')
  62. .set('spouseNativePlace')
  63. .set('spouseEntryTime')
  64. .set('spousePost')
  65. .set('spouseEnterpriseName')
  66. .set('spouseEnterpriseAddress')
  67. .set('spouseAddress')
  68. .set('spousePhone')
  69. .set('spouseEmail')
  70. .set('houseType')
  71. .set('checkState');
  72. this.houseRentingInfoData['pensionDetail'] = Feng.getCheckBoxValues("pensionDetail");
  73. this.houseRentingInfoData['unemploymentDetail'] = Feng.getCheckBoxValues("unemploymentDetail");
  74. this.houseRentingInfoData['medicaDetail'] = Feng.getCheckBoxValues("medicaDetail");
  75. this.houseRentingInfoData['taxDetail'] = Feng.getCheckBoxValues("taxDetail");
  76. }
  77. /**
  78. * 验证数据
  79. */
  80. HouseRentingInfoDlg.validate = function () {
  81. $('#houseRentingInfoForm').data("bootstrapValidator").resetForm();
  82. $('#houseRentingInfoForm').bootstrapValidator('validate');
  83. return $("#houseRentingInfoForm").data('bootstrapValidator').isValid();
  84. }
  85. HouseRentingInfoDlg.nameChange = function(){
  86. var talentId = $("#talentId").val();
  87. if(Feng.isNotEmptyStr(talentId)){
  88. var ajax = new $ax(Feng.ctxPath + "/api/talentInfo/detail/"+talentId, function(data){
  89. var talentInfo = data;
  90. $("#name").val(talentInfo.name);
  91. $("#sex").val(talentInfo.sex);
  92. $("#cardType").val(talentInfo.cardType);
  93. $("#idCard").val(talentInfo.idCard);
  94. $("#nativePlace").val(talentInfo.provinceName+talentInfo.cityName+talentInfo.countyName);
  95. $("#talentArrange").val(talentInfo.talentArrange).trigger("change");
  96. $("#entryTime").val(talentInfo.entryTime);
  97. $("#post").val(talentInfo.post);
  98. $("#enterpriseAddress").val(talentInfo.enterpriseAddress);
  99. $("#phone").val(talentInfo.phone);
  100. $("#email").val(talentInfo.email);
  101. },function(data){
  102. Feng.error("查询失败!" + data.responseJSON.message + "!");
  103. });
  104. ajax.start();
  105. }
  106. }
  107. /**
  108. * 添加未成年子女
  109. */
  110. HouseRentingInfoDlg.addChild = function(){
  111. var options = $("#cardType").html();
  112. $("#childData").append(
  113. '<div class="col-sm-12">\n' +
  114. '<input type="hidden" name="id"/>\n' +
  115. '<input type="hidden" name="pId"/>'+
  116. '<div class="rowGroup col-sm-3">\n' +
  117. '<input type="text" class="form-control" name="childName" placeholder="未成年子女姓名"/>\n' +
  118. '</div>\n' +
  119. '<div class="rowGroup col-sm-3">\n' +
  120. '<select class="form-control" name="childCardType" placeholder="未成年子女证件类型">\n' +
  121. options+
  122. '</select>\n' +
  123. '</div>\n' +
  124. '<div class="rowGroup col-sm-3">\n' +
  125. '<input type="text" class="form-control" name="childIdCard" placeholder="未成年子女证件号码"/>\n' +
  126. '</div>\n' +
  127. '<div class="add-btn" onclick="HouseRentingInfoDlg.addChild()"></div>\n' +
  128. '<div class="reduce" onclick="HouseRentingInfoDlg.reduceChild(this)"></div>'+
  129. '</div>');
  130. }
  131. /**
  132. * 删除子女信息
  133. */
  134. HouseRentingInfoDlg.reduceChild = function(context){
  135. var id = $(context).parent().find("input[name='id']").val();
  136. if(Feng.isEmptyStr(id)){
  137. $(context).parent().remove();
  138. if($("#childData").children().length == 0){
  139. HouseRentingInfoDlg.addChild();
  140. }
  141. }else{
  142. if(!validateIsEdit())return;
  143. var operation = function () {
  144. var ajax = new $ax(Feng.ctxPath + "/api/houseRenting/deleteChildren", function(data){
  145. if(data.code == 200){
  146. $(context).parent().remove();
  147. Feng.success(data.msg);
  148. if($("#childData").children().length == 0){
  149. HouseRentingInfoDlg.addChild();
  150. }
  151. }else{
  152. Feng.info(data.msg);
  153. }
  154. },function(data){
  155. Feng.error("添加失败!" + data.responseJSON.message + "!");
  156. });
  157. ajax.set("id",id);
  158. ajax.start();
  159. }
  160. Feng.confirm("删除后无法恢复,确认删除吗?", operation);
  161. }
  162. }
  163. /**
  164. * 提交添加
  165. */
  166. HouseRentingInfoDlg.addSubmit = function() {
  167. var id = $("#id").val();
  168. if(Feng.isNotEmptyStr(id)){
  169. HouseRentingInfoDlg.editSubmit(1);
  170. return;
  171. }
  172. this.clearData();
  173. this.collectData();
  174. if(!HouseRentingInfoDlg.validate()){
  175. return ;
  176. }
  177. //提交信息
  178. var child = new Array();
  179. var error = "";
  180. $("#childData .col-sm-12").each(function (index) {
  181. var id = $(this).find("input[name='id']").val();
  182. var pId = $(this).find("input[name='pId']").val();
  183. var childName = $(this).find("input[name='childName']").val();
  184. var childCardType = $(this).find("select[name='childCardType']").val();
  185. var childIdCard = $(this).find("input[name='childIdCard']").val();
  186. if (Feng.isNotEmptyStr(id) || Feng.isNotEmptyStr(pId) || Feng.isNotEmptyStr(childName) || Feng.isNotEmptyStr(childCardType) || Feng.isNotEmptyStr(childIdCard)){
  187. if(Feng.isEmptyStr(childName)){
  188. error = error + "第"+ (index + 1) + "行未成年子女姓名为空;\n";
  189. }
  190. if(Feng.isEmptyStr(childCardType)){
  191. error = error + "第"+ (index + 1) + "行未成年子女证件类型为空;\n";
  192. }
  193. if(Feng.isEmptyStr(childIdCard)){
  194. error = error + "第"+ (index + 1) + "行未成年子女证件号码为空;\n";
  195. }
  196. child.push({"id":id,"pId":pId,"name":childName,"cardType":childCardType,"idCard":childIdCard});
  197. }
  198. });
  199. if (Feng.isNotEmptyStr(error)){
  200. Feng.info(error);
  201. return;
  202. }
  203. this.houseRentingInfoData['childList'] = child;
  204. var ajax = new $ax(Feng.ctxPath + "/api/houseRenting/add", function(data){
  205. if(data.code == 200){
  206. var obj = data.obj;
  207. var childList = obj.childList;
  208. Feng.success(data.msg);
  209. $("#id").val(obj.id);
  210. $("#type").val(obj.type);
  211. $("#fileLi").removeAttr("style");
  212. $("#checkState").val(obj.checkState);
  213. HouseRentingInfoDlg.initChildData(childList);
  214. }else{
  215. Feng.info(data.msg);
  216. }
  217. },function(data){
  218. Feng.error("添加失败!" + data.responseJSON.message + "!");
  219. });
  220. ajax.setcontentType("application/json;charset=utf-8");
  221. ajax.setData(JSON.stringify(this.houseRentingInfoData));
  222. ajax.start();
  223. }
  224. /**
  225. * 提交修改
  226. */
  227. HouseRentingInfoDlg.editSubmit = function(type) {
  228. this.clearData();
  229. this.collectData();
  230. if(!validateIsEdit())return;
  231. if(!HouseRentingInfoDlg.validate()){
  232. return ;
  233. }
  234. //提交信息
  235. var child = new Array();
  236. var error = "";
  237. $("#childData .col-sm-12").each(function (index) {
  238. var id = $(this).find("input[name='id']").val();
  239. var pId = $(this).find("input[name='pId']").val();
  240. var childName = $(this).find("input[name='childName']").val();
  241. var childCardType = $(this).find("select[name='childCardType']").val();
  242. var childIdCard = $(this).find("input[name='childIdCard']").val();
  243. if (Feng.isNotEmptyStr(id) || Feng.isNotEmptyStr(pId) || Feng.isNotEmptyStr(childName) || Feng.isNotEmptyStr(childCardType) || Feng.isNotEmptyStr(childIdCard)){
  244. if(Feng.isEmptyStr(childName)){
  245. error = error + "第"+ (index + 1) + "行未成年子女姓名为空;\n";
  246. }
  247. if(Feng.isEmptyStr(childCardType)){
  248. error = error + "第"+ (index + 1) + "行未成年子女证件类型为空;\n";
  249. }
  250. if(Feng.isEmptyStr(childIdCard)){
  251. error = error + "第"+ (index + 1) + "行未成年子女证件号码为空;\n";
  252. }
  253. child.push({"id":id,"pId":pId,"name":childName,"cardType":childCardType,"idCard":childIdCard});
  254. }
  255. });
  256. if (Feng.isNotEmptyStr(error)){
  257. Feng.info(error);
  258. return;
  259. }
  260. this.houseRentingInfoData['childList'] = child;
  261. var ajax = new $ax(Feng.ctxPath + "/api/houseRenting/update", function(data){
  262. if(data.code == 200){
  263. if(type == 1){
  264. var childList = data.obj.childList;
  265. Feng.success(data.msg);
  266. HouseRentingInfoDlg.initChildData(childList);
  267. }else{
  268. HouseRentingInfoDlg.submitToCheck();
  269. }
  270. }else{
  271. Feng.info(data.msg);
  272. }
  273. },function(data){
  274. Feng.error("修改失败!" + data.responseJSON.message + "!");
  275. });
  276. ajax.setcontentType("application/json;charset=utf-8");
  277. ajax.setData(JSON.stringify(this.houseRentingInfoData));
  278. ajax.start();
  279. }
  280. /**
  281. * 提交审核
  282. */
  283. HouseRentingInfoDlg.submitToCheck = function(){
  284. if(!validateIsEdit())return;
  285. var operation = function() {
  286. var ajax = new $ax(Feng.ctxPath + "/api/houseRenting/submitToCheck", function (data) {
  287. if(data.code==200){
  288. Feng.success(data.msg);
  289. window.parent.HouseRenting.table.refresh();
  290. HouseRentingInfoDlg.close();
  291. }else{
  292. Feng.error(data.msg);
  293. }
  294. }, function (data) {
  295. Feng.error("提交审核失败!" + data.responseJSON.message + "!");
  296. });
  297. ajax.set("id", $("#id").val());
  298. ajax.start();
  299. }
  300. Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  301. }
  302. /**
  303. * 校验是否显示按钮
  304. * @param type 类型 1-上传按钮,2-修改删除按钮
  305. * @param row
  306. * @returns {string}
  307. */
  308. function validUploadButton(type,row,fileId){
  309. var files = $("#files").val();
  310. var checkState = $("#checkState").val();
  311. if(Feng.isEmptyStr(checkState)||checkState==1 || (checkState == 10 )){
  312. return type == 1?
  313. "<button type='button' onclick=\"checkFile(this,'"+row.id+"','"+null+"')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  314. "<i class=\"fa fa-upload\"></i>上传" +
  315. "</button>"
  316. :
  317. "<button type=\'button\' onclick=\"checkFile(this,'"+row.id+"','"+fileId+"')\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\">" +
  318. "<i class=\"fa fa-paste\"></i>修改" +
  319. "</button>" +
  320. "<button type='button' onclick=\"deleteFile('"+fileId+"','"+CONFIG.project_renting+"')\" class=\"btn btn-xs btn-danger\">" +
  321. "<i class=\"fa fa-times\"></i>删除" +
  322. "</button>";
  323. }else{
  324. return type == 1?"":"" ;
  325. }
  326. }
  327. function validateIsEdit(){
  328. var id = $("#id").val();
  329. var checkState = $("#checkState").val();
  330. if(Feng.isEmptyStr(id)){
  331. Feng.info("请先填写基础信息并上传附件");
  332. return false;
  333. }
  334. if(checkState != 1 && checkState != 10){
  335. if(checkState==-1){
  336. Feng.error("您的申报审核不通过,无法修改");
  337. return false;
  338. }else if(checkState>=30){
  339. Feng.error("您的申报已审核通过,无法修改");
  340. return false;
  341. }else{
  342. Feng.error("您的申报正在审核中,请耐心等待");
  343. return false;
  344. }
  345. }
  346. return true;
  347. }
  348. /**
  349. * 初始化子女信息
  350. * @param list
  351. */
  352. HouseRentingInfoDlg.initChildData = function(list){
  353. var options = $("#cardType").html();
  354. var html = "";
  355. for(var key in list) {
  356. html = html +
  357. '<div class="col-sm-12">\n' +
  358. '<input type="hidden" name="id" value="'+list[key].id+'"/>\n' +
  359. '<input type="hidden" name="pId" value="'+list[key].pId+'"/>' +
  360. '<div class="rowGroup col-sm-3">\n' +
  361. '<input type="text" class="form-control" name="childName" value="'+list[key].name+'" placeholder="未成年子女姓名"/>\n' +
  362. '</div>\n' +
  363. '<div class="rowGroup col-sm-3">\n' +
  364. '<select class="form-control" name="childCardType" value="'+list[key].cardType+'" placeholder="未成年子女证件类型">\n' +
  365. options +
  366. '</select>\n' +
  367. '</div>\n' +
  368. '<div class="rowGroup col-sm-3">\n' +
  369. '<input type="text" class="form-control" name="childIdCard" value="'+list[key].idCard+'" placeholder="未成年子女证件号码"/>\n' +
  370. '</div>\n' +
  371. '<div class="add-btn" onclick="HouseRentingInfoDlg.addChild()"></div>\n' +
  372. '<div class="reduce" onclick="HouseRentingInfoDlg.reduceChild(this)"></div>'+
  373. '</div>';
  374. }
  375. if(Feng.isEmptyStr(html)){
  376. html = html +
  377. '<div class="col-sm-12">\n' +
  378. '<input type="hidden" name="id" />\n' +
  379. '<input type="hidden" name="pId" />' +
  380. '<div class="rowGroup col-sm-3">\n' +
  381. '<input type="text" class="form-control" name="childName" placeholder="未成年子女姓名"/>\n' +
  382. '</div>\n' +
  383. '<div class="rowGroup col-sm-3">\n' +
  384. '<select class="form-control" name="childCardType" placeholder="未成年子女证件类型">\n' +
  385. options +
  386. '</select>\n' +
  387. '</div>\n' +
  388. '<div class="rowGroup col-sm-3">\n' +
  389. '<input type="text" class="form-control" name="childIdCard" placeholder="未成年子女证件号码"/>\n' +
  390. '</div>\n' +
  391. '<div class="add-btn" onclick="HouseRentingInfoDlg.addChild()"></div>\n' +
  392. '</div>';
  393. }
  394. $("#childData").empty().append(html);
  395. $("#childData select").each(function () {
  396. $(this).val($(this).attr("value"))
  397. })
  398. if(list == null){
  399. HouseRentingInfoDlg.addChild();
  400. }
  401. }
  402. HouseRentingInfoDlg.checkSbAndTax = function(){
  403. var pensionDetail = $("#pensionDetail").attr("value");
  404. var unemploymentDetail = $("#unemploymentDetail").attr("value");
  405. var medicaDetail = $("#medicaDetail").attr("value");
  406. var taxDetail = $("#taxDetail").attr("value");
  407. $("#pensionDetail input").each(function () {
  408. if(pensionDetail.indexOf($(this).val())!= -1){
  409. $(this).attr("checked", true);
  410. }
  411. })
  412. $("#unemploymentDetail input").each(function () {
  413. if(unemploymentDetail.indexOf($(this).val())!= -1){
  414. $(this).attr("checked", true);
  415. }
  416. })
  417. $("#medicaDetail input").each(function () {
  418. if(medicaDetail.indexOf($(this).val())!= -1){
  419. $(this).attr("checked", true);
  420. }
  421. })
  422. $("#taxDetail input").each(function () {
  423. if(taxDetail.indexOf($(this).val())!= -1){
  424. $(this).attr("checked", true);
  425. }
  426. })
  427. }
  428. $(function() {
  429. Feng.initValidatorTip("houseRentingInfoForm", HouseRentingInfoDlg.validateFields);
  430. //批量加载字典表数据
  431. var arr = [
  432. {"name":"cardType","code":"un_cardType"},
  433. {"name":"talentArrange","code":"un_talentLevel"},
  434. {"name":"houseType","code":"un_renting_houseType"},
  435. {"name":"marryStatus","code":"un_marryStatus"},
  436. {"name":"spouseCardType","code":"un_cardType"},
  437. {"name":"spouseTalentArrange","code":"un_talentLevel"}];
  438. Feng.findChildDictBatch(JSON.stringify(arr));
  439. $("select[name='childCardType']").empty().append($("#cardType").html());
  440. //加载时间控件
  441. $(".date").each(function(){laydate.render({
  442. elem: this,type: 'date',trigger: 'click'
  443. });
  444. });
  445. var id = $("#id").val();
  446. if(Feng.isNotEmptyStr(id)){
  447. $("select").each(function () {$(this).val($(this).attr("value")).trigger("change");});
  448. $("#fileLi").removeAttr("style");
  449. HouseRentingInfoDlg.checkSbAndTax();
  450. Feng.getCheckLog("logTable",{"type":CONFIG.project_renting,"mainId":id,"typeFileId":"","active":1})
  451. }else{
  452. $("#fileLi").attr("style","pointer-events: none");
  453. }
  454. });