processNotTextArea.js 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632
  1. function reActive(){
  2. //激活tabpanel
  3. var cls = 'active';
  4. $('.nav-tabs>li>a').click(function(){
  5. if(!$(this).hasClass(cls)) {
  6. var nav = $(this).parent().parent(), bd = nav.next(),
  7. old = nav.children('.' + cls).index(),
  8. index = $(this).parent().index();
  9. $('.tab-pane:eq(' + old + ')', bd).removeClass(cls);
  10. $('.tab-pane:eq(' + index + ')', bd).addClass(cls);
  11. var width = $('#topToolbar').width()-$('.nav-tabs>li:eq('+index+')').attr("oldwidth")-2;
  12. var lis = $('.nav-tabs>li');
  13. for(var j=0; j<lis.length;j++){
  14. if(lis[j].id != $('.nav-tabs>li:eq('+index+')')[0].id){
  15. lis[j].style.width = width/(lis.length-1)+'px';
  16. }
  17. }
  18. $('.nav-tabs>li:eq('+index+')')[0].style.width = $('.nav-tabs>li:eq('+index+')').attr("oldwidth")+'px';
  19. nav.children('.' + cls).removeClass(cls);
  20. $(this).parent().addClass(cls);
  21. }
  22. });
  23. }
  24. function getUrlParam(name){
  25. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  26. var r = window.location.search.substr(1).match(reg);
  27. if (r != null)
  28. return decodeURI(r[2]);
  29. return null;
  30. }
  31. function parseDate(date){
  32. var y = date.getFullYear(), m = date.getMonth() + 1, d = date.getDate(),
  33. h = date.getHours(), i = date.getMinutes();
  34. var now = new Date(), _y = now.getFullYear(), _m = now.getMonth() + 1, _d = now.getDate();
  35. if(_y != y) {
  36. return y + '-' + m + '-' + d + ' ' + h + ':' + i;
  37. } else {
  38. if(_m != m) {
  39. return m + '月' + d + '号' + h + '点' + i + '分';
  40. } else {
  41. if(_d != d) {
  42. return d + '号' + h + '点' + i + '分';
  43. } else {
  44. return (h < 12 ? '上午' : '下午' ) + h + '点' + i + '分';
  45. }
  46. }
  47. }
  48. }
  49. function setLoading (isLoading) {
  50. $('.loading-container').css('display', isLoading ? 'block' : 'none');
  51. }
  52. function ValidateNumber(e, pnumber) {
  53. if (!/^\d+[.]?\d*$/.test(pnumber)) {
  54. $(e).val(/^\d+[.]?\d*/.exec($(e).val()));
  55. }
  56. return false;
  57. }
  58. function changeEscapeCharacter(da){
  59. var e = da;
  60. if(isNaN(e)){//不是数字
  61. e = e.replace(/\'/g, "&apos;");
  62. e = e.replace(/\"/g, "&quot;");
  63. }
  64. return e;
  65. }
  66. var ignores = [],items = [],dbfinds = {};
  67. //更新明细行,并且重新加载数据
  68. function updateRow (gridId,rowId,caller,instance,keyName,keyValue,mad_code){
  69. $('#'+gridId).jqGrid('setSelection',rowId);
  70. $('#'+gridId).jqGrid('editGridRow',rowId,{
  71. editCaption:'编辑',bSubmit:'保存',bCancel:'关闭',checkOnSubmit:true,checkOnUpdate:true,
  72. closeAfterEdit:true,closeOnEscape:true,
  73. serializeEditData :function(a,b){//序列化传至服务器的参数
  74. delete a.oper;
  75. delete a.id;
  76. if(items.length !=0 && dbfinds.length != 0){//
  77. $.each(dbfinds,function(key,value){
  78. if(typeof(items[value.dbGridField])!= "undefined" )
  79. a[value.field]= items[value.dbGridField];
  80. });
  81. }
  82. //判断是否存在忽略类型 ignore
  83. if(ignores.length > 0 ){
  84. $.each(ignores,function(key,value){
  85. delete a[value];
  86. });
  87. }
  88. var b = new Object();
  89. b._noc = 1;
  90. b.caller = caller;
  91. b.processInstanceId = instance ;
  92. b.formStore = '{'+keyName+':'+keyValue+'}';
  93. b.param = $.toJSON(a);
  94. return b;
  95. },
  96. errorTextFormat:function(a,b){//錯誤捕獲
  97. if(a.responseJSON.exceptionInfo== 'ERR_NETWORK_SESSIONOUT') {
  98. return '保存信息失败,请先登录!';
  99. } else {
  100. return '错误:'+ a.responseJSON.exceptionInfo;
  101. }
  102. },
  103. afterSubmit : function(response, postdata) {
  104. $.showtip("修改明细成功!", 2000);
  105. setLoading(true);
  106. $.ajax({
  107. url:basePath + 'common/loadNewGridStore.action',
  108. type: 'POST',
  109. data: {caller:caller,condition:mad_code +"='"+keyValue+"'",_noc: 1},
  110. success: function(result){
  111. setLoading(false);
  112. $('#'+gridId)[0].addJSONData(result.data);
  113. },
  114. error:function(){
  115. setLoading(false);
  116. }
  117. });
  118. return true;
  119. }
  120. });
  121. }
  122. var requiredFields = null,instance = null;
  123. function saveForm(keyName,keyValue,caller){
  124. //requiredFields array格式
  125. var d = {};
  126. var t = $('#mainForm').serializeArray();
  127. $.each(t, function() {
  128. if($('#'+this.name).attr("logic") || $('#'+this.name).attr("logic") != 'ignore'){ //判断logic的属性是否为ignore 忽略
  129. d[this.name] = this.value;
  130. }
  131. });
  132. var bool = true;
  133. if (requiredFields != null) {//判断必填项是否填写
  134. $.each(requiredFields, function(key, field){
  135. if (d[field] == null || d[field] == "") {
  136. bool = false;
  137. $('#tips').text('保存之前请先填写必填的信息!');
  138. $('#'+field).focus();
  139. return;
  140. }
  141. });
  142. }
  143. //获取改变了的值
  144. $.each(d,function(key,field){//只将修改的值提交到后台
  145. if(d[key] == bill[key])
  146. delete d[key];
  147. });
  148. if($.isEmptyObject(d)){
  149. $.showtip("还未添加或修改数据!", 2000);
  150. return;
  151. }
  152. if (bool) {//获取编辑的字段值
  153. d[keyName] = keyValue;
  154. var b = new Object();
  155. b._noc = 1;
  156. b.caller = caller;
  157. b.processInstanceId = instance;
  158. b.formStore = $.toJSON(d);
  159. setLoading(true);
  160. $.ajax({
  161. url:basePath+"common/processUpdate.action",
  162. type: 'POST',
  163. data: b,
  164. success: function(result){
  165. setLoading(false);
  166. $.showtip("修改成功!", 2000);
  167. var url = window.location.href;
  168. window.location.href = url.substr(0, url.indexOf('?') + 1) + 'nodeId=' + getUrlParam('nodeId');
  169. /*$.each(d,function(key,field){//修改数据
  170. if(d[key] != bill[key])
  171. bill[key] = d[key];
  172. });*/
  173. },
  174. error:function(){
  175. setLoading(false);
  176. }
  177. });
  178. }
  179. }
  180. function orient() {
  181. var orientation = (window.innerWidth > window.innerHeight) ?'portrait':'landscape';
  182. document.body.parentNode.setAttribute('class',orientation);
  183. if (window.orientation == 90 || window.orientation == -90) {
  184. //ipad、iphone竖屏;Andriod横屏
  185. $("body").attr("class", "landscape");
  186. orientation = 'landscape';
  187. return false;
  188. }else if (window.orientation == 0 || window.orientation == 180) {
  189. //ipad、iphone横屏;Andriod竖屏
  190. $("body").attr("class", "portrait");
  191. orientation = 'portrait';
  192. return false;
  193. }
  194. }
  195. $(document).ready(function() {
  196. $.event.special.boxready = {
  197. /**
  198. * 初始化事件处理器 - this指向元素
  199. * @param 附加的数据
  200. * @param 事件类型命名空间
  201. * @param 回调函数
  202. */
  203. setup: function(data, namespaces, eventHandle) {
  204. var elem = this;
  205. $.event.add(elem, 'click', function (event) {
  206. if ($.data(elem, '@loaded') !== true) {
  207. $.event.trigger('boxready', null, elem);
  208. $.data(elem, '@loaded', true);
  209. }
  210. });
  211. },
  212. /**
  213. * 卸载事件处理器 - this指向元素
  214. * @param 事件类型命名空间
  215. */
  216. teardown: function(namespaces) {
  217. var elem = this;
  218. $.event.remove(elem, 'click');
  219. $.removeData(elem, '@loaded');
  220. }
  221. };
  222. var readyTime = new Date();
  223. //激活tabpanel
  224. reActive();
  225. // modal dialog
  226. var dialog = {
  227. show: function(title, content, timeout, callback){
  228. var back = $('.modal-backdrop'), modal = $('.modal'),
  229. tt = $('.modal-title', modal), tb = $('.modal-body', modal);
  230. back.css('display', 'block');
  231. modal.css('display', 'block');
  232. tt.text(title);
  233. if(timeout && timeout > 0) {
  234. content = '<div><strong class="text-success text-xl" id="timeout">' + timeout + '</strong>&nbsp;秒后,' + content + '</div>';
  235. }
  236. tb.html(content);
  237. if(timeout) {
  238. var pre = 1000;
  239. if(timeout <=0 ) {// auto close
  240. pre = 1500;
  241. if(!callback)
  242. callback = dialog.hide;
  243. }
  244. var timer = function(t) {
  245. setTimeout(function(){
  246. if(t > -1) {
  247. $('#timeout').text(t--);
  248. timer(t);
  249. } else {
  250. callback && callback.call();
  251. }
  252. }, pre);
  253. };
  254. timer(timeout);
  255. }
  256. },
  257. hide: function() {
  258. var back = $('.modal-backdrop'), modal = $('.modal');
  259. back.css('display', 'none');
  260. modal.css('display', 'none');
  261. }
  262. };
  263. var parseBillDetail = function(content,i,detail,field,keyValue,keyName){//field 可编辑的字段,keyValue关联主表字段值
  264. var caller = detail[i].mad_caller;
  265. var mad_code = detail[i].mad_code;
  266. var detno_code = detail[i].mad_detnocode;
  267. var condition ;
  268. if(caller == "PayPleaseDet"){
  269. condition = mad_code +"=(select ppd_id from (select ppd_id,row_number() over (order by ppd_detno) rn from paypleasedetail where ppd_ppid="+keyValue+") where rn < 2)"
  270. }else if(caller == ""){
  271. condition = mad_code +"=(select ppd_id from (select ppd_id,row_number() over (order by ppd_detno) rn from paypleasedetail where ppd_ppid="+keyValue+") where rn < 2)";
  272. }else{
  273. condition = mad_code +"='"+keyValue+"'";
  274. }
  275. setLoading(true);
  276. //获取表的列名,列值
  277. $.ajax({
  278. url:basePath + 'common/singleGridPanel.action',
  279. type: 'POST',
  280. data: {caller:caller,condition:condition,_noc: 1},
  281. success: function(result){
  282. setLoading(false);
  283. var colModel = [];
  284. if(field.length != 0){
  285. //增加一列编辑列
  286. colModel.push({"label":'编辑',"name":'act',"index":'act',"sorttype":false,"width":75,"editable":false,"frozen":true,"align":'center'});
  287. }
  288. dbfinds = result.dbfinds;
  289. for(var n=0;n<result.columns.length;n++){
  290. var hidden = false;//是否隐藏列
  291. if(result.columns[n].hidden || result.columns[n].width == 0){
  292. hidden = true;
  293. }
  294. //是否为忽略
  295. if(result.columns[n].logic == 'ignore'){//将忽略的保存起来
  296. ignores.push(result.fields[n].name);
  297. }
  298. var editable = false;//是否可编辑列,//编辑类型
  299. var edittype = '', number = false,required = false;
  300. if($.inArray(result.fields[n].name.toLowerCase(), field) > -1){
  301. required = editable = true;
  302. if(result.columns[n].xtype == 'numbercolumn'){ //数字类型
  303. edittype = 'text';
  304. number = true;
  305. }else if(result.columns[n].xtype == '' && result.columns[n].editor.xtype == 'dbfindtrigger'){//dbfind
  306. edittype = 'custom';
  307. var resultDatas = {};
  308. var name = result.fields[n].name;
  309. var ars = result.columns[n].dbfind.split('|');
  310. editoptions = {
  311. dataInit: function (element) {
  312. $(element).autocomplete({ //dbfind字段模糊查询
  313. minLength:1,
  314. source: function(query, proxy) {
  315. $.ajax({
  316. url: basePath+'common/dbfind.action',
  317. dataType: "json",
  318. data: {
  319. which:'grid',
  320. caller:ars[0],
  321. field:name,
  322. condition:"upper("+ars[1]+") like '%"+query.term.toUpperCase()+"%'",
  323. ob:'',
  324. page:1,
  325. pageSize:13
  326. },
  327. success: function (result) {
  328. resultDatas = $.evalJSON(result.data) ;
  329. proxy($.evalJSON(result.data));
  330. }
  331. });
  332. },
  333. select: function(event, ui) {
  334. items = ui.item;
  335. $.each(dbfinds,function(key,value){
  336. if($('input#'+value.field).length != 0 && typeof(ui.item[value.dbGridField])!= "undefined"){
  337. $('input#'+value.field).val(ui.item[value.dbGridField]);
  338. }
  339. });
  340. return false;
  341. }
  342. }).blur(function(event){
  343. if(resultDatas.length != 0){
  344. var id = $(this)[0].id,val= $(this).val(),field;
  345. $.each(dbfinds,function(key,value){
  346. if(value.field == id){
  347. field = value.dbGridField ;
  348. }
  349. });
  350. $.each(resultDatas,function(key,value){
  351. if(value[field] == val){
  352. items = value;
  353. $.each(dbfinds,function(key,da){
  354. if($('input#'+da.field).length != 0 && typeof(value[da.dbGridField])!= "undefined"){
  355. $('input#'+da.field).val(value[da.dbGridField]);
  356. }
  357. });
  358. }
  359. });
  360. }else{
  361. items = [];
  362. }
  363. }).autocomplete("instance" )._renderItem = function( ul, item ) {
  364. return $( "<li>" )
  365. .append( "<a>" + item[ars[1]] + "</a>" )
  366. .appendTo( ul );
  367. };
  368. }
  369. }
  370. }else if(result.columns[n].xtype == ''){//基本类型
  371. edittype = 'text';
  372. }else if(result.columns[n].xtype == 'combocolumn'){//下拉框类型
  373. edittype='select';
  374. }
  375. }
  376. if(result.fields[n].name == detno_code){
  377. colModel.push({"label":result.columns[n].header,"name":result.fields[n].name,"index":result.fields[n].name,"sorttype":result.fields[n].type,"width":result.columns[n].width,"editable":true,editoptions: {readonly: 'readonly'},"align":'center'});
  378. }else if(result.columns[n].logic == 'keyField'){//主鍵字段
  379. colModel.push({"label":result.columns[n].header,"name":result.fields[n].name,"index":result.fields[n].name,"sorttype":result.fields[n].type,"width":result.columns[n].width,"editable":true,editoptions: {readonly: 'readonly',edithidden:true},key:true,hidden:hidden});
  380. }else if(edittype == 'select'){//下拉框
  381. var data = result.columns[n].editor.store.data;
  382. var values = '';
  383. $.each(data,function(d,va){
  384. values = va.display+":"+va.value;
  385. });
  386. colModel.push({"label":result.columns[n].header,"name":result.fields[n].name,"index":result.fields[n].name,"sorttype":result.fields[n].type,"width":result.columns[n].width,"editable":editable,"edittype":edittype,"editoptions":{value:values},hidden:hidden});
  387. }else if(editable && result.fields[n].type == 'date'){//日期类型
  388. colModel.push({"label":result.columns[n].header,"name":result.fields[n].name,"index":result.fields[n].name,"sorttype":result.fields[n].type,"width":result.columns[n].width,"editable":editable,"edittype":edittype,hidden:hidden,
  389. "editoptions":{dataInit: function (element) {
  390. $(element).datepicker({
  391. id: 'orderDate_datePicker',
  392. dateFormat: 'yy-mm-dd',
  393. showOn: 'focus'
  394. });
  395. }}
  396. });
  397. }else if(edittype == 'custom'){//dbfind
  398. colModel.push({"label":result.columns[n].header,"name":result.fields[n].name,"index":result.fields[n].name,"sorttype":result.fields[n].type,"width":result.columns[n].width,"editable":editable,"edittype":'text',"editoptions": editoptions ,hidden:hidden});
  399. }else{
  400. colModel.push({"label":result.columns[n].header,"name":result.fields[n].name,"index":result.fields[n].name,"sorttype":result.fields[n].type,"width":result.columns[n].width,"editable":editable,"edittype":edittype,"editrules":{required:required,number:number},hidden:hidden});
  401. }
  402. }
  403. var data = $.evalJSON(result.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  404. content.html('<table id="grid'+i+'"class="content"></table><div id="pager'+i+'"></div>');
  405. jQuery('#grid'+i).jqGrid({
  406. "hoverrows":false,
  407. "viewrecords":true,
  408. //"styleUI": 'Bootstrap',
  409. "gridview":true,
  410. "data": data,
  411. "scrollPaging":true,
  412. "shrinkToFit":false,
  413. "autoScroll": true,
  414. "width":$('#topToolbar').width(),
  415. "rowNum":20,
  416. "rowList" : [20,40,60],
  417. "datatype": "local",
  418. "colModel":colModel,
  419. gridComplete : function() {//增加一列编辑列
  420. var ids = $(this).jqGrid('getDataIDs');
  421. for ( var i = 0; i < ids.length; i++) {
  422. var cl = ids[i];
  423. var id = $(this)[0].id;
  424. be = "<input type='image' src='img/edit.png' id='image1' onclick=\"updateRow('"+$(this)[0].id+"','"+cl+"','"+caller+"','"+instance+"','"+keyName+"','"+keyValue+"','"+mad_code+"');\"/>";
  425. $(this).jqGrid('setRowData', ids[i],
  426. {
  427. act : be
  428. });
  429. }
  430. },
  431. loadComplete: function() { //修改行高
  432. var grid = $(this);
  433. var ids = grid.getDataIDs();
  434. for (var i = 0; i < ids.length; i++) {
  435. grid.setRowData( ids[i], false, {height: 35} );
  436. }
  437. },
  438. "pager":"#pager"+i,
  439. "editurl":basePath+"common/processUpdate.action"
  440. });
  441. jQuery('#grid'+i).jqGrid('navGrid','#pager'+i,{add:false,edit:false,del:false},{reloadAfterSubmit:false},{},{},{multipleSearch:true});
  442. },
  443. error: function(xhr){
  444. setLoading(false);
  445. if(xhr.responseText) {
  446. var response = $.evalJSON(xhr.responseText);
  447. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  448. dialog.show('获取用户信息失败', '请先登录!');
  449. } else {
  450. dialog.show('错误', response.exceptionInfo);
  451. }
  452. }
  453. }
  454. });
  455. };
  456. //包含明细增加tab 切换
  457. var addTabPanel = function(cn,detail,fields,keyValue,keyName){
  458. //增加多个tab,如果有明细行
  459. var html = '',html2 = '';
  460. for(var i=0;i<cn;i++){
  461. html += '<li id="detail-header'+i+'"><a><span class="glyphicon glyphicon-list-alt"></span>&nbsp;'+detail[i].mad_name+'</a></li>';
  462. html2 +='<div id="bill-detail'+i+'" class="tab-pane"><div class="empty"></div></div>';
  463. }
  464. $('.nav-tabs>#main-header').after(html);
  465. $('#bill-main').after(html2);
  466. var width = $('#topToolbar').width()-$('.nav-tabs>li.active').width()-2;
  467. var d = width/(i+1)+'px';
  468. var lis = $('.nav-tabs>li');
  469. for(var j=0; j<lis.length;j++){
  470. $('#'+lis[j].id).attr("oldwidth",$('.nav-tabs>li:eq('+j+')').width());
  471. if(lis[j].id != $('.nav-tabs>li.active')[0].id){
  472. lis[j].style.width = d;
  473. }
  474. }
  475. for(var i=0;i<cn;i++){
  476. //生成明细表grid
  477. $('#detail-header'+i).bind('boxready', function(a){
  478. parseBillDetail($('#bill-detail'+a.target.id.split("header")[1]),a.target.id.split("header")[1],detail,fields,keyValue,keyName);
  479. });
  480. }
  481. };
  482. //获取关联明细表
  483. var getDetail = function(fields,keyValue,caller,keyName){
  484. $.ajax({
  485. url:basePath + 'mobile/common/getAuditDetail.action',
  486. type: 'POST',
  487. data: {caller: caller,_noc: 1},
  488. success: function(result){
  489. var detail = result.detail;
  490. if(detail) {
  491. addTabPanel(detail.length,detail,fields,keyValue,keyName);
  492. reActive();
  493. }
  494. },
  495. error: function(xhr){
  496. if(xhr.responseText) {
  497. var response = $.evalJSON(xhr.responseText);
  498. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  499. dialog.show('获取用户信息失败', '请先登录!');
  500. } else {
  501. dialog.show('错误', response.exceptionInfo);
  502. }
  503. }
  504. }
  505. });
  506. };
  507. // parse bill main
  508. var parseBillMain = function(main,button,cond,caller) {
  509. bill = $.evalJSON(main.data.replace(/,}/g, '}').replace(/,]/g, ']'));
  510. var items = main.items;
  511. var bo = false, ifGroup = false;
  512. var sortItems;
  513. $.each(items, function(key, val){
  514. val['readOnly'] = true;
  515. });
  516. if(button != null){//判断是否有可编辑的字段
  517. var fieldsArray = button.jb_fields.split(";");
  518. var neccessaryField ='';
  519. if(button.jt_neccessaryfield){
  520. neccessaryField = button.jt_neccessaryfield.toLowerCase().split(",") ;
  521. }
  522. requiredFields = neccessaryField;
  523. $.each(items, function(key, val){
  524. if (val.groupName == button.jb_buttonname && button.jb_fields.indexOf("#") > 0) {
  525. val['readOnly'] = false;
  526. bo = true;
  527. } else {
  528. if ($.inArray(val.groupName,fieldsArray) > -1) {
  529. val['readOnly'] = false;
  530. bo = true;
  531. }
  532. if (neccessaryField != null && $.inArray(val.name,neccessaryField) > -1) {//编辑字段中是否有必填字段
  533. val.allowBlank = false;
  534. val.fieldStyle = "background:#fffac0;color:#515151;";
  535. } else val.fieldStyle = "background:#FFFAFA;color:#515151;"
  536. }
  537. });
  538. }
  539. if(bo){//有可编辑字段需要按照可编辑排序,和组别排序,通过引入的thenBy.js实现
  540. sortItems = items.sort(
  541. firstBy(function (v1, v2) {
  542. if(!v1.readOnly){
  543. return -1;
  544. }
  545. }
  546. ).thenBy(function (v1, v2) {
  547. return v1.group - v2.group;
  548. })
  549. );
  550. }else{//没有不要排序,按原有顺序显示
  551. sortItems = items;
  552. }
  553. //分组,按照groupName分组
  554. var getMixedGroups = function (items, fields) {
  555. var data = new Object(), k, o;
  556. $.each(items,function(key,d) {
  557. k = '';
  558. o = new Object();
  559. if(d[fields] != null && d[fields] != ''){
  560. k += fields + ':' + d[fields] + ',';
  561. o[fields] = d[fields];
  562. if (k.length > 0) {
  563. if (!data[k]) {
  564. data[k] = {
  565. keys: o,
  566. groups: [d]
  567. };
  568. } else {
  569. data[k].groups.push(d);
  570. }
  571. }
  572. }
  573. });
  574. return data;
  575. }
  576. var tempItems = getMixedGroups(sortItems,'groupName');
  577. if(! $.isEmptyObject(tempItems)){//有分组
  578. sortItems = tempItems;
  579. ifGroup = true;
  580. }
  581. var html = '<form method="post" id="mainForm"> ' +
  582. ' <table class="table table-condensed table-bordered table-striped"><colgroup><col width="45%"></col><col width="55%"></col></colgroup>';
  583. if(bo){//有可编辑的增加保存按钮
  584. var cd = cond.split("=");
  585. html +='<div class="list-group"> <div class="text-center col-xs-8" id="tips" style="color:#FF0000;"> </div>';
  586. html +="<div class='text-right'><button type='button' class='btn-sm' id='"+button.jb_buttonid +"' name='"+button.jb_buttonname+ "' onclick=\"saveForm('"+cd[0]+"',"+cd[1]+",'"+caller+"');\">"+button.jb_buttonname+"</button></div></div>";
  587. }
  588. $.each(sortItems,function(key,d) {
  589. var strData,seData;
  590. if(d.keys){//有分组
  591. if(d.keys.groupName != null){
  592. html += ' <tbody><tr><td colspan="2" class="text-center text-success" id="'+d.keys.groupName+'"><strong>' + d.keys.groupName + '</strong>&nbsp;<span class="glyphicon glyphicon-chevron-down"></span></td></tr> <tbody>';
  593. html += ' <tbody id="'+d.keys.groupName+'0">';
  594. }
  595. for(var i=0;i<d.groups.length;i++){
  596. if(d.groups[i].id != null && d.groups[i].xtype != "hidden" && d.groups[i].fieldLabel != null){
  597. html += '<tr>';
  598. html += '<td class="text-right special" ><strong><label for='+d.groups[i].id+'>' + d.groups[i].fieldLabel+ '</label></strong></td>';
  599. if(!d.groups[i].readOnly){//可编辑字段
  600. //编辑的类型,下拉框,dbfind,数字类型【需要新增】
  601. if(d.groups[i].xtype == 'combo'){//下拉框
  602. html +='<td class="text-center"><select name="'+d.groups[i].id+'" class="cellElement form-control" style="'+d.groups[i].fieldStyle+'"'+ (d.groups[i].logic ? 'logic="' + d.groups[i].logic + '"' : '') +(d.groups[i].allowBlank ? '' : 'required') +'>';
  603. html +='<option value=""></option>';
  604. $.each(d.groups[i].store.data,function(key,da){
  605. if(bill[d.groups[i].id] == da.value){
  606. html +='<option value="'+da.value+'" selected="selected">'+da.display+'</option>';
  607. }else{
  608. html +='<option value="'+da.value+'">'+da.display+'</option>';
  609. }
  610. });
  611. html+='</select></td>';
  612. }else if(d.groups[i].xtype == "dbfindtrigger"){//dbfind字段
  613. strData = changeEscapeCharacter(bill[d.groups[i].id]);
  614. html += '<td class="text-center">' +
  615. '<input type="text" id="'+d.groups[i].id+'" style='+d.groups[i].fieldStyle+
  616. ' name='+ d.groups[i].id+' style='+d.groups[i].fieldStyle +
  617. ' class="cellElement form-control" dbfind value="'+strData +'"'+ (d.groups[i].logic ? 'logic="' + d.groups[i].logic + '"' : '') +(d.groups[i].allowBlank ? '' : 'required') +'/>' +
  618. '</td>';
  619. }else if (d.groups[i].xtype == "multifield"){//MT类型
  620. strData = changeEscapeCharacter(bill[d.groups[i].id]);
  621. seData = changeEscapeCharacter(bill[d.groups[i].secondname]);
  622. html += '<td class="text-center">' +
  623. '<input type="text" id="'+d.groups[i].id+'" style='+d.groups[i].fieldStyle+
  624. ' name='+ d.groups[i].id+' style='+d.groups[i].fieldStyle +
  625. ' class="cellElement form-control" dbfind value="'+strData +'"'+ (d.groups[i].logic ? 'logic="' + d.groups[i].logic + '"' : '') +(d.groups[i].allowBlank ? '' : 'required') +'/>' +
  626. '<input type="text" id="'+ d.groups[i].secondname+'" readonly name='+ d.groups[i].secondname+
  627. ' class="setInput " value="'+seData+'"/>'+
  628. '</td>';
  629. }else if(d.groups[i].xtype == 'numberfield'){//数字类型
  630. html += '<td class="text-center">' +
  631. '<input type="text" id='+ d.groups[i].id+' style='+d.groups[i].fieldStyle+
  632. ' name='+ d.groups[i].id+' style='+d.groups[i].fieldStyle +
  633. ' class="cellElement form-control" value="'+bill[d.groups[i].id] +'"'+ (d.groups[i].logic ? 'logic="' + d.groups[i].logic + '"' : '') +(d.groups[i].allowBlank ? '' : 'required') +'onkeyup="return ValidateNumber($(this),value)"/>' +
  634. '</td>';
  635. }else {//其他类型字段
  636. strData = changeEscapeCharacter(bill[d.groups[i].id]);
  637. html += '<td class="text-center">' +
  638. '<input type="text" id='+ d.groups[i].id+' style='+d.groups[i].fieldStyle+
  639. ' name='+ d.groups[i].id+' style='+d.groups[i].fieldStyle +
  640. ' class="cellElement form-control" value="'+strData +'"'+ (d.groups[i].logic ? 'logic="' + d.groups[i].logic + '"' : '') +(d.groups[i].allowBlank ? '' : 'required') +'/>' +
  641. '</td>';
  642. }
  643. }else{//不可编辑字段
  644. strData = changeEscapeCharacter(bill[d.groups[i].id]);
  645. if(d.groups[i].xtype == "multifield"){//MT类型
  646. seData = changeEscapeCharacter(bill[d.groups[i].secondname]);
  647. html += '<td class="text-center">' +
  648. ' <input type="text" id='+ d.groups[i].id+' readonly name='+ d.groups[i].id+
  649. ' class="setInput" value="'+strData +'"'+(d.groups[i].logic ? 'logic="' + d.groups[i].logic + '"' : '')+'/>' +
  650. ' <input type="text" id='+ d.groups[i].secondname+' readonly name='+ d.groups[i].secondname+
  651. ' class="setInput" value="'+seData +'"/>' +
  652. '</td>';
  653. }else{
  654. html += '<td class="text-center">' +
  655. ' <input type="text" id='+ d.groups[i].id+' readonly name='+ d.groups[i].id+
  656. ' class="setInput" value="'+strData +'"'+(d.groups[i].logic ? 'logic="' + d.groups[i].logic + '"' : '')+'/>' +
  657. '</td>';
  658. }
  659. }
  660. html += '</tr>';
  661. }
  662. }
  663. html+='</tbody>';
  664. }else{//无分组
  665. strData = changeEscapeCharacter(bill[d.id]);
  666. if(d.id != null && d.xtype != "hidden" && d.fieldLabel != null){
  667. html += '<tr>';
  668. html += '<td class="text-right special"><strong><label for='+d.id+'>' + d.fieldLabel+ '</label></strong></td>';
  669. if(d.xtype == "multifield"){ //MT
  670. seData = changeEscapeCharacter(bill[d.secondname]);
  671. html += '<td class="text-center">' +
  672. '<input type="text" id='+ d.id+' readonly class="setInput" name='+ d.id+
  673. ' value="'+strData +'"'+(d.logic ? 'logic="' + d.logic + '"' : '')+'/>' +
  674. '<input type="text" id='+ d.secondname+' readonly class="setInput" name='+ d.secondname+
  675. ' value="'+seData +'"/>' +
  676. '</td>';
  677. }else{
  678. html += '<td class="text-center">' +
  679. '<input type="text" id='+ d.id+' readonly class="setInput" name='+ d.id+
  680. ' value="'+strData +'"'+(d.logic ? 'logic="' + d.logic + '"' : '')+'/>' +
  681. '</td>';
  682. }
  683. html += '</tr>';
  684. }else if(d.id != null){//隐藏字段
  685. html += '<input type="hidden" id='+ d.id+' readonly name='+ d.id+
  686. ' value="'+ strData +'"'+(d.logic ? 'logic="' + d.logic + '"' : '')+'/>';
  687. }
  688. }
  689. });
  690. html += '</table></form>';
  691. $('#bill-main').html(html);
  692. $("#mainForm :input[required]:eq(0)").focus();
  693. if(ifGroup){//有分组点击收缩
  694. $.each(sortItems,function(key,d){
  695. $("#"+d.keys.groupName).click(function(){
  696. $("#"+d.keys.groupName+"0").slideToggle("normal");
  697. });
  698. });
  699. }
  700. var formDbfinds = {},resultData = {};
  701. var dbs = $("#mainForm :input[dbfind]") ;
  702. $.each(dbs,function(key,value){
  703. $('#'+value.id).autocomplete({ //form表DBfind获取数据
  704. minLength: 1,
  705. source: function(query, proxy) {
  706. $.ajax({
  707. url: basePath+'common/dbfind.action',
  708. dataType: "json",
  709. type:'POST',
  710. data: {
  711. which:'form',
  712. caller:caller,
  713. field:$(this)[0].element[0].id,
  714. condition:"upper("+$(this)[0].element[0].id+") like '%"+query.term.toUpperCase()+"%'",
  715. ob:'',
  716. page:1,
  717. pageSize:13
  718. },
  719. success: function (result) {
  720. resultData = $.evalJSON(result.data);
  721. formDbfinds = result.dbfinds;
  722. proxy($.evalJSON(result.data));
  723. }
  724. });
  725. },
  726. select: function(event, ui) {
  727. $.each(formDbfinds,function(key,value){
  728. if($('input#'+value.field).length != 0 && typeof(ui.item[value.dbGridField])!= "undefined"){
  729. $('input#'+value.field).val(ui.item[value.dbGridField]);
  730. }
  731. });
  732. return false;
  733. }
  734. })/*.focus(function () {
  735. $(this).autocomplete("search");
  736. })*/.blur(function(event){
  737. if(formDbfinds.length != 0){
  738. var id = $(this)[0].id,val= $(this).val(),field;
  739. $.each(formDbfinds,function(key,value){
  740. if(value.field == id){
  741. field = value.dbGridField ;
  742. }
  743. });
  744. $.each(resultData,function(key,value){
  745. if(value[field] == val){
  746. $.each(formDbfinds,function(key,da){
  747. if($('input#'+da.field).length != 0 && typeof(value[da.dbGridField])!= "undefined"){
  748. $('input#'+da.field).val(value[da.dbGridField]);
  749. }
  750. });
  751. }
  752. });
  753. }
  754. }).autocomplete("instance" )._renderItem = function( ul, item ) {
  755. var id = $(this)[0].element[0].id;
  756. var data ;
  757. $.each(formDbfinds,function(key,value){
  758. if(value.field == id){
  759. data = value.dbGridField ;
  760. }
  761. });
  762. return $( "<li>" )
  763. .append( "<a>" + item[data]+ "</a>" )
  764. .appendTo( ul );
  765. };
  766. });
  767. };
  768. //获取主表数据字段
  769. var getBillMain = function(caller, url, cond, billId,button) {
  770. $.ajax({
  771. url:basePath + 'common/singleFormItems.action',
  772. type: 'POST',
  773. data: {caller: caller, condition: cond, _noc: 1},
  774. success: function(result){
  775. if(result.data) {
  776. parseBillMain(result,button,cond,caller);
  777. }
  778. },
  779. error: function(xhr){
  780. if(xhr.responseText) {
  781. var response =$.evalJSON(xhr.responseText);
  782. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  783. dialog.show('获取用户信息失败', '请先登录!');
  784. } else {
  785. dialog.show('错误', response.exceptionInfo);
  786. }
  787. }
  788. }
  789. });
  790. };
  791. //根据审批流caller 获取页面caller
  792. var getPageCaller = function(nodeCaller,url,callback) {
  793. $.ajax({
  794. url:basePath + '/common/form/getPageCaller.action',
  795. type: 'POST',
  796. data: {caller : nodeCaller,url:url, _noc: 1},
  797. success: function(result){
  798. callback && callback.call(null, result);
  799. },
  800. error: function(xhr){
  801. if(xhr.responseText) {
  802. var response =$.evalJSON(xhr.responseText);
  803. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  804. dialog.show('获取信息失败', '请先登录!');
  805. } else {
  806. dialog.show('错误', response.exceptionInfo);
  807. }
  808. }
  809. }
  810. });
  811. };
  812. //init extra element when VisitRecord
  813. var initVisitRecord = function(main, billId) {
  814. $('#ex').css('display', 'block');
  815. var data = main.data['评价'], title = data ? (data['评分'] || '良') : '良',
  816. msg = data ? data['评语'] : '';
  817. if(title) {
  818. $('#ex-rating button[title="' + title + '"]').addClass('active');
  819. }
  820. $('#ex-msg').val(msg);
  821. $('#ex-rating button').click(function(){
  822. $('#ex-rating button').each(function(){
  823. $(this).removeClass('active');
  824. });
  825. $(this).addClass('active');
  826. });
  827. $('#ex-confirm').click(function(){
  828. msg = $('#ex-msg').val() || '-';
  829. title = '';
  830. $('#ex-rating button').each(function(){
  831. if($(this).hasClass('active'))
  832. title = $(this).attr('title');
  833. });
  834. setLoading(true);
  835. $.ajax({
  836. url:basePath + 'crm/customermgr/updateVisitRecordPingjia.action',
  837. type: 'POST',
  838. data: {id: billId, vr_newtitle: title, vr_purpose: msg, _noc: 1},
  839. success: function(result){
  840. setLoading(false);
  841. dialog.show('提示', '评价成功', -1);
  842. },
  843. error: function(xhr){
  844. setLoading(false);
  845. if(xhr.responseText) {
  846. var response =$.evalJSON(xhr.responseText);
  847. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  848. dialog.show('获取信息失败', '请先登录!');
  849. } else {
  850. dialog.show('错误', response.exceptionInfo);
  851. }
  852. }
  853. }
  854. });
  855. });
  856. };
  857. // parse main point
  858. var parseMainPoint = function(points) {
  859. var html = '<ul class="list-group">';
  860. html += '<li class="list-group-item disabled"><strong>问题要点</strong></li>';
  861. $.each(points, function(i, p){
  862. html += '<li class="list-group-item">';
  863. html += '<span>' + p.text + '</span>';
  864. if(p.type === 'B') {//boolean
  865. html += '<div class="pull-right"><div class="has-switch switch-small"><div class="' + (p.value && p.value != '是' ? 'switch-off' : 'switch-on') + ' switch-animate"><input type="checkbox" ' + (p.value && p.value != '是' ? '' : 'checked') + ' title="' + p.text + '" ' + (p.logic ? 'logic="' + p.logic + '"' : '') +(p.required ? 'required' : '') + '> <span class="switch-left switch-success switch-small">是</span> <label class="switch-small">&nbsp;</label> <span class="switch-right switch-warning switch-small">否</span></div></div></div>';
  866. } else if(p.type === 'S' ) {//字符串
  867. html += '<div class="pull-right"><input class="form-control input-xs" type="text" placeholder="..." value="' + (p.value || '') + '" ' + (p.logic ? 'logic="' + p.logic + '"' : '') + ' title="' + p.text + '" ' + (p.required ? 'required' : '') + '></div>';
  868. } else if(p.type === 'D') {//日期
  869. html += '<div class="pull-right"><input class="form-control input-xs" type="date" placeholder="..." value="' + (p.value || '') + '" ' + (p.logic ? 'logic="' + p.logic + '"' : '') + ' title="' + p.text + '" ' + (p.required ? 'required' : '') + '></div>';
  870. }else if(p.type === 'C'){//下拉框
  871. html += '<div class="pull-right"><select class="form-control input-xs" '+(p.required ? 'required' : '')+' ><option></option>';
  872. $.each(p.data,function(i,da){
  873. html+='<option value="'+da+'"'+(da==p.value ? 'selected="selected"' : ' ')+'>'+da+'</option>'
  874. });
  875. html +='</select></div>';
  876. }else if(p.type === 'N'){//数字型
  877. html += '<div class="pull-right">'+'<input class="form-control input-xs numbertype" type="text" placeholder="..." value="' + (p.value || '') + '" ' + (p.logic ? 'logic="' + p.logic + '"' : '') + ' title="' + p.text + '" ' + (p.required ? 'required' : '') + ' onkeyup="return ValidateNumber($(this),value)"></div>';
  878. }
  879. html += '</li>';
  880. });
  881. html += '</ul>';
  882. $('#points').html(html);
  883. // toggle switch
  884. $('#points .has-switch').click(function(){
  885. var e = $(this), box = e.find('input'), checked = box.is(':checked');
  886. if(checked)
  887. box.removeAttr('checked');
  888. else
  889. box.attr('checked','checked');
  890. e.find('>div').removeClass(checked ? 'switch-on' : 'switch-off');
  891. e.find('>div').addClass(checked ? 'switch-off' : 'switch-on');
  892. });
  893. };
  894. var getMainPoint = function(id) {
  895. $.ajax({
  896. url:basePath + 'common/getCustomSetupOfTask.action',
  897. type: 'POST',
  898. data: {nodeId: id, _noc: 1},
  899. success: function(result){
  900. if(result.cs) {
  901. var points = [], data = result.data ? result.data.split(';') : [];
  902. $.each(result.cs, function(i, c){
  903. var m = c.indexOf('^'), n = c.indexOf('$'), q = c.indexOf('@');
  904. points.push({
  905. type: c.substring(m + 1, n),
  906. text: c.substring(0, m),
  907. required: c.substr(n + 1, 1) === 'Y',
  908. value: data[i] ? data[i].substring(data[i].lastIndexOf("(") + 1, data[i].lastIndexOf(")")) : null,
  909. logic: q > 0 ? c.substring(q + 1) : null,
  910. data : c.substring(c.indexOf('[')+1,c.indexOf(']')).split(";")
  911. });
  912. });
  913. if(points.length > 0)
  914. parseMainPoint(points);
  915. }
  916. },
  917. error: function(xhr){
  918. if(xhr.responseText) {
  919. var response =$.evalJSON(xhr.responseText);
  920. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  921. dialog.show('获取信息失败', '请先登录!');
  922. } else {
  923. dialog.show('错误', response.exceptionInfo);
  924. }
  925. }
  926. }
  927. });
  928. };
  929. var parseNode = function(node,button) {
  930. current = node;
  931. $('#jp_name').text(node.jp_name);
  932. $('#jp_name').css('margin-left', "-" + node.jp_name.replace(/[^\x00-\xff]/g, 'xx').length * 7 + "px");
  933. $('#jp_nodeName').text(node.jp_nodeName);
  934. $('#jp_launcherName').text(node.jp_launcherName);
  935. $('#jp_launchTime').text(parseDate(new Date(node.jp_launchTime)));
  936. $('#jp_codevalue').text(node.jp_codevalue);
  937. getPageCaller(node.jp_caller,node.jp_url,function(caller){
  938. //根据node
  939. var fields = [];var bol = false;
  940. if(button != null){//判断编辑字段
  941. var buttontype = button.jb_fields;
  942. var neccessaryField = button.jt_neccessaryfield ;
  943. if(neccessaryField != null){
  944. neccessaryField = neccessaryField.toLowerCase();
  945. }
  946. if(buttontype == 'updatedetail'){
  947. if (neccessaryField != null){
  948. fields = neccessaryField.split(",");
  949. }
  950. }else if (buttontype.indexOf('#') > 0) {
  951. }else{//主表编辑字段
  952. bol = true;
  953. }
  954. }
  955. // get bill main data
  956. if(node.jp_keyName && node.jp_keyValue && bol) {
  957. getBillMain(caller, node.jp_url, node.jp_keyName + '=\'' + node.jp_keyValue + '\'', node.jp_keyValue,button);
  958. }else{
  959. getBillMain(caller, node.jp_url, node.jp_keyName + '=\'' + node.jp_keyValue + '\'', node.jp_keyValue);
  960. }
  961. // has detail
  962. if(node.jp_formDetailKey) {
  963. //获取明细表个数
  964. getDetail(fields,node.jp_keyValue,caller,node.jp_keyName);
  965. }
  966. });
  967. // main point
  968. getMainPoint(node.jp_nodeId);
  969. //deal relative
  970. if(true){
  971. dealRelative(node.jp_caller);
  972. }
  973. };
  974. //获取审批流设置的信息
  975. var getProcess = function(id) {
  976. setLoading(true);
  977. $.ajax({
  978. url:basePath + 'common/getCurrentNode.action',
  979. type: 'POST',
  980. data: {jp_nodeId: id, _noc: 1},
  981. success: function(result){
  982. setLoading(false);
  983. instance = result.info.InstanceId;
  984. parseNode(result.info.currentnode,result.info.button);
  985. },
  986. error: function(xhr,a,b,c){
  987. setLoading(false);
  988. if(xhr.responseText) {
  989. var response =$.evalJSON(xhr.responseText);
  990. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  991. dialog.show('获取信息失败', '请先登录!');
  992. } else {
  993. dialog.show('错误', response.exceptionInfo,-1);
  994. }
  995. }
  996. }
  997. });
  998. };
  999. var getHistory = function(instanceId, callback) {
  1000. setLoading(true);
  1001. $.ajax({
  1002. url:basePath + 'common/getAllHistoryNodes.action',
  1003. type: 'POST',
  1004. data: {processInstanceId: instanceId, _noc: 1},
  1005. success: function(result){
  1006. setLoading(false);
  1007. if(callback)
  1008. callback.call(null, result.nodes);
  1009. if(result.nodes && result.nodes.length > 0) {
  1010. parseHistory(result.nodes);
  1011. }
  1012. },
  1013. error: function(xhr){
  1014. setLoading(false);
  1015. if(xhr.responseText) {
  1016. var response =$.evalJSON(xhr.responseText);
  1017. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1018. dialog.show('获取用户信息失败', '请先登录!');
  1019. } else {
  1020. dialog.show('错误', response.exceptionInfo);
  1021. }
  1022. }
  1023. }
  1024. });
  1025. };
  1026. var getInstance = function(id, callback) {
  1027. $.ajax({
  1028. url:basePath + 'common/getProcessInstanceId.action',
  1029. type: 'POST',
  1030. data: {jp_nodeId: id, _noc: 1},
  1031. success: function(result){
  1032. instance = result.processInstanceId;
  1033. callback && callback.call(null, instance);
  1034. },
  1035. error: function(xhr){
  1036. if(xhr.responseText) {
  1037. var response =$.evalJSON(xhr.responseText);
  1038. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1039. dialog.show('获取信息失败', '请先登录!');
  1040. } else {
  1041. dialog.show('错误', response.exceptionInfo);
  1042. }
  1043. }
  1044. }
  1045. });
  1046. };
  1047. var parseHistory = function(hist) {
  1048. var html = '<ul class="list-unstyled list-inline">';
  1049. $.each(hist, function(i, h){
  1050. var res = h.jn_dealResult == '同意' ? 'success' : (h.jn_dealResult == '不同意' ? 'error' : 'warning');
  1051. html += '<li>';
  1052. html += '<div class="text-top">';
  1053. html += '<span>' + h.jn_name + '</span>';
  1054. html += '</div>';
  1055. html += '<blockquote>';
  1056. html += '<strong>' + h.jn_dealManName + '</strong>';
  1057. html += '<div class="text-trans ' + res + '">';
  1058. html += '<span>' + h.jn_dealResult + '</span>';
  1059. html += '</div>';
  1060. html += '<footer>' + h.jn_dealTime + '</footer>';
  1061. html += '</blockquote>';
  1062. if(h.jn_operatedDescription || h.jn_nodeDescription || h.jn_infoReceiver) {
  1063. html += '<div class="highlight">';
  1064. if(h.jn_nodeDescription)
  1065. html += '<div>' + h.jn_nodeDescription + '</div>';
  1066. if(h.jn_infoReceiver)
  1067. html += '<p class="text-muted"><i>' + h.jn_infoReceiver + '</i></p>';
  1068. if(h.jn_operatedDescription) {
  1069. if(h.jn_operatedDescription.indexOf('(是)') > 0 ||
  1070. h.jn_operatedDescription.indexOf('(否)') > 0) {
  1071. html += '<ul class="list-group">';
  1072. var descs = h.jn_operatedDescription.split(';');
  1073. $.each(descs, function(j, d){
  1074. res = d.substr(d.length - 3) == '(是)' ? 'glyphicon glyphicon-ok text-success' :
  1075. 'glyphicon glyphicon-remove text-warning';
  1076. html += '<li class="list-group-item"><span class="pull-right ' + res + '"></span>' + d.substr(0, d.length-3) + '</li>';
  1077. });
  1078. html += '</ul>';
  1079. } else {
  1080. html += '<div>' + h.jn_operatedDescription + '</div>';
  1081. }
  1082. }
  1083. html += '</div>';
  1084. }
  1085. html += '</li>';
  1086. });
  1087. html += '</ul>';
  1088. $('#history').html(html);
  1089. };
  1090. // get process by node id
  1091. var nodeId = getUrlParam('nodeId');
  1092. if (nodeId) {
  1093. getProcess(nodeId);
  1094. // get history by instance id
  1095. $('#history-header').bind('boxready', function(){
  1096. if(instance) {
  1097. getHistory(instance);
  1098. } else {
  1099. getInstance(nodeId, function(instanceId){
  1100. getHistory(instanceId);
  1101. });
  1102. }
  1103. });
  1104. }
  1105. // get radio,checkbox value
  1106. var getBoxValue = function(selector) {
  1107. var value = null;
  1108. $(selector).each(function(){
  1109. var t = $(this);
  1110. if(t.is(":checked")) {
  1111. value = t.val();
  1112. }
  1113. });
  1114. return value;
  1115. };
  1116. // node next step
  1117. var nextStep = function(callback) {
  1118. $.post(basePath + 'common/dealNextStepOfPInstance.action', {
  1119. processInstanceId: instance,
  1120. _noc: 1
  1121. }, function(result, text) {
  1122. if(result.hasNext) {
  1123. if (result.actorUsers.length > 0 && result.actorUsers[0].JP_CANDIDATES.length>0) {
  1124. var html = '<p>';
  1125. html += "下一步审批节点有多位处理人,请指定一位:";
  1126. html += '</p>';
  1127. html += '<form>';
  1128. html += '<div class="form-group" style="max-height:150px;overflow-y:auto;">';
  1129. $.each(result.actorUsers[0].JP_CANDIDATES, function(i, u){
  1130. html += '<label class="radio-inline" style="margin-bottom:10px;margin-right:20px;">';
  1131. html += '<input type="radio" name="user" value="' + u + '"' +
  1132. (i == 0 ? ' checked="checked"' : '') + ' style="position:static;"> ' + u;
  1133. html += '</label>';
  1134. });
  1135. html += '</div>';
  1136. html += '<div class="btn-group btn-group-xs btn-group-justified">';
  1137. html += '<div class="btn-group"><button type="button" class="btn btn-primary" id="confirm">指定</button></div>';
  1138. html += '<div class="btn-group"><button type="button" class="btn btn-default" id="cancel">暂不指定</button></div>';
  1139. html += '</div>';
  1140. html += '</form>';
  1141. dialog.show('下一步', html);
  1142. // choose one to handle next node
  1143. $('#confirm').click(function(){
  1144. appointNext(result.actorUsers[0].JP_NODEID, getBoxValue('form input[type="radio"]'), callback);
  1145. });
  1146. // notice evenyone to receive next node
  1147. $('#cancel').click(function(){
  1148. noticeNext(result.actorUsers[0].JP_NODEID, result.actorUsers[0].JP_CANDIDATES, callback);
  1149. });
  1150. } else {
  1151. callback && callback.call();
  1152. }
  1153. }
  1154. });
  1155. };
  1156. // appoint one to deal next
  1157. var appointNext = function(nodeId, user, callback) {
  1158. $.ajax({
  1159. url:basePath + 'common/takeOverTask.action',
  1160. type: 'POST',
  1161. data: {em_code: user.substring(user.lastIndexOf('(') + 1, user.length - 1), nodeId: nodeId, _noc: 1},
  1162. success: function(result){
  1163. if(result.success)
  1164. callback && callback.call();
  1165. },
  1166. error: function(xhr){
  1167. if(xhr.responseText) {
  1168. var response =$.evalJSON(xhr.responseText);
  1169. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1170. dialog.show('获取信息失败', '请先登录!');
  1171. } else {
  1172. dialog.show('指派失败', response.exceptionInfo);
  1173. }
  1174. }
  1175. }
  1176. });
  1177. };
  1178. // notice next users
  1179. var noticeNext = function(nodeId, users, callback) {
  1180. $.ajax({
  1181. url:basePath + 'common/processpaging.action',
  1182. type: 'POST',
  1183. data: {persons: unescape(users.join(',')), nodeId: nodeId, _noc: 1},
  1184. success: function(result){
  1185. if(result.success)
  1186. callback && callback.call();
  1187. },
  1188. error: function(xhr){
  1189. if(xhr.responseText) {
  1190. var response =$.evalJSON(xhr.responseText);
  1191. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1192. dialog.show('获取信息失败', '请先登录!');
  1193. } else {
  1194. dialog.show('错误', response.exceptionInfo);
  1195. }
  1196. }
  1197. }
  1198. });
  1199. };
  1200. // load next process
  1201. var processNext = function(id) {
  1202. if(id != '-1') {
  1203. var url = window.location.href;
  1204. window.location.href = url.substr(0, url.indexOf('?') + 1) + 'nodeId=' + id;
  1205. } else {
  1206. dialog.show('提示', '暂时没有新的审批任务了!');
  1207. }
  1208. };
  1209. // is valid
  1210. var isValid = function() {
  1211. var bo = true;
  1212. var deals = $('#points input');
  1213. if(deals.length > 0) {
  1214. $.each(deals, function(i, d){
  1215. var e = $(d), type = e.attr('type'), val = e.val();
  1216. if((type === 'text' || type === 'date') && (e.attr('required') === 'required') && !val ){
  1217. bo = false;
  1218. }
  1219. });
  1220. }
  1221. deals = $('#points select');
  1222. if(deals.length > 0) {
  1223. $.each(deals, function(i, d){
  1224. var e = $(d), val = e.val();
  1225. if((e.attr('required') === 'required') && !val)
  1226. bo = false;
  1227. });
  1228. }
  1229. return bo;
  1230. };
  1231. // get your points
  1232. var getDealPoints = function() {
  1233. var deals = $('#points input');
  1234. if(deals.length > 0) {
  1235. var points = [];
  1236. $.each(deals, function(i, d){
  1237. var e = $(d), text = e.attr('title'), type = e.attr('type'), val = e.val(),
  1238. lg = e.attr('logic');
  1239. val = type == 'checkbox' ? (e.is(':checked') ? '是' : '否') : val;
  1240. points.push(text + '(' + val + ')' + (lg ? '@' + lg + '@' : ''));
  1241. });
  1242. return points.join(';');
  1243. }
  1244. return null;
  1245. };
  1246. // agree
  1247. var agree = function() {
  1248. var d = {};
  1249. var bool = true;
  1250. var t = $('#mainForm').serializeArray();
  1251. $.each(t, function() {
  1252. if($('#'+this.name).attr("logic") || $('#'+this.name).attr("logic") != 'ignore'){ //判断logic的属性是否为ignore 忽略
  1253. d[this.name] = this.value;
  1254. }
  1255. });
  1256. //判断主表是否存在未填写的必填字段
  1257. if (requiredFields != null) {//判断必填项是否填写
  1258. $.each(requiredFields, function(key, field){
  1259. if (d[field] == null || d[field] == "") {
  1260. bool = false;
  1261. $.showtip("保存之前请先填写必填的信息!", 2000);
  1262. $('#'+field).focus();
  1263. return;
  1264. }
  1265. });
  1266. }
  1267. if(!bool){
  1268. return ;
  1269. }
  1270. //获取改变了的值
  1271. $.each(d,function(key,field){//只将修改的值提交到后台
  1272. if(d[key] == bill[key])
  1273. delete d[key];
  1274. });
  1275. if(!$.isEmptyObject(d)){
  1276. $.showtip("请先保存修改的数据,再执行后续操作!", 2000);
  1277. return;
  1278. }
  1279. //判断从表是否存在未填写的必填字段
  1280. if(!isValid()) {
  1281. dialog.show(' 警告', '您还有审批要点问题没处理!', -1);
  1282. return;
  1283. }
  1284. setLoading(true);
  1285. $.ajax({
  1286. url:basePath + 'common/review.action',
  1287. type: 'POST',
  1288. data: {taskId: nodeId, nodeName: current.jp_nodeName, nodeLog: $('#deal-msg').val(),
  1289. holdtime: ((new Date() - readyTime) / 1000).toFixed(0),customDes: getDealPoints(),result: true,_noc: 1},
  1290. success: function(result){
  1291. setLoading(false);
  1292. if(result.success) {
  1293. if (result.nextnode == '0') {
  1294. dialog.show('审批成功', '您暂时没有其它的审批任务了。');
  1295. } else {
  1296. if(result.after) {
  1297. if (result.after.trim().substr(0, 12) == 'AFTERSUCCESS') {
  1298. dialog.show('审批出现提示:' + result.after.replace('AFTERSUCCESS', ''),
  1299. '自动为您跳转到下一条...', 5, function(){
  1300. nextStep(function(){
  1301. processNext(result.nextnode);
  1302. });
  1303. });
  1304. } else {
  1305. dialog.show('审批出现异常', result.after);
  1306. }
  1307. } else {
  1308. dialog.show('审批成功', '自动为您跳转到下一条...', 1, function(){
  1309. nextStep(function(){
  1310. processNext(result.nextnode);
  1311. });
  1312. });
  1313. }
  1314. }
  1315. }
  1316. },
  1317. error: function(xhr){
  1318. setLoading(false);
  1319. if(xhr.responseText) {
  1320. var response =$.evalJSON(xhr.responseText);
  1321. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1322. dialog.show('获取用户信息失败', '请先登录!');
  1323. } else {
  1324. dialog.show('无法审批', response.exceptionInfo);
  1325. }
  1326. }
  1327. }
  1328. });
  1329. };
  1330. $('#agree').click(function(){//点击我同意按钮事件
  1331. agree();
  1332. });
  1333. // disagree -> return back
  1334. var disagree = function(backNode, msg){
  1335. setLoading(true);
  1336. $.ajax({
  1337. url:basePath + 'common/review.action',
  1338. type: 'POST',
  1339. data: {taskId: nodeId, nodeName: current.jp_nodeName, backTaskName: backNode, nodeLog: msg,
  1340. holdtime: ((new Date() - readyTime) / 1000).toFixed(0), result: false, _noc: 1},
  1341. success: function(result){
  1342. setLoading(false);
  1343. if(result.success) {
  1344. if(result.after) {
  1345. dialog.show('回退过程出现提示:' + result.after);
  1346. } else {
  1347. dialog.show('回退成功', '自动为您跳转到下一条...', 1, function(){
  1348. nextStep(function(){
  1349. processNext(result.nextnode);
  1350. });
  1351. });
  1352. }
  1353. } else {
  1354. dialog.show('处理结果', "该任务已处理,不能重复操作!");
  1355. }
  1356. },
  1357. error: function(xhr){
  1358. setLoading(false);
  1359. if(xhr.responseText) {
  1360. var response =$.evalJSON(xhr.responseText);
  1361. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1362. dialog.show('获取用户信息失败', '请先登录!');
  1363. } else {
  1364. dialog.show('错误', response.exceptionInfo);
  1365. }
  1366. }
  1367. }
  1368. });
  1369. };
  1370. $('#disagree').click(function(){
  1371. getHistory(instance, function(nodes){
  1372. var html = '<form>';
  1373. html += '<div class="form-group">';
  1374. html += '<label class="radio-inline">';
  1375. html += '<input type="radio" name="node" value="RECORDER" checked="checked"> 制单人';
  1376. html += '</label>';
  1377. $.each(nodes, function(i, n){
  1378. html += '<label class="radio-inline">';
  1379. html += '<input type="radio" name="node" value="' + n.jn_name + '"> ' + n.jn_name;
  1380. html += '</label>';
  1381. });
  1382. html += '</div>';
  1383. html += '<div class="form-group"><textarea id="back-msg" rows="2" placeholder="填写您不同意的原因..." class="form-control">' + $('#deal-msg').val() + '</textarea><span class="help-block text-lg text-error" id="back_err"></span></div>';
  1384. html += '<div class="btn-group btn-group-xs btn-group-justified">';
  1385. html += '<div class="btn-group"><button type="button" class="btn btn-primary" id="back">回退</button></div>';
  1386. html += '<div class="btn-group"><button type="button" class="btn btn-default" id="cancel2">取消</button></div>';
  1387. html += '</div>';
  1388. html += '</form>';
  1389. dialog.show('回退到节点', html);
  1390. // choose one to back
  1391. $('#back').click(function(){
  1392. var msg = $('#back-msg').val();
  1393. if (!msg) {
  1394. $('#back_err').text('请填写您不同意的原因!');
  1395. $('#back-msg').focus();
  1396. } else {
  1397. disagree(getBoxValue('form input[type="radio"]'), msg);
  1398. }
  1399. });
  1400. // cancel
  1401. $('#cancel2').click(function(){
  1402. dialog.hide();
  1403. });
  1404. });
  1405. });
  1406. // end
  1407. var end = function(){
  1408. setLoading(true);
  1409. $.ajax({
  1410. url:basePath + 'common/endProcessInstance.action',
  1411. type: 'POST',
  1412. data: {processInstanceId: instance, holdtime: ((new Date() - readyTime) / 1000).toFixed(0),
  1413. nodeId: nodeId, _noc: 1},
  1414. success: function(result){
  1415. setLoading(false);
  1416. if(result.success) {
  1417. dialog.show('流程已结束', '自动为您跳转到下一条...', 1, function(){
  1418. nextStep(function(){
  1419. processNext(result.nextnode);
  1420. });
  1421. });
  1422. } else {
  1423. dialog.show('警告', "流程实例不存在!");
  1424. }
  1425. },
  1426. error: function(xhr){
  1427. setLoading(false);
  1428. if(xhr.responseText) {
  1429. var response =$.evalJSON(xhr.responseText);
  1430. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1431. dialog.show('获取用户信息失败', '请先登录!');
  1432. } else {
  1433. dialog.show('错误', response.exceptionInfo);
  1434. }
  1435. }
  1436. }
  1437. });
  1438. };
  1439. $('#end').click(function(){
  1440. end();
  1441. });
  1442. // change
  1443. var change = function(user, msg){
  1444. if(!user) {
  1445. $('#change_err').text('您还没选择变更人!');
  1446. return;
  1447. }
  1448. if(!isValid()) {
  1449. $('#change_err').text('您还有审批要点问题没处理!');
  1450. return;
  1451. }
  1452. setLoading(true);
  1453. $.ajax({
  1454. url:basePath + 'common/setAssignee.action',
  1455. type: 'POST',
  1456. data: {taskId: nodeId, assigneeId: user, processInstanceId: instance,
  1457. ncustomDes: getDealPoints(), description: msg, _noc: 1},
  1458. success: function(result){
  1459. setLoading(false);
  1460. if(result.result) {
  1461. dialog.show('处理结果', '节点已成功变更');
  1462. } else {
  1463. dialog.show('处理结果', "任务不存在,无法变更!");
  1464. }
  1465. },
  1466. error: function(xhr){
  1467. setLoading(false);
  1468. if(xhr.responseText) {
  1469. var response =$.evalJSON(xhr.responseText);
  1470. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1471. dialog.show('获取用户信息失败', '请先登录!');
  1472. } else {
  1473. dialog.show('错误', response.exceptionInfo);
  1474. }
  1475. }
  1476. }
  1477. });
  1478. };
  1479. $('#change').click(function(){
  1480. var html = '<form>';
  1481. html += '<div class="form-group has-feedback dropdown"><input id="em_new" name="em_new" class="form-control dropdown-toggle" type="text" placeholder="新的处理人,点击搜索"/><span id="change_search_icon" class="glyphicon glyphicon-search form-control-feedback"></span><div class="dropdown-menuman dropdown-menu"><div id="em_search" class="list-group"></div></div>' +
  1482. '<span class="help-block text-lg">' +
  1483. '<span id="change_name"></span>' +
  1484. '<span id="em_code"></span>' +
  1485. '</span></div>';
  1486. html += '<div class="form-group"><textarea id="change-msg" rows="2" placeholder="填写您要变更的原因..." class="form-control">' + $('#deal-msg').val() + '</textarea><span class="help-block text-lg text-error" id="change_err"></span></div>';
  1487. html += '<div class="btn-group btn-group-xs btn-group-justified">';
  1488. html += '<div class="btn-group"><button type="button" class="btn btn-primary" id="change3">变更</button></div>';
  1489. html += '<div class="btn-group"><button type="button" class="btn btn-default" id="cancel3">取消</button></div>';
  1490. html += '</div>';
  1491. html += '</form>';
  1492. dialog.show('变更办理人', html);
  1493. // search deal man
  1494. $('#em_new').bind('focus', function(){
  1495. if($(this).val()) {
  1496. $(this).parent().children('.dropdown-menuman').css('display', 'block');
  1497. }
  1498. });
  1499. $('#em_new').bind('change', function(){// 点击获取变更的候选人
  1500. var v = $(this).val();
  1501. var view = $(this).parent().children('.dropdown-menuman');
  1502. if(v) {
  1503. view.css('display', 'block');
  1504. getSearchResult(v);
  1505. } else {
  1506. view.css('display', 'none');
  1507. }
  1508. });
  1509. $('#em_new').bind('keyup', function(event){// 回车获取变更的候选人
  1510. if(event.keyCode == 13) {
  1511. event.preventDefault();
  1512. var v = $(this).val();
  1513. var view = $(this).parent().children('.dropdown-menuman');
  1514. if(v) {
  1515. view.css('display', 'block');
  1516. getSearchResult(v);
  1517. } else {
  1518. view.css('display', 'none');
  1519. }
  1520. }
  1521. });
  1522. $('#change_search_icon').bind('click', function(event){// 变更查询放大镜图标点击获取变更的候选人
  1523. var v = $('#em_new').val();
  1524. var view = $('#em_new').parent().parent().children('.dropdown-menuman');
  1525. if(v) {
  1526. view.css('display', 'block');
  1527. getSearchResult(v);
  1528. } else {
  1529. view.css('display', 'none');
  1530. }
  1531. });
  1532. // change
  1533. $('#change3').click(function(){
  1534. var msg = $('#change-msg').val();
  1535. change($('#em_code').text(), msg);
  1536. });
  1537. // cancel
  1538. $('#cancel3').click(function(){
  1539. dialog.hide();
  1540. });
  1541. });
  1542. // get search result
  1543. var getSearchResult = function(input) {
  1544. setLoading(true);
  1545. $.post(basePath + 'hr/emplmana/search.action', {
  1546. keyword: input
  1547. }, function(result, text){
  1548. setLoading(false);
  1549. if(result.length > 0) {
  1550. parseSearchResult(result);
  1551. }
  1552. });
  1553. };
  1554. // parse search result
  1555. var parseSearchResult = function(datas){
  1556. var html = '';
  1557. $.each(datas, function(i, d){
  1558. var e = d.split('\n');
  1559. html += '<a href="javascript:onItemClick(\'' + e[1] + '\',\'' + e[2] + '\');" class="list-group-item">';
  1560. html += '<span class="left">' + (e[0] || '(空)') + '</span>';
  1561. html += '<span class="right">' + e[2] + '(' + e[1] + ')</span>';
  1562. html += '</a>';
  1563. });
  1564. $('#em_search').html(html);
  1565. };
  1566. //关联查询
  1567. var dealRelative = function(caller) {
  1568. $('#expand').html('展开&nbsp;<span '+
  1569. 'class="glyphicon glyphicon-share-alt"></span>');
  1570. $('#expand').click(function(){
  1571. $('#expand').addClass('hidden');
  1572. $('#re-content').removeClass('hidden');
  1573. $('#shrink').removeClass('hidden');
  1574. });
  1575. $('#expand').bind('boxready', function(){
  1576. setLoading(true);
  1577. $.ajax({
  1578. url:basePath + 'common/form/relativeSearchMobile.action',
  1579. type: 'POST',
  1580. data: {caller: caller},
  1581. success: function(result){
  1582. setLoading(false);
  1583. $('#relative .title .text').css('width', (138+result.data[0].form.title.length*18)+'px');
  1584. $('#relative .title .text').append('-'+result.data[0].form.title);
  1585. var html = '';
  1586. html += '<div class="control-group">'+
  1587. '<label class="control-lable" for="'+result.data[0].form.items[0].name+'">'+
  1588. result.data[0].form.items[0].fieldLabel+':</label>'+
  1589. '<select type="text" id="'+result.data[0].form.items[0].name+'" name="'+
  1590. result.data[0].form.items[0].name+'" class="form-control"></select>'+
  1591. '<button id="re-search" type="button" class="btn btn-success">筛选</button>'+
  1592. '</div>';
  1593. $('#re-filtrate').html(html);
  1594. },
  1595. error: function(xhr){
  1596. setLoading(false);
  1597. if(xhr.responseText) {
  1598. var response =$.evalJSON(xhr.responseText);
  1599. if(response.exceptionInfo == 'ERR_NETWORK_SESSIONOUT') {
  1600. dialog.show('获取信息失败', '请先登录!', 1, function(){dialog.hide();})
  1601. } else {
  1602. dialog.show('错误', response.exceptionInfo,1, function(){dialog.hide();});
  1603. }
  1604. }
  1605. }
  1606. });
  1607. });
  1608. $('#shrink').click(function(){
  1609. $('#expand').removeClass('hidden');
  1610. $('#re-content').addClass('hidden');
  1611. $('#shrink').addClass('hidden');
  1612. });
  1613. };
  1614. // touch on mobile need jquery-mobile.js & event 'tap'
  1615. window.onItemClick = function(code, name) {
  1616. $('#em_search').parent().css('display', 'none');
  1617. $('#change_name').text(name + ' - ')
  1618. $('#em_code').text(code);
  1619. };
  1620. });