ANG YU 5 gadi atpakaļ
vecāks
revīzija
97f17d2bba

+ 1 - 4
app/Policies/CustomerLogPolice.php

@@ -14,10 +14,7 @@ class CustomerLogPolice
 
     public function update(User $user, CustomerLog $customerLog): bool
     {
-        $lastOne = cache()->remember($this->cache_key . $user->id, 1, function () use ($user) {
-            return CustomerLog::query()->where('user_id', $user->id)->orderByDesc('updated_at')->first();
-        });
-        return (int)$user->id === (int)$customerLog->user_id && $customerLog->id == $lastOne->id;
+        return (int)$user->id === (int)$customerLog->user_id;
     }
 
     public function destroy(User $user, CustomerLog $customerLog)

+ 13 - 6
resources/views/customer/customer/index.blade.php

@@ -8,9 +8,9 @@
     </div>
     <div class="container-fluid" id="container">
         <div class="card-body">
-{{--            @if(Session::has('successTip'))--}}
-{{--                <div class="alert alert-success h1">{{Session::get('successTip')}}</div>--}}
-{{--            @endif--}}
+            @if(Session::has('successTip'))
+                <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
+            @endif
             <table class="table table-striped table-hover text-nowrap">
                 <tr>
                     <th>序号</th>
@@ -43,7 +43,7 @@
                                     <span v-if="!log.editing" @click="editLogDescription(log,customer.customer_logs,i)">@{{ log.description }}</span>
                                     <span v-if="log.editing">
                                         <input type="text" v-model="log.description">
-                                        <button class="btn btn-sm btn-info">ok</button>
+                                        <button class="btn btn-sm btn-info" @click = "updateLog(log)">更新</button>
                                     </span>
                                 </td>
                                 <td>@{{ log.user.name }}</td>
@@ -61,7 +61,7 @@
                     <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
+                        @can("客户-编辑")<a :href="'{{url('customer')}}/'+customer.id+'/edit'"><button class="btn btn-sm btn-outline-info">改</button></a>@endcan
                         @can("客户-删除")<button class="btn btn-sm btn-outline-danger" @click="destroy(customer.id,i,customer.name)">删</button>@endcan
                     </td>
                 </tr>
@@ -86,7 +86,7 @@
             methods:{
                 destroy(id,index,name){
                     window.tempTip.confirm("确定要删除"+name+"吗?",()=>{
-                        window.axios.delete("{{url('customer/customer')}}/"+id)
+                        window.axios.delete("{{url('customer')}}/"+id)
                             .then(res=>{
                                 if (res.data.success){
                                     this.$delete(this.customers,index);
@@ -121,6 +121,13 @@
                 toggleButton(customer) {
                     customer.collapsed = !customer.collapsed;
                     this.$forceUpdate();
+                },
+                updateLog(log) {
+                    axios.patch('customer/customer_logs/'+log.id, log).then(function(res){
+                        if (res.status === 200) {
+                            this.$forceUpdate();
+                        }
+                    });
                 }
             },
         });