livingAllowanceInfo_info.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. /**
  2. * 初始化硕博人才生活补贴申报详情对话框
  3. */
  4. var LivingAllowanceInfoInfoDlg = {
  5. livingAllowanceInfoInfoData: {},
  6. validateFields: {
  7. enterpriseId: {validators: {notEmpty: {message: '所属企业不能为空'}}},
  8. enterpriseName: {validators: {notEmpty: {message: '所属企业不能为空'}}},
  9. type: {validators: {notEmpty: {message: '人才类别不能为空'}}},
  10. talentType: {validators: {notEmpty: {message: '人才标签不能为空'}}},
  11. name: {validators: {notEmpty: {message: '姓名不能为空'}}},
  12. nation: {validators: {notEmpty: {message: '民族不能为空'}}},
  13. provinceCode: {validators: {notEmpty: {message: '户籍省份不能为空'}}},
  14. cityCode: {validators: {notEmpty: {message: '户籍市不能为空'}}},
  15. address: {validators: {notEmpty: {message: '现居地址不能为空'}}},
  16. highEducation: {validators: {notEmpty: {message: '最高学历不能为空'}}},
  17. graduateSchool: {validators: {notEmpty: {message: '毕业院校不能为空'}}},
  18. major: {validators: {notEmpty: {message: '专业不能为空'}}},
  19. phone: {
  20. validators: {
  21. notEmpty: {
  22. message: '手机号码不能为空'
  23. },
  24. regexp: {
  25. regexp: /0?(13|14|15|17|18|19)[0-9]{9}/,
  26. message: "手机号码格式不正确"
  27. }
  28. }
  29. },
  30. bank: {
  31. validators: {
  32. notEmpty: {
  33. message: '开户银行不能为空'
  34. },
  35. regexp: {
  36. regexp: /^[\u4e00-\u9fa5]*银行$/,
  37. message: "开户银行格式不正确"
  38. }
  39. }
  40. },
  41. bankAccount: {
  42. validators: {
  43. notEmpty: {
  44. message: '银行账号不能为空'
  45. },
  46. regexp: {
  47. regexp: /^\d+$/,
  48. message: "银行账号格式不正确"
  49. }
  50. }
  51. },
  52. entryTime: {validators: {notEmpty: {message: '入职时间不能为空'}}},
  53. endTime: {validators: {notEmpty: {message: '工作合同结束时间不能为空'}}},
  54. type: {validators: {notEmpty: {message: '人才类别不能为空'}}},
  55. cardType: {validators: {notEmpty: {message: '证件类型不能为空'}}},
  56. idCard: {validators: {notEmpty: {message: '证件号码不能为空'}}},
  57. sex: {validators: {notEmpty: {message: '性别不能为空'}}},
  58. nationality: {validators: {notEmpty: {message: '国籍/地区不能为空'}}},
  59. birthday: {validators: {notEmpty: {message: '出生日期不能为空'}}},
  60. politics: {validators: {notEmpty: {message: '政治面貌不能为空'}}},
  61. post: {validators: {notEmpty: {message: '职务不能为空'}}},
  62. email: {
  63. validators: {
  64. notEmpty: {
  65. message: '电子邮箱不能为空'
  66. },
  67. emailAddress: {
  68. message: "电子邮箱格式不正确"
  69. }
  70. }
  71. },
  72. bankNetwork: {
  73. validators: {
  74. notEmpty: {
  75. message: '开户银行网点不能为空'
  76. },
  77. regexp: {
  78. regexp: /^[\u4e00-\u9fa5]*银行[\u4e00-\u9fa5]*省?[\u4e00-\u9fa5]+市[\u4e00-\u9fa5]*$/,
  79. message: "开户银行格式不正确"
  80. }
  81. }
  82. },
  83. bankNumber: {
  84. validators: {
  85. notEmpty: {
  86. message: '银行行号不能为空'
  87. },
  88. regexp: {
  89. regexp: /^\d+$/,
  90. message: "银行行号格式不正确"
  91. }
  92. }
  93. },
  94. introductionMode: {
  95. validators: {
  96. notEmpty: {
  97. message: '引进方式不能为空'
  98. }
  99. }
  100. },
  101. startTime: {validators: {notEmpty: {message: '工作合同开始时间不能为空'}}},
  102. mainHonours: {validators: {notEmpty: {message: '主要业绩及取得的荣誉不能为空'}}},
  103. educationAndResume: {validators: {notEmpty: {message: '教育背景及工作简历不能为空'}}},
  104. firstInJJTime: {validators: {notEmpty: {message: '首次来晋工作时间不能为空'}}},
  105. industryField: {validators: {notEmpty: {message: '行业领域不能为空'}}}
  106. },
  107. tax: null,
  108. socialSecurity: null
  109. };
  110. /**
  111. * 清除数据
  112. */
  113. LivingAllowanceInfoInfoDlg.clearData = function () {
  114. this.livingAllowanceInfoInfoData = {};
  115. }
  116. /**
  117. * 设置对话框中的数据
  118. *
  119. * @param key 数据的名称
  120. * @param val 数据的具体值
  121. */
  122. LivingAllowanceInfoInfoDlg.set = function (key, val) {
  123. this.livingAllowanceInfoInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  124. return this;
  125. }
  126. /**
  127. * 设置对话框中的数据
  128. *
  129. * @param key 数据的名称
  130. * @param val 数据的具体值
  131. */
  132. LivingAllowanceInfoInfoDlg.get = function (key) {
  133. return $("#" + key).val();
  134. }
  135. /**
  136. * 关闭此对话框
  137. */
  138. LivingAllowanceInfoInfoDlg.close = function () {
  139. parent.layer.close(window.parent.LivingAllowanceInfo.layerIndex);
  140. }
  141. /**
  142. * 收集数据
  143. */
  144. LivingAllowanceInfoInfoDlg.collectData = function () {
  145. this
  146. .set('id')
  147. .set('year')
  148. .set('enterpriseId')
  149. .set('enterpriseName')
  150. .set('type')
  151. .set('talentType')
  152. .set('cardType')
  153. .set('idCard')
  154. .set('name')
  155. .set('photo')
  156. .set('sex')
  157. .set('nation')
  158. .set('nationality')
  159. .set('provinceCode')
  160. .set('cityCode')
  161. .set('countyCode')
  162. .set('birthday')
  163. .set('address')
  164. .set('politics')
  165. .set('highEducation')
  166. .set('graduateSchool')
  167. .set('major')
  168. .set('post')
  169. .set('phone')
  170. .set('email')
  171. .set('bank')
  172. .set('bankNetwork')
  173. .set('bankAccount')
  174. .set('bankNumber')
  175. .set('entryTime')
  176. // .set('quitTime')
  177. .set('startTime')
  178. .set('endTime')
  179. .set('educationAndResume')
  180. .set('mainHonours')
  181. .set('firstInJJTime')
  182. // .set('isIntroduction')
  183. .set('industryField')
  184. .set('title')
  185. .set('professionalQualifications')
  186. .set('studyAbroad')
  187. // .set('studyAbroadCountry')
  188. .set('studyAbroadTime')
  189. .set('introductionMode')
  190. .set('letterTime')
  191. // .set('applyCount')
  192. ;
  193. if ($("#provinceCode").val() != null && $("#provinceCode").val() != '') {
  194. this.livingAllowanceInfoInfoData["provinceName"] = $("#provinceCode").find("option:selected").text();
  195. }
  196. if ($("#cityCode").val() != null && $("#cityCode").val() != '') {
  197. this.livingAllowanceInfoInfoData["cityName"] = $("#cityCode").find("option:selected").text();
  198. }
  199. if ($("#countyCode").val() != null && $("#countyCode").val() != '') {
  200. this.livingAllowanceInfoInfoData["countyName"] = $("#countyCode").find("option:selected").text();
  201. }
  202. var personalTaxVal = LivingAllowanceInfoInfoDlg.tax.getValue();
  203. var socialSecurityVal = LivingAllowanceInfoInfoDlg.socialSecurity.getValue();
  204. // if(personalTaxVal == null || personalTaxVal.length <= 0){
  205. // Feng.info("")
  206. // }
  207. var personalTax = personalTaxVal.map(function (item) {
  208. return item.value;
  209. }).join(",");
  210. var socialSecurity = socialSecurityVal.map(function (item) {
  211. return item.value;
  212. }).join(",");
  213. LivingAllowanceInfoInfoDlg.livingAllowanceInfoInfoData["personalTax"] = personalTax;
  214. LivingAllowanceInfoInfoDlg.livingAllowanceInfoInfoData["socialSecurity"] = socialSecurity;
  215. }
  216. /**
  217. * 数据校验
  218. * @returns {*|Window.jQuery}
  219. */
  220. LivingAllowanceInfoInfoDlg.validate = function () {
  221. $('#talentInfoForm').data("bootstrapValidator").resetForm();
  222. $('#talentInfoForm').bootstrapValidator('validate');
  223. return $("#talentInfoForm").data('bootstrapValidator').isValid();
  224. }
  225. /**
  226. * 提交添加
  227. */
  228. LivingAllowanceInfoInfoDlg.addSubmit = function () {
  229. this.clearData();
  230. this.collectData();
  231. if (!LivingAllowanceInfoInfoDlg.validate()) {
  232. return;
  233. }
  234. var formData = new FormData();
  235. Object.keys(this.livingAllowanceInfoInfoData).forEach((key) => {
  236. formData.append(key, this.livingAllowanceInfoInfoData[key]);
  237. });
  238. if (Feng.isEmptyStr(LivingAllowanceInfoInfoDlg.livingAllowanceInfoInfoData.id) && Feng.isEmptyStr($("#photo").val())) {
  239. Feng.info("头像不能为空!");
  240. return;
  241. }
  242. formData.append('file', $('#photo')[0].files[0]);
  243. $.ajax({
  244. url: Feng.ctxPath + "/api/livingAllowanceInfo/upsert",
  245. type: "POST",
  246. processData: false,
  247. contentType: false,
  248. data: formData,
  249. success: function (data) {
  250. LivingAllowanceInfoInfoDlg.setNoChangeField();
  251. if (data.code == 200) {
  252. Feng.success(data.msg);
  253. window.parent.LivingAllowanceInfo.table.refresh();
  254. $("#id").val(data.obj.id);
  255. $("#fileLi").removeAttr("style");
  256. $("#checkState").val(data.obj.checkState);
  257. } else {
  258. Feng.info(data.msg);
  259. }
  260. }, error: function (data) {
  261. Feng.error("保存失败!" + data.responseJSON.message + "!");
  262. }
  263. });
  264. }
  265. /**
  266. * 提交审核
  267. */
  268. LivingAllowanceInfoInfoDlg.submitToCheck = function () {
  269. var id = $("#id").val();
  270. if (Feng.isEmptyStr(id)) {
  271. Feng.info("请先填写基础信息并上传附件");
  272. return;
  273. }
  274. if (!validateIsEdit()) return;
  275. var operation = function () {
  276. var ajax = new $ax(Feng.ctxPath + "/api/livingAllowanceInfo/submitToCheck", function (data) {
  277. if (data.code == 200) {
  278. Feng.success(data.msg);
  279. // $("#checkState").val(data.obj);
  280. window.parent.LivingAllowanceInfo.table.refresh();
  281. LivingAllowanceInfoInfoDlg.close();
  282. } else {
  283. Feng.error(data.msg);
  284. }
  285. }, function (data) {
  286. Feng.error("提交审核失败!" + data.responseJSON.message + "!");
  287. });
  288. ajax.set("id", id);
  289. ajax.start();
  290. }
  291. Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  292. }
  293. /**
  294. * 设置不可修改的字段
  295. */
  296. LivingAllowanceInfoInfoDlg.setNoChangeField = function () {
  297. var checkState = $("#checkState").val();
  298. var fields = $("#fields").val();
  299. if (checkState == 10) {
  300. $("input,textarea").each(function () {
  301. $(this).attr("readonly", "readonly");
  302. });
  303. $("select").each(function () {
  304. $(this).attr("disabled", "disabled");
  305. });
  306. if (fields != null && fields != '') {
  307. var arr = fields.split(",");
  308. for (var key in arr) {
  309. var name = $("#" + arr[key]).prop("tagName");
  310. if (name == 'select' || name == 'SELECT') {
  311. $("#" + arr[key]).removeAttr("disabled");
  312. }
  313. if (name == "input" || name == 'textarea' || name == "INPUT" || name == 'TEXTAREA') {
  314. $("#" + arr[key]).removeAttr("readonly");
  315. }
  316. }
  317. }
  318. }
  319. }
  320. /**
  321. * 数据加载
  322. * */
  323. /**
  324. * 加载市
  325. */
  326. LivingAllowanceInfoInfoDlg.afterSelectProvince = function () {
  327. var province = $("#provinceCode").val();
  328. $("#cityCode").empty();
  329. $("#countyCode").empty();
  330. if (province == null || province == '') {
  331. return;
  332. }
  333. Feng.addAjaxSelect({
  334. "id": "cityCode",
  335. "displayCode": "code",
  336. "displayName": "name",
  337. "type": "GET",
  338. "url": Feng.ctxPath + "/api/commonLocation/findCityByProvinceSelect/" + province
  339. });
  340. }
  341. /**
  342. * 加载县
  343. */
  344. LivingAllowanceInfoInfoDlg.afterSelectCity = function () {
  345. var city = $("#cityCode").val();
  346. $("#countyCode").empty();
  347. if (city == null || city == '') {
  348. return;
  349. }
  350. Feng.addAjaxSelect({
  351. "id": "countyCode",
  352. "displayCode": "code",
  353. "displayName": "name",
  354. "type": "GET",
  355. "url": Feng.ctxPath + "/api/commonLocation/findCountyByCitySelect/" + city
  356. });
  357. }
  358. //校验是否保存基础信息
  359. LivingAllowanceInfoInfoDlg.validId = function () {
  360. var id = $("#id").val();
  361. if (id != null && id != '') {
  362. $("#fileLi").removeAttr("style");
  363. } else {
  364. $("#fileLi").attr("style", "pointer-events: none");
  365. }
  366. }
  367. LivingAllowanceInfoInfoDlg.initTaxAndSocialSecurity = function () {
  368. var year = $("#year").val().substr(0, 4);
  369. var data = new Array();
  370. for (var i = 1; i <= 12; i++) {
  371. var month = year + "-" + (i < 10 ? "0" + i : i);
  372. data.push({name: month, value: month, selected: false, disabled: false});
  373. }
  374. LivingAllowanceInfoInfoDlg.tax = xmSelect.render({
  375. el: '#personalTax',
  376. data: data
  377. })
  378. LivingAllowanceInfoInfoDlg.socialSecurity = xmSelect.render({
  379. el: '#socialSecurity',
  380. data: data
  381. })
  382. }
  383. function validUploadButton(type, row, fileId) {
  384. var files = $("#files").val();
  385. var checkState = $("#checkState").val();
  386. if ((Feng.isEmptyStr(checkState) || checkState == 0 || (checkState == 2 && files.indexOf(row.id) != -1)) && $("#hand").val() != "select") {
  387. return type == 1 ?
  388. "<button type='button' onclick=\"checkFile(this,'" + row.id + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  389. "<i class=\"fa fa-upload\"></i>上传" +
  390. "</button>"
  391. :
  392. "<button type=\'button\' onclick=\"checkFile(this,'" + row.id + "','" + fileId + "')\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\">" +
  393. "<i class=\"fa fa-paste\"></i>修改" +
  394. "</button>" +
  395. "<button type='button' onclick=\"deleteFile('" + fileId + "','" + CONFIG.project_master_living_allowance + "')\" class=\"btn btn-xs btn-danger\">" +
  396. "<i class=\"fa fa-times\"></i>删除" +
  397. "</button>";
  398. } else {
  399. return type == 1 ? "" : "";
  400. }
  401. }
  402. /**
  403. * 校验是否可以操作
  404. */
  405. function validateIsEdit() {
  406. var checkState = $("#checkState").val();
  407. if (checkState != 0 && checkState != 2) {
  408. Feng.error("您的申报正在审核中或已审核完成,无法操作");
  409. return false;
  410. }
  411. return true;
  412. }
  413. $(function () {
  414. Feng.initValidatorTip("talentInfoForm", LivingAllowanceInfoInfoDlg.validateFields);
  415. var hand = $("#hand").val();
  416. var id = $("#id").val();
  417. var checkState = $("#checkState").val();
  418. //批量加载字典表数据
  419. var arr = [
  420. {"name": "nation", "code": "un_nation"},
  421. {"name": "nationality", "code": "un_nationality"},
  422. {"name": "politics", "code": "un_political"},
  423. {"name": "highEducation", "code": "un_master_education"},
  424. {"name": "introductionMode", "code": "un_introduction_mode"},
  425. {"name": "industryField", "code": "un_industryField"},
  426. {"name": "address", "code": "un_street"}];
  427. if (hand == "select") arr.push({"name": "talentType", "code": "un_jbt_talentType"});
  428. if (hand == "update" && checkState != 0 && checkState != 2) arr.push({
  429. "name": "talentType",
  430. "code": "un_jbt_talentType"
  431. });
  432. Feng.findChildDictBatch(JSON.stringify(arr))
  433. //加载省份
  434. Feng.addAjaxSelect({
  435. "id": "provinceCode",
  436. "displayCode": "code",
  437. "displayName": "name",
  438. "type": "GET",
  439. "url": Feng.ctxPath + "/api/commonLocation/getProvinceSelect"
  440. });
  441. if (hand == 'add' || (hand == 'update' && (checkState == 0 || checkState == 2))) {
  442. //加载人才标签
  443. Feng.addAjaxSelect({
  444. "id": "talentType",
  445. "displayCode": "code",
  446. "displayName": "name",
  447. "type": "GET",
  448. "url": Feng.ctxPath + "/api/talentInfo/findTalentTypeByEnterprise"
  449. });
  450. }
  451. LivingAllowanceInfoInfoDlg.setNoChangeField();
  452. LivingAllowanceInfoInfoDlg.initTaxAndSocialSecurity();
  453. //批量加载时间控件
  454. $(".date").each(function () {
  455. laydate.render({
  456. elem: this
  457. , type: 'date'
  458. , trigger: 'click'
  459. });
  460. });
  461. if (id != null && id != '') {
  462. //select初始化
  463. $("select").each(function () {
  464. $(this).val($(this).attr("value")).trigger("change");
  465. });
  466. if (Feng.isNotEmptyStr($("#personalTax").attr("value"))) {
  467. LivingAllowanceInfoInfoDlg.tax.setValue($("#personalTax").attr("value").split(","));
  468. }
  469. if (Feng.isNotEmptyStr($("#socialSecurity").attr("value"))) {
  470. LivingAllowanceInfoInfoDlg.socialSecurity.setValue($("#socialSecurity").attr("value").split(","));
  471. }
  472. Feng.getCheckLog("logTable", {
  473. "type": CONFIG.project_master_living_allowance,
  474. "mainId": id,
  475. "typeFileId": "",
  476. "active": 1
  477. })
  478. }
  479. $("#address").val($("#address").attr("value"));
  480. $("#industryField").val($("#industryField").attr("value"));
  481. $("#provinceCode").val($("#provinceCode").attr("value"));
  482. LivingAllowanceInfoInfoDlg.afterSelectProvince();
  483. $("#cityCode").val($("#cityCode").attr("value"));
  484. LivingAllowanceInfoInfoDlg.afterSelectCity();
  485. $("#countyCode").val($("#countyCode").attr("value"));
  486. LivingAllowanceInfoInfoDlg.validId();
  487. $("#photo").change(function (e) {
  488. var tag = e.target;
  489. var file = tag.files[0];
  490. var imgSrc;
  491. var reader = new FileReader();
  492. reader.readAsDataURL(file);
  493. reader.onload = function () {
  494. imgSrc = this.result;
  495. $("#photoImg").attr("src", imgSrc);
  496. };
  497. });
  498. });