1
13693261870
2022-09-16 21ddee1a38257297288b88bc6c0476ec96a5f867
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
 
//jqGrid鐨勯厤缃俊鎭�
if($.jgrid){
    $.jgrid.defaults.width = 1000;
    $.jgrid.defaults.responsive = true;
    $.jgrid.defaults.styleUI = 'Bootstrap';
}
//宸ュ叿闆嗗悎Tools
window.T = {};
 
// 鑾峰彇璇锋眰鍙傛暟
// 浣跨敤绀轰緥
// location.href = http://192.168.1.128/index.html?id=123
// T.p('id') --> 123;
var url = function(name) {
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]); return null;
};
T.p = url;
 
//鍙墽琛屼竴娆etToken()
var hasNewToken = false;
//鐧诲綍token
var token = localStorage.getItem("token"); //localStorage sessionStorage
if(!token){
//    parent.location.href = baseURL + 'admin/login.html';
//鏍规嵁鍙傛暟鏄惁甯︽湁username鍜寁alidatenumber鏉ュ垽鏂姹傛潵婧愭槸鍚︽槸鍔炲叕鑷姩鍖栫郴缁�,鑻ユ槸鍒欒繘琛屽弽鍚戦獙璇佺櫥褰昞
    if(T.p("username")&&T.p("validateNumber")){
        ValidLoginUser(T.p("validateNumber"));
    }
    
   if(iisRun) getToken();
}
 
 
function ValidLoginUser(validateNumber){
 
    $.ajax({
           type: "get",
           async:false,
        url:restServerBaseURL + "sys/portallogin" ,
           dataType: "json",
           timeout: 10000,
           data: "",
           error:function(){
                alert('璇诲彇鏁版嵁閿欒');
                 },
           success:function(data){
               debugger
              if(data.result.validateResult==true){
                  console.log('璋冪敤鎴愬姛');
                  
              }         
       }
     });
}
//jquery鍏ㄥ眬閰嶇疆
$.ajaxSetup({
    // beforeSend: function(xhr) {
    //     console.log("beforeSend:token is [%s]",token);
    // },
    dataType: "json",
    cache: false,
    headers: {
        "token": token
    },
    xhrFields: {
        withCredentials: false
    },
    crossDomain: true,
    complete: function(xhr) {
        // console.log("complete:token is [%s], xhr.responseJSON:",token,xhr.responseJSON);
        //鏃犳晥鐨則oken锛屽垯璺宠浆鍒扮櫥褰曢〉闈�
        if(!!xhr.responseJSON && xhr.responseJSON.code == 401){
            //localStorage.setItem("token", "");
            //alert("鏃犳晥鐨則oken,璇峰埛鏂伴〉闈㈡垨閲嶆柊鐧婚檰绯荤粺锛�");
            //parent.location.href = baseURL + 'admin/login.html';
            //debugger;
            //getToken();
        }
        //鏃犳晥鐨則oken鐨勫彟涓€绉嶆儏鍐碉細ajax璇锋眰鏈畬鎴愬嵆杩斿洖閿欒
//        if(!!token && !xhr.responseJSON){
//            debugger;
//            getToken();
//        }
    }
});
 
//jqgrid鍏ㄥ眬閰嶇疆
if($.jgrid){
    $.extend($.jgrid.defaults, {
        ajaxGridOptions : {
                headers: {
                "token": token
            }
        }
    });
}
 
//鑾峰緱Token
function getToken() {
    // console.log("getToken:");
    if(hasNewToken){
        return;
    }
    hasNewToken = true;
    // debugger
    $.ajax({
        // async: false,
        type: "GET",
        url: restServerBaseURL + "sys/caslogin2",
        dataType: "jsonp",
        jsonp: "callback",
        jsonpCallback: "casloginCallback",
        beforeSend: function(xhr) {},
        complete: function(xhr) {}, //瑕嗙洊鍏ㄥ眬鏂规硶
        success: function (r) {
            if(r.code == 0){//鐧诲綍鎴愬姛
                // console.log("\tnewToken:",r.token);
                localStorage.setItem("token", r.token);
                token = r.token;
                parent.location.reload();
            }else{
                alert(r.msg);
            }
        },
        error: function(xhr, err) {
            if(xhr.status == 404){
                alert("鏃犳晥鐨凴EST鏈嶅姟鍣細" + restServerBaseURL);
            }            
        }
    });
}
 
//鏉冮檺鍒ゆ柇
function hasPermission(permission) {  //alert ykm 2019-01-18 淇敼鍥犻棬鎴风偣鍑昏繘杩愮淮鐩戞帶锛屾病鏈夋潈闄愮殑鐢ㄦ埛杩涘埌锛�//寮瑰嚭绐楀彛鐨勬潈闄愬垽鏂級鍑虹幇閿欒
    if (window.parent.permissions != undefined) {
        if(window.parent.permissions.indexOf(permission) > -1) {
            return true;
        }
        else {
            return false;
        }
    } else if(window.opener != undefined && window.opener.parent != undefined && window.opener.parent != null &&  window.opener.parent.permissions != undefined && window.opener.parent.permissions != null  && window.opener.parent.permissions.indexOf(permission) > -1){ //寮瑰嚭绐楀彛鐨勬潈闄愬垽鏂�
        return true;
    } else if(window.opener != undefined && window.opener.opener != undefined && window.opener.opener.parent.permissions != undefined && window.opener.opener.parent.permissions.indexOf(permission) > -1){
        return true;//绐楀彛閲屽啀寮圭獥鍙� 锛堝崟浣嶇鐞嗭級
    }else{
        return false
    }
}
 
//閲嶅啓alert
window.alert = function(msg, callback){
    parent.layer.alert(msg, function(index){
        parent.layer.close(index);
        if(typeof(callback) === "function"){
            callback("ok");
        }
    });
}
 
//閲嶅啓confirm寮忔牱妗�
window.confirm = function(msg, callback){
    parent.layer.confirm(msg, { btn: ['确定', '取消'] },
    //parent.layer.confirm(msg, {btn: ['纭畾','鍙栨秷']},
    function(){//纭畾浜嬩欢
        if(typeof(callback) === "function"){
            callback("ok");
        }
    });
}
 
//閫夋嫨涓€鏉¤褰�
function getSelectedRow() {
    var grid = $("#jqGrid");
    var rowKey = grid.getGridParam("selrow");
    if(!rowKey){
        alert("璇烽€夋嫨涓€绗旇褰曪紒");
        return;
    }
    var selectedIDs = grid.getGridParam("selarrrow");
    if(selectedIDs.length > 1){
        alert("鍙兘閫夋嫨涓€绗旇褰曪紒");
        return;
    }
    return selectedIDs[0];
}
 
//閫夋嫨澶氭潯璁板綍
function getSelectedRows() {
    var grid = $("#jqGrid");
    var rowKey = grid.getGridParam("selrow");
    if(!rowKey){
        alert("璇烽€夋嫨鎿嶄綔璁板綍锛�");
        return;
    }
    return grid.getGridParam("selarrrow");
}
 
//鍒ゆ柇鏄惁涓虹┖
function isBlank(value) {
    return !value || !/\S/.test(value);
}
 
function openLayer(width, height, title, div){
    layer.open({
        type: 1,
        skin: 'layui-layer-molv',
        title: title,
        shadeClose: false,
        area: [width, height],
        content: jQuery("#"+div)
    });
}
 
function openLayerOfBtn(width, height, title, div, callback){
    layer.open({
        type: 1,
        skin: 'layui-layer-molv',
        title: title,
        shadeClose: false,
        area: [width, height],
        content: jQuery("#"+div),
        btn: ['纭畾', '鍙栨秷'],
        btn1: function (index) {
            callback();
            layer.close(index);
        }
    });
}
 
