feat(WorkbenchController): 根据日期参数动态生成图表数据

This commit is contained in:
mkm 2024-06-22 14:56:13 +08:00
parent 13987de998
commit fd0b942c85
3 changed files with 30 additions and 9 deletions

View File

@ -98,14 +98,32 @@ class WorkbenchController extends BaseAdminController
public function get_trend()
{
$dates = [];
$today = new DateTime();
$thirtyDaysAgo = new DateTime($today->format('Y-m-d'));
$thirtyDaysAgo->modify('-30 days');
for ($i = 0; $i < 31; $i++) {
$date = new DateTime($thirtyDaysAgo->format('Y-m-d'));
$date->modify('+' . $i . ' days');
$dates[] = $date->format('Y-m-d');
$date=$this->request->get('date','');
$days=31;
if($date){
$arr=explode('-', $date);
if($arr[0]==$arr[1]){
$date = new DateTime($arr[0]);
$dates[] = $date->format("Y-m-d");
}else{
$datetime_start = new DateTime($arr[0]);
$datetime_end = new DateTime($arr[1]);
$days = $datetime_start->diff($datetime_end)->days;
for ($i = 0; $i <= $days; $i++) {
$date = new DateTime($datetime_start->format('Y-m-d'));
$date->modify('+' . $i . ' days');
$dates[] = $date->format('Y-m-d');
}
}
}else{
$today = new DateTime();
$thirtyDaysAgo = new DateTime($today->format('Y-m-d'));
$thirtyDaysAgo->modify('-30 days');
for ($i = 0; $i < $days; $i++) {
$date = new DateTime($thirtyDaysAgo->format('Y-m-d'));
$date->modify('+' . $i . ' days');
$dates[] = $date->format('Y-m-d');
}
}
$data = [
"xAxis" => $dates,

View File

@ -56,6 +56,7 @@ class StoreCashFinanceFlowController extends BaseAdminController
public function edit()
{
$params = (new StoreCashFinanceFlowValidate())->post()->goCheck('edit');
$params['admin_id']=$this->adminId;
$result = StoreCashFinanceFlowLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);

View File

@ -54,7 +54,9 @@ class StoreCashFinanceFlowLogic extends BaseLogic
Db::startTrans();
try {
StoreCashFinanceFlow::where('id', $params['id'])->update([
'file' => $params['file']
'file' => $params['file'],
'static'=>1,
'admin_id'=>$params['admin_id'],
]);
Db::commit();