index.blade.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. @extends('layouts.app')
  2. @section('title')查询-快递-计费模型@endsection
  3. @section('content')
  4. <div id="nav2">
  5. @component('maintenance.menu')@endcomponent
  6. @component('maintenance.priceModel.logistic.menu')@endcomponent
  7. </div>
  8. <div class="container-fluid mt-2" id="container">
  9. @include("maintenance.priceModel.logistic._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>项目</th>
  19. <th>承运商</th>
  20. <th>单位一</th>
  21. <th>单位一区间</th>
  22. <th>单位二</th>
  23. <th>单位二区间</th>
  24. <th>提货费</th>
  25. <th>燃油附加费</th>
  26. <th>信息服务费</th>
  27. <th>录入时间</th>
  28. <th>操作</th>
  29. </tr>
  30. <tr v-for="(model,i) in models" @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
  31. <td>@{{ i+1 }}</td>
  32. <td>
  33. <button class="btn btn-sm btn-info" @click="showDetailModal(model,i)">维护详情</button>
  34. </td>
  35. <td>@{{ model.name }}</td>
  36. <td>
  37. <small v-for="owner in model.owners" class="m-0 font-weight-bold">@{{ owner.name }}<br></small>
  38. </td>
  39. <td>
  40. <small v-for="logistic in model.logistics" class="font-weight-bold">@{{ logistic.name }}<br></small>
  41. </td>
  42. <td>@{{ model.unitName }}</td>
  43. <td>
  44. <small v-for="range in model.unitRange">@{{ range }}<br></small>
  45. </td>
  46. <td>@{{ model.otherUnitName }}</td>
  47. <td>
  48. <small v-for="range in model.otherUnitRange">@{{ range }}<br></small>
  49. </td>
  50. <td>@{{ model.pickUpPrice }}</td>
  51. <td>@{{ model.fuelPrice }}</td>
  52. <td>@{{ model.servicePrice }}</td>
  53. <td>@{{ model.createdAt }}</td>
  54. <td>
  55. @can("计费模型-物流-编辑")<button type="button" class="btn btn-sm btn-outline-info" @click="edit(model.id)">编辑</button>@endcan
  56. @can("计费模型-物流-删除")<button type="button" class="btn btn-sm btn-outline-danger" @click="deleteModel(model,i)">删除</button>@endcan
  57. </td>
  58. </tr>
  59. </table>
  60. </div>
  61. @stop
  62. @section("lastScript")
  63. <script>
  64. new Vue({
  65. el:"#container",
  66. data:{
  67. models : [
  68. @foreach($models as $model)
  69. { id:"{{$model->id}}",
  70. name:"{{$model->name}}",
  71. unitId:"{{$model->unit_id}}",
  72. otherUnitId:"{{$model->other_unit_id}}",
  73. unitRange:{!! $model->unit_range_json !!},
  74. unitName:"{{$model->unit ? $model->unit->name : ''}}",
  75. otherUnitRange:{!! $model->other_unit_range_json !!},
  76. otherUnitName:"{{$model->otherUnit ? $model->otherUnit->name : ''}}",
  77. pickUpPrice:"{{$model->pick_up_price}}",
  78. fuelPrice:"{{$model->fuel_price}}",
  79. servicePrice:"{{$model->service_price}}",
  80. createdAt:"{{$model->created_at}}",
  81. owners:{!! $model->owners !!},
  82. logistics:{!! $model->logistics !!}
  83. },
  84. @endforeach
  85. ],
  86. index:"",
  87. details : [],
  88. units : null,
  89. provinces : null,
  90. cities : null,
  91. errors:{!! $errors !!},
  92. isShowError : false,
  93. selectTr:0
  94. },
  95. methods:{
  96. _dataReady(){
  97. if (this.units === null){
  98. this.units = [];
  99. window.axios.post("{{url('maintenance/unit/getUnits')}}")
  100. .then(res=>{
  101. if (res.data.success){
  102. this.units = res.data.data;
  103. return;
  104. }
  105. window.tempTip.setDuration(3000);
  106. window.tempTip.show(res.data.data);
  107. }).catch(err=>{
  108. window.tempTip.setDuration(3000);
  109. window.tempTip.show("网络错误:"+err);
  110. });
  111. }
  112. if (this.provinces === null){
  113. this.provinces = [];
  114. window.axios.post('{{url('maintenance/province/get')}}')
  115. .then(res=>{
  116. this.provinces = res.data.data;
  117. });
  118. }
  119. if (this.cities === null){
  120. this.cities = [];
  121. window.axios.post('{{url('maintenance/city/get')}}')
  122. .then(res=>{
  123. let cities = [];
  124. res.data.data.forEach(function (city) {
  125. if (city.province_id){
  126. if (cities[city.province_id]){
  127. cities[city.province_id].push(city)
  128. }else{
  129. cities[city.province_id] = [city];
  130. }
  131. }
  132. });
  133. this.cities = cities;
  134. });
  135. }
  136. },
  137. showDetailModal(model,index){
  138. this._dataReady();
  139. this.index = index;
  140. if (this.details[model.id]){
  141. $("#detailModal").modal("show");
  142. return;
  143. }
  144. window.axios.post("{{url('maintenance/priceModel/logistic/getDetail')}}", {id:model.id})
  145. .then(res=>{
  146. if (res.data.success){
  147. this.details[model.id] = res.data.data;
  148. this.$forceUpdate();
  149. $("#detailModal").modal("show");
  150. return;
  151. }
  152. window.tempTip.setDuration(3000);
  153. window.tempTip.show(res.data.data);
  154. }).catch(err=>{
  155. window.tempTip.setDuration(3000);
  156. window.tempTip.show("网络错误:"+err);
  157. });
  158. },
  159. deleteModel(model,index){
  160. window.tempTip.confirm("确定要删除“"+model.name+"”吗?",()=>{
  161. window.axios.delete('{{url('maintenance/priceModel/logistic')}}/'+model.id)
  162. .then(res=>{
  163. if (res.data.success){
  164. this.$delete(this.models,index);
  165. tempTip.setDuration(2000);
  166. tempTip.showSuccess("删除"+model.name+"成功");
  167. return;
  168. }
  169. tempTip.setDuration(3000);
  170. tempTip.show(res.data.data);
  171. }).catch(err=> {
  172. tempTip.setDuration(3000);
  173. tempTip.show("网络错误:"+err);
  174. })
  175. });
  176. },
  177. edit(id){
  178. window.location.href = "{{url('maintenance/priceModel/logistic')}}/"+id+"/edit";
  179. },
  180. selectFile(){
  181. $("#file").click();
  182. },
  183. importDetail(e){
  184. let file=e.target.files[0];
  185. if (!file){
  186. tempTip.setDuration(3000);
  187. tempTip.setIndex(1099);
  188. tempTip.show("未选择文件");
  189. return;
  190. }
  191. let formData = new FormData();
  192. formData.append("file",file);
  193. formData.append("id",this.models[this.index]["id"]);
  194. window.tempTip.setIndex(1099);
  195. window.tempTip.setDuration(9999);
  196. window.tempTip.waitingTip("执行中,请耐心等候......");
  197. axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
  198. 'Content-Type':'multipart/form-data'
  199. })
  200. .then(res=>{
  201. if (res.data.success) {
  202. this.details[this.models[this.index]["id"]] = res.data.data;
  203. this.errors = res.data.errors;
  204. tempTip.cancelWaitingTip();
  205. tempTip.setDuration(2000);
  206. tempTip.showSuccess("导入成功!");
  207. return;
  208. }
  209. tempTip.cancelWaitingTip();
  210. tempTip.setDuration(3000);
  211. tempTip.show(res.data.data);
  212. }).catch(err=> {
  213. tempTip.cancelWaitingTip();
  214. tempTip.setDuration(3000);
  215. tempTip.show("网络错误:"+err);
  216. })
  217. },
  218. addDetail(){
  219. this._dataReady();
  220. this.details[this.models[this.index].id].unshift({
  221. "id" : "",
  222. "unit_id" : "",
  223. "range" : "",
  224. "province_id" : "",
  225. "city_id" : "",
  226. "unit_price" : "",
  227. "delivery_fee" : "",
  228. "initial_fee" : "",
  229. "initial_amount" : "",
  230. "rate" : "",
  231. "edit" : true,
  232. });
  233. this.$forceUpdate();
  234. },
  235. delDetail(detail,index){
  236. if (detail.id){
  237. detail.unit_price = $("#unit_price-"+detail.id).attr('data');
  238. detail.delivery_fee = $("#delivery_fee-"+detail.id).attr('data');
  239. detail.initial_fee = $("#initial_fee-"+detail.id).attr('data');
  240. detail.initial_amount = $("#initial_amount-"+detail.id).attr('data');
  241. detail.rate = $("#rate-"+detail.id).attr('data');
  242. detail.edit = false;
  243. }else{
  244. this.$delete(this.details[this.models[this.index]["id"]],index);
  245. }
  246. this.$forceUpdate();
  247. },
  248. updateDetail(detail){
  249. detail["edit"] = true;
  250. this.$forceUpdate();
  251. },
  252. submitDetail(detail){
  253. tempTip.setIndex(1099);
  254. window.axios.post('{{url('maintenance/priceModel/logistic/updateDetail')}}',{id:this.models[this.index].id,detail:detail})
  255. .then(res=>{
  256. if (res.data.success) {
  257. tempTip.setDuration(2000);
  258. if (detail.id){
  259. tempTip.showSuccess("修改成功");
  260. }else{
  261. detail.id = res.data.data.id;
  262. detail.province = res.data.data.province;
  263. detail.city = res.data.data.city;
  264. detail.unit = res.data.data.unit;
  265. tempTip.showSuccess("新增成功");
  266. }
  267. detail.edit = false;
  268. this.$forceUpdate();
  269. return;
  270. }
  271. tempTip.setDuration(3000);
  272. tempTip.show(res.data.data);
  273. }).catch(err=> {
  274. tempTip.setDuration(3000);
  275. tempTip.setIndex(1099);
  276. tempTip.show("网络错误:"+err);
  277. })
  278. },
  279. deletePriceModel(id,index){
  280. window.tempTip.setIndex(1099);
  281. window.tempTip.confirm("确定要删除该省份计费模型吗?",()=>{
  282. window.axios.post('{{url('maintenance/priceModel/logistic/destroyDetail')}}',{id:id})
  283. .then(res=>{
  284. if (res.data.success){
  285. this.$delete(this.details[this.models[this.index].id],index);
  286. tempTip.setDuration(2000);
  287. tempTip.showSuccess("删除成功");
  288. this.$forceUpdate();
  289. return;
  290. }
  291. tempTip.setDuration(3000);
  292. tempTip.show(res.data.data);
  293. }).catch(err=> {
  294. tempTip.setDuration(3000);
  295. tempTip.setIndex(1099);
  296. tempTip.show("网络错误:"+err);
  297. })
  298. });
  299. },
  300. exportDetail(){
  301. window.open("{{url('maintenance/priceModel/logistic/export')}}/"+this.models[this.index].id);
  302. }
  303. },
  304. });
  305. </script>
  306. @stop