Feng.js 27 KB

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