talentInfo_select.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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 age = 0;
  74. if ($("#" + rel).val()) {
  75. let birthDate = new Date($("#" + rel).val());//生日日期
  76. let birthYear = birthDate.getFullYear();
  77. let birthMonth = birthDate.getMonth() + 1;
  78. let currentDate = new Date();//当前日期
  79. let currentYear = currentDate.getFullYear();
  80. let currentMonth = currentDate.getMonth() + 1;
  81. age = (currentYear * 12 + currentMonth - birthYear * 12 - birthMonth) / 12;
  82. }
  83. if (age < data["rows"][k].option)
  84. data["rows"][k].hidden = true;
  85. } else {
  86. let selectVal = $("#" + rel).data("value").toString();
  87. let options = data["rows"][k].option.split(",");
  88. if (options.indexOf(selectVal) == -1) {
  89. data["rows"][k].hidden = true;
  90. }
  91. }
  92. }
  93. } else {
  94. if (data["rows"][k].isConditionFile) {
  95. var isMatchZhiren = $("input[name=isMatchZhiren]").length > 0 ? parseInt($("input[name=isMatchZhiren]:checked").val()) : false;
  96. var isImport = parseInt($("#import").val());
  97. if (isImport == 1 && isMatchZhiren)
  98. continue;
  99. var tableIndex = 0;
  100. if ($("#talent_condition").parents(".table").length > 0) {
  101. tableIndex = $("#talent_condition").parents(".table").find("table.fileTable").index(".fileTable");
  102. } else {
  103. tableIndex = $("#talent_condition").parents(".row").next(".row").find("table.fileTable").index(".fileTable");
  104. }
  105. data["rows"][k].tableIndex = tableIndex;
  106. data["rows"][k].trIndex = datas[tableIndex].length;
  107. datas[tableIndex].push(data["rows"][k]);//放入人才条件后面的附件表
  108. } else {
  109. var tableIndex = $(".fileTable").length - 1;
  110. data["rows"][k].tableIndex = tableIndex;
  111. data["rows"][k].trIndex = datas[tableIndex].length;
  112. datas[$(".fileTable").length - 1].push(data["rows"][k]);//没有归属,放入最后一个附件表
  113. }
  114. }
  115. }
  116. for (var i = 0; i < $(".fileTable").length; i++) {
  117. var that = $(".fileTable").eq(i);
  118. that.bootstrapTable({
  119. columns: TalentInfoInfoDlg.initFileTypeColumn(),
  120. data: datas[i],
  121. showHeader: false,
  122. rowStyle: function (row, index) {
  123. return {classes: ""};
  124. },
  125. onPostBody: function (data) {
  126. for (var k in data) {
  127. var files = data[k].files;
  128. 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>';
  129. for (var key in files) {
  130. var sn = files[key].url.lastIndexOf(".");
  131. var suffix = files[key].ext;//files[key].url.substring(sn + 1, files[key].url.length);
  132. var imgStr = "";
  133. if (suffix == "pdf" || suffix == "PDF") {
  134. 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>";
  135. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS') {
  136. 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>";
  137. } else {
  138. imgStr = '<img class=\"imgUrl\" onclick="Feng.showImg(this)" src=\"' + files[key].url + '\" style=\"width:25px;height:25px;\">';
  139. }
  140. html += '<li data-id="' + files[key].id + '">\n\
  141. <div><input type="hidden" name="uploadFiles[]" value="' + files[key].id + '"></div>\n' +
  142. '<div style="width: 80%;">' + files[key].orignName + '</div>\n' +
  143. '<div style="width: 10%;">' + imgStr + '</div>\n' +
  144. '<div style="width: 10%;"></div>\n\
  145. </li>';
  146. }
  147. html = html + '</ul>';
  148. that.find("tr[data-index='" + k + "']").attr("data-rel", data[k]["rel"]);
  149. that.find("tr[data-index='" + k + "']").attr("data-option", data[k]["option"]);
  150. that.find("tr[data-index='" + k + "']").after('<tr class="detail-view"><td colspan="5">' + html + '</td></tr>');
  151. if (typeof data[k].hidden != "undefined") {
  152. that.find("tr[data-index='" + k + "']").css("display", "none");
  153. that.find("tr[data-index='" + k + "']").next("tr.detail-view").css("display", "none");
  154. }
  155. }
  156. $("td.uitd_showTip").bind("mouseover", function () {
  157. var htm = $(this).html();
  158. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  159. });
  160. },
  161. });
  162. }
  163. }, function (data) {
  164. Feng.error("查询失败!" + data.responseJSON.message + "!");
  165. });
  166. var queryData = {};
  167. queryData["mainId"] = $("#id").val();
  168. queryData['project'] = CONFIG.project_rcrd;
  169. queryData['type'] = $("#type").val();
  170. queryData["source"] = $("#source").val();
  171. queryData["talent_condition"] = $("#talent_condition").val();
  172. queryData['checkState'] = $("#checkState").val();
  173. ajax.set(queryData);
  174. ajax.start();
  175. }
  176. TalentInfoInfoDlg.downloadFile = function (id, type) {
  177. window.location.href = Feng.ctxPath + "/common/api/downloadFile?id=" + id + "&type=" + type;
  178. }
  179. $(function () {
  180. $(":input").prop("disabled", true);
  181. $("#talent_type option").eq(0).prop("selected", true);
  182. var id = $("#id").val();
  183. var checkState = $("#checkState").val();
  184. TalentInfoInfoDlg.initFileTable();
  185. if (id != null && id != '') {
  186. //select初始化
  187. $("select").each(function () {
  188. $(this).val($(this).attr("value")).trigger("change");
  189. });
  190. Feng.getCheckLog("logTable", {"type": CONFIG.project_rcrd, "mainId": id, "typeFileId": "", "active": 1})
  191. }
  192. /*var source = $("#source").val();
  193. var columns = 3;
  194. if (source == 1 || source == 2) {
  195. columns = 3;
  196. } else if (source == 3 || source == 4) {
  197. columns = 4;
  198. }
  199. $("#source").parents("td").attr("colspan", columns);
  200. $("#talent_arrange").parents("td").attr("colspan", columns);
  201. $("#talent_condition").parents("td").attr("colspan", columns - 1);*/
  202. });