Feng.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  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)return decodeURI(r[2]); return null;
  249. },
  250. addAjaxSelect: function (val) {
  251. var id = val.id; //下拉框对象的id
  252. var obj = val.obj;
  253. var url = val.url; //请求地址
  254. var displayCode = val.displayCode; //下拉框实际值名称
  255. var displayName = val.displayName; //下拉框显示值名称
  256. var bindData = val.bindData;
  257. var type = val.type; //请求方式 GET 或者 POST, 默认POST
  258. var async = val.async; //同步方式 {异步--falae, 同步--true}, 默认为同步
  259. if (async == null){
  260. async = false;
  261. }
  262. if (type==null){
  263. type == "POST";
  264. }
  265. var select = typeof id !="undefined"?$("#"+id):$(obj);
  266. select.empty();
  267. var ajax = new $ax(url, function(data){
  268. var length = data.length;
  269. var html = "<option value=''>---请选择---</option>";
  270. for(var i=0; i<length; i++){
  271. if (length == 1){
  272. if(typeof bindData !="undefined" && bindData){
  273. html = html+ "<option value=\""+data[i][displayCode]+"\" data-"+bindData+"=\""+data[i][bindData]+"\">"+data[i][displayName]+"</option>";
  274. }else{
  275. html = html+ "<option value=\""+data[i][displayCode]+"\">"+data[i][displayName]+"</option>";
  276. }
  277. }else{
  278. if(typeof bindData !="undefined" && bindData){
  279. if(data[i][displayCode]==select.attr("defval")){
  280. html += "<option selected='selected' value=\""+data[i][displayCode]+"\" data-"+bindData+"=\""+data[i][bindData]+"\">"+data[i][displayName]+"</option>";
  281. }else{
  282. html += "<option value=\""+data[i][displayCode]+"\" data-"+bindData+"=\""+data[i][bindData]+"\">"+data[i][displayName]+"</option>";
  283. }
  284. }else{
  285. if(data[i][displayCode]==select.attr("defval")){
  286. html += "<option selected='selected' value=\""+data[i][displayCode]+"\">"+data[i][displayName]+"</option>";
  287. }else{
  288. html += "<option value=\""+data[i][displayCode]+"\">"+data[i][displayName]+"</option>";
  289. }
  290. }
  291. }
  292. }
  293. select.append(html);
  294. if (length == 1){ //如果只有一个选项,需要触发select的onchange方法
  295. select.change();
  296. }
  297. },function(data){
  298. Feng.error("操作失败!");
  299. });
  300. ajax.async = async;
  301. ajax.type = type;
  302. ajax.set({});
  303. ajax.start();
  304. },
  305. acceptImg:function (){
  306. return {
  307. title : 'Images',
  308. extensions : 'gif,jpg,jpeg,bmp,png',
  309. mimeTypes : 'image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  310. };
  311. },
  312. acceptWord:function (){
  313. return {
  314. title: 'word',
  315. extensions: 'rar,zip,doc,xls,docx,xlsx,pdf',
  316. mimeTypes: '.rar,.zip,.doc,.xls,.docx,.xlsx,.pdf'
  317. };
  318. },
  319. acceptWord_Img:function (){
  320. return {
  321. title: 'word_img',
  322. extensions: 'doc,xls,docx,xlsx,pdf,gif,jpg,jpeg,bmp,png',
  323. mimeTypes: '.doc,.xls,.docx,.xlsx,.pdf,image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  324. };
  325. },
  326. resetSelect: function(id){
  327. var options = $("#"+id).children();
  328. if (options.length > 1){
  329. $("#"+id).val("");
  330. }
  331. },
  332. dictFormatter: function(code,type){
  333. var result = "";
  334. var ajax = new $ax(Feng.ctxPath + "/dict/findDetailByCode/"+type+"/"+code, function(data){
  335. result=data.name;
  336. },function(data){
  337. Feng.error("操作失败!");
  338. });
  339. ajax.start();
  340. return result;
  341. },
  342. showImg: function(context) { //传一个<img>对像
  343. var pic = $(context);
  344. var src = pic.attr("src");
  345. var sbp = window.top.$("#showBigPic");
  346. sbp.empty();
  347. sbp.append("<img id=\"_pic0001\" src=\""+src+"\" style=\"width:1px; height:1px; margin:0px;padding:0px;\"/>");
  348. window.top.$("#_pic0001").viewer({
  349. toolbar:true,
  350. fullscreen:false
  351. });
  352. window.top.$("#_pic0001").click();
  353. },
  354. findChildDictBatch : function (data) {
  355. var ajax = new $ax(Feng.ctxPath + "/common/tool/findChildDictBatch", function (res) {
  356. var data = res.obj;
  357. for(var i in data){
  358. var html = "<option value=''>---请选择---</option>";
  359. for(var j in data[i]){
  360. html = html + '<option value="'+data[i][j].code+'">'+data[i][j].name+'</option>';
  361. }
  362. $("#"+i).empty().append(html);
  363. }
  364. }, function (data) {
  365. Feng.error("初始化失败!" + data.responseJSON.message + "!");
  366. });
  367. ajax.setData(data);
  368. ajax.setcontentType('application/json;charset=utf-8');
  369. ajax.start();
  370. },
  371. checkMobilePhoneNum: function(num) {
  372. var telReg=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  373. if (!telReg.test(num)) {
  374. return false;
  375. } else {
  376. return true;
  377. }
  378. },
  379. getCheckLog : function (id,data) {
  380. //初始化日志
  381. $('#'+id).bootstrapTable({
  382. url: Feng.ctxPath + "/common/api/getCheckLog",
  383. method: 'POST',
  384. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  385. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  386. showRefresh: false, // 是否显示刷新按钮
  387. clickToSelect: true, // 是否启用点击选中行
  388. singleSelect: true, // 设置True 将禁止多选
  389. striped: true, // 是否显示行间隔色
  390. pagination: false, // 设置为 true 会在表格底部显示分页条
  391. paginationHAlign: "left",
  392. paginationDetailHAlign: "right",
  393. sidePagination: "server", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  394. showColumns: false,
  395. queryParams: function (params) {
  396. return data;
  397. },
  398. rowStyle : function(row,index){
  399. return {
  400. css: {
  401. "word-break": "break-word",
  402. "white-space": "inherit"
  403. }
  404. }
  405. },
  406. columns:
  407. [
  408. {title: '步骤', field: 'stepName', visible: true, align: 'center', valign: 'middle',width:"10%",'class':'uitd_showTip',
  409. formatter : function (value,row,index) {
  410. return ""+value;
  411. }
  412. },
  413. {title: '审核状态', field: 'stateName', visible: true, align: 'center', valign: 'middle',width:"10%",'class':'uitd_showTip'},
  414. {title: '状态变更', field: 'stateChange', visible: true, align: 'center', valign: 'middle',width:"20%",'class':'uitd_showTip'},
  415. {title: '审核意见/备注', field: 'description', visible: true, align: 'center', valign: 'middle',width:"30%",'class':'uitd_showTip',
  416. formatter : function (value,row,index) {
  417. return '<span data-toggle="tooltip" title="'+ value +'">"'+value+'"</span>';
  418. }
  419. },
  420. {title: '操作人', field: 'createUser', visible: true, align: 'center', valign: 'middle',width:"15%",'class':'uitd_showTip'},
  421. {title: '操作时间', field: 'createTime', visible: true, align: 'center', valign: 'middle',width:"15%",'class':'uitd_showTip'},
  422. ]
  423. ,
  424. onPostBody: function () {
  425. $('#'+id+"td.uitd_showTip").bind("mouseover", function () {
  426. var htm = $(this).html();
  427. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  428. });
  429. }
  430. });
  431. },
  432. getCheckLogModel : function (id,type,fileType) {
  433. layer.open({
  434. type: 1,
  435. title:"日志",
  436. fixed:false,
  437. content: '<table id="'+id+'"></table>',
  438. area: ['80%', '80%'],
  439. maxmin: true,
  440. success :function (layero, index) {
  441. //初始化日志
  442. $('#'+id).bootstrapTable({
  443. url: Feng.ctxPath + "/api/talentInfo/getCheckLog",
  444. method: 'POST',
  445. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  446. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  447. showRefresh: false, // 是否显示刷新按钮
  448. clickToSelect: true, // 是否启用点击选中行
  449. singleSelect: true, // 设置True 将禁止多选
  450. striped: true, // 是否显示行间隔色
  451. pagination: false, // 设置为 true 会在表格底部显示分页条
  452. paginationHAlign: "left",
  453. paginationDetailHAlign: "right",
  454. sidePagination: "server", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  455. showColumns: false,
  456. queryParams: function (params) {
  457. if(Feng.isEmptyStr(fileType)){
  458. fileType = "";
  459. }
  460. return {"type":type,"mainId":id,"typeFileId":fileType,"active":1};
  461. },
  462. rowStyle : function(row,index){
  463. return {
  464. css: {
  465. "word-break": "break-word",
  466. "white-space": "inherit"
  467. }
  468. }
  469. },
  470. columns:
  471. [
  472. {title: '步骤', field: 'stepName', visible: true, align: 'center', valign: 'middle',width:"10%",'class':'uitd_showTip',
  473. formatter : function (value,row,index) {
  474. return ""+value;
  475. }
  476. },
  477. {title: '审核状态', field: 'stateName', visible: true, align: 'center', valign: 'middle',width:"10%",'class':'uitd_showTip'},
  478. {title: '状态变更', field: 'stateChange', visible: true, align: 'center', valign: 'middle',width:"20%",'class':'uitd_showTip'},
  479. {title: '审核意见/备注', field: 'description', visible: true, align: 'center', valign: 'middle',width:"30%",'class':'uitd_showTip',
  480. formatter : function (value,row,index) {
  481. return '<span data-toggle="tooltip" title="'+ value +'">"'+value+'"</span>';
  482. }
  483. },
  484. {title: '操作人', field: 'createUser', visible: true, align: 'center', valign: 'middle',width:"15%",'class':'uitd_showTip'},
  485. {title: '操作时间', field: 'createTime', visible: true, align: 'center', valign: 'middle',width:"15%",'class':'uitd_showTip'},
  486. ]
  487. ,
  488. onPostBody: function () {
  489. $('#'+id+"td.uitd_showTip").bind("mouseover", function () {
  490. var htm = $(this).html();
  491. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  492. });
  493. }
  494. });
  495. }
  496. });
  497. },
  498. pdfReader:function(url,filename){
  499. filename = typeof filename == "undefined" ? "临时文件" : filename;
  500. var index = layer.open({
  501. type: 2,
  502. title: "查看PDF文件 - " + filename,
  503. area: ['80%', '80%'], //宽高
  504. fix: false, //不固定
  505. maxmin: true,
  506. content: url
  507. });
  508. return index;
  509. },
  510. showPdf : function(url,id,title){
  511. if(Feng.isEmptyStr(id)){
  512. id = "id";
  513. }
  514. if(Feng.isEmptyStr(title)){
  515. title = "预览";
  516. }
  517. let origin = window.location.origin;
  518. //let full_url = "https://fileview.jinjianghc.com/onlinePreview?url=" + encodeURIComponent(Base64.encode(url));
  519. var index = layer.open({
  520. id:id,
  521. type: 2,
  522. shade: 0,
  523. title: title,
  524. area: ['80%', '80%'], //宽高
  525. fix: false, //不固定
  526. maxmin: true,
  527. content: url,
  528. });
  529. // layer.full(index);
  530. },
  531. showExcel:function(url,id,title){
  532. window.location.href = url;
  533. },
  534. showFile:function(url,id,title){
  535. if(Feng.isEmptyStr(id)){
  536. id = "id";
  537. }
  538. if(Feng.isEmptyStr(title)){
  539. title = "预览";
  540. }
  541. var index = layer.open({
  542. id:id,
  543. type: 2,
  544. shade: 0,
  545. title: title,
  546. area: ['600px', '350px'], //宽高
  547. fix: false, //不固定
  548. maxmin: true,
  549. content: url,
  550. });
  551. },
  552. isEmptyStr:function(str) {
  553. if(str == null || str == ''){
  554. return true;
  555. }else{
  556. return false;
  557. }
  558. },
  559. isNotEmptyStr:function (str) {
  560. if(str!=null && str != ''){
  561. return true;
  562. }else{
  563. return false;
  564. }
  565. },
  566. checkAll:function (id) {
  567. $("#"+id+" input").each(function () {
  568. this.checked = true;
  569. })
  570. },
  571. unCheckAll :function(id) {
  572. $("#"+id+" input").each(function () {
  573. if(this.checked){
  574. this.checked = false;
  575. }else{
  576. this.checked = true;
  577. }
  578. })
  579. },
  580. showMiniFileModal:function (project,type,id) {
  581. layer.open({
  582. type: 2,
  583. title: "附件",
  584. shade: 0,
  585. resize:true,
  586. maxmin:true,
  587. // moveOut:true,
  588. id:"file",
  589. area: ['800px', '500px'],
  590. offset: 'rb', //右下角弹出content:
  591. shift: 2,
  592. content: Feng.ctxPath + "/api/common/gotoFileShow",
  593. zIndex: layer.zIndex,
  594. success:function (layero,index) {
  595. layer.setTop(layero);
  596. //按钮【按钮一】的回调
  597. var iframeWin = window[layero.find('iframe')[0]['name']];
  598. iframeWin.getFile(project,type,id);
  599. }
  600. });
  601. },
  602. getCheckBoxValues:function (str) { //获取checkbox值
  603. var val = "";
  604. $("#"+str+" input[name='"+str+"']").each(function () {
  605. if (this.checked) {
  606. val = val + $(this).val() + ",";
  607. }
  608. });
  609. return val.substring(0,val.length-1);
  610. },
  611. initDate:function () {
  612. $(".date").removeAttr('lay-key');
  613. $(".date").each(function(){
  614. laydate.render({
  615. elem: this
  616. ,type: 'date'
  617. ,trigger: 'click'
  618. });
  619. });
  620. },
  621. downloadFile:function (id,type) {
  622. window.location.href = Feng.ctxPath + "/common/api/downloadFile?id=" + id + "&type="+type;
  623. },
  624. bankChange:function (val,target){
  625. var bank = $("#"+val).val();
  626. if($.trim(bank)=='中国工商银行'){
  627. $("#"+target).val('102391050013');
  628. }else {
  629. $("#"+target).val('');
  630. }
  631. },
  632. chkFileInvalid:function(file,maxImageSize,maxFileSize,fileType,msg){
  633. var size = 0;
  634. if(typeof fileType != "undefined" && fileType != null){
  635. if(fileType.indexOf(file.type)<0){
  636. msg = typeof msg !="undefined"?msg:"不支持的文件类型";
  637. Feng.error(msg)
  638. return false;
  639. }
  640. }
  641. switch(file.type){
  642. case "image/jpeg":
  643. case "image/gif":
  644. case "image/png":
  645. case "image/jpg":
  646. size = maxImageSize * 1024 * 1024;//图片限制最大5M
  647. if(file.size > size){
  648. Feng.error("图片大小不能超过"+maxImageSize+"MB!");
  649. return false;
  650. }
  651. break;
  652. case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
  653. case "application/pdf":
  654. case "application/msword":
  655. case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
  656. case "application/vnd.ms-excel":
  657. case "application/zip":
  658. case "application/x-rar-compressed":
  659. case "application/x-7z-compressed":
  660. size = maxFileSize * 1024 * 1024;//其它允许文件类型限制最大均为10M
  661. if(file.size > size){
  662. Feng.error("文件大小不能超过"+maxFileSize+"MB!");
  663. return false;
  664. }
  665. break;
  666. default:
  667. Feng.error("文件类型不支持")
  668. return false;
  669. }
  670. return true;
  671. },
  672. isImg:function(type){
  673. var imgtypes = ["image/jpeg", "image/gif", "image/png", "image/jpg"];
  674. if(imgtypes.indexOf(type) > -1){
  675. return true;
  676. }
  677. return false;
  678. }
  679. };