create.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. <label for="remark" class="col-2 col-form-label text-right">备注</label>
  96. <div class="col-8">
  97. <textarea id="remark" type="text" class="form-control" name="remark" autocomplete="off" value="{{ old('remark') }}" v-model="remark"></textarea>
  98. </div>
  99. </div>
  100. <div class="form-group row">
  101. <div class="col-8 offset-2">
  102. <input type="submit" class="btn btn-success form-control">
  103. </div>
  104. </div>
  105. </form>
  106. </div>
  107. </div>
  108. </div>
  109. @endsection
  110. @section('lastScript')
  111. <script>
  112. let vueList=new Vue({
  113. el:'#list',
  114. data:{
  115. owners:[
  116. @foreach($owners as $owner)
  117. {
  118. id:'{{$owner->id}}',name:'{{$owner->name}}',
  119. ownerMaterials:[
  120. @foreach($owner->ownerMaterials ? $owner->ownerMaterials :[] as $ownerMaterial)
  121. {
  122. id:'{{$ownerMaterial->id}}',material_code:'{{$ownerMaterial->material_code}}',material_name:'{{$ownerMaterial->material->name}}',
  123. size:'{{$ownerMaterial->size}}',special:'{{$ownerMaterial->special}}',specification:'{{$ownerMaterial->specification}}',
  124. },
  125. @endforeach
  126. ],
  127. @if($owner->customer)customer_name:'{{$owner->customer->name}}',@endif
  128. },
  129. @endforeach
  130. ],
  131. owner_id:'{{old('owner_id')}}',
  132. owner_material_id:'{{old('owner_material_id')}}',
  133. material_name:'{{old('material_name')}}',
  134. customer_name:'{{old('customer_name')}}',
  135. size:'{{old('size')}}',
  136. special:'{{old('special')}}',
  137. specification:'{{old('specification')}}',
  138. quantity:'{{old('quantity')}}',
  139. amount:'{{old('amount')}}',
  140. unit_price:'{{old('unit_price')}}',
  141. total_price:'{{old('total_price')}}',
  142. ownerMaterials:[],
  143. errors:{},
  144. },
  145. methods:{
  146. owner_seek:function (e) {
  147. let _this=this;
  148. let $val=e.target.value;
  149. if($val===''){
  150. _this.owner_id='';
  151. }else{
  152. _this.owners.forEach(function (owner) {
  153. if (owner.name.includes($val)){
  154. _this.owner_id=owner.id;
  155. _this.ownerMaterials=owner.ownerMaterials;
  156. _this.customer_name=owner.customer_name;
  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. _this.customer_name=owner.customer_name;
  178. }
  179. })
  180. },
  181. countTotalPrice:function () {
  182. let _this=this;
  183. if (_this.unit_price===''|| _this.amount==='')_this.total_price=null;
  184. _this.total_price=_this.unit_price*_this.amount;
  185. }
  186. },
  187. });
  188. </script>
  189. @endsection