educationSchool_info.js 10 KB

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