talentInfo_wj_select_new.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: "70%", 'class': 'uitd_showTip',
  14. formatter: function (value, row, index) {
  15. let str = '<div class="word-wrap">';
  16. let highlights_by_api = ["crz"];
  17. let description = row.description;
  18. if (highlights_by_api.indexOf(row.api) > -1) {
  19. value = '<span style="font-weight:bold;color:red;">' + value + '</span>';
  20. description = '<span style="font-weight:bold;color:red;">' + description + '</span>';
  21. }
  22. if (row.must == 1) {
  23. return '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
  24. }
  25. if (row.must == 2) {
  26. return '<i class="fa fa-paste"></i>' + value;
  27. }
  28. str = str + '<br /><span id="desc_' + row.rel + '">' + description + '</span></div>'
  29. return str;
  30. }
  31. },
  32. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "10%",
  33. formatter: function (value, row, index) {
  34. if (value == null || value == '' || value == 'null') {
  35. return '无';
  36. }
  37. return "<button type='button' onclick=\"TalentInfoInfoDlg.downloadFile('" + row.id + "',5)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  38. "<i class=\"fa fa-download\"></i>下载" +
  39. "</button>";
  40. }
  41. },
  42. {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "20%",
  43. formatter: function (value, row, index) {
  44. return "";
  45. }
  46. }
  47. ]
  48. };
  49. TalentInfoInfoDlg.initFileTable = function () {
  50. var ajax = new $ax("/common/api/findCommonFileType", function (data) {
  51. if (data == null || data.length == 0) {
  52. return;
  53. }
  54. var datas = new Array();
  55. for (var i = 0; i < $(".fileTable").length; i++) {
  56. datas.push([]);//创建空的多维数组,等下用来存每个附件表的各自的列
  57. }
  58. var enterpriseTag = $("#enterprise_tag").val();
  59. for (var k in data["rows"]) {
  60. if (data["rows"][k].enterprise_tag != "" && data["rows"][k].enterprise_tag != null && data["rows"][k].enterprise_tag.indexOf(enterpriseTag) == -1) {
  61. continue;
  62. }
  63. var rel = data["rows"][k].rel;
  64. if ($("#" + rel).length > 0) {
  65. var tableIndex = 0;
  66. if ($("#" + rel).parents(".table").length > 0) {
  67. tableIndex = $("#" + rel).parents(".table").find("table.fileTable").index(".fileTable");
  68. } else {
  69. tableIndex = $("#" + rel).parents(".row").next(".row").find("table.fileTable").index(".fileTable");
  70. }
  71. data["rows"][k].tableIndex = tableIndex;
  72. data["rows"][k].trIndex = datas[tableIndex].length;
  73. datas[tableIndex].push(data["rows"][k]);
  74. if (data["rows"][k].option) {
  75. //指定了选项
  76. if (rel == "birthday") {
  77. let age = 0;
  78. if ($("#" + rel).val()) {
  79. let birthDate = new Date($("#" + rel).val());//生日日期
  80. let birthYear = birthDate.getFullYear();
  81. let birthMonth = birthDate.getMonth() + 1;
  82. let currentDate = new Date();//当前日期
  83. let currentYear = currentDate.getFullYear();
  84. let currentMonth = currentDate.getMonth() + 1;
  85. age = (currentYear * 12 + currentMonth - birthYear * 12 - birthMonth) / 12;
  86. }
  87. if (age < data["rows"][k].option)
  88. data["rows"][k].hidden = true;
  89. } else {
  90. let selectVal = $("#" + rel).data("value").toString();
  91. let options = data["rows"][k].option.split(",");
  92. if (options.indexOf(selectVal) == -1) {
  93. data["rows"][k].hidden = true;
  94. }
  95. }
  96. }
  97. } else {
  98. if (data["rows"][k].isConditionFile) {
  99. var tableIndex = 0;
  100. if ($("#talent_condition_rel").parents(".table").length > 0) {
  101. tableIndex = $("#talent_condition_rel").parents(".table").find("table.fileTable").index(".fileTable");
  102. } else {
  103. tableIndex = $("#talent_condition_rel").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 - 2;
  110. data["rows"][k].tableIndex = tableIndex;
  111. data["rows"][k].trIndex = datas[tableIndex].length;
  112. datas[$(".fileTable").length - 2].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: 70%;font-weight: bold;padding-top: 5px;">附件原名</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">预览</li><li style="width: 20%;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: 70%;">' + files[key].orignName + '</div>\n' +
  143. '<div style="width: 10%;">' + imgStr + '</div>\n' +
  144. '<div style="width: 20%;"></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. });