diff --git a/config.py b/config.py index 51c04f4..83e0371 100644 --- a/config.py +++ b/config.py @@ -320,7 +320,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.171" +SYSTEM_VERSION = "V10.172" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示 diff --git a/templates/daily_sales.html b/templates/daily_sales.html index 540ceba..3a5e054 100644 --- a/templates/daily_sales.html +++ b/templates/daily_sales.html @@ -52,7 +52,11 @@ {% endmacro %} {% block ewooo_content %} -
+
{% include 'components/_analysis_report_tabs.html' ignore missing %} {% if error %} @@ -76,7 +80,7 @@
- {% for date in available_dates %} {% endfor %} @@ -93,7 +97,7 @@ {% else %} 單日 {{ selected_date }} - + 月度總計 {% endif %} @@ -144,15 +148,15 @@ {% if calendar_data %}
-

+

{{ calendar_data.month_name }} 業績行事曆

@@ -174,7 +178,6 @@ {% if day.date == selected_date and not is_month_view %}is-selected{% endif %}" data-date="{{ day.date }}" data-has-data="{{ 'true' if day.has_data and day.is_current_month else 'false' }}" - onclick="{% if day.has_data and day.is_current_month %}toggleDateSelection('{{ day.date }}', '{{ selected_date }}'){% endif %}" title="{% if day.is_holiday %}🎊 {{ day.holiday_name | e }} | {% endif %}{{ day.weekday | e }}{% if day.has_data %} | 業績 ${{ '{:,.0f}'.format(day.revenue) }} | 毛利 ${{ '{:,.0f}'.format(day.profit) }} | DoD {{ day.dod_percent | e }}%{% endif %}">
@@ -302,7 +305,7 @@
行銷活動業績貢獻 -
@@ -348,7 +351,7 @@ {% elif category_total > category_visible %} 顯示全部 {% endif %} - diff --git a/web/static/js/page-daily-sales.js b/web/static/js/page-daily-sales.js index e8c773f..e720038 100644 --- a/web/static/js/page-daily-sales.js +++ b/web/static/js/page-daily-sales.js @@ -316,14 +316,14 @@ }); } - // -- Navigation handlers (global) ---------------------------------- - window.changeDate = function () { + // -- Navigation handlers ------------------------------------------- + function changeDate() { const sel = document.getElementById('dateSelector'); if (!sel) return; window.location.href = `/daily_sales?date=${sel.value}`; - }; + } - window.toggleDateSelection = function (clickedDate, currentSelectedDate) { + function toggleDateSelection(clickedDate, currentSelectedDate) { const isMonthView = window.__DAILY_SALES__.isMonthView; if (isMonthView) { window.location.href = `/daily_sales?date=${clickedDate}`; @@ -334,28 +334,28 @@ } else { window.location.href = `/daily_sales?date=${clickedDate}`; } - }; + } - window.backToMonthView = function () { + function backToMonthView() { const params = new URLSearchParams(window.location.search); const month = params.get('month'); window.location.href = month ? `/daily_sales?month=${month}` : '/daily_sales'; - }; + } - window.changeMonth = function (month) { + function changeMonth(month) { window.location.href = `/daily_sales?month=${month}`; - }; + } // -- Export handlers ----------------------------------------------- - window.exportCategoryTable = function () { + function exportCategoryTable() { const sel = document.getElementById('dateSelector'); if (!sel || !sel.value) { alert('請先選擇日期'); return; } window.location.href = `/daily_sales/export?date=${sel.value}`; - }; + } - window.exportMarketingData = function () { + function exportMarketingData() { const sel = document.getElementById('dateSelector'); const date = sel ? sel.value : ''; const params = new URLSearchParams(window.location.search); @@ -372,7 +372,50 @@ url += `&date=${date}`; } window.location.href = url; - }; + } + + function initDailySalesActions() { + const page = document.querySelector('.daily-sales-page'); + const selectedDate = page ? page.dataset.selectedDate : ''; + + document.querySelectorAll('[data-daily-date-selector]').forEach(select => { + select.addEventListener('change', changeDate); + }); + + document.querySelectorAll('[data-daily-action="month-view"]').forEach(control => { + control.addEventListener('click', event => { + event.preventDefault(); + backToMonthView(); + }); + control.addEventListener('keydown', event => { + if (event.key !== 'Enter' && event.key !== ' ') return; + event.preventDefault(); + backToMonthView(); + }); + }); + + document.querySelectorAll('[data-daily-month]').forEach(button => { + button.addEventListener('click', () => changeMonth(button.dataset.dailyMonth)); + }); + + document.querySelectorAll('.cal-day[data-has-data="true"][data-date]').forEach(day => { + day.addEventListener('click', () => toggleDateSelection(day.dataset.date, selectedDate)); + day.addEventListener('keydown', event => { + if (event.key !== 'Enter' && event.key !== ' ') return; + event.preventDefault(); + toggleDateSelection(day.dataset.date, selectedDate); + }); + day.setAttribute('role', 'button'); + day.setAttribute('tabindex', '0'); + }); + + document.querySelectorAll('[data-daily-export="marketing"]').forEach(button => { + button.addEventListener('click', exportMarketingData); + }); + document.querySelectorAll('[data-daily-export="category"]').forEach(button => { + button.addEventListener('click', exportCategoryTable); + }); + } // -- Boot ----------------------------------------------------------- function renderAllCharts() { @@ -413,6 +456,7 @@ } document.addEventListener('DOMContentLoaded', function () { + initDailySalesActions(); initDataTable(); observeCharts(); });