Home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <div class="mt-5">
  3. <div class="alert alert-danger alert-rounded pt-5 m-3" v-if="strError.length != 0">
  4. <button type="button" class="close" data-dismiss="alert" aria-label="Close"></button>
  5. <i class="material-icons icon-align">report_problem</i>
  6. {{ strError }}
  7. </div>
  8. <div class="container-fluid background-estantes">
  9. <div class="row">
  10. <div class="col-12 offset-sm-2 col-sm-9 offset-lg-2 col-lg-9 pb-5">
  11. <div class="row">
  12. <div class="col-sm-12">
  13. <h4 class="text-center mt-5">
  14. ÚLTIMOS
  15. <span class="text-danger">CAMBIOS</span>
  16. </h4>
  17. <hr
  18. style="border: 3px solid rgb(228, 47, 43);
  19. width: 40px;
  20. border-radius: 30px 30px 30px 30px;"
  21. />
  22. </div>
  23. <div class="col-sm-12" style="background:#fff;border-radius:30px;">
  24. <div class="news-estantes p-2 m-3">
  25. <slick ref="slick" :options="slickOptions" v-if="newEstantes.length">
  26. <router-link
  27. :to="{ name:'estantes', params: { est: slug(estante.ESTA) } }"
  28. tag="a"
  29. class="p-2"
  30. v-for="estante in newEstantes"
  31. :key="estante.IDES"
  32. >
  33. <div class="card p-1">
  34. <img :data-lazy="estante.IDIM" class="img-responsive" :id="estante.IDES" />
  35. <b-tooltip :target="estante.IDES" placement="bottom">
  36. <span class="text-lowercase">{{ estante.ESTA }}</span>
  37. </b-tooltip>
  38. </div>
  39. </router-link>
  40. </slick>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="container-fluid whithoutPadding" id="divEstantes">
  48. <div class="row">
  49. <div class="col-sm-3" style="background: #fff">
  50. <div class="row" style="background: #E30425 none repeat scroll 0% 0%">
  51. <div class="col-sm-12 p-4">
  52. <h6 class="pb-1 text-white">BUSCAR</h6>
  53. <div class="input-group">
  54. <div class="input-group-append">
  55. <span class="input-group-text" id="inputGroup">
  56. <i class="material-icons">search</i>
  57. </span>
  58. </div>
  59. <input
  60. type="text"
  61. class="form-control"
  62. v-model="buscar"
  63. placeholder="Escriba su búsqueda"
  64. />
  65. </div>
  66. <hr />
  67. <h6 class="pb-1 text-white">ORDENAR POR</h6>
  68. <div class="datepicker-trigger">
  69. <div class="input-group">
  70. <div class="input-group-append">
  71. <span class="input-group-text" id="basic-addon2">
  72. <i class="material-icons align-middle">date_range</i>
  73. </span>
  74. </div>
  75. <input
  76. type="text"
  77. class="form-control"
  78. id="datepicker-trigger"
  79. placeholder="Selecciona un rango"
  80. :value="formatoFechaCalendario(filtroFecha.fechaInicial,filtroFecha.fechaFinal)"
  81. />
  82. </div>
  83. <p>
  84. <a
  85. href="#"
  86. @click.prevent="filtroFecha.fechaInicial='';
  87. filtroFecha.fechaFinal='';
  88. filtroFecha.activar = false"
  89. class="btn btn-sm btn-danger bg-dark text-white mt-3 float-right"
  90. v-show="filtroFecha.fechaInicial !== ''&&filtroFecha.fechaFinal !== ''"
  91. >Borrar filtro</a>
  92. </p>
  93. </div>
  94. <AirbnbStyleDatepicker
  95. :trigger-element-id="'datepicker-trigger'"
  96. :mode="'range'"
  97. :fullscreen-mobile="false"
  98. :date-one="filtroFecha.fechaInicial"
  99. :date-two="filtroFecha.fechaFinal"
  100. :end-date="filtroFecha.fechaLimiteCalendario"
  101. @date-one-selected="val => { filtroFecha.fechaInicial = val }"
  102. @date-two-selected="val => { filtroFecha.fechaFinal = val }"
  103. @apply="filtroFecha.activar = true"
  104. />
  105. </div>
  106. </div>
  107. </div>
  108. <div class="col-sm-9" style="background: #fff">
  109. <div class="container-fluid background-todosEstantes">
  110. <div class="col-sm-12 pb-1">
  111. <h4 class="text-center">
  112. TODOS LOS
  113. <span class="text-danger">ESTANTES</span>
  114. </h4>
  115. <hr
  116. style="border: 3px solid rgb(228, 47, 43);
  117. width: 40px;
  118. border-radius: 30px 30px 30px 30px;"
  119. />
  120. </div>
  121. <div class="row">
  122. <div class="col-sm-12 offset-lg-1 offset-xl-1">
  123. <transition-group name="flip-list" tag="div">
  124. <div
  125. v-for="estante in buscarEstante"
  126. :key="estante.IDES"
  127. class="col-12 col-sm-6 col-md-4 col-lg-3 col-xl-2 list-item m-lg-4 m-xl-4 p-4 p-sm-3 p-md-3 p-lg-0 p-xl-0"
  128. >
  129. <router-link
  130. :to="{ name:'estantes', params: { est: slug(estante.ESTA) } }"
  131. tag="div"
  132. class="ribbon-wrapper-reverse card shadow-sm p-1"
  133. style="cursor:pointer"
  134. >
  135. <h6 class="mb-0 ml-3 mr-3 mt-3">{{ estante.ESTA }}</h6>
  136. <img class="img-responsive p-1" v-lazy="estante.IDIM" />
  137. <label class="m-1 label text-muted">Publicado el {{estante.FECR }}</label>
  138. </router-link>
  139. </div>
  140. </transition-group>
  141. </div>
  142. <div class="col-sm-12">
  143. <p
  144. class="text-center"
  145. v-if="buscarEstante.length === 0 && !loading &&
  146. (buscar !== '' || filtroFecha.fechaFinal !== '') && estantesPermitidos.length !== 0"
  147. >No se encontraron resultados para su búsqueda.</p>
  148. </div>
  149. </div>
  150. <div
  151. v-if="mensajeEstantesVacios"
  152. class="alert alert-secondary text-center mt-3"
  153. role="alert"
  154. >No se encontraron estantes para mostrar.</div>
  155. <infinite-loading @infinite="infiniteEstante" v-else>
  156. <div slot="no-more" class="text-muted"></div>
  157. <div slot="no-results">No tenemos estantes... :c</div>
  158. </infinite-loading>
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </template>
  165. <script>
  166. require("../../../node_modules/slick-carousel/slick/slick.css");
  167. require("../../../node_modules/slick-carousel/slick/slick-theme.css");
  168. import { token } from "../../_mixin/user_mixin.js";
  169. import { downloadMixin } from "../../_mixin/public_mixin.js";
  170. import slick from "vue-slick";
  171. import InfiniteLoading from "vue-infinite-loading";
  172. import { BTooltip } from "bootstrap-vue";
  173. import moment from "moment";
  174. var _ = require("lodash");
  175. export default {
  176. name: "Estantes",
  177. components: {
  178. BTooltip,
  179. slick,
  180. InfiniteLoading
  181. },
  182. mixins: [downloadMixin, token],
  183. data() {
  184. return {
  185. porPagina: 6,
  186. inicioPagina: 1,
  187. estantesTemp: [],
  188. estantesPermitidos: [],
  189. permisosDatos: [],
  190. slickOptions: {
  191. centerPadding: "10px",
  192. slidesToShow: 6,
  193. adaptiveHeight: true,
  194. autoplay: true,
  195. lazyLoad: "ondemand",
  196. responsive: [
  197. {
  198. breakpoint: 768,
  199. settings: {
  200. centerMode: true,
  201. centerPadding: "15px",
  202. slidesToShow: 3
  203. }
  204. },
  205. {
  206. breakpoint: 480,
  207. settings: {
  208. arrows: false,
  209. centerMode: true,
  210. centerPadding: "15px",
  211. slidesToShow: 1
  212. }
  213. }
  214. ]
  215. },
  216. mensajeEstantesVacios: false
  217. };
  218. },
  219. async mounted() {
  220. await this.getEstantes();
  221. this.permisosEstantes();
  222. this.inicioPagina = 0;
  223. },
  224. methods: {
  225. permisosEstantes() {
  226. if (this.$store.getters.user.role === "colaborador") {
  227. this.permisosDatos = JSON.parse(this.$store.getters.permisos);
  228. let estantesConAcceso = _.filter(
  229. this.permisosDatos[0].children,
  230. perm => !perm.text.match("Sin Acceso")
  231. );
  232. let estantesPermitidos = _.values(
  233. _.mapValues(estantesConAcceso, est => {
  234. let arrEstanteAndId = est.text.split(" | ");
  235. let strEstante = arrEstanteAndId[0].split(" - ");
  236. let resultadoFinal = _.find(this.estantes, ["ESTA", strEstante[0]]);
  237. return resultadoFinal;
  238. })
  239. );
  240. this.estantesPermitidos = estantesPermitidos;
  241. }
  242. if (this.$store.getters.user.role === "admin") {
  243. this.estantesPermitidos = this.estantes;
  244. this.mensajeEstantesVacios =
  245. this.estantesPermitidos.length === 0 ? true : false;
  246. }
  247. },
  248. infiniteEstante(state) {
  249. setTimeout(() => {
  250. // Calcular la página
  251. const indiceInicio = (this.inicioPagina - 1) * this.porPagina;
  252. const indiceFinal =
  253. indiceInicio + this.porPagina >= this.estantesPermitidos.length
  254. ? this.estantesPermitidos.length
  255. : indiceInicio + this.porPagina;
  256. if (indiceInicio >= 0) {
  257. this.estantesTemp = this.estantesTemp.concat(
  258. this.estantesPermitidos.slice(indiceInicio, indiceFinal)
  259. );
  260. }
  261. state.loaded();
  262. if (this.inicioPagina * this.porPagina > indiceFinal) {
  263. return state.complete();
  264. }
  265. }, 1000);
  266. // Aumentamos pagina cada vez que se ejecute la funcion
  267. this.inicioPagina++;
  268. }
  269. },
  270. computed: {
  271. newEstantes: function() {
  272. return this.estantesPermitidos.slice(0, 7);
  273. },
  274. buscarEstante() {
  275. if (this.filtroFecha.activar || this.buscar.length) {
  276. var estantesFiltroFecha = this.filtrarFecha("est");
  277. // filtramos por input busqueda
  278. return estantesFiltroFecha.filter(estante => {
  279. return estante.ESTA.toLowerCase().match(this.buscar.toLowerCase());
  280. });
  281. }
  282. return this.estantesTemp;
  283. }
  284. }
  285. };
  286. </script>
  287. <style scoped>
  288. .card {
  289. transition: ease-in 0.3s;
  290. }
  291. .card:hover {
  292. box-shadow: 0 0.3rem 0.95rem rgba(0, 0, 0, 0.18) !important;
  293. }
  294. </style>
  295. <style>
  296. /* infinite scroll */
  297. .loading {
  298. text-align: center;
  299. position: absolute;
  300. color: #fff;
  301. z-index: 9;
  302. background: blue;
  303. padding: 8px 18px;
  304. border-radius: 5px;
  305. left: calc(50% - 45px);
  306. top: calc(50% - 18px);
  307. }
  308. .fade-enter-active,
  309. .fade-leave-active {
  310. transition: opacity 0.5s;
  311. }
  312. .fade-enter,
  313. .fade-leave-to {
  314. opacity: 0;
  315. }
  316. .slick-prev::before,
  317. .slick-next::before {
  318. font-size: 27px !important;
  319. color: #dc3545 !important;
  320. }
  321. .background-estantes {
  322. background-image: url("../../assets/images/fondo-nuevos-estantes.png");
  323. height: 100%;
  324. background-repeat: no-repeat;
  325. background-size: cover;
  326. background-position: center center;
  327. }
  328. .bg-image--2 {
  329. background-repeat: no-repeat;
  330. background-size: cover;
  331. background-position: center center;
  332. height: 350px;
  333. }
  334. .section__title {
  335. margin: 0 auto;
  336. max-width: 650px;
  337. }
  338. .section__title h2 {
  339. color: #333;
  340. display: block;
  341. font-size: 30px;
  342. font-weight: 700;
  343. line-height: 30px;
  344. margin-bottom: 20px;
  345. position: relative;
  346. text-transform: uppercase;
  347. }
  348. .section__title h2 span {
  349. color: #0581d3;
  350. }
  351. .container-fluid.whithoutPadding {
  352. padding: 0px 0px !important;
  353. }
  354. /* transition flip */
  355. .flip-list-move {
  356. transition: transform 0.8s;
  357. }
  358. .list-item {
  359. display: inline-block;
  360. margin-bottom: 10px;
  361. }
  362. </style>