houseRentingPurchaseFees_info.js 19 KB

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