Advertisement
Guest User

Untitled

a guest
Sep 10th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.92 KB | None | 0 0
  1. <template>
  2. <div class="modal fade in" role="dialog" aria-labelledby="showedItem" tabindex="-1" id="showedItem" style="display: block;">
  3. <div class="modal-dialog">
  4. <div class="modal-content">
  5. <div class="modal-header">
  6. <button type="button" data-dismiss="modal" aria-label="Close" class="close" @click="closeModal()"><span aria-hidden="true">×</span></button>
  7. <h4 class="modal-title">Show User</h4>
  8. </div>
  9. <div class="modal-body">
  10. <form method="POST" action="" accept-charset="UTF-8" role="form" abineguid="" @submit.prevent="onSubmit">
  11. <div class="box-body">
  12. <div class="form-group" v-bind:class="form.errors.has('email')? 'has-error' : ''">
  13. <label for="email">Email</label>
  14. <input placeholder="Email" name="email" type="text" id="email" class="form-control" v-model="form.email">
  15. <span class="help-block" v-if="form.errors.has('email')" v-text="form.errors.get('email')"></span>
  16. </div>
  17. </div>
  18. <div class="box-body">
  19. <div class="form-group" v-bind:class="form.errors.has('username')? 'has-error' : ''">
  20. <label for="username">Username</label>
  21. <input placeholder="Username" name="username" type="text" id="username" class="form-control" v-model="form.username">
  22. <span class="help-block" v-if="form.errors.has('username')" v-text="form.errors.get('username')"></span>
  23. </div>
  24. </div>
  25. <div class="box-body">
  26. <div class="form-group" v-bind:class="form.errors.has('password')? 'has-error' : ''">
  27. <label for="password">Password</label>
  28. <input placeholder="Password" name="password" type="password" id="password" class="form-control" v-model="form.password">
  29. <span class="help-block" v-if="form.errors.has('password')" v-text="form.errors.get('password')"></span>
  30. </div>
  31. </div>
  32. <div class="box-body">
  33. <div class="form-group">
  34. <label for="password_confirmation">Confirm Password</label>
  35. <input placeholder="Confirm Password" name="password_confirmation" type="password" id="password_confirmation" class="form-control" v-model="form.password_confirmation">
  36. </div>
  37. </div>
  38. <div class="box-body">
  39. <div class="form-group" v-bind:class="form.errors.has('name')? 'has-error' : ''">
  40. <label for="name">Name</label>
  41. <input placeholder="Chanel name" name="name" type="text" id="name" class="form-control" v-model="form.name">
  42. <span class="help-block" v-if="form.errors.has('name')" v-text="form.errors.get('name')"></span>
  43. </div>
  44. </div>
  45. <div class="box-body">
  46. <div class="form-group" v-bind:class="form.errors.has('status')? 'has-error' : ''">
  47. <label for="status">Status</label>
  48. <select id="status" name="status" class="form-control input-sm" v-model="form.status">
  49. <option value="1">Active</option>
  50. <option value="0" selected="selected">Unactive</option>
  51. </select>
  52. <span class="help-block" v-if="form.errors.has('status')" v-text="form.errors.get('status')"></span>
  53. </div>
  54. </div>
  55. </form>
  56. </div>
  57. <div class="modal-footer">
  58. <button type="button" data-dismiss="modal" class="btn btn-default pull-left" @click="closeModal()">Hủy</button>
  59. <button type="button" data-method="store" @click="submitAndClose()">
  60. Save
  61. </button>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. export default {
  69. props: {
  70. id:{
  71. type: Number,
  72. default: 0
  73. }
  74. },
  75.  
  76. data() {
  77. return {
  78. form: new Form({
  79. id: 0,
  80. email: '',
  81. username: '',
  82. name: '',
  83. password: null,
  84. password_confirmation: null,
  85. status: '',
  86. created_at: '',
  87. updated_at: '',
  88. deleted_at: '',
  89. })
  90. };
  91. },
  92.  
  93. created(){
  94. this.setValue();
  95. },
  96.  
  97. methods: {
  98. closeModal() {
  99. this.$emit('closeShowed');
  100. },
  101.  
  102. submitAndClose() {
  103. this.form.put(site_url + 'api/user/' + this.id)
  104. .then((res) => {
  105. this.$emit('submitUpdated', res);
  106. })
  107. .catch((err) => {
  108. console.error(err);
  109. });
  110. },
  111.  
  112. setValue(){
  113. axios.get(site_url + 'api/user/' + this.id, {}).then((res) => {
  114. this.form.id = res.data.item.id;
  115. this.form.email = res.data.item.email;
  116. this.form.username = res.data.item.username;
  117. this.form.name = res.data.item.name;
  118. this.form.status = res.data.item.status;
  119. this.form.created_at = res.data.item.created_at;
  120. this.form.updated_at = res.data.item.updated_at;
  121. this.form.deleted_at = res.data.item.deleted_at;
  122. }).catch((err) => console.error(err));
  123. },
  124. },
  125. }
  126. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement