index.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  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. selectTr:0
  73. },
  74. methods:{
  75. showDetailModal(model){
  76. this.id = model.id;
  77. this.name = model.name;
  78. if (this.details[model.id]){
  79. $("#detailModal").modal("show");
  80. return;
  81. }
  82. window.axios.post("{{url('maintenance/priceModel/express/getDetail')}}", {id:model.id})
  83. .then(res=>{
  84. if (res.data.success){
  85. if (res.data.data.length>0){
  86. this.details[model.id] = res.data.data;
  87. this.$forceUpdate();
  88. }else {
  89. this.details[model.id] = [];
  90. this.addDetail();
  91. }
  92. $("#detailModal").modal("show");
  93. return;
  94. }
  95. window.tempTip.setDuration(3000);
  96. window.tempTip.show(res.data.data);
  97. }).catch(err=>{
  98. console.log(err);
  99. window.tempTip.setDuration(3000);
  100. window.tempTip.show("网络错误:"+err);
  101. });
  102. },
  103. selectFile(){
  104. $("#file").click();
  105. },
  106. importDetail(e){
  107. let file=e.target.files[0];
  108. if (!file){
  109. tempTip.setDuration(3000);
  110. tempTip.setIndex(1099);
  111. tempTip.show("未选择文件");
  112. return;
  113. }
  114. let formData = new FormData();
  115. formData.append("file",file);
  116. formData.append("id",this.id);
  117. axios.post('{{url('maintenance/priceModel/express/import')}}',formData,{
  118. 'Content-Type':'multipart/form-data'
  119. })
  120. .then(res=>{
  121. if (res.data.success) {
  122. this.details[this.id] = res.data.data;
  123. this.errors = res.data.errors;
  124. tempTip.setDuration(3000);
  125. tempTip.setIndex(1099);
  126. tempTip.showSuccess("导入成功!");
  127. return;
  128. }
  129. tempTip.setDuration(3000);
  130. tempTip.setIndex(1099);
  131. tempTip.show(res.data.data);
  132. }).catch(err=> {
  133. tempTip.setDuration(3000);
  134. tempTip.setIndex(1099);
  135. tempTip.show("网络错误:"+err);
  136. })
  137. },
  138. addDetail(){
  139. if (this.provinces === null){
  140. window.tempTip.postBasicRequest('{{url('maintenance/province/get')}}',{},data=>{
  141. this.provinces = data;
  142. });
  143. }
  144. this.details[this.id].unshift({
  145. "id" : "",
  146. "province_id" : "",
  147. "initial_weight_price" : "",
  148. "additional_weight_price" : "",
  149. "edit" : true,
  150. });
  151. this.$forceUpdate();
  152. },
  153. delDetail(detail,index){
  154. if (detail.id){
  155. detail.additional_weight_price = $("#additional-"+detail.id).attr('data');
  156. detail.initial_weight_price = $("#initial-"+detail.id).attr('data');
  157. detail.edit = false;
  158. }else{
  159. this.$delete(this.details[this.id],index);
  160. }
  161. this.$forceUpdate();
  162. },
  163. updateDetail(detail){
  164. detail["edit"] = true;
  165. this.$forceUpdate();
  166. },
  167. submitDetail(detail){
  168. tempTip.setIndex(1099);
  169. window.axios.post('{{url('maintenance/priceModel/express/updateDetail')}}',{id:this.id,detail:detail})
  170. .then(res=>{
  171. if (res.data.success) {
  172. tempTip.setDuration(2000);
  173. if (detail.id){
  174. tempTip.showSuccess("修改成功");
  175. }else{
  176. detail.id = res.data.data.id;
  177. detail.province = res.data.data.province;
  178. tempTip.showSuccess("新增成功");
  179. }
  180. detail.edit = false;
  181. this.$forceUpdate();
  182. return;
  183. }
  184. tempTip.setDuration(3000);
  185. tempTip.show(res.data.data);
  186. }).catch(err=> {
  187. tempTip.setDuration(3000);
  188. tempTip.setIndex(1099);
  189. tempTip.show("网络错误:"+err);
  190. })
  191. },
  192. deletePriceModel(id,index){
  193. window.tempTip.setIndex(1099);
  194. window.tempTip.confirm("确定要删除该省份计费模型吗?",()=>{
  195. window.axios.post('{{url('maintenance/priceModel/express/destroyDetail')}}',{id:id})
  196. .then(res=>{
  197. if (res.data.success){
  198. this.$delete(this.details[this.id],index);
  199. tempTip.setDuration(2000);
  200. tempTip.showSuccess("删除成功");
  201. this.$forceUpdate();
  202. return;
  203. }
  204. tempTip.setDuration(3000);
  205. tempTip.show(res.data.data);
  206. }).catch(err=> {
  207. tempTip.setDuration(3000);
  208. tempTip.setIndex(1099);
  209. tempTip.show("网络错误:"+err);
  210. })
  211. });
  212. },
  213. deleteModel(model,index){
  214. window.tempTip.confirm("确定要删除"+model.name+"吗?",()=>{
  215. window.axios.delete('{{url('maintenance/priceModel/express')}}/'+model.id)
  216. .then(res=>{
  217. if (res.data.success){
  218. this.$delete(this.models,index);
  219. tempTip.setDuration(2000);
  220. tempTip.showSuccess("删除成功");
  221. return;
  222. }
  223. tempTip.setDuration(3000);
  224. tempTip.show(res.data.data);
  225. }).catch(err=> {
  226. tempTip.setDuration(3000);
  227. tempTip.show("网络错误:"+err);
  228. })
  229. });
  230. },
  231. edit(id){
  232. window.location.href = "{{url('maintenance/priceModel/express')}}/"+id+"/edit";
  233. },
  234. exportDetail(){
  235. window.open("{{url('maintenance/priceModel/express/export')}}/"+this.id);
  236. }
  237. },
  238. });
  239. </script>
  240. @stop