Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.91 KB | None | 0 0
  1. <template>
  2.     <v-client-table :data="carData" :columns="carColumns" :options="carOptions"></v-client-table>
  3. </template>
  4.  
  5. <script>
  6.     import * as moment from "moment";
  7.     export default {
  8.         data: function () {
  9.             return {
  10.                 carColumns:['invoice','year','make','model','stock','vin','optional','product','price',"created_at","updated_at"],
  11.                 carData: [],
  12.                 carOptions:{
  13.                     dateFormat: "DD-MM-YY",
  14.                     dateColumns: ['created_at'],
  15.                     headings: {
  16.                         invoice: 'Invoice',
  17.                         year: 'Year',
  18.                         make: 'Make',
  19.                         model: 'Model',
  20.                         stock: 'Stock',
  21.                         vin: 'VIN',
  22.                         optional: 'Optional',
  23.                         product: 'Product',
  24.                         price: 'Price',
  25.                         created_at: 'Created',
  26.                         updated_at: 'Updated',
  27.                         edit: 'Edit',
  28.                     },
  29.                     templates: {
  30.                         edit: function(row) {
  31.                             return `<a href='#!/${row.id}/edit'><i class='glyphicon glyphicon-edit'></i></a>`
  32.                         },
  33.  
  34.                     },
  35.                 },
  36.  
  37.             };
  38.         },
  39.         methods: {
  40.             getsCars: function(){
  41.                 $.getJSON("/cars/get",function (data) {
  42.                     data.forEach(car=>{
  43.                         car.created_at = moment(car.created_at);
  44.                         car.updated_at = moment(car.updated_at);
  45.                     });
  46.                     this.carData = data;
  47.                 }.bind(this));
  48.             }
  49.         },
  50.         created: function(){
  51.             this.getsCars();
  52.             this.timer = setInterval(this.getsCars, 1000)
  53.         },
  54.     }
  55. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement