【调度系统】广东民航医疗快线调度系统源代码
wanglizhong
2025-06-16 ae5b0a8c63979351028215b8fe8cdf4b0766c272
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
/*global jQuery, define */
(function( factory ) {
    "use strict";
    if ( typeof define === "function" && define.amd ) {
 
    // AMD. Register as an anonymous module.
        define([
            "jquery"
        ], factory );
    } else {
 
    // Browser globals
        factory();
    }
}(function() {
"use strict";
//module begin
window.jqGridUtils = {
    stringify : function(obj) {
        return JSON.stringify(obj,function(key, value){
            return (typeof value === 'function' ) ? value.toString() : value;
        });
    },
    parse : function(str) {
        return JSON.parse(str,function(key, value){
            if(typeof value === "string" && value.indexOf("function") !== -1) {
                return  eval('('+value+')');
            }
            return value;
        });
    },
    encode : function ( text ) { // repeated, but should not depend on grid
        return String(text).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
    },
    jsonToXML : function ( tree, options ) {
        var o = $.extend( {
            xmlDecl : '<?xml version="1.0" encoding="UTF-8" ?>\n',
            attr_prefix : '-',
            encode : true
        }, options || {}),
        that = this,
        scalarToxml = function ( name, text ) {
            if ( name === "#text" ) {
                return (o.encode ? that.encode(text) : text);
            } else if(typeof(text) ==='function') {
                return "<"+name+"><![CDATA["+ text +"]]></"+name+">\n";
            } if(text === "") {
                return "<"+name+">__EMPTY_STRING_</"+name+">\n";
            } else {
                return "<"+name+">"+(o.encode ? that.encode(text) : text )+"</"+name+">\n";
            }
        },
        arrayToxml = function ( name, array ) {
            var out = [];
            for( var i=0; i<array.length; i++ ) {
                var val = array[i];
                if ( typeof(val) === "undefined" || val == null ) {
                    out[out.length] = "<"+name+" />";
                } else if ( typeof(val) === "object" && val.constructor == Array ) {
                    out[out.length] = arrayToxml( name, val );
                } else if ( typeof(val) === "object" ) {
                    out[out.length] = hashToxml( name, val );
                } else {
                    out[out.length] = scalarToxml( name, val );
                }
            }
            if(!out.length) {
                out[0] = "<"+ name+">__EMPTY_ARRAY_</"+name+">\n";
            }
            return out.join("");
        },
        hashToxml = function ( name, tree ) {
            var elem = [];
            var attr = [];
            for( var key in tree ) {
                if ( ! tree.hasOwnProperty(key) ) continue;
                var val = tree[key];
                if ( key.charAt(0) !==  o.attr_prefix ) {
                    if ( val == null ) { // null or undefined
                       elem[elem.length] = "<"+key+" />";
                    } else if ( typeof(val) === "object" && val.constructor === Array ) {
                        elem[elem.length] = arrayToxml( key, val );
                    } else if ( typeof(val) === "object" ) {
                        elem[elem.length] = hashToxml( key, val );
                    } else {
                        elem[elem.length] = scalarToxml( key, val );
                    }
                } else {
                    attr[attr.length] = " "+(key.substring(1))+'="'+(o.encode ? that.encode( val ) : val)+'"';
                }
            }
            var jattr = attr.join("");
            var jelem = elem.join("");
            if ( name == null ) { // null or undefined
                // no tag
            } else if ( elem.length > 0 ) {
                if ( jelem.match( /\n/ )) {
                    jelem = "<"+name+jattr+">\n"+jelem+"</"+name+">\n";
                } else {
                    jelem = "<"+name+jattr+">"  +jelem+"</"+name+">\n";
                }
            } else {
                jelem = "<"+name+jattr+" />\n";
            }
            return jelem;
        };
 
        var xml = hashToxml( null, tree );
        return o.xmlDecl + xml;
    },
    xmlToJSON : function ( root, options ) {
        var o = $.extend ( {
            force_array : [], //[ "rdf:li", "item", "-xmlns" ];
            attr_prefix : '-'
        }, options || {} );
        
        if(!root) { return; }
        
        var __force_array = {};
        if ( o.force_array ) {
            for( var i=0; i< o.force_array.length; i++ ) {
                __force_array[o.force_array[i]] = 1;
            }
        }
        
        if(typeof root === 'string') {
            root = $.parseXML(root);
        } 
        if(root.documentElement) {
            root = root.documentElement;
        }
        var addNode = function ( hash, key, cnts, val ) {
            if(typeof val === 'string') {
                if( val.indexOf('function') !== -1) {
                    val =  eval( '(' + val +')'); // we need this in our implement
                } else {
                    switch(val) {
                        case '__EMPTY_ARRAY_' :
                            val = [];
                            break;
                        case '__EMPTY_STRING_':
                            val = "";
                            break;
                        case "false" :
                            val = false;
                            break;
                        case "true":
                            val = true;
                            break;
                    }
                }
            } 
            if ( __force_array[key] ) {
                if ( cnts === 1 ) {
                    hash[key] = [];
                }
                hash[key][hash[key].length] = val;      // push
            } else if ( cnts === 1 ) {                   // 1st sibling
                hash[key] = val;
            } else if ( cnts === 2 ) {                   // 2nd sibling
                hash[key] = [ hash[key], val ];
            } else {                                    // 3rd sibling and more
                hash[key][hash[key].length] = val;
            }
        },
        parseElement = function ( elem ) {
            //  COMMENT_NODE
            if ( elem.nodeType === 7 ) {
                return;
            }
 
            //  TEXT_NODE CDATA_SECTION_NODE
            if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
                var bool = elem.nodeValue.match( /[^\x00-\x20]/ );
                if ( bool == null ) return;     // ignore white spaces
                return elem.nodeValue;
            }
            
            var retval,    cnt = {}, i, key, val;
 
            //  parse attributes
            if ( elem.attributes && elem.attributes.length ) {
                retval = {};
                for ( i=0; i<elem.attributes.length; i++ ) {
                    key = elem.attributes[i].nodeName;
                    if ( typeof(key) !== "string" )  {
                        continue;
                    }
                    val = elem.attributes[i].nodeValue;
                    if ( ! val ) {
                        continue;
                    }
                    key = o.attr_prefix + key;
                    if ( typeof(cnt[key]) === "undefined" ) {
                        cnt[key] = 0;
                    }
                    cnt[key] ++;
                    addNode( retval, key, cnt[key], val );
                }
            }
 
            //  parse child nodes (recursive)
            if ( elem.childNodes && elem.childNodes.length ) {
                var textonly = true;
                if ( retval ) {
                    textonly = false;
                }        // some attributes exists
                for ( i=0; i<elem.childNodes.length && textonly; i++ ) {
                    var ntype = elem.childNodes[i].nodeType;
                    if ( ntype === 3 || ntype === 4 ) {
                        continue;
                    }
                    textonly = false;
                }
                if ( textonly ) {
                    if ( ! retval ) {
                        retval = "";
                    }
                    for ( i=0; i<elem.childNodes.length; i++ ) {
                        retval += elem.childNodes[i].nodeValue;
                    }
                } else {
                    if ( ! retval ) {
                        retval = {};
                    }
                    for ( i=0; i<elem.childNodes.length; i++ ) {
                        key = elem.childNodes[i].nodeName;
                        if ( typeof(key) !== "string" ) {
                            continue;
                        }
                        val = parseElement( elem.childNodes[i] );
                        if ( !val ) {
                            continue;
                        }
                        if ( typeof(cnt[key]) === "undefined" ) {
                            cnt[key] = 0;
                        }
                        cnt[key] ++;
                        addNode( retval, key, cnt[key], val );
                    }
                }
            }
            return retval;
        };
        
        var json = parseElement( root );   // parse root node
        if ( __force_array[root.nodeName] ) {
            json = [ json ];
        }
        if ( root.nodeType !== 11 ) {            // DOCUMENT_FRAGMENT_NODE
            var tmp = {};
            tmp[root.nodeName] = json;          // root nodeName
            json = tmp;
        }
        return json;
    }
};
//module end
return window.jqGridUtils;
 
}));