empresa-libre/source/static/js/ui/products.js

172 lines
5.6 KiB
JavaScript
Raw Normal View History

2017-06-27 15:43:02 -05:00
var toolbar_products = [
{view: "button", id: "cmd_new_product", label: "Nuevo", type: "iconButton",
autowidth: true, icon: "plus"},
{view: "button", id: "cmd_edit_product", label: "Editar", type: "iconButton",
autowidth: true, icon: "pencil"},
2017-10-02 23:51:00 -05:00
{view: "button", id: "cmd_delete_product", label: "Eliminar",
type: "iconButton", autowidth: true, icon: "minus"},
]
2017-06-27 15:43:02 -05:00
var grid_products_cols = [
2017-10-02 23:51:00 -05:00
{ id: "id", header: "ID", width: 75},
2017-10-04 00:11:49 -05:00
{ id: "clave", header: ["Clave", {content: "textFilter"}], width: 100,
2017-10-02 23:51:00 -05:00
sort:"string" },
2017-10-04 00:11:49 -05:00
{ id: "descripcion", header: ["Descripción", {content: "textFilter"}],
2017-10-02 23:51:00 -05:00
fillspace:true, sort:"string" },
{ id: "unidad", header: ["Unidad", {content: "selectFilter"}], width: 150,
sort:"string" },
2017-10-04 00:11:49 -05:00
{ id: "valor_unitario", header: ["Precio", {content: "numberFilter"}], width: 150,
sort:"int", format: webix.i18n.priceFormat, css: "right" },
2017-10-02 23:51:00 -05:00
]
2017-06-27 15:43:02 -05:00
var grid_products = {
view: "datatable",
id: "grid_products",
select: "row",
adjust: true,
footer: true,
resizeColumn: true,
headermenu: true,
columns: grid_products_cols,
2017-10-02 23:51:00 -05:00
}
2017-06-27 15:43:02 -05:00
2017-10-04 00:11:49 -05:00
var suggest_categories = {
view: "datasuggest",
type: "tree",
width: 400,
body: { data: [] },
}
var grid_product_taxes_cols = [
{id:"id", header:"ID", hidden: true},
{id:"name", header:'Nombre'},
{id:"tipo", header:'Tipo'},
{id:"tasa", header:'Tasa'},
]
var grid_product_taxes = {
view: 'datatable',
id: 'grid_product_taxes',
select: 'row',
multiselect: true,
adjust: true,
autoheight: true,
autowidth: true,
headermenu: true,
columns: grid_product_taxes_cols,
}
2017-06-27 15:43:02 -05:00
2017-10-02 23:51:00 -05:00
2017-06-27 15:43:02 -05:00
var controls_generals = [
2017-10-02 23:51:00 -05:00
{view: 'checkbox', id: 'es_activo_producto', name: 'es_activo_producto',
label: 'Activo: ', value: true,
bottomLabel: 'Se recomienda solo desactivar y no eliminar'},
{cols: [
2017-10-04 00:11:49 -05:00
{view: 'combo', id: 'categoria', name: 'categoria', label: 'Categoría',
labelPosition: 'top', options: suggest_categories},
2017-10-02 23:51:00 -05:00
{view: 'text', id: 'clave', name: 'clave', label: 'Clave',
labelPosition: 'top', readonly: true, required: true},
2017-10-04 00:11:49 -05:00
{view: 'checkbox', id: 'chk_automatica', label: 'Automática',
labelPosition: 'top', value: true, maxWidth: 80},
{view: 'search', id: 'clave_sat', name: 'clave_sat', label: 'Clave SAT',
labelPosition: 'top', required: true, placeholder: 'Buscar clave...'},
2017-10-02 23:51:00 -05:00
]},
2017-10-04 00:11:49 -05:00
{cols: [
{view: 'text', id: 'codigo_barras', name: 'codigo_barras',
label: 'Código de Barras', labelPosition: 'top', hidden: true},
{view: 'text', id: 'cuenta_predial', name: 'cuenta_predial',
label: 'Cuenta Predial', labelPosition: 'top', hidden: true},
{id: 'txt_col1'}]},
{view: "textarea", id: "descripcion", name: "descripcion", height: 200,
2017-10-02 23:51:00 -05:00
label: "Descripción", required: true, labelPosition: "top",
invalidMessage: "La Descripción es requerida" },
2017-10-04 00:11:49 -05:00
{minHeight: 5},
2017-10-02 23:51:00 -05:00
{cols: [
2017-10-04 00:11:49 -05:00
{view: "richselect", id: "unidad", name: "unidad", label: "Unidad",
width: 300, labelWidth: 130, labelAlign: "right", required: true,
invalidMessage: "La Unidad es requerida", options: []},
{view: 'text', id: 'tags_producto', name: 'tags_producto',
labelAlign: 'right', label: 'Etiquetas',
placeholder: 'Separadas por comas'}
]},
{cols: [{view: "currency", type: "text", id: "valor_unitario",
name: "valor_unitario", label: "Valor Unitario", width: 300,
labelWidth: 130, labelAlign: "right", required: true,
invalidMessage: "Captura un valor númerico", inputAlign: "right" },{}]},
{cols: [
{view: 'checkbox', id: 'inventario', name: 'inventario', hidden: true,
2017-10-02 23:51:00 -05:00
label: 'Inventario', labelAlign: 'right', labelWidth: 130},
2017-10-04 00:11:49 -05:00
{view: 'counter', id: 'existencia', name: 'existencia', hidden: true,
2017-10-02 23:51:00 -05:00
label: 'Existencia', step: 5, value: 0, min: 0, disabled: true},
2017-10-04 00:11:49 -05:00
{view: 'counter', id: 'minimo', name: 'minimo', hidden: true,
2017-10-02 23:51:00 -05:00
label: 'Mínimo', step: 5, value: 0, min: 0, disabled: true},
2017-10-04 00:11:49 -05:00
{id: 'txt_col2'}]},
{cols:[{view:'label', label:'Impuestos', width: 300, align:'center'}, {}]},
{cols:[grid_product_taxes, {}]}
2017-06-27 15:43:02 -05:00
]
var controls_products = [
{
view: "tabview",
2017-10-02 23:51:00 -05:00
tabbar: { options: ["Datos"]}, animate: true,
2017-06-27 15:43:02 -05:00
cells: [
2017-10-02 23:51:00 -05:00
{id: "Datos", rows: controls_generals},
2017-10-04 00:11:49 -05:00
],
2017-06-27 15:43:02 -05:00
},
{rows: [
{ template:"", type: "section" },
{ margin: 10, cols: [{},
{view: "button", id: "cmd_save_product", label: "Guardar" , type: "form", autowidth: true, align:"center"},
{view: "button", id: "cmd_cancel_product", label: "Cancelar" , type: "danger", autowidth: true, align:"center"},
{}]
},
]}
2017-10-02 23:51:00 -05:00
]
2017-06-27 15:43:02 -05:00
var form_product = {
type: "space",
cols: [{
view: "form",
id: "form_product",
//~ width: 600,
complexData: true,
elements: controls_products,
rules: {
2017-10-04 00:11:49 -05:00
descripcion: function(value){ return value.trim() != ""; },
valor_unitario: function(value){ return value.trim() != "$"; },
2017-06-27 15:43:02 -05:00
}
2017-10-02 23:51:00 -05:00
}],
}
2017-06-27 15:43:02 -05:00
var multi_products = {
id: "multi_products",
animate: true,
cells:[
{id: "products_home", rows:[
{view:"toolbar", elements: toolbar_products},
grid_products,
]},
{id: "product_new", rows:[form_product, {}]}
2017-10-02 23:51:00 -05:00
],
}
2017-06-27 15:43:02 -05:00
var app_products = {
id: "app_products",
rows:[
{view: "template", id: "th_products", type: "header", template:"Administración de Productos" },
multi_products
2017-10-02 23:51:00 -05:00
],
}
2017-06-27 15:43:02 -05:00