kuaifan 5 years atrás
parent
commit
d239da5c83

+ 28 - 4
app/Http/Controllers/Api/ReportController.php

@@ -239,9 +239,33 @@ class ReportController extends Controller
             $user = $user['data'];
         }
         //
+        $whereArray = [];
+        $whereArray[] = ['username', '=', $user['username']];
+        if (trim(Request::input('username'))) {
+            $whereArray[] = ['username', '=', trim(Request::input('username'))];
+        }
+        if (in_array(trim(Request::input('type')), ['日报', '周报'])) {
+            $whereArray[] = ['type', '=', trim(Request::input('type'))];
+        }
+        $indate = Request::input('indate');
+        if (is_array($indate)) {
+            if ($indate[0] > 0) $whereArray[] = ['indate', '>=', Base::dayTimeF($indate[0])];
+            if ($indate[1] > 0) $whereArray[] = ['indate', '<=', Base::dayTimeE($indate[1])];
+        }
+        //
+        $orderBy = '`id` DESC';
+        $sorts = Base::json2array(Request::input('sorts'));
+        if (in_array($sorts['order'], ['asc', 'desc'])) {
+            switch ($sorts['key']) {
+                case 'indate':
+                    $orderBy = '`' . $sorts['key'] . '` ' . $sorts['order'] . ',`id` DESC';
+                    break;
+            }
+        }
+        //
         $lists = DB::table('report_lists')
-            ->where('username', $user['username'])
-            ->orderByDesc('id')
+            ->where($whereArray)
+            ->orderByRaw($orderBy)
             ->paginate(Min(Max(Base::nullShow(Request::input('pagesize'), 10), 1), 100));
         $lists = Base::getPageList($lists);
         if ($lists['total'] == 0) {
@@ -287,8 +311,8 @@ class ReportController extends Controller
         }
         $indate = Request::input('indate');
         if (is_array($indate)) {
-            if ($indate[0] > 0) $whereArr[] = ['report_lists.indate', '>=', Base::dayTimeF($indate[0])];
-            if ($indate[1] > 0) $whereArr[] = ['report_lists.indate', '<=', Base::dayTimeE($indate[1])];
+            if ($indate[0] > 0) $whereArray[] = ['report_lists.indate', '>=', Base::dayTimeF($indate[0])];
+            if ($indate[1] > 0) $whereArray[] = ['report_lists.indate', '<=', Base::dayTimeE($indate[1])];
         }
         //
         $orderBy = '`id` DESC';

+ 4 - 4
resources/assets/js/common.js

@@ -648,12 +648,12 @@
                 return "";
             }
             let str = "";
-            $A.each(obj, (key, val)=>{
+            $A.each(obj, (key, val) => {
                 if (val !== null) {
                     if (typeof val === "object" && this.count(val) > 0) {
-                        str+= this.objImplode(val);
-                    }else{
-                        str+= String(val);
+                        str += this.objImplode(val);
+                    } else {
+                        str += String(val);
                     }
                 }
             });

+ 45 - 5
resources/assets/js/main/components/report/my.vue

@@ -1,8 +1,31 @@
 <template>
     <drawer-tabs-container>
         <div class="report-my">
+            <!-- 搜索 -->
+            <Row class="sreachBox">
+                <div class="item">
+                    <div class="item-2">
+                        <sreachTitle :val="keys.type">类型</sreachTitle>
+                        <Select v-model="keys.type" placeholder="全部">
+                            <Option value="">全部</Option>
+                            <Option value="日报">日报</Option>
+                            <Option value="周报">周报</Option>
+                        </Select>
+                    </div>
+                    <div class="item-2">
+                        <sreachTitle :val="keys.indate">日期</sreachTitle>
+                        <Date-picker v-model="keys.indate" type="daterange" placement="bottom" placeholder="日期范围"></Date-picker>
+                    </div>
+                </div>
+                <div class="item item-button">
+                    <Button type="text" v-if="$A.objImplode(keys)!=''" @click="sreachTab(true)">取消筛选</Button>
+                    <Button type="primary" icon="md-search" :loading="loadIng > 0" @click="sreachTab">搜索</Button>
+                </div>
+            </Row>
             <!-- 按钮 -->
-            <Button :loading="loadIng > 0" type="primary" icon="md-add" @click="[addDrawerId=0,addDrawerShow=true]">新建汇报</Button>
+            <Row class="butBox" style="float:left;margin-top:-32px;">
+                <Button :loading="loadIng > 0" type="primary" icon="md-add" @click="[addDrawerId=0,addDrawerShow=true]">新建汇报</Button>
+            </Row>
             <!-- 列表 -->
             <Table class="tableFill" ref="tableRef" :columns="columns" :data="lists" :loading="loadIng > 0" :no-data-text="noDataText" stripe></Table>
             <!-- 分页 -->
@@ -49,6 +72,9 @@
         },
         data () {
             return {
+                keys: {},
+                sorts: {key:'', order:''},
+
                 loadYet: false,
 
                 loadIng: 0,
@@ -77,6 +103,7 @@
                 "title": "创建日期",
                 "width": 160,
                 "align": 'center',
+                "sortable": true,
                 render: (h, params) => {
                     return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
                 }
@@ -153,6 +180,18 @@
         },
 
         methods: {
+            sreachTab(clear) {
+                if (clear === true) {
+                    this.keys = {};
+                }
+                this.getLists(true);
+            },
+
+            sortChange(info) {
+                this.sorts = {key:info.key, order:info.order};
+                this.getLists(true);
+            },
+
             setPage(page) {
                 this.listPage = page;
                 this.getLists();
@@ -169,14 +208,15 @@
                 if (resetLoad === true) {
                     this.listPage = 1;
                 }
+                let whereData = $A.date2string($A.cloneData(this.keys));
+                whereData.page = Math.max(this.listPage, 1);
+                whereData.pagesize = Math.max($A.runNum(this.listPageSize), 10);
+                whereData.sorts = $A.cloneData(this.sorts);
                 this.loadIng++;
                 this.noDataText = "数据加载中.....";
                 $A.aAjax({
                     url: 'report/my',
-                    data: {
-                        page: Math.max(this.listPage, 1),
-                        pagesize: Math.max($A.runNum(this.listPageSize), 10),
-                    },
+                    data: whereData,
                     complete: () => {
                         this.loadIng--;
                     },

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

@@ -108,6 +108,7 @@
                 "title": "创建日期",
                 "width": 160,
                 "align": 'center',
+                "sortable": true,
                 render: (h, params) => {
                     return h('span', $A.formatDate("Y-m-d H:i:s", params.row.indate));
                 }
@@ -179,11 +180,11 @@
                 if (resetLoad === true) {
                     this.listPage = 1;
                 }
-                this.loadIng++;
-                let whereData = $A.cloneData(this.keys);
+                let whereData = $A.date2string($A.cloneData(this.keys));
                 whereData.page = Math.max(this.listPage, 1);
                 whereData.pagesize = Math.max($A.runNum(this.listPageSize), 10);
                 whereData.sorts = $A.cloneData(this.sorts);
+                this.loadIng++;
                 this.noDataText = "数据加载中.....";
                 $A.aAjax({
                     url: 'report/receive',