From df96e69034016101ee5f68656d63cdc92e81ff86 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Tue, 12 Dec 2023 17:22:16 +0800 Subject: [PATCH] * Add fetch api for screen preview chart data. --- module/screen/control.php | 8 +++++++- module/screen/js/view.js | 2 +- module/screen/model.php | 4 ++-- module/screen/view/view.html.php | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/module/screen/control.php b/module/screen/control.php index 815c7fd16c..28915086fb 100644 --- a/module/screen/control.php +++ b/module/screen/control.php @@ -84,7 +84,7 @@ class screen extends control return; } - $screen = $this->screen->getByID($screenID, $year, $month, $dept, $account); + $screen = $this->screen->getByID($screenID, $year, $month, $dept, $account, false); $this->view->title = $screen->name; $this->view->screen = $screen; @@ -106,6 +106,12 @@ class screen extends control } } + public function ajaxGetScreenScheme($screenID, $year = 0, $month = 0, $dept = 0, $account = '') + { + $screen = $this->screen->getByID($screenID, $year, $month, $dept, $account); + echo(json_encode($screen)); + } + /** * Ajax get chart. * diff --git a/module/screen/js/view.js b/module/screen/js/view.js index b7403a1726..37d87cf6da 100644 --- a/module/screen/js/view.js +++ b/module/screen/js/view.js @@ -26,7 +26,7 @@ self["MonacoEnvironment"] = (function(paths) { }); location.hash = '#/chart/preview/' + screen.id; -window.chartData = screen.chartData; window.location.replace(window.location.href.toString().replace(window.location.hash, '')+'#/chart/preview/' + screen.id) window.fetchChartApi = createLink('screen', 'ajaxGetChart'); window.fetchMetricDataApi = createLink('screen', 'ajaxGetMetricData'); +window.fetchScreenSchemeApi = createLink('screen', 'ajaxGetScreenScheme', 'screenID=' + screen.id + '&year=' + year + '&month=' + month + '&dept=' + dept + '&account=' + account); diff --git a/module/screen/model.php b/module/screen/model.php index 387524a20d..f8e67137a2 100644 --- a/module/screen/model.php +++ b/module/screen/model.php @@ -68,11 +68,11 @@ class screenModel extends model * @access public * @return object */ - public function getByID($screenID, $year = '', $month = '', $dept = '', $account = '') + public function getByID($screenID, $year = '', $month = '', $dept = '', $account = '', $withChartData = true) { $screen = $this->dao->select('*')->from(TABLE_SCREEN)->where('id')->eq($screenID)->fetch(); if(!isset($screen->scheme) or empty($screen->scheme)) $screen->scheme = file_get_contents(__DIR__ . '/json/screen.json'); - $screen->chartData = $this->genChartData($screen, $year, $month, $dept, $account); + if($withChartData) $screen->chartData = $this->genChartData($screen, $year, $month, $dept, $account); return $screen; } diff --git a/module/screen/view/view.html.php b/module/screen/view/view.html.php index 4271dc9e8c..63aa4d8a2f 100644 --- a/module/screen/view/view.html.php +++ b/module/screen/view/view.html.php @@ -2,6 +2,7 @@ +