create.blade.php 10 KB

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