create.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. @extends('layouts.app')
  2. @section('title')采购管理-采购-新建@endsection
  3. @section('content')
  4. @component('procurement.procurement.menu')@endcomponent
  5. <div class="container-fluid" id="list">
  6. <div class="card col-md-8 offset-md-2">
  7. <div class="card-body">
  8. @if(Session::has('successTip'))
  9. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  10. @endif
  11. <form method="POST" action="{{ url('procurement/procurement/store') }}">
  12. @csrf
  13. <div class="form-group row">
  14. <label for="owner_id" class="col-2 col-form-label text-right text-primary">项目名称{{old('owner_id')}} *</label>
  15. <div class="col-8 form-inline">
  16. <select id="owner_id" name="owner_id" class="form-control @error('owner_id') is-invalid @enderror col-4" v-model="owner_id" @change="selectOwner" required>
  17. <option v-for="owner in owners" :value="owner.id">@{{owner.name}}</option>
  18. </select>
  19. <input type="text" class="form-control-sm ml-2" placeholder="输入关键字定位项目" @input="owner_seek">
  20. </div>
  21. <div class="col-sm-5">
  22. <p class="form-control-static text-danger small font-weight-bold" >{{ $errors->first('owner_id') }}</p>
  23. </div>
  24. </div>
  25. <div class="form-group row">
  26. <label for="owner_material_id" class="col-2 col-form-label text-right text-primary">项目耗材编号{{old('owner_material_id')}} *</label>
  27. <div class="col-8">
  28. <select id="owner_material_id" name="owner_material_id" class="form-control @error('owner_material_id') is-invalid @enderror col-4" v-model="owner_material_id" @change="ownerMaterial" required>
  29. <option v-for="ownerMaterial in ownerMaterials" :value="ownerMaterial.id">@{{ownerMaterial.material_code}}</option>
  30. </select>
  31. @error('owner_material_id')
  32. <span class="invalid-feedback" role="alert">
  33. <strong>{{ $message }}</strong>
  34. </span>
  35. @enderror
  36. </div>
  37. </div>
  38. <div class="form-group row">
  39. <label for="name" class="col-2 col-form-label text-right">耗材名称</label>
  40. <div class="col-8">
  41. <input type="text" class="form-control " name="material_name" autocomplete="off" value="{{ old('material_name') }}" v-model="material_name" readonly>
  42. </div>
  43. </div>
  44. <div class="form-group row">
  45. <label for="name" class="col-2 col-form-label text-right">尺寸大小</label>
  46. <div class="col-8">
  47. <input type="text" class="form-control " name="size" autocomplete="off" value="{{ old('size') }}" v-model="size" readonly>
  48. </div>
  49. </div>
  50. <div class="form-group row">
  51. <label for="name" class="col-2 col-form-label text-right">特殊要求</label>
  52. <div class="col-8">
  53. <input type="text" class="form-control " name="special" autocomplete="off" value="{{ old('special') }}" v-model="special" readonly>
  54. </div>
  55. </div>
  56. <div class="form-group row">
  57. <label for="name" class="col-2 col-form-label text-right">材质规格</label>
  58. <div class="col-8">
  59. <textarea type="text" class="form-control" name="specification" autocomplete="off" value="{{ old('specification') }}" readonly>@{{ specification }}</textarea>
  60. </div>
  61. </div>
  62. <div class="form-group row">
  63. <label for="quantity" class="col-2 col-form-label text-right">采购数量</label>
  64. <div class="col-8">
  65. <input type="text" class="form-control @error('quantity') is-invalid @enderror"
  66. name="quantity" autocomplete="off" value="{{ old('quantity') }}" v-model="quantity" required>
  67. @error('quantity')
  68. <span class="invalid-feedback" role="alert">
  69. <strong>{{ $message }}</strong>
  70. </span>
  71. @enderror
  72. </div>
  73. </div>
  74. <div class="form-group row">
  75. <label for="amount" class="col-2 col-form-label text-right">销售数量</label>
  76. <div class="col-8">
  77. <input type="text" class="form-control @error('amount') is-invalid @enderror"
  78. name="amount" autocomplete="off" value="{{ old('amount') }}" @input="countTotalPrice" v-model="amount" required>
  79. @error('amount')
  80. <span class="invalid-feedback" role="alert">
  81. <strong>{{ $message }}</strong>
  82. </span>
  83. @enderror
  84. </div>
  85. </div>
  86. <div class="form-group row">
  87. <label for="unit_price" class="col-2 col-form-label text-right">销售单价</label>
  88. <div class="col-8">
  89. <input type="text" class="form-control @error('unit_price') is-invalid @enderror"
  90. name="unit_price" autocomplete="off" value="{{ old('unit_price') }}" @input="countTotalPrice" v-model="unit_price" required>
  91. @error('unit_price')
  92. <span class="invalid-feedback" role="alert">
  93. <strong>{{ $message }}</strong>
  94. </span>
  95. @enderror
  96. </div>
  97. </div>
  98. <div class="form-group row">
  99. <label for="total_price" class="col-2 col-form-label text-right">销售总价</label>
  100. <div class="col-8">
  101. <input type="text" class="form-control" name="total_price" autocomplete="off" value="{{ old('total_price') }}" v-model="total_price" readonly>
  102. </div>
  103. </div>
  104. <div class="form-group row">
  105. <div class="col-8 offset-2">
  106. <input type="submit" class="btn btn-success form-control">
  107. </div>
  108. </div>
  109. </form>
  110. </div>
  111. </div>
  112. </div>
  113. @endsection
  114. @section('lastScript')
  115. <script>
  116. let vueList=new Vue({
  117. el:'#list',
  118. data:{
  119. owners:[
  120. @foreach($owners as $owner)
  121. {
  122. id:'{{$owner->id}}',name:'{{$owner->name}}',
  123. ownerMaterials:[
  124. @foreach($owner->ownerMaterials ? $owner->ownerMaterials :[] as $ownerMaterial)
  125. {
  126. id:'{{$ownerMaterial->id}}',material_code:'{{$ownerMaterial->material_code}}',material_name:'{{$ownerMaterial->material->name}}',
  127. size:'{{$ownerMaterial->size}}',special:'{{$ownerMaterial->special}}',specification:'{{$ownerMaterial->specification}}',
  128. },
  129. @endforeach
  130. ],
  131. },
  132. @endforeach
  133. ],
  134. owner_id:'{{old('owner_id')}}',
  135. owner_material_id:'{{old('owner_material_id')}}',
  136. material_name:'{{old('material_name')}}',
  137. size:'{{old('size')}}',
  138. special:'{{old('special')}}',
  139. specification:'{{old('specification')}}',
  140. quantity:'{{old('quantity')}}',
  141. amount:'{{old('amount')}}',
  142. unit_price:'{{old('unit_price')}}',
  143. total_price:'{{old('total_price')}}',
  144. ownerMaterials:[],
  145. },
  146. methods:{
  147. owner_seek:function (e) {
  148. let _this=this;
  149. let $val=e.target.value;
  150. if($val===''){
  151. _this.owner_id='';
  152. }else{
  153. _this.owners.forEach(function (owner) {
  154. if (owner.name.includes($val)){
  155. _this.owner_id=owner.id;
  156. _this.ownerMaterials=owner.ownerMaterials;
  157. }
  158. });
  159. }
  160. },
  161. ownerMaterial:function () {
  162. let _this=this;
  163. _this.ownerMaterials.forEach(function (ownerMaterial) {
  164. if (_this.owner_material_id===ownerMaterial.id){
  165. _this.material_name=ownerMaterial.material_name;
  166. _this.size=ownerMaterial.size;
  167. _this.special=ownerMaterial.special;
  168. _this.specification=ownerMaterial.specification;
  169. }
  170. })
  171. },
  172. selectOwner:function () {
  173. let _this=this;
  174. _this.owners.forEach(function (owner) {
  175. if (_this.owner_id===owner.id){
  176. _this.ownerMaterials=owner.ownerMaterials;
  177. }
  178. })
  179. },
  180. countTotalPrice:function () {
  181. let _this=this;
  182. if (_this.unit_price===''|| _this.amount==='')_this.total_price=null;
  183. _this.total_price=_this.unit_price*_this.amount;
  184. }
  185. },
  186. });
  187. </script>
  188. @endsection