OWL ITS + 탐지시스템(인터넷 진흥원)
jhjang
2021-10-14 b74776268dd3eb2bc57744928d6f7150ffcd4ec2
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
'use strict';
 
define(['app', 'angular'],
    function (app, angular) {
        app.provider("$tableProvider", function () {
            return {
                $get : function ($log) {
                    return {
                        config : function () {
                            var tableConfig = {
                                hName : "",    //    헤더 이름
                                hWidth : "",    //    칼럼 길이
                                hChecked : false,    //    체크 박스 선택 여부
                                hAlign : "text-center",    //    헤더 정렬 기준
                                hSort : true,    //    정렬 가능 여부
                                dName : "",    //    데이터 이름
                                dAlign : "text-left",    //    데이터 정렬 기준
                                dRenderer : "",    //    렌더러 여부
                                dVisible : "",  //      bootstrap 반응형 컬럼 표시 여부
                                dType : "none",        // 태그 타입
                                dDateFormat : "",   //  날짜 형식
                                rowSpan : 0,    //  rowspan 을 지원한다.
                                colSpan : 0,    //  colspan 을 지원한다.
                                subHead : false,    //  만약 rowspan, colspan 을 사용하게 되면 true 로 셋팅.
                                columnHint : "",    //  컬럼 정보를 추출하기 위한 힌트 정보를 준다 - tableColumnGenerator 의 사용자 정의 필드 부분에서 사용
                                setHName : function (hName) {
                                    this.hName = hName;
                                    return this;
                                },
                                setHWidth : function (hWidth) {
                                    this.hWidth = hWidth;
                                    return this;
                                },
                                setHChecked : function (hChecked) {
                                    this.hChecked = hChecked;
                                    return this;
                                },
                                setHAlign : function (hAlign) {
                                    this.hAlign = hAlign;
                                    return this;
                                },
                                setHSort : function (hSort) {
                                    this.hSort = hSort;
                                    return this;
                                },
                                setDName : function (dName) {
                                    this.dName = dName;
                                    return this;
                                },
                                setDAlign : function (dAlign) {
                                    this.dAlign = dAlign;
                                    return this;
                                },
                                setDRenderer : function (dRenderer) {
                                    this.dRenderer = dRenderer;
                                    return this;
                                },
                                setDVisible : function (dVisible) {
                                    this.dVisible = dVisible;
                                    return this;
                                },
                                setDType : function (dType) {
                                    this.dType = dType;
                                    return this;
                                },
                                setDDateFormat : function (dDateFormat) {
                                    this.dDateFormat = dDateFormat;
                                    return this;
                                },
                                setRowSpan : function (dRowSpan) {
                                    this.rowSpan = dRowSpan;
                                    return this;
                                },
                                setColSpan : function (dColSpan) {
                                    this.colSpan = dColSpan;
                                    return this;
                                },
                                setSubHead : function (dSubHead) {
                                    this.subHead = dSubHead;
                                    return this;
                                },
                                setColumnHint : function (dColumnHint) {
                                    this.columnHint = dColumnHint;
                                    return this;
                                }
                            };
 
                            return tableConfig;
                        },
                        toggleChecked : function (checkStatus, datas) {
                            //  전체 선택 체크 박스를 클릭했을 경우
                            angular.forEach(datas, function (data) {
                                if (angular.isDefined(data.defaultYn)) {
                                    if (!data.defaultYn) {
                                        data.checked = checkStatus;
                                    }
                                }
                                else {
                                    data.checked = checkStatus;
                                }
                            });
                        },
                        radioChecked : function (target, datas) {
                            //  해당 row 가 라디오 버튼일 경우
                            angular.forEach(datas, function (data) {
                                if (target.id == data.id) {
                                    data.checked = true;
                                }
                                else {
                                    data.checked = false;
                                }
                            });
                        },
                        rowChecked : function (tableConfig, target, datas) {
                            //  각 row 의 체크박스/라디오 버튼을 클릭했을 경우
                            if (tableConfig[0].dType == "checkbox") {
                                target.checked = !target.checked;
 
                                for (var data in datas) {
                                    if (!data.checked) {
                                        this.hChecked = false;
                                        break;
                                    }
                                }
                            }
                            else if (tableConfig[0].dType == "radio") {
                                this.radioChecked(target, datas);
                            }
                        },
                        orderByColumn : "",  // table order By column name
                        reverse : true,
                        setOrderByColumn : function (column) {
                            if (column == "") {
                                return;
                            }
 
                            if (this.orderByColumn == column) {
                                this.reverse = !this.reverse;
                            }
                            else {
                                this.reverse = true;
                            }
 
                            this.orderByColumn = column;
                            return this;
                        },
                        getDateFormat : function (formatType, date) {
                            if (formatType == "" || formatType == null) {
                                formatType = "01";
                            }
                            Date.prototype.format = function (f) {
                                if (!this.valueOf()) {
                                    return " ";
                                }
                                var weekName = ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"];
                                var d = this;
 
                                return f.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function ($1) {
                                    switch ($1) {
                                        case "yyyy":
                                            return d.getFullYear();
                                        case "yy":
                                            return (d.getFullYear() % 1000).zf(2);
                                        case "MM":
                                            return (d.getMonth() + 1).zf(2);
                                        case "dd":
                                            return d.getDate().zf(2);
                                        case "E":
                                            return weekName[d.getDay()];
                                        case "HH":
                                            return d.getHours().zf(2);
                                        case "hh":
                                            var h = d.getHours();
                                            return ((h = d.getHours() % 12) ? h : 12).zf(2);
                                        case "mm":
                                            return d.getMinutes().zf(2);
                                        case "ss":
                                            return d.getSeconds().zf(2);
                                        case "a/p":
                                            return d.getHours() < 12 ? "오전" : "오후";
                                        default:
                                            return $1;
                                    }
                                });
                            };
 
                            String.prototype.string = function (len) {
                                var s = '', i = 0;
                                while (i++ < len) {
                                    s += this;
                                }
                                return s;
                            };
                            String.prototype.zf = function (len) {
                                return "0".string(len - this.length) + this;
                            };
                            Number.prototype.zf = function (len) {
                                return this.toString().zf(len);
                            };
 
                            var dateFormat = "";
                            var dynamicTime = false;
                            var today = new Date().format("yyyy-MM-dd");
                            var compareDate = new Date(date).format("yyyy-MM-dd");
 
                            if (today == compareDate) {
                                dynamicTime = true;
                            }
 
                            switch (formatType) {
                                case "01":  //  날짜
                                    dateFormat = "yyyy-MM-dd";
                                    break;
                                case "02":  //  날짜 + 시간
                                    dateFormat = "yyyy-MM-dd HH:mm";
                                    break;
                                case "03":  //  유동적 표시
                                    if (dynamicTime) {
                                        dateFormat = "HH:mm";
                                    }
                                    else {
                                        dateFormat = "yyyy-MM-dd HH:mm";
                                    }
 
                                    break;
                            }
 
                            return dateFormat;
                        }
                    }
                }
            }
        });
    });