|
@@ -58,6 +58,13 @@ class Database
|
|
|
*/
|
|
|
private $search = false;
|
|
|
|
|
|
+ /**
|
|
|
+ * chart
|
|
|
+ *
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ private $chart = false;
|
|
|
+
|
|
|
/**
|
|
|
* __construct
|
|
|
*
|
|
@@ -628,6 +635,9 @@ class Database
|
|
|
$config['end']['insert'] = $v['value'];
|
|
|
}
|
|
|
*/
|
|
|
+ if (isset($v['search_button'])) {
|
|
|
+ $config['manage']['search']['button'][$k] = $v['search_button'];
|
|
|
+ }
|
|
|
|
|
|
if (isset($v['update'])) {
|
|
|
if (!isset($config['manage']['insert'])) {
|
|
@@ -1109,7 +1119,30 @@ class Database
|
|
|
$search = Dever::preInput('search_');
|
|
|
|
|
|
$node = Html::node(array(' style="margin-top:0px;"', ''));
|
|
|
- $btn = '<div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel"><button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="$(\'#form1\').attr(\'action\', \'' . $this->url('search') . '\');list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button></div>';
|
|
|
+
|
|
|
+ $btn = '<div class="layui-inline"><input type="hidden" value="2" name="excel" id="excel">';
|
|
|
+
|
|
|
+ if (isset($config['manage']['search']['button'])) {
|
|
|
+ foreach ($config['manage']['search']['button'] as $k => $v) {
|
|
|
+ $i = 0;
|
|
|
+ foreach ($v['option'] as $k1 => $v1) {
|
|
|
+ $value = $k . '_' . $v['sum'] . '_' . $k1;
|
|
|
+ if (!isset($search['search_button']) && $i == 0) {
|
|
|
+ $search['search_button'] = $value;
|
|
|
+ }
|
|
|
+ if (isset($search['search_button']) && $search['search_button'] == $value) {
|
|
|
+ $class = 'layui-btn-normal';
|
|
|
+ } else {
|
|
|
+ $class = 'layui-btn-primary';
|
|
|
+ }
|
|
|
+
|
|
|
+ $url = $this->url('list', 0, false, '&search_button=' . $k . '_' . $v['sum'] . '_' . $k1);
|
|
|
+ $btn .= '<a class="btn btn-primary layui-btn layuiadmin-btn-list '.$class.'" href="'.$url.'" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">'.$v1.'</a> ';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $btn .= '<button class="btn btn-primary layui-btn layuiadmin-btn-list" onclick="$(\'#form1\').attr(\'action\', \'' . $this->url('search') . '\');list_search($(this))" type="button" style="height: 38px;margin-left:0px;margin-top:-2px;">搜索</button></div>';
|
|
|
|
|
|
//$result .= '<form id="f1" action="'.$this->url('list').'" method="post">';
|
|
|
|
|
@@ -2254,6 +2287,10 @@ class Database
|
|
|
$return[$i][$ki] = $text;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ if (isset($config['manage']['chart'])) {
|
|
|
+ $this->chart($config['manage']['chart'], $ki, $return[$i][$ki], $vi);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3350,6 +3387,130 @@ class Database
|
|
|
return 'reload';
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * list_data
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function list_data()
|
|
|
+ {
|
|
|
+ $config = $this->config();
|
|
|
+ $data = array();
|
|
|
+ if (isset($config['manage']['data'])) {
|
|
|
+ foreach ($config['manage']['data'] as $k => $v) {
|
|
|
+ if (is_object($v[1])) {
|
|
|
+ $function = $v[1];
|
|
|
+ $v[1] = $function();
|
|
|
+ }
|
|
|
+ $data[] = '<li class="layui-col-xs3">
|
|
|
+ <a class="layadmin-backlog-body"><h3>'.$v[0].'</h3>
|
|
|
+ <p><cite>'.$v[1].'</cite></p></a></li>';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * list_data
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function list_data_show()
|
|
|
+ {
|
|
|
+ $config = $this->config();
|
|
|
+ if (isset($config['manage']['data'])) {
|
|
|
+ return 'display:block';
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'display:none';
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * chart
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function chart($config, $key, $data, $struct)
|
|
|
+ {
|
|
|
+ if (!$this->chart) {
|
|
|
+ $this->chart = array();
|
|
|
+ $this->chart['x'] = array();
|
|
|
+ $this->chart['data'] = array();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($config['x'] == $key) {
|
|
|
+ $this->chart['x'][] = $data;
|
|
|
+ } elseif (in_array($key, $config['data'])) {
|
|
|
+ if (!isset($this->chart['data'][$key])) {
|
|
|
+ $this->chart['data'][$key] = array
|
|
|
+ (
|
|
|
+ 'name' => $struct['name'],
|
|
|
+ 'type' => 'line',
|
|
|
+ 'stack' => 'Total',
|
|
|
+ 'data' => array(),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->chart['data'][$key]['data'][] = $data;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * chart_data
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function list_chart()
|
|
|
+ {
|
|
|
+ $config = $this->config();
|
|
|
+ $chart = '';
|
|
|
+ if (isset($config['manage']['chart']) && $this->chart) {
|
|
|
+ $x = Dever::json_encode($this->chart['x']);
|
|
|
+ $this->chart['data'] = array_values($this->chart['data']);
|
|
|
+ $data = Dever::json_encode($this->chart['data']);
|
|
|
+ $echarts = Dever::assets('lib/echarts/echarts.common.min.js', 'script');
|
|
|
+ $chart = '<script type="text/javascript" src="'.$echarts.'"></script><script>var chartDom = document.getElementById("chart");var myChart = echarts.init(chartDom);';
|
|
|
+ $chart .= "var option = {
|
|
|
+ tooltip: {
|
|
|
+ trigger: 'axis'
|
|
|
+ },
|
|
|
+
|
|
|
+ toolbox: {
|
|
|
+ feature: {
|
|
|
+ saveAsImage: {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: 'category',
|
|
|
+ boundaryGap: false,
|
|
|
+ data: ".$x."
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: 'value'
|
|
|
+ },
|
|
|
+ series: ".$data."
|
|
|
+ };option && myChart.setOption(option);</script>";
|
|
|
+ }
|
|
|
+
|
|
|
+ return $chart;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * chart_data
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function list_chart_show()
|
|
|
+ {
|
|
|
+ $config = $this->config();
|
|
|
+ if (isset($config['manage']['chart'])) {
|
|
|
+ return 'display:block';
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'display:none';
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* stat 为主动统计提供相关数据
|
|
|
*
|