Search.js 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.Search', {
  3. extend : 'Ext.app.Controller',
  4. requires : ['erp.util.GridUtil', 'erp.util.BaseUtil'],
  5. views : [ 'common.search.Viewport', 'core.trigger.DbfindTrigger', 'core.form.FtField',
  6. 'core.form.ConDateField', 'core.form.YnField',
  7. 'core.form.FtDateField', 'core.form.YearDateField',
  8. 'core.form.MonthDateField', 'core.form.FtFindField', 'core.form.FtNumberField',
  9. 'core.grid.YnColumn', 'core.grid.TfColumn',
  10. 'core.form.ConMonthDateField', 'core.trigger.TextAreaTrigger' ],
  11. models : ['SearchTemplate'],
  12. refs : [ {
  13. ref : 'grid',
  14. selector : '#querygrid'
  15. }, {
  16. ref: 'dataCount',
  17. selector: '#dataCount'
  18. } ],
  19. init : function() {
  20. var me = this;
  21. me.GridUtil = Ext.create('erp.util.GridUtil');
  22. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  23. this.control({
  24. 'button[name=find]' : {
  25. click : function(btn) {
  26. this.onQueryClick();
  27. },
  28. afterrender : function() {
  29. Ext.defer(function(){
  30. me.onQueryClick();
  31. }, 500);
  32. }
  33. },
  34. 'button[name=group]' : {
  35. click : function(btn) {
  36. this.onGroupClick();
  37. }
  38. },
  39. 'button[name=close]' : {
  40. click : function() {
  41. if (parent.Ext && parent.Ext.getCmp('content-panel')) {
  42. parent.Ext.getCmp('content-panel').getActiveTab().close();
  43. } else {
  44. window.close();
  45. }
  46. }
  47. },
  48. 'button[name=clearcondition]' : {
  49. click : function() {
  50. if (this.querywin) {
  51. var g = this.querywin.down('grid');
  52. g.store.removeAll();
  53. g.loadEmptyData();
  54. }
  55. }
  56. },
  57. 'button[name=filter]' : {
  58. click : function() {
  59. }
  60. },
  61. 'button[name=sort]' : {
  62. click : function() {
  63. var items = this.searchTemplate ? this.searchTemplate.items : [],
  64. sorts = this.searchTemplate ? this.searchTemplate.st_sorts : null;
  65. this.onSortClick(items, sorts, function(sorts){
  66. });
  67. }
  68. },
  69. 'button[name=temp]' : {
  70. click : function() {
  71. warnMsg('保存当前设置到方案?', function(b){
  72. if(b == 'ok' || b == 'yes') {
  73. me.updateTemp();
  74. }
  75. });
  76. }
  77. },
  78. 'menuitem[name=exportexcel]' : {
  79. click : function() {
  80. this.BaseUtil.exportGrid(this.getGrid().normalGrid);
  81. }
  82. },
  83. 'menuitem[name=exportpdf]' : {
  84. click : function() {
  85. this.BaseUtil.exportPdf(this.getGrid().normalGrid);
  86. }
  87. },
  88. 'button[name=lock]' : {
  89. click : function() {
  90. this.onLockClick();
  91. }
  92. },
  93. 'menuitem[name=sum]' : {
  94. click : function() {
  95. }
  96. },
  97. 'menuitem[name=average]' : {
  98. click : function() {
  99. }
  100. },
  101. 'menuitem[name=max]' : {
  102. click : function() {
  103. window.open(window.location.href);
  104. }
  105. },
  106. 'menuitem[name=webexcel]' : {
  107. click : function() {
  108. window.open(basePath + 'jsps/Excel/sheet/index.jsp');
  109. }
  110. },
  111. 'button[name=removeformat]' : {
  112. click : function() {
  113. this.onClear();
  114. }
  115. },
  116. 'button[name=clearall]' : {
  117. click : function() {
  118. this.getGrid().normalGrid.store.loadData([{},{},{},{},{},{},{},{},{},{}]);
  119. }
  120. },
  121. 'menuitem[name=template-copy]': {
  122. click: function(item) {
  123. var record = item.ownerCt.record;
  124. if (record) {
  125. var t = record.get('st_title');
  126. me.addTemp(t + '(新)', function(title){
  127. me.copyTemp(title, record.get('st_id'));
  128. });
  129. }
  130. }
  131. },
  132. 'menuitem[name=template-title]': {
  133. click: function(item) {
  134. var record = item.ownerCt.record;
  135. if (record) {
  136. me.addTemp(record.get('st_title'), function(title){
  137. me.onTempTitleChange(title, record.get('st_id'), function(){
  138. record.set('st_title', title);
  139. });
  140. });
  141. }
  142. }
  143. },
  144. 'menuitem[name=template-set]': {
  145. click: function(item) {
  146. var record = item.ownerCt.record;
  147. if (record) {
  148. me.onTempSet(record, record.get('items'), record.get('st_id'));
  149. }
  150. }
  151. },
  152. 'menuitem[name=template-del]': {
  153. click: function(item) {
  154. var grid = item.ownerCt.grid, record = item.ownerCt.record;
  155. if (record) {
  156. warnMsg('确定删除 ' + record.get('st_title') + ' ?', function(k){
  157. if(k == 'ok' || k == 'yes') {
  158. me.onTempDel(record.get('st_id'), function(){
  159. Ext.example.msg('info', '提示', record.get('st_title') + ' 删除成功', 2000);
  160. grid.store.remove(record);
  161. record = grid.store.first();
  162. if(record) {
  163. grid.selModel.select(record);
  164. }
  165. });
  166. }
  167. });
  168. }
  169. }
  170. }
  171. });
  172. if(!window.onLinkClick)
  173. window.onLinkClick = function(l, t, arg1, arg2){
  174. me.onLinkClick(l, t, arg1, arg2);
  175. };
  176. },
  177. onQueryClick : function() {
  178. var me = this, win = me.querywin;
  179. if (!win) {
  180. var form = me.createQueryForm(), temp = me.createTempGrid();
  181. win = me.querywin = Ext.create('Ext.window.Window', {
  182. closeAction : 'hide',
  183. title : '筛选',
  184. height: 500,
  185. width: 550,
  186. items : [form, temp],
  187. buttonAlign : 'center',
  188. buttons : [{
  189. text : $I18N.common.button.erpQueryButton,
  190. height : 26,
  191. handler : function(b) {
  192. var items = temp.selModel.getSelection();
  193. if(items.length > 0) {
  194. me.onQuery(items[0].data);
  195. }
  196. b.ownerCt.ownerCt.hide();
  197. }
  198. },{
  199. text : '直接导出',
  200. iconCls: 'icon-xls',
  201. height : 26,
  202. handler : function(b) {
  203. me.exportExcel(me.getGrid().normalGrid, temp.selModel.getSelection(), form.getCondition());
  204. b.ownerCt.ownerCt.hide();
  205. }
  206. }, {
  207. text : $I18N.common.button.erpCloseButton,
  208. height : 26,
  209. handler : function(b) {
  210. b.ownerCt.ownerCt.hide();
  211. }
  212. }]
  213. });
  214. me.onTempLoad(function(data, lastId){
  215. temp.store.loadData(data);
  216. if(data.length > 0) {
  217. var r = (lastId && temp.store.findRecord('st_id', lastId)) || temp.store.first();
  218. temp.selModel.select(r);
  219. form.setTitle(r.get('st_title'));
  220. }
  221. });
  222. }
  223. win.show();
  224. },
  225. createTempGrid : function() {
  226. var me = this;
  227. return Ext.create('Ext.grid.Panel', {
  228. id: 'temp',
  229. cls: 'custom-grid',
  230. title: '自定义方案',
  231. region: 'south',
  232. height: 200,
  233. autoScroll: true,
  234. tools: [{
  235. type: 'plus',
  236. tooltip: '添加方案',
  237. handler: function(e, el, tb, tool) {
  238. me.addTemp();
  239. }
  240. }],
  241. columns: [{
  242. text: '日期',
  243. dataIndex: 'st_date',
  244. renderer: function(v) {
  245. return Ext.Date.format(new Date(v), 'Y-m-d');
  246. },
  247. flex: 1
  248. },{
  249. text: '创建人',
  250. dataIndex: 'st_man',
  251. flex: 0.8
  252. },{
  253. text: '描述',
  254. dataIndex: 'st_title',
  255. flex: 3
  256. },{
  257. xtype: 'actioncolumn',
  258. flex: .6,
  259. align: 'center',
  260. items: [{
  261. icon: basePath + 'resource/images/16/edit.png',
  262. tooltip: '设置',
  263. handler: function(grid, rIdx, cIdx) {
  264. var record = grid.store.getAt(rIdx);
  265. me.onTempSet(record, record.get('items'), record.get('st_id'));
  266. }
  267. },{
  268. icon: basePath + 'resource/images/16/delete.png',
  269. tooltip: '删除',
  270. handler: function(grid, rIdx, cIdx) {
  271. var record = grid.store.getAt(rIdx);
  272. warnMsg('确定删除 ' + record.get('st_title') + ' ?', function(k){
  273. if(k == 'ok' || k == 'yes') {
  274. me.onTempDel(record.get('st_id'), function(){
  275. Ext.example.msg('info', '提示', record.get('st_title') + ' 删除成功', 2000);
  276. grid.store.remove(record);
  277. record = grid.store.first();
  278. if(record) {
  279. grid.selModel.select(record);
  280. }
  281. });
  282. }
  283. });
  284. }
  285. }]
  286. }],
  287. selModel: Ext.create('Ext.selection.CheckboxModel',{
  288. mode: 'SINGLE',
  289. listeners: {
  290. select : function(sm, record, idx) {
  291. var items = record.get('items');
  292. if(items) {
  293. me.formatTempSet(items, record.get('properties'), true);
  294. }
  295. me.defaultCondition = record.get('st_condition');
  296. me.searchTemplate = record.data;
  297. }
  298. }
  299. }),
  300. columnLines: true,
  301. store: new Ext.data.Store({
  302. fields: ['st_date', 'st_man', 'st_title', 'items', 'properties', 'st_id','st_condition','st_usedtable','st_tablesql','st_sorts', 'st_limits']
  303. }),
  304. viewConfig: {
  305. listeners: {
  306. itemcontextmenu: function(view, record, item, index, e) {
  307. me.onTempContextmenu(view, record, e);
  308. }
  309. }
  310. }
  311. });
  312. },
  313. /**
  314. * 方案grid,右键菜单
  315. */
  316. onTempContextmenu: function(view, record, e) {
  317. e.preventDefault();
  318. var menu = view.contextMenu;
  319. if (!menu) {
  320. menu = view.contextMenu = new Ext.menu.Menu({
  321. items: [{
  322. text : '复制方案',
  323. name: 'template-copy'
  324. },{
  325. text : '修改描述',
  326. name: 'template-title'
  327. },{
  328. text : '编辑方案',
  329. name: 'template-set'
  330. },{
  331. iconCls: 'icon-remove',
  332. text : '删除',
  333. name: 'template-del'
  334. }]
  335. });
  336. menu.grid = view.ownerCt;
  337. }
  338. menu.showAt(e.getXY());
  339. menu.record = record;
  340. },
  341. formatTempSet : function(items, properties, load) {
  342. var me = this, grid = this.getGrid();
  343. var datas = new Array(), columns = new Array(), alias = new Array(),
  344. group = null, locks = new Array(), temp = new Array(), v, w = 0.5;
  345. Ext.Array.each(items, function(i){
  346. var modeItems = [];
  347. if(1 === i.stg_query) {
  348. if (i.stg_mode && i.stg_mode != '' && properties) {// multi properties field
  349. Ext.Array.each(properties, function(p){
  350. if(p.stg_field == i.stg_field) {
  351. modeItems.push({
  352. display: p.display,
  353. value: p.value
  354. });
  355. }
  356. });
  357. if(i.stg_mode == 'checkboxgroup' || i.stg_mode == 'radiogroup') {
  358. var items = [];
  359. Ext.Array.each(properties, function(p){
  360. if(p.stg_field == i.stg_field) {
  361. items.push({
  362. boxLabel: p.display,
  363. inputValue: p.value,
  364. name: i.stg_field,
  365. checked: (i.stg_value && (i.stg_value == p.value || i.stg_value == '$ALL'))
  366. });
  367. }
  368. });
  369. datas.push({
  370. xtype: i.stg_mode,
  371. fieldLabel: i.stg_text,
  372. relativeTable: i.stg_table,
  373. columnWidth: 1,
  374. columns: 3,
  375. vertical: true,
  376. items: items
  377. });
  378. } else if (i.stg_mode == 'combobox') {
  379. var store = new Ext.data.Store({
  380. fields: ['display', 'value'],
  381. data: Ext.Array.merge([{
  382. display: '全部',
  383. value: '$ALL'
  384. },{
  385. display: '无',
  386. value: '$NULL'
  387. }], modeItems)
  388. });
  389. datas.push({
  390. xtype: i.stg_mode,
  391. name: i.stg_field,
  392. fieldLabel: i.stg_text,
  393. relativeTable: i.stg_table,
  394. columnWidth: .5,
  395. store: store,
  396. queryMode: 'local',
  397. displayField: 'display',
  398. valueField: 'value',
  399. value: i.stg_value
  400. });
  401. }
  402. } else {
  403. w = .5;
  404. v = i.stg_value;
  405. var t = 'textfield', type = i.stg_type.toUpperCase();
  406. if(type == 'DATE' || type == 'TIMESTAMP') {
  407. t = 'datefield';
  408. if(!Ext.isEmpty(v)) {
  409. w = 1;
  410. switch(v) {
  411. case '今天':
  412. t = 'condatefield';v = 1;break;
  413. case '昨天':
  414. t = 'condatefield';v = 2;break;
  415. case '本月':
  416. t = 'condatefield';v = 3;break;
  417. case '上个月':
  418. t = 'condatefield';v = 4;break;
  419. case '本年度':
  420. t = 'condatefield';v = 5;break;
  421. case '上年度':
  422. t = 'condatefield';v = 6;break;
  423. case '自定义':
  424. t = 'condatefield';v = 7;break;
  425. default:
  426. if(!Ext.isDate(v) && /\d{4}-\d{2}-\d{2}/.test(v)) {
  427. v = Ext.Date.parse(v, 'Y-m-d');
  428. }
  429. break;
  430. }
  431. }
  432. } else if(type == 'NUMBER') {
  433. t = 'numberfield';
  434. }
  435. if(1 == i.stg_dbfind) {
  436. t = 'dbfindtrigger';
  437. }
  438. if(1 == i.stg_double) {
  439. w = 1;
  440. if(t == 'numberfield') {
  441. t = 'erpFtNumberField';
  442. } else if (t == 'dbfindtrigger') {
  443. t = 'ftfindfield';
  444. } else if (t == 'datefield') {
  445. t = 'ftdatefield';
  446. } else if (t == 'textfield'){
  447. t = 'erpFtField';
  448. }
  449. if(i.stg_format == 'Ym') {
  450. t = 'conmonthdatefield';
  451. }
  452. }
  453. datas.push({
  454. fieldLabel: i.stg_text,
  455. relativeTable: i.stg_table,
  456. labelWidth: 100,
  457. xtype: t,
  458. name: i.stg_field,
  459. id: i.stg_field,
  460. value: v,
  461. columnWidth: w
  462. });
  463. }
  464. }
  465. if(1 === i.stg_group) {
  466. group = i.stg_alias;
  467. }
  468. if(1 === i.stg_lock) {
  469. locks.push(i.stg_alias);
  470. }
  471. var xtype = me.getTypeByStg(i.stg_type);
  472. if(1 === i.stg_use) {
  473. var col = {
  474. text: i.stg_text,
  475. xtype: xtype,
  476. dataIndex: i.stg_alias,
  477. dataField: i.stg_field,
  478. dataTable: i.stg_table,
  479. format: (i.stg_format == 'Ym') ? null : i.stg_format,
  480. width: i.stg_width,
  481. summaryType: i.stg_sum == 1 ? 'sum' : null,
  482. align: xtype == 'numbercolumn' ? 'right' : 'left'
  483. };
  484. if(i.stg_link) {
  485. col.renderer = function(value, p, record) {
  486. if(value) {
  487. return Ext.String.format(
  488. '<a href="javascript:void(0)" onclick="onLinkClick(\'' + i.stg_link + '\',\'{2}\',\'{0}\',\'{1}\')">{2}</a>',
  489. record.get(i.stg_tokencol1),
  490. record.get(i.stg_tokencol2),
  491. value
  492. );
  493. return null;
  494. };
  495. };
  496. }
  497. columns.push(col);
  498. }
  499. temp.push({
  500. stg_text: i.stg_text,
  501. stg_use: i.stg_use,
  502. stg_field: i.stg_field,
  503. stg_value: i.stg_value,
  504. stg_lock: i.stg_lock == 1,
  505. stg_group: i.stg_group == 1,
  506. stg_sum: i.stg_sum == 1,
  507. stg_dbfind: i.stg_dbfind == 1,
  508. stg_double: i.stg_double == 1,
  509. stg_query: i.stg_query == 1,
  510. stg_width: i.stg_width,
  511. stg_type: i.stg_type,
  512. stg_table: i.stg_table,
  513. stg_format: i.stg_format,
  514. stg_formula: i.stg_formula,
  515. stg_mode: i.stg_mode,
  516. modeItems: i.stg_mode ? (modeItems || [{dispay:null,value:null}]) : modeItems,
  517. type: xtype,
  518. links: i.links,
  519. stg_link: i.stg_link,
  520. stg_tokentab1: i.stg_tokentab1,
  521. stg_tokencol1: i.stg_tokencol1,
  522. stg_tokentab2: i.stg_tokentab2,
  523. stg_tokencol2: i.stg_tokencol2
  524. });
  525. });
  526. // 加载筛选条件
  527. if(load) {
  528. var f = this.querywin.down('form');
  529. f.removeAll();
  530. f.add(datas);
  531. var alias = Ext.Array.pluck(columns, 'dataIndex');
  532. Ext.Array.each(temp, function(t){
  533. if(t.stg_tokencol1 && !Ext.Array.contains(alias, t.stg_tokencol1)) {
  534. alias.push(t.stg_tokencol1);
  535. }
  536. if(t.stg_tokencol2 && !Ext.Array.contains(alias, t.stg_tokencol2)) {
  537. alias.push(t.stg_tokencol2);
  538. }
  539. });
  540. Ext.suspendLayouts();
  541. grid.reconfigure(new Ext.data.Store({
  542. fields: alias
  543. }), columns);
  544. Ext.resumeLayouts(true);
  545. // 加载分组条件
  546. this.groupfield = group;
  547. this.toogleGroup(group, true);
  548. // 固定列
  549. this.lockfields = locks;
  550. if(locks.length > 0) {
  551. var normal = grid.getView().normalGrid;
  552. Ext.Array.each(locks, function(){
  553. var column = normal.down('gridcolumn[dataIndex=' + this + ']');
  554. if (column.locked) {
  555. grid.unlock(column);
  556. } else {
  557. grid.lock(column);
  558. }
  559. });
  560. }
  561. // 加载合计
  562. }
  563. return temp;
  564. },
  565. onTempSet : function(record, items, sId) {
  566. var me = this, win = me.tempwin, temp = me.formatTempSet(items, record.get('properties'), false);
  567. if (!win) {
  568. var sGrid = me.getSettingGrid();
  569. Ext.define("Post", {
  570. extend: 'Ext.data.Model',
  571. proxy: {
  572. type: 'ajax',
  573. url : basePath + 'ma/dataDictionary/search.action',
  574. reader: {
  575. type: 'json',
  576. root: 'datas',
  577. totalProperty: 'totalCount'
  578. },
  579. headers: {
  580. 'Content-Type': 'application/json;charset=utf-8'
  581. }
  582. },
  583. fields: [
  584. {name: 'desc', mapping: 'dd_description'},
  585. {name: 'table', mapping: 'dd_tablename'}
  586. ]
  587. });
  588. ds = Ext.create('Ext.data.Store', {
  589. pageSize: 10,
  590. model: 'Post'
  591. });
  592. win = me.tempwin = Ext.create('Ext.window.Window', {
  593. header: {
  594. items: [{
  595. xtype: 'tbtext',
  596. id: 'set-title',
  597. text: '方案设置',
  598. style: 'font-weight: 700;'
  599. }, {
  600. xtype: 'tbtext',
  601. id: 'set-info',
  602. tpl: Ext.create('Ext.XTemplate',
  603. '共 <strong>{tableCount}</strong> 个表关联,' +
  604. '可选 <strong>{columnCount}</strong> 列 ' +
  605. '已选 <strong>{usedCount}</strong> 列')
  606. }]
  607. },
  608. closeAction : 'hide',
  609. width : '100%',
  610. height : '80%',
  611. layout: 'border',
  612. items : [{
  613. region: 'west',
  614. width: 400,
  615. layout: 'accordion',
  616. id: 'dictionary',
  617. tbar: [{
  618. xtype: 'combo',
  619. store: ds,
  620. width: 360,
  621. displayField: 'desc',
  622. emptyText: '查找数据字典',
  623. typeAhead: false,
  624. hideLabel: true,
  625. hideTrigger:true,
  626. minChars: 3,
  627. listConfig: {
  628. minHeight: 360,
  629. maxHeight: 360,
  630. loadingText: '查找中...',
  631. emptyText: '<h3>没有找到您需要的数据字典.</h3>',
  632. getInnerTpl: function() {
  633. return '<div style="padding: 5px 10px;">' +
  634. '<span style="font-weight:bold;font-size:120%;">' +
  635. '<tpl if="desc">{desc}<tpl else>{table}</tpl>' +
  636. '</span>' +
  637. '<span style="float:right;">{table}</span>' +
  638. '</div>';
  639. }
  640. },
  641. pageSize: 10,
  642. listeners: {
  643. select: function(combo, records, opts) {
  644. me.addDictionary(win, records[0].get('table'));
  645. combo.reset();
  646. }
  647. },
  648. getParams: function(queryString) {
  649. var params = {},
  650. param = this.queryParam;
  651. if (param) {
  652. params[param] = escape(queryString);
  653. }
  654. return params;
  655. }
  656. },'->', {
  657. xtype: 'tool',
  658. type: 'left',
  659. style: {
  660. marginRight: '5px'
  661. },
  662. tooltip: '收拢',
  663. handler: function(e, el, tb, tool) {
  664. tb.ownerCt.collapse(Ext.Component.DIRECTION_LEFT, true);
  665. }
  666. }]
  667. },{
  668. region: 'center',
  669. layout: 'anchor',
  670. items: [sGrid]
  671. }],
  672. buttonAlign : 'center',
  673. buttons : [{
  674. text : '保存到方案',
  675. height : 26,
  676. handler : function(b) {
  677. var w = b.ownerCt.ownerCt;
  678. me.updateTemp(function(){
  679. w.hide();
  680. });
  681. }
  682. },{
  683. text : '作为新方案保存',
  684. id: 'new_temp_btn',
  685. height : 26,
  686. hidden : (sId <= 0),
  687. handler : function(b) {
  688. var t = win.relativeRecord.get('st_title');
  689. me.addTemp(t + '(新)', function(title){
  690. var w = b.ownerCt.ownerCt;
  691. w.hide();
  692. me.copyTemp(title);
  693. });
  694. }
  695. }, {
  696. text : $I18N.common.button.erpCloseButton,
  697. height : 26,
  698. handler : function(b) {
  699. b.ownerCt.ownerCt.hide();
  700. }
  701. }]
  702. });
  703. }
  704. win.show();
  705. if(sId <= 0) {
  706. win.down('#new_temp_btn').hide();
  707. } else {
  708. win.down('#new_temp_btn').show();
  709. }
  710. var g = win.down('#grid-setting');
  711. g.store.loadData(temp);
  712. g.sorts = record.get('st_sorts');
  713. g.limits = record.get('st_limits');
  714. g.down('#st_condition').setValue(record.get('st_condition'));
  715. // 加载数据字典
  716. var dic = win.down('#dictionary'),
  717. usedTabs = record.get('st_usedtable'), tabSql = record.get('st_tablesql');
  718. if(dic.tables != usedTabs || win.relativeId != sId) {
  719. g.down('#set-tab-info').setTooltip(me.getCodeTip({
  720. usedTabs: usedTabs.split(','),
  721. tabSql: tabSql,
  722. condSql: record.get('st_condition'),
  723. sortSql: g.sorts,
  724. data: temp
  725. }));
  726. me.getDictionary(usedTabs, function(datas){
  727. dic.tables = usedTabs;
  728. dic.removeAll();
  729. var c = 0;
  730. for(var i in datas) {
  731. dic.add(me.createDictionaryGrid(datas[i]));
  732. c += datas[i].dataDictionaryDetails.length;
  733. }
  734. win.down('#set-info').update({
  735. tableCount: datas.length,
  736. columnCount: c,
  737. usedCount: temp.length
  738. });
  739. });
  740. }
  741. if(win.relativeId != sId) {
  742. win.down('#set-title').setText(record.get('st_title'));
  743. win.relativeRecord = record;
  744. win.relativeId = sId;
  745. }
  746. },
  747. /**
  748. * 显示方案sql的tip
  749. */
  750. getCodeTip: function(config) {
  751. var me = this, oldConf = me.templateConfig;
  752. if(!oldConf)
  753. oldConf = {};
  754. me.templateConfig = config = Ext.Object.merge(oldConf, config);
  755. return new Ext.tip.ToolTip({
  756. target: 'set-tab-info',
  757. cls: 'tip-custom',
  758. autoHide: false,
  759. hideDelay: 0,
  760. html: me.getCodeHtml(config)
  761. });
  762. },
  763. /**
  764. * 代码html
  765. */
  766. getCodeHtml: function(datas) {
  767. return new Ext.XTemplate(
  768. '<strong class="code-title">数据字典:</strong>' +
  769. '<tpl for="usedTabs">' +
  770. '<label class="label label-info">{.}</label>' +
  771. '</tpl>' +
  772. '<strong class="code-title">关联SQL:</strong>' +
  773. '<div class="code-body">{tabSql:this.format}</div>' +
  774. '<strong class="code-title">排序SQL:</strong>' +
  775. '<div class="code-body">{sortSql:this.orderBy}</div>' +
  776. '<strong class="code-title">条件SQL:</strong>' +
  777. '<div class="code-body">{condSql:this.format}</div>' +
  778. '<strong class="code-title">查询SQL:</strong>' +
  779. '<div class="code-body">{[this.getSearchSql(values)]}</div>', {
  780. keywords : ['SELECT ', ' FROM ', ' WHERE ', ' LEFT JOIN ', ' ON ', 'ORDER BY ', ' AND ', ' DESC', ' ASC', 'TO_CHAR'],
  781. format: function(sql) {
  782. if(!sql) return null;
  783. var kw = this.keywords;
  784. for(var i in kw) {
  785. var reg = new RegExp(kw[i], 'g');
  786. sql = sql.replace(reg, '<span class="code-key">' + kw[i] + '</span>');
  787. }
  788. sql = this.replaceQuot(sql);
  789. return sql;
  790. },
  791. replaceQuot: function(sql) {
  792. var index = 0, length = sql.length, s, e = -1, c = 0, htm = '';
  793. while(index < length) {
  794. if((s = sql.indexOf('\'', index)) != -1 && (e = sql.indexOf('\'', s + 1)) != -1) {
  795. c = 1;
  796. while(sql.substring(e + c, e + c + 1) == '\'' || c%2 == 0){
  797. e++;
  798. c++;
  799. }
  800. htm += sql.substring(index, s) + '<span class="code-quot">' + sql.substring(s, e+1) +'</span>';
  801. index = e + 1;
  802. } else {
  803. htm += sql.substring(e + 1);
  804. break;
  805. }
  806. }
  807. return htm.length > 0 ? htm : sql;
  808. },
  809. orderBy: function(sql) {
  810. if(!sql) return null;
  811. return this.format('ORDER BY ' + sql);
  812. },
  813. getSearchSql: function(values) {
  814. var fs = [];
  815. Ext.Array.each(values.data, function(d){
  816. if(d.stg_type.toLowerCase() == 'date')
  817. fs.push('TO_CHAR(' + d.stg_table + '.' + d.stg_field +
  818. ', \'yyyy-mm-dd hh24:mi:ss\') ' + d.stg_field);
  819. else
  820. fs.push(d.stg_table + '.' + d.stg_field + ' ' + d.stg_field);
  821. });
  822. return this.format('SELECT ' + fs.join(',') + ' FROM ' + values.tabSql +
  823. (values.condSql ? (' WHERE (' + values.condSql + ')') : '') +
  824. (values.sortSql ? (' ORDER BY ' + values.sortSql) : ''));
  825. }
  826. }).apply(datas);
  827. },
  828. /**
  829. * 添加数据字典
  830. */
  831. addDictionary: function(win, table) {
  832. var me = this, dic = win.down('#dictionary');
  833. if(dic.tables && Ext.Array.indexOf(dic.tables.split(','), table) > -1) {
  834. Ext.example.msg('warning', '警告', '不能添加已经存在的表', 4000);
  835. return;
  836. }
  837. var newTabs = dic.tables ? dic.tables + ',' + table : table;
  838. me.getTabSql(newTabs, function(sql){
  839. me.getDictionary(table, function(datas){
  840. dic.tables = newTabs;
  841. var c = 0;
  842. for(var i in datas) {
  843. dic.add(me.createDictionaryGrid(datas[i]));
  844. c += datas[i].dataDictionaryDetails.length;
  845. }
  846. Ext.each(dic.items.items, function(g){
  847. c += g.store.getCount();
  848. });
  849. win.down('#set-info').update({
  850. tableCount: dic.items.items.length,
  851. columnCount: c
  852. });
  853. win.down('#set-tab-info').setTooltip(me.getCodeTip({
  854. usedTabs: dic.tables.split(','),
  855. tabSql: sql
  856. }));
  857. });
  858. });
  859. },
  860. getTypeByStg: function(t) {
  861. t = t.toUpperCase();
  862. if(t.indexOf('NUMBER') > -1)
  863. return 'numbercolumn';
  864. if(t.indexOf('DATE') > -1)
  865. return 'datecolumn';
  866. return null;
  867. },
  868. /**
  869. * 显示数据字典的grid
  870. */
  871. createDictionaryGrid: function(dic) {
  872. var id = 'grid-' + dic.dd_tablename, datas = [], me = this;
  873. Ext.Array.each(dic.dataDictionaryDetails, function(d){
  874. var nl = {
  875. text: d.ddd_description,
  876. type: me.getTypeByStg(d.ddd_fieldtype),
  877. stg_width: 100,
  878. stg_text: d.ddd_description,
  879. stg_use: 1,
  880. stg_field: d.ddd_fieldname,
  881. stg_table: d.ddd_tablename,
  882. stg_type: d.ddd_fieldtype,
  883. modeItems: [],
  884. links: d.links
  885. };
  886. if(d.links && d.links.length > 0) {
  887. nl.stg_link = d.links[0].dl_link;
  888. nl.stg_tokentab1 = d.links[0].dl_tokentab1;
  889. nl.stg_tokencol1 = d.links[0].dl_tokencol1;
  890. nl.stg_tokentab2 = d.links[0].dl_tokentab2;
  891. nl.stg_tokencol2 = d.links[0].dl_tokencol2;
  892. }
  893. datas.push(nl);
  894. });
  895. return new Ext.grid.Panel({
  896. title: dic.dd_description,
  897. cls: 'custom-grid',
  898. id: id,
  899. columns: [{
  900. text: '代码',
  901. dataIndex: 'stg_field',
  902. flex: 1,
  903. filter: {
  904. xtype : 'textfield'
  905. }
  906. },{
  907. text: '描述',
  908. dataIndex: 'stg_text',
  909. flex: 1,
  910. filter: {
  911. xtype : 'textfield'
  912. }
  913. }],
  914. plugins: [Ext.create('erp.view.core.grid.HeaderFilter')],
  915. viewConfig: {
  916. plugins: {
  917. ptype: 'gridviewdragdrop',
  918. dragGroup: 'grid-setting',
  919. dropGroup: 'grid-setting'
  920. },
  921. listeners: {
  922. drop: function(node, data) {
  923. // 从配置里面拖过来的,表示删除
  924. // 重新加载数据,防止出现checkcolumn的勾选错位情况
  925. var newData = [];
  926. data.view.store.each(function(record){
  927. newData.push(record.data);
  928. });
  929. data.view.store.loadData(newData);
  930. }
  931. }
  932. },
  933. selModel: new Ext.selection.RowModel({
  934. mode: 'MULTI'
  935. }),
  936. store: new Ext.data.Store({
  937. model: erp.model.SearchTemplate,
  938. data: datas,
  939. sorters: [{
  940. property: 'stg_field',
  941. direction: 'ASC'
  942. }]
  943. })
  944. });
  945. },
  946. createQueryForm : function() {
  947. var me = this;
  948. var form = Ext.create('Ext.form.Panel', {
  949. region: 'center',
  950. height: 300,
  951. title: '(未选择方案)',
  952. layout: 'column',
  953. autoScroll: true,
  954. defaults: {
  955. columnWidth: 1,
  956. margin: '4 8 4 8'
  957. },
  958. bodyStyle: 'background:#f1f2f5;',
  959. getCondition: function() {
  960. var s = me.defaultCondition ? '(' + me.defaultCondition + ')' : '';
  961. Ext.each(this.items.items, function(){
  962. var v = this.getValue(), b = this.relativeTable, n = this.name, _n = b + '.' + n, t;
  963. if(!Ext.isEmpty(v) && v != '$ALL') {
  964. switch(this.xtype) {
  965. case 'datefield':
  966. t = "to_char(" + _n + ",'yyyy-mm-dd')='" + Ext.Date.format(v,'Y-m-d') + "'";break;
  967. case 'condatefield':
  968. t = _n + ' ' + v;break;
  969. case 'ftdatefield':
  970. t = _n + ' ' + this.value;break;
  971. case 'ftfindfield':
  972. t = _n + ' ' + this.value;break;
  973. case 'erpFtNumberField':
  974. t = _n + ' ' + this.value;break;
  975. case 'checkboxgroup':
  976. if(!Ext.Object.isEmpty(v)) {
  977. var ks = Ext.Object.getKeys(v), k = ks[0], vs = [];
  978. Ext.Array.each(v[k], function(c){
  979. vs.push(k + '=\'' + c + '\'');
  980. });
  981. t = vs.join(' OR ');
  982. }
  983. break;
  984. case 'radiogroup':
  985. if(!Ext.Object.isEmpty(v)) {
  986. var ks = Ext.Object.getKeys(v), k = ks[0];
  987. t = k + '=\'' + v[k] + '\'';
  988. }
  989. break;
  990. case 'conmonthdatefield':
  991. if(!Ext.Object.isEmpty(v)) {
  992. if(n.toUpperCase().indexOf('YM_VIEW_PARAM') > -1) {
  993. t = ' ' + this.value;
  994. } else {
  995. t = _n + ' ' + this.value;
  996. }
  997. }
  998. break;
  999. default:
  1000. v = String(v);
  1001. if(v.charAt(0) == '%' || v.charAt(v.length - 1) == '%') {
  1002. t = _n + " like '" + v + "'";
  1003. } else if (v == '$NULL') {
  1004. t = "nvl(" + _n + ",' ')=' '";
  1005. } else {
  1006. t = _n + "='" + v + "'";
  1007. }
  1008. break;
  1009. }
  1010. if(t) {
  1011. t = '(' + t + ')';
  1012. s += s.length > 0 ? (' and ' + t ) : t;
  1013. }
  1014. }
  1015. });
  1016. return s.length > 0 ? s : '0=0';
  1017. }
  1018. });
  1019. return form;
  1020. },
  1021. onQuery : function(data) {
  1022. var g = this.getGrid(), q = this.querywin.down('form'), end = g.maxDataSize || 10000;
  1023. this.loadNewStore(g, {
  1024. sId: data ? data.st_id : this.$sid,
  1025. condition: q.getCondition(),
  1026. sorts: data ? data.st_sorts : this.templateConfig.sorts,
  1027. start: 1,
  1028. end: end
  1029. });
  1030. this.querywin.hide();
  1031. this.log();//记录本次选择的方案
  1032. },
  1033. onGroupClick : function() {
  1034. var me = this, win = me.groupwin;
  1035. if (!win) {
  1036. var form = me.getAliaForm();
  1037. win = me.groupwin = Ext.create('Ext.window.Window', {
  1038. title : '分组设置',
  1039. closeAction : 'hide',
  1040. width : 500,
  1041. maxHeight : 400,
  1042. items : [form],
  1043. buttonAlign : 'center',
  1044. buttons : [{
  1045. text : '取消分组',
  1046. flag : 'cancel',
  1047. height : 26,
  1048. disabled : true,
  1049. handler : function(b) {
  1050. var w = b.ownerCt.ownerCt;
  1051. me.toogleGroup(w.down('form'), false);
  1052. w.hide();
  1053. }
  1054. },{
  1055. text : $I18N.common.button.erpConfirmButton,
  1056. height : 26,
  1057. handler : function(b) {
  1058. var w = b.ownerCt.ownerCt;
  1059. me.toogleGroup(w.down('form'), true);
  1060. w.hide();
  1061. }
  1062. }, {
  1063. text : $I18N.common.button.erpCloseButton,
  1064. height : 26,
  1065. handler : function(b) {
  1066. b.ownerCt.ownerCt.hide();
  1067. }
  1068. }]
  1069. });
  1070. if(this.groupfield) {
  1071. var f = win.down('radio[inputValue=' + this.groupfield + ']');
  1072. if(f) {
  1073. f.setValue(true);
  1074. }
  1075. }
  1076. }
  1077. win.show();
  1078. var f = win.down('radio[value=true]'), b = win.down('button[flag=cancel]');
  1079. b.setDisabled(!f);
  1080. },
  1081. onLockClick : function() {
  1082. var me = this, win = me.lockwin;
  1083. if (!win) {
  1084. var form = me.getAliaForm('checkbox');
  1085. win = me.lockwin = Ext.create('Ext.window.Window', {
  1086. title : '固定列设置',
  1087. closeAction : 'hide',
  1088. width : 500,
  1089. maxHeight : 400,
  1090. items : [form],
  1091. buttonAlign : 'center',
  1092. buttons : [{
  1093. text : $I18N.common.button.erpConfirmButton,
  1094. height : 26,
  1095. handler : function(b) {
  1096. var w = b.ownerCt.ownerCt;
  1097. me.onLock(w.down('form'));
  1098. w.hide();
  1099. }
  1100. }, {
  1101. text : $I18N.common.button.erpCloseButton,
  1102. height : 26,
  1103. handler : function(b) {
  1104. b.ownerCt.ownerCt.hide();
  1105. }
  1106. }]
  1107. });
  1108. if(this.lockfields) {
  1109. Ext.Array.each(this.lockfields, function(l){
  1110. var f = win.down('checkbox[inputValue=' + l + ']');
  1111. if(f) {
  1112. f.setValue(true);
  1113. }
  1114. });
  1115. }
  1116. }
  1117. win.show();
  1118. },
  1119. onSortClick : function(source, oldSorts, callback) {
  1120. var me = this, win = me.sortwin;
  1121. var oldData = [], oldProp = [];
  1122. if(oldSorts) {
  1123. Ext.Array.each(oldSorts.split(','), function(s, i){
  1124. var p = s.split(' '), t = null, f = p[0], tx = '';
  1125. if(f.indexOf('.') > 0) {// table.field
  1126. t = f.substr(0, f.indexOf('.'));
  1127. f = f.substr(f.indexOf('.') + 1);
  1128. }
  1129. if(Ext.isArray(source)) {
  1130. var obj = Ext.Array.findBy(source, function(i){
  1131. return i.stg_field == f;
  1132. });
  1133. if (obj) tx = obj.stg_text;
  1134. } else {
  1135. tx = source.findRecord('stg_field', f).get('stg_text');
  1136. }
  1137. oldData.push({property: f, direction: p[1], number: i+1, description: tx, table: t});
  1138. oldProp.push(f);
  1139. });
  1140. }
  1141. if (!win) {
  1142. var form = me.getGridForm('checkbox', null, source, oldProp),
  1143. view = me.getSortingView(oldData);
  1144. win = me.sortwin = Ext.create('Ext.window.Window', {
  1145. title : '排序设置',
  1146. closeAction : 'hide',
  1147. width : 800,
  1148. layout: 'hbox',
  1149. defaults: {flex: 1},
  1150. items : [form, view],
  1151. buttonAlign : 'center',
  1152. buttons : [{
  1153. text : $I18N.common.button.erpConfirmButton,
  1154. height : 26,
  1155. handler : function(b) {
  1156. var w = b.ownerCt.ownerCt, sorts = [], desc = '';
  1157. view.getStore().each(function(i){
  1158. desc = i.get('property') + ' ' + i.get('direction');
  1159. if(i.get('table'))
  1160. desc = i.get('table') + '.' + desc;
  1161. sorts.push(desc);
  1162. });
  1163. callback.call(me, sorts.join(','));
  1164. w.hide();
  1165. }
  1166. }, {
  1167. text : $I18N.common.button.erpCloseButton,
  1168. height : 26,
  1169. handler : function(b) {
  1170. b.ownerCt.ownerCt.hide();
  1171. }
  1172. }]
  1173. });
  1174. } else {
  1175. var form = win.down('form'), view = win.down('dataview');
  1176. form.removeAll();
  1177. form.add(me.createFormItems(source, oldProp));
  1178. view.store.loadData(oldData);
  1179. }
  1180. win.show();
  1181. me.onSortChange(win.down('form'), win.down('dataview'));
  1182. },
  1183. /**
  1184. * 排序设置,监听字段变化
  1185. */
  1186. onSortChange: function(form, view) {
  1187. var me = this, onDirectionChange = function() {
  1188. var d = Ext.select("td.sort-value input"), e = d.elements;
  1189. Ext.each(e, function(m) {
  1190. Ext.EventManager.on(m, {
  1191. change : function(e, el){
  1192. var record = view.getStore().findRecord('property', el.name);
  1193. record.set('direction', el.value);
  1194. },
  1195. buffer : 100
  1196. });
  1197. });
  1198. };
  1199. form.getForm().getFields().each(function(field){
  1200. field.on('change', function(scope){
  1201. view.getStore().loadData(me.getSortProperties(scope.ownerCt, view.getStore()));
  1202. onDirectionChange();
  1203. });
  1204. });
  1205. Ext.defer(onDirectionChange, 100);
  1206. },
  1207. /**
  1208. * 选中的排序字段view
  1209. */
  1210. getSortingView: function(oldData) {
  1211. var sortStore = new Ext.data.Store({
  1212. fields: ['property', 'description', 'direction', 'number', 'table'],
  1213. sorters: [{
  1214. property: 'number',
  1215. direction: 'ASC'
  1216. }],
  1217. data: oldData
  1218. });
  1219. return Ext.create('Ext.view.View', {
  1220. cls: 'sort-view',
  1221. tpl: '<tpl for=".">' +
  1222. '<div class="sort"><table><tbody>' +
  1223. '<tr><td class="sort-name">{description}</td></tr>' +
  1224. '<tr><td class="sort-value">' +
  1225. '<em>升序 </em><input type="radio" name="{property}" value="ASC" ' +
  1226. '<tpl if="direction == &quot;ASC&quot;"> checked="checked"</tpl>' +
  1227. '/>' +
  1228. '</td></tr>' +
  1229. '<tr><td class="sort-value">' +
  1230. '<em>降序 </em><input type="radio" name="{property}" value="DESC" ' +
  1231. '<tpl if="direction == &quot;DESC&quot;"> checked="checked"</tpl>' +
  1232. '/>' +
  1233. '</td></tr>' +
  1234. '</tbody></table></div>' +
  1235. '</tpl>' +
  1236. '<ol class="sort-note">' +
  1237. '<li>如果直接点击列抬头来排序,将不会使用到本次排序设置</li>' +
  1238. '<li>可以拖放选中的字段来改变排序的优先顺序</li>' +
  1239. '</ol>',
  1240. itemSelector: 'div.sort',
  1241. overItemCls: 'sort-over',
  1242. selectedItemClass: 'sort-selected',
  1243. singleSelect: true,
  1244. ddGroup: 'sort',
  1245. store: sortStore,
  1246. listeners: {
  1247. render: function(v) {
  1248. v.dragZone = new Ext.dd.DragZone(v.ownerCt.el, {
  1249. ddGroup: 'sort',
  1250. getDragData: function(e) {
  1251. var sourceEl = e.getTarget(v.itemSelector, 10), d;
  1252. if (sourceEl) {
  1253. d = sourceEl.cloneNode(true);
  1254. d.id = Ext.id();
  1255. return (v.dragData = {
  1256. sourceEl: sourceEl,
  1257. repairXY: Ext.fly(sourceEl).getXY(),
  1258. ddel: d,
  1259. record: v.getRecord(sourceEl)
  1260. });
  1261. }
  1262. },
  1263. getRepairXY: function() {
  1264. return this.dragData.repairXY;
  1265. }
  1266. });
  1267. v.dropZone = new Ext.dd.DropZone(v.ownerCt.el, {
  1268. ddGroup: 'sort',
  1269. getTargetFromEvent: function(e) {
  1270. return e.getTarget('.sort .sort-over');
  1271. },
  1272. onNodeEnter: function(target, dd, e, data){
  1273. var fly = Ext.fly(target);
  1274. if(fly && typeof fly.addClass === 'function')
  1275. fly.addClass('sort-target-hover');
  1276. },
  1277. onNodeOut: function(target, dd, e, data){
  1278. var fly = Ext.fly(target);
  1279. if(fly && typeof fly.removeClass === 'function')
  1280. fly.removeClass('sort-target-hover');
  1281. },
  1282. onNodeOver: function(target, dd, e, data){
  1283. return Ext.dd.DropZone.prototype.dropAllowed;
  1284. },
  1285. onNodeDrop : function(target, dd, e, data){
  1286. var dragRec = dd.dragData.record,
  1287. dropRec = v.getRecord(target);
  1288. var i = dragRec.get('number'), j = dropRec.get('number');
  1289. dragRec.set('number', j);
  1290. dropRec.set('number', i);
  1291. v.getStore().sort('number', 'ASC');
  1292. return true;
  1293. }
  1294. });
  1295. }
  1296. }
  1297. });
  1298. },
  1299. newComboConfig: function(data) {
  1300. return {
  1301. store: Ext.create('Ext.data.Store', {
  1302. fields: ['display', 'value'],
  1303. data : data
  1304. }),
  1305. displayField: 'display',
  1306. valueField: 'value',
  1307. queryMode: 'local'
  1308. };
  1309. },
  1310. getSettingGrid : function() {
  1311. var me = this, config = {
  1312. store: Ext.create('Ext.data.Store', {
  1313. fields: ['display', 'value'],
  1314. data : [
  1315. {"display": '今天', "value": '今天'},
  1316. {"display": '昨天', "value": '昨天'},
  1317. {"display": '本月', "value": '本月'},
  1318. {"display": '上个月', "value": '上个月'},
  1319. {"display": '本年度', "value": '本年度'},
  1320. {"display": '上年度', "value": '上年度'},
  1321. {"display": '自定义', "value": '自定义'}
  1322. ]
  1323. }),
  1324. displayField: 'display',
  1325. valueField: 'value',
  1326. queryMode: 'local'
  1327. };
  1328. var formatStore = new Ext.data.Store({
  1329. fields: ['display', 'value', 'type'],
  1330. data: [{
  1331. display: '0,000.00',
  1332. value: '0,000.00',
  1333. type: 'numbercolumn'
  1334. },{
  1335. display: '0,000.0000',
  1336. value: '0,000.0000',
  1337. type: 'numbercolumn'
  1338. },{
  1339. display: '0,000.000000',
  1340. value: '0,000.000000',
  1341. type: 'numbercolumn'
  1342. },{
  1343. display: '整数',
  1344. value: '0,000',
  1345. type: 'numbercolumn'
  1346. },{
  1347. display: '年-月-日',
  1348. value: 'Y-m-d',
  1349. type: 'datecolumn'
  1350. },{
  1351. display: '年-月-日 时:分:秒',
  1352. value: 'Y-m-d H:i:s',
  1353. type: 'datecolumn'
  1354. },{
  1355. display: '年-月',
  1356. value: 'Y-m',
  1357. type: 'datecolumn'
  1358. },{
  1359. display: '月-日 时:分',
  1360. value: 'm-d H:i',
  1361. type: 'datecolumn'
  1362. }]
  1363. });
  1364. return Ext.create('Ext.grid.Panel', {
  1365. id: 'grid-setting',
  1366. anchor: '100% 100%',
  1367. autoScroll : true,
  1368. cls: 'custom-grid',
  1369. border: false,
  1370. columnLines: true,
  1371. tbar: [{
  1372. text: '自定义公式',
  1373. iconCls: 'icon-fx',
  1374. handler: function(t) {
  1375. var g = t.ownerCt.ownerCt;
  1376. me.onFormulaClick(g.getStore(), null, function(formula){
  1377. g.store.add({
  1378. stg_text: '输入公式名称',
  1379. stg_use: true,
  1380. stg_field: 'COL_' + new Date().getTime(),
  1381. stg_formula: formula,
  1382. stg_width: 100,
  1383. stg_type: 'NUMBER',
  1384. stg_format: '0,000.00',
  1385. modeItems: []
  1386. });
  1387. g.selModel.select(g.store.last());
  1388. });
  1389. }
  1390. },{
  1391. text: '权限约束',
  1392. iconCls: 'icon-limit',
  1393. handler: function(t) {
  1394. var g = t.ownerCt.ownerCt;
  1395. me.onLimitClick(g.getStore(), g.limits, function(val){
  1396. g.limits = val;
  1397. });
  1398. }
  1399. },{
  1400. text: '排序设置',
  1401. iconCls: 'icon-sort',
  1402. handler: function(t) {
  1403. var g = t.ownerCt.ownerCt;
  1404. me.onSortClick(g.getStore(), g.sorts, function(sorts){
  1405. g.sorts = sorts;
  1406. g.down('#set-tab-info').setTooltip(me.getCodeTip({
  1407. sortSql: g.sorts
  1408. }));
  1409. });
  1410. }
  1411. },'->',{
  1412. xtype: 'textfield',
  1413. emptyText: 'SQL条件',
  1414. width: '66%',
  1415. id: 'st_condition'
  1416. }],
  1417. bbar: ['提示:1. 可以拖动数据字典的字段到右边;2. 字段可以拖放来调整顺序;3. 行展开设置特殊选项', '->', {
  1418. icon: basePath + 'resource/images/16/question.png',
  1419. cls: 'x-btn-icon',
  1420. text: '查看方案代码',
  1421. tooltip: '',
  1422. id: 'set-tab-info'
  1423. }],
  1424. viewConfig: {
  1425. plugins: {
  1426. ptype: 'gridviewdragdrop',
  1427. dragGroup: 'grid-setting',
  1428. dropGroup: 'grid-setting'
  1429. },
  1430. listeners: {
  1431. drop: function(node, data, over) {
  1432. // 重新加载数据,防止出现checkcolumn的勾选错位情况
  1433. var newData = [];
  1434. if(over) {
  1435. over.store.each(function(record){
  1436. newData.push(record.data);
  1437. });
  1438. over.store.loadData(newData);
  1439. }
  1440. }
  1441. }
  1442. },
  1443. plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
  1444. clicksToEdit: 1,
  1445. listeners: {
  1446. beforeedit: function(editor, e, opts) {
  1447. if(e.column.dataIndex == 'stg_value') {
  1448. var isDate = ['datecolumn','datetimecolumn'].indexOf(e.record.get('type')) > -1,
  1449. isRadio = e.record.get('stg_mode') == 'radiogroup',
  1450. isMulti = ['checkboxgroup','combobox'].indexOf(e.record.get('stg_mode')) > -1,
  1451. items = e.record.get('modeItems');
  1452. if(isDate) {
  1453. e.column.setEditor(new Ext.form.field.ComboBox(Ext.Object.merge(config, {
  1454. value: e.value
  1455. })));
  1456. } else if(isRadio) {
  1457. e.column.setEditor(new Ext.form.field.ComboBox(Ext.Object.merge(me.newComboConfig(items), {
  1458. value: e.value
  1459. })));
  1460. } else if(isMulti) {
  1461. var _items = Ext.Array.merge([{display: '全选', value: '$ALL'}], items);
  1462. e.column.setEditor(new Ext.form.field.ComboBox(Ext.Object.merge(me.newComboConfig(_items), {
  1463. value: e.value
  1464. })));
  1465. } else {
  1466. e.column.setEditor(new Ext.form.field.Text({
  1467. value: e.value
  1468. }));
  1469. }
  1470. } else if(e.column.dataIndex == 'stg_format') {
  1471. formatStore.clearFilter(true);
  1472. formatStore.filter('type', e.record.get('type'));
  1473. }
  1474. }
  1475. }
  1476. }), {
  1477. ptype: 'rowexpander',
  1478. pluginId: 'rowexpander',
  1479. expandOnDblClick: false,
  1480. rowBodyTpl : [
  1481. '<tpl if="stg_formula">' +
  1482. '<div class="row">' +
  1483. '<label class="radio-inline text-info col-xs-2">' +
  1484. '表达式:' +
  1485. '</label>' +
  1486. '<div class="col-xs-8">{stg_formula:this.formatFormula}</div>' +
  1487. '<div class="col-xs-1">' +
  1488. '<button id="{[this.linkEvent(\'onFormulaEdit\')]}" class="x-btn" data-bind="{stg_field}">编辑</button>' +
  1489. '</div>' +
  1490. '</div><br>' +
  1491. '</tpl>'+
  1492. '<tpl if="stg_link">' +
  1493. '<div class="links row">' +
  1494. '<label class="radio-inline text-info col-xs-2">' +
  1495. '链接:' +
  1496. '</label>' +
  1497. '<div class="col-xs-10">' +
  1498. '<tpl for="links">' +
  1499. '<label class="radio-inline">' +
  1500. '<input type="radio" id="{[this.linkEvent(\'onLinkChange\')]}" name="{dl_fieldname}-link" data-bind="{dl_fieldname}" value="{[xindex]}" ' +
  1501. '<tpl if="dl_link == parent.stg_link"> checked="checked"</tpl>' +
  1502. ' /> {dl_title}' +
  1503. '</label>' +
  1504. '</tpl>' +
  1505. '</div>' +
  1506. '</div>' +
  1507. '</tpl>' +
  1508. '<tpl if="stg_table">' +
  1509. '<div class="mode-type row" data-bind="{stg_field}">' +
  1510. '<label class="radio-inline text-info col-xs-2">' +
  1511. '查询格式:' +
  1512. '</label>' +
  1513. '<div class="col-xs-10">' +
  1514. '<label class="radio-inline">' +
  1515. '<input type="radio" id="{[this.linkEvent(\'onModeChange\')]}" name="{stg_field}" value="" ' +
  1516. '<tpl if="!stg_mode || stg_mode == &quot;&quot;"> checked="checked"</tpl>' +
  1517. ' /> 无' +
  1518. '</label>' +
  1519. '<label class="radio-inline">' +
  1520. '<input type="radio" id="{[this.linkEvent(\'onModeChange\')]}" name="{stg_field}" value="checkboxgroup" ' +
  1521. '<tpl if="stg_mode == &quot;checkboxgroup&quot;"> checked="checked"</tpl>' +
  1522. ' /> 勾选框' +
  1523. '</label>' +
  1524. '<label class="radio-inline">' +
  1525. '<input type="radio" id="{[this.linkEvent(\'onModeChange\')]}" name="{stg_field}" value="radiogroup" ' +
  1526. '<tpl if="stg_mode == &quot;radiogroup&quot;"> checked="checked"</tpl>' +
  1527. ' /> 单选框' +
  1528. '</label>' +
  1529. '<label class="radio-inline">' +
  1530. '<input type="radio" id="{[this.linkEvent(\'onModeChange\')]}" name="{stg_field}" value="combobox" ' +
  1531. '<tpl if="stg_mode == &quot;combobox&quot;"> checked="checked"</tpl>' +
  1532. ' /> 下拉框' +
  1533. '</label>' +
  1534. '</div>' +
  1535. '</div>' +
  1536. '</tpl>' +
  1537. '<tpl if="stg_mode">' +
  1538. '<div class="mode-items" data-bind="{stg_field}">' +
  1539. '<a class="x-btn btn-default" id="{[this.linkEvent(\'onModeItemAdd\')]}"><i class="x-btn-icon-el icon-add"></i><span class="x-btn-text">添加属性</span></a>' +
  1540. '<tpl for="modeItems">' +
  1541. '<div class="mode-item">' +
  1542. '<input type="text" id="{[this.linkEvent(\'onModeItemFocus\')]}" name="display" value="{display}" placeholder="显示属性" />' +
  1543. '<input type="text" id="{[this.linkEvent(\'onModeItemFocus\')]}" name="value" value="{value}" placeholder="实际属性" />' +
  1544. '<input type="button" id="{[this.linkEvent(\'onModeItemDel\')]}" data-index="{[xindex]}" value="&times;" title="删除"/>' +
  1545. '</div>' +
  1546. '</tpl>' +
  1547. '</div>' +
  1548. '</tpl>',
  1549. {
  1550. formatFormula: function(formula) {
  1551. var units = formula._split(/[\+\-\*\/%,\(\)]/), text = '', scope = this;
  1552. Ext.Array.each(units, function(unit){
  1553. if(!isNumber(unit) && (unit.indexOf('.') > 0 || unit.indexOf('COL_') == 0))
  1554. text += scope.getDesc(unit);
  1555. else
  1556. text += unit;
  1557. });
  1558. return text;
  1559. },
  1560. onFormulaEdit: function(elm) {
  1561. var store = this.owner.view.store, grid = this.owner.grid;
  1562. Ext.EventManager.on(elm, {
  1563. click: function(event, el) {
  1564. var record = grid.store.findRecord('stg_field', el.getAttribute('data-bind'));
  1565. me.onFormulaClick(store, record.get('stg_formula'), function(formula){
  1566. record.set('stg_formula', formula);
  1567. });
  1568. Ext.EventManager.stopEvent(event);
  1569. },
  1570. buffer: 50
  1571. });
  1572. },
  1573. getDesc: function(unit) {
  1574. var table = null, field = unit;
  1575. if(unit.indexOf('.') > 0) {
  1576. table = unit.substring(0, unit.indexOf('.'));
  1577. field = unit.substr(unit.indexOf('.')+1);
  1578. }
  1579. var res = this.owner.view.store.queryBy(function(record){
  1580. return record.get('stg_table') == table && record.get('stg_field') == field;
  1581. }), item = res.first();
  1582. if(item)
  1583. return item.get('stg_text');
  1584. return '';
  1585. },
  1586. linkEvent: function(eventName) {
  1587. var result = Ext.id();
  1588. Ext.defer(this.addListener, 1, this, [result, eventName]);
  1589. return result;
  1590. },
  1591. addListener: function(id, eventName) {
  1592. var elm = Ext.get(id);
  1593. elm && this[eventName].call(this, elm);
  1594. },
  1595. onModeChange: function(elm) {
  1596. var grid = this.owner.grid;
  1597. Ext.EventManager.on(elm, {
  1598. change: function(event, el) {
  1599. var record = grid.store.findRecord('stg_field', el.name);
  1600. record.set('stg_mode', el.value);
  1601. if(el.value && el.value != '') {
  1602. var items = record.get('modeItems');
  1603. if(!items || items.length == 0) {
  1604. record.set('modeItems', [{display: null,value:null}]);
  1605. }
  1606. }
  1607. Ext.EventManager.stopEvent(event);
  1608. },
  1609. buffer: 100
  1610. });
  1611. },
  1612. getViewItems: function(el) {
  1613. var p = el.parentNode.parentNode;
  1614. if(p) {
  1615. var gps = Ext.query('.mode-item', el.parentNode.parentNode), items = [];
  1616. Ext.Array.each(gps, function(els){
  1617. var e = els.childNodes, d = e[0].value, v = e[1].value;
  1618. v = (!v || v == '') ? d : v;
  1619. v = (!d || d == '') ? null : v;
  1620. items.push({display: d, value: v});
  1621. });
  1622. return items;
  1623. }
  1624. return null;
  1625. },
  1626. onModeItemAdd: function(elm) {
  1627. var grid = this.owner.grid, me = this;
  1628. Ext.EventManager.on(elm, {
  1629. click: function(event, el) {
  1630. var p = el.parentNode.parentNode;
  1631. if(p) {
  1632. var field = p.getAttribute('data-bind'),
  1633. record = grid.store.findRecord('stg_field', field),
  1634. items = me.getViewItems(el) || [];
  1635. items.push({
  1636. display: null,
  1637. value: null
  1638. });
  1639. record.set('modeItems', items);
  1640. }
  1641. Ext.EventManager.stopEvent(event);
  1642. },
  1643. buffer: 50
  1644. });
  1645. },
  1646. onModeItemDel: function(elm) {
  1647. var grid = this.owner.grid;
  1648. Ext.EventManager.on(elm, {
  1649. click: function(event, el) {
  1650. var p = el.parentNode.parentNode;
  1651. if(p) {
  1652. var field = p.getAttribute('data-bind'),
  1653. record = grid.store.findRecord('stg_field', field),
  1654. items = record.get('modeItems'), idx = Number(el.getAttribute('data-index')) - 1;
  1655. items.splice(idx, 1);
  1656. Ext.get(el.parentNode).remove();
  1657. record.set('modeItems', items);
  1658. }
  1659. Ext.EventManager.stopEvent(event);
  1660. }
  1661. });
  1662. },
  1663. onModeItemFocus: function(elm) {
  1664. var me = this;
  1665. Ext.EventManager.on(elm, {
  1666. mousedown: function(event, el) {
  1667. el.focus();
  1668. Ext.EventManager.stopEvent(event);
  1669. },
  1670. buffer: 100
  1671. });
  1672. Ext.EventManager.on(elm, {
  1673. blur: function(event, el) {
  1674. if(el.name == 'display') {
  1675. var nextEl = el.nextSibling;
  1676. if(Ext.isEmpty(el.value) || el.value == '') {
  1677. nextEl.value = null;
  1678. } else {
  1679. if(Ext.isEmpty(nextEl.value) || nextEl.value == '') {
  1680. nextEl.value = el.value;
  1681. }
  1682. }
  1683. }
  1684. },
  1685. change: function(event, el) {
  1686. var items = me.getViewItems(el);
  1687. if (items) {
  1688. var field = el.parentNode.parentNode.getAttribute('data-bind'),
  1689. grid = me.owner.grid,
  1690. record = grid.store.findRecord('stg_field', field);
  1691. record.set('modeItems', items);
  1692. }
  1693. },
  1694. buffer: 10
  1695. });
  1696. },
  1697. onLinkChange: function(elm) {
  1698. var grid = this.owner.grid;
  1699. Ext.EventManager.on(elm, {
  1700. change: function(event, el) {
  1701. var record = grid.store.findRecord('stg_field', el.getAttribute('data-bind')),
  1702. links = record.get('links'), dl = links[el.value - 1];
  1703. record.set('stg_link', dl.dl_link);
  1704. record.set('stg_tokentab1', dl.dl_tokentab1);
  1705. record.set('stg_tokencol1', dl.dl_tokencol1);
  1706. record.set('stg_tokentab2', dl.dl_tokentab1);
  1707. record.set('stg_tokencol2', dl.dl_tokencol2);
  1708. Ext.EventManager.stopEvent(event);
  1709. },
  1710. buffer: 100
  1711. });
  1712. }
  1713. }]
  1714. }],
  1715. store: new Ext.data.Store({
  1716. model: erp.model.SearchTemplate
  1717. }),
  1718. columns: [{
  1719. text: '列',
  1720. flex: 1,
  1721. columns: [{
  1722. text: '名称',
  1723. dataIndex: 'stg_text',
  1724. width: 180,
  1725. editor: {
  1726. xtype: 'textfield'
  1727. },
  1728. sortable: false,
  1729. renderer: function(val, meta, record){
  1730. var a = record.get('stg_table'), b = record.get('stg_field'),
  1731. c = record.get('stg_formula'), text = '';
  1732. a && (text += '表:' + a);
  1733. b && (text += ' 字段:' + b);
  1734. c && (text += ' 公式:' + c);
  1735. return '<span title="' + text + '">' + val + '</span>';
  1736. }
  1737. },{
  1738. text: '是否<br>显示',
  1739. xtype: 'checkcolumn',
  1740. dataIndex: 'stg_use',
  1741. align: 'center',
  1742. headerCheckable: false,
  1743. width: 45,
  1744. sortable: false
  1745. },{
  1746. text: '宽度',
  1747. xtype: 'numbercolumn',
  1748. dataIndex: 'stg_width',
  1749. align: 'center',
  1750. width: 50,
  1751. format: '0,00',
  1752. editor: {
  1753. xtype: 'numberfield',
  1754. hideTrigger: true
  1755. },
  1756. sortable: false
  1757. },{
  1758. text: '格式转换',
  1759. dataIndex: 'stg_format',
  1760. align: 'center',
  1761. width: 90,
  1762. editor: {
  1763. xtype: 'combo',
  1764. store: formatStore,
  1765. displayField: 'display',
  1766. valueField: 'value',
  1767. queryMode: 'local'
  1768. },
  1769. sortable: false
  1770. }],
  1771. sortable: false
  1772. },{
  1773. text: '查询',
  1774. columns: [{
  1775. text: '用于<br>查询',
  1776. xtype: 'checkcolumn',
  1777. dataIndex: 'stg_query',
  1778. align: 'center',
  1779. width: 45,
  1780. sortable: false
  1781. },{
  1782. text: '多输<br>入框',
  1783. dataIndex: 'stg_double',
  1784. xtype: 'checkcolumn',
  1785. align: 'center',
  1786. width: 45,
  1787. sortable: false
  1788. },{
  1789. text: '带放<br>大镜',
  1790. dataIndex: 'stg_dbfind',
  1791. xtype: 'checkcolumn',
  1792. align: 'center',
  1793. width: 45,
  1794. sortable: false
  1795. },{
  1796. text: '默认值',
  1797. dataIndex: 'stg_value',
  1798. align: 'center',
  1799. flex: 1,
  1800. sortable: false,
  1801. editor: {
  1802. xtype: 'textfield'
  1803. }
  1804. }],
  1805. sortable: false
  1806. },{
  1807. text: '锁列',
  1808. dataIndex: 'stg_lock',
  1809. xtype: 'checkcolumn',
  1810. width: 40,
  1811. sortable: false
  1812. },{
  1813. text: '分组',
  1814. dataIndex: 'stg_group',
  1815. xtype: 'checkcolumn',
  1816. singleChecked: true,
  1817. width: 40,
  1818. sortable: false
  1819. },{
  1820. text: '合计',
  1821. dataIndex: 'stg_sum',
  1822. xtype: 'checkcolumn',
  1823. width: 40,
  1824. sortable: false
  1825. }]
  1826. });
  1827. },
  1828. getLimitForm: function(combo) {
  1829. return Ext.create('Ext.form.Panel', {
  1830. title: '选择字段,建立约束关系',
  1831. bodyStyle : 'background:#f1f2f5;padding:5px 5px 0',
  1832. items: [{
  1833. xtype:'fieldset',
  1834. title: '客户分配',
  1835. padding: '0 5 10 10',
  1836. name: '_L',
  1837. checkboxToggle: true,
  1838. collapsible: true,
  1839. collapsed: true,
  1840. defaultType: 'combobox',
  1841. defaults: {columnWidth: .5, margin: '3 10 0 0', labelWidth: 80, editable: false},
  1842. layout: 'column',
  1843. items :[Ext.Object.merge({
  1844. fieldLabel: '客户编号',
  1845. name: '_L_CU_1'
  1846. }, combo), {
  1847. xtype: 'displayfield',
  1848. value: '调取分配给你的客户的所有数据'
  1849. }, Ext.Object.merge({
  1850. fieldLabel: '业务员编号',
  1851. name: '_L_CU_2'
  1852. }, combo), {
  1853. xtype: 'displayfield',
  1854. value: '调取业务员是你的所有数据'
  1855. }],
  1856. getValue: function() {
  1857. var a = this.down('combo[name=_L_CU_1]').getValue(),
  1858. b = this.down('combo[name=_L_CU_2]').getValue();
  1859. return a ? 'CU(' + a + (b ? (',' + b) : '') + ')' : null;
  1860. }
  1861. }, {
  1862. xtype:'fieldset',
  1863. title: '供应商分配',
  1864. padding: '0 5 10 10',
  1865. name: '_L',
  1866. checkboxToggle: true,
  1867. collapsible: true,
  1868. collapsed: true,
  1869. defaultType: 'combobox',
  1870. defaults: {columnWidth: .5, margin: '3 10 0 0', labelWidth: 80, editable: false},
  1871. layout: 'column',
  1872. items :[Ext.Object.merge({
  1873. fieldLabel: '供应商编号',
  1874. name: '_L_VE_1'
  1875. }, combo), {
  1876. xtype: 'displayfield',
  1877. value: '调取分配给你的供应商的所有数据'
  1878. }, Ext.Object.merge({
  1879. fieldLabel: '采购员编号',
  1880. name: '_L_VE_2'
  1881. }, combo), {
  1882. xtype: 'displayfield',
  1883. value: '调取采购员是你的所有数据'
  1884. }],
  1885. getValue: function() {
  1886. var a = this.down('combo[name=_L_VE_1]').getValue(),
  1887. b = this.down('combo[name=_L_VE_2]').getValue();
  1888. return a && b ? 'VE(' + a + (b ? (',' + b) : '') + ')' : null;
  1889. }
  1890. }, {
  1891. xtype:'fieldset',
  1892. title: '个人',
  1893. padding: '0 5 10 10',
  1894. name: '_L',
  1895. checkboxToggle: true,
  1896. collapsible: true,
  1897. collapsed: true,
  1898. defaultType: 'combobox',
  1899. defaults: {columnWidth: .5, margin: '3 10 0 0', labelWidth: 80, editable: false},
  1900. layout: 'column',
  1901. items :[Ext.Object.merge({
  1902. fieldLabel: '个人编号',
  1903. name: '_L_EM_1'
  1904. }, combo)],
  1905. getValue: function() {
  1906. var a = this.down('combo[name=_L_EM_1]').getValue();
  1907. return a ? 'EM(' + a + ')' : null;
  1908. }
  1909. }]
  1910. });
  1911. },
  1912. /**
  1913. * 权限约束设置
  1914. */
  1915. onLimitClick: function(source, oldLimits, callback) {
  1916. var me = this, win = me.limitwin, datas = [{display: '(无)', value: null}];
  1917. source.each(function(item){
  1918. if(item.get('stg_type').indexOf('VARCHAR2') == 0) {
  1919. datas.push({
  1920. display: item.get('stg_text'),
  1921. value: item.get('stg_table') + '.' + item.get('stg_field')
  1922. });
  1923. }
  1924. });
  1925. var combo = me.newComboConfig(datas);
  1926. if (!win) {
  1927. win = me.limitwin = Ext.create('Ext.window.Window', {
  1928. title : '权限约束设置',
  1929. closeAction : 'hide',
  1930. width : 500,
  1931. items : [me.getLimitForm(combo)],
  1932. buttonAlign : 'center',
  1933. buttons : [{
  1934. text : $I18N.common.button.erpConfirmButton,
  1935. height : 26,
  1936. handler : function(b) {
  1937. var w = b.ownerCt.ownerCt,
  1938. fs = w.down('form').down('fieldset[collapsed=false]'),
  1939. value = fs ? fs.getValue() : null;
  1940. callback && callback.call(me, value);
  1941. w.hide();
  1942. }
  1943. }, {
  1944. text : $I18N.common.button.erpCloseButton,
  1945. height : 26,
  1946. handler : function(b) {
  1947. b.ownerCt.ownerCt.hide();
  1948. }
  1949. }]
  1950. });
  1951. } else {
  1952. var coms = win.down('form').query('combobox');
  1953. Ext.Array.each(coms, function(com){
  1954. com.getStore().loadData(datas);
  1955. });
  1956. }
  1957. win.show();
  1958. var form = win.down('form');
  1959. if(oldLimits) {
  1960. if(oldLimits.indexOf('CU') == 0) {// 客户分配
  1961. var col1 = null, col2 = null;
  1962. if(oldLimits.indexOf(",") > -1) {
  1963. col1 = oldLimits.substring(3, oldLimits.indexOf(','));
  1964. col2 = oldLimits.substring(oldLimits.indexOf(',') + 1, oldLimits.lastIndexOf(')'));
  1965. } else {
  1966. col1 = oldLimits.substring(3, oldLimits.indexOf(')'));
  1967. }
  1968. form.down('combobox[name=_L_CU_1]').setValue(col1);
  1969. form.down('combobox[name=_L_CU_2]').setValue(col2);
  1970. form.down('combobox[name=_L_CU_1]').ownerCt.setExpanded(true);
  1971. } else if(oldLimits.indexOf('VE') == 0) {// 供应商分配
  1972. var col1 = null, col2 = null;
  1973. if(oldLimits.indexOf(",") > -1) {
  1974. col1 = oldLimits.substring(3, oldLimits.indexOf(','));
  1975. col2 = oldLimits.substring(oldLimits.indexOf(',') + 1, oldLimits.lastIndexOf(')'));
  1976. } else {
  1977. col1 = oldLimits.substring(3, oldLimits.indexOf(')'));
  1978. }
  1979. form.down('combobox[name=_L_VE_1]').setValue(col1);
  1980. form.down('combobox[name=_L_VE_2]').setValue(col2);
  1981. form.down('combobox[name=_L_VE_1]').ownerCt.setExpanded(true);
  1982. } else if(oldLimits.indexOf('EM') == 0) {// 个人
  1983. var col1 = oldLimits.substring(3, oldLimits.lastIndexOf(')'));
  1984. form.down('combobox[name=_L_EM_1]').setValue(col1);
  1985. form.down('combobox[name=_L_EM_1]').ownerCt.setExpanded(true);
  1986. }
  1987. } else {
  1988. var fs = form.down('fieldset[collapsed=false]');
  1989. fs && fs.setExpanded(false);
  1990. }
  1991. },
  1992. /**
  1993. * 公式设置用到的函数
  1994. */
  1995. formula: function() {
  1996. var me = this;
  1997. me.formula_operator = [];
  1998. return {
  1999. log: function(oper, text, data, isfn) {
  2000. me.formula_operator.push({oper: oper, text: text, data: data, isfn: isfn});
  2001. },
  2002. getContainer: function(scope) {
  2003. return scope.up('form').down('fieldcontainer[cls~=x-screen]');
  2004. },
  2005. add: function(scope) {
  2006. var f = this.getContainer(scope);
  2007. f.add({text: scope.text, data: scope.data, isfn: scope.isfn});
  2008. if(scope.isfn) {
  2009. f.add({text: '('});
  2010. this.log(1, scope.text, null, true);
  2011. this.log(2, '(');
  2012. } else {
  2013. this.log(1, scope.text, scope.data);
  2014. }
  2015. },
  2016. del: function(scope) {
  2017. var f = this.getContainer(scope), l = f.down('button:last');
  2018. if (l) {
  2019. f.remove(l);
  2020. this.log(0, l.text, l.data, l.isfn);
  2021. }
  2022. },
  2023. back: function(scope) {
  2024. var f = this.getContainer(scope), len = me.formula_operator.length;
  2025. if(len > 0) {
  2026. var i = len - 1, o = me.formula_operator[i], oper = o.oper;
  2027. switch(oper) {
  2028. case 0:
  2029. f.add({text: o.text, data: o.data, isfn: o.isfn});
  2030. break;
  2031. case 1:
  2032. var b = f.down('button:last');
  2033. if(b && b.text == o.text)
  2034. f.remove(b);
  2035. break;
  2036. case 2:
  2037. var b = f.down('button:last');
  2038. if(b && b.text == o.text) {
  2039. f.remove(b);
  2040. f.remove(f.down('button:last'));
  2041. }
  2042. break;
  2043. case 3:
  2044. var j = 0;
  2045. for(;i > 0;i-- ) {
  2046. if(me.formula_operator[i].oper == 3) {
  2047. j = i;
  2048. } else {
  2049. break;
  2050. }
  2051. }
  2052. for(;j < len;j++ ) {
  2053. o = me.formula_operator[j];
  2054. f.add({text: o.text, data: o.data, isfn: o.isfn});
  2055. }
  2056. i++;
  2057. break;
  2058. }
  2059. me.formula_operator.splice(i);
  2060. }
  2061. },
  2062. clear: function(scope) {
  2063. var m = this, f = m.getContainer(scope), btns = f.query('button');
  2064. f.removeAll();
  2065. Ext.Array.each(btns, function(b){
  2066. m.log(3, b.text, b.data, b.isfn);
  2067. });
  2068. },
  2069. reset: function(scope, source, oldData) {
  2070. var f = this.getContainer(scope);
  2071. if(me.formula_operator.length > 0) {
  2072. f.removeAll();
  2073. f.add(f.initItems);
  2074. }
  2075. me.formula_operator = [];
  2076. }
  2077. };
  2078. },
  2079. getFormulaForm: function(source, oldData) {
  2080. var defItems = [], defBtns = "789/%456*(123-)0.+".split(""),
  2081. colItems = [], me = this, formula = me.formula();
  2082. defItems.push({
  2083. text: '←',
  2084. tooltip: '删除',
  2085. handler: function(btn) {
  2086. formula.del(btn);
  2087. }
  2088. });
  2089. defItems.push({
  2090. text: '→',
  2091. tooltip: '回退',
  2092. handler: function(btn) {
  2093. formula.back(btn);
  2094. }
  2095. });
  2096. defItems.push({text: ','});
  2097. defItems.push({
  2098. text: 'RE',
  2099. tooltip: '重置',
  2100. handler: function(btn) {
  2101. formula.reset(btn);
  2102. }
  2103. });
  2104. defItems.push({
  2105. text: 'CE',
  2106. tooltip: '清除',
  2107. handler: function(btn) {
  2108. formula.clear(btn);
  2109. }
  2110. });
  2111. Ext.Array.each(defBtns, function(b){
  2112. var o = {text: b};
  2113. if(b == '0')
  2114. o.columnWidth = .4;
  2115. defItems.push(o);
  2116. });
  2117. defItems.push({text: 'abs', isfn: true, tooltip: 'abs(x),返回x的绝对值'});
  2118. defItems.push({
  2119. text: 'round',
  2120. isfn: true,
  2121. columnWidth: .4,
  2122. tooltip: 'round(x,y),返回四舍五入到小数点右边y位的x值'
  2123. });
  2124. defItems.push({
  2125. text: 'floor',
  2126. isfn: true,
  2127. columnWidth: .4,
  2128. tooltip: 'floor(x)函数,返回小于或等于x的最大整数'
  2129. });
  2130. defItems.push({text: 'ceil', isfn: true, tooltip: 'ceil(x),返回大于或等于x的最小整数'});
  2131. source.each(function(item){
  2132. if(item.get('stg_type').indexOf('NUMBER') == 0 && item.get('stg_table')) {
  2133. colItems.push({
  2134. text: item.get('stg_text'),
  2135. data: item.data
  2136. });
  2137. }
  2138. });
  2139. var form = Ext.create('Ext.form.Panel', {
  2140. bodyStyle : 'background:#f1f2f5;padding:5px',
  2141. layout: 'vbox',
  2142. items: [{
  2143. xtype: 'fieldcontainer',
  2144. margin: '0 3 8 3',
  2145. width: '100%',
  2146. minHeight: 50,
  2147. cls: 'x-form-text x-screen',
  2148. defaultType: 'button',
  2149. defaults: {
  2150. margin: '0 0 3 0',
  2151. cls: 'x-btn-clear'
  2152. }
  2153. },{
  2154. xtype: 'container',
  2155. layout: 'hbox',
  2156. width: '100%',
  2157. defaultType: 'fieldcontainer',
  2158. defaults: {flex: 1},
  2159. items: [{
  2160. layout: 'column',
  2161. defaultType: 'button',
  2162. defaults: {
  2163. columnWidth: .2,
  2164. height: 30,
  2165. margin: '3 3 3 3'
  2166. },
  2167. items: defItems
  2168. },{
  2169. layout: 'column',
  2170. defaultType: 'button',
  2171. defaults: {
  2172. columnWidth: .5,
  2173. height: 30,
  2174. margin: '3 3 3 3'
  2175. },
  2176. items: colItems
  2177. }]
  2178. }]
  2179. });
  2180. var btns = form.query('button');
  2181. Ext.Array.each(btns, function(btn){
  2182. if(!btn.handler) {
  2183. btn.handler = function() {
  2184. formula.add(btn);
  2185. };
  2186. }
  2187. });
  2188. if(oldData) {
  2189. var container = form.down('fieldcontainer[cls~=x-screen]'),
  2190. items = me.getItemsFromFormula(source, oldData);
  2191. container.initItems = items;
  2192. container.add(items);
  2193. }
  2194. return form;
  2195. },
  2196. /**
  2197. * 解析表达式
  2198. */
  2199. getItemsFromFormula: function(source, oldData) {
  2200. var sign = /[\+\-\*\/%,\(\)]/, units = oldData._split(sign), items = [],
  2201. fns = ['abs', 'ceil', 'floor', 'round'];
  2202. Ext.Array.each(units, function(unit){
  2203. if(isNumber(unit)) {
  2204. Ext.Array.each(unit.split(""), function(u){
  2205. items.push({text: u});
  2206. });
  2207. } else if(fns.indexOf(unit) > -1){
  2208. items.push({
  2209. text: unit,
  2210. isfn: true
  2211. });
  2212. } else if(sign.test(unit)) {
  2213. items.push({text: unit});
  2214. } else {
  2215. var table = null, field = unit;
  2216. if(unit.indexOf('.') > 0) {
  2217. table = unit.substring(0, unit.indexOf('.'));
  2218. field = unit.substr(unit.indexOf('.')+1);
  2219. }
  2220. var res = source.queryBy(function(record){
  2221. return record.get('stg_table') == table && record.get('stg_field') == field;
  2222. }), item = res.first();
  2223. if(item)
  2224. unit = item.get('stg_text');
  2225. items.push({
  2226. text: unit,
  2227. data: {stg_table: table, stg_field: field}
  2228. });
  2229. }
  2230. });
  2231. return items;
  2232. },
  2233. /**
  2234. * 自定义公式
  2235. */
  2236. onFormulaClick: function(source, oldData, callback) {
  2237. var me = this;
  2238. var win = Ext.create('Ext.window.Window', {
  2239. title : '自定义公式',
  2240. closeAction: 'destroy',
  2241. width : 500,
  2242. items : [me.getFormulaForm(source, oldData)],
  2243. buttonAlign : 'center',
  2244. buttons : [{
  2245. text : $I18N.common.button.erpConfirmButton,
  2246. height : 26,
  2247. handler : function(b) {
  2248. var w = b.ownerCt.ownerCt,
  2249. items = w.query('fieldcontainer[cls~=x-screen] > button'),
  2250. text = '', test = '', d = 0.123;
  2251. Ext.Array.each(items, function(item){
  2252. if(item.data) {
  2253. text += item.data.stg_table + '.' + item.data.stg_field;
  2254. d = Math.pow(d, 2);
  2255. test += d;
  2256. } else {
  2257. text += item.text;
  2258. test += item.text;
  2259. }
  2260. });
  2261. try {
  2262. Ext.Test.eval(test);
  2263. callback && callback.call(me, text);
  2264. w.close();
  2265. } catch(e) {
  2266. Ext.example.msg('error', '错误', '您的公式有误,请检查并修改正确' +
  2267. '<p><strong>' +e + '</strong></p>', 5000);
  2268. }
  2269. }
  2270. }, {
  2271. text : $I18N.common.button.erpCloseButton,
  2272. height : 26,
  2273. handler : function(b) {
  2274. var w = b.ownerCt.ownerCt;
  2275. w.close();
  2276. }
  2277. }]
  2278. });
  2279. win.show();
  2280. },
  2281. /**
  2282. * 生成form的字段<br>
  2283. * 勾选、单选框
  2284. */
  2285. createFormItems: function(source, oldData) {
  2286. var fields = [];
  2287. if(source) {
  2288. if(Ext.isArray(source)) {
  2289. Ext.Array.each(source, function(i){
  2290. if(i.stg_use == 1) {
  2291. var obj = {boxLabel : i.stg_text, inputValue : i.stg_field, table: i.stg_table};
  2292. if(oldData && Ext.Array.indexOf(oldData, i.stg_field) > -1)
  2293. obj.checked = true;
  2294. fields.push(obj);
  2295. }
  2296. });
  2297. } else {
  2298. source.each(function(i){
  2299. if(i.get('stg_use') == 1) {
  2300. var obj = {boxLabel : i.get('stg_text'), inputValue : i.get('stg_field'), table: i.get('stg_table')};
  2301. if(oldData && Ext.Array.indexOf(oldData, i.get('stg_field')) > -1)
  2302. obj.checked = true;
  2303. fields.push(obj);
  2304. }
  2305. });
  2306. }
  2307. } else {
  2308. var grid = this.getGrid().getView().normalGrid, columns = grid.headerCt.getGridColumns();
  2309. Ext.each(columns, function(){
  2310. if(!this.hidden && this.getWidth() > 0 && this.dataIndex) {
  2311. var obj = {boxLabel : this.text, inputValue : this.dataField, table: this.dataTable};
  2312. if(oldData && Ext.Array.indexOf(oldData, this.dataIndex) > -1)
  2313. obj.checked = true;
  2314. fields.push(obj);
  2315. }
  2316. });
  2317. }
  2318. return fields;
  2319. },
  2320. /**
  2321. * 生成form的字段<br>
  2322. * 勾选、单选框<br>使用别名
  2323. */
  2324. createAliaItems: function(oldData) {
  2325. var fields = [];
  2326. var grid = this.getGrid().getView().normalGrid, columns = grid.headerCt.getGridColumns();
  2327. Ext.each(columns, function(){
  2328. if(!this.hidden && this.getWidth() > 0 && this.dataIndex) {
  2329. var obj = {boxLabel : this.text, inputValue : this.dataIndex};
  2330. if(oldData && Ext.Array.indexOf(oldData, this.dataIndex) > -1)
  2331. obj.checked = true;
  2332. fields.push(obj);
  2333. }
  2334. });
  2335. return fields;
  2336. },
  2337. /**
  2338. *
  2339. */
  2340. getAliaForm : function(type, itemId, oldData) {
  2341. var me = this;
  2342. return Ext.create('Ext.form.Panel', {
  2343. itemId : itemId,
  2344. autoScroll : true,
  2345. layout : 'column',
  2346. bodyStyle : 'background:#f1f2f5;',
  2347. defaults : {
  2348. xtype : type || 'radio',
  2349. name : 'gridfield',
  2350. columnWidth : .33,
  2351. margin : '3 3 3 10'
  2352. },
  2353. items : me.createAliaItems(oldData)
  2354. });
  2355. },
  2356. getGridForm : function(type, itemId, source, oldData) {
  2357. var me = this;
  2358. return Ext.create('Ext.form.Panel', {
  2359. itemId : itemId,
  2360. autoScroll : true,
  2361. layout : 'column',
  2362. bodyStyle : 'background:#f1f2f5;',
  2363. defaults : {
  2364. xtype : type || 'radio',
  2365. name : 'gridfield',
  2366. columnWidth : .33,
  2367. margin : '3 3 3 10'
  2368. },
  2369. items : me.createFormItems(source, oldData)
  2370. });
  2371. },
  2372. toogleGroup : function(f, b) {
  2373. if (!f) return;
  2374. var dx = null;
  2375. if (typeof f === 'string') {
  2376. dx = f;
  2377. } else {
  2378. var r = f.down('radio[value=true]');
  2379. if (r) {
  2380. dx = r.inputValue;
  2381. }
  2382. }
  2383. if (dx) {
  2384. var grid = this.getGrid(), c = grid.down('gridcolumn[dataIndex=' + dx + ']');
  2385. if(b) {
  2386. if(grid.store.groupField) {
  2387. var m = grid.down('gridcolumn[dataIndex=' + grid.store.groupField + ']');
  2388. if(m) {
  2389. m.summaryType = m.lastSummaryType;
  2390. m.summaryRenderer = m.lastSummaryRenderer;
  2391. }
  2392. }
  2393. if(typeof c.lastSummaryType === 'undefined') {
  2394. c.lastSummaryType = c.summaryType;
  2395. }
  2396. if(typeof c.lastSummaryRenderer === 'undefined') {
  2397. c.lastSummaryRenderer = c.summaryRenderer;
  2398. }
  2399. c.summaryType = 'count';
  2400. c.summaryRenderer = function(v) {
  2401. return '共(' + v + ')条';
  2402. };
  2403. grid.store.groupField = dx;
  2404. grid.store.group(dx, 'ASC');
  2405. } else {
  2406. c.summaryType = c.lastSummaryType;
  2407. c.summaryRenderer = c.lastSummaryRenderer;
  2408. var view = grid.lockedGrid.getView(), fe = view.getFeature('group');
  2409. if(fe) {
  2410. fe.disable();
  2411. view.refresh();
  2412. }
  2413. view = grid.normalGrid.getView(), fe = view.getFeature('group');
  2414. if(fe) {
  2415. fe.disable();
  2416. view.refresh();
  2417. }
  2418. var r = f.down('radio[value=true]');
  2419. if (r) {
  2420. r.setValue(false);
  2421. }
  2422. grid.store.groupField = null;
  2423. }
  2424. }
  2425. },
  2426. /**
  2427. * 锁定列
  2428. */
  2429. onLock : function(form) {
  2430. var r = form.query('checkbox[value=true]');
  2431. var grid = this.getGrid(), normal = grid.getView().normalGrid;
  2432. Ext.Array.each(r, function(){
  2433. var column = normal.down('gridcolumn[dataIndex=' + this.inputValue + ']');
  2434. if (column.locked) {
  2435. grid.unlock(column);
  2436. } else {
  2437. grid.lock(column);
  2438. }
  2439. });
  2440. },
  2441. /**
  2442. * 取出排序设置
  2443. */
  2444. getSortProperties : function(form, store) {
  2445. var r = form.query('checkbox[value=true]'), prop = [];
  2446. Ext.Array.each(r, function(c, i){
  2447. var obj = {
  2448. property: c.inputValue,
  2449. direction: 'ASC',
  2450. description: c.boxLabel,
  2451. number: i + 1,
  2452. table: c.table
  2453. };
  2454. if (store) {
  2455. var item = store.findRecord('property', c.inputValue);
  2456. if (item) {
  2457. obj.direction = item.get('direction');
  2458. }
  2459. }
  2460. prop.push(obj);
  2461. });
  2462. return prop;
  2463. },
  2464. /**
  2465. * 后台排序
  2466. */
  2467. onSort : function(sorts) {
  2468. // var grid = this.getGrid().getView().normalGrid;
  2469. // grid.store.sort(this.getSortProperties(form));
  2470. },
  2471. /**
  2472. * 清除排序、分组等
  2473. */
  2474. onClear : function() {
  2475. var grid = this.getGrid().getView().normalGrid;
  2476. grid.store.clearGrouping();
  2477. grid.store.clearFilter();
  2478. },
  2479. onTempLoad : function(fn) {
  2480. Ext.Ajax.request({
  2481. url: basePath + 'ma/search/temp/g.action',
  2482. params: {
  2483. caller: caller
  2484. },
  2485. callback: function(opt, s, res) {
  2486. var r = Ext.decode(res.responseText);
  2487. if(r.success && r.data) {
  2488. fn.call(null, r.data, r.lastId);
  2489. } else if(r.exceptionInfo) {
  2490. Ext.example.msg('error', '错误', r.exceptionInfo, 5000);
  2491. }
  2492. }
  2493. });
  2494. },
  2495. addTemp : function(title, fn) {
  2496. var me = this;
  2497. var t = title || (me.BaseUtil.getActiveTab().title + '(' + em_name + ')' + Ext.Date.format(new Date(),'Y-m-d'));
  2498. var w = Ext.create('Ext.window.Window', {
  2499. width: 300,
  2500. height: 97,
  2501. title: '为方案命名',
  2502. layout: 'anchor',
  2503. items: [{
  2504. xtype: 'textfield',
  2505. allowBlank: false,
  2506. anchor: '100% 100%',
  2507. value: t
  2508. }],
  2509. buttonAlign: 'center',
  2510. buttons: [{
  2511. text : $I18N.common.button.erpConfirmButton,
  2512. height : 26,
  2513. handler : function(b) {
  2514. var w = b.ownerCt.ownerCt, f = w.down('textfield');
  2515. if(!Ext.isEmpty(f.getValue())) {
  2516. if(fn) {
  2517. fn.call(me, f.getValue());
  2518. } else {
  2519. var g = me.querywin.down('grid');
  2520. var r = g.store.add({st_id: 0, st_date: new Date().getTime(), st_man: em_name, st_title: f.getValue(), st_caller: caller});
  2521. if(r.length > 0) {
  2522. g.selModel.select(r[0]);
  2523. me.onTempSet(r[0], [], 0);
  2524. }
  2525. }
  2526. }
  2527. w.close();
  2528. }
  2529. }, {
  2530. text : $I18N.common.button.erpCloseButton,
  2531. height : 26,
  2532. handler : function(b) {
  2533. b.ownerCt.ownerCt.hide();
  2534. }
  2535. }]
  2536. });
  2537. w.show();
  2538. },
  2539. updateTemp : function(callback) {
  2540. var me = this, win = this.tempwin, g = win.down('#grid-setting'),
  2541. datas = new Array(), d, s = win.relativeId, i = 1,
  2542. c = g.down('#st_condition').getValue(),
  2543. sorts = g.sorts, limits = g.limits;
  2544. g.store.each(function(r){
  2545. d = r.data;
  2546. if(d.stg_use || d.stg_query || d.stg_group || d.stg_lock) {
  2547. d.stg_use = d.stg_use ? 1 : 0;
  2548. d.stg_query = d.stg_query ? 1 : 0;
  2549. d.stg_group = d.stg_group ? 1 : 0;
  2550. d.stg_lock = d.stg_lock ? 1 : 0;
  2551. d.stg_sum = d.stg_sum ? 1 : 0;
  2552. d.stg_double = d.stg_double ? 1 : 0;
  2553. d.stg_dbfind = d.stg_dbfind ? 1 : 0;
  2554. d.stg_stid = s;
  2555. d.stg_detno = i++;
  2556. delete d.text;
  2557. delete d.type;
  2558. delete d.links;
  2559. delete d.stg_alias;
  2560. if (d.modeItems) {
  2561. var validItems = [];
  2562. Ext.Array.each(d.modeItems, function(item, i){
  2563. if(item.display && item.display != '') {
  2564. item.num = validItems.length + 1;
  2565. item.st_id = s;
  2566. item.stg_field = d.stg_field;
  2567. item.value = (item.value == null || item.value == '') ?
  2568. item.display : item.value;
  2569. validItems.push(item);
  2570. }
  2571. });
  2572. d.modeItems = validItems;
  2573. }
  2574. datas.push(d);
  2575. }
  2576. });
  2577. var e = me.getRepeats(datas);
  2578. if(e) {
  2579. Ext.example.msg('error', '有重复选择的字段', e, 5000);
  2580. return;
  2581. }
  2582. if(s > 0) {
  2583. me.onTempUpdate(datas, c, sorts, limits, s, callback);
  2584. } else {
  2585. me.onTempSave(win.relativeRecord.get('st_title'), datas, c, sorts, limits, callback);
  2586. }
  2587. },
  2588. /**
  2589. * 判断是否有重复拖放过来的字段或重复的公式
  2590. */
  2591. getRepeats: function(datas) {
  2592. var p = {}, k = null, e = '';
  2593. Ext.Array.each(datas, function(d, i){
  2594. k = d.stg_table + '.' + d.stg_field;
  2595. if(d.stg_formula)
  2596. k = d.stg_formula;
  2597. if(p[k])
  2598. e += '行' + (i + 1) + '的' + d.stg_text;
  2599. else
  2600. p[k] = true;
  2601. });
  2602. if(e.length > 0)
  2603. return e;
  2604. return null;
  2605. },
  2606. copyTemp: function(title, sourceId) {
  2607. if(sourceId) {
  2608. this.onTempCopy(title, sourceId);
  2609. } else {
  2610. var me = this, win = this.tempwin, g = win.down('#grid-setting'),
  2611. datas = new Array(), d, i = 1,
  2612. c = g.down('#st_condition').getValue(), sorts = g.sorts, limits = g.limits;
  2613. g.store.each(function(r){
  2614. d = r.data;
  2615. if(d.stg_use || d.stg_query || d.stg_group || d.stg_lock) {
  2616. d.stg_use = d.stg_use ? 1 : 0;
  2617. d.stg_query = d.stg_query ? 1 : 0;
  2618. d.stg_group = d.stg_group ? 1 : 0;
  2619. d.stg_lock = d.stg_lock ? 1 : 0;
  2620. d.stg_sum = d.stg_sum ? 1 : 0;
  2621. d.stg_double = d.stg_double ? 1 : 0;
  2622. d.stg_dbfind = d.stg_dbfind ? 1 : 0;
  2623. d.stg_stid = 0;
  2624. d.stg_detno = i++;
  2625. delete d.text;
  2626. delete d.type;
  2627. delete d.links;
  2628. delete d.stg_alias;
  2629. if (d.modeItems) {
  2630. var validItems = [];
  2631. Ext.Array.each(d.modeItems, function(item, i){
  2632. if(item.display && item.display != '') {
  2633. item.num = validItems.length + 1;
  2634. item.stg_field = d.stg_field;
  2635. item.value = (item.value == null || item.value == '') ?
  2636. item.display : item.value;
  2637. validItems.push(item);
  2638. }
  2639. });
  2640. d.modeItems = validItems;
  2641. }
  2642. datas.push(d);
  2643. }
  2644. });
  2645. me.onTempSave(title, datas, c, sorts, limits);
  2646. }
  2647. },
  2648. onTempUpdate : function(datas, condition, sorts, limits, id, callback) {
  2649. var me = this;
  2650. Ext.Ajax.request({
  2651. url: basePath + 'ma/search/temp/u.action',
  2652. params: {
  2653. sId: id,
  2654. caller: caller,
  2655. datas: Ext.encode(datas),
  2656. condition: condition,
  2657. sorts: sorts,
  2658. limits: limits
  2659. },
  2660. callback: function(opt, s, res) {
  2661. var r = Ext.decode(res.responseText);
  2662. if(r.success) {
  2663. callback && callback.call(me);
  2664. Ext.example.msg('info', '提示', '方案修改成功', 2000);
  2665. me.onTempLoad(function(data){
  2666. var temp = me.querywin.down('gridpanel[id=temp]'),
  2667. grid = me.querywin.down('grid');
  2668. temp.store.loadData(data);
  2669. if(data.length > 0) {
  2670. var r = temp.store.findRecord('st_id', id) || temp.store.last();
  2671. temp.selModel.select(r);
  2672. grid.setTitle(r.get('st_title'));
  2673. }
  2674. });
  2675. } else if(r.exceptionInfo) {
  2676. Ext.example.msg('error', '失败', r.exceptionInfo, 5000);
  2677. }
  2678. }
  2679. });
  2680. },
  2681. onTempSave : function(title, datas, condition, sorts, limits, callback) {
  2682. var me = this;
  2683. Ext.Ajax.request({
  2684. url: basePath + 'ma/search/temp/s.action',
  2685. params: {
  2686. caller: caller,
  2687. title: title,
  2688. datas: Ext.encode(datas),
  2689. condition: condition,
  2690. sorts: sorts,
  2691. limits: limits
  2692. },
  2693. callback: function(opt, s, res) {
  2694. var r = Ext.decode(res.responseText);
  2695. if(r.success) {
  2696. callback && callback.call(me);
  2697. Ext.example.msg('info', '提示', '方案保存成功', 2000);
  2698. me.onTempLoad(function(data){
  2699. var temp = me.querywin.down('gridpanel[id=temp]'),
  2700. grid = me.querywin.down('grid');
  2701. temp.store.loadData(data);
  2702. if(data.length > 0) {
  2703. var r = temp.store.last();
  2704. temp.selModel.select(r);
  2705. grid.setTitle(r.get('st_title'));
  2706. }
  2707. });
  2708. } else if(r.exceptionInfo) {
  2709. Ext.example.msg('error', '失败', r.exceptionInfo, 5000);
  2710. }
  2711. }
  2712. });
  2713. },
  2714. onTempCopy : function(title, id) {
  2715. var me = this;
  2716. Ext.Ajax.request({
  2717. url: basePath + 'ma/search/temp/c.action',
  2718. params: {
  2719. title: title,
  2720. sId: id
  2721. },
  2722. callback: function(opt, s, res) {
  2723. var r = Ext.decode(res.responseText);
  2724. if(r.success) {
  2725. Ext.example.msg('info', '提示', '方案复制成功', 2000);
  2726. me.onTempLoad(function(data){
  2727. var temp = me.querywin.down('gridpanel[id=temp]'),
  2728. grid = me.querywin.down('grid');
  2729. temp.store.loadData(data);
  2730. if(data.length > 0) {
  2731. var r = temp.store.last();
  2732. temp.selModel.select(r);
  2733. grid.setTitle(r.get('st_title'));
  2734. }
  2735. });
  2736. } else if(r.exceptionInfo) {
  2737. Ext.example.msg('error', '失败', r.exceptionInfo, 5000);
  2738. }
  2739. }
  2740. });
  2741. },
  2742. onTempTitleChange: function(title, id, callback) {
  2743. var me = this;
  2744. Ext.Ajax.request({
  2745. url: basePath + 'ma/search/temp/t.action',
  2746. params: {
  2747. title: title,
  2748. sId: id
  2749. },
  2750. callback: function(opt, s, res) {
  2751. var r = Ext.decode(res.responseText);
  2752. if(r.success) {
  2753. Ext.example.msg('info', '提示', '修改成功', 2000);
  2754. callback && callback.call(me);
  2755. } else if(r.exceptionInfo) {
  2756. Ext.example.msg('error', '失败', r.exceptionInfo, 5000);
  2757. }
  2758. }
  2759. });
  2760. },
  2761. onTempDel : function(id, fn) {
  2762. if(id > 0) {
  2763. Ext.Ajax.request({
  2764. url: basePath + 'ma/search/temp/d.action',
  2765. params: {
  2766. caller: caller,
  2767. sId: id
  2768. },
  2769. callback: function(opt, s, res) {
  2770. var r = Ext.decode(res.responseText);
  2771. if(r.success) {
  2772. fn.call();
  2773. } else if(r.exceptionInfo) {
  2774. Ext.example.msg('error', '失败', r.exceptionInfo, 5000);
  2775. }
  2776. }
  2777. });
  2778. } else {
  2779. fn.call();
  2780. }
  2781. },
  2782. /**
  2783. * 记录选择方案
  2784. */
  2785. log : function() {
  2786. var grid = this.querywin.down('grid'), record = grid.selModel.lastSelected;
  2787. if (record) {
  2788. var id = record.get('st_id');
  2789. if(id && id > 0 ) {
  2790. Ext.Ajax.request({
  2791. url: basePath + 'ma/search/log.action',
  2792. params: {
  2793. caller: caller,
  2794. sId: id
  2795. },
  2796. callback: function(opt, s, res) {
  2797. var r = Ext.decode(res.responseText);
  2798. if(r.exceptionInfo) {
  2799. Ext.example.msg('error', '错误', r.exceptionInfo, 5000);
  2800. }
  2801. }
  2802. });
  2803. }
  2804. }
  2805. },
  2806. /**
  2807. * 数据字典
  2808. */
  2809. getDictionary: function(tableNames, callback) {
  2810. var me = this;
  2811. if(tableNames && tableNames != '') {
  2812. Ext.Ajax.request({
  2813. url: basePath + 'ma/getDataDictionaries.action',
  2814. params: {
  2815. tables: tableNames
  2816. },
  2817. callback: function(opt, s, res) {
  2818. var r = Ext.decode(res.responseText);
  2819. if(r.exceptionInfo) {
  2820. Ext.example.msg('error', '错误', r.exceptionInfo, 5000);
  2821. } else if(r.datas) {
  2822. callback.call(me, r.datas);
  2823. }
  2824. }
  2825. });
  2826. } else {
  2827. callback.call(me, []);
  2828. }
  2829. },
  2830. /**
  2831. * 重新加载数据
  2832. */
  2833. loadNewStore : function(grid, params) {
  2834. var me = this;
  2835. grid.setLoading(true);
  2836. Ext.Ajax.request({
  2837. url : basePath + "common/search.action",
  2838. params: params,
  2839. method : 'post',
  2840. callback : function(opt, s, res){
  2841. grid.setLoading(false);
  2842. var r = Ext.decode(res.responseText);
  2843. if(r.datas) {
  2844. grid.store.loadData(r.datas);
  2845. me.getDataCount().update({count: r.datas.length});
  2846. me.getDataCount().show();
  2847. }
  2848. }
  2849. });
  2850. },
  2851. /**
  2852. * 导出excel
  2853. */
  2854. exportExcel : function(grid, records, condition) {
  2855. var columns = grid.headerCt.getGridColumns(),
  2856. cm = new Array(), gf = grid.store.groupField;
  2857. Ext.Array.each(columns, function(c){
  2858. if(!c.hidden && (c.width > 0 || c.flex > 0) && !c.isCheckerHd) {
  2859. cm.push({
  2860. text: (Ext.isEmpty(c.text) ? ' ' : c.text.replace(/<br>/g, '\n')),
  2861. dataIndex: c.dataIndex,
  2862. width: c.width,
  2863. xtype: c.xtype,
  2864. format: c.format,
  2865. locked: c.locked,
  2866. summary: c.summaryType == 'sum',
  2867. group: c.dataIndex == gf
  2868. });
  2869. }
  2870. });
  2871. if (!Ext.fly('ext-grid-excel')) {
  2872. var frm = document.createElement('form');
  2873. frm.id = 'ext-grid-excel';
  2874. frm.name = frm.id;
  2875. frm.className = 'x-hidden';
  2876. document.body.appendChild(frm);
  2877. }
  2878. var record = records[0];
  2879. Ext.Ajax.request({
  2880. url: basePath + 'common/search/excel.xls',
  2881. method: 'post',
  2882. form: Ext.fly('ext-grid-excel'),
  2883. isUpload: true,
  2884. params: {
  2885. sId: record.get('st_id'),
  2886. condition: condition,
  2887. columns: unescape(Ext.encode(cm).replace(/\\/g,"%")),
  2888. sorts: record.get('st_sorts'),
  2889. title: record.get('st_title') + '----' + Ext.Date.format(new Date(), 'Y-m-d H:i:s')
  2890. }
  2891. });
  2892. },
  2893. /**
  2894. * 传入表名,获得表的关联sql
  2895. */
  2896. getTabSql: function(tables, callback) {
  2897. var me = this;
  2898. Ext.Ajax.request({
  2899. url: basePath + 'ma/search/relation.action',
  2900. method : 'post',
  2901. params: {
  2902. tables: tables
  2903. },
  2904. callback : function(opt, s, res){
  2905. var r = Ext.decode(res.responseText);
  2906. if(r.data) {
  2907. callback && callback.call(me, r.data);
  2908. } else {
  2909. Ext.example.msg('error', '错误', '您选择的数据字典 ' + tables +
  2910. ' 暂时还没有建立关联关系', 5000);
  2911. }
  2912. }
  2913. });
  2914. },
  2915. /**
  2916. * 行点击链接,打开单据界面
  2917. */
  2918. onLinkClick: function(link, title) {
  2919. var args = encodeURI(Ext.Array.toArray(arguments, 2).join('-')).replace(/%/g,'-');
  2920. var tabPanel = this.getTabPanel(),
  2921. panel = tabPanel.down('#' + args);
  2922. // 出入库单据、工单、等按类型来获取caller,统一类型标志class
  2923. // 用于jsp页面一致,caller不同的
  2924. if(link.indexOf('class=') > -1) {
  2925. link += '&whoami=' + this.getCaller(this.getUrlParam(link, 'class'));
  2926. }
  2927. if (!panel) {
  2928. panel = tabPanel.add({
  2929. id : args,
  2930. title : title,
  2931. tag : 'iframe',
  2932. border : false,
  2933. layout : 'fit',
  2934. iconCls : 'x-tree-icon-tab-tab1',
  2935. html : '<iframe src="' + link + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  2936. closable : true
  2937. });
  2938. }
  2939. tabPanel.setActiveTab(panel);
  2940. },
  2941. /**
  2942. * 主界面的tabPanel
  2943. */
  2944. getTabPanel: function() {
  2945. var main = parent.Ext.getCmp("content-panel");
  2946. if (!main) {
  2947. main = parent.parent.Ext.getCmp("content-panel");
  2948. }
  2949. return main;
  2950. },
  2951. /**
  2952. * URL里面解析出参数值
  2953. */
  2954. getUrlParam: function(url, param) {
  2955. var reg = new RegExp("(^|&)" + param + "=([^&]*)(&|$)"),
  2956. matchs = url.substr(url.indexOf('?') + 1).match(reg);
  2957. if (matchs)
  2958. return decodeURI(matchs[2]);
  2959. return null;
  2960. },
  2961. /**
  2962. * 按类型获取caller。用于出入库单等
  2963. */
  2964. getCaller: function(cls) {
  2965. var call = null;
  2966. switch (cls) {
  2967. case '采购验收单':
  2968. call = 'ProdInOut!PurcCheckin';
  2969. break;
  2970. case '采购验退单':
  2971. call = 'ProdInOut!PurcCheckout';
  2972. break;
  2973. case '出货单':
  2974. call = 'ProdInOut!Sale';
  2975. break;
  2976. case '拨入单':
  2977. call = 'ProdInOut!AppropriationIn';
  2978. break;
  2979. case '销售拨出单':
  2980. call = 'ProdInOut!SaleAppropriationOut';
  2981. break;
  2982. case '销售退货单':
  2983. call = 'ProdInOut!SaleReturn';
  2984. break;
  2985. case '拨出单':
  2986. call = 'ProdInOut!AppropriationOut';
  2987. break;
  2988. case '不良品入库单':
  2989. call = 'ProdInOut!DefectIn';
  2990. break;
  2991. case '不良品出库单':
  2992. call = 'ProdInOut!DefectOut';
  2993. break;
  2994. case '委外领料单':
  2995. call = 'ProdInOut!OutsidePicking';
  2996. break;
  2997. case '委外退料单':
  2998. call = 'ProdInOut!OutsideReturn';
  2999. break;
  3000. case '委外验收单':
  3001. call = 'ProdInOut!OutsideCheckIn';
  3002. break;
  3003. case '委外验退单':
  3004. call = 'ProdInOut!OutesideCheckReturn';
  3005. break;
  3006. case '借货归还单':
  3007. call = 'ProdInOut!OutReturn';
  3008. break;
  3009. case '研发采购验收单':
  3010. call = 'ProdInOut!PurcCheckin!PLM';
  3011. break;
  3012. case '研发采购验退单':
  3013. call = 'ProdInOut!PurcCheckout!PLM';
  3014. break;
  3015. case '换货入库单':
  3016. call = 'ProdInOut!ExchangeIn';
  3017. break;
  3018. case '换货出库单':
  3019. call = 'ProdInOut!ExchangeOut';
  3020. break;
  3021. case '生产补料单':
  3022. call = 'ProdInOut!Make!Give';
  3023. break;
  3024. case '完工入库单':
  3025. call = 'ProdInOut!Make!In';
  3026. break;
  3027. case '生产退料单':
  3028. call = 'ProdInOut!Make!Return';
  3029. break;
  3030. case '生产报废单':
  3031. call = 'ProdInOut!Make!Useless';
  3032. break;
  3033. case '无订单出货单':
  3034. call = 'ProdInOut!NoSale';
  3035. break;
  3036. case '委外补料单':
  3037. call = 'ProdInOut!OSMake!Give';
  3038. break;
  3039. case '其它入库单':
  3040. call = 'ProdInOut!OtherIn';
  3041. break;
  3042. case '其它出库单':
  3043. call = 'ProdInOut!OtherOut';
  3044. break;
  3045. case '其它采购入库单':
  3046. call = 'ProdInOut!OtherPurcIn';
  3047. break;
  3048. case '其它采购出库单':
  3049. call = 'ProdInOut!OtherPurcOut';
  3050. break;
  3051. case '拆件入库单':
  3052. call = 'ProdInOut!PartitionStockIn';
  3053. break;
  3054. case '生产领料单':
  3055. call = 'ProdInOut!Picking';
  3056. break;
  3057. case '库存初始化':
  3058. call = 'ProdInOut!ReserveInitialize';
  3059. break;
  3060. case '借货出货单':
  3061. call = 'ProdInOut!SaleBorrow';
  3062. break;
  3063. case '销售拨入单':
  3064. call = 'ProdInOut!SalePutIn';
  3065. break;
  3066. case '盘亏调整单':
  3067. call = 'ProdInOut!StockLoss';
  3068. break;
  3069. case '盘盈调整单':
  3070. call = 'ProdInOut!StockProfit';
  3071. break;
  3072. case '报废单':
  3073. call = 'ProdInOut!StockScrap';
  3074. break;
  3075. case '研发退料单':
  3076. call = 'ProdInOut!YFIN';
  3077. break;
  3078. case '研发领料单':
  3079. call = 'ProdInOut!YFOUT';
  3080. break;
  3081. case 'MAKE':
  3082. call = 'Make!Base';
  3083. break;
  3084. case 'OS':
  3085. call = 'Make';
  3086. break;
  3087. case '采购收料单':
  3088. call = 'VerifyApply';
  3089. break;
  3090. case '委外收料单':
  3091. call = 'VerifyApply!OS';
  3092. break;
  3093. case '采购入库申请单':
  3094. call = 'VerifyApply';
  3095. break;
  3096. case '委外入库申请单':
  3097. call = 'VerifyApply!OS';
  3098. break;
  3099. case '冲应付款':
  3100. call = 'PayBalance!CAID';
  3101. break;
  3102. case '付款单':
  3103. call = 'PayBalance';
  3104. break;
  3105. case '应付款转销':
  3106. call = 'PayBalance!APRM';
  3107. break;
  3108. case '收款单':
  3109. call = 'RecBalance!PBIL';
  3110. break;
  3111. case '冲应收款':
  3112. call = 'RecBalance!IMRE';
  3113. break;
  3114. }
  3115. return call;
  3116. }
  3117. });