Seen.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <i @click="fetchData" data-bs-toggle="tooltip" :title=tooltipMessage :class="[ state ? statusOn : statusOff ]"></i>
  3. </template>
  4. <script>
  5. import axios from "axios"
  6. export default {
  7. props: {
  8. content: { type: String },
  9. path: { type: String },
  10. initialState: { type: Boolean, default: false },
  11. stateOn: { type: String },
  12. stateOff: { type: String },
  13. textOn: { type: String },
  14. textOff: { type: String }
  15. },
  16. data () {
  17. return {
  18. filmId: this.content,
  19. state: this.initialState,
  20. statusOn: this.stateOn,
  21. statusOff: this.stateOff,
  22. }
  23. },
  24. computed: {
  25. tooltipMessage() {
  26. return (this.state ? this.textOn : this.textOff)
  27. }
  28. },
  29. methods: {
  30. fetchData() {
  31. axios.post( this.path, {
  32. id_film: this.filmId
  33. },{
  34. headers: {'X-Requested-With': 'XMLHttpRequest'},
  35. }).then(response => {
  36. this.state = response.data.newState
  37. })
  38. }
  39. },
  40. }
  41. </script>
  42. <style>
  43. </style>