|
|
@@ -6,16 +6,18 @@
|
|
|
@component('maintenance.menu')@endcomponent
|
|
|
</span>
|
|
|
<div class="container-fluid" id="material_div">
|
|
|
+ @include('maintenance.material._edit')
|
|
|
+ @include('maintenance.material._create')
|
|
|
<div class="card">
|
|
|
- <div class="card_header">
|
|
|
- </div>
|
|
|
<div class="card_body">
|
|
|
- @component('maintenance.material._table')@endcomponent
|
|
|
+ <div class="row pull-left m-1">
|
|
|
+ <button class="btn btn-outline-info mb-1 mr-3" @click="store"><span class="fa fa-plus"></span> 新 增</button>
|
|
|
+ </div>
|
|
|
+ @include('maintenance.material._table')
|
|
|
</div>
|
|
|
</div>
|
|
|
- @component('maintenance.material._edit')@endcomponent
|
|
|
- </div>
|
|
|
|
|
|
+ </div>
|
|
|
@endsection
|
|
|
@section('lastScript')
|
|
|
<script>
|
|
|
@@ -23,8 +25,9 @@
|
|
|
el:'#material_div',
|
|
|
data:{
|
|
|
materials:{!! $materials->toJson() !!}['data'],
|
|
|
- material:{},
|
|
|
+ editMaterial:{},
|
|
|
index:'',
|
|
|
+ addMaterial:{},
|
|
|
},
|
|
|
methods:{
|
|
|
destroy(id,index){
|
|
|
@@ -43,10 +46,14 @@
|
|
|
});
|
|
|
},
|
|
|
edit(material,i){
|
|
|
- this.material = material;
|
|
|
+ this.editMaterial = material;
|
|
|
this.index = i;
|
|
|
$('#editModal').modal('show');
|
|
|
},
|
|
|
+ store(){
|
|
|
+ this.addMaterial = {};
|
|
|
+ $('#addModal').modal('show');
|
|
|
+ },
|
|
|
update(index){
|
|
|
axios.post('{{url('apiLocal/material/update')}}',this.material)
|
|
|
.then(res=>{
|
|
|
@@ -64,6 +71,24 @@
|
|
|
tempTip.setDuration(3000);
|
|
|
tempTip.show(err);
|
|
|
});
|
|
|
+ },
|
|
|
+ create(){
|
|
|
+ axios.post('{{url('apiLocal/material/store')}}',this.addMaterial)
|
|
|
+ .then(res=>{
|
|
|
+ if(res.data.success){
|
|
|
+ $('#addModal').modal('hide');
|
|
|
+ this.addMaterial={};
|
|
|
+ tempTip.setDuration(3000);
|
|
|
+ tempTip.showSuccess('添加成功');
|
|
|
+ this.$set(this.materials,this.materials.length,res.data.data);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ tempTip.setDuration(3000);
|
|
|
+ tempTip.show(res.data.message);
|
|
|
+ }).catch(err=>{
|
|
|
+ tempTip.setDuration(3000);
|
|
|
+ tempTip.show(err);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
});
|