123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.ma.HelpDocScan', {
- extend: 'Ext.app.Controller',
- stores: ['TreeStore'],
- views: ['common.main.TreePanel','ma.logic.Config', 'core.form.ColorField','core.form.FileField',
- 'common.main.Toolbar','core.trigger.SearchField', 'core.trigger.DbfindTrigger'],
- FormUtil:Ext.create('erp.util.FormUtil'),
- refs: [{
- ref: 'tree',
- selector: '#tree-panel'
- },{
- ref: 'tabPanel',
- selector: '#tabpanel'
- }],
- init: function(){
- var me = this;
- me.FormUtil = Ext.create('erp.util.FormUtil');
- me.Toast = Ext.create('erp.view.core.window.Toast');
- this.control({
- 'erpTreePanel': {
- itemmousedown: function(selModel, record){
- Ext.defer(function(){
- me.onNodeClick(selModel, record);
- }, 20);
- },
- beforerender: function(tree) {
- if(window.whoami)
- tree.hide();
- },
- afterrender: function(){
- var panel = parent.Ext.getCmp('tree-panel');
- if(panel && !panel.collapsed) {
- panel.toggleCollapse();
- }
- }
- },
- 'button[itemId=btn-save]':{
- click:function(btn){
- me.setHelpDoc(btn.ownerCt.ownerCt);
- }
- },
- 'button[id=btn-scan]':{
- click:function(btn){
- me.scan();
- }
- },
- 'textfield[name=CALLER_]':{
- change:function(field){
- Ext.defer(function(){
- var field=Ext.ComponentQuery.query('textfield[name=CALLER_]')[0];
- var mfield=field.ownerCt.down('mfilefield[name=PATH_]');
- if(mfield.items.items[0].value){
- mfield.download(mfield.items.items[0].value);
- }
- },100);
-
- }
- }
- });
- },
- onNodeClick: function(selModel, record){
- var me = this;
- if (record.get('leaf')) {
- caller=record.raw.caller;
- me.scan(caller);
- } else {
- if(record.isExpanded() && record.childNodes.length > 0){
- record.collapse(true, true);// 已展开则收拢
- } else {
- //未展开看是否加载了children
- if(record.childNodes.length == 0){
- me.getChildren(record);
- } else {
- record.expand(false, true);//展开
- }
- }
- }
- },
- scan:function(){
- Ext.Ajax.request({
- url: basePath + 'ma/help/scan.action?caller=' + caller,
- method: 'GET',
- callback: function(opt, s, r) {
- if(r && r.status == 200) {
- var res = Ext.JSON.decode(r.responseText);
- if(!res.path){
- res.path='jsps/ma/helpdocremind.html';
- }
- var panel=Ext.getCmp('doc-panel');
- panel.removeAll();
- panel.add({
- tag : 'iframe',
- layout : 'fit',
- html : '<iframe src="' + basePath + res.path + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
- });
- }
- }
- });
- },
- refreshScan:function(bool){
- var btn=Ext.getCmp('btn-scan');
- if(btn) btn.setDisabled(!bool);
- },
- /**
- * 从后台加载树节点
- */
- getChildren: function(record) {
- var tree = this.getTree();
- tree.setLoading(true, tree.body);
- Ext.Ajax.request({//拿到tree数据
- url : basePath + 'common/lazyTree.action',
- params: {
- parentId: record.get('id')
- },
- callback : function(opt, s, r){
- tree.setLoading(false);
- var res = new Ext.decode(r.responseText);
- if(res.tree && record.childNodes.length == 0){
- record.appendChild(res.tree);
- record.expand(false, true);//展开
- } else if(res.exceptionInfo){
- showError(res.exceptionInfo);
- }
- }
- });
- },
- getSetting: function(caller, title){
- var me = this;
- if(caller) {
- if(caller != me.currCaller) {
- me.loadConfigs(caller, function(configs){
- me.currCaller = caller;
- me.setConfigs(configs);
- title && me.getConfigPanel().setTitle(title);
- });
- me.loadInterceptors(caller, function(interceptors){
- me.setInterceptors(interceptors);
- var tab = me.getTabPanel();
- if(interceptors.length == 0 && !tab.collapsed)
- tab.collapse();
- else if(interceptors.length > 0 && tab.collapsed)
- tab.expand();
- });
- }
- } else {
- me.currCaller = null;
- }
- },
- /**
- * 配置参数
- */
- loadConfigs: function(caller, callback) {
- Ext.Ajax.request({
- url: basePath + 'ma/setting/configs.action?caller=' + caller,
- method: 'GET',
- callback: function(opt, s, r) {
- if(r && r.status == 200) {
- var res = Ext.JSON.decode(r.responseText);
- callback.call(null, res);
- }
- }
- });
- },
- /**
- * 配置逻辑
- */
- loadInterceptors: function(caller, callback) {
- Ext.Ajax.request({
- url: basePath + 'ma/setting/interceptors.action?caller=' + caller,
- method: 'GET',
- callback: function(opt, s, r) {
- if(r && r.status == 200) {
- var res = Ext.JSON.decode(r.responseText);
- callback.call(null, res);
- }
- }
- });
- },
- setConfigs: function(configs) {
- var me = this, pane = me.getConfigPanel(), items = [];
- Ext.Array.each(configs, function(c, i){
- switch(c.data_type) {
- case 'YN':
- items.push({
- xtype: 'checkbox',
- boxLabel: c.title,
- name: c.code,
- id: c.id,
- checked: c.data == 1,
- columnWidth: 1,
- margin: c.help ? '4 8 0 8' : '4 8 4 8'
- });
- break;
- case 'RADIO':
- var s = [];
- Ext.Array.each(c.properties, function(p){
- s.push({
- name: c.code,
- boxLabel: p.display,
- inputValue: p.value,
- checked: p.value == c.data
- });
- });
- items.push({
- xtype: 'radiogroup',
- id: c.id,
- fieldLabel: c.title,
- columnWidth: 1,
- columns: 2,
- vertical: true,
- items: s
- });
- break;
- case 'COLOR':
- items.push({
- xtype: 'colorfield',
- fieldLabel: c.title,
- id: c.id,
- name: c.code,
- value: c.data,
- readOnly: c.editable == 0,
- editable: c.editable == 1,
- labelWidth: 150
- });
- break;
- case 'NUMBER':
- items.push({
- xtype: 'numberfield',
- fieldLabel: c.title,
- id: c.id,
- name: c.code,
- value: c.data,
- readOnly: c.editable == 0,
- labelWidth: 150
- });
- break;
- default :
- if(c.multi == 1) {
- var data = c.data ? c.data.split('\n') : [null], s = [];
- Ext.Array.each(data, function(d){
- s.push({
- xtype: (c.dbfind ? 'dbfindtrigger' : 'textfield'),
- name: c.dbfind || c.code,
- value: d,
- readOnly: !c.dbfind && c.editable == 0,
- editable: c.editable == 1,
- clearable: true
- });
- });
- s.push({
- xtype: 'button',
- text: '添加',
- width: 22,
- cls: 'x-dd-drop-ok-add',
- iconCls: 'x-dd-drop-icon',
- iconAlign: 'right',
- config: c
- });
- items.push({
- xtype: 'fieldset',
- title: c.title,
- id: c.id,
- name: c.code,
- columnWidth: 1,
- layout: 'column',
- defaults: {
- columnWidth: .25,
- margin: '4 8 4 8'
- },
- items: s
- });
- } else {
- items.push({
- xtype: (c.dbfind ? 'dbfindtrigger' : 'textfield'),
- fieldLabel: c.title,
- id: c.id,
- name: c.dbfind || c.code,
- value: c.data,
- readOnly: !c.dbfind && c.editable == 0,
- editable: c.editable == 1,
- clearable: true,
- columnWidth: .5,
- labelWidth: 150
- });
- }
- break;
- }
- if(c.help) {
- items.push({
- xtype: 'displayfield',
- value: c.help,
- columnWidth: ['NUMBER', 'VARCHAR2'].indexOf(c.data_type) > -1 ? .5 : 1,
- cls: 'help-block',
- margin: '4 8 8 8'
- });
- } else {
- if(['NUMBER', 'VARCHAR2'].indexOf(c.data_type) > -1) {
- items.push({
- xtype: 'displayfield'
- });
- }
- }
- });
- pane.removeAll();
- if(items.length == 0)
- items.push({
- html: '没有参数配置',
- cls: 'x-form-empty'
- });
- pane.add(items);
- },
- /**
- * 字符长度
- */
- getCharLength: function(str) {
- if(str) {
- for (var len = str.length, c = 0, i = 0; i < len; i++)
- str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126 ? c += 2 : c++;
- return c;
- }
- return 0;
- }
- });
|