Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!doctype html>
  2. <html lang="pt-br">
  3.  
  4. <head>
  5.   <!-- Required meta tags -->
  6.   <meta charset="utf-8">
  7.   <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  8.  
  9.   <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css" integrity="sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B"
  10.     crossorigin="anonymous">
  11.  
  12.  
  13.   <title>Condominios</title>
  14. </head>
  15.  
  16. <body>
  17.   <nav class="  navbar navbar-expand-sm navbar-dark bg-dark">
  18.     <div class="container">
  19.       <a href="#" class="navbar-brand">AudiCond</a>
  20.       <button type="button" class="navbar-toggler">
  21.         <span class="navbar-toggler-icon"></span>
  22.       </button>
  23.       <div class=" row justify-content-end collapse navbar-collapse " id="">
  24.         <ul class=" navbar-nav mr-left">
  25.           <ul class=" navbar-nav mr-auto">
  26.             <li class="nav-item ">
  27.               <a href="home.html" class="nav-link">Home</a>
  28.             </li>
  29.             <li class=" nav-item active">
  30.               <a href="Condominios.html" class="nav-link">Condominios</a>
  31.             </li>
  32.             <li class=" nav-item ">
  33.               <a href="CtaPagar.html" class="nav-link">Contas Pagar</a>
  34.             </li>
  35.           </ul>
  36.         </ul>
  37.       </div>
  38.     </div>
  39.   </nav>
  40.  
  41.   <div class="container" id="cadastro">
  42.     <div class="row">
  43.     </div>
  44.     <div class="row">
  45.  
  46.       <div class="container">
  47.         <div class="row justify-content-left justify-content-md-start">
  48.           <!--tela super peq 12, small(peq) 8, media 4-->
  49.           <div class="col-12 col-sm-8 col-md-4">
  50.             <form action="">
  51.             </form>
  52.           </div>
  53.           <div class=" justify-content-left col-md-6">
  54.             <form action="">
  55.  
  56.               <div class="form-row">
  57.                 <label for="">Nome</label>
  58.                 <input type="text" class="form-control" id="nome" v-model="nome" aria-describedby="nome" placeholder="">
  59.               </div>
  60.  
  61.  
  62.               <div class="form-group">
  63.                 <label for="">CNPJ</label>
  64.                 <input type="text" class="form-control" id="cnpj" v-model="cnpj" aria-describedby="cnpj" placeholder="">
  65.               </div>
  66.  
  67.               <div class="form-group">
  68.                 <label for="">Contato</label>
  69.                 <input type="text" class="form-control" id="contato" v-model="contato" aria-describedby="contato" placeholder="">
  70.               </div>
  71.  
  72.  
  73.  
  74.               <button type="button" class=" btn btn-primary  btn-block" @Click.prevent="addItem">Gravar</button>
  75.             </form>
  76.           </div>
  77.         </div>
  78.       </div>
  79.     </div>
  80.  
  81.   <table class="table">
  82.     <thead>
  83.       <tr>
  84.         <th scope="col">Nome</th>
  85.         <th scope="col">CNPJ</th>
  86.         <th scope="col">Contato</th>
  87.         <th scope="col">Ações</th>
  88.       </tr>
  89.     </thead>
  90.     <tbody>
  91.       <tr v-for="p,index in cadastro">
  92.         <td>{{ p.nome }}</td>
  93.         <td>{{ p.cnpj }}</td>
  94.         <td>{{ p.contato }}</td>
  95.         <td>
  96.  
  97.           <td>
  98.             <button class="btn btn-success" @click.prevent="editItem(index)">Editar</button>
  99.           </td>
  100.       </tr>
  101.     </tbody>
  102.   </table>
  103. </div>
  104.   <footer>
  105.     <div class="fixed-bottom bg-dark text-white">
  106.       <p class="text-center">Curso de TI - Fundatec @ 2019</p>
  107.     </div>
  108.   </footer>
  109.  
  110.  
  111.  
  112.   <!-- Foi colocado no final para a página carregar mais rápido -->
  113.   <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
  114.     crossorigin="anonymous"></script>
  115.   <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
  116.     crossorigin="anonymous"></script>
  117.   <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
  118.     crossorigin="anonymous"></script>
  119.   <script src="http://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  120.   <script src="http://unpkg.com/axios/dist/axios.min.js"></script>
  121.   <script src="c.json"></script>
  122.  
  123.   <script>
  124.     const app = new Vue({
  125.  
  126.       el: '#cadastro',
  127.       data: {
  128.         cadastro: [], //Array
  129.         //dadosiniciais: json,
  130.         condominio: {},  //Objetos
  131.         nome: '',
  132.         cnpj: '',
  133.         contato: ''
  134.  
  135.       },
  136.       methods: {
  137.  
  138.         addItem() {
  139.           this.condominio = {
  140.             "nome": this.nome,
  141.             "cnpj": this.cnpj,
  142.             "contato": this.contato
  143.  
  144.           };
  145.           this.cadastro.push(this.condominio);
  146.           this.condominio = {};
  147.           this.nome = '';
  148.           this.cnpj = '';
  149.           this.contato = '';
  150.  
  151.         },
  152.  
  153.        
  154.        
  155.         editItem(index) {
  156.           this.nome = this.cadastro[index].nome;
  157.           this.cnpj = this.cadastro[index].cnpj;
  158.           this.contato = this.cadastro[index].contato;
  159.           this.cadastro.splice(index, 1);
  160.  
  161.         },
  162.  
  163.       getCondominio() {
  164.           // Este código serve APENAS para ler o arquivo JSON
  165.           let tam = dad.length;
  166.           console.log(tam);
  167.           for(let i=0; i<tam ; i++){
  168.               console.log(dad[i]);
  169.               this.cadastro.push(dad[i]);
  170.  
  171.             }
  172.         // Este códig serve para acessar a sua API -> USE ESTE AQUI NO TCC
  173.           //let url = "http://localhost.......";
  174.           //axios.get(url).then((response) => {
  175.           //  const dados = response.data;
  176.           //  console.log(dados);
  177.           //}).catch((error) => {
  178.           //  console.log('ERR: ' + error);
  179.           //}); // axios
  180.          
  181.         }
  182.     },
  183.       mounted() {
  184.         this.getCondominio();
  185.       }
  186.     });
  187.  
  188.  
  189.   </script>
  190. </body>
  191.  
  192. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement