Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. <div id="app" class="container">
  2. <b-table
  3. show-empty
  4. stacked="md"
  5. :items="items"
  6. :fields="fields"
  7. :current-page="currentPage"
  8. :per-page="perPage"
  9. :filter="filter"
  10. :sort-by.sync="sortBy"
  11. :sort-desc.sync="sortDesc"
  12. :sort-direction="sortDirection"
  13. @filtered="onFiltered">
  14.  
  15. <template slot="id">
  16.  
  17. </template>
  18.  
  19. <template slot="actions" slot-scope="item">
  20. <b-button size="sm" @click="info(items.id)" class="mr-1">
  21. <span class="glyphicon glyphicon-edit"></span>
  22. </b-button>
  23. <b-button size="sm" @click="info(items.id, $event.target)" class="mr-1">
  24. <span class="glyphicon glyphicon-remove"></span>
  25. </b-button>
  26. </template>
  27. </b-container>
  28. </template>
  29. </div>
  30.  
  31. var app = new Vue({
  32. el: "#app",
  33. delimiters: ['${','}'],
  34. components: {
  35. vuejsDatepicker
  36. },
  37. data() {
  38. return {
  39. items: [],
  40. fields: [
  41. { key: 'id', label: 'Id', sortable: true, sortDirection: 'desc', class: 'text-center' },
  42. { key: 'tipo', label: 'Tipo', sortable: true, class: 'text-center' },
  43. { key: 'descripcion', label: 'Descripción', sortable: true, class: 'text-center' },
  44. { key: 'razaanimal.nombre', label: 'Raza', sortable: true, class: 'text-center' },
  45. { key: 'fecha', label: 'Fecha', sortable: true, class: 'text-center' },
  46. { key: 'actions', label: 'Acciones', class: 'text-center' }
  47. ],
  48. totalRows: 1,
  49. currentPage: 1,
  50. perPage: 5,
  51. pageOptions: [5, 10, 15],
  52. sortBy: null,
  53. sortDesc: false,
  54. sortDirection: 'asc',
  55. filter: null,
  56. infoModal: {
  57. id: '',
  58. title: '',
  59. content: ''
  60. }
  61. }
  62. },
  63. computed: {
  64. sortOptions() {
  65. // Create an options list from our fields
  66. return this.fields
  67. //alert(this.fields)
  68. .filter(f => f.sortable)
  69. .map(f => {
  70. return { text: f.label, value: f.key }
  71. })
  72. }
  73. },
  74. mounted() {
  75.  
  76. this.getMovimientos()
  77.  
  78. },
  79. methods: {
  80. getMovimientos: function() {
  81. this.loading = true;
  82. this.$http.get('/control/movimiento/api/mov/').then(response => {
  83. this.items = response.data;
  84. //alert(this.items);
  85. this.loading = false;
  86. }, response => {
  87. this.loading = false;
  88. console.log(err);
  89. });
  90. },
  91. info(id) {
  92. alert(id)
  93. this.infoModal.title = 'Row index: ${id}'
  94. this.infoModal.content = JSON.stringify(id, null, 2)
  95. this.$root.$emit('bv::show::modal', this.infoModal.id)
  96. },
  97. resetInfoModal() {
  98. this.infoModal.title = ''
  99. this.infoModal.content = ''
  100. },
  101. }
  102. });
  103.  
  104. <template slot="actions" slot-scope="item">
  105. **En esta parte--->**<b-button size="sm" @click="info(items.id)" class="mr-1">
  106. <span class="glyphicon glyphicon-edit"></span>
  107. </b-button>
  108. <b-button size="sm" @click="info(items.id, $event.target)" class="mr-1">
  109. <span class="glyphicon glyphicon-remove"></span>
  110. </b-button>
  111. </template>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement