index.blade.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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">
  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. },
  94. methods:{
  95. _dataReady(){
  96. if (this.units === null){
  97. this.units = [];
  98. window.axios.post("{{url('maintenance/unit/getUnits')}}")
  99. .then(res=>{
  100. if (res.data.success){
  101. this.units = res.data.data;
  102. return;
  103. }
  104. window.tempTip.setDuration(3000);
  105. window.tempTip.show(res.data.data);
  106. }).catch(err=>{
  107. window.tempTip.setDuration(3000);
  108. window.tempTip.show("网络错误:"+err);
  109. });
  110. }
  111. if (this.provinces === null){
  112. this.provinces = [];
  113. window.axios.post('{{url('maintenance/province/get')}}')
  114. .then(res=>{
  115. this.provinces = res.data;
  116. });
  117. }
  118. if (this.cities === null){
  119. this.cities = [];
  120. window.axios.post('{{url('maintenance/city/get')}}')
  121. .then(res=>{
  122. let cities = [];
  123. res.data.forEach(function (city) {
  124. if (city.province_id){
  125. if (cities[city.province_id]){
  126. cities[city.province_id].push(city)
  127. }else{
  128. cities[city.province_id] = [city];
  129. }
  130. }
  131. });
  132. this.cities = cities;
  133. });
  134. }
  135. },
  136. showDetailModal(model,index){
  137. this._dataReady();
  138. this.index = index;
  139. if (this.details[model.id]){
  140. $("#detailModal").modal("show");
  141. return;
  142. }
  143. window.axios.post("{{url('maintenance/priceModel/logistic/getDetail')}}", {id:model.id})
  144. .then(res=>{
  145. if (res.data.success){
  146. this.details[model.id] = res.data.data;
  147. this.$forceUpdate();
  148. $("#detailModal").modal("show");
  149. return;
  150. }
  151. window.tempTip.setDuration(3000);
  152. window.tempTip.show(res.data.data);
  153. }).catch(err=>{
  154. window.tempTip.setDuration(3000);
  155. window.tempTip.show("网络错误:"+err);
  156. });
  157. },
  158. deleteModel(model,index){
  159. window.tempTip.confirm("确定要删除“"+model.name+"”吗?",()=>{
  160. window.axios.delete('{{url('maintenance/priceModel/logistic')}}/'+model.id)
  161. .then(res=>{
  162. if (res.data.success){
  163. this.$delete(this.models,index);
  164. tempTip.setDuration(2000);
  165. tempTip.showSuccess("删除"+model.name+"成功");
  166. return;
  167. }
  168. tempTip.setDuration(3000);
  169. tempTip.show(res.data.data);
  170. }).catch(err=> {
  171. tempTip.setDuration(3000);
  172. tempTip.show("网络错误:"+err);
  173. })
  174. });
  175. },
  176. edit(id){
  177. window.location.href = "{{url('maintenance/priceModel/logistic')}}/"+id+"/edit";
  178. },
  179. selectFile(){
  180. $("#file").click();
  181. },
  182. importDetail(e){
  183. let file=e.target.files[0];
  184. if (!file){
  185. tempTip.setDuration(3000);
  186. tempTip.setIndex(1099);
  187. tempTip.show("未选择文件");
  188. return;
  189. }
  190. let formData = new FormData();
  191. formData.append("file",file);
  192. formData.append("id",this.models[this.index]["id"]);
  193. window.tempTip.setIndex(1099);
  194. window.tempTip.setDuration(9999);
  195. window.tempTip.waitingTip("执行中,请耐心等候......");
  196. axios.post('{{url('maintenance/priceModel/logistic/import')}}',formData,{
  197. 'Content-Type':'multipart/form-data'
  198. })
  199. .then(res=>{
  200. if (res.data.success) {
  201. this.details[this.models[this.index]["id"]] = res.data.data;
  202. this.errors = res.data.errors;
  203. tempTip.cancelWaitingTip();
  204. tempTip.setDuration(2000);
  205. tempTip.showSuccess("导入成功!");
  206. return;
  207. }
  208. tempTip.cancelWaitingTip();
  209. tempTip.setDuration(3000);
  210. tempTip.show(res.data.data);
  211. }).catch(err=> {
  212. tempTip.cancelWaitingTip();
  213. tempTip.setDuration(3000);
  214. tempTip.show("网络错误:"+err);
  215. })
  216. },
  217. addDetail(){
  218. this._dataReady();
  219. this.details[this.models[this.index].id].unshift({
  220. "id" : "",
  221. "unit_id" : "",
  222. "range" : "",
  223. "province_id" : "",
  224. "city_id" : "",
  225. "unit_price" : "",
  226. "delivery_fee" : "",
  227. "initial_fee" : "",
  228. "initial_amount" : "",
  229. "rate" : "",
  230. "edit" : true,
  231. });
  232. this.$forceUpdate();
  233. },
  234. delDetail(detail,index){
  235. if (detail.id){
  236. detail.unit_price = $("#unit_price-"+detail.id).attr('data');
  237. detail.delivery_fee = $("#delivery_fee-"+detail.id).attr('data');
  238. detail.initial_fee = $("#initial_fee-"+detail.id).attr('data');
  239. detail.initial_amount = $("#initial_amount-"+detail.id).attr('data');
  240. detail.rate = $("#rate-"+detail.id).attr('data');
  241. detail.edit = false;
  242. }else{
  243. this.$delete(this.details[this.models[this.index]["id"]],index);
  244. }
  245. this.$forceUpdate();
  246. },
  247. updateDetail(detail){
  248. detail["edit"] = true;
  249. this.$forceUpdate();
  250. },
  251. submitDetail(detail){
  252. tempTip.setIndex(1099);
  253. window.axios.post('{{url('maintenance/priceModel/logistic/updateDetail')}}',{id:this.models[this.index].id,detail:detail})
  254. .then(res=>{
  255. if (res.data.success) {
  256. tempTip.setDuration(2000);
  257. if (detail.id){
  258. tempTip.showSuccess("修改成功");
  259. }else{
  260. detail.id = res.data.data.id;
  261. detail.province = res.data.data.province;
  262. detail.city = res.data.data.city;
  263. detail.unit = res.data.data.unit;
  264. tempTip.showSuccess("新增成功");
  265. }
  266. detail.edit = false;
  267. this.$forceUpdate();
  268. return;
  269. }
  270. tempTip.setDuration(3000);
  271. tempTip.show(res.data.data);
  272. }).catch(err=> {
  273. tempTip.setDuration(3000);
  274. tempTip.setIndex(1099);
  275. tempTip.show("网络错误:"+err);
  276. })
  277. },
  278. deletePriceModel(id,index){
  279. window.tempTip.setIndex(1099);
  280. window.tempTip.confirm("确定要删除该省份计费模型吗?",()=>{
  281. window.axios.post('{{url('maintenance/priceModel/logistic/destroyDetail')}}',{id:id})
  282. .then(res=>{
  283. if (res.data.success){
  284. this.$delete(this.details[this.models[this.index].id],index);
  285. tempTip.setDuration(2000);
  286. tempTip.showSuccess("删除成功");
  287. this.$forceUpdate();
  288. return;
  289. }
  290. tempTip.setDuration(3000);
  291. tempTip.show(res.data.data);
  292. }).catch(err=> {
  293. tempTip.setDuration(3000);
  294. tempTip.setIndex(1099);
  295. tempTip.show("网络错误:"+err);
  296. })
  297. });
  298. },
  299. exportDetail(){
  300. window.open("{{url('maintenance/priceModel/logistic/export')}}/"+this.models[this.index].id);
  301. }
  302. },
  303. });
  304. </script>
  305. @stop