likang 2 år sedan
förälder
incheckning
434a95f99c

+ 11 - 2
catch/fan/controller/Fan.php

@@ -63,8 +63,17 @@ class Fan extends CatchController
      * @param $id
      */
     public function update(Request $request, $id) : \think\Response
-    {
-        return CatchResponse::success($this->fanModel->updateBy($id, $request->post()));
+    {   $data = $request->post();
+        if($data['production_date']){
+            $date = date('Y-m-d',$data['production_date']);
+            $data['production_date'] = $date?$date:$data['production_date'];
+        }
+        if($data['install_date']){
+            $date = date('Y-m-d',$data['install_date']);
+            $data['install_date'] = $date?$date:$data['install_date'];
+           
+        }
+        return CatchResponse::success($this->fanModel->updateBy($id, $data));
     }
     
     /**

+ 6 - 1
catch/hydraulic/controller/Hydraulic.php

@@ -34,9 +34,12 @@ class Hydraulic extends CatchController
     public function save(Request $request) : \think\Response
     {
         $data = $request->post();
+       
         if($data['out_date']){
+        
             $data['out_date'] = date('Y-m-d',$data['out_date']);
         }
+
         return CatchResponse::success($this->hydraulicModel->storeBy($data));
     }
     
@@ -59,7 +62,9 @@ class Hydraulic extends CatchController
     public function update(Request $request, $id) : \think\Response
     {
         $data = $request->post();
-        $data['out_date'] = date('Y-m-d H:i:s',$data['out_date']);
+        var_dump($data);
+        $date = date('Y-m-d H:i:s',$data['out_date']);
+        $data['out_date'] = $date?$date:$data['out_date'];
         return CatchResponse::success($this->hydraulicModel->updateBy($id, $data));
     }
     

+ 49 - 0
catch/hydraulic/database/migrations/20220505112140_hydraulic_add_fields.php

@@ -0,0 +1,49 @@
+<?php
+// +----------------------------------------------------------------------
+// | CatchAdmin [Just Like ~ ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
+// +----------------------------------------------------------------------
+// | Author: JaguarJack [ njphper@gmail.com ]
+// +----------------------------------------------------------------------
+
+use think\migration\Migrator;
+use think\migration\db\Column;
+
+class HydraulicAddFields extends Migrator
+{
+    /**
+     * Change Method.
+     *
+     * Write your reversible migrations using this method.
+     *
+     * More information on writing migrations is available here:
+     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
+     *
+     * The following commands can be used in this method and Phinx will
+     * automatically reverse them when rolling back:
+     *
+     *    createTable
+     *    renameTable
+     *    addColumn
+     *    renameColumn
+     *    addIndex
+     *    addForeignKey
+     *
+     * Remember to call "create()" or "update()" and NOT "save()" when working
+     * with the Table class.
+     */
+    public function change()
+    {
+        if ($this->hasTable('hydraulic')) {
+            $table = $this->table('hydraulic');
+
+            $table  ->addColumn('torque', 'string', ['limit' => 10,'null' => true,'signed' => true,'comment' => '扭矩',])
+                    ->addColumn('stress', 'string', ['limit' => 10,'null' => true,'signed' => true,'comment' => '压力',])
+                    ->update();
+        }
+      
+    }
+}

+ 8 - 0
catch/hydraulic/model/Hydraulic.php

@@ -35,6 +35,14 @@ class Hydraulic extends Model
         'net_state',
         // 在线时间
         'online_time',
+        //扭矩
+        'torque',
+        //压力
+        'stress',
+        //螺栓尺寸
+        'bolts_size',
+        //螺栓数量
+        'bolts_num',
         //备注
         'remark',
         // 创建人ID