Trabajadores
Nombre | Empresa | ||
---|---|---|---|
|
new Vue({ el: '#app', data: function(){ return { empresa: [], item_menu_temp: { nombre: '', email: '', empresa: '' }, menu: [], texto_busqueda: '' } }, created: function(){ this.getEmpresa(); }, methods: { getEmpresa: function(){ let that = this; google.script.run.withSuccessHandler(function(empresa){ that.empresa = empresa; }).getEmpresa(); }, addItemMenu: function(){ let that = this; google.script.run.withSuccessHandler(function(){ alert("El registro se ha guardado en el menú."); that.item_menu_temp.nombre = ""; that.item_menu_temp.email = ""; that.item_menu_temp.empresa = ""; }).addItemMenu(that.item_menu_temp); }, validarItemMenu: function(p_item){ return ( p_item.nombre.split(" ").join("") != "" && p_item.email.split(" ").join("") != "" && p_item.empresa.split(" ").join("") != "" ); }, getMenu: function(){ let that = this; that.menu = []; google.script.run.withSuccessHandler(function(menu){ that.menu = []; for(let i = 0; i < menu.length; i++) { that.menu.push({ ID: menu[i][0], nombre: menu[i][1], email: menu[i][2], empresa: menu[i][3] }); } }).getMenu(); }, getMenuFiltrado: function(){ let that = this; that.menu = []; google.script.run.withSuccessHandler(function(menu_filtrado){ that.menu = []; if(menu_filtrado.length > 0){ for(let i = 0; i < menu_filtrado.length; i++) { that.menu.push({ ID: menu_filtrado[i][0], nombre: menu_filtrado[i][1], email: menu_filtrado[i][2], empresa: menu_filtrado[i][3] }); } }else{ alert('La búsqueda no ha traído resultado'); } }).getMenuFiltrado(that.texto_busqueda); }, updateItemMenu: function(p_item){ google.script.run.withSuccessHandler(function(){ alert("El registro se ha guardado en el menú."); }).updateItemMenu(p_item); }, deleteItemMenu: function(p_item){ let that = this; if(confirm("Está segura/o que desea eliminar este ítem?")){ google.script.run.withSuccessHandler(function(){ alert("El registro se ha eliminado del menú."); that.getMenu(); }).deleteItemMenu(p_item); } } } });