| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.make.MakeIMEI', {
- extend: 'Ext.app.Controller',
- requires: ['erp.util.BaseUtil','erp.util.GridUtil'],
- views: ['common.init.Template', 'core.button.UpExcel', 'core.trigger.DbfindTrigger', 'core.trigger.MultiDbfindTrigger',
- 'core.toolbar.Toolbar'],
- init: function(){
- var me = this;
- me.BaseUtil = Ext.create('erp.util.BaseUtil');
- me.GridUtil = Ext.create('erp.util.GridUtil');
- this.control({
- 'form[id=upexcel]': {
- afterrender: function(btn){
- btn.upexcel = function(field){
- if(btn.grid){
- btn.getForm().submit({
- url: basePath + 'pm/make/upexcel.action?caller='+caller,
- waitMsg: "正在解析Excel",
- success: function(fp, o){
- field.reset();
- btn.grid.ilid = o.result.ilid;
- btn.grid.down('pagingtoolbar').dataCount = o.result.count;
- /*btn.grid.down('pagingtoolbar').pageSize = o.result.count;*/
- btn.grid.down('pagingtoolbar').onLoad(o.result.count);
- btn.grid.getGridData(1);
- Ext.getCmp('check').show();
- Ext.getCmp('toformal').hide();
- Ext.getCmp('thisdelete').hide();
- //Ext.getCmp('saveupdates').hide();
- },
- failure: function(fp, o){
- if(o.result.size){
- showError(o.result.error + " " + Ext.util.Format.fileSize(o.result.size));
- field.reset();
- } else {
- showError(o.result.error);
- field.reset();
- }
- }
- });
-
- }
- };
- }
- },
- 'button[id=export]': {
- click: function(btn){
- var grid = btn.ownerCt.ownerCt.down('gridpanel');
- if(grid){
- me.BaseUtil.exportGrid(grid);
- }
- }
- },
- 'button[id=rule]': {
- click: function(btn){
- this.openUrl();
- }
- },
- 'button[id=check]': {
- click: function(btn){
- var grid = btn.ownerCt.ownerCt.down('gridpanel');
- if(grid && grid.down('pagingtoolbar').dataCount<=0) showMessage('提示', '无数据');
- else if(grid) me.checkdata(grid);
- }
- },
- 'button[id=history]': {
- click: function(btn){
- var grid = btn.ownerCt.ownerCt.down('gridpanel');
- if(grid){
- me.showHistory(grid.caller);
- }
- }
- },
- 'button[id=toformal]': {
- click: function(btn){
- var grid = btn.ownerCt.ownerCt.down('gridpanel');
- var bool = false;
- if(grid && grid.ilid > 0) {
- if(grid.down('pagingtoolbar').dataCount<=0) showMessage('提示', '无数据');
- else {
- for(var i = 0 ; i < grid.errorNodesStr.length ; i++){
- if(grid.errorNodesStr[i]!=''){
- bool = true;
- break;
- }
- }
- if(bool) {
- showMessage('提示', '测试未通过,无法转入正式');
- } else {
- me.toformal(grid);
- }
- }
- }
- }
- },
- 'button[id=thisdelete]': {
- click: function(btn){
- var grid = btn.ownerCt.ownerCt.down('gridpanel');
- var bool = false;
- if(grid && grid.ilid > 0) {
- if(grid.down('pagingtoolbar').dataCount<=0) showMessage('提示', '无数据');
- else {
- for(var i = 0 ; i < grid.errorNodesStr.length ; i++){
- if(grid.errorNodesStr[i]!=''){
- bool = true;
- break;
- }
- }
- if(bool) {
- showMessage('提示', '测试未通过,无需删除数据');
- } else {
- me.thisdelete(grid,me);
- }
- }
- }
- }
- },
- /*'button[id=saveupdates]': {
- click: function(btn){
- var grid = btn.ownerCt.ownerCt.down('gridpanel');
- if(grid && grid.ilid > 0) {
- me.saveUpdates(grid);
- }
- }
- },*/
- '#template': {
- afterrender: function(p) {
- this.getDetails(p, caller, false);
- }
- }
- });
- },
- getDetails: function(p, caller, isReload){
- if(caller != p.caller || isReload){
- p.caller = caller;
- var me = this;
- Ext.Ajax.request({
- url: basePath + 'common/singleGridPanel.action',
- params: {
- caller: caller,
- condition:''
- },
- method: 'post',
- callback: function(options, success, response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo != null){
- Ext.getCmp('upexcel').hide();
- showError(res.exceptionInfo);return;
- } else {
- p.removeAll();
- var store = me.emptyData(res.columns);
- p.add({
- xtype: 'grid',
- id: 'template-data',
- anchor: "100% 100%",
- cls: 'custom',
- caller: caller,
- ilid: -1,
- cfg: res.columns,//当前导入项的配置信息
- columnLines: true,
- viewConfig: {
- style: { overflow: 'hidden', overflowX: 'hidden' }
- },
- columns: me.parseInitDetails(res.columns),
- store: store,
- dockedItems: [me.getDockedItems(store)],
- getGridData: function(page){
- me.loadInitData(this, page);
- },
- loadData: function(ilid, count, page){
- this.ilid = ilid;
- this.down('pagingtoolbar').dataCount = count;
- this.down('pagingtoolbar').onLoad();
- this.getGridData(page);
- Ext.getCmp('toformal').show();
- if(caller!='ProductSmt!Import'){
- Ext.getCmp('thisdelete').show();
- }
- //Ext.getCmp('saveupdates').show();
- Ext.getCmp('check').show();
- },
- deleteData: function(ilid){
- me.ondelete(ilid);
- },
- reset: function(){
- this.ilid = -1;
- this.down('pagingtoolbar').dataCount = 25;
- this.down('pagingtoolbar').onLoad();
- this.store.removeAll(true);
- this.store.loadData([{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]);
- },
- showErrors: function(page){
- var grid = this,items = grid.store.data.items,
- columns = grid.columns,d,lineError,fieldS,errorS,nodesStr = grid.errorNodesStr,log = '',
- f = (page-1) * 100,t = page*100;
- if(nodesStr && nodesStr.length > 0) {
- var end = t<nodesStr.length-1?t:nodesStr.length-1;
- for(var i = f; i<end; i++){
- log = '';
- if(nodesStr[nodesStr.length-1]==''){
- if(nodesStr[i] == ''){
- me.parseError([],items,columns,i);
- continue;
- }
- lineError = nodesStr[i].split(";");
- me.parseError(lineError,items,columns,i);
-
- }else{
- lineError = (nodesStr[nodesStr.length-1]+nodesStr[i]).split(";");
- me.parseError(lineError,items,columns,i);
- }
-
- }
- }
- },
- plugins: [{
- ptype: 'rowexpander',
- rowBodyTpl : [
- '<p><b>校验状态:</b> {log}</p><br>'
- ],
- toggleRow: function(rowIdx) {
- var rowNode = this.view.getNode(rowIdx),
- row = Ext.get(rowNode),
- nextBd = Ext.get(row).down(this.rowBodyTrSelector),
- record = this.view.getRecord(rowNode),
- grid = this.getCmp();
- if (row.hasCls(this.rowCollapsedCls)) {
- row.removeCls(this.rowCollapsedCls);
- nextBd.removeCls(this.rowBodyHiddenCls);
- this.recordsExpanded[record.internalId] = true;
- this.view.fireEvent('expandbody', rowNode, record, nextBd.dom);
- } else {
- row.addCls(this.rowCollapsedCls);
- nextBd.addCls(this.rowBodyHiddenCls);
- this.recordsExpanded[record.internalId] = false;
- this.view.fireEvent('collapsebody', rowNode, record, nextBd.dom);
- }
- this.view.up('gridpanel').invalidateScroller();
- this.view.up('gridpanel').doComponentLayout();
- //this.view.up('gridpanel').view.refresh();//速度慢
-
- }
- }, Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1
- })]
- });
- var btn = Ext.getCmp('upexcel');
- if(btn) {
- btn.show();
- btn.grid = p.down('gridpanel');
- }
- }
- }
- });
- }
- },
- parseInitDetails: function(arr){
- var me = this, d = new Array(),o;
- var dd = 'import_detno';
- if(caller == 'Make!IMEI'){
- dd = 'MIL_DETNO'
- }
- d.push({xtype: 'rownumberer', width: 35, text:'序号', dataIndex:dd});
- d.push({
- text: '导入日志',
- dataIndex: 'log',
- hidden: true,
- renderer: function(val, meta){
- meta.style = 'height:0px;';
- }
- });
- d.push({
- text: 'ID',
- dataIndex: 'dg_id',
- hidden: true
- });
- var num = 0;
- Ext.each(arr, function(a){
- if(a.dataIndex.toUpperCase().indexOf('DETNO')<0){
- o = new Object();
- o.text = a.text;
- o.dataIndex = a.dataIndex;
- o.hidden = a.hidden;
- o.width = a.width;
- o.caller = caller;
- o.num = num++;
- /*o.rule = a.id_rule;
- o.dataType = a.id_type;*/
- /*o.isNeed = a.id_need == 1 ? '是' : '否';
- o.logic = a.id_logic;
- o.logicdesc = me.parseLogic(o.logic);*/
- o.editor = {
- xtype: 'textfield',
- cls:null,
- displayField:"display",
- editable:true,
- format:"",
- hideTrigger:true,
- maxLength:4000,
- minValue:null,
- positiveNum:false,
- queryMode:"local",
- store:null,
- valueField:"value"
- };
- o.renderer = function(val, meta, record, x, y, store, view){
- if(view) {
- var grid = view.ownerCt,nodesStr = grid.errorNodesStr,cm = grid.columns[y],page = grid.down('pagingtoolbar').page;
- var index = (page-1)*100+x;
- if(nodesStr && nodesStr.length > 0) {
- if(nodesStr[index] != ''){
- var lineError = nodesStr[index].split(";")
- for(var i = 0 ; i<lineError.length-1 ; i++){
- if(lineError[i].split("-")[0]==cm.dataIndex.toLowerCase()){
- meta.tdCls = 'x-td-warn';
- meta.tdAttr = 'data-qtip="' + lineError[i].split('-')[1] + '"';
- }
- }
- }
- }
- }
- return val;
- };
- d.push(o);
- }
- });
- return d;
- },
- emptyData: function(arr){
- var fields = new Array();
- Ext.each(arr, function(a){
- fields.push(a.dataIndex);
- });
- return new Ext.data.Store({
- fields: fields,
- data: [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]
- });
- },
- getDockedItems: function(store){
- return {
- xtype: 'pagingtoolbar',
- store: store,
- pageSize: 100,
- dataCount: store.data.items.length,
- page: 1,
- dock: 'bottom',
- displayInfo: true,
- updateInfo : function(){
- var page = this.child('#inputItem').getValue() || 1;
- var me = this,
- pageSize = me.pageSize || 100,
- dataCount = me.dataCount || 20;
- var displayItem = me.child('#displayItem'),
- pageData = me.getPageData();
- pageData.fromRecord = (page-1)*pageSize+1;
- pageData.toRecord = page*pageSize > dataCount ? dataCount : page*pageSize;
- pageData.total = dataCount;
- var msg;
- if (displayItem) {
- if (me.dataCount === 0) {
- msg = me.emptyMsg;
- } else {
- msg = Ext.String.format(
- me.displayMsg,
- pageData.fromRecord,
- pageData.toRecord,
- pageData.total
- );
- }
- displayItem.setText(msg);
- me.doComponentLayout();
- }
- },
- getPageData : function(){
- var me = this,
- totalCount = me.dataCount;
- return {
- total : totalCount,
- currentPage : me.page,
- pageCount: Math.ceil(me.dataCount / me.pageSize),
- fromRecord: ((me.page - 1) * me.pageSize) + 1,
- toRecord: Math.min(me.page * me.pageSize, totalCount)
- };
- },
- doRefresh:function(){
- this.moveFirst();
- },
- onPagingKeyDown : function(field, e){
- var me = this,
- k = e.getKey(),
- pageData = me.getPageData(),
- increment = e.shiftKey ? 10 : 1,
- pageNum = 0;
- if (k == e.RETURN) {
- e.stopEvent();
- pageNum = me.readPageFromInput(pageData);
- if (pageNum !== false) {
- pageNum = Math.min(Math.max(1, pageNum), pageData.pageCount);
- me.child('#inputItem').setValue(pageNum);
- if(me.fireEvent('beforechange', me, pageNum) !== false){
- me.page = pageNum;
- me.ownerCt.getGridData(me.page);
- }
-
- }
- } else if (k == e.HOME || k == e.END) {
- e.stopEvent();
- pageNum = k == e.HOME ? 1 : pageData.pageCount;
- field.setValue(pageNum);
- } else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN) {
- e.stopEvent();
- pageNum = me.readPageFromInput(pageData);
- if (pageNum) {
- if (k == e.DOWN || k == e.PAGEDOWN) {
- increment *= -1;
- }
- pageNum += increment;
- if (pageNum >= 1 && pageNum <= pageData.pages) {
- field.setValue(pageNum);
- }
- }
- }
- me.updateInfo();
- me.resetTool(value);
- },
- moveFirst : function(){
- var me = this;
- me.child('#inputItem').setValue(1);
- value = 1;
- me.page = value;
- me.ownerCt.getGridData(value);
- me.updateInfo();
- me.resetTool(value);
- },
- movePrevious : function(){
- var me = this;
- me.child('#inputItem').setValue(me.child('#inputItem').getValue() - 1);
- value = me.child('#inputItem').getValue();
- me.page = value;
- me.ownerCt.getGridData(value);
- me.updateInfo();
- me.resetTool(value);
- },
- moveNext : function(){
- var me = this,
- last = me.getPageData().pageCount;
- total = last;
- me.child('#inputItem').setValue(me.child('#inputItem').getValue() + 1);
- value = me.child('#inputItem').getValue();
- me.page = value;
- me.ownerCt.getGridData(value);
- me.updateInfo();
- me.resetTool(value);
- },
- moveLast : function(){
- var me = this,
- last = me.getPageData().pageCount;
- total = last;
- me.child('#inputItem').setValue(last);
- value = me.child('#inputItem').getValue();
- me.page = value;
- me.ownerCt.getGridData(value);
- me.updateInfo();
- me.resetTool(value);
- },
- onLoad : function() {
- var e = this, d, b, c, a;
- if (!e.rendered) {
- return
- }
- d = e.getPageData();
- b = d.currentPage;
- c = Math.ceil(e.dataCount / e.pageSize);
- a = Ext.String.format(e.afterPageText, isNaN(c) ? 1 : c);
- e.child("#afterTextItem").setText(a);
- e.child("#inputItem").setValue(b);
- e.child("#first").setDisabled(b === 1);
- e.child("#prev").setDisabled(b === 1);
- e.child("#next").setDisabled(b === c || c===1);//
- e.child("#last").setDisabled(b === c || c===1);
- e.child("#refresh").enable();
- e.updateInfo();
- e.fireEvent("change", e, d);
- },
- resetTool: function(value){
- var pageCount = this.getPageData().pageCount;
- this.child('#last').setDisabled(value == pageCount || pageCount == 1);
- this.child('#next').setDisabled(value == pageCount || pageCount == 1);
- this.child('#first').setDisabled(value <= 1);
- this.child('#prev').setDisabled(value <= 1);
- }
- };
- },
- getPathString: function(tree, record){//path:/root/5/12
- var str = tree.ownerCt.title;
- return record.getPath('text', '»').replace('root', str);
- },
- ondelete: function(id){
- var grid = Ext.getCmp('template-data');
- grid.setLoading(true);
- Ext.Ajax.request({
- url: basePath + 'system/deleteInitData.action',
- params: {
- id: id
- },
- method: 'post',
- callback: function(options, success, response){
- var res = new Ext.decode(response.responseText);
- grid.setLoading(false);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- } else {
- if(id == grid.ilid) {//如果删除的是当前显示的数据,要清除当前grid的数据
- grid.reset();
- }
- }
- }
- });
- },
- showHistory: function(caller){
- var w = Ext.create('Ext.Window', {
- width: '60%',
- height: '80%',
- id: 'history-win',
- title: '导入数据历史记录',
- autoShow: true,
- layout: 'anchor',
- items: [{
- xtype: 'gridpanel',
- anchor: '100% 100%',
- columnLines: true,
- columns: [{dataIndex: 'il_id', hidden: true},{dataIndex: 'il_caller', hidden: true},{dataIndex: 'il_date', text: '日期', flex: 2},
- {dataIndex: 'il_sequence', text: '次数', flex: 1},{dataIndex: 'il_count', text: '数据量(条)', flex: 1},
- {dataIndex: 'il_checked', text: '是否已校验', flex: 1, renderer: function(val, m){
- if(val == '否') {
- m.style = 'float:right';
- }
- return val;
- }},{dataIndex: 'il_success',text:'是否校验通过', flex: 1, renderer: function(val, m){
- if(val == '否') {
- m.style = 'float:right';
- }
- return val;
- }},
- {dataIndex: 'il_toformal', text: '是否转正式', flex: 1, renderer: function(val, m){
- if(val == '否') {
- m.style = 'float:right';
- }
- return val;
- }}, {text: '', flex: 1, renderer: function(val, m, r){
- return '<a href="javascript:Ext.getCmp(\'template-data\').loadData(' + r.get('il_id') + ','
- + r.get('il_count') + ',1);Ext.getCmp(\'history-win\').close();Ext.getDom(\'check\').click();">载入</a> <a href="javascript:Ext.getCmp(\'template-data\').deleteData(' +
- r.get('il_id') + ');Ext.getCmp(\'history-win\').close();">删除</a>';
- }}],
- store: Ext.create('Ext.data.Store', {
- fields: ['il_id', 'il_caller', 'il_date', 'il_sequence', 'il_count', 'il_checked', 'il_success', 'il_toformal'],
- data: [{},{},{},{},{},{},{},{},{},{}]
- })
- }]
- });
- this.getInitLog(w.down('gridpanel'), caller);
- },
- getInitLog: function(g, c){
- Ext.Ajax.request({
- url: basePath + 'system/initHistory.action',
- params: {
- caller: c
- },
- method: 'post',
- callback: function(opt, s, r){
- var res = new Ext.decode(r.responseText);
- var dd = res.data;
- Ext.each(dd, function(d){
- d.il_date = Ext.Date.format(new Date(d.il_date), 'Y-m-d H:i:s');
- d.il_checked = d.il_checked == 1 ? '是' : '否';
- d.il_success = d.il_success == 1 ? '是' : '否';
- d.il_toformal = d.il_toformal == 1 ? '是' : '否';
- });
- g.store.loadData(dd);
- }
- });
- },
- loadInitData: function(grid, page){
- var f = (page-1) * 100 + 1,
- t = page*100;
- grid.setLoading(true);
- Ext.Ajax.request({
- url: basePath + 'system/getInitData.action',
- params: {
- condition: "id_ilid=" + grid.ilid +
- " AND id_detno between " + f + " AND " + t
- },
- method: 'post',
- callback: function(options, success, response){
- var res = new Ext.decode(response.responseText);
- grid.setLoading(false);
- if(res.exceptionInfo != null){
- showError(res.exceptionInfo);return;
- } else {
- var datas = new Array(), o;
- Ext.each(res.data, function(d){
- o = Ext.decode(d.id_data);
- o.id_id = d.id_id;
- datas.push(o);
- });
- grid.store.loadData(datas);
- grid.showErrors(page);
- }
- }
- });
- },
- /* saveInitDetails: function(grid, caller){
- var me = this,datas = [],items = grid.store.data.items,d;
- Ext.each(items, function(i){
- if(i.dirty) {
- d = i.data;
- if(!Ext.isEmpty(d.id_field) && !Ext.isEmpty(d.id_table)) {
- d.id_field=d.id_field.trim();
- d.id_need = d.id_need ? 1 : 0;
- d.id_visible = d.id_visible ? 1 : 0;
- d.id_caller = caller;
- d.id_fieldtype =Ext.isEmpty(d.id_fieldtype)? 0:d.id_fieldtype;
- d.id_width = Ext.isEmpty(d.id_width) ? 100 : d.id_width;
- datas.push(d);
- }
- }
- });
- Ext.Ajax.request({
- url: basePath + 'system/saveInitDetail.action',
- method: 'post',
- params: {
- data: unescape(Ext.encode(datas).replace(/\\/g,"%"))
- },
- callback: function(opt, s, r) {
- var rs = Ext.decode(r.responseText);
- if(!rs || rs.exceptionInfo) {
- showError(rs.exceptionInfo);
- } else {
- alert('保存成功!');
- grid.ownerCt.destroy();
- me.getDetails(Ext.getCmp('template'), caller, true);
- }
- }
- });
- },*/
- fieldTypes: function(f, record){
- var g = Ext.getCmp('initdetails'), dd = g.store.data.items,ff = [];
- Ext.each(dd, function(i){
- if(i.data.id_field != record.data.id_field) {
- ff.push({
- display: i.data.id_caption,
- value: i.data.id_field
- });
- }
- });
- var ww = Ext.create('Ext.Window', {
- autoShow: true,
- modal: true,
- title: '默认值',
- width: '55%',
- height: '50%',
- layout: 'column',
- items: [{
- xtype: 'fieldcontainer',
- name: 'keyField',
- columnWidth: 1,
- items: [{
- xtype: 'radio',
- columnWidth: 1,
- boxLabel: '自动取ID',
- name: 'default'
- }],
- getValue: function(){
- return 'keyField';
- },
- setValue: function(){
- this.down('radio').setValue(true);
- }
- },{
- xtype: 'fieldcontainer',
- name: 'codeField',
- columnWidth: 1,
- items: [{
- xtype: 'radio',
- columnWidth: 1,
- boxLabel: '自动取编号',
- name: 'default'
- }],
- getValue: function(){
- return 'codeField';
- },
- setValue: function(){
- this.down('radio').setValue(true);
- }
- },{
- xtype: 'fieldcontainer',
- name: 'date',
- columnWidth: 1,
- layout: 'hbox',
- items: [{
- xtype: 'radio',
- boxLabel: '当前时间',
- name: 'default'
- },{
- xtype: 'checkbox',
- inputValue: 'yy-MM-dd',
- separator: ' ',
- boxLabel: '年月日'
- },{
- xtype: 'checkbox',
- inputValue: 'HH:mm:ss',
- separator: '',
- boxLabel: '时分秒'
- }],
- getValue: function(){
- var rr = this.query('checkbox[checked=true]'), vv = '', len = rr.length;
- Ext.each(rr, function(r, idx){
- if(r.xtype == 'checkbox' && r.inputValue) {
- vv += r.inputValue;
- if(idx < len - 1) {
- vv += r.separator;
- }
- }
- });
- if(vv == '') {
- return '';
- }
- return 'date(' + vv + ')';
- },
- setValue: function(v){
- this.down('radio').setValue(true);
- v = v.substring(v.indexOf('(') + 1, v.indexOf(')'));
- var y = v.split(' '),arr,me = this;
- Ext.each(y, function(i){
- arr = me.down('checkbox[inputValue=' + i + ']');
- if(arr)
- arr.setValue(true);
- });
- }
- },{
- xtype: 'fieldcontainer',
- name: 'replace',
- columnWidth: 1,
- layout: 'hbox',
- items: [{
- xtype: 'radio',
- name: 'default',
- boxLabel: '替代值'
- },{
- xtype: 'fieldcontainer',
- items: [{
- xtype: 'textfield',
- emptyText: '显示值'
- },{
- xtype: 'textfield',
- emptyText: '实际值'
- }],
- getValue: function(){
- var val = this.items.items[0],dis = this.items.items[1];
- if(!Ext.isEmpty(val.value) && !Ext.isEmpty(dis.value)) {
- return val.value + ':' + dis.value;
- }
- return '';
- },
- setValue: function(v) {
- if(!Ext.isEmpty(v)) {
- this.items.items[0].setValue(v.split(':')[0]);
- this.items.items[1].setValue(v.split(':')[1] || '');
- }
- }
- },{
- xtype: 'button',
- iconCls: 'x-button-icon-add',
- cls: 'x-btn-tb',
- handler: function(b){
- b.ownerCt.insert(b.ownerCt.items.items.length - 1, {
- xtype: 'fieldcontainer',
- items: [{
- xtype: 'textfield',
- emptyText: '显示值'
- },{
- xtype: 'textfield',
- emptyText: '实际值'
- }],
- getValue: function(){
- var val = this.items.items[0],dis = this.items.items[1];
- if(!Ext.isEmpty(val.value) && !Ext.isEmpty(dis.value)) {
- return val.value + ':' + dis.value;
- }
- return '';
- },
- setValue: function(v) {
- if(!Ext.isEmpty(v)) {
- this.items.items[0].setValue(v.split(':')[0]);
- this.items.items[1].setValue(v.split(':')[1] || '');
- }
- }
- });
- }
- }],
- getValue: function(){
- var tx = this.query('fieldcontainer'),val = '';
- Ext.each(tx, function(t){
- if(!Ext.isEmpty(t.getValue())) {
- if(val == '') {
- val = t.getValue();
- } else {
- val += ',' + t.getValue();
- }
- }
- });
- if(val == '') {
- return null;
- }
- return 'replace(' +val + ')';
- },
- setValue: function(v){
- var m = this;
- this.down('radio').setValue(true);
- var t = v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')).split(',');
- Ext.each(t, function(r, i){
- if(i == 0) {
- m.down('fieldcontainer').setValue(r);
- } else {
- var f = Ext.create('Ext.form.FieldContainer', {
- items: [{
- xtype: 'textfield',
- emptyText: '显示值'
- },{
- xtype: 'textfield',
- emptyText: '实际值'
- }],
- getValue: function(){
- var val = this.items.items[0],dis = this.items.items[1];
- if(!Ext.isEmpty(val.value) && !Ext.isEmpty(dis.value)) {
- return val.value + ':' + dis.value;
- }
- return '';
- },
- setValue: function(v) {
- if(!Ext.isEmpty(v)) {
- this.items.items[0].setValue(v.split(':')[0]);
- this.items.items[1].setValue(v.split(':')[1] || '');
- }
- }
- });
- m.insert(m.items.items.length - 1, f);
- f.setValue(r);
- }
- });
- }
- },{
- xtype: 'fieldcontainer',
- name: 'copy',
- columnWidth: 1,
- layout: 'hbox',
- items: [{
- xtype: 'radio',
- boxLabel: '等于字段',
- name: 'default'
- },{
- xtype: 'combo',
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- editable: false,
- store: Ext.create('Ext.data.Store', {
- fields: ['display','value'],
- data: ff
- })
- },{
- xtype: 'radio',
- name: 'condition',
- inputValue: 'if',
- boxLabel: '只在值为空时'
- },{
- xtype: 'radio',
- name: 'condition',
- inputValue: 'of',
- boxLabel: '任何情况下',
- checked: true
- }],
- getValue: function(){
- var rr = this.query('radio[name=condition]'), vv = '';
- Ext.each(rr, function(){
- if(this.checked) {
- vv = this.inputValue;
- }
- });
- return 'copy' + vv + '(' + this.down('combo').value + ')';
- },
- setValue: function(v) {
- this.down('radio').setValue(true);
- this.down('combo').setValue(v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')));
- var ff = v.substring(4, v.indexOf('('));
- this.down('radio[inputValue=' + ff + ']').setValue(true);
- }
- },{
- xtype: 'fieldcontainer',
- name: 'others',
- columnWidth: 1,
- layout: 'hbox',
- items: [{
- xtype: 'radio',
- boxLabel: '其它',
- name: 'default'
- },{
- xtype: 'textfield'
- }],
- getValue: function() {
- return this.down('textfield').value;
- },
- setValue: function(v) {
- this.down('radio').setValue(true);
- this.down('textfield').setValue(v);
- }
- }],
- buttonAlign: 'center',
- buttons: [{
- text: '确定',
- handler: function(b){
- var w = b.ownerCt.ownerCt;
- var val = '',ch = w.query('radio[name="default"]'),cc = null;
- Ext.each(ch, function(){
- if(this.checked) {
- cc = this;
- }
- });
- if(cc) {
- v = cc.ownerCt.getValue();
- if(v != null) {
- val = v;
- }
- }
- f.setValue(val);
- record.set('id_default', val);
- w.close();
- }
- },{
- text: '取消',
- handler: function(b){
- b.ownerCt.ownerCt.close();
- }
- }]
- });
- var fc = ww.query('fieldcontainer');
- if(!Ext.isEmpty(f.value)) {
- var vv = f.value,bool = false;
- Ext.each(fc, function(r){
- if(contains(vv, r.name, true)) {
- bool = true;
- r.setValue(vv);
- }
- });
- if(!bool) {
- ww.down('fieldcontainer[name=others]').setValue(vv);
- }
- }
- },
- logicTypes: function(f, record){
- var g = Ext.getCmp('initdetails'), dd = g.store.data.items,ff = [];
- Ext.each(dd, function(i){
- if(i.data.id_field != record.data.id_field) {
- ff.push({
- display: i.data.id_caption,
- value: i.data.id_field
- });
- }
- });
- var ww = Ext.create('Ext.Window', {
- autoShow: true,
- modal: true,
- title: '逻辑表达式',
- width: '80%',
- height: '60%',
- layout: 'column',
- padding: 15,
- items: [{
- xtype: 'fieldcontainer',
- name: 'unique',
- columnWidth: 1,
- items: [{
- xtype: 'checkbox',
- boxLabel: '唯一性'
- }],
- getValue: function(){
- return 'unique(' + record.data.id_table + '|' + record.data.id_field + ')';
- },
- setValue: function(v){
- this.down('checkbox').setValue(true);
- }
- },{
- xtype: 'fieldcontainer',
- name: 'upper',
- columnWidth: 1,
- items: [{
- xtype: 'checkbox',
- boxLabel: '强制转大写'
- }],
- getValue: function(){
- return 'upper(' + record.data.id_field + ')';
- },
- setValue: function(v){
- this.down('checkbox').setValue(true);
- }
- },{
- xtype: 'fieldcontainer',
- name: 'trim',
- columnWidth: 1,
- layout: 'column',
- items: [{
- xtype: 'checkbox',
- columnWidth: 0.1,
- boxLabel: '禁用字符'
- },{
- xtype: 'textfield',
- columnWidth: 0.1
- },{
- xtype: 'button',
- iconCls: 'x-button-icon-add',
- cls: 'x-btn-tb',
- handler: function(b){
- b.ownerCt.insert(b.ownerCt.items.items.length - 1, {
- xtype: 'textfield',
- columnWidth: 0.1
- });
- }
- }],
- getValue: function(){
- var tx = this.query('textfield'),val = '';
- Ext.each(tx, function(t){
- if(!Ext.isEmpty(t.value)) {
- if(val == '') {
- val = t.value;
- } else {
- val += ',' + t.value;
- }
- }
- });
- if(val == '') {
- return null;
- }
- return 'trim(' +val + ')';
- },
- setValue: function(v){
- var m = this;
- m.down('checkbox').setValue(true);
- var t = v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')).split(',');
- Ext.each(t, function(r, i){
- if(i == 0) {
- m.down('textfield').setValue(r);
- } else {
- m.insert(m.items.items.length - 1, {
- xtype: 'textfield',
- columnWidth: 0.1,
- value: r
- });
- }
- });
- }
- },{
- xtype: 'fieldcontainer',
- name: 'combo',
- columnWidth: 1,
- layout: 'column',
- items: [{
- xtype: 'checkbox',
- columnWidth: 0.1,
- boxLabel: '可选范围'
- },{
- xtype: 'textfield',
- columnWidth: 0.1
- },{
- xtype: 'button',
- iconCls: 'x-button-icon-add',
- cls: 'x-btn-tb',
- handler: function(b){
- b.ownerCt.insert(b.ownerCt.items.items.length - 1, {
- xtype: 'textfield',
- columnWidth: 0.1
- });
- }
- }],
- getValue: function(){
- var tx = this.query('textfield'),val = '';
- Ext.each(tx, function(t){
- if(!Ext.isEmpty(t.value)) {
- if(val == '') {
- val = t.value;
- } else {
- val += ',' + t.value;
- }
- }
- });
- if(val == '') {
- return null;
- }
- return 'combo(' +val + ')';
- },
- setValue: function(v){
- var m = this;
- m.down('checkbox').setValue(true);
- var t = v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')).split(',');
- Ext.each(t, function(r, i){
- if(i == 0) {
- m.down('textfield').setValue(r);
- } else {
- m.insert(m.items.items.length - 1, {
- xtype: 'textfield',
- columnWidth: 0.1,
- value: r
- });
- }
- });
- }
- },{
- xtype: 'fieldcontainer',
- name: 'accord',
- columnWidth: 1,
- layout: 'column',
- items: [{
- xtype: 'checkbox',
- columnWidth: 0.1,
- boxLabel: '关联'
- },{
- columnWidth: 0.3,
- emptyText: '表',
- id: 'accord_table',
- name: 'accord_table',
- xtype: 'dbfindtrigger'
- },{
- columnWidth: 0.3,
- emptyText: '字段',
- id: 'accord_field',
- name: 'accord_field',
- dbKey: 'accord_table',
- mappingKey: 'ddd_tablename',
- dbMessage: '请选择表名',
- xtype: 'dbfindtrigger'
- }],
- getValue: function(){
- var at = this.down('dbfindtrigger[name=accord_table]'),
- af = this.down('dbfindtrigger[name=accord_field]');
- if(!Ext.isEmpty(at.value) && !Ext.isEmpty(af.value)) {
- return 'accord(' + at.value + '|' + af.value + ')';
- }
- return null;
- },
- setValue: function(v){
- this.down('checkbox').setValue(true);
- var t = v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')).split('|');
- this.down('dbfindtrigger[name=accord_table]').setValue(t[0]);
- this.down('dbfindtrigger[name=accord_field]').setValue(t[1]);
- }
- },{
- xtype: 'fieldcontainer',
- name: 'diffence',
- columnWidth: 1,
- layout: 'column',
- items: [{
- xtype: 'checkbox',
- columnWidth: 0.1,
- boxLabel: '不同于'
- },{
- columnWidth: 0.3,
- xtype: 'combo',
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- editable: false,
- store: Ext.create('Ext.data.Store', {
- fields: ['display','value'],
- data: ff
- })
- }],
- getValue: function(){
- var c = this.down('combo');
- if(!Ext.isEmpty(c.value)) {
- return 'diffence(' + c.value + ')';
- }
- return null;
- },
- setValue: function(v){
- this.down('checkbox').setValue(true);
- this.down('combo').setValue(v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')));
- }
- },{
- xtype: 'fieldcontainer',
- name: 'combine',
- columnWidth: 1,
- layout: 'column',
- items: [{
- xtype: 'checkbox',
- columnWidth: 0.1,
- boxLabel: '组合校验'
- },{
- columnWidth: 0.3,
- xtype: 'combo',
- displayField: 'display',
- valueField: 'value',
- queryMode: 'local',
- multiSelect: true,
- editable: false,
- store: Ext.create('Ext.data.Store', {
- fields: ['display','value'],
- data: ff
- })
- }],
- getValue: function(){
- var c = this.down('combo');
- if(!Ext.isEmpty(c.value)) {
- return 'combine(' + c.value + ')';
- }
- return null;
- },
- setValue: function(v){
- this.down('checkbox').setValue(true);
- this.down('combo').setValue(v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')));
- }
- },{
- xtype: 'fieldcontainer',
- name: 'minValue',
- columnWidth: 1,
- layout: 'column',
- items: [{
- xtype: 'checkbox',
- columnWidth: 0.1,
- boxLabel: '最小值'
- },{
- columnWidth: 0.3,
- xtype: 'numberfield'
- }],
- getValue: function(){
- var c = this.down('numberfield');
- if(!Ext.isEmpty(c.value)) {
- return 'minValue(' + c.value + ')';
- }
- return null;
- },
- setValue: function(v){
- this.down('checkbox').setValue(true);
- this.down('minValue').setValue(v.substring(v.indexOf('(') + 1, v.lastIndexOf(')')));
- }
- }],
- buttonAlign: 'center',
- buttons: [{
- text: '确定',
- handler: function(b){
- var w = b.ownerCt.ownerCt;
- var val = '',ch = w.query('checkbox[checked=true]'),v;
- Ext.each(ch, function(c){
- v = c.ownerCt.getValue();
- if(v != null) {
- if(val != '') {
- val += ';';
- }
- val += v;
- }
- });
- f.setValue(val);
- record.set('id_logic', val);
- w.close();
- }
- },{
- text: '取消',
- handler: function(b){
- b.ownerCt.ownerCt.close();
- }
- }]
- });
- var fc = ww.query('fieldcontainer');
- if(!Ext.isEmpty(f.value)) {
- var vv = f.value.split(';');
- Ext.each(vv, function(s){
- Ext.each(fc, function(r){
- if(contains(s, r.name, true)) {
- r.setValue(s);
- }
- });
- });
- }
- },
- dataTypes: function(f, record){
- var v = f.value,a = v.substring(v.indexOf('(') + 1, v.indexOf(')')),x = 30,y = 0;
- if(a) {
- x = a.split(',')[0];
- y = a.split(',')[1];
- }
- var isDate = contains(f.value, 'date', true), isStr = contains(f.value, 'varchar2', true);
- Ext.create('Ext.Window', {
- autoShow: true,
- modal: true,
- title: '数据类型',
- width: '40%',
- height: '30%',
- items: [{
- xtype: 'container',
- padding: '10 5 5 10',
- items: [{
- xtype: 'radio',
- boxLabel: '日期',
- name: 'type',
- checked: isDate,
- inputValue: 'date()',
- listeners: {
- change : function(){
- if(this.checked) {
- this.ownerCt.down('numberfield[name=length_y]').hide();
- this.ownerCt.down('numberfield[name=length_x]').hide();
- } else {
- this.ownerCt.down('numberfield[name=length_x]').show();
- }
- }
- }
- },{
- xtype: 'radio',
- boxLabel: '字符串',
- name: 'type',
- checked: isStr,
- inputValue: 'varchar2'
- },{
- xtype: 'radio',
- boxLabel: '数字',
- name: 'type',
- checked: !isDate && !isStr,
- inputValue: 'number',
- listeners: {
- change : function(){
- if(this.checked) {
- this.ownerCt.down('numberfield[name=length_y]').show();
- this.ownerCt.down('numberfield[name=length_x]').setMaxValue(38);
- this.ownerCt.down('numberfield[name=length_x]').validate();
- } else {
- this.ownerCt.down('numberfield[name=length_y]').hide();
- this.ownerCt.down('numberfield[name=length_x]').setMaxValue(2000);
- }
- }
- }
- },{
- xtype: 'numberfield',
- fieldLabel: '长度',
- name: 'length_x',
- format: '0',
- value: x,
- hidden: isDate,
- maxText: '超过最大长度',
- listeners: {
- change: function(f){
- var a = f.ownerCt.down('radio[checked=true]').inputValue;
- if(a == 'number') {
- f.setMaxValue(38);
- } else {
- f.setMaxValue(2000);
- }
- }
- }
- },{
- xtype: 'numberfield',
- fieldLabel: '小数位数',
- name: 'length_y',
- hidden: isDate || isStr,
- format: '0',
- maxValue: 57,
- maxText: '超过最大数57',
- value: y
- }]
- }],
- buttonAlign: 'center',
- buttons: [{
- text: '确定',
- handler: function(b){
- var w = b.ownerCt.ownerCt;
- v = w.down('radio[checked=true]').inputValue;
- x = w.down('numberfield[name=length_x]').value || 0;
- y = w.down('numberfield[name=length_y]').value || 0;
- if(v == 'varchar2') {
- v += '(' + x + ')';
- } else if (v == 'number') {
- v += '(' + x + ',' + y + ')';
- }
- f.setValue(v);
- record.set(f.name, v);
- w.close();
- }
- },{
- text: '取消',
- handler: function(b){
- b.ownerCt.ownerCt.close();
- }
- }]
- });
- },
- /**
- * 数据校验
- */
- checkdata: function(grid){
- var me = this;
- var p = Ext.create('Ext.ProgressBar', {
- width: '60%',
- text: '准备校验中...',
- floating: true,
- renderTo: Ext.getBody()
- }).show();
- grid.setLoading(true);
- //先删除上次校验记录
- me.beforeCheck(grid, p, function(){
- // 校验+清除校验环境
- me.onCheck(grid, p, function(){
- //刷新grid.renderer
- me.getCheckResult(grid, p);
- })
- });
- },
- beforeCheck: function(grid, process, callback) {
- Ext.Ajax.request({
- url: basePath + 'pm/make/beforeCheckLog.action',
- params: {
- id: grid.ilid
- },
- method: 'post',
- callback: function(opt, s, r) {
- var res = Ext.decode(r.responseText);
- if(res.success) {
- callback.call();
- } else {
- alert('系统错误,准备校验失败!');
- grid.setLoading(false);
- process.destroy();
- }
- }
- });
- },
- onCheck: function(grid, process, callback) {
- process.updateProgress(0.4, '准备完毕,正在校验...', true);
- Ext.Ajax.request({
- url: basePath + 'pm/make/checkInitData.action',
- timeout: 300000,
- params: {
- id: grid.ilid,
- caller : caller
- },
- method: 'post',
- callback: function(opt, s, r){
- var res = Ext.decode(r.responseText);
- if(!res) {
- grid.setLoading(false);
- p.destroy();
- Ext.Msg.alert('发现错误', '连接超时');
- } else if(res.success) {
- process.updateProgress(0.8, '校验完成,正在获取校验结果...', true);
- callback.call();
- }
- }
- });
- },
- /**
- * 从数据库取校验结果
- */
- getCheckResult: function(grid, p){
- grid.setLoading(true);
- Ext.Ajax.request({
- url: basePath + 'pm/make/getCheckResult.action',
- timeout: 60000,
- params: {
- id: grid.ilid
- },
- method: 'post',
- callback: function(opt, s, r){
- p.destroy();
- grid.setLoading(false);
- var rs = r.responseText;
- if(rs != null && rs != '') {
- grid.errorNodesStr = rs.replace(/\s/g, '').split('/');
- } else {
- grid.errorNodesStr = [];
- alert('系统错误,未找到校验结果.');
- }
- grid.showErrors(1);
- Ext.getCmp('toformal').show();
- if(caller !='ProductSmt!Import'){
- Ext.getCmp('thisdelete').show();
- }
- //Ext.getCmp('saveupdates').show();
- }
- });
- },
- toformal: function(grid){
- var count = grid.down('pagingtoolbar').dataCount, pageSize = 2000, page = 0, a, b,
- len = Math.ceil(count/pageSize), index = 0;
- var p = Ext.create('Ext.ProgressBar', {
- width: '60%',
- text: '准备中...',
- floating: true,
- renderTo: Ext.getBody()
- }).show();
- grid.setLoading(true);
- Ext.Ajax.request({
- url: basePath + 'system/beforeToFormal.action',
- params: {
- id: grid.ilid
- },
- callback: function(opt, s, r){
- if (!s) {
- grid.setLoading(false);
- p.destroy();
- showError('网络或系统错误!');return;
- }
- var res = Ext.decode(r.responseText);
- if(res.success) {
- while (page*pageSize < count) {
- a = page * pageSize + 1;
- b = (page + 1) * pageSize;
- p.updateProgress(index/len, '开始导入' + index/len*100 + '%', true);
- Ext.Ajax.request({
- url: basePath + 'pm/make/toFormalData.action',
- timeout: 30000,
- method: 'post',
- async: false,
- params: {
- id: grid.ilid,
- start: a,
- end: b
- },
- callback: function(_opt, _s, _r){
- var rs = Ext.decode(_r.responseText);
- if(rs.exceptionInfo) {
- grid.setLoading(false);
- p.destroy();
- showError(rs.exceptionInfo);return;
- } else if(_s){
- index++;
- p.updateProgress(index/len, '完成' + index/len*100 + '%', true);
- if(index == len) {
- grid.setLoading(false);
- p.destroy();
- alert('转入成功!');
- Ext.getCmp('check').hide();
- Ext.getCmp('toformal').hide();
- Ext.Ajax.request({
- url: basePath + 'pm/make/afterToFormal.action',
- params: {
- id: grid.ilid
- },
- callback: function(){
-
- }
- });
- }
- } else
- return;
- }
- });
- page++;
- }
- } else {
- grid.setLoading(false);
- p.destroy();
- showError(res.exceptionInfo);
- }
- }
- });
- },
- /**
- * 保存已修改的数据
- *//*
- saveUpdates: function(grid){
- var items = grid.store.data.items,arr = new Array(), d;
- Ext.each(items, function(item){
- if(item.dirty) {
- d = item.data;
- delete d.log;
- arr.push(d);
- }
- });
- Ext.Ajax.request({
- url: basePath + 'system/updateInitData.action',
- method: 'post',
- params: {
- data: Ext.encode(arr)
- },
- callback: function(opt, s, r) {
- var res = Ext.decode(r.responseText);
- if(res.success) {
- alert('保存成功!');
- grid.getGridData(1);
- }
- }
- });
- },*/
- parseLogic: function(logic) {
- if(logic != null) {
- var gc = logic.split(';'), str = '';
- for(var i in gc) {
- var s = gc[i];
- if(s != null) {
- if(s.indexOf('unique') > -1) {
- str += '唯一性;';
- } else if(s.indexOf('trim') > -1) {
- str += '不能包含' + s.replace('trim', '') + ';';
- } else if(s.indexOf('combo') > -1) {
- str += '只能是' + s.replace('combo', '') + '之一;';
- } else if(s.indexOf('accord') > -1) {
- str += '必须存在于' + s.replace('accord', '') + '中;';
- }else if(s.indexOf('combine') > -1) {
- str += '组合字段在关联表中不存在;';
- } else if(s.indexOf('diffence') > -1) {
- str += '必须与' + s.replace('diffence', '') + '不同;';
- }else if(s.indexOf('minValue') > -1) {
- str += '必须大于' + s.replace('minValue', '') + ';';
- }
- }
- }
- return str;
- }
- return null;
- },
- openUrl: function() {
- var me = this, value = caller;
- var keyField = 'dg_caller';
- var pfField = 'dg_caller';
- var formCondition = keyField + "IS" + value ;
- var gridCondition = pfField + "IS" + value;
- var panelId = caller + keyField + "_" + value + gridCondition;
- var panel = Ext.getCmp(panelId);
- var main = parent.Ext.getCmp("content-panel");
- var url = 'jsps/ma/detailgrid.jsp';
- if(!main){
- main = parent.parent.Ext.getCmp("content-panel");
- }
- if(!panel){
- var title = "";
- if (value.toString().length>4) {
- title = value.toString().substring(value.toString().length-4);
- } else {
- title = value;
- }
- var myurl = '';
- if(me.BaseUtil.contains(url, '?', true)){
- myurl = url + '&formCondition='+formCondition+'&gridCondition='+gridCondition;
- } else {
- myurl = url + '?formCondition='+formCondition+'&gridCondition='+gridCondition;
- }
- myurl += "&datalistId=" + main.getActiveTab().id;
- if(main._mobile) {
- main.addPanel(me.BaseUtil.getActiveTab().title+'('+title+')', myurl, panelId);
- } else {
- panel = {
- title : me.BaseUtil.getActiveTab().title+'('+title+')',
- tag : 'iframe',
- tabConfig:{tooltip:me.BaseUtil.getActiveTab().tabConfig.tooltip+'('+keyField + "=" + value+')'},
- border : false,
- layout : 'fit',
- iconCls : 'x-tree-icon-tab-tab1',
- html : '<iframe id="iframe_maindetail_'+caller+"_"+value+'" src="' + myurl + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
- closable : true,
- listeners : {
- close : function(){
- if(!main){
- main = parent.parent.Ext.getCmp("content-panel");
- }
- main.setActiveTab(main.getActiveTab().id);
- }
- }
- };
- this.openTab(panel, panelId);
- }
- }else{
- main.setActiveTab(panel);
- }
- },
- openTab : function (panel,id){
- var o = (typeof panel == "string" ? panel : id || panel.id);
- var main = parent.Ext.getCmp("content-panel");
- /*var tab = main.getComponent(o); */
- if(!main) {
- main =parent.parent.Ext.getCmp("content-panel");
- }
- var tab = main.getComponent(o);
- if (tab) {
- main.setActiveTab(tab);
- } else if(typeof panel!="string"){
- panel.id = o;
- var p = main.add(panel);
- main.setActiveTab(p);
- }
- },
- parseError : function(lineError,items,columns,i){
- log = '<table class="custom-log">';
- log += '<tr class="custom-tr"><td>字段</td><td>错误</td></tr>';
- item = items[i%100];
- var d = item.data;
- if(lineError.length==0){
- item.set('log', '');
- }else{
- for(var j = 0; j < lineError.length-1 ; j++){
- var fieldS = lineError[j].split('-')[0];
- var errorS = lineError[j].split('-')[1];
- Ext.each(columns, function(c, idx){
- if(idx > 0 ){
- if(c.dataIndex.toLocaleLowerCase() == fieldS){
- log += '<tr><td>' + c.text + '</td><td><font color=red>'
- + (errorS || '') + '</font></td></tr>';
- }
- }
- });
- }
- if(log != '') {
- log += '</table>';
- }
- item.set('log', log);
- }
- },
- //删除导入数据
- thisdelete: function(grid,me){
- grid.setLoading(true);
- Ext.Ajax.request({
- url: basePath + 'pm/make/thisdelete.action',
- params: {
- id: grid.ilid,
- caller : caller
- },
- callback: function(opt, s, r){
- if (!s) {
- grid.setLoading(false);
- showError('网络或系统错误!');return;
- }
- var res = Ext.decode(r.responseText);
- if(res.success) {
- grid.setLoading(false);
- alert('删除成功!');
- me.getDetails(Ext.getCmp('template'), caller, true);
- Ext.getCmp('check').hide();
- Ext.getCmp('toformal').hide();
- Ext.getCmp('thisdelete').hide();
- } else {
- grid.setLoading(false);
- showError(res.exceptionInfo);
- }
- }
- });
- }
- });
|