소스 검색

客戶列表添加日志跳转链接

ANG YU 5 년 전
부모
커밋
b85ff04c02
3개의 변경된 파일17개의 추가작업 그리고 18개의 파일을 삭제
  1. 6 0
      app/Customer.php
  2. 2 3
      app/Http/Controllers/CustomerLogsController.php
  3. 9 15
      resources/views/customer/customer/index.blade.php

+ 6 - 0
app/Customer.php

@@ -3,6 +3,7 @@
 namespace App;
 
 use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasMany;
 
 class Customer extends Model
 {
@@ -15,4 +16,9 @@ class Customer extends Model
         "phone",  //公司名称
         "comment",  //公司名称
     ];
+
+    public function customerLogs(): HasMany
+    {
+        return $this->hasMany(CustomerLog::class,'customer_id','id');
+    }
 }

+ 2 - 3
app/Http/Controllers/CustomerLogsController.php

@@ -7,7 +7,6 @@ use App\CustomerLog;
 use App\CustomerLogStatus;
 use Illuminate\Http\RedirectResponse;
 use Illuminate\Http\Request;
-use App\Http\Controllers\Controller;
 
 class CustomerLogsController extends Controller
 {
@@ -16,9 +15,9 @@ class CustomerLogsController extends Controller
         $this->middleware('auth');
     }
 
-    public function index()
+    public function index(Request $request)
     {
-        $customer_logs = CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->orderByDesc('updated_at')->paginate();
+        $customer_logs = CustomerLog::query()->with(['customerLogStatus', 'user', 'customer'])->where('id',$request->id) ->orderByDesc('updated_at')->paginate();
         return view('customer.customer_logs.index', compact('customer_logs'));
     }
 

+ 9 - 15
resources/views/customer/customer/index.blade.php

@@ -21,6 +21,8 @@
                     <th>联系人</th>
                     <th>联系电话</th>
                     <th>公司备注</th>
+                    <th>日志</th>
+                    <th>合同</th>
                     <th>创建时间</th>
                     <th>操作</th>
                 </tr>
@@ -33,6 +35,8 @@
                     <td>@{{ customer.contact_man }}</td>
                     <td>@{{ customer.phone }}</td>
                     <td>@{{ customer.comment }}</td>
+                    <td><a href="#" @click="gotoLogs(customer.id)">链接</a></td>
+                    <td>#</td>
                     <td>@{{ customer.created_at }}</td>
                     <td>
                         @can("客户-编辑")<a :href="'{{url('customer/customer')}}/'+customer.id+'/edit'"><button class="btn btn-sm btn-outline-info">改</button></a>@endcan
@@ -49,21 +53,7 @@
         new Vue({
             el:"#container",
             data:{
-                customers : [
-                    @foreach($customers as $customer)
-                    {
-                        id:"{{$customer->id}}",
-                        code:"{{$customer->code}}",
-                        name:"{{$customer->name}}",
-                        company_name:"{{$customer->company_name}}",
-                        invoice_address:"{{$customer->invoice_address}}",
-                        contact_man:"{{$customer->contact_man}}",
-                        phone:"{{$customer->phone}}",
-                        comment:"{{$customer->comment}}",
-                        created_at:"{{$customer->created_at}}",
-                    },
-                    @endforeach
-                ],
+                customers :  {!!  $customers->toJson() !!}['data']
             },
             methods:{
                 destroy(id,index,name){
@@ -83,6 +73,10 @@
                             window.tempTip.show("网络错误:"+err);
                         })
                     })
+                },
+                gotoLogs(id){
+                    let url = '{{ url("customer/customer/customer_logs") }}'+'?id='+id;
+                    window.open(url);
                 }
             },
         });