Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="es">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.0/css/bulma.min.css">

  <!-- Default theme -->
  <link rel="stylesheet" href="css/style.css">
  <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
  <title>Almacen</title>
</head>

<body>
  <section class="hero is-dark">
    <div class="hero-body">
      <div class="container">
        <h1 class="title">
          Practica con Vue
        </h1>
        <h2 class="subtitle">
          Almacen de Prodcutos Electronica
        </h2>
      </div>
    </div>
  </section>
  <div id="app">
    <div class="box">
      <div class="columns">
        <div class="column">
          <h4 class="title is-4">Cear Prodcutos</h4>
          <div class="content">
            <div class="field">
              <label class="label">Nombre Del Producto</label>
              <div class="control">
                <input autocomplete="off" class="input" type="text" id="nombre" placeholder="Nombre Del Producto" v-model="producto.nombre">
              </div>
            </div>
            <div class="field">
              <label class="label">Código Del Producto</label>
              <div class="control">
                <input autocomplete="off" class="input" type="text" placeholder="Código Del Producto" v-model="producto.codigo">
              </div>
            </div>
            <div class="field">
              <label class="label">Precio Del Producto</label>
              <div class="control">
                <input autocomplete="off" class="input numeros" type="text" placeholder="Precio Del Producto" v-model="producto.precio">
              </div>
            </div>
            <div class="field">
              <label class="label">Stock Del Producto</label>
              <div class="control">
                <input autocomplete="off" class="input" type="text" placeholder="Stock Del Producto" v-model="producto.stock" @keyup="VnumeroStock">
              </div>
            </div>
            <div class="field">
              <div class="control">
                <button class="button is-info" @click="addProducto">Agregar Al Almacen +
                </button>
              </div>
            </div>
          </div>
        </div>
        <div class="column">
          <h4 class="title is-4">Listado de Prodcutos</h4>&nbsp;<button style="left: 82%;" class="button is-danger" @click="eliminar2()" v-if="checkedlist.length!=0">Eliminar</button>
          <div class="content">
            <table class="table">
              <thead>
                <tr>
                  <th><input type="checkbox" name="chkeliminar" id="chkeliminar" @change="todos($event)"></th>
                  <th><abbr title="Position">Nombre</abbr></th>
                  <th>Codigo</th>
                  <th><abbr title="Played">Precio</abbr></th>
                  <th><abbr title="Won">Stock</abbr></th>
                  <th><abbr title="Won">Fecha</abbr></th>
                  <th><abbr title="Won">add</abbr></th>
                  <th><abbr title="Won">Acciones</abbr></th>
                </tr>
              </thead>
              <tfoot>
                <tr>
                  <th>Eliminar</th>
                  <th><abbr title="Position">Nombre</abbr></th>
                  <th>Codigo</th>
                  <th><abbr title="Played">Precio</abbr></th>
                  <th><abbr title="Won">Stock</abbr></th>
                  <th><abbr title="Won">Fecha</abbr></th>
                  <th><abbr title="Won">add</abbr></th>
                  <th><abbr title="Won">Acciones</abbr></th>
                </tr>
              </tfoot>
              <tbody>
                <tr v-for="(value, key, index) of lista" :key="key" :style="{ background: value.stock == 0 ? '#ff7a7a' : value.stock == 1 ? '#ffd77a' : value.stock <= 4 ? '#ffd77a' : 'white' }">
                  <td><input type="checkbox" :name="key" :id="key" class="checks" :value="value.codigo" v-model="checkedlist"></td>
                  <td>
                    <div v-if="value.ed"><input type="text" class="inputs" name="editar" id="editar" v-model="value.nombre"></div>
                    <div v-if="!value.ed">{{value.nombre}}-{{key}} </div>
                  </td>
                  <td>
                    <div v-if="value.ed"><input type="text" class="inputs" name="editar" id="editar" v-model="value.codigo"></div>
                    <div v-if="!value.ed">{{value.codigo}}-{{key}} </div>
                  </td>
                  <td>
                    <div v-if="value.ed"><input type="text" class="inputs" name="editar" id="editar" v-model="value.precio"></div>
                    <div v-if="!value.ed">{{value.precio}}-{{key}} </div>
                  </td>
                  <td><input type="text" name="stockVal" id="stockVal" v-model="value.stock" min="0" style="width: 49px;"></td>
                  <td><input type="text" class="fecha" style="width: 49px;"></td>
                  <td><button @click="value.stock++">+</button><button @click="value.stock--" :disabled="value.stock == 0">-</button></td>
                  <td><button class="button is-primary" @click="value.ed=!value.ed">Editar</button>&nbsp;<button class="button is-danger" @click="eliminar(key)">Eliminar</button></td>
                </tr>
              </tbody>
            </table>
          </div>
          <div class="columns">
            <div class="column">
              <div class="content">
                <div class="field">
                  <label class="label">Total + IVA</label>
                  <div class="control">
                    <input class="input is-primary" type="text" placeholder="Primary input" v-model="total">
                  </div>
                </div>
              </div>
            </div>
            <div class="column">

            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script src="js/app.js"></script>
  <script src="js/validaciones.js"></script>
