瀏覽代碼

添加Material.index删除

ajun 5 年之前
父節點
當前提交
7c5c64fd4c

+ 1 - 1
resources/views/maintenance/material/_table.blade.php

@@ -11,7 +11,7 @@
         <td>@{{ material.name }}</td>
         <td>
             <button class="btn btn-sm btn-outline-primary">编辑</button>
-            <button class="btn btn-sm btn-outline-danger">删除</button>
+            <button class="btn btn-sm btn-outline-danger" @click="destroy(material.id)">删除</button>
         </td>
     </tr>
 </table>

+ 14 - 1
resources/views/maintenance/material/index.blade.php

@@ -25,7 +25,20 @@
             materials:{!! $materials->toJson() !!}['data']
         },
         methods:{
-
+            destroy($id){
+                axios.delete('api/material/destroy',{'id':$id}).then(res=>{
+                    if(res.data.success){
+                        tempTip.setDuration(3000);
+                        tempTip.showSuccess('删除成功');
+                        return;
+                    }
+                    tempTip.setDuration(3000);
+                    tempTip.show(res.data.message);
+                }).error(err=>{
+                    tempTip.setDuration(3000);
+                    tempTip.show(err);
+                })
+            }
         }
     });
 </script>