Bladeren bron

工作报告新增发送日期

kuaifan 4 jaren geleden
bovenliggende
commit
e9c10bced2

+ 29 - 11
app/Http/Controllers/Api/ReportController.php

@@ -107,7 +107,13 @@ class ReportController extends Controller
                     unset($ccuser[$ck]);
                     continue;
                 }
-                DB::table('report_ccuser')->updateOrInsert(['rid' => $reportDetail['id'], 'username' => $cuser], ['cc' => 1]);
+                DB::table('report_ccuser')->updateOrInsert([
+                    'rid' => $reportDetail['id'],
+                    'username' => $cuser,
+                    'indate' => Base::time()
+                ], [
+                    'cc' => 1
+                ]);
             }
             DB::table('report_lists')->where('id', $reportDetail['id'])->update([
                 'status' => '已发送',
@@ -158,7 +164,13 @@ class ReportController extends Controller
                         unset($ccuserArr[$ck]);
                         continue;
                     }
-                    DB::table('report_ccuser')->updateOrInsert(['rid' => $reportDetail['id'], 'username' => $cuser], ['cc' => 1]);
+                    DB::table('report_ccuser')->updateOrInsert([
+                        'rid' => $reportDetail['id'],
+                        'username' => $cuser,
+                        'indate' => Base::time()
+                    ], [
+                        'cc' => 1
+                    ]);
                 }
                 $reportDetail['status'] = '已发送';
             }
@@ -261,10 +273,11 @@ class ReportController extends Controller
             if ($indate[1] > 0) $whereArray[] = ['indate', '<=', Base::dayTimeE($indate[1])];
         }
         //
-        $orderBy = '`id` DESC';
+        $orderBy = '`indate` DESC,`id` DESC';
         $sorts = Base::json2array(Request::input('sorts'));
         if (in_array($sorts['order'], ['asc', 'desc'])) {
             switch ($sorts['key']) {
+                case 'date':
                 case 'indate':
                     $orderBy = '`' . $sorts['key'] . '` ' . $sorts['order'] . ',`id` DESC';
                     break;
@@ -323,24 +336,28 @@ class ReportController extends Controller
             if ($indate[1] > 0) $whereArray[] = ['report_lists.indate', '<=', Base::dayTimeE($indate[1])];
         }
         //
-        $orderBy = '`id` DESC';
+        $builder = DB::table('report_lists')
+            ->join('report_ccuser', 'report_lists.id', '=', 'report_ccuser.rid')
+            ->select(['report_lists.*', 'report_ccuser.indate as senddate'])
+            ->where($whereArray);
         $sorts = Base::json2array(Request::input('sorts'));
         if (in_array($sorts['order'], ['asc', 'desc'])) {
             switch ($sorts['key']) {
                 case 'title':
                 case 'username':
+                    $builder->orderBy($sorts['key'], $sorts['order']);
+                    break;
                 case 'indate':
-                    $orderBy = '`' . $sorts['key'] . '` ' . $sorts['order'] . ',`id` DESC';
+                    $builder->orderBy('report_ccuser.indate', $sorts['order']);
                     break;
             }
+        } else {
+            $builder->orderByDesc('report_ccuser.indate');
+            $builder->orderByDesc('report_ccuser.id');
         }
         //
-        $lists = DB::table('report_lists')
-            ->join('report_ccuser', 'report_lists.id', '=', 'report_ccuser.rid')
-            ->select(['report_lists.*'])
-            ->where($whereArray)
-            ->orderByRaw($orderBy)
-            ->paginate(Base::getPaginate(100, 20));
+        $builder->orderByDesc('date');
+        $lists = $builder->paginate(Base::getPaginate(100, 20));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
             return Base::retError('未找到任何相关的汇报', $lists);
@@ -367,6 +384,7 @@ class ReportController extends Controller
         $rid = DB::table('report_ccuser')
             ->join('report_lists', 'report_lists.id', '=', 'report_ccuser.rid')
             ->where('report_lists.username', $user['username'])
+            ->orderByDesc('report_ccuser.id')
             ->value('rid');
         if (empty($rid)) {
             return Base::retError('没有相关数据!');

+ 32 - 0
database/migrations/2021_02_19_000412_alter_pre_report_ccuser.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AlterPreReportCcuser extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('report_ccuser', function (Blueprint $table) {
+            $table->bigInteger('indate')->after('cc')->nullable()->default(0)->comment('发送时间');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('report_ccuser', function (Blueprint $table) {
+            $table->dropColumn('indate');
+        });
+    }
+}

+ 2 - 2
resources/assets/js/main/components/report/receive.vue

@@ -125,13 +125,13 @@
                     "maxWidth": 120,
                     "align": 'center',
                 }, {
-                    "title": this.$L("创建日期"),
+                    "title": this.$L("发送日期"),
                     "minWidth": 160,
                     "maxWidth": 200,
                     "align": 'center',
                     "sortable": true,
                     render: (h, params) => {
-                        return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
+                        return h('span', params.row.senddate ? $A.formatDate("Y-m-d H:i:s", params.row.senddate) : '-');
                     }
                 }, {
                     "title": " ",

+ 1 - 0
resources/lang/en/general.js

@@ -639,4 +639,5 @@ export default {
     "项目总任务数": "The total number of project tasks",
     "项目已完成数": "Number of projects have been completed",
     "项目未完成数": "The number of unfinished projects",
+    "发送日期": "Send date",
 }