|
@@ -26,7 +26,9 @@ let USER_INTI_USERPW = '/api/user/inti-userpw';
|
26
|
26
|
|
27
|
27
|
require(['config'], function() {
|
28
|
28
|
require([
|
29
|
|
- 'jquery'
|
|
29
|
+ 'jquery',
|
|
30
|
+ 'xlsx',
|
|
31
|
+ 'jspdf'
|
30
|
32
|
], function($) {
|
31
|
33
|
// 버튼 권한설정
|
32
|
34
|
fn_proc_btn_auth('OPERATION01010');
|
|
@@ -133,8 +135,83 @@ require(['config'], function() {
|
133
|
135
|
fn_ajax_call(USER_SAVE_USER, JSON.stringify(param), searhFn, 'POST');
|
134
|
136
|
}
|
135
|
137
|
}
|
136
|
|
- });
|
137
|
|
-
|
|
138
|
+ });
|
|
139
|
+
|
|
140
|
+ // 엑셀 다운로드 버튼
|
|
141
|
+ $('#ITP_BTN_OPERATION01010_EXCEL').on('click', function() {
|
|
142
|
+ console.log('엑셀 다운로드...');
|
|
143
|
+ let exportExcel = {
|
|
144
|
+ fileName : 'OPERATION01010.xlsx',
|
|
145
|
+ sheetName : '사용자관리',
|
|
146
|
+ header : {
|
|
147
|
+ userId: ITP_MSG_LOCALE.label.userId, //사용자ID
|
|
148
|
+ userNm: ITP_MSG_LOCALE.label.userName, //닉네임
|
|
149
|
+ email: ITP_MSG_LOCALE.label.idEmail, //아이디(이메일)
|
|
150
|
+ telNo: ITP_MSG_LOCALE.label.telNo, //휴대폰 번호
|
|
151
|
+ userStatNm: ITP_MSG_LOCALE.label.status, //상태
|
|
152
|
+ userStatDt: ITP_MSG_LOCALE.label.statusDt, //상태일시
|
|
153
|
+ addDt: ITP_MSG_LOCALE.label.regDt, //등록일
|
|
154
|
+ lastLoginDt: ITP_MSG_LOCALE.label.lastLogin, //마지막 로그인
|
|
155
|
+ },
|
|
156
|
+ blobParts : function(wb) {
|
|
157
|
+ let buf = new ArrayBuffer(wb.length);
|
|
158
|
+ let view = new Uint8Array(buf);
|
|
159
|
+ for (let i=0; i<wb.length; i++) view[i] = wb.charCodeAt(i) & 0xFF;
|
|
160
|
+ return buf;
|
|
161
|
+ },
|
|
162
|
+ download : function(rowData, isHeader) {
|
|
163
|
+ let wb = XLSX.utils.book_new();
|
|
164
|
+ if(isHeader) rowData.unshift(this.header);
|
|
165
|
+ let newWorksheet = XLSX.utils.json_to_sheet(rowData);
|
|
166
|
+ XLSX.utils.book_append_sheet(wb, newWorksheet, this.sheetName);
|
|
167
|
+ let wbout = XLSX.write(wb, {bookType:'xlsx', type: 'binary'});
|
|
168
|
+ saveAs(new Blob([this.blobParts(wbout)],{type:"application/octet-stream"}), this.fileName);
|
|
169
|
+ },
|
|
170
|
+ save : function() {
|
|
171
|
+ let _this = this;
|
|
172
|
+ let rowData = $(OPERATION01010_GRID_ID).getRowData();
|
|
173
|
+ console.log(rowData);
|
|
174
|
+ this.download(rowData, true);
|
|
175
|
+ }
|
|
176
|
+ }
|
|
177
|
+ exportExcel.save();
|
|
178
|
+ });
|
|
179
|
+
|
|
180
|
+ // PDF 다운로드 버튼
|
|
181
|
+ $('#ITP_BTN_OPERATION01010_PDF').on('click', function() {
|
|
182
|
+ console.log('PDF 다운로드...');
|
|
183
|
+ html2canvas($(OPERATION01010_GRID_ID)[0], {
|
|
184
|
+ //logging : true, // 디버그 목적 로그
|
|
185
|
+ allowTaint : true, // cross-origin allow
|
|
186
|
+ useCORS: true, // CORS 사용한 서버로부터 이미지 로드할 것인지 여부
|
|
187
|
+ scale : 2 // 기본 96dpi에서 해상도를 두 배로 증가
|
|
188
|
+ }).then(canvas => {
|
|
189
|
+ let imgData = canvas.toDataURL('image/png');
|
|
190
|
+ let imgWidth = 190; // 이미지 가로 길이(mm) / A4 기준 210mm
|
|
191
|
+ let pageHeight = imgWidth * 1.414; // 출력 페이지 세로 길이 계산 A4 기준
|
|
192
|
+ let imgHeight = canvas.height * imgWidth / canvas.width;
|
|
193
|
+ let heightLeft = imgHeight;
|
|
194
|
+ let margin = 10; // 출력 페이지 여백설정
|
|
195
|
+ let doc = new jsPDF('p', 'mm');
|
|
196
|
+ let position = 0;
|
|
197
|
+
|
|
198
|
+ // 첫 페이지 출력
|
|
199
|
+ doc.addImage(imgData, 'PNG', margin, position, imgWidth, imgHeight);
|
|
200
|
+ heightLeft -= pageHeight;
|
|
201
|
+
|
|
202
|
+ // 한 페이지 이상일 경우 루프 돌면서 출력
|
|
203
|
+ while (heightLeft >= 20) {
|
|
204
|
+ position = heightLeft - imgHeight;
|
|
205
|
+ doc.addPage();
|
|
206
|
+ doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
|
|
207
|
+ heightLeft -= pageHeight;
|
|
208
|
+ }
|
|
209
|
+
|
|
210
|
+ // 파일 저장
|
|
211
|
+ doc.save('file-name.pdf');
|
|
212
|
+ });
|
|
213
|
+ });
|
|
214
|
+
|
138
|
215
|
// 중복체크
|
139
|
216
|
$('#ITP_FORM_OPERATION01010_DETAIL_DUP').on('click', function() {
|
140
|
217
|
const formId = '#ITP_FORM_OPERATION01010_DETAIL';
|