feat(WorkbenchController): 根据日期参数动态生成图表数据
This commit is contained in:
parent
13987de998
commit
fd0b942c85
@ -98,15 +98,33 @@ class WorkbenchController extends BaseAdminController
|
|||||||
public function get_trend()
|
public function get_trend()
|
||||||
{
|
{
|
||||||
$dates = [];
|
$dates = [];
|
||||||
|
$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();
|
$today = new DateTime();
|
||||||
$thirtyDaysAgo = new DateTime($today->format('Y-m-d'));
|
$thirtyDaysAgo = new DateTime($today->format('Y-m-d'));
|
||||||
$thirtyDaysAgo->modify('-30 days');
|
$thirtyDaysAgo->modify('-30 days');
|
||||||
|
for ($i = 0; $i < $days; $i++) {
|
||||||
for ($i = 0; $i < 31; $i++) {
|
|
||||||
$date = new DateTime($thirtyDaysAgo->format('Y-m-d'));
|
$date = new DateTime($thirtyDaysAgo->format('Y-m-d'));
|
||||||
$date->modify('+' . $i . ' days');
|
$date->modify('+' . $i . ' days');
|
||||||
$dates[] = $date->format('Y-m-d');
|
$dates[] = $date->format('Y-m-d');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$data = [
|
$data = [
|
||||||
"xAxis" => $dates,
|
"xAxis" => $dates,
|
||||||
"series" => [
|
"series" => [
|
||||||
|
@ -56,6 +56,7 @@ class StoreCashFinanceFlowController extends BaseAdminController
|
|||||||
public function edit()
|
public function edit()
|
||||||
{
|
{
|
||||||
$params = (new StoreCashFinanceFlowValidate())->post()->goCheck('edit');
|
$params = (new StoreCashFinanceFlowValidate())->post()->goCheck('edit');
|
||||||
|
$params['admin_id']=$this->adminId;
|
||||||
$result = StoreCashFinanceFlowLogic::edit($params);
|
$result = StoreCashFinanceFlowLogic::edit($params);
|
||||||
if (true === $result) {
|
if (true === $result) {
|
||||||
return $this->success('编辑成功', [], 1, 1);
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
@ -54,7 +54,9 @@ class StoreCashFinanceFlowLogic extends BaseLogic
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
StoreCashFinanceFlow::where('id', $params['id'])->update([
|
StoreCashFinanceFlow::where('id', $params['id'])->update([
|
||||||
'file' => $params['file']
|
'file' => $params['file'],
|
||||||
|
'static'=>1,
|
||||||
|
'admin_id'=>$params['admin_id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user