chore(version): 버전 8.58 업데이트 및 문자 이력 고객정보 저장 기능 추가
수동 일반 발주의 이름·연락처·주소를 문자 이력에 함께 저장하고 최근 전송 메시지 클릭 시 다시 불러오도록 개선 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+51
-7
@@ -1201,12 +1201,19 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
});
|
||||
|
||||
const custName = document.getElementById('cust-name').value.trim();
|
||||
const custPhone = document.getElementById('cust-phone').value.trim();
|
||||
const custAddress = document.getElementById('cust-address').value.trim();
|
||||
|
||||
const histData = {
|
||||
timestamp: stamp,
|
||||
deposit_amount_str: finalPayable.toLocaleString() + "원",
|
||||
custName: document.getElementById('cust-name').value.trim(),
|
||||
custPhone: document.getElementById('cust-phone').value.trim(),
|
||||
custAddress: document.getElementById('cust-address').value.trim(),
|
||||
custName: custName,
|
||||
custPhone: custPhone,
|
||||
custAddress: custAddress,
|
||||
customer_name: custName,
|
||||
phone: custPhone,
|
||||
address: custAddress,
|
||||
orderType: document.querySelector('input[name="order-type"]:checked').value,
|
||||
noLid: document.getElementById('chk-no-lid').checked,
|
||||
items: savedItems,
|
||||
@@ -1224,7 +1231,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(histData)
|
||||
}).then(() => loadSmsHistory());
|
||||
}).then(() => {
|
||||
writeSmsCustomerCache(stamp, {
|
||||
custName: custName,
|
||||
custPhone: custPhone,
|
||||
custAddress: custAddress
|
||||
});
|
||||
loadSmsHistory();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@@ -1232,6 +1246,32 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
// ============================================
|
||||
// SMS HISTORY
|
||||
// ============================================
|
||||
const SMS_CUSTOMER_CACHE_KEY = 'smsCustomerHistoryByTimestamp';
|
||||
|
||||
function readSmsCustomerCache() {
|
||||
try {
|
||||
return JSON.parse(localStorage.getItem(SMS_CUSTOMER_CACHE_KEY) || '{}');
|
||||
} catch (e) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
function writeSmsCustomerCache(timestamp, customer) {
|
||||
if (!timestamp) return;
|
||||
const cache = readSmsCustomerCache();
|
||||
cache[timestamp] = customer;
|
||||
localStorage.setItem(SMS_CUSTOMER_CACHE_KEY, JSON.stringify(cache));
|
||||
}
|
||||
|
||||
function firstNonEmpty(...values) {
|
||||
for (const value of values) {
|
||||
if (value !== undefined && value !== null && String(value).trim() !== '') {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function loadSmsHistory() {
|
||||
const u = document.getElementById('sms-history-list');
|
||||
u.innerHTML = '';
|
||||
@@ -1338,9 +1378,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
document.getElementById('btn-reset').click();
|
||||
|
||||
if (d.custName !== undefined) document.getElementById('cust-name').value = d.custName;
|
||||
if (d.custPhone !== undefined) document.getElementById('cust-phone').value = d.custPhone;
|
||||
if (d.custAddress !== undefined) document.getElementById('cust-address').value = d.custAddress;
|
||||
const cachedCustomer = readSmsCustomerCache()[d.timestamp] || {};
|
||||
const savedCustName = firstNonEmpty(d.custName, d.customer_name, cachedCustomer.custName, cachedCustomer.customer_name);
|
||||
const savedCustPhone = firstNonEmpty(d.custPhone, d.phone, cachedCustomer.custPhone, cachedCustomer.phone);
|
||||
const savedCustAddress = firstNonEmpty(d.custAddress, d.address, cachedCustomer.custAddress, cachedCustomer.address);
|
||||
document.getElementById('cust-name').value = savedCustName;
|
||||
document.getElementById('cust-phone').value = savedCustPhone;
|
||||
document.getElementById('cust-address').value = savedCustAddress;
|
||||
if (d.orderType !== undefined) {
|
||||
const rb = document.querySelector(`input[name="order-type"][value="${d.orderType}"]`);
|
||||
if (rb) rb.checked = true;
|
||||
|
||||
Reference in New Issue
Block a user