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

250 lines
8.3 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"},
2018-01-19 15:42:00 -06:00
{},
{view: 'button', id: 'cmd_import_products', label: 'Importar',
type: 'iconButton', autowidth: true, icon: 'upload'},
2017-10-02 23:51:00 -05:00
]
2017-06-27 15:43:02 -05:00
var grid_products_cols = [
2017-12-06 00:24:13 -06:00
{ id: "id", header: "ID", width: 75, hidden: true},
2018-01-17 23:40:19 -06:00
{ id: 'es_activo', header: 'Activo', hidden: true},
2018-01-13 18:39:22 -06:00
{ id: "clave_sat", header: ["Clave SAT"], width: 100,},
2017-10-04 00:11:49 -05:00
{ id: "clave", header: ["Clave", {content: "textFilter"}], width: 100,
2017-12-20 01:15:48 -06:00
sort: 'string', footer: {content: 'countRows', css: 'right'}},
2017-10-04 00:11:49 -05:00
{ id: "descripcion", header: ["Descripción", {content: "textFilter"}],
2017-11-16 01:17:22 -06:00
fillspace:true, sort: 'string', footer: 'Productos y Servicios'},
2017-10-02 23:51:00 -05:00
{ 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 = {
2018-01-17 23:40:19 -06:00
view: 'datatable',
id: 'grid_products',
select: 'row',
2017-06-27 15:43:02 -05:00
adjust: true,
footer: true,
resizeColumn: true,
headermenu: true,
columns: grid_products_cols,
2018-01-17 23:40:19 -06:00
scheme:{
$change:function(item){
if(!item.es_activo){
item.$css = 'cancel'
}
}
},
2017-10-02 23:51:00 -05:00
}
2017-06-27 15:43:02 -05:00
2017-11-15 19:29:51 -06:00
2017-10-04 00:11:49 -05:00
var suggest_categories = {
2017-11-14 20:38:20 -06:00
view: 'datasuggest',
type: 'tree',
2017-10-04 00:11:49 -05:00
width: 400,
2017-11-14 20:38:20 -06:00
body: {data: []},
2017-10-04 00:11:49 -05:00
}
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-11-14 20:38:20 -06:00
var suggest_sat_producto = {
view: 'gridsuggest',
id: 'grid_producto_found',
name: 'grid_producto_found',
body: {
autoConfig: false,
scroll: true,
autoheight: false,
header: true,
yCount: 10,
columns: [
{id: 'id', hidden: true},
{id: 'key', adjust: 'data', header: 'Clave SAT'},
{id: 'name', header: 'Producto', width: 750},
],
dataFeed:function(text){
if (text.length > 3){
this.load('/values/satproductos?key=' + text)
}else{
this.hide()
}
}
2017-11-15 19:29:51 -06:00
},
2017-11-14 20:38:20 -06: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',
2017-11-15 19:29:51 -06:00
labelPosition: 'top', suggest: 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',
2017-11-14 20:38:20 -06:00
labelPosition: 'top', required: true, suggest: suggest_sat_producto,
placeholder: 'Al menos 4 caracteres...'},
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",
2018-01-26 13:46:16 -06:00
invalidMessage: "La Descripción es requerida",
placeholder: 'El SAT solo permite 1000 caracteres en este campo'},
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'}
]},
2017-12-23 23:54:47 -06:00
{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"},
{view: 'currency', type: 'text', id: 'precio_con_impuestos',
name: 'precio_con_impuestos', label: 'Con Impuestos', width: 300,
labelWidth: 115, labelAlign: 'right', required: false,
invalidMessage: 'Captura un valor númerico', inputAlign: 'right'},
{},]},
2017-10-04 00:11:49 -05:00
{cols: [
2018-01-05 13:33:43 -06:00
{view: 'checkbox', id: 'chk_inventario', name: 'inventario', hidden: true,
2017-10-02 23:51:00 -05:00
label: 'Inventario', labelAlign: 'right', labelWidth: 130},
2018-01-05 13:33:43 -06:00
{view: 'counter', id: 'txt_existencia', name: 'existencia',
hidden: true, label: 'Existencia', step: 5, value: 0, min: 0,
disabled: true},
{view: 'counter', id: 'txt_minimo', name: 'minimo', hidden: true,
2017-10-02 23:51:00 -05:00
label: 'Mínimo', step: 5, value: 0, min: 0, disabled: true},
2018-01-08 13:57:15 -06:00
{},]},
2017-10-04 00:11:49 -05:00
{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",
2017-11-15 19:33:41 -06:00
scroll: true,
2017-06-27 15:43:02 -05:00
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,
]},
2017-11-15 19:33:41 -06:00
{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 = {
2018-01-27 02:45:45 -06:00
id: 'app_products',
2017-06-27 15:43:02 -05:00
rows:[
2018-01-27 02:45:45 -06:00
{view: 'template', id: 'th_products', type: 'header',
template: 'Administración de Productos y Servicios'},
2017-06-27 15:43:02 -05:00
multi_products
2017-10-02 23:51:00 -05:00
],
}
2017-06-27 15:43:02 -05:00
2018-01-19 15:42:00 -06:00
var body_import_products = {rows: [
{view: 'form', id: 'form_upload_products', rows: [
{cols: [{},
{view: 'uploader', id: 'up_products', autosend: false,
link: 'lst_upload_products', value: 'Seleccionar Archivo',
upload: '/files/products'}, {}]},
{cols: [
{view: 'list', id: 'lst_upload_products', name: 'lst_upload_products',
type: 'uploader', autoheight: true, borderless: true}]},
{cols: [{}, {view: 'button', id: 'cmd_upload_products',
label: 'Importar Productos'}, {}]},
]},
]}
var win_import_products = {
init: function(){
webix.ui({
view: 'window',
id: 'win_import_products',
width: 400,
modal: true,
position: 'center',
head: 'Importar Productos',
body: body_import_products,
})
$$('cmd_upload_products').attachEvent('onItemClick', cmd_upload_products_click)
$$('up_products').attachEvent('onUploadComplete', up_products_upload_complete)
}
}