kiosk 진행중
This commit is contained in:
@@ -6,543 +6,225 @@
|
||||
this.choicesInstances = new Map();
|
||||
this.data = {
|
||||
nationality: '',
|
||||
nationalityCode: '',
|
||||
userType: '',
|
||||
visitPath: '',
|
||||
treatment: ''
|
||||
nationalityCode: '', // 선택된 국적 코드 저장용
|
||||
visitPath: ''
|
||||
};
|
||||
this.datepickerInstance = null;
|
||||
this.isInitialized = false;
|
||||
this.userModalRetryCount = 0;
|
||||
this.KOREA_CODE = 'C202404180007';
|
||||
this.allowSystemCheck = false;
|
||||
}
|
||||
|
||||
init() {
|
||||
if (this.isInitialized) return;
|
||||
|
||||
if (!this.validateDependencies()) {
|
||||
if (!this.validateDependencies() || !this.validateDOM()) {
|
||||
this.scheduleRetry();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.validateDOM()) {
|
||||
this.scheduleRetry();
|
||||
return;
|
||||
}
|
||||
|
||||
this.initializeComponents();
|
||||
this.isInitialized = true;
|
||||
console.log('✅ NewPatientPage 초기화 완료');
|
||||
}
|
||||
|
||||
validateDependencies() {
|
||||
return !!($ && window.Choices);
|
||||
}
|
||||
|
||||
validateDOM() {
|
||||
const requiredElements = [
|
||||
'#selectNationality', '#selectUserType', '#selectTreatment',
|
||||
'#selectChannel', '#selectIdentification', '#newPatientForm'
|
||||
];
|
||||
return requiredElements.every(selector => document.querySelector(selector));
|
||||
}
|
||||
|
||||
scheduleRetry() {
|
||||
setTimeout(() => this.init(), 150);
|
||||
}
|
||||
|
||||
initializeComponents() {
|
||||
this.initChoices();
|
||||
this.initUserIntroModal(); // 내장 모달 초기화
|
||||
this.loadCommonCategories();
|
||||
this.initDatepicker();
|
||||
this.bindEvents();
|
||||
this.isInitialized = true;
|
||||
}
|
||||
|
||||
initChoices() {
|
||||
const choicesConfig = {
|
||||
searchEnabled: true,
|
||||
searchPlaceholderValue: '검색...',
|
||||
noResultsText: '결과 없음',
|
||||
noChoicesText: '선택 가능한 항목이 없습니다',
|
||||
itemSelectText: '선택',
|
||||
removeItemButton: false,
|
||||
shouldSort: false,
|
||||
placeholderValue: '선택하세요'
|
||||
};
|
||||
validateDependencies() { return !!($ && window.Choices); }
|
||||
validateDOM() { return !!(document.querySelector('#selectNationality')); }
|
||||
scheduleRetry() { setTimeout(() => this.init(), 150); }
|
||||
|
||||
const selectors = {
|
||||
nationality: { id: '#selectNationality', key: 'nationality', placeholder: '국적 선택' },
|
||||
userType: { id: '#selectUserType', key: 'userType', placeholder: '고객구분 선택' },
|
||||
treatment: { id: '#selectTreatment', key: 'treatment', placeholder: '관심진료 선택' },
|
||||
channel: { id: '#selectChannel', key: 'channel', placeholder: '방문경로 선택' },
|
||||
identification: {
|
||||
id: '#selectIdentification',
|
||||
key: 'identification',
|
||||
config: { searchEnabled: false, placeholder: false }
|
||||
}
|
||||
};
|
||||
bindEvents() {
|
||||
const $rrn1 = $('input[name="modalUserRrn1"]');
|
||||
const $rrn2 = $('input[name="modalUserRrn2"]');
|
||||
|
||||
Object.entries(selectors).forEach(([key, config]) => {
|
||||
try {
|
||||
const instance = new Choices(config.id, {
|
||||
...choicesConfig,
|
||||
placeholder: true,
|
||||
placeholderValue: config.placeholder,
|
||||
...(config.config || {})
|
||||
});
|
||||
this.choicesInstances.set(config.key, instance);
|
||||
} catch (e) {
|
||||
console.error(`Choices 초기화 실패 (${key}):`, e);
|
||||
$rrn2.on('keyup input', (e) => {
|
||||
const rrn1Val = $rrn1.val();
|
||||
const rrn2Val = $(e.target).val();
|
||||
if (rrn1Val.length === 6 && rrn2Val.length >= 1) {
|
||||
this.handleRrnInput(rrn1Val, rrn2Val.charAt(0));
|
||||
}
|
||||
});
|
||||
|
||||
this.toggleForeignerBox(false);
|
||||
this.bindChoicesEvents();
|
||||
}
|
||||
|
||||
// 🔥 내장형 userIntroSelectModal
|
||||
initUserIntroModal() {
|
||||
window.userIntroSelectModal = {
|
||||
callback: null,
|
||||
dataList: null,
|
||||
|
||||
popup(callback) {
|
||||
this.callback = callback;
|
||||
this.initModal();
|
||||
setTimeout(() => $('#userIntroSelectModal').modal('show'), 200);
|
||||
},
|
||||
|
||||
initModal() {
|
||||
if ($('#userIntroSelectModal').length) {
|
||||
$('#userIntroSelectModal').remove();
|
||||
}
|
||||
$('body').append(this.htmlTemplate);
|
||||
this.bindModalEvents();
|
||||
},
|
||||
|
||||
bindModalEvents() {
|
||||
$('#userIntroSelectModal .btnCancle').off().on('click', () => this.close());
|
||||
$('#searchIntroUserBtn').off().on('click', () => this.search());
|
||||
$('#introUserSearchKeyword').off('keypress').on('keypress', (e) => {
|
||||
if (e.key === 'Enter') this.search();
|
||||
});
|
||||
},
|
||||
|
||||
search() {
|
||||
const keyword = $('#introUserSearchKeyword').val()?.trim();
|
||||
if (keyword.length < 2) {
|
||||
this.showAlert('검색어는 2자 이상 입력하세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '/kiosk/getUserOptionList.do',
|
||||
method: 'POST',
|
||||
data: { userSearchKeywordParam: keyword },
|
||||
dataType: 'json',
|
||||
success: (data) => {
|
||||
if (data.msgCode === '0') {
|
||||
this.dataList = data.rows || [];
|
||||
this.renderResults(this.dataList);
|
||||
} else {
|
||||
this.showAlert('검색 결과가 없습니다.');
|
||||
}
|
||||
},
|
||||
error: () => this.showAlert('검색 중 오류가 발생했습니다.')
|
||||
});
|
||||
},
|
||||
|
||||
renderResults(users) {
|
||||
const $tbody = $('#userIntroSelectModal tbody');
|
||||
$tbody.empty();
|
||||
|
||||
if (users.length === 0) {
|
||||
$tbody.html('<tr><td colspan="5" class="text-center p-3">검색결과가 없습니다.</td></tr>');
|
||||
return;
|
||||
}
|
||||
|
||||
users.forEach((user, index) => {
|
||||
const $row = $(`
|
||||
<tr class="user-row" data-index="${index}" style="cursor: pointer;">
|
||||
<td>${user.username || ''}</td>
|
||||
<td>${this.formatDate(user.birthday)}</td>
|
||||
<td>${user.gender || ''}</td>
|
||||
<td>${this.formatPhone(user.phonenumber)}</td>
|
||||
<td>${user.lastvisitdate || ''}</td>
|
||||
</tr>
|
||||
`);
|
||||
$tbody.append($row);
|
||||
});
|
||||
|
||||
$('.user-row').off('click').on('click', (e) => {
|
||||
const index = $(e.currentTarget).data('index');
|
||||
this.selectUser(index);
|
||||
});
|
||||
},
|
||||
|
||||
selectUser(index) {
|
||||
if (this.dataList?.[index]) {
|
||||
this.callback(this.dataList[index]);
|
||||
}
|
||||
this.close();
|
||||
},
|
||||
|
||||
formatDate(dateStr) {
|
||||
if (!dateStr) return '';
|
||||
try {
|
||||
const date = new Date(dateStr.match(/\d{4}-\d{2}-\d{2}/)?.[0]);
|
||||
if (isNaN(date)) return '';
|
||||
return date.toISOString().slice(0, 10).replace(/-/g, '.');
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
formatPhone(phone) {
|
||||
if (!phone) return '';
|
||||
return phone.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3');
|
||||
},
|
||||
|
||||
showAlert(message) {
|
||||
if (window.modalEvent) {
|
||||
window.modalEvent.warning('', message);
|
||||
} else {
|
||||
alert(message);
|
||||
}
|
||||
},
|
||||
|
||||
close() {
|
||||
$('#userIntroSelectModal').modal('hide');
|
||||
setTimeout(() => $('#userIntroSelectModal').remove(), 500);
|
||||
},
|
||||
|
||||
htmlTemplate: `
|
||||
<div id="userIntroSelectModal" class="modal fade list1_diagnosis" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header list1_modal_header">
|
||||
<h5 class="modal-title">고객조회</h5>
|
||||
</div>
|
||||
<div class="modal-body list1_modal_body">
|
||||
<div class="input-group mb-3">
|
||||
<div class="search_box flex-grow-1">
|
||||
<img src="/image/web/search_B.svg" style="width:20px;margin-right:8px;">
|
||||
<input id="introUserSearchKeyword" class="form-control" placeholder="성함, 연락처, 생년월일">
|
||||
</div>
|
||||
<button id="searchIntroUserBtn" class="btn btn-primary ms-2">검색</button>
|
||||
</div>
|
||||
<div class="list1_modal_table">
|
||||
<table class="table table-sm">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>성함</th><th>생년월일</th><th>성별</th><th>연락처</th><th>최근내원</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td colspan="5" class="text-center">검색어를 입력하세요.</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer list1_modal_footer">
|
||||
<button class="btn btn-secondary btnCancle">취소</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
};
|
||||
}
|
||||
|
||||
bindChoicesEvents() {
|
||||
const idSelect = document.getElementById('selectIdentification');
|
||||
if (idSelect) {
|
||||
idSelect.addEventListener('change', (e) => {
|
||||
const isPassport = e.target.value === 'pno';
|
||||
$('.passport_number_box').toggle(isPassport);
|
||||
$('.foreigner_number_box').toggle(!isPassport);
|
||||
const nationalityInstance = this.choicesInstances.get('nationality');
|
||||
if (nationalityInstance) {
|
||||
const element = nationalityInstance.passedElement.element;
|
||||
element.addEventListener('change', (event) => {
|
||||
this.data.nationalityCode = event.detail.value; // 국적 코드 업데이트
|
||||
this.updateUIByNationality(event.detail.value);
|
||||
});
|
||||
}
|
||||
|
||||
$('#modalAddress, #btnSearchAddress').on('click', () => {
|
||||
this.openAddrSearch();
|
||||
});
|
||||
|
||||
const eventMap = {
|
||||
'selectNationality': (e) => this.handleNationalityChange(e),
|
||||
'selectUserType': (e) => this.data.userType = e.target.value,
|
||||
'selectTreatment': (e) => this.data.treatment = e.target.value,
|
||||
'selectChannel': (e) => this.handleChannelChange(e)
|
||||
};
|
||||
|
||||
Object.entries(eventMap).forEach(([id, handler]) => {
|
||||
const element = document.getElementById(id);
|
||||
if (element) element.addEventListener('change', handler);
|
||||
// 체크박스 직접 클릭 방지 및 안내 문구 출력
|
||||
const consentIds = ['#agreePrivacy', '#agreeProcedure', '#agreeTerms', '#refusePhoto'];
|
||||
$(consentIds.join(', ')).on('click', (e) => {
|
||||
if (!this.allowSystemCheck) {
|
||||
e.preventDefault();
|
||||
alert('동의서 보기 버튼을 클릭하여 내용을 확인하신 후 [동의함] 버튼을 눌러주세요.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleNationalityChange(event) {
|
||||
this.data.nationalityCode = event.target.value;
|
||||
const selectedText = event.target.options[event.target.selectedIndex]?.text || '';
|
||||
const isKorean = selectedText.includes('대한민국') || event.target.value.includes('KR') || event.target.value === 'Local';
|
||||
this.data.nationality = isKorean ? 'Local' : 'Foreigner';
|
||||
this.toggleForeignerBox(!isKorean);
|
||||
}
|
||||
|
||||
handleChannelChange(event) {
|
||||
this.data.visitPath = event.target.value;
|
||||
const selectedText = event.target.options[event.target.selectedIndex]?.text || '';
|
||||
if (selectedText.includes('소개')) {
|
||||
$('.searchIntroUser').show();
|
||||
updateUIByNationality(selectedCode) {
|
||||
const $rrnLabel = $('label[for="modalUserRrn1"], .form-row:has(input[name="modalUserRrn1"]) label').first();
|
||||
const $passportBox = $('.foreigner_box');
|
||||
if (selectedCode === this.KOREA_CODE) {
|
||||
$rrnLabel.text('주민등록번호');
|
||||
$passportBox.hide();
|
||||
} else {
|
||||
$('input[name="modalRecommendId"]').val('').removeAttr('data-userid');
|
||||
$rrnLabel.text('외국인등록번호');
|
||||
$passportBox.show();
|
||||
}
|
||||
}
|
||||
|
||||
toggleForeignerBox(show) {
|
||||
$('.foreigner_box').toggle(show);
|
||||
$('.local_box').toggle(!show);
|
||||
}
|
||||
handleRrnInput(rrn1, genderDigitStr) {
|
||||
const genderDigit = parseInt(genderDigitStr, 10);
|
||||
const isMale = [1, 3, 5, 7].includes(genderDigit);
|
||||
if (isMale) $('#genderM').prop('checked', true);
|
||||
else $('#genderF').prop('checked', true);
|
||||
|
||||
loadCommonCategories() {
|
||||
const categories = [
|
||||
{ code: 'C202404110001', key: 'nationality' },
|
||||
{ code: 'C202404110002', key: 'userType' },
|
||||
{ code: 'C202404110003', key: 'channel' }
|
||||
];
|
||||
categories.forEach(({ code, key }) => this.fetchCategory(code, key));
|
||||
this.fetchTreatmentList();
|
||||
}
|
||||
|
||||
fetchCategory(code, choicesKey) {
|
||||
$.ajax({
|
||||
url: '/kiosk/getCategoryItem.do',
|
||||
type: 'POST',
|
||||
data: { categoryCode: code },
|
||||
success: (data) => {
|
||||
if (data.rows?.length > 0) {
|
||||
const choices = data.rows.map(item => ({
|
||||
value: item.categoryitemcode || item.commonCode || '',
|
||||
label: item.categoryitemname || item.codeName || ''
|
||||
}));
|
||||
const instance = this.choicesInstances.get(choicesKey);
|
||||
if (instance) {
|
||||
instance.setChoices(choices, 'value', 'label', true);
|
||||
if (choicesKey === 'nationality') {
|
||||
const defaultItem = choices.find(c => c.label.includes('대한민국'));
|
||||
if (defaultItem) {
|
||||
instance.setChoiceByValue(defaultItem.value);
|
||||
this.data.nationalityCode = defaultItem.value;
|
||||
this.data.nationality = 'Local';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
error: (xhr) => console.error(`카테고리 조회 실패 (${code}):`, xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
fetchTreatmentList() {
|
||||
$.ajax({
|
||||
url: '/kiosk/getTreatmentOptionList.do',
|
||||
type: 'POST',
|
||||
success: (data) => {
|
||||
if (data.rows?.length > 0) {
|
||||
const choices = data.rows.map(item => ({
|
||||
value: item.mutreatmentid || '',
|
||||
label: item.treatmentname || ''
|
||||
}));
|
||||
const instance = this.choicesInstances.get('treatment');
|
||||
if (instance) instance.setChoices(choices, 'value', 'label', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initDatepicker() {
|
||||
const birthdayInput = document.querySelector('input[name="modalBirthday"]');
|
||||
if (!birthdayInput) return;
|
||||
|
||||
this.datepickerInstance = flatpickr(birthdayInput, {
|
||||
locale: "ko",
|
||||
dateFormat: "Y-m-d",
|
||||
maxDate: "today",
|
||||
disableMobile: true,
|
||||
onChange: (selectedDates) => {
|
||||
if (selectedDates.length > 0) {
|
||||
this.calculateAgeAndRrn(selectedDates[0]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('.date-input-wrapper').off('click.datepicker').on('click.datepicker', (e) => {
|
||||
e.stopPropagation();
|
||||
this.datepickerInstance?.open();
|
||||
});
|
||||
}
|
||||
|
||||
calculateAgeAndRrn(birthDate) {
|
||||
let yearPrefix = [1, 2, 5, 6].includes(genderDigit) ? '19' : '20';
|
||||
const year = yearPrefix + rrn1.substring(0, 2);
|
||||
const month = rrn1.substring(2, 4);
|
||||
const day = rrn1.substring(4, 6);
|
||||
$('#modalBirthday').val(`${year}${month}${day}`);
|
||||
|
||||
const today = new Date();
|
||||
let age = today.getFullYear() - birthDate.getFullYear();
|
||||
let age = today.getFullYear() - parseInt(year);
|
||||
const birthDate = new Date(year, month - 1, day);
|
||||
const m = today.getMonth() - birthDate.getMonth();
|
||||
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) age--;
|
||||
$('.txtAge').text(`만 ${age}세`);
|
||||
|
||||
const yy = String(birthDate.getFullYear()).substring(2);
|
||||
const mm = String(birthDate.getMonth() + 1).padStart(2, '0');
|
||||
const dd = String(birthDate.getDate()).padStart(2, '0');
|
||||
$('input[name="modalUserRrn1"]').val(`${yy}${mm}${dd}`);
|
||||
}
|
||||
|
||||
bindEvents() {
|
||||
$('.cancel_btn').off('click.newPatient').on('click.newPatient', () => history.back());
|
||||
$('.registration_bth').off('click.newPatient').on('click.newPatient', () => this.save());
|
||||
|
||||
$('input[name="modalPhoneNumber"], input[name="modalPhoneNumber2"]')
|
||||
.off('input.phoneFormat').on('input.phoneFormat', function() {
|
||||
this.value = this.value.replace(/[^0-9]/g, '')
|
||||
.replace(/(\d{3})(\d{3,4})(\d{4})/, '$1-$2-$3').substring(0, 13);
|
||||
});
|
||||
|
||||
$('.searchIntroUser').off('click.newPatient').on('click.newPatient', () => {
|
||||
window.userIntroSelectModal?.popup((obj) => {
|
||||
$('input[name="modalRecommendId"]').val(obj.username || '').attr('data-userid', obj.muuserid || '');
|
||||
});
|
||||
initChoices() {
|
||||
const choicesConfig = { searchEnabled: true, itemSelectText: '', shouldSort: false, placeholderValue: '선택하세요' };
|
||||
['nationality', 'channel'].forEach(key => {
|
||||
const selector = key === 'nationality' ? '#selectNationality' : '#selectChannel';
|
||||
this.choicesInstances.set(key, new Choices(selector, choicesConfig));
|
||||
});
|
||||
}
|
||||
|
||||
async save() {
|
||||
const formData = this.collectFormData();
|
||||
if (!this.validateForm(formData)) return;
|
||||
|
||||
try {
|
||||
const response = await this.submitForm(formData);
|
||||
this.handleSaveResponse(response);
|
||||
} catch (error) {
|
||||
this.showError('통신 중 오류가 발생했습니다.');
|
||||
}
|
||||
loadCommonCategories() {
|
||||
const categories = [{ code: 'C202404110001', key: 'nationality' }, { code: 'C202404110003', key: 'channel' }];
|
||||
categories.forEach(({ code, key }) => this.fetchCategory(code, key));
|
||||
}
|
||||
|
||||
collectFormData() {
|
||||
return {
|
||||
userName: $('input[name="modalUserName"]').val()?.trim() || '',
|
||||
phone: $('input[name="modalPhoneNumber"]').val().replace(/-/g, '') || '',
|
||||
phone2: $('input[name="modalPhoneNumber2"]').val().replace(/-/g, '') || '',
|
||||
birthday: $('input[name="modalBirthday"]').val() || '',
|
||||
gender: $('input[name="modalGender"]:checked').val() || '',
|
||||
smsYn: $('input[name="modalSmsYn"]:checked').val() || '',
|
||||
refusePhoto: $('input[name="modalRefusePhotoYn"]:checked').val() || '',
|
||||
rrn1: $('input[name="modalUserRrn1"]').val() || '',
|
||||
rrn2: $('input[name="modalUserRrn2"]').val() || '',
|
||||
pno: $('input[name="modalUserPno"]').val() || '',
|
||||
arc1: $('input[name="modalUserArc1"]').val() || '',
|
||||
arc2: $('input[name="modalUserArc2"]').val() || '',
|
||||
memo: $('textarea[name="modalMemo"]').val() || '',
|
||||
etc: $('textarea[name="modalEtc"]').val() || '',
|
||||
introUserId: $('input[name="modalRecommendId"]').attr('data-userid') || '',
|
||||
...this.data
|
||||
};
|
||||
}
|
||||
|
||||
validateForm(data) {
|
||||
const errors = {
|
||||
userName: !data.userName && '고객명을 입력해주세요.',
|
||||
phone: (!data.phone || data.phone.length < 10) && '올바른 연락처를 입력해주세요.',
|
||||
privacy: !$('#agree_privacy').is(':checked') && '개인정보 수집 이용에 동의해야 합니다.'
|
||||
};
|
||||
|
||||
const errorMsg = Object.values(errors).find(Boolean);
|
||||
if (errorMsg && window.modalEvent) {
|
||||
window.modalEvent.warning('알림', errorMsg);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
submitForm(data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
url: '/kiosk/putUser.do',
|
||||
type: 'POST',
|
||||
data: {
|
||||
nationality: data.nationality,
|
||||
nationalityCode: data.nationalityCode,
|
||||
userName: data.userName,
|
||||
phoneNumber: data.phone,
|
||||
phoneNumber2: data.phone2,
|
||||
birthday: data.birthday,
|
||||
gender: data.gender,
|
||||
userRrn1: data.rrn1,
|
||||
userRrn2: data.rrn2,
|
||||
userPno: data.pno,
|
||||
userArc1: data.arc1,
|
||||
userArc2: data.arc2,
|
||||
userTypeCode: data.userType,
|
||||
channelCode: data.visitPath,
|
||||
muGroupId: data.treatment,
|
||||
introUserId: data.introUserId,
|
||||
memo: data.memo,
|
||||
etc: data.etc,
|
||||
smsYn: data.smsYn,
|
||||
refusePhotoYn: data.refusePhoto
|
||||
},
|
||||
success: resolve,
|
||||
error: reject
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
handleSaveResponse(data) {
|
||||
if (data.msgCode === '0') {
|
||||
if (window.modalEvent) {
|
||||
window.modalEvent.success('등록 성공', '신규 고객 등록이 완료되었습니다.', () => {
|
||||
location.href = '/kiosk/kiosk_main';
|
||||
});
|
||||
} else {
|
||||
location.href = '/kiosk/kiosk_main';
|
||||
fetchCategory(code, choicesKey) {
|
||||
$.post('/kiosk/getCategoryItem.do', { categoryCode: code }, (data) => {
|
||||
if (data.rows?.length > 0) {
|
||||
const choices = data.rows.map(item => ({ value: item.categoryItemCode || item.commonCode, label: item.categoryItemName || item.codeName }));
|
||||
const instance = this.choicesInstances.get(choicesKey);
|
||||
if (instance) {
|
||||
instance.setChoices(choices, 'value', 'label', true);
|
||||
if (choicesKey === 'nationality') {
|
||||
instance.setChoiceByValue(this.KOREA_CODE);
|
||||
this.data.nationalityCode = this.KOREA_CODE; // 초기 국적 설정
|
||||
this.updateUIByNationality(this.KOREA_CODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (window.modalEvent) {
|
||||
window.modalEvent.danger('오류', data.msgDesc || '등록에 실패했습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
showError(message) {
|
||||
if (window.modalEvent) {
|
||||
window.modalEvent.danger('오류', message);
|
||||
} else {
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.choicesInstances.forEach(instance => instance?.destroy());
|
||||
this.choicesInstances.clear();
|
||||
this.datepickerInstance?.destroy();
|
||||
$('#userIntroSelectModal')?.remove();
|
||||
this.isInitialized = false;
|
||||
});
|
||||
}
|
||||
|
||||
openAddrSearch() {
|
||||
new daum.Postcode({
|
||||
oncomplete: (data) => {
|
||||
let addr = data.userSelectedType === 'R' ? data.roadAddress : data.jibunAddress;
|
||||
document.getElementById("modalAddress").value = addr;
|
||||
document.getElementById("modalAddressDetail").focus();
|
||||
}
|
||||
}).open();
|
||||
}
|
||||
}
|
||||
|
||||
// 싱글톤 인스턴스 관리
|
||||
let instance = null;
|
||||
window.newPatientPage = {
|
||||
init() {
|
||||
if (instance) return;
|
||||
instance = new NewPatientPage();
|
||||
instance.init();
|
||||
},
|
||||
destroy() {
|
||||
instance?.destroy();
|
||||
instance = null;
|
||||
},
|
||||
getInstance() {
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
$(document).ready(() => {
|
||||
const pageApp = new NewPatientPage();
|
||||
window.newPatientPage = pageApp;
|
||||
pageApp.init();
|
||||
|
||||
$('.consent-link').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
openConsentDialog($(this).data('type'));
|
||||
});
|
||||
|
||||
// 자동 초기화
|
||||
const init = () => window.newPatientPage.init();
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
setTimeout(init, 50);
|
||||
}
|
||||
window.addEventListener('load', () => setTimeout(init, 100));
|
||||
})();
|
||||
function openConsentDialog(type) {
|
||||
if ($('#dynamicConsentDialog').length) $('#dynamicConsentDialog').dialog('destroy').remove();
|
||||
|
||||
const $dialog = $('<div id=\"dynamicConsentDialog\" style=\"overflow-y: auto; padding: 20px; line-height: 1.6;\"></div>');
|
||||
let isAgreed = false;
|
||||
|
||||
$dialog.dialog({
|
||||
modal: true, width: 800, height: 700,
|
||||
title: getDialogTitle(type),
|
||||
resizable: false, draggable: true,
|
||||
buttons: [
|
||||
{
|
||||
text: "동의함", class: "registration_bth",
|
||||
click: function() {
|
||||
isAgreed = true;
|
||||
pageApp.allowSystemCheck = true;
|
||||
$('#' + type).prop('checked', true);
|
||||
pageApp.allowSystemCheck = false;
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
{ text: "닫기", class: "cancel_btn", click: function() { $(this).dialog('close'); } }
|
||||
],
|
||||
close: function() {
|
||||
if (!isAgreed) {
|
||||
pageApp.allowSystemCheck = true;
|
||||
$('#' + type).prop('checked', false);
|
||||
pageApp.allowSystemCheck = false;
|
||||
}
|
||||
$(this).dialog('destroy').remove();
|
||||
}
|
||||
});
|
||||
|
||||
$dialog.html('<div style=\"text-align:center; padding:50px;\">내용을 불러오는 중입니다...</div>');
|
||||
|
||||
$.ajax({
|
||||
url: '/kiosk/getConsentForm.do',
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({
|
||||
consentFormTypeCd: getConsentFormTypeCd(type), // 코드로 변환하여 전송
|
||||
nationalCd: pageApp.data.nationalityCode // 현재 국적 코드 전송
|
||||
}),
|
||||
success: function(res) {
|
||||
if(res && res.consentFormContent) {
|
||||
$dialog.html(res.consentFormContent);
|
||||
} else {
|
||||
$dialog.html('<div style=\"text-align:center; color:red;\">등록된 동의서 내용이 없습니다.</div>');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$dialog.html('<div style=\"text-align:center; color:red;\">서버 통신 중 오류가 발생했습니다.</div>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getDialogTitle(type) {
|
||||
const titles = {
|
||||
'agreePrivacy': '개인정보 수집 및 이용안내',
|
||||
'agreeProcedure': '시술동의서',
|
||||
'agreeTerms': '이용약관',
|
||||
'refusePhoto': '사진촬영거부동의서'
|
||||
};
|
||||
return titles[type] || '동의서';
|
||||
}
|
||||
|
||||
/**
|
||||
* type 명칭을 DB consentFormTypeCd 코드로 변환
|
||||
*/
|
||||
function getConsentFormTypeCd(type) {
|
||||
const typeMapping = {
|
||||
'agreePrivacy': 'C202601180001',
|
||||
'agreeProcedure': 'C202601180002',
|
||||
'agreeTerms': 'C202601180003',
|
||||
'refusePhoto': 'C202601180004'
|
||||
};
|
||||
return typeMapping[type] || '';
|
||||
}
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user