talentQuit_select.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /**
  2. * 初始化离职管理详情对话框
  3. */
  4. var TalentQuitInfoDlg = {
  5. talentQuitInfoData: {},
  6. validateFields: {
  7. talentId: {validators: {notEmpty: {message: '离职对象不能为空'}}},
  8. starttime: {validators: {notEmpty: {message: '合同开始时间不能为空'}}},
  9. endtime: {validators: {notEmpty: {message: '合同结束时间不能为空'}}},
  10. quitTime: {validators: {notEmpty: {message: '离职时间不能为空'}}},
  11. phone: {
  12. validators: {
  13. notEmpty: {
  14. message: '手机号码不能为空'
  15. },
  16. regexp: {
  17. regexp: /0?(13|14|15|17|18|19)[0-9]{9}/,
  18. message: "手机号码格式不正确"
  19. }
  20. }
  21. }
  22. }
  23. };
  24. /**
  25. * 清除数据
  26. */
  27. TalentQuitInfoDlg.clearData = function () {
  28. this.talentQuitInfoData = {};
  29. }
  30. /**
  31. * 设置对话框中的数据
  32. *
  33. * @param key 数据的名称
  34. * @param val 数据的具体值
  35. */
  36. TalentQuitInfoDlg.set = function (key, val) {
  37. this.talentQuitInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  38. return this;
  39. }
  40. /**
  41. * 设置对话框中的数据
  42. *
  43. * @param key 数据的名称
  44. * @param val 数据的具体值
  45. */
  46. TalentQuitInfoDlg.get = function (key) {
  47. return $("#" + key).val();
  48. }
  49. /**
  50. * 关闭此对话框
  51. */
  52. TalentQuitInfoDlg.close = function () {
  53. parent.layer.close(window.parent.TalentQuit.layerIndex);
  54. }
  55. /**
  56. * 收集数据
  57. */
  58. TalentQuitInfoDlg.collectData = function () {
  59. this
  60. .set('id')
  61. .set('talentId')
  62. .set('talentName')
  63. .set('enterpriseId')
  64. .set('enterpriseName')
  65. .set('idCard')
  66. .set('talentArrange')
  67. .set('identifyTime')
  68. .set('starttime')
  69. .set('endtime')
  70. .set('phone')
  71. .set('quitTime')
  72. .set('description');
  73. }
  74. /**
  75. * 验证数据
  76. */
  77. TalentQuitInfoDlg.validate = function () {
  78. $('#talentQuitForm').data("bootstrapValidator").resetForm();
  79. $('#talentQuitForm').bootstrapValidator('validate');
  80. return $("#talentQuitForm").data('bootstrapValidator').isValid();
  81. }
  82. /**
  83. * 提交添加
  84. */
  85. TalentQuitInfoDlg.addSubmit = function () {
  86. this.clearData();
  87. this.collectData();
  88. if (!this.validate()) {
  89. return;
  90. }
  91. var id = $("#id").val();
  92. //提交信息
  93. if (this.talentQuitInfoData.id != null && this.talentQuitInfoData.id != '') {
  94. //提交信息
  95. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent_quit/apply", function (data) {
  96. if (data.code == "200") {
  97. Feng.success(data.msg);
  98. window.parent.TalentQuit.table.refresh();
  99. TalentQuitInfoDlg.close();
  100. } else {
  101. Feng.info(data.msg);
  102. }
  103. }, function (data) {
  104. Feng.error("修改失败!" + data.responseJSON.message + "!");
  105. });
  106. ajax.set(this.talentQuitInfoData);
  107. ajax.start();
  108. } else {
  109. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent_quit/apply", function (data) {
  110. if (data.code == "200") {
  111. Feng.success(data.msg);
  112. $("#fileLi").removeAttr("style");
  113. $("#id").val(data.obj.id);
  114. $("#checkState").val(data.obj.checkState);
  115. window.parent.TalentQuit.table.refresh();
  116. } else {
  117. Feng.info(data.msg);
  118. }
  119. }, function (data) {
  120. Feng.error("添加失败!" + data.responseJSON.message + "!");
  121. });
  122. ajax.set(this.talentQuitInfoData);
  123. ajax.start();
  124. }
  125. }
  126. /**
  127. * 提交修改
  128. */
  129. TalentQuitInfoDlg.editSubmit = function () {
  130. this.clearData();
  131. this.collectData();
  132. if (!this.validate()) {
  133. return;
  134. }
  135. //提交信息
  136. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent_quit/apply", function (data) {
  137. if (data.code == "200") {
  138. Feng.success(data.msg);
  139. window.parent.TalentQuit.table.refresh();
  140. TalentQuitInfoDlg.close();
  141. } else {
  142. Feng.info(data.msg);
  143. }
  144. }, function (data) {
  145. Feng.error("修改失败!" + data.responseJSON.message + "!");
  146. });
  147. ajax.set(this.talentQuitInfoData);
  148. ajax.start();
  149. }
  150. //点击按钮初始化
  151. TalentQuitInfoDlg.talentInfoDetail = function () {
  152. var talentId = $("#talentId").val();
  153. var ajax = new $ax(Feng.ctxPath + "/enterprise/talent/detail/id/" + talentId, function (data) {
  154. $("#enterpriseId").val(data.enterpriseId);
  155. $("#talentName").val(data.name);
  156. $("#idCard").val(data.idCard);
  157. $("#identifyTime").val(data.identifyGetTime);
  158. $("#enterpriseName").val(data.enterpriseName);
  159. $("#talentArrange").val(data.talentArrange);
  160. }, function (data) {
  161. Feng.error("查询失败!" + data.responseJSON.message + "!");
  162. });
  163. ajax.set();
  164. ajax.start();
  165. }
  166. //附件初始化
  167. TalentQuitInfoDlg.initFileTable = function () {
  168. var queryData = {};
  169. queryData['project'] = CONFIG.project_quit;
  170. queryData['type'] = $("#type").val();
  171. $("#fileTable").bootstrapTable({
  172. url: Feng.ctxPath + "/common/api/findUnCommonFileType",
  173. method: 'POST',
  174. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  175. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  176. showRefresh: false, // 是否显示刷新按钮
  177. clickToSelect: true, // 是否启用点击选中行
  178. singleSelect: true, // 设置True 将禁止多选
  179. striped: true, // 是否显示行间隔色
  180. escape: true,
  181. pagination: false, // 设置为 true 会在表格底部显示分页条
  182. paginationHAlign: "left",
  183. paginationDetailHAlign: "right",
  184. sidePagination: "server", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  185. showColumns: false,
  186. detailView: true, //是否显示父子表
  187. pageList: [10, 30, 50],
  188. queryParams: function (params) {
  189. return $.extend(queryData, params)
  190. },
  191. rowStyle: function (row, index) {
  192. return {classes: "info"};
  193. },
  194. columns:
  195. [
  196. {field: 'selectItem', checkbox: false, visible: false},
  197. {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle', width: "30%", 'class': 'uitd_showTip',
  198. formatter: function (value, row, index) {
  199. if (row.must == 1) {
  200. return '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
  201. }
  202. if (row.must == 2) {
  203. return '<i class="fa fa-paste"></i>' + value;
  204. }
  205. }
  206. },
  207. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "8%",
  208. formatter: function (value, row, index) {
  209. if (value == null || value == '' || value == 'null') {
  210. return '无';
  211. }
  212. return "<button type='button' onclick=\"TalentQuitInfoDlg.downloadFile('" + row.id + "',3)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  213. "<i class=\"fa fa-download\"></i>下载" +
  214. "</button>";
  215. }
  216. },
  217. ]
  218. ,
  219. onPostBody: function () {
  220. $("td.uitd_showTip").bind("mouseover", function () {
  221. var htm = $(this).html();
  222. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  223. });
  224. },
  225. onLoadSuccess: function (data) {
  226. $("#fileTable").bootstrapTable('expandAllRows');
  227. },
  228. onExpandRow: function (index, row, $detail) {
  229. var ajax = new $ax(Feng.ctxPath + "/common/api/listTalentCommonFile", function (data) {
  230. if (data == null || data.length == 0) {
  231. return;
  232. }
  233. var html = '<ul class="imgs"><li style="width: 80%;font-weight: bold;padding-top: 5px;">附件原名</li><li style="width: 20%;font-weight: bold;padding-top: 5px;">预览</li>';
  234. for (var key in data) {
  235. var sn = data[key].url.lastIndexOf(".");
  236. var suffix = data[key].url.substring(sn + 1, data[key].url.length);
  237. var imgStr = "";
  238. if (suffix == "pdf" || suffix == "PDF") {
  239. 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>";
  240. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS') {
  241. 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>";
  242. } else {
  243. imgStr = '<img class=\"imgUrl\" src=\"' + data[key].url + '\" style=\"width:25px;height:25px;\">';
  244. }
  245. html = html + '<li style="display: none">' + data[key].id + '</li>\n' +
  246. '<li style="width: 80%;padding-top: 5px;">' + data[key].orignName + '</li>\n' +
  247. '<li style="width: 20%;">' + imgStr + '</li>\n';
  248. }
  249. html = html + '</ul>';
  250. $detail.html(html);
  251. $(".imgs").viewer();
  252. }, function (data) {
  253. Feng.error("查询失败!" + data.responseJSON.message + "!");
  254. });
  255. var queryData = {};
  256. queryData["mainId"] = $("#id").val();
  257. queryData["typeId"] = row.id;
  258. ajax.set(queryData);
  259. ajax.start();
  260. }
  261. });
  262. }
  263. TalentQuitInfoDlg.downloadFile = function (id, type) {
  264. window.location.href = Feng.ctxPath + "/common/api/downloadFile?id=" + id + "&type=" + type;
  265. }
  266. $(function () {
  267. Feng.initValidator("talentQuitForm", TalentQuitInfoDlg.validateFields);
  268. Feng.addAjaxSelect({
  269. "id": 'talentArrange',
  270. "displayCode": "code",
  271. "displayName": "name",
  272. "type": "GET",
  273. "url": Feng.ctxPath + "/common/tool/findChildDictByCode?code=talent_arrange"
  274. });
  275. var id = $("#id").val();
  276. var url = Feng.isEmptyStr(id) ? "/enterprise/talent/findTalentInfoInLibrary/type/" + CONFIG.project_quit : "/enterprise/talent/findTalentInfoByChangeId/type/" + CONFIG.project_quit + "/id/" + id;
  277. Feng.addAjaxSelect({
  278. "id": 'talentId',
  279. "displayCode": "id",
  280. "displayName": "name",
  281. "type": "GET",
  282. "url": Feng.ctxPath + url
  283. });
  284. $("select").each(function () {
  285. $(this).val($(this).attr("value"));
  286. });
  287. if (id != null && id != '') {
  288. $("#fileLi").removeAttr("style");
  289. } else {
  290. $("#fileLi").attr("style", "pointer-events: none");
  291. }
  292. });