talentQuit_info.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. /**
  2. * 初始化离职管理详情对话框
  3. */
  4. var locked = false;
  5. var TalentQuitInfoDlg = {
  6. talentQuitInfoData: {},
  7. validateFields: {
  8. talentId: {validators: {notEmpty: {message: '离职对象不能为空'}}},
  9. starttime: {validators: {notEmpty: {message: '合同开始时间不能为空'}}},
  10. endtime: {validators: {notEmpty: {message: '合同结束时间不能为空'}}},
  11. quitTime: {validators: {notEmpty: {message: '离职时间不能为空'}}},
  12. phone: {
  13. validators: {
  14. notEmpty: {
  15. message: '手机号码不能为空'
  16. },
  17. regexp: {
  18. regexp: /0?(13|14|15|17|18|19)[0-9]{9}/,
  19. message: "手机号码格式不正确"
  20. }
  21. }
  22. }
  23. }
  24. };
  25. /**
  26. * 清除数据
  27. */
  28. TalentQuitInfoDlg.clearData = function () {
  29. this.talentQuitInfoData = {};
  30. }
  31. /**
  32. * 设置对话框中的数据
  33. *
  34. * @param key 数据的名称
  35. * @param val 数据的具体值
  36. */
  37. TalentQuitInfoDlg.set = function (key, val) {
  38. this.talentQuitInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  39. return this;
  40. }
  41. /**
  42. * 设置对话框中的数据
  43. *
  44. * @param key 数据的名称
  45. * @param val 数据的具体值
  46. */
  47. TalentQuitInfoDlg.get = function (key) {
  48. return $("#" + key).val();
  49. }
  50. /**
  51. * 关闭此对话框
  52. */
  53. TalentQuitInfoDlg.close = function () {
  54. parent.layer.close(window.parent.TalentQuit.layerIndex);
  55. }
  56. /**
  57. * 收集数据
  58. */
  59. TalentQuitInfoDlg.collectData = function () {
  60. this
  61. .set('id')
  62. .set('type')
  63. .set('year')
  64. .set('talentId')
  65. .set('talentName')
  66. .set('enterpriseId')
  67. .set('enterpriseName')
  68. .set('idCard')
  69. .set('talentArrange')
  70. .set('identifyTime')
  71. .set('starttime')
  72. .set('endtime')
  73. .set('phone')
  74. .set('entryTime')
  75. .set('quitReason')
  76. .set('quitTime')
  77. .set('description');
  78. }
  79. /**
  80. * 验证数据
  81. */
  82. TalentQuitInfoDlg.validate = function () {
  83. $('#talentQuitForm').data("bootstrapValidator").resetForm();
  84. $('#talentQuitForm').bootstrapValidator('validate');
  85. return $("#talentQuitForm").data('bootstrapValidator').isValid();
  86. }
  87. /**
  88. * 提交添加
  89. */
  90. TalentQuitInfoDlg.addSubmit = function () {
  91. this.clearData();
  92. this.collectData();
  93. if (!this.validate()) {
  94. return;
  95. }
  96. //提交信息
  97. if (locked)
  98. return;
  99. locked = true;
  100. if (this.talentQuitInfoData.id != null && this.talentQuitInfoData.id != '') {
  101. //提交信息
  102. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent_quit/apply", function (data) {
  103. if (data.code == "200") {
  104. Feng.success(data.msg);
  105. window.parent.TalentQuit.table.refresh();
  106. } else {
  107. Feng.info(data.msg);
  108. }
  109. locked = false;
  110. }, function (data) {
  111. Feng.error("修改失败!" + data.responseJSON.message + "!");
  112. locked = false;
  113. });
  114. ajax.set(this.talentQuitInfoData);
  115. ajax.start();
  116. } else {
  117. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent_quit/apply", function (data) {
  118. if (data.code == "200") {
  119. Feng.success(data.msg);
  120. $("#fileLi").removeAttr("style");
  121. $("#id").val(data.obj.id);
  122. $("#checkState").val(data.obj.checkState);
  123. window.parent.TalentQuit.table.refresh();
  124. } else {
  125. Feng.info(data.msg);
  126. }
  127. locked = false;
  128. }, function (data) {
  129. Feng.error("添加失败!" + data.responseJSON.message + "!");
  130. locked = false;
  131. });
  132. ajax.set(this.talentQuitInfoData);
  133. ajax.start();
  134. }
  135. }
  136. /**
  137. * 提交修改
  138. */
  139. TalentQuitInfoDlg.editSubmit = function (type) {
  140. this.clearData();
  141. this.collectData();
  142. // if(!this.validate()){
  143. // return;
  144. // }
  145. //提交信息
  146. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent_quit/apply", function (data) {
  147. if (data.code == "200") {
  148. if (type == 1) {
  149. Feng.success(data.msg);
  150. window.parent.TalentQuit.table.refresh();
  151. } else {
  152. TalentQuitInfoDlg.submitToCheck();
  153. }
  154. } else {
  155. Feng.info(data.msg);
  156. }
  157. locked = false;
  158. }, function (data) {
  159. Feng.error("修改失败!" + data.responseJSON.message + "!");
  160. locked = false;
  161. });
  162. ajax.set(this.talentQuitInfoData);
  163. ajax.start();
  164. }
  165. //点击按钮初始化
  166. TalentQuitInfoDlg.talentInfoDetail = function () {
  167. var talentId = $("#talentId").val();
  168. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent/getInfoById/id/" + talentId, function (data) {
  169. $("#type").val(data.type);
  170. $("#enterpriseId").val(data.enterprise_id);
  171. $("#talentName").val(data.name);
  172. $("#idCard").val(data.card_number);
  173. $("#identifyTime").val(data.identifyMonth);
  174. $("#enterpriseName").val(data.enterpriseName);
  175. $("#talentArrange").val(data.talent_arrange);
  176. $("#talentTypeName").val(data.talentTypeName);
  177. $("#starttime").val(data.startTime);
  178. $("#endtime").val(data.endTime);
  179. $("#entryTime").val(data.entryTime);
  180. $("#phone").val(data.phone);
  181. }, function (data) {
  182. Feng.error("查询失败!" + data.responseJSON.message + "!");
  183. });
  184. ajax.set();
  185. ajax.start();
  186. }
  187. //附件初始化
  188. TalentQuitInfoDlg.initFileTable = function () {
  189. var queryData = {};
  190. queryData['project'] = CONFIG.project_quit;
  191. queryData['type'] = $("#type").val();
  192. $("#fileTable").bootstrapTable({
  193. url: Feng.ctxPath + "/common/api/findUnCommonFileType",
  194. method: 'POST',
  195. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  196. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  197. showRefresh: false, // 是否显示刷新按钮
  198. clickToSelect: true, // 是否启用点击选中行
  199. singleSelect: true, // 设置True 将禁止多选
  200. striped: true, // 是否显示行间隔色
  201. escape: true,
  202. pagination: false, // 设置为 true 会在表格底部显示分页条
  203. paginationHAlign: "left",
  204. paginationDetailHAlign: "right",
  205. sidePagination: "server", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  206. showColumns: false,
  207. detailView: true, //是否显示父子表
  208. pageList: [10, 30, 50],
  209. queryParams: function (params) {
  210. return $.extend(queryData, params)
  211. },
  212. rowStyle: function (row, index) {
  213. return {classes: "info"};
  214. },
  215. columns:
  216. [
  217. {field: 'selectItem', checkbox: false, visible: false},
  218. {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle', width: "40%", 'class': 'uitd_showTip',
  219. formatter: function (value, row, index) {
  220. if (row.must == 1) {
  221. return '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
  222. }
  223. if (row.must == 2) {
  224. return '<i class="fa fa-paste"></i>' + value;
  225. }
  226. }
  227. },
  228. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "10%",
  229. formatter: function (value, row, index) {
  230. if (value == null || value == '' || value == 'null') {
  231. return '无';
  232. }
  233. return "<button type='button' onclick=\"TalentQuitInfoDlg.downloadFile('" + row.id + "',3)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  234. "<i class=\"fa fa-download\"></i>下载" +
  235. "</button>";
  236. }
  237. },
  238. {title: "说明", field: 'description', visible: true, align: 'center', valign: 'middle', width: "40%", },
  239. {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%",
  240. formatter: function (value, row, index) {
  241. return "<button type='button' onclick=\"TalentQuitInfoDlg.checkFile('" + value + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  242. "<i class=\"fa fa-upload\"></i>上传" +
  243. "</button>";
  244. }
  245. }
  246. ]
  247. ,
  248. onPostBody: function () {
  249. $("td.uitd_showTip").bind("mouseover", function () {
  250. var htm = $(this).html();
  251. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  252. });
  253. },
  254. onLoadSuccess: function (data) {
  255. $("#fileTable").bootstrapTable('expandAllRows');
  256. },
  257. onExpandRow: function (index, row, $detail) {
  258. var ajax = new $ax(Feng.ctxPath + "/common/api/listTalentCommonFile", function (data) {
  259. if (data == null || data.length == 0) {
  260. return;
  261. }
  262. var html = '<ul class="imgs"><li style="width: 80%;font-weight: bold;padding-top: 5px;">附件原名</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">预览</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">操作</li>';
  263. for (var key in data) {
  264. var sn = data[key].url.lastIndexOf(".");
  265. var suffix = data[key].url.substring(sn + 1, data[key].url.length);
  266. var imgStr = "";
  267. if (suffix == "pdf" || suffix == "PDF") {
  268. imgStr = "<button type='button' onclick=\"Feng.showPdf('" + data[key].url + "','" + data[key].id + "','" + data[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-pdf-o\" aria-hidden=\"true\"></i></button>";
  269. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS') {
  270. imgStr = "<button type='button' onclick=\"Feng.showExcel('" + data[key].url + "','" + data[key].id + "','" + data[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-excel-o\" aria-hidden=\"true\"></i></button>";
  271. } else {
  272. imgStr = '<img class=\"imgUrl\" src=\"' + data[key].url + '\" style=\"width:25px;height:25px;\">';
  273. }
  274. var btn = "<button type=\'button\' onclick=\"TalentQuitInfoDlg.checkFile('" + row.id + "','" + data[key].id + "')\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\"><i class=\"fa fa-paste\"></i>修改</button>" +
  275. "<button type='button' onclick=\"TalentQuitInfoDlg.deleteFile('" + data[key].id + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-times\"></i>删除</button>";
  276. html = html + '<li style="display: none">' + data[key].id + '</li>\n' +
  277. '<li style="width: 80%;padding-top: 5px;">' + data[key].orignName + '</li>\n' +
  278. '<li style="width: 10%;">' + imgStr + '</li>\n' +
  279. '<li style="width: 10%;padding-top: 2px;">' + btn + '</li>';
  280. }
  281. html = html + '</ul>';
  282. $detail.html(html);
  283. $(".imgs").viewer({
  284. // toolbar:false,
  285. fullscreen: false
  286. });
  287. }, function (data) {
  288. Feng.error("查询失败!" + data.responseJSON.message + "!");
  289. });
  290. var queryData = {};
  291. queryData["mainId"] = $("#id").val();
  292. queryData["typeId"] = row.id;
  293. ajax.set(queryData);
  294. ajax.start();
  295. }
  296. });
  297. }
  298. TalentQuitInfoDlg.downloadFile = function (id, type) {
  299. window.location.href = Feng.ctxPath + "/common/api/downloadFile?id=" + id + "&type=" + type;
  300. }
  301. //选择附件并显示附件名
  302. TalentQuitInfoDlg.checkFile = function (fileTypeId, fileId) {
  303. var checkState = $("#checkState").val();
  304. if (checkState == 1) {
  305. Feng.error("正在审核中,无法修改");
  306. return;
  307. }
  308. if (checkState == 3) {
  309. Feng.error("审核通过,无法修改");
  310. return;
  311. }
  312. $("#upload_file ").unbind("change");
  313. $("#upload_file ").change(function () {
  314. TalentQuitInfoDlg.upload(fileTypeId, fileId);
  315. });
  316. $('#upload_file').val("");
  317. $('#upload_file').click()
  318. }
  319. //上传附件
  320. TalentQuitInfoDlg.upload = function (fileTypeId, fileId) {
  321. if (fileId != null && fileId != 'null') {
  322. $("#fileId").val(fileId)
  323. } else {
  324. $("#fileId").val("");
  325. }
  326. $("#mainId").val($("#id").val());
  327. $("#typeId").val(fileTypeId);
  328. var index = layer.load(0, {shade: false, time: 0});
  329. $("#index").val(index);
  330. $("#uploadForm").submit();
  331. }
  332. //删除附件
  333. TalentQuitInfoDlg.deleteFile = function (id) {
  334. var checkState = $("#checkState").val();
  335. if (checkState == 1) {
  336. Feng.error("正在审核中,无法修改");
  337. return;
  338. }
  339. if (checkState == 3) {
  340. Feng.error("审核通过,无法修改");
  341. return;
  342. }
  343. var operation = function () {
  344. var ajax = new $ax(Feng.ctxPath + "/common/api/deleteTalentCommonFile", function (data) {
  345. if (data.code = 200) {
  346. Feng.success(data.msg);
  347. $("#fileTable").bootstrapTable("refresh", {});
  348. } else {
  349. Feng.error(data.msg);
  350. }
  351. }, function (data) {
  352. Feng.error("删除失败!" + data.responseJSON.message + "!");
  353. });
  354. ajax.set("id", id);
  355. ajax.start();
  356. }
  357. Feng.confirm("删除后无法恢复,确认删除吗?", operation);
  358. }
  359. //回调
  360. TalentQuitInfoDlg.callBack = function (data) {
  361. layer.close(data.obj);
  362. Feng.info(data.msg);
  363. if (data.code == 200) {
  364. $("#fileTable").bootstrapTable("refresh", {});
  365. }
  366. }
  367. /**
  368. * 提交审核
  369. */
  370. TalentQuitInfoDlg.submitToCheck = function () {
  371. var id = $("#id").val();
  372. if (id == null || id == "") {
  373. Feng.info("请先填写基础信息并上传附件");
  374. return;
  375. }
  376. var checkState = $("#checkState").val();
  377. if (checkState == 1) {
  378. Feng.error("正在审核中,无法修改");
  379. return;
  380. }
  381. if (checkState == 3) {
  382. Feng.error("审核通过,无法修改");
  383. return;
  384. }
  385. var operation = function () {
  386. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent_quit/submitToCheck", function (data) {
  387. if (data.code == 200) {
  388. Feng.success(data.msg);
  389. // $("#checkState").val(data.obj);
  390. window.parent.TalentQuit.table.refresh();
  391. TalentQuitInfoDlg.close();
  392. } else {
  393. Feng.error(data.msg);
  394. }
  395. }, function (data) {
  396. Feng.error("提交审核失败!" + data.responseJSON.message + "!");
  397. });
  398. ajax.set("id", id);
  399. ajax.start();
  400. }
  401. Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  402. }
  403. $(function () {
  404. Feng.initValidator("talentQuitForm", TalentQuitInfoDlg.validateFields);
  405. Feng.addAjaxSelect({
  406. "id": 'talentArrange',
  407. "displayCode": "code",
  408. "displayName": "name",
  409. "type": "GET",
  410. "url": Feng.ctxPath + "/common/tool/findChildDictByCode?code=talent_arrange"
  411. });
  412. var id = $("#id").val();
  413. var url = "";
  414. if (id == null || id == '') {
  415. url = "/enterprise/talent/findTalentInfoInLibrary/type/" + CONFIG.project_quit;
  416. } else {
  417. url = "/enterprise/talent/findTalentInfoByChangeId/type/" + CONFIG.project_quit + "/id/" + id;
  418. Feng.getCheckLog("logTable", {"type": CONFIG.project_quit, "mainId": id, "typeFileId": "", "active": 1});
  419. }
  420. Feng.addAjaxSelect({
  421. "id": 'talentId',
  422. "displayCode": "id",
  423. "displayName": "name",
  424. "type": "GET",
  425. "url": Feng.ctxPath + url
  426. });
  427. //批量加载时间控件
  428. $(".time").each(function () {
  429. laydate.render({
  430. elem: "#" + $(this).attr("id")
  431. , type: "date"
  432. , trigger: 'click'
  433. });
  434. });
  435. $("select").each(function () {
  436. $(this).val($(this).attr("value"));
  437. });
  438. if (id != null && id != '') {
  439. $("#fileLi").removeAttr("style");
  440. } else {
  441. $("#fileLi").attr("style", "pointer-events: none");
  442. $("#talentId").on('chosen:ready', function (e, params) {
  443. $(".chosen-container-single .chosen-single").css("padding", "4px 0px 0px 10px");
  444. });
  445. $("#talentId").chosen({
  446. search_contains: true,    //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
  447. disable_search: false,
  448. width: "100%",
  449. enable_split_word_search: true
  450. });
  451. }
  452. });