index.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. @extends('layouts.app')
  2. @section('title')计费模型-物流计费@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.priceModel.express.menu')@endcomponent
  7. </div>
  8. <div class="container-fluid mt-2" id="container">
  9. @include("maintenance.priceModel.express._detailModal")
  10. @if(Session::has('successTip'))
  11. <div class="alert alert-success h1">{{Session::get('successTip')}}</div>
  12. @endif
  13. <table class="table table-hover table-striped text-nowrap">
  14. <tr>
  15. <th>序号</th>
  16. <th>价格名称</th>
  17. <th>操作</th>
  18. <th>首重(KG)</th>
  19. <th>续重(KG)</th>
  20. <th>项目</th>
  21. <th>承运商</th>
  22. <th>录入时间</th>
  23. <th>操作</th>
  24. </tr>
  25. <tr v-for="(model,i) in models">
  26. <td>@{{ i+1 }}</td>
  27. <td>@{{ model.name }}</td>
  28. <td>
  29. <button type="button" class="btn btn-sm btn-primary" @click="showDetailModal(model)">维护详情</button>
  30. </td>
  31. <td>@{{ model.initialWeight }}</td>
  32. <td>@{{ model.additionalWeight }}</td>
  33. <td>
  34. <small v-for="owner in model.owners" class="font-weight-bold">@{{ owner.name }}<br></small>
  35. </td>
  36. <td>
  37. <small v-for="logistic in model.logistics" class="font-weight-bold">@{{ logistic.name }}<br></small>
  38. </td>
  39. <td>@{{ model.createdAt }}</td>
  40. <td>
  41. @can("计费模型-快递-编辑")<button type="button" class="btn btn-sm btn-outline-info" @click="edit(model.id)">编辑</button>@endcan
  42. @can("计费模型-快递-删除")<button type="button" class="btn btn-sm btn-outline-danger" @click="deleteModel(model,i)">删除</button>@endcan
  43. </td>
  44. </tr>
  45. </table>
  46. </div>
  47. @stop
  48. @section("lastScript")
  49. <script>
  50. new Vue({
  51. el:"#container",
  52. data:{
  53. models : [
  54. @foreach($models as $model)
  55. {
  56. id:"{{$model->id}}",
  57. name:"{{$model->name}}",
  58. initialWeight:"{{$model->initial_weight }}",
  59. additionalWeight:"{{$model->additional_weight }}",
  60. createdAt:"{{$model->created_at}}",
  61. owners:{!! $model->owners !!},
  62. logistics:{!! $model->logistics !!},
  63. },
  64. @endforeach
  65. ],
  66. id : "",
  67. name : "",
  68. details : [],
  69. errors : [],
  70. isShowError : false,
  71. provinces : null,
  72. },
  73. methods:{
  74. showDetailModal(model){
  75. this.id = model.id;
  76. this.name = model.name;
  77. if (this.details[model.id]){
  78. $("#detailModal").modal("show");
  79. return;
  80. }
  81. window.axios.post("{{url('maintenance/priceModel/express/getDetail')}}", {id:model.id})
  82. .then(res=>{
  83. if (res.data.success){
  84. if (res.data.data.length>0){
  85. this.details[model.id] = res.data.data;
  86. this.$forceUpdate();
  87. }else {
  88. this.details[model.id] = [];
  89. this.addDetail();
  90. }
  91. $("#detailModal").modal("show");
  92. return;
  93. }
  94. window.tempTip.setDuration(3000);
  95. window.tempTip.show(res.data.data);
  96. }).catch(err=>{
  97. console.log(err);
  98. window.tempTip.setDuration(3000);
  99. window.tempTip.show("网络错误:"+err);
  100. });
  101. },
  102. selectFile(){
  103. $("#file").click();
  104. },
  105. importDetail(e){
  106. let file=e.target.files[0];
  107. if (!file){
  108. tempTip.setDuration(3000);
  109. tempTip.setIndex(1099);
  110. tempTip.show("未选择文件");
  111. return;
  112. }
  113. let formData = new FormData();
  114. formData.append("file",file);
  115. formData.append("id",this.id);
  116. axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  117. 'Content-Type':'multipart/form-data'
  118. })
  119. .then(res=>{
  120. if (res.data.success) {
  121. this.details[this.id] = res.data.data;
  122. this.errors = res.data.errors;
  123. tempTip.setDuration(3000);
  124. tempTip.setIndex(1099);
  125. tempTip.showSuccess("导入成功!");
  126. return;
  127. }
  128. tempTip.setDuration(3000);
  129. tempTip.setIndex(1099);
  130. tempTip.show(res.data.data);
  131. }).catch(err=> {
  132. tempTip.setDuration(3000);
  133. tempTip.setIndex(1099);
  134. tempTip.show("网络错误:"+err);
  135. })
  136. },
  137. addDetail(){
  138. if (this.provinces === null){
  139. window.tempTip.postBasicRequest('{{url('maintenance/province/get')}}',{},data=>{
  140. this.provinces = data;
  141. });
  142. }
  143. this.details[this.id].unshift({
  144. "id" : "",
  145. "province_id" : "",
  146. "initial_weight_price" : "",
  147. "additional_weight_price" : "",
  148. "edit" : true,
  149. });
  150. this.$forceUpdate();
  151. },
  152. delDetail(detail,index){
  153. if (detail.id){
  154. detail.additional_weight_price = $("#additional-"+detail.id).attr('data');
  155. detail.initial_weight_price = $("#initial-"+detail.id).attr('data');
  156. detail.edit = false;
  157. }else{
  158. this.$delete(this.details[this.id],index);
  159. }
  160. this.$forceUpdate();
  161. },
  162. updateDetail(detail){
  163. detail["edit"] = true;
  164. this.$forceUpdate();
  165. },
  166. submitDetail(detail){
  167. tempTip.setIndex(1099);
  168. window.axios.post('{{url('maintenance/priceModel/express/updateDetail')}}',{id:this.id,detail:detail})
  169. .then(res=>{
  170. if (res.data.success) {
  171. tempTip.setDuration(2000);
  172. if (detail.id){
  173. tempTip.showSuccess("修改成功");
  174. }else{
  175. detail.id = res.data.data.id;
  176. detail.province = res.data.data.province;
  177. tempTip.showSuccess("新增成功");
  178. }
  179. detail.edit = false;
  180. this.$forceUpdate();
  181. return;
  182. }
  183. tempTip.setDuration(3000);
  184. tempTip.show(res.data.data);
  185. }).catch(err=> {
  186. tempTip.setDuration(3000);
  187. tempTip.setIndex(1099);
  188. tempTip.show("网络错误:"+err);
  189. })
  190. },
  191. deletePriceModel(id,index){
  192. window.tempTip.setIndex(1099);
  193. window.tempTip.confirm("确定要删除该省份计费模型吗?",()=>{
  194. window.axios.post('{{url('maintenance/priceModel/express/destroyDetail')}}',{id:id})
  195. .then(res=>{
  196. if (res.data.success){
  197. this.$delete(this.details[this.id],index);
  198. tempTip.setDuration(2000);
  199. tempTip.showSuccess("删除成功");
  200. this.$forceUpdate();
  201. return;
  202. }
  203. tempTip.setDuration(3000);
  204. tempTip.show(res.data.data);
  205. }).catch(err=> {
  206. tempTip.setDuration(3000);
  207. tempTip.setIndex(1099);
  208. tempTip.show("网络错误:"+err);
  209. })
  210. });
  211. },
  212. deleteModel(model,index){
  213. window.tempTip.confirm("确定要删除"+model.name+"吗?",()=>{
  214. window.axios.delete('{{url('maintenance/priceModel/express')}}/'+model.id)
  215. .then(res=>{
  216. if (res.data.success){
  217. this.$delete(this.models,index);
  218. tempTip.setDuration(2000);
  219. tempTip.showSuccess("删除成功");
  220. return;
  221. }
  222. tempTip.setDuration(3000);
  223. tempTip.show(res.data.data);
  224. }).catch(err=> {
  225. tempTip.setDuration(3000);
  226. tempTip.show("网络错误:"+err);
  227. })
  228. });
  229. },
  230. edit(id){
  231. window.location.href = "{{url('maintenance/priceModel/express')}}/"+id+"/edit";
  232. },
  233. exportDetail(){
  234. window.open("{{url('maintenance/priceModel/express/export')}}/"+this.id);
  235. }
  236. },
  237. });
  238. </script>
  239. @stop