create.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. @extends('layouts.app')
  2. @section('title')客户管理-项目录入@endsection
  3. @section('content')
  4. @component('customer.project.menu')
  5. @if($owner)
  6. <li class="nav-item">
  7. <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">编辑</a>
  8. </li>
  9. @endif
  10. @endcomponent
  11. <div class="container-fluid card" id="container">
  12. <div class="card-body offset-3">
  13. <form method="POST" action="{{url('customer/project/store')}}" class="mt-3">
  14. @csrf
  15. <label><input hidden name="id" :value="owner.id"></label>
  16. <div class="row">
  17. <label for="code" class="col-2 text-info">项目代码</label>
  18. <input :readonly="display" type="text" id="code" class="form-control form-control-sm col-7 mb-0" :class="errors.code ? 'is-invalid' : ''" v-model="owner.code" name="code" @change="codeSeekOwner()">
  19. <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors.code">
  20. <strong>@{{ errors.code[0] }}</strong>
  21. </span>
  22. </div>
  23. <div class="row mt-3">
  24. <label for="name" class="col-2 text-info">项目名称</label>
  25. <input :readonly="display" type="text" id="name" class="form-control form-control-sm col-7 mb-0" :class="errors.name ? 'is-invalid' : style" v-model="owner.name" name="name" @change="nameSeekOwner()">
  26. <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors.name">
  27. <strong>@{{ errors.name[0] }}</strong>
  28. </span>
  29. </div>
  30. <div class="row mt-3">
  31. <label for="customer_id" class="col-2 text-info">客户</label>
  32. <select id="customer_id" v-model="owner.customer_id" class="form-control form-control-sm col-4 mb-0" :class="errors.customer_id ? 'is-invalid' : ''" name="customer_id" >
  33. <option v-for="customer in customers" :value="customer.id">@{{ customer.name }}</option>
  34. </select>
  35. <span class="invalid-feedback mt-0 offset-2" role="alert" v-if="errors.customer_id">
  36. <strong>@{{ errors.customer_id[0] }}</strong>
  37. </span>
  38. </div>
  39. <div class="row mt-3">
  40. <label for="owner_group_id" class="col-2 text-info">项目小组</label>
  41. <select id="owner_group_id" v-model="owner.owner_group_id" class="form-control form-control-sm col-4 mb-0" :class="errors.owner_group_id ? 'is-invalid' : ''" name="owner_group_id" >
  42. <option v-for="ownerGroup in ownerGroups" :value="ownerGroup.id">@{{ ownerGroup.name }}</option>
  43. </select>
  44. <span class="invalid-feedback offset-2 mt-0" role="alert" v-if="errors.owner_group_id">
  45. <strong>@{{ errors.owner_group_id[0] }}</strong>
  46. </span>
  47. </div>
  48. <div class="row mt-3">
  49. <label class="col-2" for="owner_storage_price_model_id">仓储计费类型</label>
  50. <select id="owner_storage_price_model_id" v-model="owner.owner_storage_price_model_id" class="selectpicker" multiple data-live-search="true" title="仓储计费类型(多选)">
  51. <option v-for="t in storagePriceModels" :value="t.id" :data-subtext="'起:'+t.minimum_area+' '+t.unit_name+' 单:'+t.price+'/'+t.unit_name">
  52. @{{ t.counting_type }} - @{{ t.using_type }}
  53. </option>
  54. </select>
  55. <label hidden><input :value="owner.owner_storage_price_model_id" name="owner_storage_price_model_id"></label>
  56. </div>
  57. <div class="row mt-3">
  58. <label for="tax_rate" class="col-2">税率<span class="badge badge-secondary">%</span></label>
  59. <input type="number" v-model="owner.tax_rate" id="tax_rate" class="form-control form-control-sm col-3 mb-0" :class="errors.tax_rate ? 'is-invalid' : ''" name="tax_rate">
  60. <span class="invalid-feedback offset-2 mt-0" role="alert" v-if="errors.tax_rate">
  61. <strong>@{{ errors.tax_rate[0] }}</strong>
  62. </span>
  63. </div>
  64. <div class="row mt-3">
  65. <label for="waring_line_on" class="col-2">月单量预警</label>
  66. <input type="number" v-model="owner.waring_line_on" id="waring_line_on" class="form-control form-control-sm col-3 mb-0" :class="errors.waring_line_on ? 'is-invalid' : ''" name="waring_line_on">
  67. <span class="invalid-feedback offset-2 mt-0" role="alert" v-if="errors.waring_line_on">
  68. <strong>@{{ errors.waring_line_on[0] }}</strong>
  69. </span>
  70. </div>
  71. <div class="row mt-3">
  72. <label for="contract_number" class="col-2">合同号</label>
  73. <input type="text" v-model="owner.contract_number" id="contract_number" class="form-control form-control-sm col-7" name="contract_number">
  74. </div>
  75. <div class="row mt-3">
  76. <label for="salesman" class="col-2">销售名称</label>
  77. <input type="text" v-model="owner.salesman" id="salesman" class="form-control form-control-sm col-7" name="salesman">
  78. </div>
  79. <div class="row mt-3">
  80. <label for="linkman" class="col-2">联系人</label>
  81. <input type="text" v-model="owner.linkman" id="linkman" class="form-control form-control-sm col-7" name="linkman">
  82. </div>
  83. <div class="row mt-3">
  84. <label for="phone_number" class="col-2">联系电话</label>
  85. <input type="text" v-model="owner.phone_number" id="phone_number" class="form-control form-control-sm col-7" name="phone_number">
  86. </div>
  87. <div class="row mt-3">
  88. <label for="description" class="col-2">项目描述</label>
  89. <textarea id="description" v-model="owner.description" class="form-control form-control-sm col-7" name="description"></textarea>
  90. </div>
  91. <button type="submit" class="btn btn-success mt-3 col-8 offset-1">提交</button>
  92. </form>
  93. </div>
  94. </div>
  95. @stop
  96. @section('lastScript')
  97. <script>
  98. new Vue({
  99. el:"#container",
  100. data:{
  101. owner : {
  102. id:"{{old('id') ?? ($owner->id ?? '') }}",
  103. name : "{{old('name') ?? ($owner->name ?? '')}}",
  104. code : "{{old('code') ?? ($owner->code ?? '')}}",
  105. customer_id : "{{old('customer_id') ?? ($owner->customer_id ?? '')}}",
  106. owner_group_id : "{{old('owner_group_id') ?? ($owner->user_owner_group_id ?? '')}}",
  107. owner_storage_price_model_id : "{{old('owner_storage_price_model_id') ?? ($owner->owner_storage_price_model_id ?? '')}}".split(','),
  108. tax_rate : "{{old('tax_rate') ?? ($owner->tax_rate ?? '')}}",
  109. contract_number : "{{old('contract_number') ?? ($owner->contract_number ?? '')}}",
  110. salesman : "{{old('salesman') ?? ($owner->salesman ?? '')}}",
  111. linkman : "{{old('linkman') ?? ($owner->linkman ?? '')}}",
  112. phone_number : "{{old('phone_number') ?? ($owner->phone_number ?? '')}}",
  113. description : "{{old('description') ?? ($owner->description ?? '')}}",
  114. waring_line_on : "{{old('waring_line_on') ?? ($owner->waring_line_on ?? '')}}",
  115. },
  116. storagePriceModels : [
  117. @foreach($storagePriceModels as $storagePriceModel)
  118. { id:"{{$storagePriceModel->id}}",
  119. counting_type : "{{$storagePriceModel->counting_type}}",
  120. using_type : "{{$storagePriceModel->using_type}}",
  121. minimum_area : "{{$storagePriceModel->minimum_area}}",
  122. price : "{{$storagePriceModel->price}}",
  123. unit_name : "{{$storagePriceModel->unit ? $storagePriceModel->unit->name : ''}}",
  124. },
  125. @endforeach
  126. ],
  127. customers : [
  128. @foreach($customers as $customer)
  129. {id:"{{$customer->id}}",name:"{{$customer->name}}"},
  130. @endforeach
  131. ],
  132. ownerGroups : [
  133. @foreach($ownerGroups as $ownerGroup)
  134. {id:"{{$ownerGroup->id}}",name:"{{$ownerGroup->name}}"},
  135. @endforeach
  136. ],
  137. style : '',
  138. errors : {!! $errors !!},
  139. display:false,
  140. },
  141. mounted(){
  142. if (this.errors.length===0 && this.owner.id){
  143. this.display = true;
  144. }
  145. },
  146. methods:{
  147. nameSeekOwner(){
  148. this.style = "";
  149. window.axios.post('{{url('customer/project/seekOwner')}}',{name:this.owner.name})
  150. .then(res=>{
  151. if (res.data.success){
  152. if (!this.owner.code){
  153. this.owner.code = res.data.data.code;
  154. this.owner.id = res.data.data.id;
  155. return;
  156. }
  157. if (this.owner.code === res.data.data.code)this.owner.id = res.data.data.id;
  158. }else this.owner.id = "";
  159. })
  160. },
  161. codeSeekOwner(){
  162. this.style = "";
  163. window.axios.post('{{url('customer/project/seekOwner')}}',{code:this.owner.code})
  164. .then(res=>{
  165. if (res.data.success){
  166. if (!this.owner.name){
  167. this.owner.name = res.data.data.name;
  168. this.owner.id = res.data.data.id;
  169. return;
  170. }
  171. if (this.owner.name === res.data.data.name){
  172. this.owner.id = res.data.data.id;
  173. return;
  174. }
  175. this.owner.name = res.data.data.name;
  176. this.owner.id = res.data.data.id;
  177. this.style = "border-success";
  178. }else this.owner.id = "";
  179. })
  180. },
  181. },
  182. });
  183. </script>
  184. @stop