xinyb_
2022-03-09 adafe008090dd068cb85a884818e32dd372cf982
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
 
(function($){        
    //加载
    $.loading=function(options){    
        var set = $.extend({
            'dbid'        : '-1',
            'isAppend'    : false,
            'hostUrl'     :'',
            'wxQuery'     : '',
            'RequestURL'  : '',
            'data_base_id': 'data_base_id'
        }, options);
        $('a').click(function(){//按钮点击进入    
            var _this=this;
            switch(this.id) {            
             case 'restart'://重启服务
                    $(this).linkbutton('disable');
                    $.post('/setXml.do?chqi=1',function(date){
                         $(this).linkbutton('enable');
                         Tips(date);
                         $.post("/500.jsp",function(data){});
                         window.location.reload();
                    });
                   break;
             case 'synchronization'://同步数据源
                 $.post('/SyncDataSource.do','',function(date){
                        Tips(date);
                     });
                break;
                
             case 'getSystemAccessKey'://获取代理商编码
                   getSystemAccesskey();
                break;
                
             case 'getInvitationCode'://获取邀请码
                   getInvitationCode();
                break;
             case 'test'://测试连接,生成(xml),保存
             case 'generate':
             case 'save':    
             case 'logodel':
                 ajaxLoading();    
                 //注释原因:用easyUi的 form表单提交在谷歌版本: 83.0.4103.97(正式版本)提交不了。-xin 2020-6-11 09:41:23
//                 $('#submit').form('submit', {
//                     url: '/setXml.do?testConn='+(this.id=='test'?1:0)+'&logodel='+(this.id=='logodel'?1:0),
//                     onSubmit: function(param){                     
//                          param.id=set.dbid;
//                          var bol=data(param,set.isAppend);
//                          if(bol){
//                             ajaxLoadEnd();
//                             return false;                             
//                          }//验证
//                     },    
                    var param={};
                    param.id=set.dbid;
                    var bol=data(param,set.isAppend);
                    if(bol){
                         ajaxLoadEnd();
                         return false;                             
                      }//验证
                    var formdata=new FormData($("#submit")[0]);
                    for(var f in param){
                        formdata.append(f,param[f]);
                    }
                    $.ajax({url:'/setXml.do?testConn='+(this.id=='test'?1:0)+'&logodel='+(this.id=='logodel'?1:0),type: "POST" 
                           ,data:formdata,processData:false,contentType:'multipart/form-data',
                     success: function(data){
                         try{
                             var json=eval('('+data+')');                             
                             Tips(json.info);
                             if(_this.id=='generate' && json.state!=2){
                                 window.location.href='/demo/update1.jsp?id=-1';
                             }else if(_this.id=='logodel' || _this.id=='save'){//保存后刷新界面
                                 setTimeout(function(){
                                     window.location.reload();        
                                 },2000 );                                         
                             }
                             ajaxLoadEnd();                             
                         }catch(e){
                             
                         }                        
                    },error:function(e1,e2){
                        Tips(e1.responseText);
                    }
                });
                 break;
             case 'modify'://页面跳转
                 if(parent.addTab){
                     parent.addTab(this.title,'','','',this.type,'');
                 }else{
                     window.open(this.type);
                 }
                 break;    
             case 'doExit'://生成配置文件
                 $.post("/setXml.do",'',function(date){
                        Tips(date);
                     });
                 break;
             case 'reload'://刷新
                 window.location.reload();
                 break;
             case 'refreshDataSourceDataSize'://刷新数据库使用情况
                 getrefreshDataSourceDataSize(set);
                 break;
             case 'doStopAction'://(启用/禁止)系统            
                 var action=this.title;
                 var id=this.type;
                 if(action == "stop"){
                     $.messager.confirm('提示', '是否真的停止系统,如果选【确定】,则系统将立即停止访问?', function(r){
                         if(r){
                             getStopAndStart(action,id,set);
                         }
                     });
                 }else{
                     getStopAndStart(action,id,set);
                 }
//                 if (action == "stop" && ! confirm("是否真的停止系统,如果选【确定】,则系统将立即停止访问!")) {
//                        return ;
//                 }        
//                 getStopAndStart(action,id,set);
                 break;
             case 'doDel'://删除一个数据库
                 var op=this.type;
                 $.messager.confirm('删除', '确认删除【'+this.name+'】数据库吗?', function(r){
                       if (r){
                            $.post("/doDelDemo.do",{"op":op},function(json){
                                if (json['hint']) {
                                    alert(json['hint']);
                                }                            
                                if (json['error']) {
                                    Tips(json['error']) ;
                                    ajaxLoadEnd();
                                    return ;
                                }    
                                
                                  window.location.reload(true);
                              });
                       }
                 });                    
                 break;
             default:                 
                break;                                
             }             
        });
        //获取邀请码
        if(set.dbid <= 0 && set.isAppend){
            getInvitationCode();
        }
        
         //复选框的单击事件
         $('.checkbox').click(function(){
                if($(this).is(':checked')){
                    $(this).val(1);
                }else{
                    $(this).val(0);
                }
         });
    }    
    
    //刷新数据库使用情况
    function getrefreshDataSourceDataSize(set){
        $.ajax({
            url: set.hostUrl+'/shopping/maintaince/maintaince.do?m=refreshdsdatasize'+(set.wxQuery==null || set.wxQuery==''?'':'&'+set.wxQuery),//<%= (wxQueryString == null||"".equals(wxQueryString)?"":"&" + wxQueryString)  %>',
            type: 'post',
            data: '',//$('input[type=\'text\'],input[type=\'radio\']:checked,input[type=\'checkbox\']:checked,select,textarea'),
            dataType: 'json',
            beforeSend:ajaxLoading,
//            complete: function() {
//                $('#button-submit').button('reset');
//            },
            success: function(json) {                            
                if (json['hint']) {
                    Tips(json['hint']);
                }                            
                if (json['error']) {
                    Tips(json['error']) ;
                    ajaxLoadEnd();
                    return ;
                }
                setTimeout(function() {
                    ajaxLoadEnd();
                    location = set.RequestURL;//"<%= request.getRequestURL() %>"
                  }, 1000);                            
            },
            error: function(xhr, ajaxOptions, thrownError) {
                Tips(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
            }
        });
    }
    //(启用/禁止)系统    
    function getStopAndStart(action,id,set){
         $.ajax({
             url: set.hostUrl+'/shopping/maintaince/maintaince.do?m=StopAndStart&action='+action +'&'+set.data_base_id+'='+ id + (set.wxQuery==null || set.wxQuery==''?'':'&'+set.wxQuery),//  '<%= (wxQueryString == null||"".equals(wxQueryString)?"":"&" + wxQueryString)  %>',
             type: 'post',
             data: '',//$('input[type=\'text\'],input[type=\'radio\']:checked,input[type=\'checkbox\']:checked,select,textarea'),
             dataType: 'json',
             beforeSend:ajaxLoading,
//             beforeSend: function() {
//                  $('#button-submit').button('loading');
//             },
//             complete: function() {
//                 $('#button-submit').button('reset');
//             },
             success: function(json) {                                        
                 if (json['hint']) {
                     Tips(json['hint']);
                 }
                 
                 if (json['error']) {
                     Tips(json['error']) ;
                 } 
                 setTimeout(function() {
                     ajaxLoadEnd();
                     location = set.RequestURL;//"<%= request.getRequestURL() %>"
                   }, 1000);                                            
             },
             error: function(xhr, ajaxOptions, thrownError) {
                 Tips(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
             }
         });        
    }
    
    //获取邀请码
    function getInvitationCode() {
          $.post('/getInvitationCode.do','',function(data){
            $("#InvitationCode").textbox('setValue', data); //赋值            
      });
    }    
    //获取代理商编码
    function getSystemAccesskey(){
        var DockingSystem=setcombobox('DockingSystem');
          if(DockingSystem == ""){
              Tips('请先选择所对接的第三方系统');
              return;
        }
        top.addTab("代理商列表",9801,1,"type='"+DockingSystem+"'");
    }        
    //集合取值
    function data(map,isAppend){
         //必录
         map.host=settextbox('host');
         map.port=settextbox('port');
         map.db=settextbox('db');
         map.userid=settextbox('userid');    
         map.password=settextbox('password');
         if(isAppend){//附加 必录
             map.Protocol=setcombobox("Protocol");            
             map.domain=settextbox("domain");
             map.systemtype=setcombobox("systemtype");            
             map.systemID=settextbox('systemID');
             map.systemDescribe=settextbox('systemDescribe');
             map.password==''?delete map.password:map.password;
         }
         var bol=(remind(map)? true:false);//必录输入验证
         if(isAppend){//附加
             map.LimitUserNumber=settextbox("LimitUserNumber");
             map.LimitDepartmentNumber=settextbox("LimitDepartmentNumber");             
             map.expiredDate=settextbox("expiredDate");                 
             map.smsUid=settextbox("smsUid");
             map.smsKey=settextbox("smsKey");
             map.isAutoGenerateFormId=setchecked("isAutoGenerateFormId");
             map.Remarks=settextbox("Remarks");
             map.DataCheckPageNum=settextbox("DataCheckPageNum");
             map.CorpURL=settextbox("CorpURL");
             map.CorpId=settextbox("CorpId");
             map.MpAppId=settextbox("MpAppId");
             map.MpSecret=settextbox("MpSecret");
             map.MpToken=settextbox("MpToken");
             map.MpAesKey=settextbox("MpAesKey");
             map.MiniAppId=settextbox("MiniAppId");
             map.MiniAppSecret=settextbox("MiniAppSecret");
             map.MiniAppToken=settextbox("MiniAppToken");
             map.MiniAppAesKey=settextbox("MiniAppAesKey");
             map.MiniAppOrgId=settextbox("MiniAppOrgId");
             map.MpOrgId=settextbox("MpOrgId");
             map.MpMchId=settextbox("MpMchId");
             map.MpMchName=settextbox("MpMchName");
             map.MpMchKey=settextbox("MpMchKey");
             map.GeoWebApiKey=settextbox("GeoWebApiKey");
             map.InvitationCode=settextbox("InvitationCode");            
             map.SystemAccessKey=settextbox("SystemAccessKey");
             map.SystemSecretKey=settextbox("SystemSecretKey");                  
             map.DockingSystem=setcombobox("DockingSystem");
             map.isShowAttendanceButton=setchecked("isShowAttendanceButton");
             map.isDisabledOpenNextPeriodId=setchecked("isDisabledOpenNextPeriodId");
             map.isUseAPP=setchecked("isUseAPP");
             map.isShowInLoginPage=setchecked("isShowInLoginPage");
             map.TengXunMapLocationServiceKey=settextbox("TengXunMapLocationServiceKey");
         }    
         map.actived=setchecked('actived');    //是否启用         
         return bol;
    }
    //取值 textbox
    function settextbox(id){
        return $('#'+id).textbox('getValue');
        }
    //取值 combobox
    function setcombobox(id){
        return $('#'+id).combobox('getValue');
        }
    //取值checked
    function setchecked(id){
        return ($('#'+id).is(':checked')?1:0);
    }
    //配置输入验证。
    function remind(map){             
                for(var m in map){
                    if(map[m]=='' && m != 'id'){
                        $.messager.show({
                            height:60,
                            msg:'<div class=\"lu\"><span style=\"color:red;\"><b>'+$('#'+m).parent().parent().find("td")[0].innerText+'不能为空</b></div>',
                            showType:'fade',
                            timeout:2000,
                            style:{}
                        });
                        return true;
                    }
                }
                return false;
    }
    //提示
    function Tips(data){
        $.messager.alert('操作提示','<div class=\"lu\">'+data+'</div>');
    }
    //请稍候。。。启用
    function ajaxLoading(){   
        $("<div class=\"datagrid-mask\"></div>").css({display:"block",width:"100%",height:$(window).height()}).appendTo("body");   
        $("<div class=\"datagrid-mask-msg\"></div>").html("正在处理,请稍候。。。").appendTo("body").css({height:"50px",display:"block",left:($(document.body).outerWidth(true) - 190) / 2,top:($(window).height()) / 2});   
        document.documentElement.style.overflow='hidden';
        document.body.style.position='fixed';
        document.body.style.top='0px';
        document.body.style.width='100%';
    }  
    //请稍候。。。结束
    function ajaxLoadEnd(){   
         $(".datagrid-mask").remove();   
         $(".datagrid-mask-msg").remove(); 
         document.documentElement.style.overflow='scroll';
         document.body.style.position='static';                       
    } 
})(jQuery);