LD 6 лет назад
Родитель
Сommit
dac425b39f
1 измененных файлов с 22 добавлено и 10 удалено
  1. 22 10
      resources/views/weight/package/statistics.blade.php

+ 22 - 10
resources/views/weight/package/statistics.blade.php

@@ -128,7 +128,7 @@
                             </th>
                             <th>货主</th>
                             <th>总计</th>
-                            <th v-for="logistic in logisticsAll">@{{ logistic.name }}</th>
+                            <th v-for="logistic in logisticsAll" v-if="logistics[logistic.id]">@{{ logistic.name }}</th>
                         </tr>
                         <tr v-for="ownerModel in ownersModel">
                             <td>
@@ -136,7 +136,7 @@
                             </td>
                             <th class="text-muted">@{{ ownerModel.name }}</th>
                             <td><p v-if="ownerModel.sum">@{{ ownerModel.sum }}</p><p v-else>0</p></td>
-                            <td class="text-muted" v-for="logistic in logisticsAll"><p v-if="ownerModel.logistics[logistic.id]">@{{ ownerModel.logistics[logistic.id] }}</p>
+                            <td class="text-muted" v-for="logistic in logisticsAll" v-if="logistics[logistic.id]"><p v-if="ownerModel.logistics[logistic.id]">@{{ ownerModel.logistics[logistic.id] }}</p>
                                 <p v-else>0</p></td>
                         </tr>
                     </table>
@@ -165,11 +165,6 @@
                     '{{$owner->id}}' : "{{$owner->name}}",
                     @endforeach
                 },
-                logistics:{
-                    @foreach($logistics as $logistic)
-                    '{{$logistic->id}}' : "{{$logistic->name}}",
-                    @endforeach
-                },
                 logisticsAll:[
                     @foreach($logistics as $logistic)
                     {id:'{{$logistic->id}}', name: '{{$logistic->name}}',style:false},
@@ -180,7 +175,7 @@
                     {id:'{{$owner->id}}',name:"{{$owner->name}}",style:false},
                     @endforeach
                 ],
-                logisticsCopy:[],
+                logistics:[],
                 ownersModel:[],
                 filterData:
                     {date_start:'',date_end:''},
@@ -270,7 +265,7 @@
                             let str=unescape(val);
                             let strs=new Array();
                             strs=str.split(",");
-                            if (key=='owner_id'){
+                            if (key=='owner_id' && val){
                                 for (let i=0;i<strs.length;i++){
                                     data.selectedOwners.push(strs[i]);
                                     data.ownersCopy.every(function (ownerCopy) {
@@ -282,7 +277,7 @@
                                     });
                                 }
                             }
-                            if (key=='logistic_id'){
+                            if (key=='logistic_id' && val){
                                 for (let i=0;i<strs.length;i++){
                                     data.selectedLogistics.push(strs[i]);
                                     data.logisticsAll.every(function (logistic) {
@@ -308,6 +303,23 @@
                             }
                             return true;
                         });
+                    };
+                    let logistics=data.selectedLogistics;
+                    if (logistics.length>0){
+                        for (let i=0;i<logistics.length;i++){
+                            data.logisticsAll.every(function (logistic) {
+                                if (logistic.id==logistics[i]){
+                                    data.logistics[logistic.id]=logistic.name;
+                                    return false;
+                                }
+                                return  true;
+                            });
+                        }
+                    }else{
+                        data.logisticsAll.every(function (logistic) {
+                            data.logistics[logistic.id]=logistic.name;
+                            return true;
+                        });
                     }
                 },
                 owner_seek:function (e) {