talentInfo_select.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /**
  2. * 初始化人才认定申报详情对话框
  3. */
  4. var TalentInfoInfoDlg = {
  5. talentInfoInfoData: {},
  6. };
  7. /**
  8. * 初始化表格的列
  9. */
  10. TalentInfoInfoDlg.initFileTypeColumn = function () {
  11. return [
  12. {field: 'selectItem', checkbox: false, visible: false},
  13. {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle', width: "30%", 'class': 'uitd_showTip',
  14. formatter: function (value, row, index) {
  15. let highlights_by_api = ["crz"];
  16. if (highlights_by_api.indexOf(row.api) > -1) {
  17. value = '<span style="font-weight:bold;color:red;">' + value + '</span>';
  18. }
  19. if (row.must == 1) {
  20. return '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
  21. }
  22. if (row.must == 2) {
  23. return '<i class="fa fa-paste"></i>' + value;
  24. }
  25. }
  26. },
  27. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "8%",
  28. formatter: function (value, row, index) {
  29. if (value == null || value == '' || value == 'null') {
  30. return '无';
  31. }
  32. return "<button type='button' onclick=\"TalentInfoInfoDlg.downloadFile('" + row.id + "',5)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  33. "<i class=\"fa fa-download\"></i>下载" +
  34. "</button>";
  35. }
  36. },
  37. {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle', width: "52%", 'class': 'uitd_showTip'},
  38. {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%",
  39. formatter: function (value, row, index) {
  40. return "";
  41. }
  42. }
  43. ]
  44. };
  45. TalentInfoInfoDlg.initFileTable = function () {
  46. var ajax = new $ax("/common/api/findCommonFileType", function (data) {
  47. if (data == null || data.length == 0) {
  48. return;
  49. }
  50. var datas = new Array();
  51. for (var i = 0; i < $(".fileTable").length; i++) {
  52. datas.push([]);//创建空的多维数组,等下用来存每个附件表的各自的列
  53. }
  54. var enterpriseTag = $("#enterprise_tag").val();
  55. for (var k in data["rows"]) {
  56. if (data["rows"][k].enterprise_tag != "" && data["rows"][k].enterprise_tag != null && data["rows"][k].enterprise_tag.indexOf(enterpriseTag) == -1) {
  57. continue;
  58. }
  59. var rel = data["rows"][k].rel;
  60. if ($("#" + rel).length > 0) {
  61. var tableIndex = 0;
  62. if ($("#" + rel).parents(".table").length > 0) {
  63. tableIndex = $("#" + rel).parents(".table").find("table.fileTable").index(".fileTable");
  64. } else {
  65. tableIndex = $("#" + rel).parents(".row").next(".row").find("table.fileTable").index(".fileTable");
  66. }
  67. data["rows"][k].tableIndex = tableIndex;
  68. data["rows"][k].trIndex = datas[tableIndex].length;
  69. datas[tableIndex].push(data["rows"][k]);
  70. if (data["rows"][k].option) {
  71. //指定了选项
  72. if (rel == "birthday") {
  73. let birthday = parseInt($("#" + rel).val().substring(0, 4));
  74. let currentYear = parseInt(new Date().getFullYear());
  75. let age = currentYear - (isNaN(birthday) ? 0 : birthday);
  76. if (isNaN(birthday) || (!isNaN(birthday) && age < data["rows"][k].option))
  77. data["rows"][k].hidden = true;
  78. } else {
  79. let selectVal = $("#" + rel).data("value").toString();
  80. let options = data["rows"][k].option.split(",");
  81. if (options.indexOf(selectVal) == -1) {
  82. data["rows"][k].hidden = true;
  83. }
  84. }
  85. }
  86. } else {
  87. if (data["rows"][k].isConditionFile) {
  88. var isMatchZhiren = $("input[name=isMatchZhiren]").length > 0 ? parseInt($("input[name=isMatchZhiren]:checked").val()) : false;
  89. var isImport = parseInt($("#import").val());
  90. if (isImport == 1 && isMatchZhiren)
  91. continue;
  92. var tableIndex = 0;
  93. if ($("#talent_condition").parents(".table").length > 0) {
  94. tableIndex = $("#talent_condition").parents(".table").find("table.fileTable").index(".fileTable");
  95. } else {
  96. tableIndex = $("#talent_condition").parents(".row").next(".row").find("table.fileTable").index(".fileTable");
  97. }
  98. data["rows"][k].tableIndex = tableIndex;
  99. data["rows"][k].trIndex = datas[tableIndex].length;
  100. datas[tableIndex].push(data["rows"][k]);//放入人才条件后面的附件表
  101. } else {
  102. var tableIndex = $(".fileTable").length - 1;
  103. data["rows"][k].tableIndex = tableIndex;
  104. data["rows"][k].trIndex = datas[tableIndex].length;
  105. datas[$(".fileTable").length - 1].push(data["rows"][k]);//没有归属,放入最后一个附件表
  106. }
  107. }
  108. }
  109. for (var i = 0; i < $(".fileTable").length; i++) {
  110. var that = $(".fileTable").eq(i);
  111. that.bootstrapTable({
  112. columns: TalentInfoInfoDlg.initFileTypeColumn(),
  113. data: datas[i],
  114. showHeader: false,
  115. rowStyle: function (row, index) {
  116. return {classes: ""};
  117. },
  118. onPostBody: function (data) {
  119. for (var k in data) {
  120. var files = data[k].files;
  121. 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>';
  122. for (var key in files) {
  123. var sn = files[key].url.lastIndexOf(".");
  124. var suffix = files[key].ext;//files[key].url.substring(sn + 1, files[key].url.length);
  125. var imgStr = "";
  126. if (suffix == "pdf" || suffix == "PDF") {
  127. imgStr = "<button type='button' onclick=\"Feng.showPdf('" + files[key].url + "','" + files[key].id + "','" + files[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-pdf-o\" aria-hidden=\"true\"></i></button>";
  128. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS') {
  129. imgStr = "<button type='button' onclick=\"Feng.showExcel('" + files[key].url + "','" + files[key].id + "','" + files[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-excel-o\" aria-hidden=\"true\"></i></button>";
  130. } else {
  131. imgStr = '<img class=\"imgUrl\" onclick="Feng.showImg(this)" src=\"' + files[key].url + '\" style=\"width:25px;height:25px;\">';
  132. }
  133. html += '<li data-id="' + files[key].id + '">\n\
  134. <div><input type="hidden" name="uploadFiles[]" value="' + files[key].id + '"></div>\n' +
  135. '<div style="width: 80%;">' + files[key].orignName + '</div>\n' +
  136. '<div style="width: 10%;">' + imgStr + '</div>\n' +
  137. '<div style="width: 10%;"></div>\n\
  138. </li>';
  139. }
  140. html = html + '</ul>';
  141. that.find("tr[data-index='" + k + "']").attr("data-rel", data[k]["rel"]);
  142. that.find("tr[data-index='" + k + "']").attr("data-option", data[k]["option"]);
  143. that.find("tr[data-index='" + k + "']").after('<tr class="detail-view"><td colspan="5">' + html + '</td></tr>');
  144. if (typeof data[k].hidden != "undefined") {
  145. that.find("tr[data-index='" + k + "']").css("display", "none");
  146. that.find("tr[data-index='" + k + "']").next("tr.detail-view").css("display", "none");
  147. }
  148. }
  149. $("td.uitd_showTip").bind("mouseover", function () {
  150. var htm = $(this).html();
  151. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  152. });
  153. },
  154. });
  155. }
  156. }, function (data) {
  157. Feng.error("查询失败!" + data.responseJSON.message + "!");
  158. });
  159. var queryData = {};
  160. queryData["mainId"] = $("#id").val();
  161. queryData['project'] = CONFIG.project_rcrd;
  162. queryData['type'] = $("#type").val();
  163. queryData["source"] = $("#source").val();
  164. queryData["talent_condition"] = $("#talent_condition").val();
  165. queryData['checkState'] = $("#checkState").val();
  166. ajax.set(queryData);
  167. ajax.start();
  168. }
  169. TalentInfoInfoDlg.downloadFile = function (id, type) {
  170. window.location.href = Feng.ctxPath + "/common/api/downloadFile?id=" + id + "&type=" + type;
  171. }
  172. $(function () {
  173. $(":input").prop("disabled", true);
  174. $("#talent_type option").eq(0).prop("selected", true);
  175. var id = $("#id").val();
  176. var checkState = $("#checkState").val();
  177. TalentInfoInfoDlg.initFileTable();
  178. if (id != null && id != '') {
  179. //select初始化
  180. $("select").each(function () {
  181. $(this).val($(this).attr("value")).trigger("change");
  182. });
  183. Feng.getCheckLog("logTable", {"type": CONFIG.project_rcrd, "mainId": id, "typeFileId": "", "active": 1})
  184. }
  185. /*var source = $("#source").val();
  186. var columns = 3;
  187. if (source == 1 || source == 2) {
  188. columns = 3;
  189. } else if (source == 3 || source == 4) {
  190. columns = 4;
  191. }
  192. $("#source").parents("td").attr("colspan", columns);
  193. $("#talent_arrange").parents("td").attr("colspan", columns);
  194. $("#talent_condition").parents("td").attr("colspan", columns - 1);*/
  195. });