Ext 页面

@using Foxglobal.EDA.Addin.Web.Extensions;
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <title>EmailApprovalIndex</title>
    <link href="@Url.Content("~/Content/resources/css/ext-all.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Scripts/EXT/ux/css/ItemSelector.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/EXT/bootstrap.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Common_EdsConfigPage.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/EXT/ext-lang-zh_CN.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/EXT/datetime/dateTimePicker.js")"  type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/EXT/datetime/dateTimeField.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/Common_SelectItem.js")" type="text/javascript"></script>
    <style type="text/css">
        .x-form-itemselector-top
        {
            background-image: '@Url.Content("~/Scripts/EXT/ux/css/images/rightall.jpg")';
        }
        .x-form-itemselector-bottom
        {
            background-image: '@Url.Content("~/Scripts/EXT/ux/css/images/leftall.jpg")';
        }
    </style>
    <script type="text/javascript">

        Ext.Loader.setConfig({ enabled: true });
        Ext.Loader.setPath('Ext.ux', '@Url.Content("~/Scripts/Ext/ux")');


        Ext.require([
                'Ext.grid.*',
                'Ext.data.*',
                'Ext.util.*',
                'Ext.state.*',
                'Ext.form.Panel',
                'Ext.ux.form.MultiSelect',
                'Ext.ux.form.ItemSelector'
                ]);


        Ext.onReady(function () {
            Ext.QuickTips.init();    //初始化Ext.QuickTips,以使得tip提示可用
            var isFirst = true;
            if (Ext.isIE) {
                Ext.enableGarbageCollector = false;
            }
            Ext.apply(Ext.form.field.VTypes, {
                daterange: function (val, field) {
                    var beginDate = null,
                    beginDateCmp = null,
                    endDate = null,
                    endDateCmp = null,
                    validStatus = true;

                    if (field.daterange) {
                        //if (!Ext.isEmpty(field.daterange.begin)) {
                        beginDateCmp = Ext.getCmp(field.daterange.begin);
                        beginDate = beginDateCmp.getValue();
                        //}
                        //if (!Ext.isEmpty(field.daterange.end)) {
                        endDateCmp = Ext.getCmp(field.daterange.end);
                        endDate = endDateCmp.getValue();
                        //}
                    }
                    if (!Ext.isEmpty(beginDate) && !Ext.isEmpty(endDate)) {
                        validStatus = beginDate < endDate;
                    }
                    return validStatus;
                },

                daterangeText: '@Html.GetLocalText("Common_time")'
            });

            overrideItemSelector();

            Ext.regModel('EmailType', {
                fields: [{ name: 'type'}]
            });
            //定义组合框中显示的数据源   
            var postStore = Ext.create('Ext.data.Store', {
                model: 'EmailType',
                data: [
                        { type: 'IMAP' },
                        { type: 'IMAPS' },
                        { type: 'SMTP' },
                        { type: 'MAPI' }
                     ]
            });

            var RpostStore = Ext.create('Ext.data.Store', {
                model: 'EmailType',
                data: [
                        { type: 'IMAP' },
                        { type: 'IMAPS' },
                        { type: 'POP3' },
                        { type: 'POP3S' },
                        { type: 'MAPI' }
                     ]
            });


            Ext.regModel('YesNO', {
                fields: [{ name: 'yesorno'}]
            });
            //定义组合框中显示的数据源   
            var yesStore = Ext.create('Ext.data.Store', {
                model: 'YesNO',
                data: [
                        { yesorno: 'Y' },
                        { yesorno: 'N' }
                     ]
            });



            //定义全局维度的model
            Ext.define('DimensionModel', {
                extend: 'Ext.data.Model',
                fields: [
                            'DimensionId',
                            'DimensionName'
                        ]
            });
            var dimensionds = Ext.create('Ext.data.Store', {
                model: 'DimensionModel',
                proxy: {
                    type: 'ajax',
                    url: '@Url.Action("GetKeyDimensionByappID", "EmailConfig")' + location.search,
                    reader: {
                        type: 'json',
                        root: "datas",
                        totalProperty: 'results'
                    }
                },
                autoLoad: true,
                listeners: {
                    load: function () {
                        var index = dimensionds.find("DimensionName", SettedData.SETENTITY)
                        if (index > -1) {
                            Ext.getCmp("EntityDim").setValue(dimensionds.getAt(index).data.DimensionId);
                        }
                        var index1 = dimensionds.find("DimensionName", SettedData.SETSCENARIO)
                        if (index1 > -1) {
                            Ext.getCmp("ScenorioDim").setValue(dimensionds.getAt(index1).data.DimensionId);
                        }


                    }
                }
            });



            Ext.define('Adapter', {
                extend: 'Ext.data.Model',
                fields: ['text', 'id']
            });
            var adapterStore = Ext.create('Ext.data.Store', {
                autoLoad: true,
                model: 'Adapter',
                proxy: {
                    type: 'ajax',
                    url: '@Url.Action("GetApapterNamesByAppID", "EmailConfig")' + location.search
                },
                listeners: {
                    load: function () {
                        if (SettedData != undefined && SettedData.HFMStatusSync != undefined && SettedData.HFMStatusSync.SYNCADAPTER != undefined) {
                            Ext.getCmp("HFMSynsAdapter").setValue(SettedData.HFMStatusSync.SYNCADAPTER);
                        }
                        serverStore.load({ params: { adaid: Ext.getCmp("HFMSynsAdapter").getValue()} });
                        if (SettedData != undefined && SettedData.HFMStatusSync != undefined && SettedData.HFMStatusSync.SYNCADAPTERSERVER != undefined) {
                            Ext.getCmp("HFMSynsServer").setValue(SettedData.HFMStatusSync.SYNCADAPTERSERVER);
                        }
                    }
                }
            });








            Ext.define('Server', {
                extend: 'Ext.data.Model',
                fields: ['ASID', 'SERVERNAME']
            });
            var serverStore = Ext.create('Ext.data.Store', {
                autoLoad: false,
                model: 'Server',
                proxy: {
                    type: 'ajax',
                    url: '@Url.Action("GetAdapterServerByID", "EmailConfig")'
                }
            });




            //已选取的维度值信息model
            Ext.regModel("DimensionModel", {
                fields: ['DIMmemberName']
            });
            //已选取的维度值信息store
            var itemselectStore = Ext.create('Ext.data.Store', {
                autoLoad: false,
                model: 'DimensionModel',
                proxy: {
                    type: 'ajax',
                    url: '@Url.Action("GetDimensionMembers", "EmailConfig")',
                    reader: {
                        type: 'json'
                    }
                }, listeners: {
                    load: function () {
                        var itemSelect = Ext.getCmp("itemselector-Yfield");
                        itemSelect.displayField = 'DIMmemberName';
                        itemSelect.valueField = 'DIMmemberName';
                        itemSelect.bindStore(itemselectStore, false);
                        if (SettedData != undefined && SettedData.lstFiterEntity != undefined) {
                            var data = [];
                            for (var i = 0; i < SettedData.lstFiterEntity.length; i++) {
                                //data.push({ DIMmemberName: SettedData.lstFiterEntity[i].ENRITYCODE });
                                data.push(SettedData.lstFiterEntity[i].ENRITYCODE);
                            }
                            itemSelect.setValue(data);
                        }
                    }
                }
            });


            搜索
            function searchByName(servName, mutilSelect) {
                var viewModel = mutilSelect.boundList.getSelectionModel();
                var store = mutilSelect.store;
                if (store.count() === 0) {
                    Ext.Msg.alert('@Html.GetLocalText("WebAppAlert")', '@Html.GetLocalText("WebAppNoValueMatch")'); //没有搜索到匹配的项
                    return;
                }

                var startIndex = 0;              //从那行开始搜索
                var currSelectRecords = viewModel.getSelection();

                if (currSelectRecords.length > 0) {
                    startIndex = store.indexOf(currSelectRecords[0]) + 1;
                }
                //var currIndex = store.find("DIMmemberName", new RegExp(servName), startIndex,true,false);//这样还是区分大小写的
                var currIndex = store.find("DIMmemberName", servName, startIndex, true, false); //这样不区分大小写的
                viewModel.deselectAll();
                var rec = store.getAt(currIndex);
                var viewModel = mutilSelect.boundList.getSelectionModel();

                Ext.get(Ext.query(".list-ct", mutilSelect.getEl().dom)[0]).scrollTo('top', currIndex * 20);

                viewModel.select(rec, false, true);
            }





            //适配器POV全局映射,第一个tab页
            var emailApproval = Ext.widget('form', {
                height: 350,
                items: [
                {
                    xtype: 'fieldset',
                    columnWidth: 1,
                    title: '@Html.GetLocalText("WebEmailAppconfiguration")', //发送审批邮件邮箱配置
                    collapsible: true,
                    defaultType: 'textfield',
                    defaults: { anchor: '100%' },
                    layout: {
                        type: 'table',
                        tdAttrs: {
                            height: 50
                        },
                        columns: 2
                    },
                    items: [
                        {
                            xtype: 'combo',
                            name: 'SProtocol',
                            id: 'SProtocol',
                            fieldLabel: '@Html.GetLocalText("WebEmailAppType")', //类型
                            maxHeight: 300,
                            style: {
                                marginTop: 30
                            },
                            triggerAction: 'all', //单击触发按钮显示全部数据   
                            store: postStore, //设置数据源   
                            displayField: 'type', //定义要显示的字段   
                            valueField: 'type', //定义值字段   
                            queryMode: 'local', //本地模式   
                            forceSelection: true, //要求输入值必须在列表中存在   
                            allowBlank: false,
                            blankText: '@Html.GetLocalText("WebEmailProtocalNotEmpty")', //类型不能为空
                            typeAhead: true,
                            listeners: {
                                change: function (th, newValue, oldValue, eOpts) {
                                    if (newValue == 'MAPI') {
                                        Ext.getCmp("SStatus").hide();
                                        Ext.getCmp("SUserName").hide();
                                        Ext.getCmp("SPwd").hide();
                                        Ext.getCmp("SHost").hide();
                                        Ext.getCmp("SPort").hide();

                                        Ext.getCmp("SStatus").allowBlank = true;
                                        Ext.getCmp("SUserName").allowBlank = true;
                                        Ext.getCmp("SPwd").allowBlank = true;
                                        Ext.getCmp("SHost").allowBlank = true;
                                        Ext.getCmp("SPort").allowBlank = true;
                                        //Ext.Msg.alert('@Html.GetLocalText("WebAppAlert")', '请在服务器配置邮件Profile'); 
                                    }
                                    else {
                                        Ext.getCmp("SStatus").show();
                                        Ext.getCmp("SUserName").show();
                                        Ext.getCmp("SPwd").show();
                                        Ext.getCmp("SHost").show();
                                        Ext.getCmp("SPort").show();


                                        Ext.getCmp("SStatus").allowBlank = false;
                                        Ext.getCmp("SUserName").allowBlank = false;
                                        Ext.getCmp("SPwd").allowBlank = false;
                                        Ext.getCmp("SHost").allowBlank = false;
                                        Ext.getCmp("SPort").allowBlank = false;
                                    }
                                }


                            }
                        }
                       ,
                         {
                             xtype: 'combo',
                             name: 'SStatus',
                             id: 'SStatus',
                             fieldLabel: '@Html.GetLocalText("WebEmailAppTrust")', //是否信任
                             maxHeight: 300,
                             style: {
                                 marginLeft: 50
                             },
                             triggerAction: 'all', //单击触发按钮显示全部数据   
                             store: yesStore, //设置数据源   
                             displayField: 'yesorno', //定义要显示的字段   
                             valueField: 'yesorno', //定义值字段   
                             allowBlank: false,
                             blankText: '@Html.GetLocalText("WebEmailyesornoNotEmpty")', //是否信任不能为空
                             queryMode: 'local', //本地模式   
                             forceSelection: true, //要求输入值必须在列表中存在   
                             typeAhead: true
                         },
                          {
                              xtype: 'textfield',
                              name: 'SUserName',
                              id: 'SUserName',
                              fieldLabel: '@Html.GetLocalText("WebEmailAppUserName")', //用户名称
                              allowBlank: false,
                              blankText: '@Html.GetLocalText("WebEmailUserNotEmpty")', //用户名不能为空
                              style: {
                                  marginTop: 20
                              },
                              maxHeight: 300
                          },
                          {
                              xtype: 'textfield',
                              name: 'SPwd',
                              id: 'SPwd',
                              fieldLabel: '@Html.GetLocalText("WebEmailAppPwd")', //密码
                              style: {
                                  marginLeft: 50
                              },
                              inputType: "password",
                              allowBlank: false,
                              blankText: '@Html.GetLocalText("WebEmailPwdNotEmpty")', //密码不能为空
                              maxHeight: 300
                          },
                         {
                             xtype: 'textfield',
                             name: 'SHost',
                             id: 'SHost',
                             fieldLabel: '@Html.GetLocalText("WebEmailAppHost")', //主机
                             allowBlank: false,
                             blankText: '@Html.GetLocalText("WebEmailHostNotEmpty")', //主机不能为空
                             maxHeight: 300
                         },
                        {
                            xtype: 'textfield',
                            name: 'SPort',
                            id: 'SPort',
                            style: {
                                marginLeft: 50
                            },
                            fieldLabel: '@Html.GetLocalText("WebEmailPort")', //端口
                            allowBlank: false,
                            blankText: '@Html.GetLocalText("WebEmailPortNotEmpty")', //端口不能为空
                            regex: /^[0-9]*$/,
                            regexText: '@Html.GetLocalText("Common_Num")', //只能是数字
                            maxHeight: 300
                        }
                  ]
                },
                {
                    xtype: 'fieldset',
                    columnWidth: 1,
                    title: '@Html.GetLocalText("WebEmailAppRconfig")', //接收审批邮件邮箱配置
                    collapsible: true,
                    defaultType: 'textfield',
                    defaults: { anchor: '100%' },
                    layout: {
                        type: 'table',
                        tdAttrs: {
                            height: 20
                        },
                        columns: 2
                    },

                    fieldLabel: '@Html.GetLocalText("WebEmailAppRconfig")',
                    items: [
                       {
                           xtype: 'combo',
                           listConfig: {
                               maxHeight: 100//设置下拉列表的最大高度为60像素 
                           },
                           name: 'Protocol',
                           id: 'Protocol',
                           fieldLabel: '@Html.GetLocalText("WebEmailAppType")', //类型
                           maxHeight: 300,
                           style: {
                               marginTop: 20
                           },
                           triggerAction: 'all', //单击触发按钮显示全部数据   
                           store: RpostStore, //设置数据源   
                           displayField: 'type', //定义要显示的字段   
                           valueField: 'type', //定义值字段   
                           queryMode: 'local', //本地模式   
                           forceSelection: true, //要求输入值必须在列表中存在   
                           allowBlank: false,
                           blankText: '@Html.GetLocalText("WebEmailProtocalNotEmpty")', //类型不能为空
                           typeAhead: true,
                           listeners: {
                               change: function (th, newValue, oldValue, eOpts) {
                                   if (newValue == 'MAPI') {
                                       Ext.getCmp("RStatus").hide();
                                       Ext.getCmp("RUserName").hide();
                                       Ext.getCmp("RPwd").hide();
                                       Ext.getCmp("RHost").hide();
                                       Ext.getCmp("RPort").hide();

                                       Ext.getCmp("RStatus").allowBlank = true;
                                       Ext.getCmp("RUserName").allowBlank = true;
                                       Ext.getCmp("RPwd").allowBlank = true;
                                       Ext.getCmp("RHost").allowBlank = true;
                                       Ext.getCmp("RPort").allowBlank = true;
                                       //Ext.Msg.alert('@Html.GetLocalText("WebAppAlert")', '请在服务器配置邮件Profile'); 
                                   }
                                   else {
                                       Ext.getCmp("RStatus").show();
                                       Ext.getCmp("RUserName").show();
                                       Ext.getCmp("RPwd").show();
                                       Ext.getCmp("RHost").show();
                                       Ext.getCmp("RPort").show();

                                       Ext.getCmp("RStatus").allowBlank = false;
                                       Ext.getCmp("RUserName").allowBlank = false;
                                       Ext.getCmp("RPwd").allowBlank = false;
                                       Ext.getCmp("RHost").allowBlank = false;
                                       Ext.getCmp("RPort").allowBlank = false;
                                   }
                               }


                           }
                       }
                       ,
                         {
                             xtype: 'combo',
                             listConfig: {
                                 maxHeight: 60//设置下拉列表的最大高度为60像素 
                             },
                             name: 'RStatus',
                             id: 'RStatus',
                             fieldLabel: '@Html.GetLocalText("WebEmailAppTrust")', //是否信任
                             style: {
                                 marginLeft: 50
                             },
                             allowBlank: false,
                             blankText: '@Html.GetLocalText("WebEmailyesornoNotEmpty")', //是否信任不能为空
                             maxHeight: 300,
                             triggerAction: 'all', //单击触发按钮显示全部数据   
                             store: yesStore, //设置数据源   
                             displayField: 'yesorno', //定义要显示的字段   
                             valueField: 'yesorno', //定义值字段  
                             queryMode: 'local', //本地模式   
                             forceSelection: true, //要求输入值必须在列表中存在   
                             typeAhead: true
                         },
                        {
                            xtype: 'textfield',
                            name: 'RUserName',
                            id: 'RUserName',
                            fieldLabel: '@Html.GetLocalText("WebEmailAppUserName")', //用户名称
                            allowBlank: false,
                            blankText: '@Html.GetLocalText("WebEmailUserNotEmpty")', //用户名不能为空
                            maxHeight: 300
                        },
                        {
                            xtype: 'textfield',
                            name: 'RPwd',
                            id: 'RPwd',
                            fieldLabel: '@Html.GetLocalText("WebEmailAppPwd")', //密码
                            style: {
                                marginLeft: 50
                            },
                            allowBlank: false,
                            blankText: '@Html.GetLocalText("WebEmailPwdNotEmpty")', //密码不能为空
                            inputType: "password",
                            maxHeight: 300
                        },
                         {
                             xtype: 'textfield',
                             name: 'RHost',
                             id: 'RHost',
                             fieldLabel: '@Html.GetLocalText("WebEmailAppHost")', //主机
                             allowBlank: false,
                             blankText: '@Html.GetLocalText("WebEmailHostNotEmpty")', //主机不能为空
                             maxHeight: 300
                         },
                        {
                            xtype: 'textfield',
                            name: 'RPort',
                            id: 'RPort',
                            style: {
                                marginLeft: 50
                            },
                            fieldLabel: '@Html.GetLocalText("WebEmailPort")', //端口
                            allowBlank: false,
                            blankText: '@Html.GetLocalText("WebEmailPortNotEmpty")', //端口不能为空
                            regex: /^[0-9]*$/,
                            regexText: '@Html.GetLocalText("Common_Num")', //只能是数字
                            maxHeight: 300
                        }
                   ]
                }]
            });




            //适配器POV值转换规则,第二个tab页
            var PhaseSubmission = Ext.widget('form', {
                height: 350,
                autoScroll: true,
                items: [
                {
                    xtype: 'fieldset',
                    columnWidth: 1,
                    title: 'CheckBox',
                    collapsible: true,
                    height: 80,
                    style: {
                        paddingTop: 15
                    },

                    items: [{
                        xtype: 'checkboxgroup',
                        id: 'chgroup',
                        allowBlank: false,
                        blankText: '@Html.GetLocalText("WebEmailPhase")', //请至少选择一个Phase
                        items: [
                                    { boxLabel: '@Html.GetLocalText("WebEmailLevel1")', name: 'rb', id: 'Level1', inputValue: '@Html.GetLocalText("WebEmailLevel1")' }, //阶段一
                                    {boxLabel: '@Html.GetLocalText("WebEmailLevel2")', name: 'rb', id: 'Level2', inputValue: '@Html.GetLocalText("WebEmailLevel2")' },
                                    { boxLabel: '@Html.GetLocalText("WebEmailLevel3")', name: 'rb', id: 'Level3', inputValue: '@Html.GetLocalText("WebEmailLevel3")' },
                                    { boxLabel: '@Html.GetLocalText("WebEmailLevel4")', name: 'rb', id: 'Level4', inputValue: '@Html.GetLocalText("WebEmailLevel4")' },
                                    { boxLabel: '@Html.GetLocalText("WebEmailLevel5")', name: 'rb', id: 'Level5', inputValue: '@Html.GetLocalText("WebEmailLevel5")' },
                                    { boxLabel: '@Html.GetLocalText("WebEmailLevel6")', name: 'rb', id: 'Level6', inputValue: '@Html.GetLocalText("WebEmailLevel6")' },
                                    { boxLabel: '@Html.GetLocalText("WebEmailLevel7")', name: 'rb', id: 'Level7', inputValue: '@Html.GetLocalText("WebEmailLevel7")' },
                                    { boxLabel: '@Html.GetLocalText("WebEmailLevel8")', name: 'rb', id: 'Level8', inputValue: '@Html.GetLocalText("WebEmailLevel8")' },
                                    { boxLabel: '@Html.GetLocalText("WebEmailLevel9")', name: 'rb', id: 'Level9', inputValue: '@Html.GetLocalText("WebEmailLevel9")' }
                                ]
                    }]
                }]

            });



            //适配器参数配置,第三个tab页
            var selectEntity = Ext.widget('form', {
                height: 350,
                autoScroll: true,
                defaults: { anchor: '100%' },
                items: [
                {
                    xtype: 'fieldset',
                    columnWidth: 1,
                    collapsible: true,
                    defaults: { anchor: '100%' },
                    layout: {
                        type: 'table',
                        columns: 3
                    },
                    items: [
                    {
                        xtype: 'textfield',
                        labelWidth: 100,
                        id: 'Dim',
                        fieldLabel: '@Html.GetLocalText("Common_Dim")'//维度
                    },
                {
                    xtype: 'button',
                    colspan: 3,
                    text: '搜索',
                    icon: '@Url.Content("~/Content/images/search.png")',
                    handler: function () {
                        var inputName = Ext.getCmp("Dim").getValue();
                        var itemselector = Ext.getCmp("itemselector-Yfield");
                        var mutilSelect = itemselector.fromField;
                        searchByName(inputName, mutilSelect);
                    }
                }]
                },
                {
                    xtype: 'fieldset',
                    columnWidth: 1,
                    collapsible: true,
                    id: 'fieldset1',
                    defaults: { anchor: '100%' },
                    items: [{
                        xtype: 'itemselector',
                        name: 'itemselector',
                        id: 'itemselector-Yfield',
                        anchor: '100%',
                        height: 300,

                        autoScroll: true,
                        hideLabel: true,
                        buttons: ["top", "add", "remove", "bottom"],
                        buttonsText: {
                            top: "添加所有项",
                            add: "添加选中项",
                            remove: "移除选中项",
                            bottom: "移除所有项"
                        },
                        imagePath: '@Url.Content("~/ux/css/images/")',
                        store: itemselectStore,
                        allowBlank: false,
                        blankText: '@Html.GetLocalText("Common_SelectAtLeastOneDim")', //请至少选择一个可用用户和组
                        multiselects: [
                                    { listTitle: '@Html.GetLocalText("WebMetaDataAccessDim")', height: 300 }, //可用用户和组
                                    {listTitle: '@Html.GetLocalText("WebMetaDataSelectDim")', id: 'selected', height: 300}//选择用户和组
                                ],
                        displayField: 'DIMmemberName',
                        valueField: 'DIMmemberId',
                        msgTarget: 'side'

                    }]
                }]

            });


            //第四个Tab页
            var emailTil = Ext.widget('form', {
                height: 300,
                autoScroll: true,
                items: [{
                    xtype: 'fieldset',
                    collapsible: true,
                    defaultType: 'textfield',
                    defaults: { anchor: '100%' },
                    layout: {
                        type: 'table',
                        tdAttrs: {
                            height: 50
                        },
                        columns: 2
                    },
                    items: [
                        {
                            fieldLabel: '@Html.GetLocalText("WebEmailSTime")', //开始时间
                            width: 300,
                            allowBlank: false,
                            labelWidth: 100,
                            labelAlign: 'right',
                            xtype: 'datetimefield',
                            vtype: 'daterange',
                            daterange: { begin: 'StartTime', end: 'EndTime' },
                            allowBlank: false,
                            format: 'd',
                            id: "StartTime",
                            name: 'StartTime',
                            listeners: {
                                blur: function () {
                                    Ext.getCmp("EndTime").validate();
                                }
                            }
                        }, {
                            fieldLabel: '@Html.GetLocalText("WebEmailETime")', //结束时间
                            labelAlign: 'right',
                            labelWidth: 85,
                            width: 300,
                            allowBlank: false,
                            xtype: 'datetimefield',
                            vtype: 'daterange',
                            daterange: { begin: 'StartTime', end: 'EndTime' },
                            allowBlank: false,
                            format: 'd',
                            id: "EndTime",
                            name: 'EndTime',
                            listeners: {
                                blur: function () {
                                    Ext.getCmp("StartTime").validate();
                                }
                            }
                        }, {
                            xtype: 'radiogroup',
                            columns: 2,
                            fieldLabel: '@Html.GetLocalText("WebEmailArrange")', //范围
                            width: 400,
                            labelWidth: 85,
                            allowBlank: false,
                            style: {
                                marginLeft: 50
                            },
                            id: 'Arrange',
                            colspan: 2,
                            name: 'Entity',
                            items: [{ boxLabel: '@Html.GetLocalText("WebEmailAllEntity")', id: "All", name: 'Test', inputValue: '@Html.GetLocalText("WebEmailAllEntity")' }, //所有Entity
                                     {boxLabel: '@Html.GetLocalText("WebEmailScrEntity")', id: "Strong", name: 'Test', inputValue: '@Html.GetLocalText("WebEmailScrEntity")', checked: true}//报表筛选Entity成员
                                    ]
                        }, {
                            fieldLabel: '@Html.GetLocalText("WebEmailFre")', //频率
                            labelAlign: 'right',
                            labelWidth: 85,
                            width: 270,
                            id: 'Frequency',
                            allowBlank: false,
                            blankText: '@Html.GetLocalText("WebEmailFrenNotEmpty")', //频率不能为空
                            xtype: 'textfield'
                        }, {
                            xtype: 'label',
                            forId: 'myFieldId',
                            text: '@Html.GetLocalText("WebEmailHour")'//小时
                        }]
                }]

            });


            //第五个Tab页
            var stateSynchronization = Ext.widget('form', {
                height: 350,
                autoScroll: true,
                items: [{
                    xtype: 'fieldset',
                    columnWidth: 1,
                    collapsible: true,
                    defaultType: 'textfield',
                    defaults: { anchor: '100%' },
                    layout: {
                        type: 'table',
                        tdAttrs: {
                            height: 50
                        },
                        columns: 2
                    },
                    items: [{
                        xtype: 'combo',
                        listConfig: {
                            maxHeight: 60//设置下拉列表的最大高度为60像素 
                        },
                        name: 'HFMSynsAdapter',
                        id: 'HFMSynsAdapter',
                        fieldLabel: '@Html.GetLocalText("WebEmailAdapter")', //指定HFM状态同步适配器
                        labelWidth: 150,
                        width: 300,
                        forceSelection: true, //输入必存在
                        labelAlign: 'right',
                        maxHeight: 300,
                        allowBlank: false,
                        triggerAction: 'all', //单击触发按钮显示全部数据   
                        store: adapterStore, //设置数据源   
                        displayField: 'text', //定义要显示的字段   
                        valueField: 'id', //定义值字段   
                        queryMode: 'local', //本地模式   
                        forceSelection: true, //要求输入值必须在列表中存在   
                        typeAhead: true,
                        listeners: {
                            'select': function (combo, record, index) {
                                serverStore.load({ params: { adaid: Ext.getCmp("HFMSynsAdapter").getValue()} }); //需要修改
                            }
                        }
                    }, {
                        xtype: 'combo',
                        listConfig: {
                            maxHeight: 100//设置下拉列表的最大高度为60像素 
                        },
                        style: {
                            marginLeft: 20
                        },
                        name: 'HFMSynsServer',
                        id: 'HFMSynsServer',
                        fieldLabel: '@Html.GetLocalText("WebEmailServer")', //指定HFM状态同步服务
                        labelWidth: 150,
                        width: 400,
                        allowBlank: false,
                        forceSelection: true, //输入必存在
                        labelAlign: 'right',
                        maxHeight: 300,
                        triggerAction: 'all', //单击触发按钮显示全部数据   
                        store: serverStore, //设置数据源   
                        displayField: 'SERVERNAME', //定义要显示的字段   
                        valueField: 'ASID', //定义值字段   
                        queryMode: 'local', //本地模式   
                        forceSelection: true, //要求输入值必须在列表中存在   
                        typeAhead: true
                    }]
                }]
            });


            var isrender = false;
            //第六个Tab页
            var EmialCopy = Ext.widget('form', {
                height: 350,
                autoScroll: true,
                items: [
                {
                    xtype: 'fieldset',
                    columnWidth: 1,
                    collapsible: true,
                    height: 300,
                    columns: 2,
                    vertical: true,
                    style: {
                        paddingTop: 15
                    },
                    items: [
                    {
                        xtype: 'displayfield',
                        hideLabel: true,
                        colspan: 2,
                        value: '@Html.GetLocalText("WebEmailCCOption")'//此处设置发送邮件提醒时的抄送选项

                    }, {
                        xtype: 'checkboxgroup',
                        allowBlank: false,
                        columns: 1,
                        id: 'ccgroup',
                        vertical: true,
                        blankText: '@Html.GetLocalText("WebEmailLeastOneType")', //最少选择一种类型
                        items: [
                                    { boxLabel: '@Html.GetLocalText("WebEmailopenFixedAddr")', xtype: 'checkbox', id: 'FixedAddress', inputValue: '@Html.GetLocalText("WebEmailopenFixedAddr")', //开启固定地址抄送(请输入邮件地址,使用;分隔)
                                        listeners: {
                                            change: function (field, newValue, oldValue) {
                                                var email = Ext.getCmp("emailAddress");
                                                if (email == undefined) return;
                                                if (newValue && isrender) {
                                                    email.allowBlank = false;
                                                    email.blankText = '@Html.GetLocalText("WebEmailaddrnotempty")'; //邮件地址不能为空
                                                } else {
                                                    email.allowBlank = true;
                                                    email.clearInvalid();
                                                }
                                            }
                                        }

                                    },
                                    {
                                        xtype: 'textfield',
                                        name: 'RHostq',
                                        id: 'emailAddress',
                                        hideLabel: true,
                                        maxHeight: 300,
                                        listeners: {
                                            afterrender: function () {
                                                isrender = true;
                                            }
                                        }
                                    },
                                    { boxLabel: '@Html.GetLocalText("WebEmailcctoorag")', id: 'SameAddress', inputValue: '@Html.GetLocalText("WebEmailcctoorag")' //开启抄送给原抄送地址

                                    },
                                    { boxLabel: '@Html.GetLocalText("WebEmailcctooragper")', id: 'Sponsor', inputValue: '@Html.GetLocalText("WebEmailcctooragper")'}//开启抄送给发起人
                               ]
                    }]
                }]
            });
            var tabpanel = Ext.create('Ext.tab.Panel', {
                height: 400,
                layout: 'fit',
                id: 'tabpanel',
                activeTab: 0,
                items: [
                    {
                        title: '@Html.GetLocalText("WebEmailApproval")', //邮件审批
                        id: 'emailApproval',
                        items: emailApproval
                    },
                    {
                        title: '@Html.GetLocalText("WebEmailSubmission")', //Phase Submission
                        id: 'PhaseSubmission',
                        items: PhaseSubmission
                    },
                     {
                         title: '@Html.GetLocalText("WebEmailFilter")', //筛选报表Entity成员
                         id: 'selectEntity',
                         items: selectEntity
                     },
                    {
                        title: '@Html.GetLocalText("WebEmailTil")', //邮件提醒
                        id: 'emailTil',
                        items: emailTil
                    },
                    {
                        title: '@Html.GetLocalText("WebEmailStatusSyc")', //HFM状态同步
                        id: 'stateSynchronization',
                        items: stateSynchronization
                    },
                    {
                        title: '@Html.GetLocalText("WebEmailCopy")', //邮件抄送
                        id: 'EmialCopy',
                        items: EmialCopy
                    }
                ], listeners: {
                    tabchange: function (tabPanel, newCard, oldCard, eOpts) {
                        if (newCard.id == "selectEntity" && isFirst) {
                            itemselectStore.load({ params: { dimensionid: Ext.getCmp("EntityDim").getValue()} });
                            isFirst = false;
                        }
                    }
                }
            });


            var emailArr = {}, EmailReminder = {}, FiterEntityMember = [], HFMStatusSync = {}, PhaseSubmssion = [], EmailOption = {}, SettedData = {}, ccEmail = {};

            var stuForm = Ext.create('Ext.form.Panel', {
                labelWidth: 75, // label settings here cascade unless overridden
                frame: true,
                bodyStyle: 'padding:5px 5px 0',
                defaults: { anchor: '100%' },
                renderTo: Ext.getBody(),
                layout: 'fit',
                defaults: {
                    bodyPadding: 4
                },
                items: [{
                    xtype: 'fieldset',
                    columnWidth: 1,
                    title: '@Html.GetLocalText("WebEmailSetDim")', //指定视点维度
                    collapsible: true,
                    defaultType: 'textfield',
                    defaults: { anchor: '100%' },
                    layout: {
                        type: 'table',
                        columns: 4
                    },
                    items: [{
                        xtype: 'combo',
                        listConfig: {
                            maxHeight: 100//设置下拉列表的最大高度为60像素 
                        },
                        name: 'EntityDim',
                        id: 'EntityDim',
                        fieldLabel: '@Html.GetLocalText("WebEmailSetEntityDim")', //指定Entity维度
                        labelWidth: 90,
                        width: 300,
                        forceSelection: true, //要求输入值必须在列表中存在   
                        labelAlign: 'right',
                        maxHeight: 300,
                        triggerAction: 'all', //单击触发按钮显示全部数据   
                        displayField: 'DimensionName',
                        valueField: "DimensionId",
                        store: dimensionds,
                        queryMode: 'local', //本地模式   
                        typeAhead: true,
                        listeners: {
                            'select': function (combo, record, index) {
                                itemselectStore.load({ params: { dimensionid: combo.getValue()} });
                            }
                        }
                    }, {
                        xtype: 'combo',
                        listConfig: {
                            maxHeight: 100//设置下拉列表的最大高度为60像素 
                        },
                        style: {
                            marginLeft: 20
                        },
                        name: 'ScenorioDim',
                        id: 'ScenorioDim',
                        fieldLabel: '@Html.GetLocalText("WebEmailSetSceDim")', //指定Scenario维度
                        labelWidth: 120,
                        width: 300,
                        hidden: true,
                        forceSelection: true, //要求输入值必须在列表中存在   
                        labelAlign: 'right',
                        maxHeight: 300,
                        triggerAction: 'all', //单击触发按钮显示全部数据   
                        displayField: 'DimensionName',
                        valueField: "DimensionId",
                        store: dimensionds,
                        queryMode: 'local', //本地模式   
                        typeAhead: true
                    }]
                },


                {
                    xtype: 'fieldset',
                    columnWidth: 1,
                    collapsible: true,
                    height: 80,
                    style: {
                        paddingTop: 15
                    },

                    items: [{
                        xtype: 'checkboxgroup',
                        items: [
                                    { boxLabel: '@Html.GetLocalText("WebEmailopenApproval")', xtype: 'checkbox', name: 'rb', id: 'EnabledEMail', inputValue: '@Html.GetLocalText("WebEmailopenApproval")', //开启邮件审批
                                        listeners: {
                                            change: function (filed, newValue, oldValue, eOpts) {
                                                if (newValue) {
                                                    Ext.getCmp("emailApproval").setDisabled(false);
                                                }
                                                else {
                                                    Ext.getCmp("SProtocol").clearInvalid();
                                                    Ext.getCmp("SStatus").clearInvalid();
                                                    Ext.getCmp("SUserName").clearInvalid();
                                                    Ext.getCmp("SPwd").clearInvalid();
                                                    Ext.getCmp("SHost").clearInvalid();
                                                    Ext.getCmp("SPort").clearInvalid();
                                                    Ext.getCmp("Protocol").clearInvalid();
                                                    Ext.getCmp("RStatus").clearInvalid();
                                                    Ext.getCmp("RUserName").clearInvalid();
                                                    Ext.getCmp("RPwd").clearInvalid();
                                                    Ext.getCmp("RHost").clearInvalid();
                                                    Ext.getCmp("RPort").clearInvalid();
                                                    Ext.getCmp("emailApproval").setDisabled(true);
                                                }
                                            }
                                        }
                                    },
                                    { boxLabel: '@Html.GetLocalText("WebEmailopenSubmission")', name: 'rb', id: 'Phase', inputValue: '@Html.GetLocalText("WebEmailopenSubmission")', //开启Phase Submisstion
                                        listeners: {
                                            change: function (filed, newValue, oldValue, eOpts) {
                                                if (newValue) {
                                                    Ext.getCmp("PhaseSubmission").setDisabled(false);
                                                }
                                                else {
                                                    Ext.getCmp("chgroup").clearInvalid();
                                                    Ext.getCmp("PhaseSubmission").setDisabled(true);
                                                }
                                            }
                                        }
                                    },
                                    { boxLabel: '@Html.GetLocalText("WebEmailopenSetEntityDim")', name: 'rb', id: 'Member', inputValue: '@Html.GetLocalText("WebEmailopenSetEntityDim")', //开启筛选报表Entity成员
                                        listeners: {
                                            change: function (filed, newValue, oldValue, eOpts) {
                                                if (newValue) {
                                                    Ext.getCmp("itemselector-Yfield").setDisabled(false);
                                                    Ext.getCmp("selectEntity").setDisabled(false);
                                                }
                                                else {
                                                    Ext.getCmp("itemselector-Yfield").clearInvalid();
                                                    Ext.getCmp("selectEntity").setDisabled(true);
                                                    Ext.getCmp("itemselector-Yfield").setDisabled(true);
                                                }
                                            }
                                        }
                                    },
                                    { boxLabel: '@Html.GetLocalText("WebEmailopenTil")', name: 'rb', id: 'Reminder', inputValue: '@Html.GetLocalText("WebEmailopenTil")', //开启邮件提醒
                                        listeners: {
                                            change: function (filed, newValue, oldValue, eOpts) {
                                                if (newValue) {
                                                    Ext.getCmp("emailTil").setDisabled(false);
                                                }
                                                else {
                                                    Ext.getCmp("StartTime").clearInvalid();
                                                    Ext.getCmp("EndTime").clearInvalid();
                                                    Ext.getCmp("Frequency").clearInvalid();
                                                    Ext.getCmp("emailTil").setDisabled(true);
                                                }
                                            }
                                        }
                                    },
                                    { boxLabel: '@Html.GetLocalText("WebEmailopenStatusSysc")', name: 'rb', id: 'Sync', inputValue: '@Html.GetLocalText("WebEmailopenStatusSysc")', //开启HFM状态同步
                                        listeners: {
                                            change: function (filed, newValue, oldValue, eOpts) {
                                                if (newValue) {
                                                    Ext.getCmp("stateSynchronization").setDisabled(false);
                                                }
                                                else {
                                                    Ext.getCmp("HFMSynsAdapter").clearInvalid();
                                                    Ext.getCmp("HFMSynsServer").clearInvalid();
                                                    Ext.getCmp("stateSynchronization").setDisabled(true);
                                                }
                                            }
                                        }
                                    },
                                    { boxLabel: '@Html.GetLocalText("WebEmailopenCC")', name: 'rb', id: 'copy', inputValue: '@Html.GetLocalText("WebEmailopenCC")', //开启邮件抄送
                                        listeners: {
                                            change: function (filed, newValue, oldValue, eOpts) {
                                                if (newValue) {
                                                    Ext.getCmp("EmialCopy").setDisabled(false);
                                                }
                                                else {
                                                    Ext.getCmp("ccgroup").clearInvalid();
                                                    Ext.getCmp("emailAddress").clearInvalid();
                                                    var value = stuForm.getForm().isValid();
                                                    Ext.getCmp("EmialCopy").setDisabled(true);
                                                }
                                            }
                                        }
                                    }
                                ]
                    }]

                },



                 {
                     xtype: 'fieldset',
                     columnWidth: 1,
                     title: '@Html.GetLocalText("WebEmailSetDim")', //指定视点维度
                     collapsible: true,
                     defaultType: 'textfield',
                     defaults: { anchor: '100%' },
                     items: [tabpanel]
                 },
                 {
                     xtype: 'fieldset',
                     columnWidth: 1,
                     title: '@Html.GetLocalText("WebEmailopenattach")', //审批附件相关
                     collapsible: true,
                     height: 80,
                     layout: {
                         type: 'table',
                         columns: 4
                     },
                     style: {
                         paddingTop: 15
                     },

                     items: [{
                         xtype: 'textfield',
                         fieldLabel: '@Html.GetLocalText("WebEmailAttachMaxCount")', //最多添加附件个数
                         id: 'maxCount',
                         regex: /^[0-9]*$/,
                         regexText: '@Html.GetLocalText("Common_Num")', //只能是数字
                         name: 'maxCount'
                     }, {
                         xtype: 'textfield',
                         style: {
                             marginLeft: 50
                         },
                         fieldLabel: '@Html.GetLocalText("WebEmailAttachMaxLength")', //附件大小
                         id: 'maxSize',
                         regex: /^[0-9]*$/,
                         regexText: '@Html.GetLocalText("Common_Num")', //只能是数字
                         name: 'maxSize'
                     }, {
                         xtype: 'label',
                         style: {
                             marginLeft: 20
                         },
                         text: 'M'
                     }

                     ]

                 }
                ]//最外层的items
                ,
                buttons: [
                        {
                            text: '@Html.GetLocalText("WebAppSave")', //保存
                            handler: function () {
                                getPageData();
                                if (ValidInput(emailArr)) {
                                    Ext.Ajax.request({
                                        url: '@Url.Action("SetEmailApproval", "EmailConfig")',
                                        method: 'post',
                                        params: { jsonData: Ext.JSON.encode(emailArr) },
                                        callback: function (options, success, response) {
                                            var text = response.responseText;
                                            var obj = eval('(' + text + ')');
                                            Ext.Msg.alert('@Html.GetLocalText("WebAppAlert")', obj.msg);
                                        }
                                    });
                                }
                            }
                        }
                       ],
                listeners: {
                    afterrender: function () {
                        getDataBaseData();
                    }
                }
            });



            function alertMsg(msg, tab, control) {
                Ext.Msg.alert('@Html.GetLocalText("WebAppAlert")', msg); //请填写必填项
                control.markInvalid(msg);
                tabpanel.setActiveTab(tab);
            }

            /输入的校验方法
            function ValidInput(data) {
                var re = /^[0-9]*$/;
                var SProtocol = Ext.getCmp("SProtocol");
                var SStatus = Ext.getCmp("SStatus");
                var SUserName = Ext.getCmp("SUserName");
                var SPwd = Ext.getCmp("SPwd");
                var SHost = Ext.getCmp("SHost");
                var SPort = Ext.getCmp("SPort");
                var Protocol = Ext.getCmp("Protocol");
                var RStatus = Ext.getCmp("RStatus");
                var RUserName = Ext.getCmp("RUserName");
                var RPwd = Ext.getCmp("RPwd");
                var RPort = Ext.getCmp("RPort");
                var RHost = Ext.getCmp("RHost");

                var chgroup = Ext.getCmp("chgroup");

                var itemSelector = Ext.getCmp("itemselector-Yfield");

                var StartTime = Ext.getCmp("StartTime");
                var EndTime = Ext.getCmp("EndTime");
                var Arrange = Ext.getCmp("Arrange");
                var Frequency = Ext.getCmp("Frequency");

                var HFMSynsAdapter = Ext.getCmp("HFMSynsAdapter");
                var HFMSynsServer = Ext.getCmp("HFMSynsServer");

                var ccgroup = Ext.getCmp("ccgroup");
                var FixedAddress = Ext.getCmp("FixedAddress");
                var emailAddress = Ext.getCmp("emailAddress");
                var SameAddress = Ext.getCmp("SameAddress");
                var Sponsor = Ext.getCmp("Sponsor");

                var EntityDim = Ext.getCmp("EntityDim");
                var ScenorioDim = Ext.getCmp("ScenorioDim");
                var EnabledEMail = Ext.getCmp("EnabledEMail");
                var Phase = Ext.getCmp("Phase");
                var Member = Ext.getCmp("Member");
                var Reminder = Ext.getCmp("Reminder");
                var Sync = Ext.getCmp("Sync");
                var copy = Ext.getCmp("copy");

                 var maxSize = Ext.getCmp("maxSize");
                    if (!re.test(maxSize.getValue())) {
                        alertMsg('@Html.GetLocalText("Common_Num")', "emailApproval", maxSize);
                        return false;
                    }
                    var maxCount = Ext.getCmp("maxCount");
                    if (!re.test(maxCount.getValue())) {
                        alertMsg('@Html.GetLocalText("Common_Num")', "emailApproval", maxCount);
                        return false;
                    }

                    if (EntityDim.getValue() == undefined || EntityDim.getValue() == '') {
                        alertMsg('@Html.GetLocalText("Common_SelectDim")', "emailApproval", EntityDim);
                        return false;
                    }
                    if (maxCount.getValue() == undefined || maxCount.getValue() == '') {
                        alertMsg('@Html.GetLocalText("WebEmailMaxCountNotEmpty")', "emailApproval", maxCount);
                        return false;
                    }
                    if (maxSize.getValue() == undefined || maxSize.getValue() == '') {
                        alertMsg('@Html.GetLocalText("WebEmailAttachNotEmpty")', "emailApproval", maxSize);
                        return false;
                    }

                     

                if (data.ENABLEEMAILAPPROVAL) {//第1个tab的校验
                    if (SProtocol.getValue() == undefined || SProtocol.getValue() == '') {
                        alertMsg('@Html.GetLocalText("WebEmailProtocalNotEmpty")', "emailApproval", SProtocol);
                        return false;
                    }
                    if (SProtocol.getValue() != 'MAPI') {
                        if (SStatus.getValue() == undefined || SStatus.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailyesornoNotEmpty")', "emailApproval", SStatus);
                            return false;
                        }
                        if (SUserName.getValue() == undefined || SUserName.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailUserNotEmpty")', "emailApproval", SUserName);
                            return false;
                        }
                        if (SPwd.getValue() == undefined || SPwd.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailPwdNotEmpty")', "emailApproval", SPwd);
                            return false;
                        }
                        if (SHost.getValue() == undefined || SHost.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailHostNotEmpty")', "emailApproval", SHost);
                            return false;
                        }
                        if (SPort.getValue() == undefined || SPort.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailPortNotEmpty")', "emailApproval", SPort);
                            return false;
                        }
                    }
                    if (Protocol.getValue() == undefined || Protocol.getValue() == '') {
                        alertMsg('@Html.GetLocalText("WebEmailProtocalNotEmpty")', "emailApproval", Protocol);
                        return false;
                    }
                    if (Protocol.getValue() != 'MAPI') {
                        if (RStatus.getValue() == undefined || RStatus.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailyesornoNotEmpty")', "emailApproval", RStatus);
                            return false;
                        }
                        if (RUserName.getValue() == undefined || RUserName.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailUserNotEmpty")', "emailApproval", RUserName);
                            return false;
                        }
                        if (RPwd.getValue() == undefined || RPwd.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailPwdNotEmpty")', "emailApproval", RPwd);
                            return false;
                        }
                        if (RHost.getValue() == undefined || RHost.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailHostNotEmpty")', "emailApproval", RHost);
                            return false;
                        }
                        if (RPort.getValue() == undefined || RPort.getValue() == '') {
                            alertMsg('@Html.GetLocalText("WebEmailPortNotEmpty")', "emailApproval", RPort);
                            return false;
                        }
                        if (!re.test(RPort.getValue())) {
                            alertMsg('@Html.GetLocalText("Common_Num")', "emailApproval", RPort);
                            return false;
                        }
                        if (!re.test(SPort.getValue())) {
                            alertMsg('@Html.GetLocalText("Common_Num")', "emailApproval", SPort);
                            return false;
                        }
                    }
                   
                    if (!re.test(Frequency.getValue())) {
                        alertMsg('@Html.GetLocalText("Common_Num")', "emailApproval", Frequency);
                        return false;
                    }
                }
                if (data.ENABLEPHASESUBMISSION) {//第2个tab的校验
                    if (PhaseSubmssion == undefined || PhaseSubmssion.length == 0) {
                        alertMsg('@Html.GetLocalText("WebEmailPhase")', "PhaseSubmission", chgroup);
                        return false;
                    }
                }

                if (data.ENABLEFILTERENTITYMEMBER) {//第3个tab的校验
                    if (FiterEntityMember == undefined || FiterEntityMember.length == 0) {
                        Ext.Msg.alert('@Html.GetLocalText("WebAppAlert")', '@Html.GetLocalText("Common_SelectAtLeastOneDim")'); //请填写必填项
                        tabpanel.setActiveTab("selectEntity");
                        return false;
                    }
                }

                if (data.ENABLEEMAILREMINDER) {//第4个tab的校验
                    if (Frequency.getValue() == undefined || Frequency.getValue() == '') {
                        alertMsg('Frequency', "emailTil", Frequency);
                        return false;
                    }
                }

                if (data.ENABLEHFMSTATUSSYNC) {//第5个tab的校验
                    if (HFMSynsAdapter.getValue() == undefined || HFMSynsAdapter.getValue() == '') {
                        alertMsg('@Html.GetLocalText("WebEmailSyncAdapterNotEmpty")', "stateSynchronization", HFMSynsAdapter);
                        return false;
                    }
                    if (HFMSynsServer.getValue() == undefined || HFMSynsServer.getValue() == '') {
                        alertMsg('@Html.GetLocalText("WebEmailSyncServerNotEmpty")', "stateSynchronization", HFMSynsServer);
                        return false;
                    }
                }

                if (data.ENABLECCEMAIL) {//第6个tab的校验
                    if (FixedAddress.checked && emailAddress.getValue() == '') {
                        alertMsg('@Html.GetLocalText("WebEmailaddrnotempty")', "EmialCopy", FixedAddress); //地址必填
                        return false;
                    }
                    if (!FixedAddress.checked && !SameAddress.checked && !Sponsor.checked) {
                        alertMsg('@Html.GetLocalText("WebEmailLeastOneType")', "EmialCopy", Ext.getCmp("ccgroup"));
                        return false;
                    }

                }
                return true;
            }


            function getPageData() {
                emailArr = {}, EmailReminder = {}, FiterEntityMember = [], HFMStatusSync = {}, PhaseSubmssion = [], EmailOption = {}, ccEmail = {};
                var arrange = "";
                if (Ext.getCmp("All").checked) {
                    arrange = "All";
                }
                else {
                    arrange = "Report";
                }
                var stime = "";
                var etime = "";
                if (Ext.getCmp("StartTime").getValue() != undefined) {
                    stime = Ext.getCmp("StartTime").getValue().toString().substr(8, 2);
                }
                if (Ext.getCmp("EndTime").getValue() != undefined) {
                    etime = Ext.getCmp("EndTime").getValue().toString().substr(8, 2);
                }
                EmailReminder = { EMAILREMINDERSTARTDATE: stime, EMAILREMINDERENDDATE: etime,
                    EMAILREMINDERRANGE: arrange, EMAILREMINDERQUENCY: Ext.getCmp("Frequency").getValue()
                };

                var filterData = Ext.getCmp("itemselector-Yfield").getValue();
                if (filterData != undefined) {
                    for (var i = 0; i < filterData.length; i++) {
                        if (filterData[i].DIMmemberName == undefined) {
                            FiterEntityMember.push({ ENRITYCODE: filterData[i] });
                        }
                        else {
                            FiterEntityMember.push({ ENRITYCODE: filterData[i].DIMmemberName });
                        }
                    }
                }


                HFMStatusSync = { SYNCADAPTER: Ext.getCmp("HFMSynsAdapter").getValue(), SYNCADAPTERSERVER: Ext.getCmp("HFMSynsServer").getValue() };

                if (Ext.getCmp("Level1").checked) {
                    PhaseSubmssion.push({ PHASECODE: '1' });
                }
                if (Ext.getCmp("Level2").checked) {
                    PhaseSubmssion.push({ PHASECODE: '2' });
                }
                if (Ext.getCmp("Level3").checked) {
                    PhaseSubmssion.push({ PHASECODE: '3' });
                }
                if (Ext.getCmp("Level4").checked) {
                    PhaseSubmssion.push({ PHASECODE: '4' });
                }
                if (Ext.getCmp("Level5").checked) {
                    PhaseSubmssion.push({ PHASECODE: '5' });
                }
                if (Ext.getCmp("Level6").checked) {
                    PhaseSubmssion.push({ PHASECODE: '6' });
                }
                if (Ext.getCmp("Level7").checked) {
                    PhaseSubmssion.push({ PHASECODE: '7' });
                }
                if (Ext.getCmp("Level8").checked) {
                    PhaseSubmssion.push({ PHASECODE: '8' });
                }
                if (Ext.getCmp("Level9").checked) {
                    PhaseSubmssion.push({ PHASECODE: '9' });
                }


                EmailOption = { RECEIVEEMAILPROTOCOL: Ext.getCmp("Protocol").getValue(), RECEIVEEMAILUSERNAME: Ext.getCmp("RUserName").getValue(), RECEIVEEMAILHOSTNAME: Ext.getCmp("RHost").getValue(), RECEIVEPASSWORD: Ext.getCmp("RPwd").getValue(),
                    RECEIVEISTRUST: Ext.getCmp("RStatus").getValue(), SENDEMAILPROTOCOL: Ext.getCmp("SProtocol").getValue(), SENDEMAILPASSWORD: Ext.getCmp("SPwd").getValue(), RECEIVEEMAILPORT: Ext.getCmp("RPort").getValue(),
                    SENDEMAILUSERNAME: Ext.getCmp("SUserName").getValue(), SENDEMAILHOSTNAME: Ext.getCmp("SHost").getValue(), SENDEMAILISTUST: Ext.getCmp("SStatus").getValue(), SENDEMAILPORT: Ext.getCmp("SPort").getValue()
                };

                var index = dimensionds.find("DimensionId", Ext.getCmp("EntityDim").getValue());
                if (index > -1) {
                    var entity = dimensionds.getAt(index).data.DimensionName;
                }
                var index1 = dimensionds.find("DimensionId", Ext.getCmp("ScenorioDim").getValue());
                if (index1 > -1) {
                    var scrio = dimensionds.getAt(index1).data.DimensionName;
                }

                ccEmail = { ENABLEFIXEDCC: Ext.getCmp("FixedAddress").getValue(), ENABLEEMAILCC: Ext.getCmp("SameAddress").getValue(), ENABLECCTOSENDER: Ext.getCmp("Sponsor").getValue(), FIXEDCCADDRESS: Ext.getCmp("emailAddress").getValue() };
                emailArr = { ID: '@ViewData["appID"]', SETENTITY: entity, SETSCENARIO: scrio, ENABLEEMAILAPPROVAL: Ext.getCmp("EnabledEMail").getValue(), ENABLECCEMAIL: Ext.getCmp("copy").getValue(),
                    ENABLEPHASESUBMISSION: Ext.getCmp("Phase").getValue(), ENABLEFILTERENTITYMEMBER: Ext.getCmp("Member").getValue(), ENABLEEMAILREMINDER: Ext.getCmp("Reminder").getValue(),
                    ENABLEHFMSTATUSSYNC: Ext.getCmp("Sync").getValue(), MAXATTACHCOUNT: Ext.getCmp("maxCount").getValue(), MAXATTACHSIZE: Ext.getCmp("maxSize").getValue(),
                    EmailReminder: EmailReminder, lstFiterEntity: FiterEntityMember, HFMStatusSync: HFMStatusSync, lstPhaseSubmission: PhaseSubmssion, EmailOption: EmailOption, ccEmail: ccEmail
                };
            }


            function getDataBaseData() {
                Ext.Ajax.request({
                    url: '@Url.Action("GetEmailApproval", "EmailConfig")' + location.search,
                    method: 'get',
                    callback: function (options, success, response) {
                        try {
                            var text = response.responseText;
                            if (text == undefined || text == "") {//没有数据
                                Ext.getCmp("EnabledEMail").setValue("false");
                                Ext.getCmp("emailApproval").setDisabled(true);

                                Ext.getCmp("Phase").setValue("false");
                                Ext.getCmp("PhaseSubmission").setDisabled(true);

                                Ext.getCmp("Member").setValue("false");
                                Ext.getCmp("selectEntity").setDisabled(true);

                                Ext.getCmp("Reminder").setValue("false");
                                Ext.getCmp("emailTil").setDisabled(true);

                                Ext.getCmp("Sync").setValue("false");
                                Ext.getCmp("stateSynchronization").setDisabled(true);

                                Ext.getCmp("copy").setValue("false");
                                Ext.getCmp("EmialCopy").setDisabled(true);
                                return;
                            }
                            var obj = eval('(' + text + ')');
                            if (obj == undefined) return;
                            SettedData = obj;
                            if (obj.ENABLEEMAILAPPROVAL != null) {
                                Ext.getCmp("EnabledEMail").setValue(obj.ENABLEEMAILAPPROVAL.toLowerCase());
                                if (Ext.getCmp("EnabledEMail").checked) {
                                    Ext.getCmp("emailApproval").setDisabled(false);
                                } else {
                                    Ext.getCmp("emailApproval").setDisabled(true);
                                }
                            }
                            if (obj.ENABLEPHASESUBMISSION != null) {
                                Ext.getCmp("Phase").setValue(obj.ENABLEPHASESUBMISSION.toLowerCase());
                                if (Ext.getCmp("Phase").checked) {
                                    Ext.getCmp("PhaseSubmission").setDisabled(false);
                                } else {
                                    Ext.getCmp("PhaseSubmission").setDisabled(true);
                                }
                            }
                            if (obj.ENABLEFILTERENTITYMEMBER != null) {
                                Ext.getCmp("Member").setValue(obj.ENABLEFILTERENTITYMEMBER.toLowerCase());
                                if (Ext.getCmp("Member").checked) {
                                    Ext.getCmp("selectEntity").setDisabled(false);
                                } else {
                                    Ext.getCmp("selectEntity").setDisabled(true);
                                }
                            }
                            if (obj.ENABLEEMAILREMINDER != null) {
                                Ext.getCmp("Reminder").setValue(obj.ENABLEEMAILREMINDER.toLowerCase());
                                if (Ext.getCmp("Reminder").checked) {
                                    Ext.getCmp("emailTil").setDisabled(false);
                                } else {
                                    Ext.getCmp("emailTil").setDisabled(true);
                                }
                            }
                            if (obj.ENABLEHFMSTATUSSYNC != null) {
                                Ext.getCmp("Sync").setValue(obj.ENABLEHFMSTATUSSYNC.toLowerCase());
                                if (Ext.getCmp("Sync").checked) {
                                    Ext.getCmp("stateSynchronization").setDisabled(false);
                                } else {
                                    Ext.getCmp("stateSynchronization").setDisabled(true);
                                }
                            } //copy
                            if (obj.ENABLECCEMAIL != null) {
                                Ext.getCmp("copy").setValue(obj.ENABLECCEMAIL.toLowerCase());
                                if (Ext.getCmp("copy").checked) {
                                    Ext.getCmp("EmialCopy").setDisabled(false);
                                } else {
                                    Ext.getCmp("EmialCopy").setDisabled(true);
                                }
                            }

                            if (obj.MAXATTACHSIZE != null) {
                                Ext.getCmp("maxSize").setValue(obj.MAXATTACHSIZE.toLowerCase());
                            }
                            if (obj.MAXATTACHCOUNT != null) {
                                Ext.getCmp("maxCount").setValue(obj.MAXATTACHCOUNT.toLowerCase());
                            }
                            if (obj.EmailOption != null && obj.EmailOption.RECEIVEEMAILPROTOCOL != null) {
                                Ext.getCmp("Protocol").setValue(obj.EmailOption.RECEIVEEMAILPROTOCOL);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.RECEIVEEMAILUSERNAME != null) {
                                Ext.getCmp("RUserName").setValue(obj.EmailOption.RECEIVEEMAILUSERNAME);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.RECEIVEEMAILHOSTNAME != null) {
                                Ext.getCmp("RHost").setValue(obj.EmailOption.RECEIVEEMAILHOSTNAME);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.RECEIVEPASSWORD != null) {
                                Ext.getCmp("RPwd").setValue(obj.EmailOption.RECEIVEPASSWORD);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.RECEIVEISTRUST != null) {
                                Ext.getCmp("RStatus").setValue(obj.EmailOption.RECEIVEISTRUST);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.SENDEMAILUSERNAME != null) {
                                Ext.getCmp("SUserName").setValue(obj.EmailOption.SENDEMAILUSERNAME);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.SENDEMAILHOSTNAME != null) {
                                Ext.getCmp("SHost").setValue(obj.EmailOption.SENDEMAILHOSTNAME);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.SENDEMAILISTUST != null) {
                                Ext.getCmp("SStatus").setValue(obj.EmailOption.SENDEMAILISTUST);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.SENDEMAILPROTOCOL != null) {
                                Ext.getCmp("SProtocol").setValue(obj.EmailOption.SENDEMAILPROTOCOL);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.SENDEMAILPASSWORD != null) {
                                Ext.getCmp("SPwd").setValue(obj.EmailOption.SENDEMAILPASSWORD);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.RECEIVEEMAILPORT != null) {
                                Ext.getCmp("RPort").setValue(obj.EmailOption.RECEIVEEMAILPORT);
                            }
                            if (obj.EmailOption != null && obj.EmailOption.SENDEMAILPORT != null) {
                                Ext.getCmp("SPort").setValue(obj.EmailOption.SENDEMAILPORT);
                            }
                            if (obj.EmailReminder != undefined && obj.EmailReminder.EMAILREMINDERSTARTDATE != undefined) {
                                if (obj.EmailReminder.EMAILREMINDERSTARTDATE.toString().substr(1, 1) == ' ') {
                                    Ext.getCmp("StartTime").setValue('0' + obj.EmailReminder.EMAILREMINDERSTARTDATE.toString().substr(0, 1));
                                } else {
                                    Ext.getCmp("StartTime").setValue(obj.EmailReminder.EMAILREMINDERSTARTDATE);
                                }

                                if (obj.EmailReminder.EMAILREMINDERENDDATE.toString().substr(1, 1) == ' ') {
                                    Ext.getCmp("EndTime").setValue('0' + obj.EmailReminder.EMAILREMINDERENDDATE.toString().substr(0, 1));
                                } else {
                                    Ext.getCmp("EndTime").setValue(obj.EmailReminder.EMAILREMINDERENDDATE);
                                }
                                if (obj.EmailReminder.EMAILREMINDERRANGE == "AllEntity") {
                                    Ext.getCmp("All").setValue(true);
                                }
                                else {
                                    Ext.getCmp("All").setValue(false);
                                }
                                if (obj.EmailReminder != undefined && obj.EmailReminder.EMAILREMINDERQUENCY != undefined) {
                                    Ext.getCmp("Frequency").setValue(obj.EmailReminder.EMAILREMINDERQUENCY);
                                }
                            }
                            if (obj.lstFiterEntity != undefined) {
                                var data = [];
                                for (var i = 0; i < obj.lstFiterEntity.length; i++) {
                                    data.push({ DIMmemberName: obj.lstFiterEntity[i].ENRITYCODE });
                                }
                                Ext.getCmp("itemselector-Yfield").setValue(data);
                            }


                            if (obj.HFMStatusSync != undefined && obj.HFMStatusSync.SYNCADAPTER != undefined) {
                                Ext.getCmp("HFMSynsAdapter").setValue(obj.HFMStatusSync.SYNCADAPTER);
                            }
                            if (obj.HFMStatusSync != undefined && obj.HFMStatusSync.SYNCADAPTERSERVER != undefined) {
                                Ext.getCmp("HFMSynsServer").setValue(obj.HFMStatusSync.SYNCADAPTERSERVER);
                            }


                            if (obj.ccEmail != undefined && obj.ccEmail.ENABLEFIXEDCC != undefined) {
                                Ext.getCmp("FixedAddress").setValue(obj.ccEmail.ENABLEFIXEDCC.toLowerCase());
                            }
                            if (obj.ccEmail != undefined && obj.ccEmail.ENABLEEMAILCC != undefined) {
                                Ext.getCmp("SameAddress").setValue(obj.ccEmail.ENABLEEMAILCC.toLowerCase());
                            }
                            if (obj.ccEmail != undefined && obj.ccEmail.ENABLECCTOSENDER != undefined) {
                                Ext.getCmp("Sponsor").setValue(obj.ccEmail.ENABLECCTOSENDER.toLowerCase());
                            }
                            if (obj.ccEmail != undefined && obj.ccEmail.FIXEDCCADDRESS != undefined) {
                                Ext.getCmp("emailAddress").setValue(obj.ccEmail.FIXEDCCADDRESS.toLowerCase());
                            }

                            if (obj.lstPhaseSubmission != undefined) {
                                for (var i = 0; i < obj.lstPhaseSubmission.length; i++) {
                                    switch (obj.lstPhaseSubmission[i].PHASECODE) {
                                        case "Phase1":
                                            Ext.getCmp("Level1").setValue(true);
                                            break;
                                        case "Phase2":
                                            Ext.getCmp("Level2").setValue(true);
                                            break;
                                        case "Phase3":
                                            Ext.getCmp("Level3").setValue(true);
                                            break;
                                        case "Phase4":
                                            Ext.getCmp("Level4").setValue(true);
                                            break;
                                        case "Phase5":
                                            Ext.getCmp("Level5").setValue(true);
                                            break;
                                        case "Phase6":
                                            Ext.getCmp("Level6").setValue(true);
                                            break;
                                        case "Phase7":
                                            Ext.getCmp("Level7").setValue(true);
                                            break;
                                        case "Phase8":
                                            Ext.getCmp("Level8").setValue(true);
                                            break;
                                        case "Phase9":
                                            Ext.getCmp("Level9").setValue(true);
                                            break;
                                        default:
                                            break;
                                    }
                                }
                            }

                        }
                        catch (ex) {
                            Ext.Msg.alert(ex);
                        }

                    } //end callback
                });
            }
        });
    </script>
</head>
<body>
    <div id="grids">
    </div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/xiongxyt2/article/details/7929498
ext
今日推荐