//閫夋嫨闄勪欢layer
function openAttachmentLayer(callback, mime_type){
    var attachment_jqGrid=$("#attachment_layer_jqGrid");
 
    layer.open({
        type: 1,
        skin: 'layui-layer-molv',
        title: '閫夋嫨闄勪欢',
        shadeClose: false,
        area: ['80%', '80%'],
        content: jQuery("#attachment_layer"),
        btn: ['纭畾', '鍙栨秷'],
        btn1: function (index) {
            var rowKey = attachment_jqGrid.getGridParam("selrow");
            if(!rowKey){
                alert("璇烽€夋嫨涓€鏉¤褰�");
                return ;
            }
 
            var rowData = attachment_jqGrid.jqGrid("getRowData", rowKey);
            var path=rowData.path;
            callback(uploadFileResource+path);
 
            layer.close(index);
        }
    });
 
    attachment_jqGrid.jqGrid({
        url: restServerBaseURL + 'sys/attachment/list',
        postData:{mime_type: mime_type},
        datatype: "json",
        colModel: [
            { label: 'id', name: 'id', index: 'id', key: true, hidden: true },
            { label: '鏍囬', name: 'title', width: 100 },
            { label: '鍦板潃', name: 'path', width: 100, hidden: true},
            { label: '缂╃暐鍥�', name: 'img', width: 100, formatter: function(value, options, row){
                var mime=row.mimeType;
                var path=row.path;
                if(mime.indexOf('image') >= 0){
                    return '<img style="width: 200px;height: 200px;" src="'+uploadFileResource+path+'" >';
                }else if(mime.indexOf('audio') >= 0){
                    return '<img style="width: 200px;height: 200px;" src="'+restServerBaseURL+'image/audio.jpg" >';
                }else if(mime.indexOf('video') >= 0){
                    return '<img style="width: 200px;height: 200px;" src="'+restServerBaseURL+'image/video.jpg" >';
                }else if(mime.indexOf('application') >= 0){
                    return '<img style="width: 200px;height: 200px;" src="'+restServerBaseURL+'image/file.jpg" >';
                }
            } },
            { label: '鍒涘缓鏃堕棿', name: 'createTime', width: 90 }
        ],
        viewrecords: true,
        height: "100%",
        rowNum: 10,
        //rowList : [10,20,30],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: false,
        pager: "#attachment_layer_jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //闅愯棌grid搴曢儴婊氬姩鏉�
            attachment_jqGrid.closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
}
 
//鍒涘缓attachment-layer缁勪欢
var attachmentLayerTemplate=Vue.extend({
    template:[
        '<div id="attachment_layer" style="display: none;">',
        '<table id="attachment_layer_jqGrid"></table>',
        '<div id="attachment_layer_jqGridPager"></div>',
        '</div>'
    ].join('')
});
Vue.component('attachment-layer', attachmentLayerTemplate);
 
//鏂囨湰缂栬緫鍣�
function initTinymce() {
    tinymce.init({
        selector : '#textarea',
        height : 365,
        language : 'zh_CN',
        menubar : false,
        automatic_uploads : true,
        paste_data_images : true,
        convert_urls : false,
        relative_urls : false,
        imagetools_toolbar : "rotateleft rotateright | flipv fliph | editimage imageoptions",
        imagetools_proxy : '',
        images_upload_url : '',
        wordcount_countregex : /[\u4e00-\u9fa5_a-zA-Z0-9]/g,
        file_picker_callback : function(callback, value, meta) {
            openAttachmentLayer(callback);
        },
        font_formats : "瀹嬩綋=SimSun;鏂板畫浣�=NSimSun;寰蒋闆呴粦=Microsoft YaHei;鍗庢枃榛戜綋=STHeiti;妤蜂綋=KaiTi;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n",
        fontsize_formats : "12px 14px 16px 18px 20px 24px 32px",
        plugins : [
            "advlist autolink autosave link image media imagetools lists charmap print preview hr anchor pagebreak spellchecker",
            "searchreplace wordcount visualblocks visualchars code codesample fullscreen insertdatetime media nonbreaking",
            "table contextmenu directionality emoticons template textcolor paste fullpage textcolor colorpicker textpattern" ],
        toolbar1 : '  bold italic underline strikethrough removeformat | blockquote hr table image media codesample | anchor link   unlink | alignleft aligncenter alignright alignjustify | bullist numlist     ',
        toolbar2 : '  fontselect | fontsizeselect | formatselect | outdent indent | forecolor backcolor  |  undo redo | code  fullscreen',
    });
}
 
//鑾峰彇鏂囨湰缂栬緫鍣ㄥ唴瀹�
function getTinymceContent(){
    return tinymce.activeEditor.getBody().innerHTML;
}
 
//璁剧疆鏂囨湰缂栬緫鍣ㄥ唴瀹�
function setTinymceContent(text){
    tinymce.activeEditor.setContent(text);
}
 
//閲嶇疆琛ㄥ崟
function resetForm(formId) {
    document.getElementById(formId).reset();
}
 
//鑾峰彇appId
function getAppId(){
    if (window.parent.appId != undefined) {
        return window.parent.appId;
    } else if(window.opener != undefined && window.opener.parent.appId != undefined){
        return window.opener.parent.appId;
    }else{
        return null
    }
}