Przeglądaj źródła

优化领料单功能

huangsanjia 3 lat temu
rodzic
commit
9d73f64753

+ 18 - 3
application/admin/controller/Task.php

@@ -77,23 +77,38 @@ class Task extends Backend
                 if (!empty($value[$i]['percentage'])) {//判断有没有材料和百分比
                     $list[$key][$i]['percentage'] = decode($value[$i]['percentage']);
                     //计算应加入的重量
-                    $list[$key][$i]['num'] = number_format($list[$key][$i]['percentage'] / $num * $task[$key]['number'],3);
+                    $number = ceil($list[$key][$i]['percentage'] / $num * $task[$key]['number'] * 1000);
+                    $list[$key][$i]['num'] = number_format($number/1000,3);
+                    $list[$key][$i]['machine'] = $task[$key]['machine'];
+                    $list[$key][$i]['str'] = '';//为汇总数组中机台做准备字段
                     array_push($res,$list[$key][$i]);//将数组push到新的需要整合的数组中
                 }else{
                     unset($list[$key][$i]);
                 }
             }
-
             $list[$key] = array_values($list[$key]);
         }
         $result = $this->sumWeight($res,'material','num');
+        foreach ($list as $k=>$v){
+            $sum_list = $this->sumWeight($v,'material','num');
+            for ($i=0;$i<count($result);$i++){//循环汇总表
+                for ($j=0;$j<count($sum_list);$j++){
+                    if ($result[$i]['material'] == $sum_list[$j]['material']){
+                        if ( $result[$i]['str'] != $sum_list[$j]['machine']){
+                            $result[$i]['str'] .= "<div>".$sum_list[$j]['machine'].":".$sum_list[$j]['num']."</div>";
+                        }
+                    }
+                }
+            }
+
+        }
 
 //        echo "<pre>";
 //        print_r($task);//一维
 //        echo "</pre>";
 //
 //        echo "<pre>";
-//        print_r($list);//原材料信息
+//        print_r($sum_list);//原材料信息
 //        echo "</pre>";
 
 //        echo "<pre>";

+ 3 - 4
application/admin/view/task/taskadd.html

@@ -66,9 +66,8 @@
         <tr>
             <th style="width: 150px;">{$vo.bach}</th>
             <th style="width: 350px;">{$vo.name}</th>
-            <th style="width: 150px;">生产量{$vo.number}</th>
-            <th style="width: 200px;">{$vo.machine}</th>
-            <th style="display: none"></th>
+            <th style="width: 150px;">生产量:{$vo.number}kg</th>
+            <th style="width: 200px;">机台号:{$vo.machine}</th>
         </tr>
         </thead>
             <tbody>
@@ -102,7 +101,7 @@
                 <td style="width: 150px;">{$v.material}</td>
                 <td style="width: 350px;">{$v.percentage}</td>
                 <td style="width: 150px;">{$v.num}</td>
-                <td style="width: 200px;"></td>
+                <td style="width: 200px;">{$v.str}</td>
             </tr>
             {/foreach}
             </tbody>