Advertisement
Guest User

field-form

a guest
Mar 12th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template>
  2.  
  3.   <div class="col-md-4 col-md-offset-4">
  4.     <!--<div class="row">-->
  5.     <div class="make-center">
  6.       <div class="panel panel-success">
  7.         <div class="panel-heading">
  8.           <h3 class="panel-title ">Field Collection</h3>
  9.         </div>
  10.         <div class="panel-body">
  11.           <form>
  12.             <!--customer id created to run get function created-->
  13.             <div class="form-group form-control">
  14.               <input type="text" v-model="location">
  15.             </div>
  16.             <div>
  17.               <button @click='created'>Enter</button>
  18.             </div>
  19.             <!--customer id created to run get function created-->
  20.  
  21.             <!--customer information is displayed here-->
  22.             <div class="card">
  23.               <div class="customer-box">
  24.                 <h4>Client Info</h4>
  25.  
  26.                 <h5 style="font-weight: 600;">{{ customers.name }}</h5>
  27.                 <div id="customerInfo" v-for="bin in customers.bins" v-model="collectedBins">
  28.                   <input class="" type="checkbox">{{bin.type}}<br>
  29.                 </div>
  30.                 <!--customer information is displayed here-->
  31.  
  32.               </div>
  33.             </div>
  34.             <div>
  35.               <textarea name="remarks" placeholder="Enter Remarks"></textarea>
  36.             </div>
  37.             <div class="button-box">
  38.               <button class="btn btn-primary pull-right" v-on:click.prevent="addCollection()">Collected</button>
  39.               <button class="btn btn-primary pull-left" v-on:click.prevent>Not Collected</button>
  40.             </div>
  41.           </form>
  42.         </div>
  43.       </div>
  44.       <!--</div>-->
  45.     </div>
  46.   </div>
  47.  
  48. </template>
  49.  
  50. <script>
  51.   import axios from 'axios'
  52.  
  53.   var session_url = 'http://localhost:8000/api/v1/collections';
  54.   var username = 'kevin@gmail.com';
  55.   var password = 'password';
  56.   var credentials = btoa(username + ':' + password);
  57.   var BasicAuth = 'Basic ' + credentials;
  58.  
  59.   export default {
  60.     name: "fieldForm.vue",
  61.  
  62.     data: function () {
  63.       return {
  64.         customers: [],
  65.  
  66.         location: '',
  67.  
  68.         status: '',
  69.  
  70.         collectedBins: [],
  71.  
  72.         collectionsId: '',
  73.  
  74.  
  75.       }
  76.     },
  77.     methods: {
  78.  
  79.       created() {
  80.         axios.get('api/v1/collections/' + this.location, {
  81.           // headers: {'Authorization': BasicAuth}
  82.         })
  83.           .then((response) => {
  84.             // console.log(response);
  85.             // console.log(response.data.data)
  86.             this.customers = response.data.data;
  87.             this.cullectionId = response.data.data["collectionsId"]
  88.  
  89.             // console.log(this.customers["bins"])
  90.            
  91.          
  92.           })
  93.           .catch(error => {
  94.             console.error(error.message)
  95.  
  96.           })
  97.       }
  98.     },
  99.     addCollectio()=> {
  100.       axios.put(session_url, {
  101.         // headers: {'Authorization': BasicAuth}
  102.           status = "collected";
  103.           bins = this.collectedBins;
  104.           collectionId =this.collectionId.id;
  105.       })
  106.         .then((update)=> {
  107.           console.log(update);
  108.         })
  109.         .catch(error => {
  110.           console.error(error.message)
  111.         });
  112.     }
  113.   }
  114. </script>
  115.  
  116. <style>
  117.   body {
  118.     background-color: green;
  119.   }
  120.  
  121.  
  122.  
  123.   .customer-box {
  124.     display: block;
  125.     margin: auto;
  126.     width: 100%;
  127.     padding: 15px;
  128.     background: #eee;
  129.  
  130.   }
  131.  
  132.  
  133.   .make-center {
  134.     align-content: center;
  135.     justify-content: center;
  136.     display: flex;
  137.     margin-top: 40%;
  138.   }
  139.  
  140.  
  141. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement