managerjstool.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. //身份证号********格式化
  2. function idCardNoFmt(idCardNo) {
  3. if(idCardNo){
  4. var no = idCardNo;
  5. if(idCardNo.length==18){
  6. no = idCardNo.substr(0,18);
  7. var reg = /^(\d{6})\d{8}([0-9Xx]{4})$/;
  8. no = no.replace(reg, "$1********$2");
  9. return no;
  10. }else{
  11. return idCardNo;
  12. }
  13. }else{
  14. return idCardNo;
  15. }
  16. }
  17. //传入字段名,获取数据,并添加空值
  18. function addDefaultValue(value){
  19. var theArray = getListData(value);
  20. var temp = {
  21. id:"",
  22. text:"全部"
  23. };
  24. theArray.push(temp);
  25. return theArray;
  26. }
  27. //传入字段名,获取数据,并添加空值
  28. function addDefaultFilterValue(value){
  29. var theArray = getListData(value);
  30. var temp = {
  31. id:"",
  32. text:"全部"
  33. };
  34. theArray.push(temp);
  35. var temp1 = {
  36. id:"9999",
  37. text:"待受理",
  38. selected:true//设置默认值
  39. };
  40. theArray.unshift(temp1);//放到数组第一个
  41. return theArray;
  42. }
  43. //格式化时间
  44. function dateboxEtr() {
  45. return {
  46. type : 'datebox',
  47. options : {
  48. editable : false,
  49. required : true,
  50. panelHeight : 'auto'
  51. }
  52. };
  53. }
  54. //按照一定格式得到系统当前时间
  55. function getNowFormatDate() {
  56. var date = new Date();
  57. var currentTime = date.Format("yyyy-MM-dd hh:mm:ss");
  58. return currentTime;
  59. }
  60. Date.prototype.Format = function(format){
  61. var o = {
  62. "M+" : this.getMonth()+1, //month
  63. "d+" : this.getDate(), //day
  64. "h+" : this.getHours(), //hour
  65. "m+" : this.getMinutes(), //minute
  66. "s+" : this.getSeconds(), //second
  67. "q+" : Math.floor((this.getMonth()+3)/3), //quarter
  68. "S" : this.getMilliseconds() //millisecond
  69. };
  70. if(/(y+)/.test(format)) {
  71. format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
  72. }
  73. for(var k in o) {
  74. if(new RegExp("("+ k +")").test(format)) {
  75. format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
  76. }
  77. }
  78. return format;
  79. };
  80. /**
  81. * 格式化时间字符串
  82. * 20160329100310格式化为2016-03-29 10:03:10
  83. * 20160329格式化为2016-03-29
  84. * @param value
  85. * @returns
  86. */
  87. function timeFmt(value) {
  88. if(!value) {
  89. return value;
  90. }
  91. if (isNaN(value.toString().substring(0,1))){
  92. return value;
  93. }
  94. var fmtTime="";
  95. var time = value.toString();
  96. time=time.replace(/\-/g, "").replace(/\s+/g, "").replace(/\:/g, "");
  97. var year=time.substring(0,4);
  98. var month=time.substring(4,6);
  99. var day=time.substring(6,8);
  100. var hour=time.substring(8,10);
  101. var minute=time.substring(10,12);
  102. var second=time.substring(12,14);
  103. if(year && month && day) {
  104. fmtTime = fmtTime + year + "-" + month + "-" + day;
  105. }
  106. if(hour && minute && second) {
  107. fmtTime = fmtTime + " " + hour + ":" + minute + ":" + second;
  108. }
  109. return fmtTime;
  110. }
  111. /**
  112. * ajax 通信工具类(协议用到)
  113. *
  114. * @param transCode 交易码
  115. * @param servletName servlet名称
  116. * @param proNames proName字段
  117. * @param params 参数
  118. * @param fun_success
  119. * @param fun_error
  120. * @param isLoginOut
  121. */
  122. function syncAjaxCall2(transCode,servletName,proNames,params,fun_success, fun_error, isLoginOut) {
  123. if (params == null) {
  124. params = {};
  125. }
  126. __mask++;
  127. if (__mask >= 0) {
  128. showLoading(1);
  129. }
  130. url = sysWebAppName + servletName + '?transCode=' + transCode
  131. + '&clientToken=' + $.__token+'&proNames=' + proNames +'&channelNo=service';
  132. $
  133. .ajax({
  134. url : encodeURI(url),
  135. data : encodeURI(params || ''),
  136. type : "POST",
  137. contentType : "application/x-www-form-urlencoded; charset=utf-8",
  138. dataType : "text",
  139. timeout : ajaxTimeout,
  140. success : function(data) {
  141. data = $.parseJSON(data);
  142. __mask--;
  143. if (data == null)
  144. return;
  145. if (__mask == 0) {
  146. showLoading(-1);
  147. }
  148. if (data.returnCode == 'EB8000006') {
  149. if (isLoginOut) {
  150. fun_success && fun_success(data);
  151. } else {
  152. if (__login > 0)
  153. return;
  154. $.messager
  155. .confirm(
  156. '用户异常提示',
  157. '用户异常,是否重新登录。',
  158. function(r) {
  159. if (r) {
  160. $(
  161. ".leftcurtain",
  162. window.parent.document)
  163. .stop().animate({
  164. width : '50%'
  165. }, 1500);
  166. $(
  167. ".rightcurtain",
  168. window.parent.document)
  169. .stop().animate({
  170. width : '51%'
  171. }, 1500);
  172. $(
  173. ".login",
  174. window.parent.document)
  175. .show();
  176. $(
  177. ".login",
  178. window.parent.document)
  179. .find(
  180. "input[type=password]")
  181. .val("");
  182. $(
  183. ".login",
  184. window.parent.document)
  185. .find(
  186. "input[type=text]")
  187. .val("");
  188. parent.changeImage();
  189. __login--;
  190. } else {
  191. __login--;
  192. }
  193. });
  194. __login++;
  195. }
  196. } else {
  197. if (data.returnCode == successCode || data.success) {
  198. fun_success && fun_success(data);
  199. } else {
  200. if (fun_error) {
  201. fun_error && fun_error(data);
  202. }
  203. }
  204. }
  205. },
  206. error : function(XMLHttpRequest, textStatus, errorThrown) {
  207. __mask--;
  208. if (__mask == 0) {
  209. showLoading(-1);
  210. }
  211. if (fun_error) {
  212. fun_error
  213. && fun_error(XMLHttpRequest, textStatus,
  214. errorThrown);
  215. }
  216. }
  217. });
  218. }
  219. //添加远程数据
  220. function comboBoxChannel2(channelList,id,text) {
  221. return {
  222. type : 'combobox',
  223. options : {
  224. editable : false,
  225. required : true,
  226. data : channelList,
  227. valueField : id,
  228. textField : text,
  229. panelHeight : 'auto'
  230. }
  231. };
  232. }
  233. //获取当前登录用户的userId
  234. function getUserId() {
  235. return $.mapData.get("myUserId");
  236. }
  237. //获取当前登录用户的昵称
  238. function getNickName() {
  239. return $.mapData.get("myNickName");
  240. }
  241. // 获取人员列表
  242. function getUserList() {
  243. var userList=[]; //人员列表数据
  244. var userListTmp=[]; //人员列表数据
  245. //以下不直接返回List,不需要isList=1参数,直接加载使用,以下方式可以检测通讯故障
  246. crudAjaxCall('HS1001','rows=-1&proNames=userid&orderBy=userid',function(data){
  247. if(data){
  248. userListTmp = data.rows;
  249. if(userListTmp){
  250. for(var i=0; i < userListTmp.length;i++) {
  251. var tmp = {};
  252. var obj = {
  253. "id":userListTmp[i].userid,
  254. "text":userListTmp[i].username
  255. }
  256. userList.push(obj);
  257. }
  258. }
  259. }
  260. });
  261. return userList;
  262. }
  263. /**
  264. * ajax 通信工具类(异步)
  265. *
  266. * @param transCode 交易码
  267. * @param servletName servlet名称
  268. * @param proNames proName字段
  269. * @param params 参数
  270. * @param fun_success
  271. * @param fun_error
  272. * @param isLoginOut
  273. */
  274. function syncAjaxCallOfService(transCode,servletName,params,fun_success, fun_error, isLoginOut) {
  275. if (params == null) {
  276. params = {};
  277. }
  278. __mask++;
  279. if (__mask >= 0) {
  280. showLoading(1);
  281. }
  282. url = sysWebAppName + servletName + '?transCode=' + transCode
  283. + '&clientToken=' + $.__token +'&channelNo=service';
  284. $
  285. .ajax({
  286. url : encodeURI(url),
  287. data : encodeURI(params || ''),
  288. type : "POST",
  289. contentType : "application/x-www-form-urlencoded; charset=utf-8",
  290. dataType : "text",
  291. timeout : ajaxTimeout,
  292. success : function(data) {
  293. data = $.parseJSON(data);
  294. __mask--;
  295. if (data == null)
  296. return;
  297. if (__mask == 0) {
  298. showLoading(-1);
  299. }
  300. if (data.returnCode == 'EB8000006') {
  301. if (isLoginOut) {
  302. fun_success && fun_success(data);
  303. } else {
  304. if (__login > 0)
  305. return;
  306. $.messager
  307. .confirm(
  308. '用户异常提示',
  309. '用户异常,是否重新登录。',
  310. function(r) {
  311. if (r) {
  312. $(
  313. ".leftcurtain",
  314. window.parent.document)
  315. .stop().animate({
  316. width : '50%'
  317. }, 1500);
  318. $(
  319. ".rightcurtain",
  320. window.parent.document)
  321. .stop().animate({
  322. width : '51%'
  323. }, 1500);
  324. $(
  325. ".login",
  326. window.parent.document)
  327. .show();
  328. $(
  329. ".login",
  330. window.parent.document)
  331. .find(
  332. "input[type=password]")
  333. .val("");
  334. $(
  335. ".login",
  336. window.parent.document)
  337. .find(
  338. "input[type=text]")
  339. .val("");
  340. parent.changeImage();
  341. __login--;
  342. } else {
  343. __login--;
  344. }
  345. });
  346. __login++;
  347. }
  348. } else {
  349. if (data.returnCode == undefined || data.returnCode == successCode || data.success) {
  350. fun_success && fun_success(data);
  351. } else {
  352. if (fun_error) {
  353. fun_error && fun_error(data);
  354. }
  355. }
  356. }
  357. },
  358. error : function(XMLHttpRequest, textStatus, errorThrown) {
  359. __mask--;
  360. if (__mask == 0) {
  361. showLoading(-1);
  362. }
  363. if (fun_error) {
  364. fun_error
  365. && fun_error(XMLHttpRequest, textStatus,
  366. errorThrown);
  367. }
  368. }
  369. });
  370. }
  371. /**
  372. * ajax 通信工具类(同步)
  373. *
  374. * @param transCode 交易码
  375. * @param servletName servlet名称
  376. * @param proNames proName字段
  377. * @param params 参数
  378. * @param fun_success
  379. * @param fun_error
  380. * @param isLoginOut
  381. */
  382. function syncAjaxCallOfService2(transCode,servletName,params,fun_success, fun_error, isLoginOut) {
  383. if (params == null) {
  384. params = {};
  385. }
  386. __mask++;
  387. if (__mask >= 0) {
  388. showLoading(1);
  389. }
  390. url = sysWebAppName + servletName + '?transCode=' + transCode
  391. + '&clientToken=' + $.__token +'&channelNo=service';
  392. $
  393. .ajax({
  394. url : encodeURI(url),
  395. data : encodeURI(params || ''),
  396. type : "POST",
  397. contentType : "application/x-www-form-urlencoded; charset=utf-8",
  398. dataType : "text",
  399. async : false,
  400. success : function(data) {
  401. data = $.parseJSON(data);
  402. __mask--;
  403. if (data == null)
  404. return;
  405. if (__mask == 0) {
  406. showLoading(-1);
  407. }
  408. if (data.returnCode == 'EB8000006') {
  409. if (isLoginOut) {
  410. fun_success && fun_success(data);
  411. } else {
  412. if (__login > 0)
  413. return;
  414. $.messager
  415. .confirm(
  416. '用户异常提示',
  417. '用户异常,是否重新登录。',
  418. function(r) {
  419. if (r) {
  420. $(
  421. ".leftcurtain",
  422. window.parent.document)
  423. .stop().animate({
  424. width : '50%'
  425. }, 1500);
  426. $(
  427. ".rightcurtain",
  428. window.parent.document)
  429. .stop().animate({
  430. width : '51%'
  431. }, 1500);
  432. $(
  433. ".login",
  434. window.parent.document)
  435. .show();
  436. $(
  437. ".login",
  438. window.parent.document)
  439. .find(
  440. "input[type=password]")
  441. .val("");
  442. $(
  443. ".login",
  444. window.parent.document)
  445. .find(
  446. "input[type=text]")
  447. .val("");
  448. parent.changeImage();
  449. __login--;
  450. } else {
  451. __login--;
  452. }
  453. });
  454. __login++;
  455. }
  456. } else {
  457. if (data.returnCode == undefined || data.returnCode == successCode || data.success) {
  458. fun_success && fun_success(data);
  459. } else {
  460. if (fun_error) {
  461. fun_error && fun_error(data);
  462. }
  463. }
  464. }
  465. },
  466. error : function(XMLHttpRequest, textStatus, errorThrown) {
  467. __mask--;
  468. if (__mask == 0) {
  469. showLoading(-1);
  470. }
  471. if (fun_error) {
  472. fun_error
  473. && fun_error(XMLHttpRequest, textStatus,
  474. errorThrown);
  475. }
  476. }
  477. });
  478. }
  479. //提交表单
  480. function ajaxFormUpload(formId, transCode, fun_success, fun_error) {
  481. var url = sysWebAppName + 'TransServlet?transCode=' + transCode + '' + '&clientToken=' + $.__token + '&channelNo=service';
  482. var form = new FormData(document.getElementById(formId));
  483. $.ajax({
  484. type:"post",
  485. data:form,
  486. processData:false,
  487. contentType:false,
  488. url : encodeURI(url),
  489. timeout : ajaxTimeout,
  490. async : false,
  491. traditional : false,
  492. cache : false,
  493. ajaxSubmit : function() {
  494. return true;
  495. },
  496. success : function(result) {
  497. var data = (new Function("return " + result))();
  498. if (data.returnCode == 'EB8000006') {
  499. $.messager.confirm('用户异常提示', '用户异常,是否重新登录。',
  500. function(r) {
  501. if (r) {
  502. $(".leftcurtain",
  503. window.parent.document).stop()
  504. .animate({
  505. width : '50%'
  506. }, 1500);
  507. $(".rightcurtain",
  508. window.parent.document).stop()
  509. .animate({
  510. width : '51%'
  511. }, 1500);
  512. $(".login", window.parent.document)
  513. .show("slow").find(
  514. "input[type=password]")
  515. .val("");
  516. parent.changeImage();
  517. }
  518. });
  519. } else {
  520. if (data.returnCode == successCode) {
  521. fun_success && fun_success(data);
  522. } else {
  523. if (fun_error) {
  524. fun_error && fun_error(data);
  525. }
  526. }
  527. }
  528. },
  529. onLoadError : function() {
  530. $.messager.alert('系统错误', '网络或系统忙提交失败,请重试!', 'error');
  531. }
  532. });
  533. }
  534. //带毫秒的数 转成 yyyy-MM-dd HH:mm:ss.ms -->去掉毫秒
  535. function time2noms(value){
  536. if(value == '' || value == "" || value == undefined){
  537. return '暂无';
  538. }
  539. var theIndex = value.indexOf('.');
  540. if(theIndex != -1){
  541. return value.substring(0,theIndex);
  542. }else{
  543. return value;
  544. }
  545. }
  546. //格式化插件地址
  547. function formatAddr(value){
  548. var addrFrist = value.substr(0,(value.indexOf(',') - 1));
  549. var addrLast = value.substr(value.indexOf(',')+1);
  550. var fullAddr = addrFrist.replace(/ /g,'')+addrLast;
  551. return fullAddr;
  552. }
  553. function getDeptList() {
  554. return $.mapData.get("deptList");
  555. }
  556. function getDeptList2Select() {
  557. var deptList = getDeptList();
  558. var single = {
  559. id:"",
  560. text:"全部"
  561. };
  562. var result = [];
  563. result.push(single);
  564. for(var i=0;i<deptList.length;i++){
  565. var temp = {
  566. id:deptList[i].deptcode,
  567. text:deptList[i].deptname
  568. };
  569. result.push(temp);
  570. }
  571. return result;
  572. }
  573. function getValueByKey(keyType,key){
  574. //var deptList = getDeptList();
  575. var keyList = $.mapData.get(keyType);
  576. for(var i=0;i<keyList.length;i++){
  577. if(keyList[i] == key){
  578. return keyList[i];
  579. }
  580. }
  581. return key;
  582. }
  583. //版权证相关方法
  584. function getOwnerShipStandardArray(ownershipDetails,dataType){
  585. var strs= new Array(); //定义一数组
  586. var result = [];
  587. var obj = undefined;
  588. var isUse = false;
  589. var stdData = $.mapData.get(dataType);
  590. //var oriStr = this.ccaInfo.statusofownershipdetails;
  591. var oriStr = ownershipDetails;
  592. if(oriStr != undefined){
  593. strs=oriStr.split(","); //字符分割
  594. for ( var key in stdData) {
  595. for (var i=0;i<strs.length ;i++ ) {
  596. if(strs[i] ==key){
  597. obj = {
  598. "flag" : 1,
  599. "text" : stdData[key]
  600. };
  601. result.push(obj);
  602. isUse = true;
  603. break;
  604. }
  605. }
  606. if(!isUse){
  607. obj = {
  608. "flag" : 0,
  609. "text" : stdData[key]
  610. };
  611. result.push(obj);
  612. }
  613. isUse = false;
  614. }
  615. }
  616. return result;
  617. }
  618. //版权证 获取几个需要按顺序展示的标准数据
  619. function sortedStdData(){
  620. var command = 'userId=tourist&pageSize=-1&orderBy=CODE_TYPE,CODE_ORDER';
  621. command = command+'&channelNo=service';
  622. syncAjaxCall('HS0001',command,function(data){
  623. var d = data.record;
  624. var _stdDataTmp = undefined;
  625. var tempStr = 'ccacreativenature,ccaacquisitionofrights,ccarightownership,ccaType';
  626. for(index in d){
  627. if(tempStr.indexOf(d[index].codeType) != -1){
  628. if(_stdDataTmp == undefined) {
  629. _stdDataTmp = {};
  630. var tmp_list = new Array();
  631. var _tmp = {};
  632. //_tmp[1] = '否'
  633. _tmp[d[index].codeValue] = d[index].codeDesc;
  634. tmp_list.push(_tmp);
  635. _stdDataTmp[d[index].codeType] = tmp_list;
  636. } else {
  637. var codeType = d[index].codeType;
  638. if(_stdDataTmp[codeType] == null || _stdDataTmp[codeType] == undefined) {
  639. var _tmp = {};
  640. var tmp_list = new Array();
  641. _tmp[d[index].codeValue] = d[index].codeDesc;
  642. tmp_list.push(_tmp);
  643. _stdDataTmp[d[index].codeType] = tmp_list;
  644. } else {
  645. var _tmp = {};
  646. _tmp[d[index].codeValue] = d[index].codeDesc;
  647. _stdDataTmp[codeType].push(_tmp);
  648. }
  649. }
  650. }
  651. }
  652. sortStdData=_stdDataTmp;
  653. },function() {
  654. });
  655. }
  656. //版权证 获取几个需要按顺序展示的标准数据
  657. function getSortedListData(codetype) {
  658. var data = [];
  659. var stdData = sortStdData[codetype];
  660. if(stdData != null && stdData.length > 0){
  661. for ( var i = 0; i < stdData.length; i++) {
  662. for ( var key in stdData[i]) {
  663. var obj = {
  664. "codeValue" : key,
  665. "codeDesc" : stdData[i][key]
  666. };
  667. data.push(obj);
  668. }
  669. }
  670. }
  671. return data;
  672. };
  673. //处理2010-12-19 或者 2010-10-19 22:22:222形式的时间,转化成2010年10月19日
  674. function timeFmtZh(value){
  675. if(value != undefined && value != '' && value.indexOf("-") != -1){
  676. //截取时间
  677. temp = value.substr(0,10);
  678. var tempArray = temp.split("-");
  679. if(tempArray.length == 3){
  680. return tempArray[0]+"年"+tempArray[1]+"月"+tempArray[2]+"日";
  681. }else{
  682. return value;
  683. }
  684. }
  685. return value;
  686. };