Advertisement
Guest User

seeee

a guest
May 14th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.78 KB | None | 0 0
  1. var detalles = new Vue ({
  2. el: "#detalleCliente",
  3. data: {
  4. logged: true,
  5. cliente: null,
  6. },
  7. methods: {
  8. detallar: function (selectedClient) {
  9. this.logged = false;
  10. this.cliente = selectedClient;
  11. },
  12. goBack: function() {
  13. this.logged = true;
  14. clientes.buscar();
  15. clientes.logged = true;
  16. }
  17. }
  18. })
  19.  
  20. var clientes = new Vue({
  21. el: "#tabla-clientes",
  22. data: {
  23. logged: false,
  24. clientes,
  25. paginaActual: 0,
  26. nombreFantasia: "",
  27. page: {
  28. totalPages: 0
  29. }
  30. },
  31. methods: {
  32. cargar: function (json) {
  33. this.clientes = json._embedded.clienteResources;
  34. this.page = json.page;
  35. this.paginaActual = json.page.number;
  36. },
  37. buscar: function () {
  38. this.paginaActual = 0;
  39. consultaClientes(this.paginaActual, this.nombreFantasia)
  40. },
  41. previous: function () {
  42. this.paginaActual--;
  43. consultaClientes(this.paginaActual, this.nombreFantasia)
  44. },
  45. next: function () {
  46. this.paginaActual++;
  47. consultaClientes(this.paginaActual, this.nombreFantasia)
  48. },
  49. detallarCliente: function(cliente) {
  50. this.logged = false;
  51. detalles.detallar(cliente);
  52. }
  53. },
  54. computed: {
  55. hasNext: function () {
  56. return clientes.paginaActual + 1 !== clientes.page.totalPages
  57. },
  58. hasPrevious: function () {
  59. return clientes.paginaActual !== 0
  60. },
  61. }
  62. })
  63.  
  64. function consultaClientes (page, nombreFantasia) {
  65. $.get({
  66. url: 'http://demo-paljet.bbjetcloud.com/pjet-api/clientes',
  67. crossDomain: true,
  68. data: {
  69. page: page,
  70. nom_fantasia: nombreFantasia
  71. },
  72. headers: {
  73. EmpID: 1,
  74. Authorization: 'Basic ' + btoa(login.user + ':' + login.password)
  75. }
  76. }).done(function (json){
  77. clientes.cargar(json)
  78. }).fail(function (){
  79. alert("HICISTE ALGO MAL FALITENS !!!");
  80. })
  81. }
  82.  
  83. var login = new Vue({
  84. el: '#login',
  85. data: {
  86. logged: false,
  87. user: "ADMIN",
  88. password: "ADMIN"
  89. },
  90. methods: {
  91. ingresar: function () {
  92. $.get({
  93. // http://10.0.0.197:9003/clientes
  94. url: 'http://demo-paljet.bbjetcloud.com/pjet-api/clientes',
  95. crossDomain: true,
  96. data: {
  97. page: clientes.paginaActual,
  98. nom_fantasia: clientes.nombreFantasia
  99. },
  100. headers: {
  101. EmpID: 1,
  102. Authorization: 'Basic ' + btoa(login.user + ':' + login.password)
  103. }
  104. }).done(function (resultadoJSON) {
  105. login.logged = true;
  106. clientes.cargar(resultadoJSON);
  107. clientes.logged = true;
  108.  
  109. }).fail(function () {
  110. alert("HICISTE ALGO MAL FALITENS !!!");
  111. });
  112.  
  113. }
  114. }
  115. })
  116.  
  117. $(document).ready(login.ingresar())
  118.  
  119.  
  120.  
  121. //HTML
  122.  
  123.  
  124.  
  125. <!DOCTYPE html>
  126. <html lang="en">
  127.  
  128. <head>
  129. <meta charset="UTF-8">
  130. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  131. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  132. <title>Document</title>
  133.  
  134. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  135. <link rel="stylesheet" href="style.css">
  136. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  137. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  138.  
  139. </head>
  140.  
  141. <body>
  142. <div class="container-fluid">
  143. <form id="login" v-if="!logged">
  144. <div class="form-group">
  145. <input type="text" v-model="user" class="form-control" id="usuario" aria-describedby="emailHelp"
  146. placeholder="Usuario" required>
  147. </div>
  148.  
  149. <div class="form-group">
  150. <input type="password" v-model="password" class="form-control" id="inputPassword"
  151. placeholder="Contraseña" required>
  152. </div>
  153.  
  154. <button v-on:click.prevent="ingresar" class="btn btn-primary">Ingresar</button>
  155. </form>
  156.  
  157. <div id="tabla-clientes" class="center" v-if="logged">
  158. <form style="display:inline-block">
  159. <div id="busqueda" class="center2">
  160. Search: <input type="text" @input="buscar(page, nombreFantasia)" v-model="nombreFantasia" placeholder="busca" id="busqueda"/>
  161. <button class="btn btn-primary"> Buscar
  162. <span class="glyphicon glyphicon-search"></span>
  163. </button>
  164. </div>
  165. </form>
  166. <div class="pager">
  167. <a class="glyphicon glyphicon-arrow-left" v-if="hasPrevious" v-on:click="previous"></a>
  168. <span class="badge num"> {{ paginaActual }} de {{ page.totalPages }}</span>
  169. <a class="glyphicon glyphicon-arrow-right arrowRight" v-if="hasNext" v-on:click.prevent="next"></a>
  170. </div>
  171.  
  172. <table class="myTable">
  173. <thead>
  174. <tr>
  175. <th scope="col">ID Cliente</th>
  176. <th scope="col">Razon Social</th>
  177. <th scope="col">Nombre Fantasia</th>
  178. <th scope="col">Domicilio</th>
  179. <th scope="col">Localidad</th>
  180. <th scope="col">Email</th>
  181. </tr>
  182. </thead>
  183. <tbody>
  184. <!-- v-bind:class="{selected: selectedClient === client}" -->
  185. <tr class="niceColor" v-for="cliente in clientes" type="value" v-on:click="detallarCliente(cliente)" v-bind:value="nombreFantasia" >
  186. <td>{{ cliente.cliId }}</td>
  187. <td>{{ cliente.razonSocial }}</td>
  188. <td>{{ cliente.nombreFantasia }}</td>
  189. <td>{{ cliente.domicilios[0].domicilio || 'no domicilio' }}</td>
  190. <td>{{ cliente.domicilios[0].localidad.nombre || 'no localidad' }}</td>
  191. <td>{{ cliente.email || 'no email' }}</td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. </div>
  196.  
  197. <div id="detalleCliente" v-if="!logged" style="width: 100%">
  198. <form>
  199. <div>
  200. <a class="glyphicon glyphicon-arrow-left" v-on:click="goBack"></a>
  201. <h4>Id Cliente: {{ cliente.cliId }}</h4>
  202. <h4>Razón social: {{ cliente.razonSocial }}</h4>
  203. <h4>Nombre: {{ cliente.nombreFantasia }}</h4>
  204. <h4>Cuit: {{ cliente.cuit }}</h4>
  205. <h4>Domicilio: {{ cliente.domicilios[0].domicilio || 'no domicilio' }}</h4>
  206. <h4>Localidad: {{ cliente.domicilios[0].localidad.nombre || 'no localidad' }}</h4>
  207. <h4>Código Postal: {{ cliente.domicilios[0].localidad.cod_postal || 'no cod pos'}}</h4>
  208. <h4>Email: {{ cliente.email || 'no email' }}</h4>
  209. <h4>Situación ante el iva: {{ cliente.sit_ante_iva_nombre}}</h4>
  210. </div>
  211. </form>
  212. </div>
  213. </div>
  214. </body>
  215. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  216. <script src="myVue.js"></script>
  217.  
  218. </html>
  219.  
  220.  
  221. //CSS
  222.  
  223.  
  224. body, html { height: 100%; width: 100%; }
  225.  
  226. .container-fluid {
  227. height: 100%;
  228. display: flex;
  229. }
  230.  
  231. form {
  232. padding: 20px;
  233. min-width: 350px;
  234. margin: auto;
  235. background: #fff;
  236. -webkit-box-shadow: 0px 0px 3px 0px rgba(107,107,107,1);
  237. -moz-box-shadow: 0px 0px 3px 0px rgba(107,107,107,1);
  238. box-shadow: 0px 0px 3px 0px rgba(107,107,107,1);
  239. }
  240.  
  241. form * {
  242. border-radius: 0 !important;
  243. }
  244.  
  245. form > button {
  246. width: 100%;
  247. }
  248.  
  249. .center {
  250. width: 80%;
  251. margin: 0 auto;
  252. }
  253.  
  254. .pager {
  255. text-align: RIGHT;
  256. }
  257.  
  258. table {
  259. border-collapse: collapse;
  260. }
  261.  
  262. table, th, td {
  263. border: 1px solid grey;
  264. }
  265.  
  266. th, td {
  267. padding: 15px;
  268. text-align: left;
  269. }
  270.  
  271. th {
  272. background-color: #4CAF50;
  273. color: white;
  274. }
  275.  
  276. .niceColor {
  277. background-color: lightblue;
  278. }
  279. #detalles{
  280. position: absolute;
  281. top:0;
  282. }
  283.  
  284. tr:hover {
  285. cursor:pointer;
  286. background-color: rgba(67, 151, 56, 0.671);
  287. }
  288.  
  289. #falito{
  290. font-size: 30px;
  291. }
  292.  
  293. /* PÁGINA LINDA PARA DEJAR LINDAS LAS COSAS, NO SÉ HAY MUCHO RE VIOLENTO */
  294. /* https://www.webucator.com/how-to/how-style-table-with-css.cfm */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement