common.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398
  1. var common = {
  2. pageSize: 10,
  3. type: "POST",
  4. param: {},
  5. getString: function (name) {
  6. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  7. var r = window.location.search.substr(1).match(reg);
  8. if (r != null) {
  9. return decodeURIComponent(r[2]);
  10. } else {
  11. return null;
  12. }
  13. },
  14. getUrl: function (urls) {
  15. if (cv == 1) {
  16. var n = (urls.split('/')).length - 1;
  17. if (n == 1) {
  18. urls = "../" + urls.substr(urls.lastIndexOf('/', urls.lastIndexOf('/') - 1) + 1);
  19. } else {
  20. urls = urls.substr(urls.lastIndexOf('/', urls.lastIndexOf('/') - 1) + 1);
  21. }
  22. } else {
  23. if (urls.indexOf('.html?') > 0) {
  24. urls = url.comMethod.getUrl + "?data=views/" + urls.replace(".html?", "&")
  25. } else {
  26. urls = url.comMethod.getUrl + "?data=views/" + urls.replace(".html", "")
  27. }
  28. }
  29. return urls
  30. },
  31. IEVersion: function () {
  32. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  33. var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
  34. var isEdge = userAgent.indexOf("Edge") > -1 && !isIE; //判断是否IE的Edge浏览器
  35. var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
  36. if (isIE) {
  37. var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
  38. reIE.test(userAgent);
  39. var fIEVersion = parseFloat(RegExp["$1"]);
  40. if (fIEVersion == 7) {
  41. return 7;
  42. } else if (fIEVersion == 8) {
  43. return 8;
  44. } else if (fIEVersion == 9) {
  45. return 9;
  46. } else if (fIEVersion == 10) {
  47. return 10;
  48. } else {
  49. return 6; //IE版本<=7
  50. }
  51. } else if (isEdge) {
  52. return 'edge'; //edge
  53. } else if (isIE11) {
  54. return 11; //IE11
  55. } else {
  56. return -1; //不是ie浏览器
  57. }
  58. },
  59. activeXHide: function (box) {
  60. document.getElementById(box).style.width = "0px";
  61. document.getElementById(box).style.height = "0px";
  62. },
  63. activeXShow: function (box, width, height) {
  64. // var box = document.getElementById(box)
  65. // box.style.display = "block"
  66. if (!width) {
  67. width = "100%"
  68. }
  69. if (!height) {
  70. height = "600px"
  71. }
  72. document.getElementById(box).style.width = width;
  73. document.getElementById(box).style.height = height;
  74. },
  75. getPath: function (file) { //获取file的真实地址
  76. var url = null;
  77. if (window.createObjcectURL != undefined) {
  78. url = window.createOjcectURL(file);
  79. } else if (window.URL != undefined) {
  80. url = window.URL.createObjectURL(file);
  81. } else if (window.webkitURL != undefined) {
  82. url = window.webkitURL.createObjectURL(file);
  83. }
  84. return url;
  85. },
  86. layerWin: function (title, width, height, url, type, box) {
  87. var _this = this;
  88. var obj = {
  89. btn: ["确定", "取消"],
  90. type: 2,
  91. area: [width, height],
  92. title: title,
  93. content: url,
  94. yes: function (index, layero) {
  95. var frameId = "#" + layero.find('iframe')[0].id;
  96. var sonTemp = $(frameId).contents();
  97. if (type == "organization") {
  98. _this.orWin(sonTemp, box)
  99. } else if (type == "business") {
  100. _this.businessWin(sonTemp, box)
  101. } else if (type == "jobNo") {
  102. _this.jobNoWin(sonTemp, box)
  103. }
  104. layer.close(index)
  105. }
  106. }
  107. layFun.layer(layer, obj)
  108. },
  109. orWin: function (sonTemp, box) {
  110. var inputB = box.parent().siblings("div").find("input")
  111. inputB.val(sonTemp.find(".groupName").val());
  112. inputB.attr("groupId", sonTemp.find(".groupId").val())
  113. if ($(".gong").length > 0) {
  114. $(".gong").click();
  115. }
  116. },
  117. businessWin: function (sonTemp, box) {
  118. sonTemp.find(".getS").click();
  119. var inputB = box.parent().siblings("div").find("input")
  120. inputB.val(sonTemp.find(".opName").val());
  121. inputB.attr("opCode", sonTemp.find(".opCodeHidden").val())
  122. $(".opCode").val(sonTemp.find(".opCodeHidden").val())
  123. },
  124. jobNoWin: function (sonTemp, box) {
  125. sonTemp.find(".getS").click();
  126. var inputB = box.parent().siblings("div").find("input")
  127. inputB.val(sonTemp.find(".opName").val());
  128. inputB.attr("workNo", sonTemp.find(".opCodeHidden").val())
  129. }
  130. }
  131. var publicFun = {
  132. getSSS:function(str){
  133. date = new Date(str);
  134. return date.getTime();
  135. },
  136. organiztionp: function (cmca_switch) {
  137. $(".organiztionp").on("click", function () {
  138. if ($(this).attr("deepN") || $(this).attr("deepn")) {
  139. win("组织结构", "730px", "460px", '../commonWin/organiztionWin.html?deepN=' + publicFun.getLogin("groupId"), $(this), cmca_switch)
  140. } else {
  141. win("组织结构", "730px", "460px", '../commonWin/organiztionWin.html', $(this), cmca_switch)
  142. }
  143. })
  144. function win(title, width, height, url, box, cmca_switch) {
  145. var obj = {
  146. btn: ["确定", "取消"],
  147. type: 2,
  148. area: [width, height],
  149. title: title,
  150. content: url,
  151. yes: function (index, layero) {
  152. var frameId = "#" + layero.find('iframe')[0].id;
  153. var sonTemp = parent.$(frameId).contents();
  154. gorup(sonTemp, box)
  155. parent.layer.close(index)
  156. },
  157. }
  158. layFun.parentLayer(layer, obj)
  159. }
  160. function gorup(sonTemp, box) {
  161. var inputB = box.parent().siblings("div").find("input")
  162. inputB.val(sonTemp.find(".groupName").val());
  163. inputB.attr("groupId", sonTemp.find(".groupId").val());
  164. if($(".roleIds").length>0){
  165. publicFun.userAct(publicFun.selectIn2,$(".roleIds"),"roleId","roleName",true,multiSelectInit,sonTemp.find(".groupId").val());
  166. }
  167. if($(".businessNo").length>0){
  168. box.parents("body").find('.businessNobtn').click();
  169. }
  170. if($(".templateId").length>0){
  171. box.parents("body").find('.templateIdBtn').click();
  172. }
  173. }
  174. },
  175. selectIn2: function (data, box, id, name, back,isxuanze) {
  176. var tagT = true;
  177. if(!isxuanze){
  178. var str = '<option value="" selected>请选择...</option>'
  179. }else if(isxuanze=="-1"){
  180. var str = '<option value="-1" selected>全部</option>'
  181. }else if(isxuanze=="-2"){
  182. var str = '<option value="0">签章服务平台</option>'
  183. tagT = false;
  184. }else if(isxuanze=="-3"){
  185. tagT = false;
  186. $.each(data, function (i, o) {
  187. if(o[id]==2){
  188. str += '<option value="' + o[id] + '">' + o[name] + '</option>'
  189. }
  190. })
  191. } else if(isxuanze=="-4"){
  192. var str = '<option value="0">请选择渠道</option>'
  193. }else{
  194. var str = '';
  195. }
  196. if(tagT){
  197. $.each(data, function (i, o) {
  198. str += '<option value="' + o[id] + '">' + o[name] + '</option>'
  199. })
  200. }
  201. box.html(str);
  202. back();
  203. },
  204. radioIn:function(data, box, id, name, tag, back,className){
  205. var str = '';
  206. $.each(data,function(i,o){
  207. if(i==0){
  208. var checked = "checked"
  209. }else{
  210. var checked = '';
  211. }
  212. str +=' <input type="radio" name="'+className+'" value="'+o[id]+'" title="'+o[name]+'" '+checked+'>'
  213. })
  214. box.html(str);
  215. if (tag) {
  216. back();
  217. }
  218. },
  219. comSelect:function(urls,fun,box,id,name,tag,back,isxuanze,data){//用户管理-用户状态下拉
  220. if(data){
  221. var obj = data;
  222. }else{
  223. var obj = {};
  224. }
  225. // var urls = url.urserManagement.other;
  226. publicFun.ajax(urls,common.type,obj,success);
  227. function success(data){
  228. fun(data.data,box,id,name,tag,back,isxuanze)
  229. }
  230. },
  231. getFile: function (obj, _this) { //返回路径
  232. var vison = common.IEVersion();
  233. var dataURL = null;
  234. if (vison > 9 || vison == -1) {
  235. var files = obj.pushFile();
  236. var file1 = null;
  237. $.each(files, function (i, o) {
  238. file1 = o
  239. })
  240. var windowURL = window.URL || window.webkitURL;
  241. dataURL = windowURL.createObjectURL(file1);
  242. } else {
  243. dataURL = $("[name=" + _this.field + ']').val()
  244. }
  245. return dataURL;
  246. },
  247. getLogin: function (wen) {
  248. var obj = null;
  249. try {
  250. obj = JSON.parse($.cookie('getLogin'));
  251. if(!obj){
  252. return ''
  253. }
  254. return obj[wen]
  255. }
  256. catch(err){
  257. return ''
  258. location.href = "./views/login-1.html"
  259. }
  260. },
  261. ajax: function (pObj,success,error) {
  262. //obj.url 请求地址
  263. //obj.data 请求数据
  264. //success 成功回调
  265. //error 失败回调
  266. // let defaultObj = {
  267. // type:"post",
  268. // }
  269. var obj_ajax = {
  270. pageSize:10,
  271. isWait:false,
  272. messageTag:false,
  273. type:"post"
  274. };
  275. pObj = $.extend({},obj_ajax,pObj);
  276. $.each(pObj.data, function (i, o) { //为了去除ie8 空字符串传到后台变为null的问题
  277. if (o === "") {
  278. pObj.data[i] = ""
  279. }
  280. })
  281. if (!pObj.isWait) {
  282. var coverIndex = layer.load(1, {
  283. shade: [0.1, '#fff'] //0.1透明度的白色背景
  284. });
  285. }
  286. if(pObj.type=="get"){
  287. var req = pObj.data;
  288. }else{
  289. var req = JSON.stringify(pObj.data);
  290. }
  291. var url = ''
  292. if(pObj.url.indexOf("?")!=-1){
  293. url= pObj.url + "&t=" + Math.random()
  294. }else{
  295. url= pObj.url + "?t=" + Math.random()
  296. }
  297. jQuery.support.cors = true;
  298. $.ajax({
  299. type: pObj.type,
  300. url:url ,
  301. dataType:"json",
  302. cache: false,
  303. async: true,
  304. headers: {
  305. 'agileauthtoken': util.getToken()
  306. },
  307. contentType: "application/json; charset=utf-8",
  308. data:req,
  309. success: function (data) {
  310. if (!pObj.isWait) {
  311. layer.close(coverIndex)
  312. }
  313. if (!data) {
  314. return false;
  315. }
  316. if (typeof data == 'string') {
  317. data = JSON.parse(data);
  318. }
  319. // if (data.result == 0) {
  320. success(data)
  321. // } else {
  322. // if (pObj.messageTag) {
  323. // layer.msg(data.message)
  324. // } else {
  325. // layer.msg("请求失败")
  326. // }
  327. // }
  328. },
  329. error: function (data) {
  330. if (!pObj.isWait) {
  331. layer.close(coverIndex)
  332. }
  333. layer.msg("请求失败")
  334. }
  335. });
  336. },
  337. inputParam: function (box) {//自动组装表单数据
  338. var obj = {};
  339. $.each(box.find("[name]"), function () {
  340. if($(this).attr("type")=="radio"){
  341. obj[$(this).attr("name")] = box.find('input[name='+$(this).attr("name")+']:checked').val();
  342. }else{
  343. obj[$(this).attr("name")] = $(this).val();
  344. }
  345. })
  346. return obj;
  347. } ,
  348. verify: function (box, veri) {//表单校验
  349. var str = false;
  350. var pin = box.find("[lay-verify]");
  351. pin.each(function (i, o) {
  352. if($(this).attr("isVer")){
  353. return true;
  354. }
  355. if ($(this)[0].tagName == "INPUT" || $(this)[0].tagName == "TEXTAREA") {
  356. var value1 = $(this).val()
  357. } else if ($(this)[0].tagName == "SELECT") {
  358. var value1 = $(this).find("option:selected").html();
  359. }
  360. var v = $(this).attr("lay-verify")
  361. if (v) {
  362. if (veri[v] instanceof Function) {
  363. str = veri[v](value1, $(this))
  364. if (str) {
  365. $(this).focus().addClass("layui-form-danger")
  366. return false;
  367. }
  368. } else if (veri[v] instanceof Array) {
  369. if (veri[v][0].test(value1)) {
  370. return veri[v][1];
  371. }
  372. if (str) {
  373. return false;
  374. }
  375. }
  376. }
  377. })
  378. return str;
  379. },
  380. downTap: function (urls, obj, urls2, tag) {
  381. var str = '';
  382. $.each(obj, function (i, o) {
  383. str += '&' + i + "=" + o;
  384. })
  385. str = str.replace("&", "")
  386. if ($("#downTap").length == 0) {
  387. var str1 = '<a href="" class="dpn" id="downTap"> 导出下载</a>'
  388. $("body").append(str1)
  389. }
  390. $("#downTap").attr({
  391. "href": urls + "?" + str
  392. })
  393. if (urls2) {
  394. publicFun.ajax(urls2, common.type, obj, fun1)
  395. function fun1(data) {
  396. if (data.data.length > 0) {
  397. document.getElementById("downTap").click();
  398. } else {
  399. layer.msg("无数据可导出")
  400. }
  401. }
  402. } else {
  403. document.getElementById("downTap").click();
  404. }
  405. },
  406. getOrgTree:function(tree,treeObj){
  407. var obj = {};
  408. var urls = url.organization.allTree;
  409. var ajaxObj = {
  410. url: urls,// 请求地址
  411. data: obj
  412. }
  413. this.ajax(ajaxObj, function(data){
  414. treefun(data)
  415. });
  416. function treefun(data){
  417. $.each(data,function(i,o){
  418. o.id = o.groupId;
  419. o.field = o.groupName;
  420. o.title = o.groupName;
  421. if(o.leafFlag=="N"){
  422. o.child = [];
  423. }
  424. })
  425. var inst1 = tree.render({
  426. elem: treeObj.elem //绑定元素
  427. ,data: data
  428. });
  429. }
  430. },
  431. organization: function (success,type,dtree,checkedTag,form) { //组织机构
  432. var obj = {
  433. isWithHall: "",
  434. rootId: ""
  435. };
  436. var urls = url.organization.getNodes;
  437. var ajaxObj = {
  438. url: urls,// 请求地址
  439. data: obj
  440. }
  441. this.ajax(ajaxObj, function(data){
  442. success(data,type,dtree,checkedTag,form)
  443. });
  444. },
  445. treeNode: function (data,type,dtree,checkedTag,form) {
  446. var obj = {};
  447. try {
  448. sealIds = sealIds.data
  449. } catch (error) {
  450. }
  451. $.each(data,function(i,o){
  452. // o.children =[] //data.childrens;
  453. // o.id = o.groupId;
  454. o.parentId = o.pid;
  455. o.title = o.name;
  456. if(o.isParent=="true"){
  457. o.last = false;
  458. }else{
  459. o.last = true;
  460. }
  461. o.spread =false;
  462. if(checkedTag){
  463. o.checkArr = [
  464. {"type": "0", "checked": "0"}
  465. ]
  466. o.checked = 0;
  467. try {
  468. $.each(sealIds,function(d,j){
  469. if(j==o.departNumber){
  470. o.checkArr = [
  471. {"type": "0", "checked": "1"}
  472. ]
  473. o.checked = 1;
  474. return false;
  475. }
  476. })
  477. } catch (error) {
  478. }
  479. }
  480. })
  481. obj.data=data
  482. tree(obj);
  483. function tree(obj){
  484. var DemoTree = dtree.render({
  485. elem: "#ag-tree",
  486. data: obj.data,
  487. dot: false, // 隐藏小圆点
  488. checkbar: checkedTag,
  489. checkbarType:"self",
  490. dataFormat: "list", //配置data的风格为list
  491. skin: "layui",
  492. async:false,
  493. });
  494. dtree.on("node('ag-tree')" ,function(obj){
  495. //layer.msg(JSON.stringify(obj.param));
  496. var treeNode = obj.param
  497. if(type==1){
  498. var obj21 = {
  499. url:url.organization.findById,
  500. type:"get",
  501. data:{
  502. groupId:treeNode.nodeId
  503. }
  504. }
  505. publicFun.ajax(obj21,success2)
  506. function success2(data){
  507. // form.val("winId", {
  508. // "describe":data.describe,
  509. // "groupId":data.groupId ,
  510. // "groupIdPks":data.groupIdPks,
  511. // "leafFlag":data.leafFlag ,
  512. // "groupName":data.groupName,
  513. // "parentGroupId":data.parentGroupId ,
  514. // "validFlag":data.validFlag
  515. // })
  516. $(".describe").val(data.describe);
  517. $(".groupId").val(data.groupId);
  518. $(".groupIdPks").val(data.groupIdPks);
  519. $(".groupName").val(data.groupName);
  520. $(".leafFlag").val(data.leafFlag);
  521. $(".parentGroupId").val(data.parentGroupId);
  522. $(".validFlag").val(data.validFlag);
  523. form.render();
  524. }
  525. }else{
  526. if(treeNode){
  527. $(".groupId").val(treeNode.nodeId);
  528. $(".groupName").val(treeNode.context);
  529. }
  530. }
  531. });
  532. dtree.on("changeTree('ag-tree')" ,function(treeobj){
  533. if(!treeobj.show){
  534. return false;
  535. }
  536. var obj1 = treeobj.param;
  537. var obj2 = {
  538. url:url.organization.getNodes,
  539. type:"get",
  540. data:{
  541. parentId:obj1.nodeId,
  542. n:obj1.context,
  543. lv: obj1.level-1,
  544. isWithHall:"" ,
  545. rootId:""
  546. }
  547. }
  548. publicFun.ajax(obj2,success)
  549. function success(data1){
  550. var objA = data1
  551. if(objA.length == 0){
  552. return false;
  553. }
  554. $.each(objA,function(i,o){
  555. o.parentId = o.pid;
  556. o.title = o.name;
  557. if(o.isParent=="true"){
  558. o.last = false;
  559. }else{
  560. o.last = true;
  561. }
  562. o.spread =false;
  563. if(checkedTag){
  564. o.checkArr = [
  565. {"type": "0", "checked": "0"}
  566. ]
  567. o.checked = 0;
  568. try {
  569. $.each(sealIds,function(d,j){
  570. if(j==o.departNumber){
  571. o.checkArr = [
  572. {"type": "0", "checked": "1"}
  573. ]
  574. o.checked = 1;
  575. return false;
  576. }
  577. })
  578. } catch (error) {
  579. }
  580. }
  581. })
  582. var $div = DemoTree.getNodeDom(obj1.nodeId).div()
  583. DemoTree.partialRefreshAdd($div,objA)
  584. // dtree.reload(DemoTree, {
  585. // data: obj.data,
  586. // dot: false, // 隐藏小圆点
  587. // checkbar: checkedTag,
  588. // dataFormat: "list", //配置data的风格为list
  589. // skin: "layui" ,
  590. // });
  591. }
  592. });
  593. }
  594. },
  595. }
  596. var layFun = {
  597. startTime: null,
  598. endTime: null,
  599. layData:function(startTime,endTime,pCom,obj,tag){
  600. if(!obj){
  601. return false;
  602. }
  603. if(tag=="1"){
  604. }else{
  605. if(obj.elem=="#startTime"||obj.elem=="#timeInstar"||obj.elem=="#timeStart"||obj.elem=="#startIn"){
  606. obj.btns= ['confirm']
  607. obj.max = 0;
  608. obj.min = '2013-1-1 00:00:00'
  609. obj.btns= ['confirm']
  610. obj.done= function(value, date){
  611. // //{"year":2018,"month":9,"date":7,"hours":0,"minutes":0,"seconds":0}
  612. // // layer.alert('你选择的日期是:' + value + '<br>获得的对象是' + JSON.stringify(date));
  613. var a1=date.year%4==0;
  614. var a2=date.year%100!=0;
  615. var a3=date.year%400==0;
  616. var DD = 31;
  617. if(date.month==4||date.month==6||date.month==9||date.month==10){
  618. DD = 30;
  619. }
  620. if((a1&&a2)||a3){//闰年 判断是平年还是闰年
  621. if(date.month==2){
  622. DD = 29;
  623. }
  624. }else{
  625. if(date.month==2){
  626. DD = 28;
  627. }
  628. }
  629. var myDate = new Date();
  630. var yyyy=myDate.getFullYear();
  631. var mm=myDate.getMonth()+1;
  632. var DD3 = myDate.getDate();
  633. if(date.year==yyyy&&mm==date.month){
  634. DD = DD3;
  635. if(DD<10){
  636. DD = "0"+DD
  637. }
  638. }
  639. if(date.month<10){
  640. date.month = "0"+date.month;
  641. }
  642. if(date.date<10){
  643. date.date = "0"+date.date;
  644. }
  645. var endT = date.year+"-"+date.month+"-"+DD+" 23:59:59"
  646. if(layFun.endTime){
  647. layFun.endTime.config.max ={
  648. year:date.year,
  649. month:date.month-1, //关键
  650. date: DD,
  651. hours: 23,
  652. minutes: 59,
  653. seconds : 59
  654. };
  655. layFun.endTime.config.min ={
  656. year:date.year,
  657. month:date.month-1, //关键
  658. date: date.date
  659. };
  660. }
  661. $(endTime).val(endT)
  662. }
  663. layFun.startTime = pCom.render(obj);
  664. }else if(obj.elem=="#endTime"||obj.elem=="#endInstar"||obj.elem=="#timeEnd"||obj.elem=="#startEnd"){
  665. obj.max = 1;
  666. obj.btns= ['confirm'];
  667. // obj.min = common.startTime
  668. layFun.endTime = pCom.render(obj);
  669. }
  670. }
  671. },
  672. layData7: function (startTime, endTime, pCom, obj, tag) {
  673. if (!obj) {
  674. return false;
  675. }
  676. if (tag == "1") {
  677. } else {
  678. if (obj.elem == "#startTime" ) {
  679. obj.btns = ['confirm']
  680. obj.max = 1;
  681. obj.done = function (value, date) {
  682. var nowTime = new Date().getTime();
  683. var startTime = NewDate(value).getTime();
  684. var endTime7 = startTime + (60000 * 60 * 24 * 7);
  685. if (endTime7 > nowTime) {
  686. endTime7 = nowTime;
  687. }
  688. var endTimeCopy = endTime7
  689. endTime7 = hsDate(endTime7, tag)
  690. var yyyy = hsDate(endTimeCopy, "yyyy")
  691. var month = hsDate(endTimeCopy, "month")
  692. var date1 = hsDate(endTimeCopy, "date")
  693. layFun.endTime.config.max = {
  694. year: yyyy,
  695. month: month - 1,
  696. date: date1
  697. };
  698. layFun.endTime.config.min = {
  699. year: date.year,
  700. month: date.month - 1,
  701. date: date.date
  702. };
  703. $(endTime).val(endTime7)
  704. }
  705. layFun.startTime = pCom.render(obj);
  706. } else if (obj.elem == "#endTime") {
  707. obj.btns = ['confirm']
  708. obj.max = 1;
  709. obj.min = common.time7Start
  710. layFun.endTime = pCom.render(obj);
  711. }
  712. }
  713. },
  714. layer: function (layer, obj, success, error) {
  715. var funObj = obj;
  716. // if (!funObj.offset) {
  717. // funObj.offset = '30px'
  718. // }
  719. // obj.content = common.getUrl(obj.content)
  720. obj.btnAlign = 'c'
  721. obj.shadeClose = true;
  722. layer.open(funObj)
  723. },
  724. parentLayer: function (layer, obj, success, error) {
  725. var funObj = obj;
  726. // obj.content = common.getUrl(obj.content)
  727. if (!funObj.offset) {
  728. funObj.offset = '30px'
  729. }
  730. obj.btnAlign = 'c';
  731. obj.shadeClose = true;
  732. parent.layer.open(funObj)
  733. },
  734. tableRender: function (table, laypage, data, arr) {
  735. var page = {
  736. elem: 'ag-area-page',
  737. count: 1, //data.totalResultNumber
  738. limit: 10,
  739. groups: 5,
  740. layout: ['prev', 'page', 'next', 'count', 'skip'],
  741. // theme: '#44ade5',
  742. curr: "1",
  743. jump: function (obj, first) {
  744. //obj包含了当前分页的所有参数,比如:
  745. //首次不执行
  746. if (!first) {
  747. $(".pageNo").val(obj.curr)
  748. $(".ag-btn-query").click();
  749. //page.curr = $(".pageNo").val();
  750. $(".pageNo").val(1)
  751. }
  752. }
  753. }
  754. page.count = data.totalRecord
  755. page.curr = data.pageNo;
  756. laypage.render(page);
  757. $.each(arr,function(i,o){
  758. o.align = "center"
  759. })
  760. table.render({
  761. elem: '#ag-table',
  762. id: 'idTest',
  763. // height: 500,
  764. data: data.data
  765. //,url: '/static/layui/json/page.json' //数据接口
  766. ,
  767. toolbar: '#ag-table-header',
  768. limit: 10,
  769. skin: 'line' //行边框风格
  770. ,even: true //开启隔行背景
  771. //,size: 'sm' //小尺寸的表格
  772. ,cols: [
  773. arr
  774. ],
  775. text: {
  776. none: '没有查询到符合条件的记录' //默认:无数据。注:该属性为 layui 2.2.5 开始新增
  777. }
  778. });
  779. },
  780. }
  781. var verify = {
  782. username: function (value, item) { //value:表单的值、item:表单的DOM对象
  783. if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
  784. return '用户名不能有特殊字符';
  785. }
  786. if (/(^\_)|(\__)|(\_+$)/.test(value)) {
  787. return '用户名首尾不能出现下划线\'_\'';
  788. }
  789. if (/^\d+\d+\d$/.test(value)) {
  790. return '用户名不能全为数字';
  791. }
  792. }
  793. //我们既支持上述函数式的方式,也支持下述数组的形式
  794. //数组的两个值分别代表:[正则匹配、匹配不符时的提示文字]
  795. ,
  796. pass: [
  797. /^[\S]{6,12}$/, '密码必须6到12位,且不能出现空格'
  798. ],
  799. phoneNo: function (value, item) {
  800. if (value.length != 0) {
  801. if (/^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$/.test(value)) {
  802. return '请填写正确手机号码';
  803. }
  804. }
  805. if (value.length == 0) {
  806. return '请填写正确手机号码';
  807. }
  808. },
  809. opcode:function (value, item) {
  810. if (value.length != 0) {
  811. if (!/^[a-zA-Z0-9]{1,20}$/.test(value)) {
  812. return '业务编码为20以下数字,字母或组合';
  813. }
  814. }else{
  815. return '请填写业务编码';
  816. }
  817. },
  818. requiredM: function (value, item) {
  819. if (!value || value == 0 || value == "请选择..."||value=='') {
  820. return '必填项不能为空';
  821. }
  822. },
  823. isChar:function (value, item) {
  824. if (value.length != 0) {
  825. if (/[\u4e00-\u9fa5]/g.test(value)) {
  826. return '规则编码不能填写中文';
  827. }
  828. }else{
  829. return '必填项不能为空';
  830. }
  831. }
  832. }
  833. //公共按钮点击区
  834. layui.use(['form', 'laydate', 'table', 'laypage', 'layer', 'element'], function () {
  835. var form = layui.form;
  836. var laydate = layui.laydate;
  837. var table = layui.table;
  838. var laypage = layui.laypage;
  839. var layer = layui.layer;
  840. $("#ag-table").parents(".layui-card").addClass("p100")
  841. $(".organiztion").on("click", function () {
  842. if ($(this).attr("deepN") || $(this).attr("deepn")) {
  843. var str = '?deepN=' + publicFun.getLogin("groupId")
  844. } else {
  845. var str = ''
  846. }
  847. common.layerWin("组织结构", "730px", "460px", '../commonWin/organiztionWin.html' + str, "organization", $(this))
  848. })
  849. $(".business").on("click", function () {
  850. common.layerWin("业务类型", "800px", "460px", '../commonWin/businessWin.html', "business", $(this))
  851. })
  852. $(".jobNoBtn").on("click", function () {
  853. common.layerWin("工号", "800px", "460px", '../commonWin/jobNoWin.html', "jobNo", $(this))
  854. })
  855. $(".cleanInput").on("click", function () {
  856. var inputbox = $(this).parent().siblings("div").find("input");
  857. if (inputbox.attr("ignore") == 1) {
  858. inputbox.val(inputbox.attr("init-value"));
  859. inputbox.attr("groupid", inputbox.attr("init-value2"))
  860. } else {
  861. inputbox.val("").removeAttr("groupid").removeAttr("opcode");
  862. $(".opCode").val("")
  863. }
  864. })
  865. $("[type=reset]").on("click", function () {
  866. $(this).parents(".layui-form ").find("input").removeAttr("groupid").removeAttr("opcode")
  867. $(".opCode").val("")
  868. });
  869. $("[reset=true]").on("click", function () {
  870. var pBox = $(this).parents(".layui-form ")
  871. pBox.find("[ignore=2]").val("").removeAttr("groupid").removeAttr("opcode"); //无限制的直接清空
  872. pBox.find("[ignore=3]").find("option:first").prop("selected", true) //select框清空
  873. $.each(pBox.find("[ignore=4]"), function () {
  874. $(this).find("option[value=" + $(this).attr("init-value") + "]").prop("selected", true)
  875. })
  876. pBox.find("[ignore=1]").val("");
  877. $.each(pBox.find("[ignore=1]"), function () { //不能清空有默认值
  878. if ($(this).attr("inputT") == "zzjg") {
  879. $(this).attr("groupid", $(this).attr("init-value2"))
  880. }
  881. var ids = $(this).attr("id");
  882. if (ids == "endTime" || ids == "endInstar" || ids == "timeEnd" || ids == "startEnd") {
  883. var endTimeCopy = layFun.startTime.config.value;
  884. var yyyy = hsDate(endTimeCopy, "yyyy")
  885. var month = hsDate(endTimeCopy, "month")
  886. var date1 = hsDate(endTimeCopy, "date")
  887. layFun.endTime.config.min = {
  888. year: yyyy,
  889. month: month - 1,
  890. date: date1
  891. };
  892. var endTimeCopy = $(this).attr("init-value");
  893. var yyyy1 = hsDate(endTimeCopy, "yyyy")
  894. var month1 = hsDate(endTimeCopy, "month")
  895. var date11 = hsDate(endTimeCopy, "date")
  896. layFun.endTime.config.max = {
  897. year: yyyy1,
  898. month: month1 - 1,
  899. date: date11 + 1
  900. };
  901. }
  902. $(this).val($(this).attr("init-value"));
  903. })
  904. $(".opCode").val("")
  905. layui.form.render('select');
  906. })
  907. $(document).keyup(function(event){
  908. if(event.keyCode ==13){
  909. $(".ag-btn-query").trigger("click");
  910. }
  911. });
  912. $('.ag-tab-title').on("click","li",function(){
  913. $(this).addClass("ag-this").siblings("li").removeClass("ag-this");
  914. console.log($(this).index())
  915. })
  916. })
  917. var TimeUtil = {
  918. timeChangehs:function(str){
  919. var time = new Date(str.replace("-", "/").replace("-", "/"));
  920. return time
  921. },
  922. hsDate: function (str) {
  923. var oDate = NewDate(str),
  924. oYear = oDate.getFullYear(),
  925. oMonth = oDate.getMonth() + 1,
  926. oDay = oDate.getDate();
  927. var oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay) + " 00:00:00"; //最后拼接时间
  928. function getzf(num) {
  929. if (parseInt(num) < 10) {
  930. num = '0' + num;
  931. }
  932. return num;
  933. }
  934. return oTime
  935. },
  936. formatTime: function (dateTime) {
  937. //var dateTime = 1544683901;
  938. if (dateTime) {
  939. var d = new Date(dateTime),
  940. str = '';
  941. var _month = d.getMonth() + 1;
  942. if (_month < 10) {
  943. _month = "0" + _month;
  944. }
  945. var _gDate = d.getDate();
  946. if (_gDate < 10) {
  947. _gDate = "0" + _gDate;
  948. }
  949. var _hours = d.getHours();
  950. if (_hours < 10) {
  951. _hours = "0" + _hours;
  952. }
  953. var _minutes = d.getMinutes();
  954. if (_minutes < 10) {
  955. _minutes = "0" + _minutes;
  956. }
  957. var _seconds = d.getSeconds();
  958. if (_seconds < 10) {
  959. _seconds = "0" + _seconds;
  960. }
  961. str += d.getFullYear() + '-';
  962. str += _month + '-';
  963. str += _gDate + ' ';
  964. str += _hours + ':';
  965. str += _minutes + ':';
  966. str += _seconds + ' ';
  967. } else {
  968. return "-";
  969. }
  970. return str
  971. },
  972. getYYYMMHHSS: function (dateTime) {
  973. var datetime = "-";
  974. if (dateTime != null && dateTime != "" && dateTime != "undefined" && dateTime != "null") {
  975. var d = new Date(dateTime),
  976. str = '';
  977. var td = d.getDay();
  978. var _month = d.getMonth() + 1;
  979. if (_month < 10) {
  980. _month = "0" + _month;
  981. }
  982. var _gDate = d.getDate();
  983. if (_gDate < 10) {
  984. _gDate = "0" + _gDate;
  985. }
  986. var _hours = d.getHours();
  987. if (_hours < 10) {
  988. _hours = "0" + _hours;
  989. }
  990. var _minutes = d.getMinutes();
  991. if (_minutes < 10) {
  992. _minutes = "0" + _minutes;
  993. }
  994. var _seconds = d.getSeconds();
  995. if (_seconds < 10) {
  996. _seconds = "0" + _seconds;
  997. }
  998. str += d.getFullYear() + '-';
  999. str += _month + '-';
  1000. str += _gDate + ' ';
  1001. str += _hours + ':';
  1002. str += _minutes + ':';
  1003. str += _seconds ;
  1004. } else {
  1005. return "-";
  1006. }
  1007. return str
  1008. },
  1009. getYYYMMHH: function (dateTime) {
  1010. var datetime = "-";
  1011. if (dateTime != null && dateTime != "" && dateTime != "undefined") {
  1012. var d = new Date(dateTime),
  1013. str = '';
  1014. var td = d.getDay();
  1015. var _month = d.getMonth() + 1;
  1016. if (_month < 10) {
  1017. _month = "0" + _month;
  1018. }
  1019. var _gDate = d.getDate();
  1020. if (_gDate < 10) {
  1021. _gDate = "0" + _gDate;
  1022. }
  1023. str += d.getFullYear() + '-';
  1024. str += _month + '-';
  1025. str += _gDate + ' ';
  1026. }
  1027. return str
  1028. },
  1029. getNowTime: function (dStr) {
  1030. //当前系统时间
  1031. var d = new Date(),
  1032. str = '';
  1033. var td = d.getDay();
  1034. var _month = d.getMonth() + 1;
  1035. if (_month < 10) {
  1036. _month = "0" + _month;
  1037. }
  1038. var _gDate = d.getDate();
  1039. if (_gDate < 10) {
  1040. _gDate = "0" + _gDate;
  1041. }
  1042. var _hours = d.getHours();
  1043. if (_hours < 10) {
  1044. _hours = "0" + _hours;
  1045. }
  1046. var _minutes = d.getMinutes();
  1047. if (_minutes < 10) {
  1048. _minutes = "0" + _minutes;
  1049. }
  1050. var _seconds = d.getSeconds();
  1051. if (_seconds < 10) {
  1052. _seconds = "0" + _seconds;
  1053. }
  1054. str += d.getFullYear() + '-';
  1055. str += _month;
  1056. // str += _gDate + ' ';
  1057. // str += _hours + ':';
  1058. // str += _minutes + ':';
  1059. // str += _seconds + ' ';
  1060. return str
  1061. },
  1062. getNowTimeHour: function () {
  1063. //当前系统时间
  1064. var d = new Date(),
  1065. str = '';
  1066. var td = d.getDay();
  1067. var _month = d.getMonth() + 1;
  1068. if (_month < 10) {
  1069. _month = "0" + _month;
  1070. }
  1071. var _gDate = d.getDate();
  1072. if (_gDate < 10) {
  1073. _gDate = "0" + _gDate;
  1074. }
  1075. var _hours = d.getHours();
  1076. if (_hours < 10) {
  1077. _hours = "0" + _hours;
  1078. }
  1079. var _minutes = d.getMinutes();
  1080. if (_minutes < 10) {
  1081. _minutes = "0" + _minutes;
  1082. }
  1083. var _seconds = d.getSeconds();
  1084. if (_seconds < 10) {
  1085. _seconds = "0" + _seconds;
  1086. }
  1087. str += d.getFullYear() + '-';
  1088. str += _month + '-';
  1089. str += _gDate + ' ';
  1090. str += _hours;
  1091. return str
  1092. },
  1093. getNowTimeStr: function () {
  1094. //当前系统时间
  1095. var d = new Date(),
  1096. str = '';
  1097. var td = d.getDay();
  1098. var _month = d.getMonth() + 1;
  1099. if (_month < 10) {
  1100. _month = "0" + _month;
  1101. }
  1102. var _gDate = d.getDate();
  1103. if (_gDate < 10) {
  1104. _gDate = "0" + _gDate;
  1105. }
  1106. var _hours = d.getHours();
  1107. if (_hours < 10) {
  1108. _hours = "0" + _hours;
  1109. }
  1110. var _minutes = d.getMinutes();
  1111. if (_minutes < 10) {
  1112. _minutes = "0" + _minutes;
  1113. }
  1114. var _seconds = d.getSeconds();
  1115. if (_seconds < 10) {
  1116. _seconds = "0" + _seconds;
  1117. }
  1118. str += d.getFullYear() + '';
  1119. str += _month + '';
  1120. str += _gDate + '';
  1121. str += _hours + '';
  1122. str += _minutes + '';
  1123. str += _seconds + '';
  1124. return str
  1125. },
  1126. getRightTime: function (str) {
  1127. var str1 = str.substring(0, 4) + "-" + str.substring(4, 6) + "-" + str.substring(6, 8) + " " + str.substring(8, 10) + ":" + str.substring(10, 12) + ":" + str.substring(12, 14)
  1128. return str1
  1129. }
  1130. }
  1131. var publicParams={
  1132. yesNot:[
  1133. {title:"是",value:"是"},
  1134. {title:"否",value:"否"}
  1135. ],
  1136. yesNotYN:[
  1137. {title:"是",value:"Y"},
  1138. {title:"否",value:"N"}
  1139. ]
  1140. }