childschoolFees_info.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. /**
  2. * 初始化学杂费补助详情对话框
  3. */
  4. var ChildschoolFeesInfoDlg = {
  5. childschoolFeesInfoData : {},
  6. validateFields: {
  7. pSex: {validators: {notEmpty: {message: '申报人性别不能为空'}}},
  8. pIdcard: {validators: {notEmpty: {message: '申报人证件号码不能为空'}}},
  9. talentArrange: {validators: {notEmpty: {message: '人才层次不能为空'}}},
  10. certificateNo: {validators: {notEmpty: {message: '人才编号不能为空'}}},
  11. nativePlace: {validators: {notEmpty: {message: '籍贯不能为空'}}},
  12. address: {validators: {notEmpty: {message: '现居地址不能为空'}}},
  13. phone: {
  14. validators: {
  15. notEmpty: {
  16. message: '联系电话不能为空'
  17. },
  18. regexp: {
  19. regexp: /0?(13|14|15|16|17|18|19)[0-9]{9}/,
  20. message: "手机号码格式不正确"
  21. }
  22. }
  23. },
  24. cName: {validators: {notEmpty: {message: '子女姓名不能为空'}}},
  25. cSex: {validators: {notEmpty: {message: '子女性别不能为空'}}},
  26. cIdcard: {validators: {notEmpty: {message: '子女证件号码不能为空'}}},
  27. cBirthday: {validators: {notEmpty: {message: '子女出生日期不能为空'}}},
  28. cRelation: {validators: {notEmpty: {message: '与申报人关系不能为空'}}},
  29. nowSchool: {validators: {notEmpty: {message: '现就读学校不能为空'}}},
  30. nowGrade: {validators: {notEmpty: {message: '现就读年级不能为空'}}},
  31. paidInMoeny: {validators: {notEmpty: {message: '实缴学杂费补助不能为空'}}},
  32. }
  33. };
  34. /**
  35. * 清除数据
  36. */
  37. ChildschoolFeesInfoDlg.clearData = function() {
  38. this.childschoolFeesInfoData = {};
  39. }
  40. /**
  41. * 设置对话框中的数据
  42. *
  43. * @param key 数据的名称
  44. * @param val 数据的具体值
  45. */
  46. ChildschoolFeesInfoDlg.set = function(key, val) {
  47. this.childschoolFeesInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  48. return this;
  49. }
  50. /**
  51. * 设置对话框中的数据
  52. *
  53. * @param key 数据的名称
  54. * @param val 数据的具体值
  55. */
  56. ChildschoolFeesInfoDlg.get = function(key) {
  57. return $("#" + key).val();
  58. }
  59. /**
  60. * 关闭此对话框
  61. */
  62. ChildschoolFeesInfoDlg.close = function() {
  63. parent.layer.close(window.parent.ChildschoolFees.layerIndex);
  64. }
  65. /**
  66. * 收集数据
  67. */
  68. ChildschoolFeesInfoDlg.collectData = function() {
  69. this
  70. .set('id')
  71. .set('year')
  72. .set('enterpriseId')
  73. .set('talentId')
  74. .set('type')
  75. .set('pName')
  76. .set('pSex')
  77. .set('pCardType')
  78. .set('pIdcard')
  79. .set('talentArrange')
  80. .set('certificateNo')
  81. .set('nativePlace')
  82. .set('address')
  83. .set('phone')
  84. .set('cName')
  85. .set('cSex')
  86. .set('cCardType')
  87. .set('cIdcard')
  88. .set('cBirthday')
  89. .set('stuNumber')
  90. .set('cRelation')
  91. .set('nowSchool')
  92. .set('nowGrade')
  93. .set('paidInMoeny')
  94. .set('bankName')
  95. .set('bankAddress')
  96. .set('bankNumber');
  97. this.childschoolFeesInfoData['pensionDetail'] = Feng.getCheckBoxValues('pensionDetail');
  98. this.childschoolFeesInfoData['unemploymentDetail'] = Feng.getCheckBoxValues('unemploymentDetail');
  99. this.childschoolFeesInfoData['medicaDetail'] = Feng.getCheckBoxValues('medicaDetail');
  100. this.childschoolFeesInfoData['taxDetail'] = Feng.getCheckBoxValues('taxDetail');
  101. }
  102. /**
  103. * 根据所选人才对象初始化相应数据
  104. */
  105. ChildschoolFeesInfoDlg.objChange = function(){
  106. var talentId = $("#talentId").val();
  107. if(Feng.isEmptyStr(talentId)){
  108. $("#pSex,#pCardType,#pIdcard,#talentArrange,#certificateNo,#nativePlace,#phone,#bankName,#bankAddress,#bankNumber").val("");
  109. }else{
  110. var ajax = new $ax(Feng.ctxPath + "/api/talentInfo/detail/"+talentId, function(data){
  111. $("#pSex").val(data.sex);
  112. $("#pCardType").val(data.cardType);
  113. $("#pIdcard").val(data.idCard);
  114. $("#talentArrange").val(data.talentArrange);
  115. $("#certificateNo").val(data.certificateNO);
  116. $("#nativePlace").val(data.provinceName+data.cityName+data.countyName);
  117. $("#phone").val(data.phone);
  118. $("#bankName").val(data.bank);
  119. $("#bankAddress").val(data.bankNetwork);
  120. $("#bankNumber").val(data.bankAccount);
  121. },function(data){
  122. Feng.error("查询失败!" + data.responseJSON.message + "!");
  123. });
  124. ajax.start();
  125. }
  126. }
  127. /**
  128. * 校验字段
  129. */
  130. ChildschoolFeesInfoDlg.validate = function(){
  131. $('#childschoolFeesForm').data("bootstrapValidator").resetForm();
  132. $('#childschoolFeesForm').bootstrapValidator('validate');
  133. return $("#childschoolFeesForm").data('bootstrapValidator').isValid();
  134. }
  135. /**
  136. * 校验是否可以操作
  137. */
  138. function validateIsEdit () {
  139. var checkState = $("#checkState").val();
  140. if(Feng.isNotEmptyStr(checkState) && checkState != 1 && checkState != 4) {
  141. Feng.error("您的申报正在审核中或已审核完成,无法操作");
  142. return false;
  143. }
  144. return true;
  145. }
  146. /**
  147. * 提交添加
  148. */
  149. ChildschoolFeesInfoDlg.addSubmit = function() {
  150. if(Feng.isNotEmptyStr($("#id").val())){
  151. ChildschoolFeesInfoDlg.editSubmit();
  152. return;
  153. }
  154. this.clearData();
  155. this.collectData();
  156. if(!ChildschoolFeesInfoDlg.validate()){
  157. return ;
  158. }
  159. if(!validateIsEdit())return;
  160. //提交信息
  161. var ajax = new $ax(Feng.ctxPath + "/api/childschoolFees/add", function(data){
  162. if(data.code == 200){
  163. Feng.success(data.msg);
  164. window.parent.ChildschoolFees.table.refresh();
  165. $("#id").val(data.obj.id);
  166. $("#checkState").val(data.obj.checkState);
  167. ChildschoolFeesInfoDlg.validId();
  168. }else{
  169. Feng.info(data.msg);
  170. }
  171. },function(data){
  172. Feng.error("添加失败!" + data.responseJSON.message + "!");
  173. });
  174. ajax.set(this.childschoolFeesInfoData);
  175. ajax.start();
  176. }
  177. /**
  178. * 提交修改
  179. */
  180. ChildschoolFeesInfoDlg.editSubmit = function() {
  181. this.clearData();
  182. this.collectData();
  183. if(!ChildschoolFeesInfoDlg.validate()){
  184. return ;
  185. }
  186. if(!validateIsEdit())return;
  187. //提交信息
  188. var ajax = new $ax(Feng.ctxPath + "/api/childschoolFees/update", function(data){
  189. if(data.code == 200){
  190. Feng.success(data.msg);
  191. window.parent.ChildschoolFees.table.refresh();
  192. }else{
  193. Feng.info(data.msg);
  194. }
  195. },function(data){
  196. Feng.error("修改失败!" + data.responseJSON.message + "!");
  197. });
  198. ajax.set(this.childschoolFeesInfoData);
  199. ajax.start();
  200. }
  201. /**
  202. * 提交审核
  203. */
  204. ChildschoolFeesInfoDlg.submitToCheck = function () {
  205. var id = $("#id").val();
  206. if(id==null || id==""){
  207. Feng.info("请先填写基础信息并上传附件");
  208. return ;
  209. }
  210. if(!validateIsEdit())return;
  211. var operation = function() {
  212. var ajax = new $ax(Feng.ctxPath + "/api/childschoolFees/submitToCheck", function (data) {
  213. if(data.code==200){
  214. Feng.success(data.msg);
  215. // $("#checkState").val(data.obj);
  216. window.parent.ChildschoolFees.table.refresh();
  217. ChildschoolFeesInfoDlg.close();
  218. }else{
  219. Feng.error(data.msg);
  220. }
  221. }, function (data) {
  222. Feng.error("提交审核失败!" + data.responseJSON.message + "!");
  223. });
  224. ajax.set("id", id);
  225. ajax.start();
  226. }
  227. Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  228. }
  229. /**
  230. * 校验是否显示按钮
  231. * @param type 类型 1-上传按钮,2-修改删除按钮
  232. * @param row
  233. * @returns {string}
  234. */
  235. function validUploadButton(type,row,fileId){
  236. var checkState = $("#checkState").val();
  237. if(Feng.isEmptyStr(checkState)|| checkState ==1 ||checkState== 4){
  238. if(type == 1){ //上传
  239. return "<button type='button' onclick=\"checkFile(this,'"+row.id+"','"+null+"')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  240. "<i class=\"fa fa-upload\"></i>上传" +
  241. "</button>" ;
  242. }else{
  243. return "<button type=\'button\' onclick=\"checkFile(this,'"+row.id+"','"+fileId+"')\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\">" +
  244. "<i class=\"fa fa-paste\"></i>修改" +
  245. "</button>" +
  246. "<button type='button' onclick=\"deleteFile('"+fileId+"','"+CONFIG.project_schoolFees+"')\" class=\"btn btn-xs btn-danger\">" +
  247. "<i class=\"fa fa-times\"></i>删除" +
  248. "</button>";
  249. }
  250. }else{
  251. return type == 1?"":"";
  252. }
  253. }
  254. //校验是否保存基础信息
  255. ChildschoolFeesInfoDlg.validId = function (){
  256. $("#fileLi").css("pointer-events",Feng.isEmptyStr($("#id").val())?"none":"auto");
  257. }
  258. ChildschoolFeesInfoDlg.checkSbAndTax = function(){
  259. var pensionDetail = $("#pensionDetail").attr("data-month");
  260. var unemploymentDetail = $("#unemploymentDetail").attr("value");
  261. var medicaDetail = $("#medicaDetail").attr("value");
  262. var taxDetail = $("#taxDetail").attr("value");
  263. $("#pensionDetail input").each(function () {
  264. if(pensionDetail.indexOf($(this).val())!= -1){
  265. $(this).attr("checked", true);
  266. }
  267. })
  268. $("#unemploymentDetail input").each(function () {
  269. if(unemploymentDetail.indexOf($(this).val())!= -1){
  270. $(this).attr("checked", true);
  271. }
  272. })
  273. $("#medicaDetail input").each(function () {
  274. if(medicaDetail.indexOf($(this).val())!= -1){
  275. $(this).attr("checked", true);
  276. }
  277. })
  278. $("#taxDetail input").each(function () {
  279. if(taxDetail.indexOf($(this).val())!= -1){
  280. $(this).attr("checked", true);
  281. }
  282. })
  283. }
  284. $(function() {
  285. Feng.initValidatorTip("childschoolFeesForm",ChildschoolFeesInfoDlg.validateFields);
  286. var arr = [{"name":"talentArrange","code":"un_talentLevel"},
  287. {"name":"cRelation","code":"un_education_relation"},
  288. {"name":"nowGrade","code":"un_grade"},
  289. {"name":"pCardType","code":"un_cardType"},
  290. {"name":"cCardType","code":"un_cardType"}];
  291. Feng.findChildDictBatch(JSON.stringify(arr))
  292. //批量加载时间控件
  293. $(".date").each(function(){
  294. laydate.render({
  295. elem: this
  296. ,type: 'date'
  297. ,trigger: 'click'
  298. });
  299. });
  300. if(Feng.isNotEmptyStr($("#id").val())){
  301. $("select").each(function () {
  302. $(this).val($(this).attr("value")).trigger("change");
  303. });
  304. Feng.getCheckLog("logTable",{"type":CONFIG.project_schoolFees,"mainId":$("#id").val(),"typeFileId":"","active":1})
  305. ChildschoolFeesInfoDlg.checkSbAndTax();
  306. }
  307. ChildschoolFeesInfoDlg.validId();
  308. });