integralInfo_select.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. /**
  2. * 初始化人才认定申报详情对话框
  3. */
  4. var locked = false;
  5. var IntegralInfoDlg = {
  6. integralInfoData: {}
  7. };
  8. /**
  9. * 关闭此对话框
  10. */
  11. IntegralInfoDlg.close = function () {
  12. parent.layer.close(window.parent.TalentInfo.layerIndex);
  13. }
  14. /**
  15. * 初始化表格的列
  16. */
  17. IntegralInfoDlg.initFileTypeColumn = function () {
  18. return [
  19. {field: 'selectItem', checkbox: false, visible: false},
  20. {title: '名称', field: 'name', visible: true, align: 'left', valign: 'middle', width: "82%", 'class': 'uitd_showTip',
  21. formatter: function (value, row, index) {
  22. let str = '<div class="word-wrap">';
  23. if (row.must == 1) {
  24. str = str + '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
  25. }
  26. if (row.must == 2) {
  27. str = str + '<i class="fa fa-paste"></i>' + value;
  28. }
  29. str = str + '<br /><span id="desc_' + row.rel + '">' + row.description + '</span></div>'
  30. return str;
  31. }
  32. },
  33. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "8%",
  34. formatter: function (value, row, index) {
  35. if (value == null || value == '' || value == 'null') {
  36. return '无';
  37. }
  38. return "<button type='button' onclick=\"IntegralInfoDlg.downloadFile('" + row.id + "',3)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  39. "<i class=\"fa fa-download\"></i>下载" +
  40. "</button>";
  41. }
  42. },
  43. {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%",
  44. formatter: function (value, row, index) {
  45. return IntegralInfoDlg.validUploadButton(1, value, '');
  46. }
  47. }
  48. ]
  49. };
  50. IntegralInfoDlg.changeAndLoadFile = function () {
  51. var table = $(".fileTable");
  52. var items = $("select[name='item_id[]']");
  53. var item_id = [];
  54. for (var i = 0; i < items.length; i++) {
  55. let _id = items.eq(i).val();
  56. if (_id) {
  57. item_id.push(_id);
  58. }
  59. }
  60. if (item_id.length == 0) {
  61. table.bootstrapTable("destroy");
  62. return;
  63. }
  64. var ajax = new $ax("/common/api/findCommonFileType", function (data) {
  65. if (data == null || data.length == 0) {
  66. return;
  67. }
  68. table.bootstrapTable("destroy");
  69. table.bootstrapTable({
  70. columns: IntegralInfoDlg.initFileTypeColumn(),
  71. data: data.rows,
  72. showHeader: true,
  73. rowStyle: function (row, index) {
  74. return {classes: ""};
  75. },
  76. onPostBody: function (data) {
  77. for (var k in data) {
  78. var files = data[k].files;
  79. 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>';
  80. for (var key in files) {
  81. var btn = "";
  82. btn = IntegralInfoDlg.validUploadButton(2, data[k].id, files[key].id);
  83. var sn = files[key].url.lastIndexOf(".");
  84. var suffix = files[key].ext; //files[key].url.substring(sn + 1, files[key].url.length);
  85. var imgStr = "";
  86. if (suffix == "pdf" || suffix == "PDF") {
  87. 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>";
  88. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS' || suffix == 'docx' || suffix == 'doc' || suffix == 'DOCX' || suffix == 'DOC') {
  89. 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>";
  90. } else {
  91. imgStr = '<img class=\"imgUrl\" onclick=\"Feng.showImg(this)\" src=\"' + files[key].url + '\" style=\"width:25px;height:25px;\">';
  92. }
  93. html += '<li data-id="' + files[key].id + '">\n\
  94. <div>' + (data[k].step != 1 ? '<input type="hidden" name="uploadFiles[]" value="' + files[key].id + '">' : "") + '</div>\n' +
  95. '<div style="width: 70%;">' + files[key].orignName + '</div>\n' +
  96. '<div style="width: 10%;">' + imgStr + '</div>\n' +
  97. '<div style="width: 20%;">' + btn + '</div>\n\
  98. </li>';
  99. }
  100. html = html + '</ul>';
  101. table.find("tr[data-index='" + k + "']").after('<tr class="detail-view"><td colspan="5">' + html + '</td></tr>');
  102. }
  103. $("td.uitd_showTip").bind("mouseover", function () {
  104. var htm = $(this).html();
  105. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  106. });
  107. },
  108. });
  109. }, function (data) {
  110. Feng.error("查询失败!" + data.responseJSON.message + "!");
  111. });
  112. var queryData = {};
  113. queryData["mainId"] = $("#id").val();
  114. queryData['project'] = CONFIG.project_integral_apply;
  115. queryData['type'] = $("#type").val();
  116. queryData["itemId"] = item_id;
  117. queryData['checkState'] = $("#checkState").val();
  118. ajax.set(queryData);
  119. ajax.start();
  120. }
  121. IntegralInfoDlg.onProjectTypeChange = function (obj) {
  122. var projectType = $(obj).val();
  123. var projectObj = $(obj).parents("table").find("select[name='projectId[]']")
  124. Feng.addAjaxSelect({
  125. "obj": projectObj,
  126. "displayCode": "id",
  127. "displayName": "name",
  128. "type": "GET",
  129. "url": "/common/api/getIntegralProjectsByType/projectType/" + projectType
  130. });
  131. }
  132. IntegralInfoDlg.onProjectChange = function (obj) {
  133. var projectId = $(obj).val();
  134. var itemObj = $(obj).parents("table").find("select[name='item_id[]']")
  135. Feng.addAjaxSelect({
  136. "obj": itemObj,
  137. "displayCode": "id",
  138. "displayName": "name",
  139. "bindData": "unit",
  140. "type": "GET",
  141. "url": "/common/api/getIntegralItemsByProject/projectId/" + projectId
  142. });
  143. }
  144. IntegralInfoDlg.onItemChange = function (obj) {
  145. var unit = $(obj).find("option:selected").data("unit");
  146. var parent = $(obj).parents("table");
  147. if (typeof unit != "undefined" && unit) {
  148. parent.find(".unit").html("(" + unit + ")");
  149. } else {
  150. parent.find(".unit").html("");
  151. }
  152. IntegralInfoDlg.changeAndLoadFile();
  153. }
  154. var currentTable = null;
  155. var currentTr = null;
  156. //选择附件并显示附件名
  157. IntegralInfoDlg.checkFile = function (content, fileTypeId, fileId) {
  158. currentTable = $(content).parents(".fileTable");
  159. currentTr = $(content).parents("tr").data("index");
  160. if (!IntegralInfoDlg.validateIsEdit())
  161. return;
  162. $("#upload_file").unbind("change");
  163. $("#upload_file").change(function () {
  164. if (!Feng.chkFileInvalid(this.files[0], 5, 10))
  165. return;
  166. IntegralInfoDlg.upload(fileTypeId, fileId);
  167. });
  168. $('#upload_file').val("");
  169. $('#upload_file').click();
  170. }
  171. //上传附件
  172. IntegralInfoDlg.upload = function (fileTypeId, fileId) {
  173. var id = $("#id").val();
  174. if (!IntegralInfoDlg.validateIsEdit())
  175. return;
  176. if (fileId != null && fileId != 'null') {
  177. $("#fileId").val(fileId)
  178. } else {
  179. $("#fileId").val("");
  180. }
  181. $("#mainId").val(id);
  182. $("#fileTypeId").val(fileTypeId);
  183. var index = layer.load(0, {shade: false, time: 0});
  184. $("#index").val(index);
  185. $("#uploadForm").submit();
  186. }
  187. //删除附件
  188. IntegralInfoDlg.deleteFile = function (id, state) {
  189. if (!IntegralInfoDlg.validateIsEdit())
  190. return;
  191. var operation = function () {
  192. var ajax = new $ax(Feng.ctxPath + "/common/api/deleteFile", function (data) {
  193. if (data.code = 200) {
  194. Feng.success(data.msg);
  195. $("input[name='uploadFiles[]'][value='" + id + "']").parents("li").remove();
  196. //$("#fileTable").bootstrapTable("refresh", {});
  197. } else {
  198. Feng.error(data.msg);
  199. }
  200. }, function (data) {
  201. Feng.error("删除失败!" + data.responseJSON.message + "!");
  202. });
  203. ajax.set("id", id);
  204. ajax.set("type", 1);
  205. ajax.start();
  206. }
  207. Feng.confirm("删除后无法恢复,确认删除吗?", operation);
  208. }
  209. /**
  210. * 校验是否显示按钮
  211. * @param type 类型 1-上传按钮,2-修改删除按钮
  212. * @param row
  213. * @returns {string}
  214. */
  215. IntegralInfoDlg.validUploadButton = function (type, fileTypeId, fileId) {
  216. var files = $("#files").val();
  217. files = files.split(",");
  218. var checkState = $("#checkState").val();
  219. var realState = $("#realState").val();
  220. //console.log(checkState, realState);
  221. if (Feng.isEmptyStr(checkState) || checkState == 0 || (checkState == 1 && realState == 1) || (checkState == 11 && realState != 14) || (realState == 11 && files.indexOf(fileTypeId.toString()) != -1)) {
  222. if (type == 1) { //上传
  223. return "<button type='button' onclick=\"IntegralInfoDlg.checkFile(this," + fileTypeId + "," + null + ")\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  224. "<i class=\"fa fa-upload\"></i>上传" +
  225. "</button>";
  226. } else {
  227. return "<button type=\'button\' onclick=\"IntegralInfoDlg.checkFile(this," + fileTypeId + "," + fileId + ")\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\">" +
  228. "<i class=\"fa fa-paste\"></i>修改" +
  229. "</button>" +
  230. "<button type='button' onclick=\"IntegralInfoDlg.deleteFile(" + fileId + ")\" class=\"btn btn-xs btn-danger\">" +
  231. "<i class=\"fa fa-times\"></i>删除" +
  232. "</button>";
  233. }
  234. } else {
  235. return "";
  236. }
  237. }
  238. IntegralInfoDlg.downloadFile = function (id, type) {
  239. window.location.href = Feng.ctxPath + "/api/common/downloadFile?id=" + id + "&type=" + type;
  240. }
  241. //设置不可修改的字段
  242. IntegralInfoDlg.setNoChangeField = function () {
  243. console.log(123)
  244. $("input,textarea").each(function () {
  245. $(this).attr("readonly", "readonly");
  246. });
  247. $("select,input[type=radio]").each(function () {
  248. $(this).attr("disabled", "disabled");
  249. });
  250. }
  251. $(function () {
  252. var id = $("#id").val();
  253. var checkState = $("#checkState").val();
  254. if (id != null && id != '') {
  255. //select初始化
  256. $("select").each(function () {
  257. $(this).val($(this).attr("value")).trigger("change");
  258. });
  259. Feng.getCheckLog("logTable", {"type": CONFIG.project_integral_apply, "mainId": id, "typeFileId": "", "active": 1})
  260. }
  261. $("#card_type").val($("#card_type").attr("value"));
  262. IntegralInfoDlg.setNoChangeField();
  263. //IntegralInfoDlg.changeAndLoadFile();
  264. });