`

从tree中谋取数据

 
阅读更多
/////////////////Select BusinessCategory (tree) jun.2011.07 Begin
    //    function customfields_build_SelectBusinessCategory_tree() {
    //        var departmentIDArr = new Array();
    //        Array.prototype.contains = function(element) {
    //            for (var i = 0; i < this.length; i++) {
    //                if (this[i] == element) {
    //                    return true;
    //                }
    //            }
    //            return false;
    //        }
    //
    //        var checkIDS = setting_customfieldsbuild_form.getForm().findField('category_id').getValue();
    //        if (checkIDS != "" && checkIDS != null) {
    //            departmentIDArr = checkIDS.split(',');
    //        }
    //
    //        function workflow_build_checkEachChildNode(treeNode) {
    //            var childLength = treeNode.childNodes.length;
    //            for (var i = 0; i < treeNode.childNodes.length; i++) {
    //                if (departmentIDArr.contains(treeNode.childNodes[i].id)) {
    //                    treeNode.childNodes[i].attributes.checked = true;//.select();//.checked=true;//toggleCheck(true);
    //                    if (!treeNode.childNodes[i].leaf) {
    //                        workflow_build_checkEachChildNode(treeNode.childNodes[i]);
    //                    }
    //                }
    //            }
    //        }
    //        Ext.getCmp('btnSelect').disable();
    //        var setting_customfield_BusinessCategory_treePanel = new Ext.tree.TreePanel({
    //            lines : true,
    //            containerScroll : true,
    //            autoScroll : true,
    //            //checkModel : 'single',
    //            checkModel : 'cascade',// 对树的级联多选 
    //            onlyLeafCheckable : false,//对树所有结点都可选 
    //            loader : new Ext.tree.TreeLoader({
    //                dataUrl : 'BLL/ModuleSystem/Setting/BusinessCategory/Operation.aspx?cmd=businessCategoryTree&rand=' + Math.round(Math.random() * (10000 - 1)).toString(),
    //                baseAttrs : {
    //                    uiProvider : Ext.tree.TreeCheckNodeUI
    //                }
    //            }),
    //            root : new Ext.tree.AsyncTreeNode({
    //                id : "root2",
    //                text : "选择业务品类",
    //                expanded : true
    //            })
    //        });
    //        if (checkIDS != "" && checkIDS != null) {
    //            setting_customfield_BusinessCategory_treePanel.expandAll();
    //        }
    //        setting_customfield_BusinessCategory_treePanel.on('load', workflow_build_checkEachChildNode);
    //        var setting_customfield_BusinessCategory_Form = new Ext.form.FormPanel({
    //            layout : 'form',
    //            labelAlign : 'top',
    //            layout : 'fit',
    //            bodyStyle : 'padding:20px',
    //            width : 400,
    //            labelWidth : 70,
    //            labelAlign : "right",
    //            autoScroll : true,
    //            items : [setting_customfield_BusinessCategory_treePanel],
    //            buttons : [{
    //                text : "选择",
    //                handler : function() {
    //                    var checkedNodes = setting_customfield_BusinessCategory_treePanel.getChecked();
    //                    var checkText = new Array;
    //                    var checkId = new Array;// 存放选中id的数组
    //                    for (var i = 0; i < checkedNodes.length; i++) {
    //                        checkText.push(checkedNodes[i].text);// 添加id到数组
    //                        checkId.push(checkedNodes[i].id);
    //                    }
    //                    var value = checkText.toString().replace(/\,/g, ';');
    //                    setting_customfieldsbuild_form.getForm().findField('TYPE').setValue(value);
    //                    setting_customfieldsbuild_form.getForm().findField('category_id').setValue(checkId.toString());
    //                    //                    Ext.getCmp('customfields_type_id').setValue(value);
    //                    //                    Ext.getCmp('businesscategory_id_hidden').setValue(checkId.toString());
    //                    Ext.getCmp('btnSelect').enable();
    //                    customfields_build_BusinessCategoryWin.close();
    //                }
    //            }, {
    //                text : "取消",
    //                handler : function() {
    //                    Ext.getCmp('btnSelect').enable();
    //                    customfields_build_BusinessCategoryWin.close();
    //                }
    //            }]
    //        });
    //        var customfields_build_BusinessCategoryWin = new Ext.Window({
    //            title : "选择业务品类",
    //            layout : 'fit',
    //            width : 400,
    //            height : 300,
    //            closeAction : 'destroy',
    //            autoScroll : true,
    //            plain : true,
    //            resizable : false,
    //            constrainHeader : true,
    //            items : setting_customfield_BusinessCategory_Form,
    //            listeners : {
    //                'beforedestroy' : function(p) {
    //                    Ext.getCmp('btnSelect').enable();
    //                }
    //            }
    //        });
    //        customfields_build_BusinessCategoryWin.show();
    //    }
    //    //End


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//CustomFields Setting FormPanel Begin
    var setting_customfieldsbuild_form = new Ext.form.FormPanel({

        id : 'setting_customfieldsbuild_form',
        layout : 'form',
        renderTo : 'customfieldstab',//customfieldstab为aspx页面定义好的div的id
        bodyStyle : 'padding:10px',
        width : 750,
        labelWidth : 70,
        labelAlign : "right",
        items : [new Ext.form.Hidden({
            name : 'ID',
            id : 'ID'
        }), {//字段名称(NAME)
            xtype : 'textfield',
            fieldLabel : "字段名称",
            //name : 'customfields_name',
            name : 'NAME',
            id : 'name_id',
            style : 'background:url(Resources/images/pen.gif) no-repeat 3px center;padding-left:15px;',
            allowBlank : false,
            blankText : "字段名称不能为空",
            width : 480
        }, {
            //字段格式(FORMAT)
            xtype : 'combo',
            fieldLabel : "类型",
            disabled : (customFields_id != null && customFields_id != "") ? true : false,
            name : 'FORMAT',
            id : 'setting_customfieldsbuild_type',
            hiddenName : 'FORMAT',
            selectOnFocus : true,
            style : 'background: url(Resources/images/pen.gif) no-repeat 3px center;padding-left:15px;',
            store : new Ext.data.SimpleStore({
                fields : ['value', 'text'],
                data : [['单行文本', '单行文本'], ['多行文本', '多行文本'], ['下拉列表', '下拉列表'], ['数字', '数字'], ['日期', '日期']]
            }),
            valueField : 'value',
            displayField : 'text',
            editable : false,
            typeAhead : true,
            mode : 'local',
            triggerAction : 'all',
            selectOnFocus : true,
            allowBlank : false,
            blankText : '类型不能为空',
            lazyRender : true,
            listeners : {
                'select' : function(box, record, index) {
                    var _form = this.ownerCt.getForm();
                    // alert(record.get('value'));//取到选择的值
                    var selectValue = record.get('value');
                    if (selectValue == "单行文本" || selectValue == "多行文本") {
                        Ext.getCmp('customfields_length_id').setVisible(true);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(false);//数字
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_length_id').allowBlank = false;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_length_id').blankText = "字段名称不能为空";
                        Ext.getCmp('customfields_min_length_id').allowBlank = true;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = true;//最大值(当为数字时为false)
                        Ext.getCmp('customfields_point_id').setVisible(false);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = true;//小数位数
                    } else if (selectValue == "下拉列表") {
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(true);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(true);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(true);//下拉列表
                        Ext.getCmp('customfields_length_id').setVisible(false);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(false);//数字
                        Ext.getCmp('customfields_length_id').allowBlank = true;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_min_length_id').allowBlank = true;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = true;//最大值(当为数字时为false)
                        Ext.getCmp('customfields_point_id').setVisible(false);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = true;//小数位数

                    } else if (selectValue == "数字") {
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_length_id').setVisible(false);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(true);//数字
                        Ext.getCmp('customfields_point_id').setVisible(true);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = false;//小数位数
                        Ext.getCmp('customfields_length_id').allowBlank = true;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_min_length_id').allowBlank = false;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = false;//最大值(当为数字时为false)
                    } else if (selectValue == "日期") {
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_length_id').setVisible(false);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(false);//数字
                        Ext.getCmp('customfields_length_id').allowBlank = true;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_min_length_id').allowBlank = true;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = true;//最大值(当为数字时为false)
                        Ext.getCmp('customfields_point_id').setVisible(false);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = true;//小数位数
                    }
                    // _form.findField('customfields_format_hidden').setValue(record.get('customfields_format'));
                }
            },
            width : 480

        }, {
            //长度(数据库中的最大长度MAX_LENGTH)(选择单行文本和多行文本时显示)
            xtype : 'numberfield',
            fieldLabel : '长度',
            id : 'customfields_length_id',
            // readOnly : (customFields_id != null && customFields_id != "") ? true : false,
            name : 'LENGTH',
            maxLength : 9,
            maxLengthText : '最大长度不能超过9位',
            style : 'background: url(Resources/images/pen.gif) no-repeat 3px center;padding-left:15px;',
            width : 480,
            hidden : true
        }, {
            //存放列表值(POSSIBLE_LIST)(下拉列表时显示)
            layout : 'tableform',
            id : 'customfields_possible_listtab_id',

            hidden : true,
            border : false,
            items : [{
                xtype : 'textfield',
                fieldLabel : '内容',
                // readOnly : (customFields_id != null && customFields_id != "") ? true : false,
                id : 'customfields_possible_list_id',
                width : 350
            }, {
                xtype : 'button',
                text : '添加',
                style : 'margin-left:10px;',
                id : 'customfields_possible_list_select_id',
                //disabled : (customFields_id != null && customFields_id != "") ? true : false,
                disabled : false,
                handler : function() {//选择业务品类
                    var _value = "";
                    var _customfields_possible_list = Ext.getCmp('customfields_possible_list_id').getValue();//从内容文本框中取到值
                    if (_customfields_possible_list == "") {
                        Ext.MessageBox.alert("提示", "请输入要添加的内容");//TODO::
                    } else {
                        var p = new tempSoteData({//实例化一个临时的store
                            FieldName : _customfields_possible_list,
                            FieldText : _customfields_possible_list
                        });
                        var kk = customFieldsPossibleListStore.getCount();
                        customFieldsPossibleListStore.insert(kk, p);//将这个临时的store插入到customFieldsPossibleListStore(列表值store)里  
                        //                   alert(Ext.getCmp('customfields_possible_lists_id').store.data);
                        customFieldsPossibleListStore.each(function(f) {
                            var _text = f.get('FieldText');
                            _value += "['" + _text + "','" + _text + "'],";
                        });
                        _value = _value.substring(0, _value.length - 1);
                        Ext.getCmp('setting_customfield_listValue').setValue(_value);
                    }
                }
            }, {
                //存放列表值的删除(下拉列表时显示)
                xtype : 'button',
                text : '删除',
                style : 'padding-left:10px;',
                id : 'customfields_possible_lists_delete_id',
                disabled : false,
                // disabled : (customFields_id != null && customFields_id != "") ? true : false,
                hidden : true,
                handler : function() {
                    //删除存放在这里面的值
                    try {
                        customFieldsPossibleListStore.remove(customField_Muil_SelectObject);//从Store中删除
                    }
                    catch (e) {
                        Ext.MessageBox.alert('警告', '请选择要删除的缺项');
                    }
                }
            }]

        }, new Ext.ux.Multiselect({
            legend : '',
            id : 'customfields_possible_lists_id',
            width : 480,
            height : 180,
            hidden : true,
            //readOnly : (customFields_id != null && customFields_id != "") ? true : false,
            name : 'POSSIBLE_LIST',
            labelSeparator : "",
            store : customFieldsPossibleListStore,
            dataFields : ["FieldName", "FieldText"],
            valueField : "FieldName",
            displayField : "FieldText",
            listeners : {
                'click' : function(v, index, node, e) {
                    //alert(this.view.getSelectedIndexes());//取到选择项的索引
                    //alert(customFieldsPossibleListStore.getAt(this.view.getSelectedIndexes()))//取到选择项的对象
                    customField_Muil_SelectObject = customFieldsPossibleListStore.getAt(this.view.getSelectedIndexes());//将选择的项附给变量
                }
            }
        }), {
            //小数位数
            xtype : 'numberfield',
            fieldLabel : "小数位数",
            id : 'customfields_point_id',
            //readOnly : (customFields_id != null && customFields_id != "") ? true : false,
            name : 'POINT',
            style : 'background:url(Resources/images/pen.gif) no-repeat 3px center;padding-left:15px;',
            allowBlank : false,
            blankText : "小数位数不能为空",
            maxLength : 5,
            maxLengthText : '最大长度不能超过5位',
            width : 480

        }, {//取值范围(选择数字时显示)
            layout : 'tableform',
            border : false,
            id : 'customfields_min_max_length_id',
            hidden : true,
            items : [{//最小长度(MIN_LENGTH)
                xtype : 'numberfield',
                fieldLabel : '取值范围',
                // name : 'customfields_min_length',
                name : 'MIN_LENGTH',
                id : 'customfields_min_length_id',
                //readOnly : (customFields_id != null && customFields_id != "") ? true : false,
                style : 'background: url(Resources/images/pen.gif) no-repeat 3px center;padding-left:15px;',
                maxLength : 5,
                maxLengthText : '最小长度不能超过5位',
                width : 200
            }, {
                xtype : 'label',
                text : '~',
                style : 'margin-left:30px;'
            }, {
                //最大长度(MAX_LENGTH)
                xtype : 'numberfield',
                labelSeparator : "",
                name : 'MAX_LENGTH',
                id : 'customfields_max_length_id',
                style : 'background: url(Resources/images/pen.gif) no-repeat 3px center;padding-left:15px;margin-left:-30px',
                validator : function() {
                    if (Ext.getCmp('customfields_min_length_id').getValue() && Ext.getCmp('customfields_max_length_id').getValue()) {
                        var max = Ext.getCmp('customfields_max_length_id').getValue();
                        var min = Ext.getCmp('customfields_min_length_id').getValue();
                        if (min > max) {
                            Ext.getCmp('customfields_max_length_id').invalidText = "最大长度不能小于最小长度";
                            return false;
                        } else {
                            Ext.getCmp('customfields_max_length_id').clearInvalid();
                            return true;
                        }
                    }
                    return true;
                },
                maxLength : 5,
                maxLengthText : '最大长度不能超过5位',
                width : 200
            }]

        }, {
            layout : 'tableform',
            border : false,
            style : 'padding-left:30px;',
            items : [{
                //是否必填(IS_REQUIRED)
                xtype : 'checkbox',
                checked : true,
                labelSeparator : '',
                labelStyle : 'font-size:20px;',
                style : 'margin-left:50px;font-size:22px;margin-bottom:5px; padding-left:20px',
                labelWidth : 250,
                hideLabel : true,
                boxLabel : "是否必填",
                readOnly : (customFields_id != null && customFields_id != "") ? true : false,
                name : 'IS_REQUIRED',
                inputValue : 1,
                id : 'customfields_is_required_id',
                inputValue : '1',
                listeners : {
                    'check' : function(check, isCheck) {
                        //                        if (isCheck) {
                        //                            Ext.getCmp('setting_customfields_is_required_hidden').setValue("1");
                        //                        } else {
                        //                            Ext.getCmp('setting_customfields_is_required_hidden').setValue("0");
                        //                        }
                    }
                },
                width : 120
            }]
        }, {
            //业务品类(类别TYPE)
            layout : 'tableform',
            border : false,
            items : [{
                xtype : 'textfield',
                fieldLabel : '业务品类',
                //readOnly : (customFields_id != null && customFields_id != "") ? true : false,
                name : 'TYPE',
                id : 'businesscategory_id',
                // id : 'customfields_type_id',
                readOnly : true,
                width : 350
            }, {
                xtype : 'button',
                text : '选择',
                style : 'margin-left:10px;',
                // disabled : (customFields_id != null && customFields_id != "") ? true : false,
                id : 'btnSelect',
                handler : customfields_build_SelectBusinessCategory
            }]
        }, {
            //正则格式(REGEXP)(预留字段)
            xtype : 'textfield',
            fieldLabel : '正则格式',
            //name : 'customfields_regexp',
            name : 'REGEXP',
            width : 480,
            hidden : true
        }, {
            //默认值(DEFAULT_VALUE)(预留字段)
            xtype : 'textfield',
            fieldLabel : '默认值',
            //name : 'customfields_default_value',
            name : 'DEFAULT_VALUE',
            width : 480,
            hidden : true
        }, new Ext.form.Hidden({//业务品类ID
            id : 'businesscategory_id_hidden',
            name : 'category_id'
        }), new Ext.form.Hidden({
            id : 'setting_customfield_listValue'
        }), new Ext.form.Hidden({
            id : 'setting_customFields_type_hidden',//类型
            name : 'customFields_type_hidden'
        })],
        buttons : [{
            //保存
            text : "保存",
            handler : setting_customfieldsbuild_save
        }, {
            //取消
            text : "重置",
            //disabled : (customFields_id != null && customFields_id != "") ? true : false,//todo
            handler : function() {
                setting_customfieldsbuild_form.form.reset();//清空表单(清空表单的数据)
            }
        }]
    });
    /**
     * 设置开始默认为单行文本
     */
    Ext.getCmp('setting_customfieldsbuild_type').setValue("单行文本");
    Ext.getCmp('customfields_length_id').setVisible(true);//单行文本和多行文本
    Ext.getCmp('customfields_min_max_length_id').setVisible(false);//数字
    Ext.getCmp('customfields_possible_listtab_id').setVisible(false);//下拉列表
    Ext.getCmp('customfields_possible_lists_id').setVisible(false);//下拉列表
    Ext.getCmp('customfields_possible_lists_delete_id').setVisible(false);//下拉列表
    Ext.getCmp('customfields_length_id').allowBlank = false;//长度,只有单行文本和多行文本时为false
    Ext.getCmp('customfields_length_id').blankText = "字段名称不能为空";
    Ext.getCmp('customfields_min_length_id').allowBlank = true;//最小值(当为数字时为false)
    Ext.getCmp('customfields_max_length_id').allowBlank = true;//最大值(当为数字时为false)
    Ext.getCmp('customfields_point_id').setVisible(false);//小数位数
    Ext.getCmp('customfields_point_id').allowBlank = true;//小数位数
    /**
     * dobind Of ModifyPage
     */
    Ext.Ajax.request({

        url : 'BLL/ModuleSystem/Setting/CustomField/Operation.aspx?cmd=dobind&&id=' + customFields_id + '&rand' + Math.round(Math.random() * (10000 - 1)).toString(),
        method : 'post',
        success : function(form, action) {
            //将请求返回的json串给form附值
            try {
                var value = Ext.decode(form.responseText);
                Ext.getCmp('setting_customfieldsbuild_type').setValue(value.FORMAT);
                Ext.getCmp('customfields_is_required_id').setValue(value.IS_REQUIRED);
                Ext.getCmp('businesscategory_id').setValue(value.BCNames);//业务品类名称
                Ext.getCmp('businesscategory_id_hidden').setValue(value.BCIDs);//业务品类IDS
                Ext.getCmp('name_id').setValue(value.NAME);
                Ext.getCmp('ID').setValue(value.ID);
                Ext.getCmp('setting_customFields_type_hidden').setValue(value.FORMAT);
                var format = value.FORMAT;
                switch (format) {
                    case "单行文本" :
                        Ext.getCmp('customfields_length_id').setValue(value.MAX_LENGTH);
                        Ext.getCmp('customfields_length_id').setVisible(true);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(false);//数字
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_length_id').allowBlank = false;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_length_id').blankText = "字段名称不能为空";
                        Ext.getCmp('customfields_min_length_id').allowBlank = true;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = true;//最大值(当为数字时为false)
                        Ext.getCmp('customfields_point_id').setVisible(false);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = true;//小数位数
                        break;
                    case "多行文本" :
                        Ext.getCmp('customfields_length_id').setValue(value.MAX_LENGTH);
                        Ext.getCmp('customfields_length_id').setVisible(true);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(false);//数字
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_length_id').allowBlank = false;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_length_id').blankText = "字段名称不能为空";
                        Ext.getCmp('customfields_min_length_id').allowBlank = true;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = true;//最大值(当为数字时为false)
                        Ext.getCmp('customfields_point_id').setVisible(false);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = true;//小数位数
                        break;
                    case "数字" :
                        Ext.getCmp('customfields_point_id').setValue(value.POINT);
                        Ext.getCmp('customfields_min_length_id').setValue(value.MIN_LENGTH);
                        Ext.getCmp('customfields_max_length_id').setValue(value.MAX_LENGTH);
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_length_id').setVisible(false);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(true);//数字
                        Ext.getCmp('customfields_point_id').setVisible(true);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = false;//小数位数
                        Ext.getCmp('customfields_length_id').allowBlank = true;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_min_length_id').allowBlank = false;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = false;//最大值(当为数字时为false)
                        break;
                    case "日期" :
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(false);//下拉列表
                        Ext.getCmp('customfields_length_id').setVisible(false);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(false);//数字
                        Ext.getCmp('customfields_length_id').allowBlank = true;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_min_length_id').allowBlank = true;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = true;//最大值(当为数字时为false)
                        Ext.getCmp('customfields_point_id').setVisible(false);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = true;//小数位数
                        break;
                    case "下拉列表" :
                        //赋值
                        var temp = "{'list':[" + value.POSSIBLE_LIST + "]}";
                        temp = Ext.decode(temp);
                        var _value = " " + value.POSSIBLE_LIST + "";
                        Ext.getCmp('setting_customfield_listValue').setValue(_value);
                        customFieldsPossibleListStore.loadData(temp.list);
                        Ext.getCmp('customfields_possible_listtab_id').setVisible(true);//下拉列表
                        Ext.getCmp('customfields_possible_lists_id').setVisible(true);//下拉列表
                        Ext.getCmp('customfields_possible_lists_delete_id').setVisible(true);//下拉列表
                        Ext.getCmp('customfields_length_id').setVisible(false);//单行文本和多行文本
                        Ext.getCmp('customfields_min_max_length_id').setVisible(false);//数字
                        Ext.getCmp('customfields_length_id').allowBlank = true;//长度,只有单行文本和多行文本时为false
                        Ext.getCmp('customfields_min_length_id').allowBlank = true;//最小值(当为数字时为false)
                        Ext.getCmp('customfields_max_length_id').allowBlank = true;//最大值(当为数字时为false)
                        Ext.getCmp('customfields_point_id').setVisible(false);//小数位数
                        Ext.getCmp('customfields_point_id').allowBlank = true;//小数位数
                        break;
                }
            }
            catch (e) {
                // alert(e + '\r\n\r\n' + e.stack)
            }
        },
        failure : function(form, action) {
            Ext.MessageBox.hide();
            Ext.MessageBox.alert("失败", "请求失败")
        }
    });
    //End
    //Save CustomFields Of BusinessCategory  //Begin
    function setting_customfieldsbuild_save() {
        //alert("新建业务品类自定义字段保存");
        if (setting_customfieldsbuild_form.form.isValid()) {
            if (customFields_id != null && customFields_id != "") {
                //修改
                Ext.Ajax.request({
                    url : 'BLL/ModuleSystem/Setting/CustomField/Operation.aspx?cmd=modifyCustomFields&&id=' + customFields_id + '&rand' + Math.round(Math.random() * (10000 - 1)).toString(),
                    method : 'post',
                    params : setting_customfieldsbuild_form.getForm().getValues(),
                    success : function(form, action) {
                        if (form.responseText == "OK") {
                            Ext.MessageBox.alert("提示", "修改成功");
                            Ext.getCmp('doc-body').remove(Ext.getCmp('doc-body').activeTab, true);
                            Ext.getCmp('doc-body').loadClass('ModuleSystem/Setting/CustomField/Main.aspx', "字段设置", 'usericon');
                            Ext.getCmp('setting_customfieldslist_grid').getStore().reload();
                        } else {
                            Ext.MessageBox.alert("警告", "修改失败");
                        }
                    },
                    failure : function(form, action) {
                        Ext.MessageBox.hide();
                        Ext.MessageBox.show({
                            title : "修改失败",
                            msg : "自定义字段修改失败",
                            buttons : Ext.Msg.OK,
                            icon : Ext.MessageBox.ERROR
                        });
                    }
                });
            } else {
                //添加
                Ext.Ajax.request({
                    url : 'BLL/ModuleSystem/Setting/CustomField/Operation.aspx?cmd=addCustomFields' + '&rand' + Math.round(Math.random() * (10000 - 1)).toString(),
                    method : 'post',
                    params : setting_customfieldsbuild_form.getForm().getValues(),//params : {'queryInfo.userId':userId}
                    success : function(form, action) {
                        if (form.responseText == "OK") {
                            Ext.MessageBox.alert("提示", "添加成功");
                            Ext.getCmp('doc-body').remove(Ext.getCmp('doc-body').activeTab, true);
                            Ext.getCmp('doc-body').loadClass('ModuleSystem/Setting/CustomField/Main.aspx', "字段设置", 'usericon');
                            Ext.getCmp('setting_customfieldslist_grid').getStore().reload();
                        } else {
                            Ext.MessageBox.alert("警告", "添加失败");
                        }
                    },
                    failure : function(form, action) {
                        Ext.MessageBox.hide();
                        Ext.MessageBox.show({
                            title : "添加失败",
                            msg : "自定义字段添加失败",
                            buttons : Ext.Msg.OK,
                            icon : Ext.MessageBox.ERROR
                        });
                    }
                });
            }
        }
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics