talentInfo_select.js 9.1 KB

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