FormUtil.js 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616
  1. /**
  2. * 与formpanel操作相关的增删改查的操作方法都在这里哦
  3. * 如果formpanel作为主表,还有一些gridpanel等的信息作为附表,form操作时还包括了对gridpanel等的操作
  4. * @author yingp
  5. */
  6. Ext.define('erp.util.FormUtil',{
  7. /**
  8. * 从后台拿到formpanel配置
  9. * @param form formpanel表
  10. * @param url 提交的action名
  11. * @param param 传递回去的数据,比如{caller:Purchase,condition:pu_id=30001}
  12. */
  13. takeoveraction:'common/takeOverTask.action',
  14. deleteProcess:'common/deleteProcessAfterAudit.action?_noc=1',
  15. getItemsAndButtons: function(form, url, param){
  16. var me = this, tab = me.getActiveTab();
  17. me.setLoading(true);
  18. Ext.Ajax.request({//拿到form的items
  19. url : basePath + url,
  20. params: param,
  21. method : 'post',
  22. callback : function(options, success, response){
  23. me.setLoading(false);
  24. if (!response) return;
  25. var res = new Ext.decode(response.responseText);
  26. if(res.exceptionInfo != null){
  27. showError(res.exceptionInfo);return;
  28. }
  29. form.fo_id = res.fo_id;
  30. form.fo_keyField = res.keyField;
  31. form.tablename = res.tablename;//表名
  32. if(res.keyField){//主键
  33. form.keyField = res.keyField;
  34. }
  35. if(res.statusField){//状态
  36. form.statusField = res.statusField;
  37. }
  38. if(res.statuscodeField){//状态码
  39. form.statuscodeField = res.statuscodeField;
  40. }
  41. if(res.codeField){//Code
  42. form.codeField = res.codeField;
  43. }
  44. if(res.dealUrl){
  45. form.dealUrl = res.dealUrl;
  46. }
  47. form.fo_detailMainKeyField = res.fo_detailMainKeyField;//从表外键字段
  48. //data&items
  49. var items = me.setItems(form, res.items, res.data, res.limits, {
  50. labelColor: res.necessaryFieldColor
  51. });
  52. form.add(items);
  53. //title
  54. if(res.title && res.title != ''){
  55. if(form.source=='allnavigation'){
  56. form.setTitle(res.title+'<font color=red>[界面展示]</font>');
  57. }else{
  58. form.setTitle(res.title);
  59. }
  60. var _tt = res.title;
  61. if(form.codeField) {
  62. var _c = form.down('#' + form.codeField);
  63. if( _c && !Ext.isEmpty(_c.value) )
  64. _tt += '(' + _c.value + ')';
  65. }
  66. if(tab && tab.id!='HomePage') tab.setTitle(_tt);
  67. }
  68. if(!form._nobutton) me.setButtons(form, res.buttons);
  69. //form第一个可编辑框自动focus
  70. me.focusFirst(form);
  71. form.fireEvent('afterload', form);
  72. }
  73. });
  74. },
  75. focusFirst: function(form){
  76. var bool = true;
  77. if(!form.readOnly){
  78. Ext.each(form.items.items, function(){
  79. if(bool && this.hidden == false && this.readOnly == false && this.editable == true){
  80. this.focus(false, 200);
  81. bool = false;
  82. }
  83. });
  84. }
  85. },
  86. /**
  87. * 调整字段显示宽度
  88. */
  89. setItemWidth: function(form, items) {
  90. var grids = Ext.ComponentQuery.query('gridpanel');
  91. var formWidth = window.innerWidth, maxSize = 0.097 * formWidth,
  92. // 宽屏
  93. wide = screen.width > 1280,
  94. // 如果该页面只有一个form,而且form字段少于8个
  95. sm = (!form.fixedlayout && !form.minMode && grids.length == 0 && items.length <= 8),
  96. // 如果该页面字段过多
  97. lg = items.length > maxSize;
  98. Ext.each(items, function(item){
  99. if(sm) {
  100. item.columnWidth = 0.5;
  101. } else if(lg) {
  102. // 4.0.7版本下必须使用固定宽度
  103. item.width = formWidth*(item.columnWidth) - item.columnWidth*4*10;
  104. } else if(form.minMode) {// 布局里面设置为minMode模式
  105. if(item.columnWidth >= 0 && item.columnWidth < 0.5){
  106. item.columnWidth = 0.5;
  107. } else if(item.columnWidth >= 0.5) {
  108. item.columnWidth = 1;
  109. }
  110. } else {
  111. if(wide) {
  112. if(item.columnWidth > 0.25 && item.columnWidth < 0.5){
  113. item.columnWidth = 1/3;
  114. } else if(item.columnWidth > 0.5 && item.columnWidth < 0.75){
  115. item.columnWidth = 2/3;
  116. }
  117. } else {
  118. if(item.columnWidth > 0 && item.columnWidth <= 0.25){
  119. item.columnWidth = 1/3;
  120. } else if(item.columnWidth > 0.25 && item.columnWidth <= 0.5){
  121. item.columnWidth = 2/3;
  122. } else if(item.columnWidth >= 1){
  123. item.columnWidth = 1;
  124. }
  125. }
  126. }
  127. });
  128. if(sm) {
  129. form.layout = 'column';
  130. }
  131. },
  132. /**
  133. * @param necessaryCss 必填项样式
  134. */
  135. setItems: function(form, items, data, limits, necessaryCss){
  136. var me = this,edit = !form.readOnly,hasData = true,limitArr = new Array();
  137. if(limits != null && limits.length > 0) {//权限外字段
  138. limitArr = Ext.Array.pluck(limits, 'lf_field');
  139. }
  140. if (data) {
  141. data = Ext.decode(data);
  142. if(form.statuscodeField && data[form.statuscodeField] != null && data[form.statuscodeField] != '' &&
  143. ['ENTERING', 'UNAUDIT', 'UNPOST', 'CANUSE'].indexOf(data[form.statuscodeField]) == -1){//非在录入和已提交均设置为只读// && data[form.statuscodeField] != 'COMMITED'
  144. form.readOnly = true;
  145. edit = false;
  146. }
  147. if(form.statusCode && data[form.statusCode] == 'POSTED'){//存在单据状态 并且单据状态不等于空 并且 单据状态等于已过账
  148. form.readOnly = true;
  149. edit = false;
  150. }
  151. } else {
  152. hasData = false;
  153. }
  154. me.setItemWidth(form, items);
  155. Ext.each(items, function(item){
  156. if(!item.allowBlank && item.fieldLabel && necessaryCss.labelColor) {
  157. item.labelStyle = 'color:#' + necessaryCss.labelColor;
  158. item.fieldStyle = 'background:#FFFAFA;color:#515151;';
  159. if(item.xtype=='mfilefield'){//附件类型必填设置title颜色
  160. this.title = '<font color=#'+necessaryCss.labelColor+'>'+this.title|| '附件'+'</font>' ;
  161. }
  162. }
  163. if(item.readOnly) {
  164. item.fieldStyle = 'background:#e0e0e0;';
  165. }
  166. if(item.renderfn){
  167. var args = new Array();
  168. if(contains(item.renderfn, ':', true)){
  169. Ext.each(item.renderfn.split(':'), function(a, index){
  170. if(index == 0){
  171. renderName = a;
  172. } else {
  173. args.push(a);
  174. }
  175. });
  176. } else
  177. renderName=item.renderfn;
  178. me[renderName](item, args, form);
  179. }
  180. if(item.name != null) {
  181. if(item.name == form.statusField){//状态加特殊颜色
  182. item.fieldStyle = item.fieldStyle + ';font-weight:bold;';
  183. } else if(item.name == form.statuscodeField){//状态码字段强制隐藏
  184. item.xtype = 'hidden';
  185. }
  186. }
  187. if(item.xtype == 'hidden') {
  188. item.columnWidth = 0;
  189. item.margin = '0';
  190. }
  191. if(item.xtype == 'checkbox') {
  192. item.focusCls = '';
  193. }
  194. if(item.maskRe!=null){
  195. item.maskRe=new RegExp(item.regex);
  196. }
  197. if (hasData) {
  198. item.value = data[item.name];
  199. if(item.secondname){//针对合并型的字段MultiField
  200. item.secondvalue = data[item.secondname];
  201. }
  202. if(!edit){
  203. form.readOnly = true;
  204. item.fieldStyle = item.fieldStyle + ';background:#f1f1f1;';
  205. item.readOnly = true;
  206. }
  207. if(item.xtype == 'checkbox'){
  208. item.checked = Math.abs(item.value || 0) == 1;
  209. item.fieldStyle = '';
  210. }
  211. }else{
  212. if(form.source=='allnavigation'){
  213. item.fieldStyle = item.fieldStyle + ';background:#f1f1f1;';
  214. item.readOnly = true;
  215. }
  216. }
  217. if(limitArr.length > 0 && Ext.Array.contains(limitArr, item.name)) {
  218. item.hidden = true;
  219. }
  220. });
  221. return items;
  222. },
  223. setButtons: function(form, buttonString){
  224. if(buttonString != null && buttonString.trim() != ''){
  225. var buttons = new Array();
  226. buttons.push('->');//->使buttons放在toolbar中间
  227. Ext.each(buttonString.split('#'), function(btn, index){
  228. var o = {};
  229. o.xtype = btn;
  230. o.height = 26;
  231. buttons.push(o);
  232. if((index + 1)%12 == 0){//每行显示12个button,超过12个就添加一个bbar
  233. buttons.push('->');
  234. form.addDocked({
  235. xtype: 'toolbar',
  236. dock: 'bottom',
  237. defaults: {
  238. style: {
  239. marginLeft: '10px'
  240. }
  241. },
  242. items: buttons//12个加进去
  243. });
  244. buttons = new Array();//清空
  245. buttons.push('->');
  246. }
  247. });
  248. buttons.push('->');
  249. form.addDocked({//未到12个的
  250. xtype: 'toolbar',
  251. dock: 'bottom',
  252. defaults: {
  253. style: {
  254. marginLeft: '10px'
  255. }
  256. },
  257. items: buttons
  258. });
  259. }
  260. },
  261. loadNewStore: function(form, param){
  262. var me = this;
  263. me.setLoading(true);
  264. Ext.Ajax.request({
  265. url : basePath + "common/loadNewFormStore.action",
  266. params: param,
  267. method : 'post',
  268. callback : function(options,success,response){
  269. me.setLoading(false);
  270. var res = new Ext.decode(response.responseText);
  271. if(res.exceptionInfo != null){
  272. showError(res.exceptionInfo);return;
  273. }
  274. if(res.data){
  275. var d = Ext.decode(res.data);
  276. form.getForm().setValues(d);
  277. var chs = form.query('checkbox');
  278. Ext.each(chs, function(){
  279. this.setValue(Math.abs(d[this.name] || 0) == 1);
  280. });
  281. form.getForm().getFields().each(function (item,index,length){
  282. item.originalValue = item.value;
  283. });
  284. }
  285. }
  286. });
  287. },
  288. getSeqId: function(form){
  289. if(!form){
  290. form = Ext.getCmp('form');
  291. }
  292. Ext.Ajax.request({
  293. url : basePath + form.getIdUrl,
  294. method : 'get',
  295. async: false,
  296. callback : function(options,success,response){
  297. var rs = new Ext.decode(response.responseText);
  298. if(rs.exceptionInfo){
  299. showError(rs.exceptionInfo);return;
  300. }
  301. if(rs.success){
  302. Ext.getCmp(form.keyField).setValue(rs.id);
  303. }
  304. }
  305. });
  306. },
  307. /**
  308. * 保存之前的判断
  309. * @param arg 额外参数
  310. */
  311. beforeSave: function(me, arg){
  312. var mm = this;
  313. var form = Ext.getCmp('form');
  314. if(! mm.checkForm()){
  315. return;
  316. }
  317. if(form.keyField){
  318. if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
  319. mm.getSeqId(form);
  320. }
  321. }
  322. var grids = Ext.ComponentQuery.query('gridpanel');
  323. var removea = new Array();
  324. Ext.each(grids,function(g,index){
  325. if(g.xtype=='itemgrid'){
  326. g.saveValue();
  327. removea.push(g);
  328. }
  329. });
  330. Ext.each(removea,function(r,index){
  331. Ext.Array.remove(grids,r);
  332. });
  333. if(grids.length > 0 && !grids[0].ignore){
  334. var param = me.GridUtil.getGridStore();
  335. if(grids[0].necessaryField&&grids[0].necessaryField.length > 0 && (param == null || param == '')){
  336. var errInfo = me.GridUtil.getUnFinish(grids[0]);
  337. if(errInfo.length > 0)
  338. errInfo = '明细表有必填字段未完成填写, 继续将不会保存未完成的数据,是否继续?<hr>' + errInfo;
  339. else
  340. errInfo = '明细表还未添加数据, 是否继续?';
  341. warnMsg(errInfo, function(btn){
  342. if(btn == 'yes'){
  343. mm.onSave(param, arg);
  344. } else {
  345. return;
  346. }
  347. });
  348. } else {
  349. mm.onSave(param, arg);
  350. }
  351. } else {
  352. mm.onSave([]);
  353. }
  354. },
  355. /**
  356. * 单据保存
  357. * @param param 传递过来的数据,比如gridpanel的数据
  358. */
  359. onSave: function(param, arg){
  360. var me = this;
  361. var form = Ext.getCmp('form');
  362. param = param == null ? [] : "[" + param.toString() + "]";
  363. if(form.getForm().isValid()){
  364. //form里面数据
  365. Ext.each(form.items.items, function(item){
  366. if(item.xtype == 'numberfield'){
  367. //number类型赋默认值,不然sql无法执行
  368. if(item.value == null || item.value == ''){
  369. item.setValue(0);
  370. }
  371. }
  372. });
  373. var r = form.getValues();
  374. Ext.each(form.items.items, function(item){
  375. if(item.xtype == 'itemgrid'){
  376. //number类型赋默认值,不然sql无法执行
  377. if(item.value != null && item.value != ''){
  378. r[item.name]=item.value;
  379. }
  380. }
  381. });
  382. //去除ignore字段
  383. var keys = Ext.Object.getKeys(r), f;
  384. var reg = /[!@#$%^&*()'":,\/?]|[\t|\n|\r]/g;
  385. Ext.each(keys, function(k){
  386. f = form.down('#' + k);
  387. if(f && f.logic == 'ignore') {
  388. delete r[k];
  389. }
  390. //codeField值强制大写,自动过滤特殊字符
  391. if(k == form.codeField && !Ext.isEmpty(r[k])) {
  392. r[k] = r[k].trim().toUpperCase().replace(reg, '');
  393. }
  394. });
  395. if(!me.contains(form.saveUrl, '?caller=', true)){
  396. form.saveUrl = form.saveUrl + "?caller=" + caller;
  397. }
  398. me.save(r, param, arg);
  399. }else{
  400. me.checkForm();
  401. }
  402. },
  403. save: function(){
  404. var params = new Object();
  405. var r = arguments[0];
  406. Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
  407. if(contains(k, '-', true) && !contains(k,'-new',true)){
  408. delete r[k];
  409. }
  410. });
  411. params.formStore = unescape(escape(Ext.JSON.encode(r)));
  412. params.param = unescape(arguments[1].toString());
  413. for(var i=2; i<arguments.length; i++) { //兼容多参数
  414. if(arguments[i])
  415. params['param' + i] = unescape(arguments[i].toString());
  416. }
  417. var me = this;
  418. var form = Ext.getCmp('form'), url = form.saveUrl;
  419. if(url.indexOf('caller=') == -1){
  420. url = url + "?caller=" + caller;
  421. }
  422. me.setLoading(true);
  423. Ext.Ajax.request({
  424. url : basePath + url,
  425. params : params,
  426. method : 'post',
  427. callback : function(options,success,response){
  428. me.setLoading(false);
  429. var localJson = new Ext.decode(response.responseText);
  430. if(localJson.success){
  431. saveSuccess(function(){
  432. //add成功后刷新页面进入可编辑的页面
  433. var value =r[form.keyField];
  434. var formCondition = form.keyField + "IS" + value ;
  435. var gridCondition = '';
  436. var grid = Ext.getCmp('grid');
  437. if(grid && grid.mainField){
  438. gridCondition = grid.mainField + "IS" + value;
  439. }
  440. if(me.contains(window.location.href, '?', true)){
  441. window.location.href = window.location.href + '&formCondition=' +
  442. formCondition + '&gridCondition=' + gridCondition;
  443. } else {
  444. window.location.href = window.location.href + '?formCondition=' +
  445. formCondition + '&gridCondition=' + gridCondition;
  446. }
  447. });
  448. } else if(localJson.exceptionInfo){
  449. var str = localJson.exceptionInfo;
  450. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  451. str = str.replace('AFTERSUCCESS', '');
  452. saveSuccess(function(){
  453. //add成功后刷新页面进入可编辑的页面
  454. var value = r[form.keyField];
  455. var formCondition = form.keyField + "IS" + value ;
  456. var gridCondition = '';
  457. var grid = Ext.getCmp('grid');
  458. if(grid && grid.mainField){
  459. gridCondition = grid.mainField + "IS" + value;
  460. }
  461. if(me.contains(window.location.href, '?', true)){
  462. window.location.href = window.location.href + '&formCondition=' +
  463. formCondition + '&gridCondition=' + gridCondition;
  464. } else {
  465. window.location.href = window.location.href + '?formCondition=' +
  466. formCondition + '&gridCondition=' + gridCondition;
  467. }
  468. });
  469. showError(str);
  470. } else {
  471. showError(str);
  472. return;
  473. }
  474. } else{
  475. saveFailure();//@i18n/i18n.js
  476. }
  477. }
  478. });
  479. },
  480. /**
  481. * 检查form未完善的字段
  482. */
  483. checkForm: function(){
  484. var s = '';
  485. var form = Ext.getCmp('form');
  486. form.getForm().getFields().each(function (item, index, length){
  487. if(!item.isValid()){
  488. if(s != ''){
  489. s += ',';
  490. }
  491. if(item.fieldLabel || item.ownerCt.fieldLabel){
  492. s += item.fieldLabel || item.ownerCt.fieldLabel;
  493. }
  494. }
  495. });
  496. if(s == ''){
  497. return true;
  498. }
  499. showError($I18N.common.form.necessaryInfo1 + '(<font color=green>' + s.replace(/&nbsp;/g,'') +
  500. '</font>)' + $I18N.common.form.necessaryInfo2);
  501. return false;
  502. },
  503. /**
  504. * 删除操作
  505. */
  506. onDelete: function(id){
  507. var me = this;
  508. warnMsg($I18N.common.msg.ask_del_main, function(btn){
  509. if(btn == 'yes'){
  510. var form = Ext.getCmp('form');
  511. if(!me.contains(form.deleteUrl, '?caller=', true)){
  512. form.deleteUrl = form.deleteUrl + "?caller=" + caller;
  513. }
  514. me.setLoading(true);
  515. Ext.Ajax.request({
  516. url : basePath + form.deleteUrl,
  517. params: {
  518. id: id
  519. },
  520. method : 'post',
  521. callback : function(options,success,response){
  522. me.setLoading(false);
  523. var localJson = new Ext.decode(response.responseText);
  524. if(localJson.exceptionInfo){
  525. showError(localJson.exceptionInfo);return;
  526. }
  527. if(localJson.success){
  528. delSuccess(function(){
  529. me.onClose();
  530. });//@i18n/i18n.js
  531. } else {
  532. delFailure();
  533. }
  534. }
  535. });
  536. }
  537. });
  538. },
  539. /**
  540. * 单据修改
  541. * @param
  542. * @param
  543. * @param opts 获取form数据的参数{asString, dirtyOnly, includeEmptyText, useDataValues}
  544. * @param extra 额外参数
  545. */
  546. onUpdate: function(me, ignoreWarn, opts, extra){
  547. var mm = this;
  548. var form = Ext.getCmp('form');
  549. var s1 = mm.checkFormDirty(form);
  550. var s2 = '';
  551. var grids = Ext.ComponentQuery.query('gridpanel');
  552. var removea = new Array();
  553. if(form.codeField && (Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == '')){
  554. showError('编号不能为空.');
  555. return;
  556. }
  557. Ext.each(grids,function(g,index){
  558. if(g.xtype=='itemgrid'){
  559. g.saveValue();
  560. removea.push(g);
  561. }
  562. });
  563. Ext.each(removea,function(r,index){
  564. Ext.Array.remove(grids,r);
  565. });
  566. if(grids.length > 0 && !grids[0].ignore){//check所有grid是否已修改
  567. Ext.each(grids, function(grid, index){
  568. if(grid.GridUtil){
  569. var msg = grid.GridUtil.checkGridDirty(grid);
  570. if(msg.length > 0){
  571. s2 = s2 + '<br/>' + msg;
  572. }
  573. }
  574. });
  575. }
  576. if(s1 == '' && (s2 == '' || s2 == '<br/>')){
  577. showError('还未添加或修改数据.');
  578. return;
  579. }
  580. if(form && form.getForm().isValid()){
  581. //form里面数据
  582. var r = (opts && opts.dirtyOnly) ? form.getForm().getValues(false, true) :
  583. form.getValues();
  584. //去除ignore字段
  585. var keys = Ext.Object.getKeys(r), f;
  586. var reg = /[!@#$%^&*()'":,\/?]|[\t|\n|\r]/g;
  587. Ext.each(keys, function(k){
  588. f = form.down('#' + k);
  589. if(f && f.logic == 'ignore') {
  590. delete r[k];
  591. }
  592. if(f && opts && opts.dirtyOnly) {
  593. extra = (extra || '') +
  594. '\n(' + f.fieldLabel + ') old: ' + f.originalValue + ' new: ' + r[k];
  595. }
  596. //codeField值强制大写,自动过滤特殊字符
  597. if(k == form.codeField && !Ext.isEmpty(r[k])) {
  598. r[k] = r[k].trim().toUpperCase().replace(reg, '');
  599. }
  600. });
  601. if(opts && opts.dirtyOnly && form.keyField) {
  602. r[form.keyField] = form.down("#" + form.keyField).getValue();
  603. }
  604. if(!mm.contains(form.updateUrl, '?caller=', true)){
  605. form.updateUrl = form.updateUrl + "?caller=" + caller;
  606. }
  607. var params = [];
  608. if(grids.length > 0 && grids[0].columns.length > 0 && !grids[0].ignore){
  609. if(grids[0].GridUtil.isEmpty(grids[0])) {
  610. warnMsg('明细还未录入数据,是否继续保存?', function(btn){
  611. if(btn == 'yes' || btn == 'ok'){
  612. mm.update(r, '[]', extra);
  613. } else {
  614. return;
  615. }
  616. });
  617. } else if(grids[0].GridUtil.isDirty(grids[0])) {
  618. var param = grids[0].GridUtil.getGridStore();
  619. if(grids[0].necessaryField && grids[0].necessaryField.length > 0 && (param == null || param.length == 0 || param == '') && !ignoreWarn){
  620. warnMsg('明细表有必填项未填写,是否继续保存?', function(btn){
  621. if(btn == 'yes' || btn == 'ok'){
  622. params = unescape("[" + param.toString() + "]");
  623. mm.update(r, params, extra);
  624. } else {
  625. return;
  626. }
  627. });
  628. } else {
  629. params = unescape("[" + param.toString() + "]");
  630. mm.update(r, params, extra);
  631. }
  632. } else {
  633. mm.update(r, '[]', extra);
  634. }
  635. } else {
  636. mm.update(r, params, extra);
  637. }
  638. }else{
  639. mm.checkForm(form);
  640. }
  641. },
  642. update: function(){
  643. var me = this, params = new Object();
  644. var r = arguments[0];
  645. Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
  646. if(contains(k, '-', true) && !contains(k,'-new',true)){
  647. delete r[k];
  648. }
  649. });
  650. params.formStore = unescape(escape(Ext.JSON.encode(r)));
  651. params.param = unescape(arguments[1].toString());
  652. for(var i=2; i<arguments.length; i++) { //兼容多参数
  653. if (arguments[i] != null)
  654. params['param' + i] = unescape(arguments[i].toString());
  655. }
  656. var form = Ext.getCmp('form'), url = form.updateUrl;
  657. if(url.indexOf('caller=') == -1){
  658. url = url + "?caller=" + caller;
  659. }
  660. me.setLoading(true);//loading...
  661. Ext.Ajax.request({
  662. url : basePath + url,
  663. params: params,
  664. method : 'post',
  665. callback : function(options,success,response){
  666. me.setLoading(false);
  667. var localJson = new Ext.decode(response.responseText);
  668. if(localJson.success){
  669. showMessage('提示', '保存成功!', 1000);
  670. //update成功后刷新页面进入可编辑的页面
  671. var u = String(window.location.href);
  672. if (u.indexOf('formCondition') == -1) {
  673. var value = r[form.keyField];
  674. var formCondition = form.keyField + "IS" + value ;
  675. var gridCondition = '';
  676. var grid = Ext.getCmp('grid');
  677. if(grid && grid.mainField){
  678. gridCondition = grid.mainField + "IS" + value;
  679. }
  680. if(me.contains(window.location.href, '?', true)){
  681. window.location.href = window.location.href + '&formCondition=' +
  682. formCondition + '&gridCondition=' + gridCondition;
  683. } else {
  684. window.location.href = window.location.href + '?formCondition=' +
  685. formCondition + '&gridCondition=' + gridCondition;
  686. }
  687. } else {
  688. window.location.reload();
  689. }
  690. } else if(localJson.exceptionInfo){
  691. var str = localJson.exceptionInfo;
  692. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  693. str = str.replace('AFTERSUCCESS', '');
  694. //update成功后刷新页面进入可编辑的页面
  695. var u = String(window.location.href);
  696. if (u.indexOf('formCondition') == -1) {
  697. var value = r[form.keyField];
  698. var formCondition = form.keyField + "IS" + value ;
  699. var gridCondition = '';
  700. var grid = Ext.getCmp('grid');
  701. if(grid && grid.mainField){
  702. gridCondition = grid.mainField + "IS" + value;
  703. }
  704. if(me.contains(window.location.href, '?', true)){
  705. window.location.href = window.location.href + '&formCondition=' +
  706. formCondition + '&gridCondition=' + gridCondition;
  707. } else {
  708. window.location.href = window.location.href + '?formCondition=' +
  709. formCondition + '&gridCondition=' + gridCondition;
  710. }
  711. } else {
  712. window.location.reload();
  713. }
  714. }
  715. showError(str);return;
  716. } else {
  717. updateFailure();
  718. }
  719. }
  720. });
  721. },
  722. /**
  723. * 关闭之前进行一些判断,根据用户选择或保存或关闭
  724. *
  725. */
  726. beforeClose: function(me){
  727. var mm = this;
  728. var s = '';
  729. var forms = Ext.ComponentQuery.query('formpanel');
  730. if(forms.length > 0 && !forms[0].ignore){//check所有form是否已修改
  731. Ext.each(forms, function(form, index){
  732. var msg = mm.checkFormDirty(form);
  733. if(msg.length > 0){
  734. s = s + '<br/>' + msg;
  735. }
  736. });
  737. }
  738. var grids = Ext.ComponentQuery.query('gridpanel');
  739. if(grids.length > 0 && !grids[0].ignore && me.GridUtil){//check所有grid是否已修改
  740. Ext.each(grids, function(grid, index){
  741. var msg = me.GridUtil.checkGridDirty(grid);
  742. if(msg.length > 0){
  743. s = s + '<br/>' + msg;
  744. }
  745. });
  746. }
  747. if(s == '' || s == '<br/>'){
  748. mm.onClose();
  749. } else {
  750. if(!formCondition){//单据新增界面哦
  751. //关闭前保存新增的数据
  752. Ext.MessageBox.show({//关闭前保存修改的数据
  753. title:'保存新添加的数据?',
  754. msg: '详细:<br/>' + s + '<br/>离开前要保存吗?',
  755. buttons: Ext.Msg.YESNOCANCEL,
  756. icon: Ext.Msg.WARNING,
  757. fn: function(btn){
  758. if(btn == 'yes'){
  759. mm.beforeSave(me);
  760. } else if(btn == 'no'){
  761. mm.onClose();
  762. } else {
  763. return;
  764. }
  765. }
  766. });
  767. } else {//单据查看界面哦
  768. Ext.MessageBox.show({
  769. title:'保存修改?',
  770. msg: '该单据已被修改:<br/>' + s + '<br/>离开前要保存吗?',
  771. buttons: Ext.Msg.YESNOCANCEL,
  772. icon: Ext.Msg.WARNING,
  773. fn: function(btn){
  774. if(btn == 'yes'){
  775. mm.onUpdate(form, []);
  776. } else if(btn == 'no'){
  777. mm.onClose();
  778. } else {
  779. return;
  780. }
  781. }
  782. });
  783. }
  784. }
  785. },
  786. /**
  787. * 检查表单是否被修改,并返回被修改的内容
  788. */
  789. checkFormDirty: function(){
  790. var form = Ext.getCmp('form');
  791. var s = '';
  792. form.getForm().getFields().each(function (item,index, length){
  793. if(item.logic!='ignore'){
  794. var value = item.value == null ? "" : item.value;
  795. if(item.xtype == 'htmleditor') {
  796. value = item.getValue();
  797. }
  798. item.originalValue = item.originalValue == null ? "" : item.originalValue;
  799. if(Ext.typeOf(item.originalValue) != 'object'){
  800. if(item.originalValue.toString() != value.toString()){//isDirty、wasDirty、dirty一直都是true,没办法判断,所以直接用item.originalValue,原理是一样的
  801. var label = item.fieldLabel || item.ownerCt.fieldLabel ||
  802. item.boxLabel || item.ownerCt.title;//针对fieldContainer、radio、fieldset等
  803. if(label){
  804. s = s + '&nbsp;' + label.replace(/&nbsp;/g,'');
  805. }
  806. }
  807. }
  808. }
  809. });
  810. return (s == '') ? s : ('表单字段(<font color=green>'+s+'</font>)已修改');
  811. },
  812. /**
  813. * 关闭操作
  814. */
  815. onClose: function(){
  816. var modal=parent.Ext.getCmp('modalwindow');
  817. if(modal){
  818. var history=modal.historyMaster;
  819. Ext.Ajax.request({
  820. url: basePath + 'common/changeMaster.action',
  821. params: {
  822. to: history
  823. },
  824. callback: function(opt, s, r) {
  825. if (s) {
  826. modal.close();
  827. } else {
  828. alert('切换到原账套失败!');
  829. }
  830. }
  831. });
  832. }else{
  833. var main = parent.Ext.getCmp("content-panel"),bool = false;
  834. if(main){
  835. bool = true;
  836. main.getActiveTab().close();
  837. } else {
  838. var win = parent.Ext.ComponentQuery.query('window');
  839. if(win){
  840. Ext.each(win, function(){
  841. this.close();
  842. });
  843. } else {
  844. bool = true;
  845. window.close();
  846. }
  847. }
  848. var p = Ext.ComponentQuery.query('erpCloseButton');
  849. if(!bool && p){//如果还是没关闭tab,直接关闭页面
  850. window.close();
  851. }
  852. }
  853. },
  854. /**
  855. * 跳转到add页面
  856. */
  857. onAdd: function(panelId, title, url){
  858. var main = parent.Ext.getCmp("content-panel");
  859. if(main){
  860. panelId = (panelId == main.getActiveTab().id || panelId == null)
  861. ? Math.random() : panelId;
  862. var panel = Ext.getCmp(panelId);
  863. if(!panel){
  864. var value = "";
  865. if (title.toString().length>5) {
  866. value = title.toString().substring(0,5);
  867. } else {
  868. value = title;
  869. }
  870. if(!contains(url, 'http://', true) && !contains(url, basePath, true)){
  871. url = basePath + url;
  872. }
  873. panel = {
  874. title : value,
  875. tag : 'iframe',
  876. tabConfig:{tooltip:title},
  877. border : false,
  878. layout : 'fit',
  879. iconCls : 'x-tree-icon-tab-tab',
  880. html : '<iframe id="iframe_add_'+panelId+'" src="' + url+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  881. closable : true
  882. };
  883. this.openTab(panel, panelId);
  884. } else {
  885. main.setActiveTab(panel);
  886. }
  887. } else {
  888. if(!contains(url, basePath, true)){
  889. url = basePath + url;
  890. }
  891. window.open(url);
  892. }
  893. },
  894. /**
  895. * 取{field}值,自动赋值给{tField}
  896. * @param caller 表名
  897. * @param tField 待赋值的字段
  898. * @param [record 待赋值的明细行]
  899. */
  900. getFieldValue: function(caller, field, condition, tField, record){
  901. Ext.Ajax.request({
  902. url : basePath + 'common/getFieldData.action',
  903. async: false,
  904. params: {
  905. caller: caller,
  906. field: field,
  907. condition: condition
  908. },
  909. method : 'post',
  910. callback : function(options,success,response){
  911. var localJson = new Ext.decode(response.responseText);
  912. if(localJson.exceptionInfo){
  913. showError(localJson.exceptionInfo);return;
  914. }
  915. if(localJson.success){
  916. if(localJson.data != null){
  917. if(record){
  918. record.set(tField, localJson.data);
  919. } else {
  920. var ff = Ext.getCmp(tField);
  921. if(ff)
  922. ff.setValue(localJson.data);
  923. }
  924. }
  925. }
  926. }
  927. });
  928. },
  929. /**
  930. * 取{fields}值,自动赋值给{tFields},field用','隔开
  931. * @param caller 表名
  932. * @param tFields 待赋值的字段
  933. * @param [record 待赋值的明细行]
  934. */
  935. getFieldsValue: function(caller, fields, condition, tFields, record){
  936. Ext.Ajax.request({
  937. url : basePath + 'common/getFieldsData.action',
  938. async: false,
  939. params: {
  940. caller: caller,
  941. fields: fields,
  942. condition: condition
  943. },
  944. method : 'post',
  945. callback : function(options,success,response){
  946. var localJson = new Ext.decode(response.responseText);
  947. if(localJson.exceptionInfo){
  948. showError(localJson.exceptionInfo);return;
  949. }
  950. if(localJson.success){
  951. if(record){
  952. if(localJson.data != null){
  953. var fis = fields.split(',');
  954. Ext.each(tFields.split(','), function(f, index){
  955. if( localJson.data[fis[index]] != null){
  956. record.set(f, localJson.data[fis[index]]);
  957. }
  958. });
  959. }
  960. } else {
  961. if(localJson.data != null){
  962. var fis = fields.split(',');
  963. Ext.each(tFields.split(','), function(f, index){
  964. if(localJson.data[fis[index]] != null){
  965. var fi = Ext.getCmp(f);
  966. if (fi)
  967. fi.setValue(localJson.data[fis[index]]);
  968. }
  969. });
  970. }
  971. }
  972. }
  973. }
  974. });
  975. },
  976. /**
  977. * 取{fields}值
  978. * @param caller 表名
  979. */
  980. getFieldsValues: function(caller, fields, condition, data, fn){
  981. Ext.Ajax.request({
  982. url : basePath + 'common/getFieldsDatas.action',
  983. async: false,
  984. params: {
  985. caller: caller,
  986. fields: fields,
  987. condition: condition
  988. },
  989. method : 'post',
  990. callback : function(options,success,response){
  991. var localJson = new Ext.decode(response.responseText);
  992. if(localJson.exceptionInfo){
  993. showError(localJson.exceptionInfo);return;
  994. }
  995. if(localJson.success){
  996. data = localJson.data;
  997. fn && fn.call(null, localJson.data);
  998. }
  999. }
  1000. });
  1001. },
  1002. /**
  1003. * 取{field}值
  1004. * @param caller 表名
  1005. */
  1006. _getFieldValue: function(caller, field, condition){
  1007. Ext.Ajax.request({
  1008. url : basePath + 'common/getFieldData.action',
  1009. async: false,
  1010. params: {
  1011. caller: caller,
  1012. field: field,
  1013. condition: condition
  1014. },
  1015. method : 'post',
  1016. callback : function(options,success,response){
  1017. var localJson = new Ext.decode(response.responseText);
  1018. if(localJson.exceptionInfo){
  1019. showError(localJson.exceptionInfo);return null;
  1020. }
  1021. if(localJson.success){
  1022. if(localJson.data != null){
  1023. return localJson.data;
  1024. } else {
  1025. return null;
  1026. }
  1027. } else {
  1028. return null;
  1029. }
  1030. }
  1031. });
  1032. },
  1033. /**
  1034. * 取{field}值
  1035. * @param caller 表名
  1036. */
  1037. _getFieldValues: function(caller, field, condition, tfield, record){
  1038. Ext.Ajax.request({
  1039. url : basePath + 'common/getFieldDatas.action',
  1040. async: false,
  1041. params: {
  1042. caller: caller,
  1043. field: field,
  1044. condition: condition
  1045. },
  1046. method : 'post',
  1047. callback : function(options,success,response){
  1048. var localJson = new Ext.decode(response.responseText);
  1049. if(localJson.exceptionInfo){
  1050. showError(localJson.exceptionInfo);return null;
  1051. }
  1052. if(localJson.success){
  1053. if(localJson.data != null){
  1054. if(record){
  1055. record.set(tfield, localJson.data);
  1056. } else {
  1057. Ext.getCmp(tfield).setValue(localJson.data);
  1058. }
  1059. }
  1060. } else {
  1061. return;
  1062. }
  1063. }
  1064. });
  1065. },
  1066. /**
  1067. * 取{fields}值,field用','隔开
  1068. * @param caller 表名
  1069. */
  1070. _getFieldsValue: function(caller, fields, condition){
  1071. Ext.Ajax.request({
  1072. url : basePath + 'common/getFieldsData.action',
  1073. async: false,
  1074. params: {
  1075. caller: caller,
  1076. fields: fields,
  1077. condition: condition
  1078. },
  1079. method : 'post',
  1080. callback : function(options,success,response){
  1081. var localJson = new Ext.decode(response.responseText);
  1082. if(localJson.exceptionInfo){
  1083. showError(localJson.exceptionInfo);return;
  1084. }
  1085. if(localJson.success){
  1086. return localJson.data;
  1087. }
  1088. }
  1089. });
  1090. },
  1091. checkFieldValue: function(caller, condition){
  1092. Ext.Ajax.request({
  1093. url : basePath + 'common/checkFieldData.action',
  1094. params: {
  1095. caller: caller,
  1096. condition: condition
  1097. },
  1098. method : 'post',
  1099. callback : function(options,success,response){
  1100. var localJson = new Ext.decode(response.responseText);
  1101. if(localJson.exceptionInfo){
  1102. showError(localJson.exceptionInfo);
  1103. return false;
  1104. }
  1105. if(localJson.success){
  1106. return localJson.data;
  1107. }
  1108. }
  1109. });
  1110. },
  1111. onAudit: function(id){
  1112. var me = this;
  1113. var form = Ext.getCmp('form');
  1114. if(form && form.getForm().isValid()){
  1115. if(!me.contains(form.auditUrl, '?caller=', true)){
  1116. form.auditUrl = form.auditUrl + "?caller=" + caller;
  1117. }
  1118. me.setLoading(true);//loading...
  1119. //清除流程
  1120. Ext.Ajax.request({
  1121. url : basePath + me.deleteProcess,
  1122. params: {
  1123. keyValue:id,
  1124. caller:caller,
  1125. _noc:1
  1126. },
  1127. method:'post',
  1128. async:false,
  1129. callback : function(options,success,response){
  1130. }
  1131. });
  1132. Ext.Ajax.request({
  1133. url : basePath + form.auditUrl,
  1134. params: {
  1135. id: id
  1136. },
  1137. method : 'post',
  1138. callback : function(options,success,response){
  1139. me.setLoading(false);
  1140. var localJson = new Ext.decode(response.responseText);
  1141. if(localJson.success){
  1142. //audit成功后刷新页面进入可编辑的页面
  1143. showMessage('提示', '审核成功!', 1000);
  1144. window.location.reload();
  1145. } else {
  1146. if(localJson.exceptionInfo){
  1147. var str = localJson.exceptionInfo;
  1148. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1149. str = str.replace('AFTERSUCCESS', '');
  1150. showMessage("提示", str);
  1151. auditSuccess(function(){
  1152. window.location.reload();
  1153. });
  1154. } else {
  1155. showError(str);return;
  1156. }
  1157. }
  1158. }
  1159. }
  1160. });
  1161. } else {
  1162. me.checkForm();
  1163. }
  1164. },
  1165. onB2b: function(id){
  1166. var me = this;
  1167. var form = Ext.getCmp('form');
  1168. if(!me.contains(form.b2bUrl, '?caller=', true)){
  1169. form.b2bUrl = form.b2bUrl + "?caller=" + caller;
  1170. }
  1171. me.setLoading(true);//loading...
  1172. Ext.Ajax.request({
  1173. url : basePath + form.b2bUrl,
  1174. params: {
  1175. id: id
  1176. },
  1177. method : 'post',
  1178. callback : function(options,success,response){
  1179. me.setLoading(false);
  1180. var localJson = new Ext.decode(response.responseText);
  1181. if(localJson.success){
  1182. //audit成功后刷新页面进入可编辑的页面
  1183. showMessage('提示', '同步成功!', 1000);
  1184. window.location.reload();
  1185. } else {
  1186. if(localJson.exceptionInfo){
  1187. var str = localJson.exceptionInfo;
  1188. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1189. str = str.replace('AFTERSUCCESS', '');
  1190. showMessage("提示", str);
  1191. auditSuccess(function(){
  1192. window.location.reload();
  1193. });
  1194. } else {
  1195. showError(str);return;
  1196. }
  1197. }
  1198. }
  1199. }
  1200. });
  1201. },
  1202. onAuditWithManAndTime: function(id,auditerFieldName,auditdateFieldName){
  1203. var me = this;
  1204. var form = Ext.getCmp('form');
  1205. if(!me.contains(form.auditUrl, '?caller=', true)){
  1206. form.auditUrl = form.auditUrl + "?caller=" + caller;
  1207. }
  1208. me.setLoading(true);//loading...
  1209. //清除流程
  1210. Ext.Ajax.request({
  1211. url : basePath + me.deleteProcess,
  1212. params: {
  1213. keyValue:id,
  1214. caller:caller,
  1215. _noc:1
  1216. },
  1217. method:'post',
  1218. async:false,
  1219. callback : function(options,success,response){
  1220. }
  1221. });
  1222. Ext.Ajax.request({
  1223. url : basePath + form.auditUrl,
  1224. params: {
  1225. id: id,
  1226. auditerFieldName:auditerFieldName,
  1227. auditdateFieldName:auditdateFieldName
  1228. },
  1229. method : 'post',
  1230. callback : function(options,success,response){
  1231. me.setLoading(false);
  1232. var localJson = new Ext.decode(response.responseText);
  1233. if(localJson.success){
  1234. //audit成功后刷新页面进入可编辑的页面
  1235. showMessage('提示', '审核成功!', 1000);
  1236. window.location.reload();
  1237. } else {
  1238. if(localJson.exceptionInfo){
  1239. var str = localJson.exceptionInfo;
  1240. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1241. str = str.replace('AFTERSUCCESS', '');
  1242. showMessage("提示", str);
  1243. auditSuccess(function(){
  1244. window.location.reload();
  1245. });
  1246. } else {
  1247. showError(str);return;
  1248. }
  1249. }
  1250. }
  1251. }
  1252. });
  1253. },
  1254. onResAuditWithManAndTime: function(id,auditerFieldName,auditdateFieldName){
  1255. var me = this;
  1256. var form = Ext.getCmp('form');
  1257. if(!me.contains(form.resAuditUrl, '?caller=', true)){
  1258. form.resAuditUrl = form.resAuditUrl + "?caller=" + caller;
  1259. }
  1260. me.setLoading(true);//loading...
  1261. Ext.Ajax.request({
  1262. url : basePath + form.resAuditUrl,
  1263. params: {
  1264. id: id,
  1265. auditerFieldName:auditerFieldName,
  1266. auditdateFieldName:auditdateFieldName
  1267. },
  1268. method : 'post',
  1269. callback : function(options,success,response){
  1270. me.setLoading(false);
  1271. var localJson = new Ext.decode(response.responseText);
  1272. if(localJson.exceptionInfo){
  1273. showError(localJson.exceptionInfo);
  1274. }
  1275. if(localJson.success){
  1276. //resAudit成功后刷新页面进入可编辑的页面
  1277. showMessage('提示', '反审核成功!', 1000);
  1278. window.location.reload();
  1279. }
  1280. }
  1281. });
  1282. },
  1283. onResAudit: function(id){
  1284. var me = this;
  1285. var form = Ext.getCmp('form');
  1286. if(!me.contains(form.resAuditUrl, '?caller=', true)){
  1287. form.resAuditUrl = form.resAuditUrl + "?caller=" + caller;
  1288. }
  1289. me.setLoading(true);//loading...
  1290. Ext.Ajax.request({
  1291. url : basePath + form.resAuditUrl,
  1292. params: {
  1293. id: id
  1294. },
  1295. method : 'post',
  1296. callback : function(options,success,response){
  1297. me.setLoading(false);
  1298. var localJson = new Ext.decode(response.responseText);
  1299. if(localJson.exceptionInfo){
  1300. showError(localJson.exceptionInfo);
  1301. }
  1302. if(localJson.success){
  1303. //resAudit成功后刷新页面进入可编辑的页面
  1304. showMessage('提示', '反审核成功!', 1000);
  1305. window.location.reload();
  1306. }
  1307. }
  1308. });
  1309. },
  1310. onAccounted: function(id){
  1311. var me = this;
  1312. var form = Ext.getCmp('form');
  1313. if(!me.contains(form.accountedUrl, '?caller=', true)){
  1314. form.accountedUrl = form.accountedUrl + "?caller=" + caller;
  1315. }
  1316. me.setLoading(true);//loading...
  1317. Ext.Ajax.request({
  1318. url : basePath + form.accountedUrl,
  1319. params: {
  1320. id: id
  1321. },
  1322. method : 'post',
  1323. callback : function(options,success,response){
  1324. me.setLoading(false);
  1325. var localJson = new Ext.decode(response.responseText);
  1326. if(localJson.success){
  1327. //记账成功后刷新页面进入不可编辑的页面
  1328. accountedSuccess(function(){
  1329. window.location.reload();
  1330. });
  1331. } else {
  1332. if(localJson.exceptionInfo){
  1333. var str = localJson.exceptionInfo;
  1334. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1335. str = str.replace('AFTERSUCCESS', '');
  1336. showMessage("提示", str);
  1337. accountedSuccess(function(){
  1338. window.location.reload();
  1339. });
  1340. } else {
  1341. showError(str);return;
  1342. }
  1343. }
  1344. }
  1345. }
  1346. });
  1347. },
  1348. onResAccounted: function(id){
  1349. var me = this;
  1350. var form = Ext.getCmp('form');
  1351. if(!me.contains(form.resAccountedUrl, '?caller=', true)){
  1352. form.resAccountedUrl = form.resAccountedUrl + "?caller=" + caller;
  1353. }
  1354. me.setLoading(true);//loading...
  1355. Ext.Ajax.request({
  1356. url : basePath + form.resAccountedUrl,
  1357. params: {
  1358. id: id
  1359. },
  1360. method : 'post',
  1361. callback : function(options,success,response){
  1362. me.setLoading(false);
  1363. var localJson = new Ext.decode(response.responseText);
  1364. if(localJson.exceptionInfo){
  1365. showError(localJson.exceptionInfo);
  1366. }
  1367. if(localJson.success){
  1368. //resAudit成功后刷新页面进入可编辑的页面
  1369. resAccountedSuccess();
  1370. window.location.reload();
  1371. }
  1372. }
  1373. });
  1374. },
  1375. /**
  1376. * @param allowEmpty 是否允许Grid为空
  1377. */
  1378. onSubmit: function(id, allowEmpty, errFn, scope, errFnArgs){
  1379. var me = this;
  1380. var form = Ext.getCmp('form');
  1381. if(form && form.getForm().isValid()){
  1382. var s = me.checkFormDirty(form);
  1383. var grids = Ext.ComponentQuery.query('gridpanel');
  1384. if(grids.length > 0 && !grids[0].ignore){//check所有grid是否已修改
  1385. var param = grids[0].GridUtil.getAllGridStore(grids[0]);
  1386. if(grids[0].necessaryField && grids[0].necessaryField.length > 0 && (param == null || param == '') && (allowEmpty !== true)){
  1387. var errInfo = grids[0].GridUtil.getUnFinish(grids[0]);
  1388. if(errInfo.length > 0)
  1389. showError("明细表有必填字段未完成填写<hr>" + errInfo);
  1390. else
  1391. showError("明细表还未添加数据,无法提交!");
  1392. return;
  1393. }
  1394. Ext.each(grids, function(grid, index){
  1395. if(grid.GridUtil){
  1396. var msg = grid.GridUtil.checkGridDirty(grid);
  1397. if(msg.length > 0){
  1398. s = s + '<br/>' + grid.GridUtil.checkGridDirty(grid);
  1399. }
  1400. }
  1401. });
  1402. }
  1403. if(s == '' || s == '<br/>'){
  1404. me.submit(id);
  1405. } else {
  1406. Ext.MessageBox.show({
  1407. title:'保存修改?',
  1408. msg: '该单据已被修改:<br/>' + s + '<br/>提交前要先保存吗?',
  1409. buttons: Ext.Msg.YESNOCANCEL,
  1410. icon: Ext.Msg.WARNING,
  1411. fn: function(btn){
  1412. if(btn == 'yes'){
  1413. if(typeof errFn === 'function')
  1414. errFn.call(scope, errFnArgs);
  1415. else
  1416. me.onUpdate(form, true);
  1417. } else if(btn == 'no'){
  1418. me.submit(id);
  1419. } else {
  1420. return;
  1421. }
  1422. }
  1423. });
  1424. }
  1425. } else {
  1426. me.checkForm();
  1427. }
  1428. },
  1429. submit: function(id){
  1430. var me = this;
  1431. var form = Ext.getCmp('form');
  1432. if(!me.contains(form.submitUrl, '?caller=', true)){
  1433. form.submitUrl = form.submitUrl + "?caller=" + caller;
  1434. }
  1435. me.setLoading(true);//loading...
  1436. Ext.Ajax.request({
  1437. url : basePath + form.submitUrl,
  1438. params: {
  1439. id: id
  1440. },
  1441. method : 'post',
  1442. callback : function(options,success,response){
  1443. me.setLoading(false);
  1444. var localJson = new Ext.decode(response.responseText);
  1445. if(localJson.success){
  1446. me.getMultiAssigns(id, caller,form);
  1447. } else {
  1448. if(localJson.exceptionInfo){
  1449. var str = localJson.exceptionInfo;
  1450. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1451. str = str.replace('AFTERSUCCESS', '');
  1452. me.getMultiAssigns(id, caller, form,me.showAssignWin);
  1453. }
  1454. showMessage("提示", str);
  1455. }
  1456. }
  1457. }
  1458. });
  1459. },
  1460. onResSubmit: function(id){
  1461. var me = this;
  1462. var form = Ext.getCmp('form');
  1463. if(!me.contains(form.resSubmitUrl, '?caller=', true)){
  1464. form.resSubmitUrl = form.resSubmitUrl + "?caller=" + caller;
  1465. }
  1466. me.setLoading(true);//loading...
  1467. Ext.Ajax.request({
  1468. url : basePath + form.resSubmitUrl,
  1469. params: {
  1470. id: id
  1471. },
  1472. method : 'post',
  1473. callback : function(options,success,response){
  1474. me.setLoading(false);
  1475. var localJson = new Ext.decode(response.responseText);
  1476. if(localJson.exceptionInfo){
  1477. showError(localJson.exceptionInfo);
  1478. }
  1479. if(localJson.success){
  1480. //resSubmit成功后刷新页面进入可编辑的页面
  1481. showMessage('提示', '反提交成功!', 1000);
  1482. window.location.reload();
  1483. }
  1484. }
  1485. });
  1486. },
  1487. onBanned: function(id){
  1488. var me = this;
  1489. var form = Ext.getCmp('form');
  1490. if(!me.contains(form.bannedUrl, '?caller=', true)){
  1491. form.bannedUrl = form.bannedUrl + "?caller=" + caller;
  1492. }
  1493. me.setLoading(true);//loading...
  1494. Ext.Ajax.request({
  1495. url : basePath + form.bannedUrl,
  1496. params: {
  1497. id: id
  1498. },
  1499. method : 'post',
  1500. callback : function(options,success,response){
  1501. me.setLoading(false);
  1502. var localJson = new Ext.decode(response.responseText);
  1503. if(localJson.success){
  1504. //banned成功后刷新页面进入可编辑的页面
  1505. window.location.href = window.location.href;
  1506. bannedSuccess();
  1507. } else {
  1508. if(localJson.exceptionInfo){
  1509. var str = localJson.exceptionInfo;
  1510. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1511. str = str.replace('AFTERSUCCESS', '');
  1512. showError(str);
  1513. bannedSuccess();
  1514. window.location.reload();
  1515. } else {
  1516. showError(str);return;
  1517. }
  1518. }
  1519. }
  1520. }
  1521. });
  1522. },
  1523. onResBanned: function(id){
  1524. var me = this;
  1525. var form = Ext.getCmp('form');
  1526. if(!me.contains(form.resBannedUrl, '?caller=', true)){
  1527. form.resBannedUrl = form.resBannedUrl + "?caller=" + caller;
  1528. }
  1529. me.setLoading(true);//loading...
  1530. Ext.Ajax.request({
  1531. url : basePath + form.resBannedUrl,
  1532. params: {
  1533. id: id
  1534. },
  1535. method : 'post',
  1536. callback : function(options,success,response){
  1537. me.setLoading(false);
  1538. var localJson = new Ext.decode(response.responseText);
  1539. if(localJson.exceptionInfo){
  1540. showError(localJson.exceptionInfo);
  1541. }
  1542. if(localJson.success){
  1543. //resBanned成功后刷新页面进入可编辑的页面
  1544. resBannedSuccess();
  1545. window.location.reload();
  1546. }
  1547. }
  1548. });
  1549. },
  1550. onPrint: function(id){
  1551. var me = this;
  1552. var form = Ext.getCmp('form');
  1553. if(form.printUrl && !me.contains(form.printUrl, '?caller=', true)){
  1554. form.printUrl = form.printUrl + "?caller=" + caller;
  1555. }
  1556. me.setLoading(true);//loading...
  1557. Ext.Ajax.request({
  1558. url : basePath + form.printUrl,
  1559. params: {
  1560. id: id
  1561. },
  1562. method : 'post',
  1563. callback : function(options,success,response){
  1564. me.setLoading(false);
  1565. var localJson = new Ext.decode(response.responseText);
  1566. if(localJson.success){
  1567. window.location.href = window.location.href;
  1568. printSuccess();
  1569. } else {
  1570. if(localJson.exceptionInfo){
  1571. var str = localJson.exceptionInfo;
  1572. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1573. str = str.replace('AFTERSUCCESS', '');
  1574. showError(str);
  1575. printSuccess();
  1576. window.location.reload();
  1577. } else {
  1578. showError(str);return;
  1579. }
  1580. }
  1581. }
  1582. }
  1583. });
  1584. },
  1585. onEnd: function(id){
  1586. var me = this;
  1587. var form = Ext.getCmp('form');
  1588. if(form.endUrl && !me.contains(form.endUrl, '?caller=', true)){
  1589. form.endUrl = form.endUrl + "?caller=" + caller;
  1590. }
  1591. me.setLoading(true);//loading...
  1592. Ext.Ajax.request({
  1593. url : basePath + form.endUrl,
  1594. params: {
  1595. id: id
  1596. },
  1597. method : 'post',
  1598. callback : function(options,success,response){
  1599. me.setLoading(false);
  1600. var localJson = new Ext.decode(response.responseText);
  1601. if(localJson.success){
  1602. endSuccess(function(){
  1603. window.location.reload();
  1604. });
  1605. } else {
  1606. if(localJson.exceptionInfo){
  1607. var str = localJson.exceptionInfo;
  1608. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1609. str = str.replace('AFTERSUCCESS', '');
  1610. showError(str);
  1611. endSuccess(function(){
  1612. window.location.reload();
  1613. });
  1614. } else {
  1615. showError(str);return;
  1616. }
  1617. }
  1618. }
  1619. }
  1620. });
  1621. },
  1622. onResEnd: function(id, f){
  1623. var me = this;
  1624. var form = f || Ext.getCmp('form');
  1625. if(form.endUrl && !me.contains(form.endUrl, '?caller=', true)){
  1626. form.endUrl = form.endUrl + "?caller=" + caller;
  1627. }
  1628. me.setLoading(true);//loading...
  1629. Ext.Ajax.request({
  1630. url : basePath + form.resEndUrl,
  1631. params: {
  1632. id: id
  1633. },
  1634. method : 'post',
  1635. callback : function(options,success,response){
  1636. me.setLoading(false);
  1637. var localJson = new Ext.decode(response.responseText);
  1638. if(localJson.success){
  1639. resEndSuccess(function(){
  1640. window.location.reload();
  1641. });
  1642. } else {
  1643. if(localJson.exceptionInfo){
  1644. var str = localJson.exceptionInfo;
  1645. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
  1646. str = str.replace('AFTERSUCCESS', '');
  1647. showError(str);
  1648. resEndSuccess(function(){
  1649. window.location.reload();
  1650. });
  1651. } else {
  1652. showError(str);return;
  1653. }
  1654. }
  1655. }
  1656. }
  1657. });
  1658. },
  1659. onNullify: function(id){
  1660. var me = this;
  1661. var form = Ext.getCmp('form');
  1662. if(form.nullifyUrl && !me.contains(form.nullifyUrl, '?caller=', true)){
  1663. form.nullifyUrl = form.nullifyUrl + "?caller=" + caller;
  1664. }
  1665. me.setLoading(true);//loading...
  1666. Ext.Ajax.request({
  1667. url : basePath + form.nullifyUrl,
  1668. params: {
  1669. id: id
  1670. },
  1671. method : 'post',
  1672. callback : function(options,success,response){
  1673. me.setLoading(false);
  1674. var localJson = new Ext.decode(response.responseText);
  1675. if(localJson.success){
  1676. nullifySuccess(function(){
  1677. window.location.reload();
  1678. });
  1679. } else {
  1680. if(localJson.exceptionInfo){
  1681. var str = localJson.exceptionInfo;
  1682. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1683. str = str.replace('AFTERSUCCESS', '');
  1684. showError(str);
  1685. nullifySuccess(function(){
  1686. window.location.reload();
  1687. });
  1688. } else {
  1689. showError(str);return;
  1690. }
  1691. }
  1692. }
  1693. }
  1694. });
  1695. },
  1696. batchPrint:function(idS,reportName,condition,title,todate,dateFW,fromdate,enddate,urladdress,whichsystem){
  1697. var printUrl = 'common/BatchPrintController/batchPrint.action';
  1698. var me = this;
  1699. var form = Ext.getCmp('form');
  1700. if(printUrl && !me.contains(printUrl, '?caller=', true)){
  1701. printUrl = printUrl + "?caller=" + caller;
  1702. }
  1703. me.setLoading(true);//loading...
  1704. Ext.Ajax.request({
  1705. url : basePath + printUrl,
  1706. params: {
  1707. idS: idS,
  1708. reportName:reportName,
  1709. condition:condition,
  1710. title:title,
  1711. todate:todate,
  1712. dateFW:dateFW,
  1713. fromdate:fromdate,
  1714. enddate:enddate
  1715. },
  1716. method : 'post',
  1717. timeout: 360000,
  1718. callback : function(options,success,response){
  1719. me.setLoading(false);//loading...
  1720. var res = new Ext.decode(response.responseText);
  1721. var url = urladdress + '?reportfile=' +
  1722. res.keyData[0]+'&&fdate='+fromdate+'&&tdate='+todate+'&&assifall=have'+'&&asscatecode='+'&&rcondition='+condition+'&&company=&&sysdate='+res.keyData[3]+'&&key='+res.keyData[1]+'&&whichsystem='+whichsystem+'';
  1723. window.open(url,'_blank');
  1724. /*window.open(url, (form == null ? '' : form.title) + '-批量打印', 'width=' + (window.screen.width-10) +
  1725. ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');*/
  1726. }
  1727. });
  1728. },
  1729. onwindowsPrint2: function(id, reportName, condition, callback){
  1730. var me = this;
  1731. var form = Ext.getCmp('form');
  1732. if(form.printUrl && !me.contains(form.printUrl, '?caller=', true)){
  1733. form.printUrl = form.printUrl + "?caller=" + caller;
  1734. }
  1735. me.setLoading(true);//loading...
  1736. Ext.Ajax.request({
  1737. url : basePath + form.printUrl,
  1738. params: {
  1739. id: id,
  1740. reportName:reportName,
  1741. condition:condition
  1742. },
  1743. method : 'post',
  1744. timeout: 360000,
  1745. callback : function(options,success,response){
  1746. var res = new Ext.decode(response.responseText);
  1747. if(res.exceptionInfo) {
  1748. me.setLoading(false);
  1749. showError(res.exceptionInfo);
  1750. return;
  1751. }
  1752. Ext.Ajax.request({
  1753. url: basePath + 'common/report/print.action',
  1754. method: 'post',
  1755. params: {
  1756. id: id,
  1757. caller:caller,
  1758. reportName:reportName,
  1759. condition:condition
  1760. },
  1761. callback : function(options, success, response){
  1762. var res = new Ext.decode(response.responseText);
  1763. me.setLoading(false);
  1764. if(res.success){
  1765. if(res.info.isbz=='pdf'){
  1766. window.location.href=res.info.printUrl+'/print?reportname='+res.info.reportname+'&condition='+res.info.condition+'&whichsystem='+res.info.whichsystem+"&"+'defaultCondition='+res.info.defaultCondition;
  1767. }else{
  1768. //var whichsystem = re.whichsystem;
  1769. var url = res.info.printUrl + '?reportfile=' + res.info.reportname + '&&rcondition='+res.info.condition+'&&company=&&sysdate=373FAE331D06E956870163DCB2A96EC7&&key=3D7595A98BFF809D5EEEA9668B47F4A5&&whichsystem='+res.info.whichsystem+'';
  1770. /*window.open(url, form.title + '-打印', 'width=' + (window.screen.width-10) +
  1771. ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');*/
  1772. window.open(url,'_blank');
  1773. }
  1774. } else if(res.exceptionInfo){
  1775. var str = res.exceptionInfo;
  1776. showError(str);return;
  1777. }
  1778. }
  1779. });
  1780. }
  1781. });
  1782. /* Ext.Ajax.request({
  1783. url : basePath + form.printUrl,
  1784. params: {
  1785. id: id,
  1786. reportName:reportName,
  1787. condition:condition
  1788. },
  1789. method : 'post',
  1790. callback : function(options,success,response){
  1791. var res = new Ext.decode(response.responseText);
  1792. if(res.exceptionInfo) {
  1793. me.setLoading(false);
  1794. showError(res.exceptionInfo);
  1795. return;
  1796. }
  1797. Ext.Ajax.request({
  1798. url : basePath + 'common/enterprise/getprinturl.action',
  1799. params: {
  1800. caller: caller,
  1801. reportName: reportName
  1802. },
  1803. callback: function(opt, s, r) {
  1804. me.setLoading(false);
  1805. var re = Ext.decode(r.responseText);
  1806. if(re.exceptionInfo) {
  1807. showError(re.exceptionInfo);
  1808. return;
  1809. }
  1810. if(re.printurl) {
  1811. var whichsystem = re.whichsystem;
  1812. var url = re.printurl + '?reportfile=' +
  1813. ( res.keyData[0]||re.report) + '&&rcondition='+condition+'&&company=&&sysdate='+res.keyData[3]+'&&key='+res.keyData[1]+'&&whichsystem='+whichsystem+'';
  1814. window.open(url, form.title + '-打印', 'width=' + (window.screen.width-10) +
  1815. ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
  1816. //(re.report || res.keyData[0])
  1817. var whichsystem=re.whichsystem;
  1818. var url = re.printurl + '/common/reportviewer.aspx?reportfile=' +
  1819. res.keyData[0]+'&&rcondition='+condition+'&&company=&&sysdate='+res.keyData[3]+'&&key='+res.keyData[1]+'&&whichsystem='+whichsystem+'';
  1820. window.open(url, form.title + '-打印', 'width=' + (window.screen.width-10) +
  1821. ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
  1822. }
  1823. callback && callback.call(null);
  1824. }
  1825. });
  1826. }
  1827. });*/
  1828. },
  1829. onwindowsPrint: function(id, reportName, condition, callback){
  1830. var me = this;
  1831. var form = Ext.getCmp('form');
  1832. if(form.printUrl && !me.contains(form.printUrl, '?caller=', true)){
  1833. form.printUrl = form.printUrl + "?caller=" + caller;
  1834. }
  1835. me.setLoading(true);//loading...
  1836. Ext.Ajax.request({
  1837. url : basePath + form.printUrl,
  1838. params: {
  1839. id: id,
  1840. reportName:reportName,
  1841. condition:condition
  1842. },
  1843. method : 'post',
  1844. timeout: 360000,
  1845. callback : function(options,success,response){
  1846. var res = new Ext.decode(response.responseText);
  1847. if(res.exceptionInfo) {
  1848. me.setLoading(false);
  1849. showError(res.exceptionInfo);
  1850. return;
  1851. }
  1852. Ext.Ajax.request({
  1853. url: basePath + 'common/report/print.action',
  1854. method: 'post',
  1855. params: {
  1856. id: id,
  1857. caller:caller,
  1858. reportName:reportName,
  1859. condition:condition
  1860. },
  1861. callback : function(options, success, response){
  1862. var res = new Ext.decode(response.responseText);
  1863. me.setLoading(false);
  1864. if(res.success){
  1865. //var whichsystem = re.whichsystem;
  1866. var url = res.info.printUrl + '?reportfile=' + res.info.reportname + '&&rcondition='+res.info.condition+'&&fdate=&&tdate=&&company=&&sysdate=373FAE331D06E956870163DCB2A96EC7&&key=3D7595A98BFF809D5EEEA9668B47F4A5&&whichsystem='+res.info.whichsystem+'';
  1867. /*window.open(url, form.title + '-打印', 'width=' + (window.screen.width-10) +
  1868. ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');*/
  1869. window.open(url,'_blank');
  1870. }else if(res.exceptionInfo){
  1871. var str = res.exceptionInfo;
  1872. showError(str);return;
  1873. }
  1874. }
  1875. });
  1876. }
  1877. });
  1878. },
  1879. //====================BOM打印方法
  1880. onwindowsPrintBom: function(id, reportName, condition,prodcode){
  1881. var me = this;
  1882. var form = Ext.getCmp('form');
  1883. if(form.printUrl && !me.contains(form.printUrl, '?caller=', true)){
  1884. form.printUrl = form.printUrl + "?caller=" + caller;
  1885. }
  1886. me.setLoading(true);//loading...
  1887. Ext.Ajax.request({
  1888. url : basePath + form.printUrl,
  1889. params: {
  1890. id: id,
  1891. reportName:reportName,
  1892. condition:condition,
  1893. prodcode:prodcode
  1894. },
  1895. method : 'post',
  1896. callback : function(options,success,response){
  1897. var res = new Ext.decode(response.responseText);
  1898. if(res.exceptionInfo) {
  1899. me.setLoading(false);
  1900. showError(res.exceptionInfo);
  1901. return;
  1902. }
  1903. Ext.Ajax.request({
  1904. url : basePath + 'common/enterprise/getprinturl.action',
  1905. params: {
  1906. caller: caller,
  1907. reportName: reportName
  1908. },
  1909. callback: function(opt, s, r) {
  1910. me.setLoading(false);
  1911. var re = Ext.decode(r.responseText);
  1912. if(re.exceptionInfo) {
  1913. showError(re.exceptionInfo);
  1914. return;
  1915. }
  1916. if(re.printurl) {
  1917. var whichsystem=re.whichsystem;
  1918. //var whichsystem = re.whichsystem;
  1919. /*var url = re.printurl + '/common/reportviewer.aspx?reportfile=' +
  1920. (re.report || res.keyData[0]) +'&&rcondition='+condition+'&&company=&&sysdate='+res.keyData[3]+'&&key='+res.keyData[1]+'&&whichsystem='+whichsystem+'';
  1921. window.open(url, form.title + '-打印', 'width=' + (window.screen.width-10) +
  1922. ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');*/
  1923. var url = re.printurl + '?reportfile=' +
  1924. (re.report || res.keyData[0]) +'&&rcondition='+condition+'&&company=&&sysdate='+res.keyData[3]+'&&key='+res.keyData[1]+'&&whichsystem='+whichsystem+'';
  1925. /*window.open(url, form.title + '-打印', 'width=' + (window.screen.width-10) +
  1926. ',height=' + (window.screen.height*0.87) + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');*/
  1927. window.open(url,'_blank');
  1928. }
  1929. // window.location.reload();
  1930. }
  1931. });
  1932. }
  1933. });
  1934. },
  1935. //========================
  1936. onPost: function(id){
  1937. var me = this;
  1938. var form = Ext.getCmp('form');
  1939. if(form && form.getForm().isValid()){
  1940. var unSave = me.getUnSave(form);
  1941. if(unSave.length > 0) {
  1942. showError('<h3>' + unSave + '</h3> 填写后未保存,请先执行更新操作');
  1943. return;
  1944. }
  1945. var grids = Ext.ComponentQuery.query('gridpanel');
  1946. if(grids.length > 0){
  1947. var invalid = [];
  1948. Ext.each(grids, function(grid, index){
  1949. if(!grid.ignore && grid.GridUtil){
  1950. var msg = grid.GridUtil.getInvalid(grid);
  1951. if(msg.length > 0){
  1952. invalid.push((grids.length > 1 ? ('从表' + (index + 1) + ' ') : '') + msg);
  1953. }
  1954. }
  1955. });
  1956. if(invalid.length > 0) {
  1957. showError('<h3>还有待完善的必填信息:</h3><hr>' + invalid.join('<br>'));
  1958. return;
  1959. }
  1960. }
  1961. if(form.postUrl && !me.contains(form.postUrl, '?caller=', true)){
  1962. form.postUrl = form.postUrl + "?caller=" + caller;
  1963. }
  1964. warnMsg('确定过账?', function(btn){
  1965. if(btn == 'yes'){
  1966. me.setLoading(true);//loading...
  1967. Ext.Ajax.request({
  1968. url : basePath + form.postUrl,
  1969. params: {
  1970. id: id
  1971. },
  1972. method : 'post',
  1973. callback : function(options,success,response){
  1974. me.setLoading(false);
  1975. var localJson = new Ext.decode(response.responseText);
  1976. if(localJson.success){
  1977. postSuccess(function(){
  1978. window.location.reload();
  1979. });
  1980. } else {
  1981. if(localJson.exceptionInfo){
  1982. var str = localJson.exceptionInfo;
  1983. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  1984. str = str.replace('AFTERSUCCESS', '');
  1985. showError(str);
  1986. postSuccess(function(){
  1987. window.location.reload();
  1988. });
  1989. } else {
  1990. showError(str);return;
  1991. }
  1992. }
  1993. }
  1994. }
  1995. });
  1996. }
  1997. });
  1998. } else {
  1999. me.checkForm();
  2000. }
  2001. },
  2002. /**
  2003. * 获取form修改但未保存的字段,并提示
  2004. */
  2005. getUnSave: function(form) {
  2006. var unSave = [];
  2007. Ext.Array.each(form.items.items, function(item){
  2008. var text = item.fieldLabel || item.boxLabel;
  2009. if(item.firstField)
  2010. item = item.firstField;
  2011. if(typeof item.getValue == 'function' && !item.allowBlank &&
  2012. Ext.isEmpty(item.originalValue) && !Ext.isEmpty(item.value)) {
  2013. text && (unSave.push(text));
  2014. }
  2015. });
  2016. return unSave.join(' ');
  2017. },
  2018. onResPost: function(id){
  2019. var me = this;
  2020. var form = Ext.getCmp('form');
  2021. if(form.resPostUrl && !me.contains(form.resPostUrl, '?caller=', true)){
  2022. form.resPostUrl = form.resPostUrl + "?caller=" + caller;
  2023. }
  2024. me.setLoading(true);//loading...
  2025. Ext.Ajax.request({
  2026. url : basePath + form.resPostUrl,
  2027. params: {
  2028. id: id
  2029. },
  2030. method : 'post',
  2031. callback : function(options,success,response){
  2032. me.setLoading(false);
  2033. var localJson = new Ext.decode(response.responseText);
  2034. if(localJson.success){
  2035. resPostSuccess(function(){
  2036. window.location.reload();
  2037. });
  2038. } else {
  2039. if(localJson.exceptionInfo){
  2040. var str = localJson.exceptionInfo;
  2041. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  2042. str = str.replace('AFTERSUCCESS', '');
  2043. showError(str);
  2044. resPostSuccess(function(){
  2045. window.location.reload();
  2046. });
  2047. } else {
  2048. showError(str);return;
  2049. }
  2050. }
  2051. }
  2052. }
  2053. });
  2054. },
  2055. onHung: function(id){
  2056. var me = this;
  2057. var form = Ext.getCmp('form');
  2058. if(!me.contains(form.resAuditUrl, '?caller=', true)){
  2059. form.resAuditUrl = form.resAuditUrl + "?caller=" + caller;
  2060. }
  2061. me.setLoading(true);//loading...
  2062. Ext.Ajax.request({
  2063. url : basePath + form.hungUrl,
  2064. params: {
  2065. id: id
  2066. },
  2067. method : 'post',
  2068. callback : function(options,success,response){
  2069. me.setLoading(false);
  2070. var localJson = new Ext.decode(response.responseText);
  2071. if(localJson.exceptionInfo){
  2072. showError(localJson.exceptionInfo);
  2073. }
  2074. if(localJson.success){
  2075. //resAudit成功后刷新页面进入可编辑的页面
  2076. resAuditSuccess();
  2077. window.location.reload();
  2078. }
  2079. }
  2080. });
  2081. },
  2082. onResHung: function(id){
  2083. var me = this;
  2084. var form = Ext.getCmp('form');
  2085. if(!me.contains(form.resAuditUrl, '?caller=', true)){
  2086. form.resAuditUrl = form.resAuditUrl + "?caller=" + caller;
  2087. }
  2088. me.setLoading(true);//loading...
  2089. Ext.Ajax.request({
  2090. url : basePath + form.resHungUrl,
  2091. params: {
  2092. id: id
  2093. },
  2094. method : 'post',
  2095. callback : function(options,success,response){
  2096. me.setLoading(false);
  2097. var localJson = new Ext.decode(response.responseText);
  2098. if(localJson.exceptionInfo){
  2099. showError(localJson.exceptionInfo);
  2100. }
  2101. if(localJson.success){
  2102. //resAudit成功后刷新页面进入可编辑的页面
  2103. resAuditSuccess();
  2104. window.location.reload();
  2105. }
  2106. }
  2107. });
  2108. },
  2109. onCheck: function(id){
  2110. var me = this;
  2111. var form = Ext.getCmp('form');
  2112. if(form.checkUrl && !me.contains(form.checkUrl, '?caller=', true)){
  2113. form.checkUrl = form.checkUrl + "?caller=" + caller;
  2114. }
  2115. me.setLoading(true);//loading...
  2116. Ext.Ajax.request({
  2117. url : basePath + form.checkUrl,
  2118. params: {
  2119. id: id
  2120. },
  2121. method : 'post',
  2122. callback : function(options,success,response){
  2123. me.setLoading(false);
  2124. var localJson = new Ext.decode(response.responseText);
  2125. if(localJson.success){
  2126. checkSuccess(function(){
  2127. window.location.reload();
  2128. });
  2129. } else {
  2130. if(localJson.exceptionInfo){
  2131. var str = localJson.exceptionInfo;
  2132. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  2133. str = str.replace('AFTERSUCCESS', '');
  2134. showError(str);
  2135. checkSuccess(function(){
  2136. vwindow.location.reload();
  2137. });
  2138. } else {
  2139. showError(str);return;
  2140. }
  2141. }
  2142. }
  2143. }
  2144. });
  2145. },
  2146. onConfirm: function(id){
  2147. var me=this;
  2148. var form=Ext.getCmp('form');
  2149. if(form.onConfirmUrl && !me.contains(form.onConfirmUrl, '?caller=', true)){
  2150. form.onConfirmUrl = form.onConfirmUrl + "?caller=" + caller;
  2151. }
  2152. me.setLoading(true);//loading...
  2153. Ext.Ajax.request({
  2154. url : basePath + form.onConfirmUrl,
  2155. params: {
  2156. id: id
  2157. },
  2158. method : 'post',
  2159. callback : function(options,success,response){
  2160. me.setLoading(false);
  2161. var localJson = new Ext.decode(response.responseText);
  2162. if(localJson.success){
  2163. Ext.Msg.alert('提示', '确认成功', function(){
  2164. window.location.reload();
  2165. });
  2166. } else {
  2167. if(localJson.exceptionInfo){
  2168. var str = localJson.exceptionInfo;
  2169. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  2170. str = str.replace('AFTERSUCCESS', '');
  2171. showError(str);
  2172. Ext.Msg.alert('提示', '确认成功', function(){
  2173. window.location.reload();
  2174. });
  2175. } else {
  2176. showError(str);return;
  2177. }
  2178. }
  2179. }
  2180. }
  2181. });
  2182. },
  2183. onResCheck: function(id){
  2184. var me = this;
  2185. var form = Ext.getCmp('form');
  2186. if(form.resCheckUrl && !me.contains(form.resCheckUrl, '?caller=', true)){
  2187. form.resCheckUrl = form.resCheckUrl + "?caller=" + caller;
  2188. }
  2189. me.setLoading(true);//loading...
  2190. Ext.Ajax.request({
  2191. url : basePath + form.resCheckUrl,
  2192. params: {
  2193. id: id
  2194. },
  2195. method : 'post',
  2196. callback : function(options,success,response){
  2197. me.setLoading(false);
  2198. var localJson = new Ext.decode(response.responseText);
  2199. if(localJson.success){
  2200. resCheckSuccess(function(){
  2201. window.location.reload();
  2202. });
  2203. } else {
  2204. if(localJson.exceptionInfo){
  2205. var str = localJson.exceptionInfo;
  2206. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  2207. str = str.replace('AFTERSUCCESS', '');
  2208. showError(str);
  2209. resCheckSuccess(function(){
  2210. window.location.reload();
  2211. });
  2212. } else {
  2213. showError(str);return;
  2214. }
  2215. }
  2216. }
  2217. }
  2218. });
  2219. },
  2220. openTab : function (panel,id){
  2221. var o = (typeof panel == "string" ? panel : id || panel.id);
  2222. var main = this.getMain();
  2223. var tab = main.getComponent(o);
  2224. if (tab) {
  2225. main.setActiveTab(tab);
  2226. } else if(typeof panel!="string"){
  2227. panel.id = o;
  2228. var p = main.add(panel);
  2229. main.setActiveTab(p);
  2230. }
  2231. },
  2232. getMain: function(){
  2233. var main = Ext.getCmp("content-panel");
  2234. if(!main)
  2235. main = parent.Ext.getCmp("content-panel");
  2236. if(!main)
  2237. main = parent.parent.Ext.getCmp("content-panel");
  2238. return main;
  2239. },
  2240. getActiveTab: function(){
  2241. var tab = null;
  2242. if(Ext.getCmp("content-panel")){
  2243. tab = Ext.getCmp("content-panel").getActiveTab();
  2244. }
  2245. if(!tab && parent.Ext && parent.Ext.getCmp("content-panel"))
  2246. tab = parent.Ext.getCmp("content-panel").getActiveTab();
  2247. if(!tab && parent.parent.Ext && parent.parent.Ext.getCmp("content-panel"))
  2248. tab = parent.parent.Ext.getCmp("content-panel").getActiveTab();
  2249. if(!tab && parent.Ext){
  2250. var win = parent.Ext.ComponentQuery.query('window');
  2251. if(win.length > 0){
  2252. tab = win[win.length-1];
  2253. }
  2254. }
  2255. return tab;
  2256. },
  2257. /**
  2258. * string:原始字符串
  2259. * substr:子字符串
  2260. * isIgnoreCase:忽略大小写
  2261. */
  2262. contains: function(string, substr, isIgnoreCase){
  2263. if (string == null || substr == null) return false;
  2264. if (isIgnoreCase === undefined || isIgnoreCase === true) {
  2265. string = string.toLowerCase();
  2266. substr = substr.toLowerCase();
  2267. }
  2268. return string.indexOf(substr) > -1;
  2269. },
  2270. getMultiAssigns:function(id,caller,form){
  2271. Ext.Ajax.request({
  2272. url : basePath + '/common/getMultiNodeAssigns.action',
  2273. params: {
  2274. id: id,
  2275. caller:caller
  2276. },
  2277. method : 'post',
  2278. callback : function(){
  2279. var localJson = new Ext.decode(arguments[2].responseText);
  2280. if(localJson.exceptionInfo){
  2281. var str = localJson.exceptionInfo;
  2282. showError(str);
  2283. }else {
  2284. if(localJson.MultiAssign){
  2285. if(localJson.autoSetJnode){
  2286. form.SetNodeDealMan(id);
  2287. }else this.showAssignWin(localJson.assigns);
  2288. }else {
  2289. showMessage('提示', '提交成功!', 1000);
  2290. window.location.reload();
  2291. if(form.onSumitSuccess){
  2292. form.onSumitSuccess();
  2293. }
  2294. }
  2295. }
  2296. },
  2297. scope:this
  2298. });
  2299. },
  2300. showAssignWin :function(persons){
  2301. var me=this;
  2302. var confirm = new Ext.button.Button({
  2303. text:$I18N.common.button.erpConfirmButton,
  2304. handler:function(btn){
  2305. var items = Ext.ComponentQuery.query('window >tabpanel>panel>radio');
  2306. var params = new Array();
  2307. Ext.each(items,function(item){
  2308. if(item.getValue()){
  2309. var param = new Object();
  2310. var label = item.boxLabel;//em_name(em_code) 2013-3-8 10:18:11
  2311. var em_code = label.substring(label.lastIndexOf('(')+1,label.length-1);
  2312. param.em_code = em_code;
  2313. param.nodeId=item.name;
  2314. params.push(JSON.stringify(param));
  2315. }
  2316. });
  2317. Ext.Ajax.request({
  2318. url: basePath + 'common/takeOverTask.action',
  2319. async: false,
  2320. params: {
  2321. params:unescape(params),
  2322. _noc: 1
  2323. },
  2324. callback: function(options,success,response){
  2325. var text = response.responseText;
  2326. jsonData = Ext.decode(text);
  2327. //再发送请求
  2328. if(jsonData.success){
  2329. Ext.Msg.alert('提示' ,"指派成功!");
  2330. Ext.Ajax.request({
  2331. url: basePath + 'common/processpaging.action',
  2332. params: {
  2333. params:unescape(params),
  2334. _noc: 1
  2335. }
  2336. });
  2337. win.close();
  2338. }else{
  2339. Ext.Msg.alert('提示' ,"指派失败!");
  2340. win.close();
  2341. }
  2342. window.location.reload();
  2343. }
  2344. });
  2345. }
  2346. });
  2347. var cancel = new Ext.button.Button({
  2348. text:$I18N.common.button.erpCancelButton,
  2349. handler:function(){
  2350. var params = new Array();
  2351. for (var i = 0; i < persons.length; i++){
  2352. var param = new Object();
  2353. param.em_code = persons[i].JP_CANDIDATES;
  2354. param.nodeId=persons[i].JP_NODEID;
  2355. params.push(JSON.stringify(param));
  2356. }
  2357. Ext.Ajax.request({
  2358. url: basePath + 'common/processpaging.action',
  2359. params: {
  2360. params:unescape(params),
  2361. _noc: 1
  2362. },
  2363. callback: function(options,success,response){
  2364. win.close();
  2365. window.location.reload();
  2366. }
  2367. });
  2368. }
  2369. });
  2370. var searchKey = new Object();
  2371. var win = Ext.create('Ext.window.Window', {
  2372. title:'<div align="center">节点处理人</div>',
  2373. height: 450,
  2374. width: 650,
  2375. layout:'border',
  2376. closable:false,
  2377. modal:true,
  2378. id:'win',
  2379. autoScroll:true,
  2380. buttonAlign:'center',
  2381. buttons: [confirm,cancel],
  2382. items: []
  2383. });
  2384. win.add([{
  2385. xtype:'textfield',
  2386. margin:'10 20 10 20',
  2387. fieldLabel:'快速搜索',
  2388. labelStyle:'font-weight:bold;',
  2389. id:'searchtextfield',
  2390. //columnWidth:0.8,
  2391. //flex:1,
  2392. enableKeyEvents:true,
  2393. region:'north',
  2394. listeners:{
  2395. keydown:function(field,e){
  2396. if(e.getKey()==Ext.EventObject.ENTER){
  2397. searchKey[Ext.getCmp('processTab').getActiveTab().id]=field.value;
  2398. var results=Ext.Array.filter(persons[Ext.getCmp('processTab').getActiveTab().id].JP_CANDIDATES,function(JP_CANDIDATE){
  2399. if(field.value==undefined || JP_CANDIDATE.indexOf(field.value)!=-1) return JP_CANDIDATE;
  2400. });
  2401. Ext.Array.each(Ext.getCmp('processTab').getActiveTab().personUsers,function(item){
  2402. Ext.getCmp('processTab').getActiveTab().remove(item);
  2403. });
  2404. me.addUserItems(Ext.getCmp('processTab').getActiveTab(),persons[Ext.getCmp('processTab').getActiveTab().id].JP_NODEID,results);
  2405. }
  2406. }
  2407. }
  2408. }]);
  2409. this.addAssignItems(win,persons,searchKey);
  2410. win.show();
  2411. },
  2412. addAssignItems:function(win,persons,searchKey){
  2413. var me=this;
  2414. var tab = new Ext.TabPanel({
  2415. id : 'processTab',
  2416. region:'center',
  2417. enableTabScroll : true,
  2418. closeAll : true,
  2419. minTabWidth :80,
  2420. autoHeight:true,
  2421. resizeTabs : true,
  2422. listeners:{
  2423. 'tabchange':function(tabPanel,newCard,oldCard,eOpts){
  2424. Ext.getCmp('searchtextfield').setValue(searchKey[newCard.id]);
  2425. }
  2426. }
  2427. });
  2428. win.add(tab);
  2429. for (var i = 0; i < persons.length; i++){
  2430. var panel=new Ext.Panel({
  2431. id:i.toString(),
  2432. autoHeight:true,
  2433. autoScroll:true,
  2434. layout:'column',
  2435. bodyStyle: 'background:#e0e0e0',
  2436. title:persons[i].JP_NODENAME
  2437. });
  2438. tab.add(panel);
  2439. me.addUserItems(panel,persons[i].JP_NODEID,persons[i].JP_CANDIDATES);
  2440. }
  2441. tab.setActiveTab(0);
  2442. },
  2443. addUserItems:function(panel,jp_nodeid,jp_candidates){
  2444. var me=this;
  2445. var maxSize=jp_candidates.length>24?24:jp_candidates.length,personUsers=new Array(),user=null,more=Ext.getCmp('more'+panel.id);
  2446. if(more)more.destroy();
  2447. for(var j=0;j<maxSize;j++){
  2448. user=Ext.create('Ext.form.field.Radio',{
  2449. name:jp_nodeid,
  2450. boxLabel:jp_candidates[j],
  2451. columnWidth: 0.33,
  2452. fieldCls:'x-myradio',
  2453. checked: j==0?true:false
  2454. });
  2455. personUsers.push(user);
  2456. }
  2457. panel.add(personUsers);
  2458. panel.personUsers=personUsers;
  2459. if(jp_candidates.length>maxSize){
  2460. panel.add({ xtype: 'textfield',
  2461. readOnly:true,
  2462. labelSeparator:'',
  2463. columnWidth:1,
  2464. id:'more'+panel.id,
  2465. fieldStyle : 'background:#e0e0e0;border-bottom:none;vertical-align:middle;border-top:none;border-right:none;border-bottom:none;border-left:none;',
  2466. fieldLabel: '『<a href="#" class="terms">全部</a>』',
  2467. listeners: {
  2468. click: {
  2469. element: 'labelEl',
  2470. fn: function(e,el) {
  2471. var target = e.getTarget('.terms');
  2472. Ext.getCmp('more'+panel.id).destroy();
  2473. if (target) {
  2474. Ext.Array.each(panel.personUsers,function(item){
  2475. panel.remove(item);
  2476. });
  2477. var personUsers=new Array();
  2478. for(var i=0;i<jp_candidates.length;i++){
  2479. user=Ext.create('Ext.form.field.Radio',{
  2480. name:jp_nodeid,
  2481. boxLabel:jp_candidates[i],
  2482. columnWidth: 0.33,
  2483. fieldCls:'x-myradio',
  2484. checked: i==0?true:false
  2485. });
  2486. personUsers.push(user);
  2487. }
  2488. panel.add(personUsers);
  2489. panel.personUsers=personUsers;
  2490. e.preventDefault();
  2491. }
  2492. }
  2493. }
  2494. }
  2495. });
  2496. }
  2497. },
  2498. setLoading : function(b) {// 原this.getActiveTab().setLoading()换成此方法,解决Window模式下无loading问题
  2499. var mask = this.mask;
  2500. if (!mask) {
  2501. this.mask = mask = new Ext.LoadMask(Ext.getBody(), {
  2502. msg : "处理中,请稍后...",
  2503. msgCls : 'z-index:10000;'
  2504. });
  2505. }
  2506. if (b)
  2507. mask.show();
  2508. else
  2509. mask.hide();
  2510. },
  2511. link: function(item,args){
  2512. if(item.xtype=='multifield'){
  2513. item.listeners={
  2514. afterrender:function(item){
  2515. var f=item.firstField;
  2516. if(f.value){
  2517. f.setFieldStyle({ 'color': 'blue'});
  2518. f.focusCls = 'mail-attach';
  2519. var index = 0,url=args[0], length = url.length, s, e;
  2520. while(index < length) {
  2521. if((s = url.indexOf('{', index)) != -1 && (e = url.indexOf('}', s + 1)) != -1) {
  2522. url = url.substring(0, s) + Ext.getCmp(url.substring(s+1, e)).value + url.substring(e+1);
  2523. index = e + 1;
  2524. } else {
  2525. break;
  2526. }
  2527. }
  2528. f.inputEl.addListener('click',function(evt,el){
  2529. openUrl(url);
  2530. });
  2531. }
  2532. }
  2533. };
  2534. }else {
  2535. item.fieldStyle=item.fieldStyle?item.fieldStyle+';color:blue':'color:blue';
  2536. item.focusCls = 'mail-attach';
  2537. item.listeners={
  2538. click: {
  2539. element:'inputEl',
  2540. buffer : 100,
  2541. fn: function(e,el) {
  2542. if(item.value){
  2543. var index = 0,url=args[0], length = url.length, s, e;
  2544. while(index < length) {
  2545. if((s = url.indexOf('{', index)) != -1 && (e = url.indexOf('}', s + 1)) != -1) {
  2546. url = url.substring(0, s) + Ext.getCmp(url.substring(s+1, e)).value + url.substring(e+1);
  2547. index = e + 1;
  2548. } else {
  2549. break;
  2550. }
  2551. }
  2552. openUrl(url);
  2553. }
  2554. }
  2555. }
  2556. };
  2557. }
  2558. },
  2559. Highlight:function(item,args){
  2560. var style='font-weight:bold;color:';
  2561. style+=(args && args[0])?args[0]+";":'red;';
  2562. item.fieldStyle=item.fieldStyle?item.fieldStyle+style:style;
  2563. },
  2564. formula: function(item, args, form){
  2565. Ext.defer(function(){
  2566. var mm = this, field = form.down('#' + item.name), vals = {};
  2567. if(field != null && !form.readOnly) {
  2568. field.addEvents({'formula': true});
  2569. field.addListener('formula', function(f, changedField, changedFieldVal){
  2570. if(changedField) {
  2571. vals[changedField] = changedFieldVal || 0;
  2572. }
  2573. // eg: eval("var a = 1, b = 2, c = 3;a + b / c")
  2574. var exp = 'var ' + Ext.Object.toQueryString(vals).replace(/&/gi, ",") + ";" + args[0];
  2575. field.setValue(eval(exp) || 0);
  2576. });
  2577. var fields = args[0].split(/\+|-|\*|\(|\)|\//g);
  2578. Ext.Array.each(fields, function(f){
  2579. if(f) {
  2580. var ff = form.down('#' + f);
  2581. if(ff) {
  2582. vals[f] = ff.getValue() || 0;
  2583. ff.on('change', function(_f, newVal){
  2584. field.fireEvent('formula', field, _f.getName(), _f.getValue());
  2585. });
  2586. }
  2587. }
  2588. });
  2589. field.fireEvent('formula');
  2590. }
  2591. }, 500);
  2592. }
  2593. });