Feng.js 27 KB

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