</body>

</html>
              
            
!

CSS

              
                
.table tr.is-danger {
    background-color: #ff7a7a;
    color: #fff;
}
.table tr.is-info {
    background-color: #ffd77a;
    color: #000;
}
.inputs{
    width: 130px;
}
.ajs-button:hover{
    background-color:rgb(228, 255, 129) !important;
    cursor: pointer;
}
.ajs-button:active{
    background-color:rgb(255, 209, 108) !important;
}
              
            
!

JS

              
                const app = new Vue({
    el:"#app",
    data:{
        producto:{
            nombre:"",
            codigo:"",
            precio:0,
            stock:0,
            ed:false,
            info:false
        },
        lista:[],
        checkedlist:[],

    },
    methods:{
        addProducto (){
            let {nombre, codigo, precio, stock}=this.producto;
            if(nombre==""){
                alertify.alert('Lo Sentimos', 'El campo nombre del producto no puede estar vacio', function(){ document.getElementById("nombre").focus(); });
                return false;
            }
            if(codigo==""){
                alertify.alert('Lo Sentimos', 'El campo código del producto no puede estar vacio', function(){ document.getElementById("nombre").focus(); });
                return false;
            }
            this.lista.push({
                nombre:nombre,
                codigo:codigo,
                precio:precio,
                stock:stock,
                ed:this.producto.ed,
                info:this.producto.info
            })
            this.producto.nombre=""; this.producto.codigo=""; this.producto.precio=0; this.producto.stock=0;
            // jQuery(".fecha").datepicker('remove');
            jQuery('.fecha').each(function() {
                jQuery(this).datepicker({
                    changeMonth:true,
                    changeYear: true
                });
            });

        },
        VnumeroStock(){
            let stock = this.producto.stock.replace(/\D/g, '');
            this.producto.stock=stock;
        },
        eliminar(index){
            this.lista.splice(index, 1);
        },
        todos(e){
            if(e.target.checked){ 
                let elementos = document.getElementsByClassName("checks");
                for(let x=0; x<elementos.length; x++){
                    if(elementos[x].checked==false){
                        elementos[x].click();
                    }
                }
                console.log(this.checkedlist.length);
                
            }else{
                let elementos = document.getElementsByClassName("checks");
                for(let x=0; x<elementos.length; x++){
                    if(elementos[x].checked==true){
                        elementos[x].click();
                    }
                }
                console.log(this.checkedlist.length);
            }
        },
        eliminar2(){
            let elementos = document.getElementsByClassName("checks");
            for(let x=0; x<elementos.length; x++){
                if(elementos[x].checked==true){
                    let cod = elementos[x].value;
                    this.lista = this.lista.filter(function(dato){ if(dato.codigo==cod){return false;}else{return true;}})
                    this.checkedlist = [];
                }
            }
            let check = document.getElementById("chkeliminar");
            if(check.checked){check.click();}
        },

    },
    computed:{
        total(){
            let total=0.00;
            for(x in this.lista){
                total += (this.lista[x].precio * this.lista[x].stock);
            }
            return total;
        },
    },
})
jQuery(document).ready( ()=>{
    jQuery(".numeros").keyup(function() {
        let val = this.value;
        if (isNaN(val)) {
            val = val.replace(/[^0-9\.]/g, '');
            if (val.split('.').length > 2)
                val = val.replace(/\.+$/, "");
        }
        jQuery(this).val(val);
    });
    jQuery(".fecha").datepicker({
        changeMonth:true,
        changeYear: true
    });
    
    // jQuery('#icono').click(function() {
    //   jQuery("#fecha").focus();
    // });
})
              
            
!
999px

Console