woinfo-edit-modal.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <modal :id="id" tabindex="-1" role="dialog" :aria-labelledby="id+'Label'">
  3. <h5 slot="header" class="modal-title" :id="id+'Label'">
  4. Edit Work Order Information
  5. </h5>
  6. <div slot="body">
  7. <div class="form-group">
  8. <label for="probdesc">Problem Description</label>
  9. <textarea id="probdesc" name="probdesc" :class="{'form-control': true, 'is-invalid': errors.probdesc}" v-model="data.probdesc"></textarea>
  10. <errorlist :errors="errors.probdesc"></errorlist>
  11. </div>
  12. <div class="form-group">
  13. <label for="suggested">Suggested Solution</label>
  14. <textarea id="suggested" name="suggested" :class="{'form-control': true, 'is-invalid': errors.suggested}" v-model="data.suggested"></textarea>
  15. <errorlist :errors="errors.suggested"></errorlist>
  16. </div>
  17. <div class="form-group">
  18. <label for="storelist">Store</label>
  19. <select name="storelist" id="storelist" class="form-control" v-if="storeList" v-model="data.storeid">
  20. <option v-for="store in storeList" v-bind:key="store.storeid" v-bind:value="store.storeid">
  21. {{ store.storesname }}
  22. </option>
  23. </select>
  24. </div>
  25. </div>
  26. <div slot="footer">
  27. <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
  28. <button type="button" class="btn btn-primary" @click="updateWorkOrder()">Save</button>
  29. </div>
  30. </modal>
  31. </template>
  32. <script>
  33. export default {
  34. props:['populateWith', 'storeList', 'modalId'],
  35. data() {
  36. return {
  37. // Copies object from prop, so it doesn't mutate the object
  38. // from the parent component. Parent component will be updated via
  39. // Websocket if updateWorkOrder is successful.
  40. data: JSON.parse(JSON.stringify(this.populateWith)),
  41. storeArray: this.storeList,
  42. id: this.modalId,
  43. errors: []
  44. }
  45. },
  46. methods: {
  47. updateWorkOrder() {
  48. axios.put('/api/workorders/' + this.data.woid, this.data)
  49. .then((response) => { $('#workordereditModal').modal('hide'); })
  50. .catch((error) => { this.errors = JSON.parse(error.response.request.response).errors; });
  51. }
  52. }
  53. }
  54. </script>