note-form-modal.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <modal :id="modalId" tabindex="-1" role="dialog" :aria-labelledby="modalId+'Label'">
  3. <h5 slot="header" class="modal-title" :id="modalId+'Label'">
  4. Edit Note
  5. </h5>
  6. <div slot="body">
  7. <div class="form-group">
  8. <label for="content">Content</label>
  9. <textarea :name="'content'+note.noteid" :id="'content'+note.noteid" class="form-control" v-model="note.thenote"></textarea>
  10. </div>
  11. </div>
  12. <div slot="footer">
  13. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  14. <button type="button" class="btn btn-primary" @click="updateNote(note)">Save</button>
  15. </div>
  16. </modal>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. populateWith: {
  22. type: Object,
  23. },
  24. modalId: {
  25. type: String,
  26. require: true
  27. },
  28. noteType: {
  29. type: Number
  30. },
  31. noteUser: {
  32. type: String
  33. },
  34. woid: {
  35. type: Number
  36. }
  37. },
  38. data () {
  39. return {
  40. note: {}
  41. }
  42. },
  43. mounted () {
  44. if(!this.populateWith) {
  45. this.note = {
  46. thenote: '',
  47. notetype: this.noteType,
  48. noteuser: this.noteUser,
  49. woid: this.woid,
  50. }
  51. } else {
  52. this.note = JSON.parse(JSON.stringify(this.populateWith))
  53. }
  54. },
  55. methods: {
  56. updateNote (note) {
  57. if (this.populateWith) {
  58. axios.put('/api/workorders/notes/' + note.noteid, note)
  59. .then((response) => {
  60. hideModal()
  61. })
  62. } else {
  63. axios.post('/api/workorders/notes', note)
  64. .then((response) => {
  65. hideModal()
  66. })
  67. }
  68. },
  69. hideModal () {
  70. $('#'+this.modalId).modal('hide')
  71. }
  72. }
  73. }
  74. </script>