Feng.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. var Feng = {
  2. ctxPath: "",
  3. addCtx: function (ctx) {
  4. if (this.ctxPath == "") {
  5. this.ctxPath = ctx;
  6. }
  7. },
  8. confirm: function (tip, ensure) {//询问框
  9. parent.layer.confirm(tip, {
  10. btn: ['确定', '取消']
  11. }, function (index, layero) {
  12. var btn = layero.find(".layui-layer-btn0");
  13. btn.css("pointer-events", "none")
  14. ensure();
  15. parent.layer.close(index);
  16. }, function (index) {
  17. parent.layer.close(index);
  18. });
  19. },
  20. log: function (info) {
  21. console.log(info);
  22. },
  23. alert: function (info, iconIndex) {
  24. parent.layer.msg(info, {
  25. icon: iconIndex
  26. });
  27. },
  28. info: function (info) {
  29. Feng.alert(info, 0);
  30. },
  31. success: function (info) {
  32. Feng.alert(info, 1);
  33. },
  34. error: function (info) {
  35. Feng.alert(info, 2);
  36. },
  37. infoDetail: function (title, info) {
  38. var display = "";
  39. if (typeof info == "string") {
  40. display = info;
  41. } else {
  42. if (info instanceof Array) {
  43. for (var x in info) {
  44. display = display + info[x] + "<br/>";
  45. }
  46. } else {
  47. display = info;
  48. }
  49. }
  50. parent.layer.open({
  51. title: title,
  52. type: 1,
  53. skin: 'layui-layer-rim', //加上边框
  54. area: ['950px', '600px'], //宽高
  55. content: '<div style="padding: 20px;">' + display + '</div>'
  56. });
  57. },
  58. writeObj: function (obj) {
  59. var description = "";
  60. for (var i in obj) {
  61. var property = obj[i];
  62. description += i + " = " + property + ",";
  63. }
  64. layer.alert(description, {
  65. skin: 'layui-layer-molv',
  66. closeBtn: 0
  67. });
  68. },
  69. showInputTree: function (inputId, inputTreeContentId, leftOffset, rightOffset) {
  70. var onBodyDown = function (event) {
  71. if (!(event.target.id == "menuBtn" || event.target.id == inputTreeContentId || $(event.target).parents("#" + inputTreeContentId).length > 0)) {
  72. $("#" + inputTreeContentId).fadeOut("fast");
  73. $("body").unbind("mousedown", onBodyDown);// mousedown当鼠标按下就可以触发,不用弹起
  74. }
  75. };
  76. if (leftOffset == undefined && rightOffset == undefined) {
  77. var inputDiv = $("#" + inputId);
  78. var inputDivOffset = $("#" + inputId).offset();
  79. $("#" + inputTreeContentId).css({
  80. left: inputDivOffset.left + "px",
  81. top: inputDivOffset.top + inputDiv.outerHeight() + "px"
  82. }).slideDown("fast");
  83. } else {
  84. $("#" + inputTreeContentId).css({
  85. left: leftOffset + "px",
  86. top: rightOffset + "px"
  87. }).slideDown("fast");
  88. }
  89. $("body").bind("mousedown", onBodyDown);
  90. },
  91. baseAjax: function (url, tip) {
  92. var ajax = new $ax(Feng.ctxPath + url, function (data) {
  93. Feng.success(tip + "成功!");
  94. }, function (data) {
  95. Feng.error(tip + "失败!" + data.responseJSON.message + "!");
  96. });
  97. return ajax;
  98. },
  99. changeAjax: function (url) {
  100. return Feng.baseAjax(url, "修改");
  101. },
  102. zTreeCheckedNodes: function (zTreeId) {
  103. var zTree = $.fn.zTree.getZTreeObj(zTreeId);
  104. var nodes = zTree.getCheckedNodes();
  105. var ids = "";
  106. for (var i = 0, l = nodes.length; i < l; i++) {
  107. ids += "," + nodes[i].id;
  108. }
  109. return ids.substring(1);
  110. },
  111. eventParseObject: function (event) {//获取点击事件的源对象
  112. event = event ? event : window.event;
  113. var obj = event.srcElement ? event.srcElement : event.target;
  114. return $(obj);
  115. },
  116. sessionTimeoutRegistry: function () {
  117. $.ajaxSetup({
  118. contentType: "application/x-www-form-urlencoded;charset=utf-8",
  119. complete: function (XMLHttpRequest, textStatus) {
  120. //通过XMLHttpRequest取得响应头,sessionstatus,
  121. var sessionstatus = XMLHttpRequest.getResponseHeader("sessionstatus");
  122. if (sessionstatus == "timeout") {
  123. //如果超时就处理 ,指定要跳转的页面
  124. window.location = Feng.ctxPath + "/global/sessionError";
  125. }
  126. }
  127. });
  128. },
  129. initValidator: function (formId, fields) {
  130. $('#' + formId).bootstrapValidator({
  131. feedbackIcons: {
  132. valid: 'glyphicon glyphicon-ok',
  133. invalid: 'glyphicon glyphicon-remove',
  134. validating: 'glyphicon glyphicon-refresh'
  135. },
  136. fields: fields,
  137. live: 'enabled',
  138. message: '该字段不能为空'
  139. });
  140. },
  141. initValidatorTip: function (formId, fields) {
  142. $('#' + formId).bootstrapValidator({
  143. feedbackIcons: {
  144. valid: 'glyphicon glyphicon-ok',
  145. invalid: 'glyphicon glyphicon-remove',
  146. validating: 'glyphicon glyphicon-refresh'
  147. },
  148. container: 'tooltip',
  149. group: '.rowGroup',
  150. fields: fields,
  151. live: 'enabled',
  152. message: '该字段不能为空'
  153. }).on('error.field.bv', function (e, data) {
  154. var $parent = data.element.parents('.form-group-sm'),
  155. $icon = $parent.find('.form-control-feedback[data-bv-icon-for="' + data.field + '"]'),
  156. title = $icon.data('bs.tooltip').getTitle();
  157. $icon.tooltip('destroy').tooltip({
  158. html: true,
  159. placement: 'right',
  160. title: title,
  161. container: 'body'
  162. });
  163. });
  164. },
  165. underLineToCamel: function (str) {
  166. var strArr = str.split('_');
  167. for (var i = 1; i < strArr.length; i++) {
  168. strArr[i] = strArr[i].charAt(0).toUpperCase() + strArr[i].substring(1);
  169. }
  170. var result = strArr.join('');
  171. return result.charAt(0).toUpperCase() + result.substring(1);
  172. },
  173. randomNum: function (minNum, maxNum) {
  174. switch (arguments.length) {
  175. case 1:
  176. return parseInt(Math.random() * minNum + 1, 10);
  177. break;
  178. case 2:
  179. return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
  180. break;
  181. default:
  182. return 0;
  183. break;
  184. }
  185. },
  186. newCrontab: function (href, menuName) {
  187. var dataUrl = href;
  188. var needCreateCrontab = true;
  189. // 轮询已有的标签,判断是否已经存在标签
  190. parent.$('.J_menuTab').each(function () {
  191. if ($(this).data('id') == dataUrl) {
  192. if (!$(this).hasClass('active')) {
  193. $(this).addClass('active').siblings('.J_menuTab').removeClass('active');
  194. parent.MyCrontab.scrollToTab(this);
  195. parent.MyCrontab.$('.J_mainContent .J_iframe').each(function () {
  196. if ($(this).data('id') == dataUrl) {
  197. $(this).show().siblings('.J_iframe').hide();
  198. $(this).attr('src', $(this).attr('src'));
  199. return false;
  200. }
  201. });
  202. }
  203. needCreateCrontab = false;
  204. return false;
  205. }
  206. });
  207. //创建标签
  208. if (needCreateCrontab) {
  209. var tabLink = '<a href="javascript:;" class="active J_menuTab" data-id="' + dataUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
  210. parent.$('.J_menuTab').removeClass('active');
  211. parent.$('.J_menuTabs .page-tabs-content').append(tabLink);
  212. var iframeContent = '<iframe class="J_iframe" name="iframe' + Feng.randomNum(100, 999) + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" seamless></iframe>';
  213. parent.$('.J_mainContent').find('iframe.J_iframe').hide().parents('.J_mainContent').append(iframeContent);
  214. parent.MyCrontab.scrollToTab($('.J_menuTab.active'));
  215. }
  216. },
  217. endWith: function (str, val) {
  218. if (str == null || val == null) {
  219. return false;
  220. }
  221. if (str.length < val.length) {
  222. return false;
  223. }
  224. var temp = str.substring(str.length - val.length);
  225. if (temp == val) {
  226. return true;
  227. } else {
  228. return false;
  229. }
  230. },
  231. setUrlParam: function (url, jsonObj) {
  232. for (var temp in jsonObj) {
  233. var key = temp;
  234. var value = jsonObj[temp];
  235. if (value != null && value != '') {
  236. if (url.indexOf("?") != -1) {
  237. url = url + "&" + key + "=" + encodeURI(encodeURI(value));
  238. } else {
  239. url = url + "?" + key + "=" + encodeURI(encodeURI(value));
  240. }
  241. }
  242. }
  243. return url
  244. },
  245. getUrlValue: function (name) {
  246. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  247. var r = window.location.search.substr(1).match(reg);
  248. if (r != null)
  249. return decodeURI(r[2]);
  250. return null;
  251. },
  252. addAjaxSelect: function (val) {
  253. var id = val.id; //下拉框对象的id
  254. var obj = val.obj;
  255. var url = val.url; //请求地址
  256. var displayCode = val.displayCode; //下拉框实际值名称
  257. var displayName = val.displayName; //下拉框显示值名称
  258. var bindData = val.bindData;
  259. var type = val.type; //请求方式 GET 或者 POST, 默认POST
  260. var async = val.async; //同步方式 {异步--falae, 同步--true}, 默认为同步
  261. if (async == null) {
  262. async = false;
  263. }
  264. if (type == null) {
  265. type == "POST";
  266. }
  267. var select = typeof id != "undefined" ? $("#" + id) : $(obj);
  268. select.empty();
  269. var ajax = new $ax(url, function (data) {
  270. var length = data.length;
  271. var html = "<option value=''>---请选择---</option>";
  272. for (var i = 0; i < length; i++) {
  273. if (length == 1) {
  274. if (typeof bindData != "undefined" && bindData) {
  275. html = html + "<option value=\"" + data[i][displayCode] + "\" data-" + bindData + "=\"" + data[i][bindData] + "\">" + data[i][displayName] + "</option>";
  276. } else {
  277. html = html + "<option value=\"" + data[i][displayCode] + "\">" + data[i][displayName] + "</option>";
  278. }
  279. } else {
  280. if (typeof bindData != "undefined" && bindData) {
  281. if (data[i][displayCode] == select.attr("defval")) {
  282. html += "<option selected='selected' value=\"" + data[i][displayCode] + "\" data-" + bindData + "=\"" + data[i][bindData] + "\">" + data[i][displayName] + "</option>";
  283. } else {
  284. html += "<option value=\"" + data[i][displayCode] + "\" data-" + bindData + "=\"" + data[i][bindData] + "\">" + data[i][displayName] + "</option>";
  285. }
  286. } else {
  287. if (data[i][displayCode] == select.attr("defval")) {
  288. html += "<option selected='selected' value=\"" + data[i][displayCode] + "\">" + data[i][displayName] + "</option>";
  289. } else {
  290. html += "<option value=\"" + data[i][displayCode] + "\">" + data[i][displayName] + "</option>";
  291. }
  292. }
  293. }
  294. }
  295. select.append(html);
  296. if (length == 1) { //如果只有一个选项,需要触发select的onchange方法
  297. select.change();
  298. }
  299. }, function (data) {
  300. Feng.error("操作失败!");
  301. });
  302. ajax.async = async;
  303. ajax.type = type;
  304. ajax.set({});
  305. ajax.start();
  306. },
  307. acceptImg: function () {
  308. return {
  309. title: 'Images',
  310. extensions: 'gif,jpg,jpeg,bmp,png',
  311. mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  312. };
  313. },
  314. acceptWord: function () {
  315. return {
  316. title: 'word',
  317. extensions: 'rar,zip,doc,xls,docx,xlsx,pdf',
  318. mimeTypes: '.rar,.zip,.doc,.xls,.docx,.xlsx,.pdf'
  319. };
  320. },
  321. acceptWord_Img: function () {
  322. return {
  323. title: 'word_img',
  324. extensions: 'doc,xls,docx,xlsx,pdf,gif,jpg,jpeg,bmp,png',
  325. mimeTypes: '.doc,.xls,.docx,.xlsx,.pdf,image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  326. };
  327. },
  328. resetSelect: function (id) {
  329. var options = $("#" + id).children();
  330. if (options.length > 1) {
  331. $("#" + id).val("");
  332. }
  333. },
  334. dictFormatter: function (code, type) {
  335. var result = "";
  336. var ajax = new $ax(Feng.ctxPath + "/dict/findDetailByCode/" + type + "/" + code, function (data) {
  337. result = data.name;
  338. }, function (data) {
  339. Feng.error("操作失败!");
  340. });
  341. ajax.start();
  342. return result;
  343. },
  344. showImg: function (context) { //传一个<img>对像
  345. var pic = $(context);
  346. var src = pic.attr("src");
  347. var prev = pic.parent().prev();
  348. var _title = prev.text();
  349. var sn = _title.lastIndexOf(".");
  350. var suffix = _title.substring(sn + 1, _title.length).toLowerCase();
  351. var title = "图片预览";
  352. var allowedPicTypes = ["jpg", "jpeg", "gif", "png"];
  353. if (allowedPicTypes.indexOf(suffix) > -1) {
  354. title = _title;
  355. }
  356. layer.open({
  357. type: 2,
  358. title: title,
  359. fixed: false,
  360. area: ['80%', '80%'],
  361. content: "/common/api/imgViewer?picShow=" + encodeURIComponent(src),
  362. maxmin: true,
  363. shade: 0
  364. })
  365. /*var sbp = window.top.$("#showBigPic");
  366. sbp.empty();
  367. sbp.append("<img id=\"_pic0001\" src=\""+src+"\" style=\"width:1px; height:1px; margin:0px;padding:0px;\"/>");
  368. window.top.$("#_pic0001").viewer({
  369. toolbar:true,
  370. fullscreen:false
  371. });
  372. window.top.$("#_pic0001").click();*/
  373. },
  374. showContract: function (talentId) {
  375. layer.open({
  376. type: 2,
  377. title: "查看合同文件",
  378. fixed: false,
  379. area: ['80%', '80%'],
  380. content: "/common/api/contractView?id=" + talentId,
  381. maxmin: true,
  382. shade: 0
  383. })
  384. },
  385. findChildDictBatch: function (data) {
  386. var ajax = new $ax(Feng.ctxPath + "/common/tool/findChildDictBatch", function (res) {
  387. var data = res.obj;
  388. for (var i in data) {
  389. var html = "<option value=''>---请选择---</option>";
  390. for (var j in data[i]) {
  391. html = html + '<option value="' + data[i][j].code + '">' + data[i][j].name + '</option>';
  392. }
  393. $("#" + i).empty().append(html);
  394. }
  395. }, function (data) {
  396. Feng.error("初始化失败!" + data.responseJSON.message + "!");
  397. });
  398. ajax.setData(data);
  399. ajax.setcontentType('application/json;charset=utf-8');
  400. ajax.start();
  401. },
  402. checkMobilePhoneNum: function (num) {
  403. var telReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  404. if (!telReg.test(num)) {
  405. return false;
  406. } else {
  407. return true;
  408. }
  409. },
  410. getCheckLog: function (id, data) {
  411. //初始化日志
  412. $('#' + id).bootstrapTable({
  413. url: Feng.ctxPath + "/common/api/getCheckLog",
  414. method: 'POST',
  415. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  416. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  417. showRefresh: false, // 是否显示刷新按钮
  418. clickToSelect: true, // 是否启用点击选中行
  419. singleSelect: true, // 设置True 将禁止多选
  420. striped: true, // 是否显示行间隔色
  421. pagination: false, // 设置为 true 会在表格底部显示分页条
  422. paginationHAlign: "left",
  423. paginationDetailHAlign: "right",
  424. sidePagination: "server", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  425. showColumns: false,
  426. queryParams: function (params) {
  427. return data;
  428. },
  429. rowStyle: function (row, index) {
  430. return {
  431. css: {
  432. "word-break": "break-word",
  433. "white-space": "inherit"
  434. }
  435. }
  436. },
  437. columns:
  438. [
  439. {title: '步骤', field: 'stepName', visible: true, align: 'center', valign: 'middle', width: "10%", 'class': 'uitd_showTip',
  440. formatter: function (value, row, index) {
  441. return "" + value;
  442. }
  443. },
  444. {title: '审核状态', field: 'stateName', visible: true, align: 'center', valign: 'middle', width: "10%", 'class': 'uitd_showTip'},
  445. {title: '状态变更', field: 'stateChange', visible: true, align: 'center', valign: 'middle', width: "20%", 'class': 'uitd_showTip'},
  446. {title: '审核意见/备注', field: 'description', visible: true, align: 'center', valign: 'middle', width: "30%", 'class': 'uitd_showTip',
  447. formatter: function (value, row, index) {
  448. return '<span data-toggle="tooltip" title="' + value + '">"' + value + '"</span>';
  449. }
  450. },
  451. {title: '操作人', field: 'createUser', visible: true, align: 'center', valign: 'middle', width: "15%", 'class': 'uitd_showTip'},
  452. {title: '操作时间', field: 'createTime', visible: true, align: 'center', valign: 'middle', width: "15%", 'class': 'uitd_showTip'},
  453. ]
  454. ,
  455. onPostBody: function () {
  456. $('#' + id + "td.uitd_showTip").bind("mouseover", function () {
  457. var htm = $(this).html();
  458. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  459. });
  460. }
  461. });
  462. },
  463. getCheckLogModel: function (id, type, fileType) {
  464. layer.open({
  465. type: 1,
  466. title: "日志",
  467. fixed: false,
  468. content: '<table id="' + id + '"></table>',
  469. area: ['80%', '80%'],
  470. maxmin: true,
  471. success: function (layero, index) {
  472. //初始化日志
  473. $('#' + id).bootstrapTable({
  474. url: Feng.ctxPath + "/common/api/getCheckLog",
  475. method: 'POST',
  476. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  477. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  478. showRefresh: false, // 是否显示刷新按钮
  479. clickToSelect: true, // 是否启用点击选中行
  480. singleSelect: true, // 设置True 将禁止多选
  481. striped: true, // 是否显示行间隔色
  482. pagination: false, // 设置为 true 会在表格底部显示分页条
  483. paginationHAlign: "left",
  484. paginationDetailHAlign: "right",
  485. sidePagination: "server", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  486. showColumns: false,
  487. queryParams: function (params) {
  488. if (Feng.isEmptyStr(fileType)) {
  489. fileType = "";
  490. }
  491. return {"type": type, "mainId": id, "typeFileId": fileType, "active": 1};
  492. },
  493. rowStyle: function (row, index) {
  494. return {
  495. css: {
  496. "word-break": "break-word",
  497. "white-space": "inherit"
  498. }
  499. }
  500. },
  501. columns:
  502. [
  503. {title: '步骤', field: 'stepName', visible: true, align: 'center', valign: 'middle', width: "10%", 'class': 'uitd_showTip',
  504. formatter: function (value, row, index) {
  505. return "" + value;
  506. }
  507. },
  508. {title: '审核状态', field: 'stateName', visible: true, align: 'center', valign: 'middle', width: "10%", 'class': 'uitd_showTip'},
  509. {title: '状态变更', field: 'stateChange', visible: true, align: 'center', valign: 'middle', width: "20%", 'class': 'uitd_showTip'},
  510. {title: '审核意见/备注', field: 'description', visible: true, align: 'center', valign: 'middle', width: "30%", 'class': 'uitd_showTip',
  511. formatter: function (value, row, index) {
  512. return '<span data-toggle="tooltip" title="' + value + '">"' + value + '"</span>';
  513. }
  514. },
  515. {title: '操作人', field: 'createUser', visible: true, align: 'center', valign: 'middle', width: "15%", 'class': 'uitd_showTip'},
  516. {title: '操作时间', field: 'createTime', visible: true, align: 'center', valign: 'middle', width: "15%", 'class': 'uitd_showTip'},
  517. ]
  518. ,
  519. onPostBody: function () {
  520. $('#' + id + "td.uitd_showTip").bind("mouseover", function () {
  521. var htm = $(this).html();
  522. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  523. });
  524. }
  525. });
  526. }
  527. });
  528. },
  529. pdfReader: function (url, filename) {
  530. filename = typeof filename == "undefined" ? "临时文件" : filename;
  531. var index = layer.open({
  532. type: 2,
  533. title: "查看PDF文件 - " + filename,
  534. area: ['80%', '80%'], //宽高
  535. fix: false, //不固定
  536. maxmin: true,
  537. content: url
  538. });
  539. return index;
  540. },
  541. showPdf: function (url, id, title) {
  542. if (Feng.isEmptyStr(id)) {
  543. id = "id";
  544. }
  545. if (Feng.isEmptyStr(title)) {
  546. title = "预览";
  547. }
  548. let origin = window.location.origin;
  549. //let full_url = "https://fileview.jinjianghc.com/onlinePreview?url=" + encodeURIComponent(Base64.encode(url));
  550. var index = layer.open({
  551. id: id,
  552. type: 2,
  553. shade: 0,
  554. title: title,
  555. area: ['80%', '80%'], //宽高
  556. fix: false, //不固定
  557. maxmin: true,
  558. content: url,
  559. });
  560. // layer.full(index);
  561. },
  562. showExcel: function (url, id, title) {
  563. if (Feng.isEmptyStr(id)) {
  564. id = "id";
  565. }
  566. if (Feng.isEmptyStr(title)) {
  567. title = "预览";
  568. }
  569. let origin = window.location.origin;
  570. //let full_url = "https://fileview.jinjianghc.com/onlinePreview?url=" + encodeURIComponent(Base64.encode(url));
  571. var index = layer.open({
  572. id: id,
  573. type: 2,
  574. shade: 0,
  575. title: title,
  576. area: ['80%', '80%'], //宽高
  577. fix: false, //不固定
  578. maxmin: true,
  579. content: Feng.ctxPath + "/common/api/filePreview?url=" + url + "&title=" + title,
  580. });
  581. //window.location.href = url;
  582. },
  583. showFile: function (url, id, title) {
  584. if (Feng.isEmptyStr(id)) {
  585. id = "id";
  586. }
  587. if (Feng.isEmptyStr(title)) {
  588. title = "预览";
  589. }
  590. var index = layer.open({
  591. id: id,
  592. type: 2,
  593. shade: 0,
  594. title: title,
  595. area: ['600px', '350px'], //宽高
  596. fix: false, //不固定
  597. maxmin: true,
  598. content: url,
  599. });
  600. },
  601. isEmptyStr: function (str) {
  602. if (str == null || str == '') {
  603. return true;
  604. } else {
  605. return false;
  606. }
  607. },
  608. isNotEmptyStr: function (str) {
  609. if (str != null && str != '') {
  610. return true;
  611. } else {
  612. return false;
  613. }
  614. },
  615. checkAll: function (id) {
  616. $("#" + id + " input").each(function () {
  617. this.checked = true;
  618. })
  619. },
  620. unCheckAll: function (id) {
  621. $("#" + id + " input").each(function () {
  622. if (this.checked) {
  623. this.checked = false;
  624. } else {
  625. this.checked = true;
  626. }
  627. })
  628. },
  629. showMiniFileModal: function (project, type, id, source, talent_condition, checkState, showOldFile) {
  630. layer.open({
  631. type: 2,
  632. title: "附件",
  633. shade: 0,
  634. resize: true,
  635. maxmin: true,
  636. // moveOut:true,
  637. id: "file",
  638. area: ['800px', '500px'],
  639. offset: 'rb', //右下角弹出content:
  640. shift: 2,
  641. content: Feng.ctxPath + "/common/api/gotoFileShow",
  642. zIndex: layer.zIndex,
  643. success: function (layero, index) {
  644. layer.setTop(layero);
  645. //按钮【按钮一】的回调
  646. var iframeWin = window[layero.find('iframe')[0]['name']];
  647. iframeWin.getFile(project, type, id, source, talent_condition, checkState, showOldFile);
  648. }
  649. });
  650. },
  651. getCheckBoxValues: function (str) { //获取checkbox值
  652. var val = "";
  653. $("#" + str + " input[name='" + str + "']").each(function () {
  654. if (this.checked) {
  655. val = val + $(this).val() + ",";
  656. }
  657. });
  658. return val.substring(0, val.length - 1);
  659. },
  660. initDate: function () {
  661. $(".date").removeAttr('lay-key');
  662. $(".date").each(function () {
  663. laydate.render({
  664. elem: this
  665. , type: 'date'
  666. , trigger: 'click'
  667. });
  668. });
  669. },
  670. downloadFile: function (id, type) {
  671. window.location.href = Feng.ctxPath + "/common/api/downloadFile?id=" + id + "&type=" + type;
  672. },
  673. bankChange: function (val, target) {
  674. var bank = $("#" + val).val();
  675. if ($.trim(bank) == '中国工商银行') {
  676. $("#" + target).val('102391050013');
  677. } else {
  678. $("#" + target).val('');
  679. }
  680. },
  681. chkFileInvalid: function (file, maxImageSize, maxFileSize, fileType, msg) {
  682. var size = 0;
  683. if (typeof fileType != "undefined" && fileType != null) {
  684. if (fileType.indexOf(file.type) < 0) {
  685. msg = typeof msg != "undefined" ? msg : "不支持的文件类型";
  686. Feng.error(msg)
  687. return false;
  688. }
  689. }
  690. switch (file.type) {
  691. case "image/jpeg":
  692. case "image/gif":
  693. case "image/png":
  694. case "image/jpg":
  695. size = maxImageSize * 1024 * 1024;//图片限制最大5M
  696. if (file.size > size) {
  697. Feng.error("图片大小不能超过" + maxImageSize + "MB!");
  698. return false;
  699. }
  700. break;
  701. case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
  702. case "application/pdf":
  703. case "application/msword":
  704. case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
  705. case "application/vnd.ms-excel":
  706. case "application/zip":
  707. case "application/x-rar-compressed":
  708. case "application/x-7z-compressed":
  709. size = maxFileSize * 1024 * 1024;//其它允许文件类型限制最大均为10M
  710. if (file.size > size) {
  711. Feng.error("文件大小不能超过" + maxFileSize + "MB!");
  712. return false;
  713. }
  714. break;
  715. default:
  716. Feng.error("文件类型不支持")
  717. return false;
  718. }
  719. return true;
  720. },
  721. isImg: function (type) {
  722. var imgtypes = ["image/jpeg", "image/gif", "image/png", "image/jpg"];
  723. if (imgtypes.indexOf(type) > -1) {
  724. return true;
  725. }
  726. return false;
  727. }
  728. };