Jelajahi Sumber

扫描计件excel导出

yuang 4 tahun lalu
induk
melakukan
d1deb2e7b6
2 mengubah file dengan 65 tambahan dan 13 penghapusan
  1. 63 12
      resources/views/order/scanInfo/index.blade.php
  2. 2 1
      routes/web.php

+ 63 - 12
resources/views/order/scanInfo/index.blade.php

@@ -20,11 +20,11 @@
             </div>
 
             <div class="form-group m-2" data-toggle="tooltip" data-placement="top" title="起始日期">
-                <input v-model="search.startTime" class="form-control" type="date">
+                <input v-model="search.startTime" class="form-control" type="datetime-local" step="01">
             </div>
 
             <div class="form-group m-2" data-toggle="tooltip" data-placement="top" title="截止日期">
-                <input v-model="search.endTime" class="form-control" type="date">
+                <input v-model="search.endTime" class="form-control" type="datetime-local" step="01">
             </div>
 
             <div class="form-group m-2" data-toggle="tooltip" data-placement="top" title="单号">
@@ -42,6 +42,10 @@
             <div class="form-group m-2">
                 <button class="form-control btn btn-sm btn-success" @click="resetSearch()">重置</button>
             </div>
+
+            <div class="form-group m-2">
+                <button class="form-control btn btn-sm btn-success" @click="downExcel()">导出EXCEL</button>
+            </div>
         </div>
 
         <!--            导出-->
@@ -59,6 +63,7 @@
                 <td class="td-warm text-muted"><span>@{{ item.waveDesc }}</span></td>
                 <td class="td-warm text-muted"><span>@{{ item.createTime }}</span></td>
                 <td class="td-warm text-muted"><span>@{{ item.recheckTime }}</span></td>
+                <td class="td-warm text-muted"><span>@{{ item.recheckUsername }}</span></td>
             </tr>
         </table>
         <nav aria-label="...">
@@ -100,6 +105,27 @@
                 }
             },
             created() {
+                Date.prototype.format = function (fmt) {
+                    var o = {
+                        "M+": this.getMonth() + 1, //月份
+                        "d+": this.getDate(), //日
+                        "h+": this.getHours(), //小时
+                        "m+": this.getMinutes(), //分
+                        "s+": this.getSeconds(), //秒
+                        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
+                        "S": this.getMilliseconds() //毫秒
+                    };
+                    if (/(y+)/.test(fmt)) {
+                        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
+                    }
+                    for (var k in o) {
+                        if (new RegExp("(" + k + ")").test(fmt)) {
+                            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+                        }
+                    }
+                    return fmt;
+                }
+
                 let url = this.getBaseUrl();
                 url += `/api/report/scanInfo/listPage?size=${this.size}&current=${this.current}`;
                 axios.post(url, this.search).then(res => {
@@ -121,6 +147,7 @@
                     {name: 'content', value: '波次类型'},
                     {name: 'createTime', value: '打包时间'},
                     {name: 'recheckTime', value: '复核时间'},
+                    {name: 'recheckUsername', value: '复核人'},
                 ];
                 new Header({
                     el: "table",
@@ -156,24 +183,25 @@
                     }
                     return url;
                 },
+                getSearch: function () {
+                    let search = Object.assign({}, this.search)
+                    if (search.startTime != null && search.startTime !== '') {
+                        search.startTime = new Date(Date.parse(search.startTime)).format("yyyy-MM-dd hh:mm:ss");
+                    }
+                    if (search.endTime != null && search.endTime !== '') {
+                        search.endTime = new Date(Date.parse(search.endTime)).format("yyyy-MM-dd hh:mm:ss");
+                    }
+                    return search;
+                },
                 pagination(flag) {
                     if (flag === 'pre' && this.current > 1) {
                         this.current--;
                     } else if (flag === 'next' && this.current < this.details.pages) {
                         this.current++;
                     }
-                    let env = "{{ config('env') }}";
-                    console.log(env);
                     let url = this.getBaseUrl();
-
                     url += `/api/report/scanInfo/listPage?size=${this.size}&current=${this.current}`;
-                    let search = Object.assign({}, this.search)
-                    if (search.startTime != null && search.startTime !== '') {
-                        search.startTime += " 00:00:00";
-                    }
-                    if (search.endTime != null && search.endTime !== '') {
-                        search.endTime += " 23:59:59";
-                    }
+                    let search = this.getSearch();
                     axios.post(url, search).then(res => {
                         if (res.data.data === undefined) {
                             this.details.data = [];
@@ -190,7 +218,30 @@
                         }
                     });
                 },
+                downExcel() {
+                    let url = this.getBaseUrl();
+                    url += '/api/report/scanInfo/export';
+                    let search = this.getSearch();
+                    axios.post(url, search).then(res => {
+                        if (res.data.code === 200) {
+                            let filename = res.data.data;
+                            let downUrl = this.getBaseUrl() + '/api/report/scanInfo/export/' + filename;
+                            let link = document.createElement('a');
+                            link.style.display = 'none';
+                            link.href = downUrl;
+                            link.download = `${filename}.xlsx`;
+                            document.body.appendChild(link);
+                            link.click();
+                            document.body.removeChild(link);
+                            tempTip.showSuccess('导出成功!');
+                        } else {
+                            tempTip.setDuration(3000);
+                            tempTip.show(res.data.data);
+                        }
+                    })
+                }
             },
+
         });
     </script>
 @endsection

+ 2 - 1
routes/web.php

@@ -62,7 +62,8 @@ Route::post("record", "ReceiveRecordController@receive");
 //人事管理
 Route::group(['prefix' => 'personnel', 'middleware' => 'auth'], function () {
     //扫描计件
-    Route::resource('scanInfo', 'ScanInfoDetailController')->only(['index']);
+    Route::get('scanInfo', 'ScanInfoDetailController@index');
+//    Route::get('scanInfo/dayHour', 'ScanInfoDetailController@dayHour');
     //临时开放录入
     Route::put('laborApply/temporaryOpen', 'LaborApplyController@temporaryOpen')->name('laborApply.temporaryOpen');
     Route::get('laborApply/createDispatch', 'LaborApplyController@createDispatch')->name('laborApply.createDispatch');