From 06715272c8cc40c7e6349abdf7a93f90d03aeb24 Mon Sep 17 00:00:00 2001 From: xman <1946321327@qq.com> Date: Thu, 24 Apr 2025 16:10:12 +0800 Subject: [PATCH] sth --- .../controller/statistics/Dispatcher.php | 9 ++-- application/config.php | 3 ++ .../js/backend/statistics/dispatcher.js | 41 ++++++++++++++----- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/application/admin/controller/statistics/Dispatcher.php b/application/admin/controller/statistics/Dispatcher.php index dc4b4a2..1793ac0 100644 --- a/application/admin/controller/statistics/Dispatcher.php +++ b/application/admin/controller/statistics/Dispatcher.php @@ -52,11 +52,14 @@ class Dispatcher extends Backend $today = now()->format('Y-m-d'); $today_end = now()->format('Y-m-d'); + //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if (false === $this->request->isAjax()) { $this->assign('daterange',$today.' - '.$today_end); + $this->assignconfig('default_daterange',now()->format('Y-m-d 00:00:00').' - '.now()->format('Y-m-d 23:59:59')); + return $this->view->fetch(); } @@ -99,7 +102,7 @@ class Dispatcher extends Backend $newData = [ - ['派单员','总业绩(¥)','转化率(%)','利润率(%)','变现值'] + ['派单员','总业绩','转化率','利润率','变现值'] ]; foreach ($data as $datum){ $newData[] = [ @@ -127,7 +130,7 @@ class Dispatcher extends Backend "COUNT(CASE WHEN status = 60 THEN 1 END) AS finish_num", //完成数 "COUNT(CASE WHEN status IN (".$orderValid.") THEN 1 END) AS count_num", //总订单数 (排除取消 和草稿) "SUM(CASE WHEN status = 60 THEN total END) AS total", //成效额 - "SUM(CASE WHEN status = 60 THEN total END) AS performance", //业绩 + "SUM(CASE WHEN status = 60 THEN performance END) AS performance", //业绩 "SUM(CASE WHEN status = 60 THEN (cost + material_cost) END) AS cost_total", //总成本 @@ -189,7 +192,7 @@ class Dispatcher extends Backend }else{ $datum->admin_user = '系统'; } - $datum->avg_time_diff = $this->_calc($datum->avg_time_diff,3600,2); + $datum->avg_time_diff = $this->_calc($datum->avg_time_diff,3600*24,2); $datum->id = $datum->dispatch_admin_id; $newData[] = $datum->toArray(); diff --git a/application/config.php b/application/config.php index 826251f..a67f2e6 100755 --- a/application/config.php +++ b/application/config.php @@ -214,6 +214,9 @@ return [ // 是否自动开启 SESSION 'auto_start' => true, + //有效期 + 'expire' => 3600*24, + 'type' => 'redis', 'host' => Env::get('redis.redis_host'), // Redis 服务器地址 'port' => Env::get('redis.redis_port'), // Redis 端口 diff --git a/public/assets/js/backend/statistics/dispatcher.js b/public/assets/js/backend/statistics/dispatcher.js index 7af3b11..5c4bb02 100644 --- a/public/assets/js/backend/statistics/dispatcher.js +++ b/public/assets/js/backend/statistics/dispatcher.js @@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-t columns: [ [ //{field: 'id', title: __('Id')}, - {field: 'id', title: __('ID'),visible:false,operate: false}, + {field: 'id', title: __('ID'),visible:true,operate: false}, {field: 'admin_user', title: __('派单员'),operate: "LIKE"}, {field: 'count_num', title: __('总订单数'),operate: false}, {field: 'finish_num', title: __('完单数'),operate: false}, @@ -45,7 +45,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-t {field: 'performance_avg', title: __('客单利润(¥)'), operate: false}, {field: 'total_avg', title: __('客单价(¥)'), operate: false}, - {field: 'avg_time_diff', title: __('派单时效(小时)'), operate: false}, + {field: 'avg_time_diff', title: __('派单时效(天)'), operate: false}, //{field: 'admin_user', title: __('派单员'),operate: "LIKE",visible:false}, //{field: 'city_name', title: __('城市'),operate: "LIKE",visible:false}, @@ -57,7 +57,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-t datetimeFormat: "YYYY-MM-DD", //defaultValue:today()+' - '+today(), data:'autocomplete="off" data-local={"format":"YYYY-MM-DD"}', - visible:false}, + visible:false, + defaultValue: Config.default_daterange + }, // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] @@ -105,6 +107,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-t // ] // } + const headers = response[0]; + const units = ['元', '%', '%', '']; // 如果你有单位可以一起拼接 + var barChart = Echarts.init(document.getElementById('bar-chart'), 'walden'); var option = { legend: {}, @@ -112,14 +117,30 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'echarts', 'echarts-t dataset: { source: response }, - xAxis: { type: 'category' }, + xAxis: { + type: 'category', + axisLabel: { + show: true // 隐藏“系统” + }, + axisTick: { show: false }, + axisLine: { show: false } + }, yAxis: {}, - series: [ - { type: 'bar' }, - { type: 'bar' }, - { type: 'bar' }, - { type: 'bar' } - ] + series: headers.slice(1).map((title, i) => ({ + type: 'bar', + label: { + show: true, + position: 'top', + formatter: function (params) { + const value = params.value[i + 1]; // 因为第一列是“派单员” + const unit = units[i] || ''; + return `${value} ${unit}`; // 显示数值 + 单位 + } + }, + itemStyle: { + borderRadius: 4 + } + })) }; barChart.setOption(option); },