talentBasicChange_info.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /**
  2. * 初始化人才基础信息变更详情对话框
  3. */
  4. var TalentBasicChangeInfoDlg = {
  5. talentBasicChangeInfoData: {},
  6. validateFields: {
  7. talentId: {validators: {notEmpty: {message: '原姓名不能为空'}}},
  8. newName: {validators: {notEmpty: {message: '现姓名不能为空'}}},
  9. newBirthday: {validators: {notEmpty: {message: '现出生日期不能为空'}}},
  10. newNationality: {validators: {notEmpty: {message: '现国家/地区不能为空'}}},
  11. newNation: {validators: {notEmpty: {message: '现民族不能为空'}}},
  12. newPolitics: {validators: {notEmpty: {message: '现政治面貌不能为空'}}},
  13. newCardType: {validators: {notEmpty: {message: '现证件类型不能为空'}}},
  14. newIdCard: {validators: {notEmpty: {message: '现证件号码不能为空'}}},
  15. newEmail: {validators: {notEmpty: {message: '现电子邮箱不能为空'}}},
  16. }
  17. };
  18. /**
  19. * 清除数据
  20. */
  21. TalentBasicChangeInfoDlg.clearData = function () {
  22. this.talentBasicChangeInfoData = {};
  23. }
  24. /**
  25. * 设置对话框中的数据
  26. *
  27. * @param key 数据的名称
  28. * @param val 数据的具体值
  29. */
  30. TalentBasicChangeInfoDlg.set = function (key, val) {
  31. this.talentBasicChangeInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  32. return this;
  33. }
  34. /**
  35. * 设置对话框中的数据
  36. *
  37. * @param key 数据的名称
  38. * @param val 数据的具体值
  39. */
  40. TalentBasicChangeInfoDlg.get = function (key) {
  41. return $("#" + key).val();
  42. }
  43. /**
  44. * 关闭此对话框
  45. */
  46. TalentBasicChangeInfoDlg.close = function () {
  47. parent.layer.close(window.parent.TalentBasicChange.layerIndex);
  48. }
  49. /**
  50. * 验证数据
  51. */
  52. TalentBasicChangeInfoDlg.validate = function () {
  53. $('#basicChangeForm').data("bootstrapValidator").resetForm();
  54. $('#basicChangeForm').bootstrapValidator('validate');
  55. return $("#basicChangeForm").data('bootstrapValidator').isValid();
  56. }
  57. /**
  58. * 收集数据
  59. */
  60. TalentBasicChangeInfoDlg.collectData = function () {
  61. this
  62. .set('id')
  63. .set('type')
  64. .set('enterpriseId')
  65. .set('talentId')
  66. .set('newName')
  67. .set('newBirthday')
  68. .set('newNationality')
  69. .set('newNation')
  70. .set('newPolitics')
  71. .set('newCardType')
  72. .set('newIdCard')
  73. .set('newEmail');
  74. }
  75. TalentBasicChangeInfoDlg.nameChange = function () {
  76. var talentId = $("#talentId").val();
  77. if (Feng.isNotEmptyStr(talentId)) {
  78. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent/getTalentBasicById/id/" + talentId, function (data) {
  79. var talentInfo = data;
  80. $("#oldBirthday").val(talentInfo.birthday);
  81. $("#oldNationality").val(talentInfo.nationality);
  82. $("#oldNation").val(talentInfo.nation);
  83. $("#oldPolitics").val(talentInfo.politics);
  84. $("#oldCardType").val(talentInfo.card_type);
  85. $("#oldIdCard").val(talentInfo.card_number);
  86. $("#oldEmail").val(talentInfo.email);
  87. $("#newName").val(talentInfo.name);
  88. $("#newBirthday").val(talentInfo.birthday);
  89. $("#newNationality").val(talentInfo.nationality);
  90. $("#newNation").val(talentInfo.nation);
  91. $("#newPolitics").val(talentInfo.politics);
  92. $("#newCardType").val(talentInfo.card_type);
  93. $("#newIdCard").val(talentInfo.card_number);
  94. $("#newEmail").val(talentInfo.email);
  95. }, function (data) {
  96. Feng.error("查询失败!" + data.responseJSON.message + "!");
  97. });
  98. ajax.start();
  99. }
  100. }
  101. /**
  102. * 提交添加
  103. */
  104. TalentBasicChangeInfoDlg.addSubmit = function () {
  105. this.clearData();
  106. this.collectData();
  107. if (!TalentBasicChangeInfoDlg.validate()) {
  108. return;
  109. }
  110. var id = $('#id').val();
  111. if (Feng.isNotEmptyStr(id)) {
  112. TalentBasicChangeInfoDlg.editSubmit();
  113. return;
  114. }
  115. //提交信息
  116. var ajax = new $ax(Feng.ctxPath + "/enterprise/talentBasicChange/apply", function (data) {
  117. if (data.code == 200) {
  118. Feng.success(data.msg);
  119. $("#id").val(data.obj.id);
  120. $("#talentId").prop("disabled", true).trigger("chosen:updated");
  121. $("#fileLi").removeAttr("style");
  122. $("#checkState").val(data.obj.checkState);
  123. } else {
  124. Feng.info(data.msg);
  125. }
  126. }, function (data) {
  127. Feng.error("添加失败!" + data.responseJSON.message + "!");
  128. });
  129. ajax.set(this.talentBasicChangeInfoData);
  130. ajax.start();
  131. }
  132. /**
  133. * 提交修改
  134. */
  135. TalentBasicChangeInfoDlg.editSubmit = function () {
  136. if (!validateIsEdit())
  137. return;
  138. //提交信息
  139. var ajax = new $ax(Feng.ctxPath + "/enterprise/talentBasicChange/apply", function (data) {
  140. if (data.code == 200) {
  141. Feng.success(data.msg);
  142. } else {
  143. Feng.info(data.msg);
  144. }
  145. }, function (data) {
  146. Feng.error("修改失败!" + data.responseJSON.message + "!");
  147. });
  148. ajax.set(this.talentBasicChangeInfoData);
  149. ajax.start();
  150. }
  151. function validateIsEdit() {
  152. var id = $("#id").val();
  153. if (id == null || id == '') {
  154. Feng.info("请先添加基本信息并保存后再试");
  155. return false;
  156. }
  157. var checkState = $("#checkState").val();
  158. if (checkState != -1 && checkState != 2) {
  159. Feng.error("您的申报正在审核中或已审核通过,无法修改");
  160. return false;
  161. }
  162. return true;
  163. }
  164. /**
  165. * 校验是否显示按钮
  166. * @param type 类型 1-上传按钮,2-修改删除按钮
  167. * @param row
  168. * @returns {string}
  169. */
  170. function validUploadButton(type, row, fileId) {
  171. var checkState = $("#checkState").val();
  172. if (Feng.isEmptyStr(checkState) || checkState == -1 || checkState == 2) {
  173. if (type == 1) { //上传
  174. return "<button type='button' onclick=\"checkFile(this,'" + row.id + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  175. "<i class=\"fa fa-upload\"></i>上传" +
  176. "</button>";
  177. } else {
  178. return "<button type=\'button\' onclick=\"checkFile(this,'" + row.id + "','" + fileId + "')\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\">" +
  179. "<i class=\"fa fa-paste\"></i>修改" +
  180. "</button>" +
  181. "<button type='button' onclick=\"deleteFile('" + fileId + "','" + CONFIG.project_basicchange + "')\" class=\"btn btn-xs btn-danger\">" +
  182. "<i class=\"fa fa-times\"></i>删除" +
  183. "</button>";
  184. }
  185. } else {
  186. return type == 1 ? "" : "";
  187. }
  188. }
  189. /**
  190. * 提交审核
  191. */
  192. TalentBasicChangeInfoDlg.submitToCheck = function () {
  193. var id = $("#id").val();
  194. if (Feng.isEmptyStr(id)) {
  195. Feng.info("请先填写基础信息");
  196. return;
  197. }
  198. var checkState = $("#checkState").val();
  199. if (checkState == 1 || checkState == 9) {
  200. Feng.error("正在审核中,无法修改");
  201. return;
  202. }
  203. if (checkState == 3) {
  204. Feng.error("审核通过,无法修改");
  205. return;
  206. }
  207. var operation = function () {
  208. var ajax = new $ax(Feng.ctxPath + "/enterprise/talentBasicChange/submitToCheck", function (data) {
  209. if (data.code == 200) {
  210. Feng.success(data.msg);
  211. // $("#checkState").val(data.obj);
  212. window.parent.TalentBasicChange.table.refresh();
  213. TalentBasicChangeInfoDlg.close();
  214. } else {
  215. Feng.error(data.msg);
  216. }
  217. }, function (data) {
  218. Feng.error("提交审核失败!" + data.responseJSON.message + "!");
  219. });
  220. ajax.set("id", id);
  221. ajax.start();
  222. }
  223. Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  224. }
  225. $(function () {
  226. Feng.initValidatorTip("basicChangeForm", TalentBasicChangeInfoDlg.validateFields);
  227. var hand = $("#hand").val();
  228. var id = $("#id").val();
  229. var checkState = $("#checkState").val();
  230. //批量加载字典表数据
  231. var arr = [
  232. {"name": "oldNationality", "code": "nationality"},
  233. {"name": "oldNation", "code": "nation"},
  234. {"name": "oldPolitics", "code": "politics"},
  235. {"name": "oldCardType", "code": "card_type"},
  236. {"name": "newNationality", "code": "nationality"},
  237. {"name": "newNation", "code": "nation"},
  238. {"name": "newPolitics", "code": "politics"},
  239. {"name": "newCardType", "code": "card_type"}
  240. ];
  241. Feng.findChildDictBatch(JSON.stringify(arr));
  242. if (Feng.isNotEmptyStr(id)) {
  243. //select初始化
  244. $("select").each(function () {
  245. $(this).val($(this).attr("value")).trigger("change");
  246. });
  247. $("#fileLi").removeAttr("style");
  248. Feng.getCheckLog("logTable", {"type": CONFIG.project_basicchange, "mainId": id, "typeFileId": "", "active": 1})
  249. } else {
  250. $("#fileLi").attr("style", "pointer-events: none");
  251. $("#talentId").on('chosen:ready', function (e, params) {
  252. $(".chosen-container-single .chosen-single").css("padding", "4px 0px 0px 8px");
  253. });
  254. $("#talentId").chosen({
  255. search_contains: true,    //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
  256. disable_search: false,
  257. width: "100%",
  258. enable_split_word_search: true,
  259. rtl: true
  260. });
  261. }
  262. });