create client

combobox comerciales
put client
This commit is contained in:
nelo 2016-12-15 16:55:11 +01:00
parent 440e9705d2
commit 6eca92afcc
18 changed files with 217 additions and 93 deletions

View File

@ -1,6 +1,6 @@
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="search"></vn-textfield> <vn-textfield vn-one label="search"></vn-textfield>
<i class="material-icons" id="down_menu">keyboard_arrow_down</i> <i class="material-icons">keyboard_arrow_down</i>
<vn-icon-button icon="search"></vn-icon-button> <vn-icon-button icon="search" margin-small-top></vn-icon-button>
</vn-horizontal> </vn-horizontal>

View File

@ -1,3 +1,3 @@
<button type="*[typeName]*" class="mdl-button mdl-js-button mdl-button--icon *[className]*"> <button type="*[typeName]*" class="mdl-button mdl-js-button mdl-button--raised *[className]*">
<i class="material-icons">*[icon]*</i> <i class="material-icons">*[icon]*</i>*[label]*
</button> </button>

View File

@ -9,6 +9,7 @@ export function factory() {
enabled: 'true', enabled: 'true',
typeName: 'button', typeName: 'button',
icon: '', icon: '',
label: '',
} }
} }
} }

View File

@ -7,6 +7,16 @@
font-weight: bolder; font-weight: bolder;
color: white; color: white;
} }
.mdl-button--icon {
background-color: #ff9400;
font-weight: bolder;
color: white;
}
.mdl-button--icon:hover {
background-color: #ffa410;
}
.mdl-button--raised:hover { .mdl-button--raised:hover {
background-color: #ffa410; background-color: #ffa410;
} }

View File

@ -1,23 +1,21 @@
<form ng-submit="basicData.submit()" pad-large> <form ng-submit="basicData.submit()" pad-large>
<vn-title>Datos básicos</vn-title> <vn-title>Datos básicos</vn-title>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Nombre" name="name" entity="client"></vn-textfield> <vn-textfield vn-one label="Nombre" model="basicData.client.name" entity="basicData"></vn-textfield>
<vn-textfield vn-one label="NIF/CIF" name="fi" entity="client"></vn-textfield> <vn-textfield vn-one label="NIF/CIF" model="basicData.client.fi" entity="basicData"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield autofocus vn-one label="Razón social" field="socialName" entity="client"></vn-textfield> <vn-textfield autofocus vn-one label="Razón social" model="basicData.client.socialName" entity="basicData"></vn-textfield>
<vn-date-picker vn-one label="Fecha alta" field="dischargeDate" entity="client"></vn-date-picker> <vn-date-picker vn-one label="Fecha alta" model="basicData.client.dischargeDate" entity="basicData"></vn-date-picker>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<!--<vn-textfield vn-one label="Contacto" name="contact" model="basicData.client"></vn-textfield>--> <vn-textfield vn-one label="Teléfono" model="basicData.client.telefono" entity="basicData"></vn-textfield>
<vn-textfield vn-one label="Teléfono" name="telefono" entity="client"></vn-textfield> <vn-textfield vn-one label="Fax" model="basicData.client.fax" entity="basicData"></vn-textfield>
<vn-textfield vn-one label="Fax" name="fax" entity="client"></vn-textfield> <vn-textfield vn-one label="Email" fiemodelld="basicData.client.email" entity="basicData"></vn-textfield>
<vn-textfield vn-one label="Email" name="email" entity="client"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-combo vn-one label="Comercial" name="salesPerson" entity="client"> <vn-combo vn-one label="Comercial" model="basicData.client.salesPerson" entity="basicData">
<option value="1">Comercial 1</option> <option ng-repeat="p in basicData.sales" value="{{p.id}}">{{p.name}}</ng-repeat>
<option value="2">Comercial 2</option>
</vn-combo> </vn-combo>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>

View File

@ -9,14 +9,20 @@ export const COMPONENT = {
client: '<' client: '<'
}, },
controller: function($http) { controller: function($http) {
$http.get('/client/api/SalesPeople').then(
json => {
this.sales = json.data;
console.log(this.sales);
},
json => console.error(json.data.error.message)
);
this.submit = function() { this.submit = function() {
$http.post('/client/api/Clients', this.model).then( $http.put('/client/api/Clients', this.client).then(
json => console.log(json.statusText), json => console.log(json.statusText),
json => console.error(json.data.error.message) json => console.error(json.data.error.message)
); );
}; };
}, }
controllerAs: 'client'
}; };
COMPONENT.controller.$inject = ['$http']; COMPONENT.controller.$inject = ['$http'];
module.component(NAME, COMPONENT); module.component(NAME, COMPONENT);

View File

@ -18,3 +18,5 @@ export {NAME as CLIENT_SEARCH_PANEL,
COMPONENT as CLIENT_SEARCH_PANEL_COMPONENT} from './search-panel/search-panel'; COMPONENT as CLIENT_SEARCH_PANEL_COMPONENT} from './search-panel/search-panel';
export {NAME as CLIENT_ITEM, export {NAME as CLIENT_ITEM,
COMPONENT as CLIENT_ITEM_COMPONENT} from './index/item-client'; COMPONENT as CLIENT_ITEM_COMPONENT} from './index/item-client';
export {NAME as CLIENT_CREATE,
COMPONENT as CLIENT_CREATE_COMPONENT} from './create/index';

View File

@ -0,0 +1,16 @@
<form ng-submit="create.submit()" pad-large>
<vn-title>Crear Cliente</vn-title>
<vn-horizontal>
<vn-textfield vn-one label="Nombre" field="name" entity="create"></vn-textfield>
<vn-textfield vn-one label="NIF/CIF" field="fi" entity="create"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield autofocus vn-one label="Razón social" field="socialName" entity="create"></vn-textfield>
<vn-one></vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one>
<vn-submit label="Crear" id="create"></vn-submit>
</vn-one>
</vn-horizontal>
</form>

View File

@ -0,0 +1,18 @@
import template from './index.html';
import {module} from '../../module';
export const NAME = "vnClientCreate";
export const COMPONENT = {
template: template,
controllerAs: "create",
controller: function($http, $state){
this.submit = function(){
$http.post('/client/api/Clients', this.model).then(
json => $state.go('clientCard.basicData',{id: json.data.id}),
json => console.error(json.data.error.message)
);
};
}
};
COMPONENT.controller.$inject = ["$http", "$state"];
module.component(NAME, COMPONENT);

View File

@ -1,9 +1,15 @@
<vn-vertical class="full-height"> <vn-vertical class="full-height">
<vn-topbar></vn-topbar> <vn-topbar></vn-topbar>
<form ng-submit="search.submit()" pad-large>
<vn-horizontal> <vn-horizontal>
<vn-four></vn-four> <vn-four></vn-four>
<vn-searchbar vn-four id="searchbar"></vn-searchbar> <vn-searchbar vn-four></vn-searchbar>
<vn-search-panel ></vn-search-panel> <vn-four></vn-four>
</vn-horizontal>
<vn-horizontal>
<vn-four></vn-four>
<a vn-two ui-sref="create"><vn-button label="Create client"></vn-button></a>
<vn-submit vn-two label="Buscar"></vn-submit>
<vn-four></vn-four> <vn-four></vn-four>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
@ -13,4 +19,5 @@
</vn-vertical> </vn-vertical>
<vn-three></vn-three> <vn-three></vn-three>
</vn-horizontal> </vn-horizontal>
</form>
</vn-vertical> </vn-vertical>

View File

@ -15,12 +15,13 @@ export const COMPONENT = {
json => console.error(json.data.error.message) json => console.error(json.data.error.message)
); );
this.submit = function() { this.submit = function() {
var query = {where: this.model, fields: {id: true}}; var query = {where: model};
var self = this;
$http.get(`/client/api/Clients/findOne?filter=${JSON.stringify(query)}`).then( $http.get(`/client/api/Clients/findOne?filter=${JSON.stringify(query)}`).then(
function(response) { function(response) {
console.log(response); self.clients = [];
self.clients.push(response.data);
}, },
function(response) { function(response) {
console.log(response); console.log(response);

View File

@ -6,7 +6,7 @@
<div>{{itemClient.client.phone}}, {{itemClient.client.contact}}</div> <div>{{itemClient.client.phone}}, {{itemClient.client.contact}}</div>
</vn-auto> </vn-auto>
<vn-empty> <vn-empty>
<a ui-sref="clientCard.basicData({ id: {{itemClient.client.id}} })"><vn-icon-button icon="edit"></vn-icon-button></a> <a ui-sref="clientCard.basicData({ id: {{itemClient.client.id}} })"><i class="material-icons">edit</i></a>
</vn-empty> </vn-empty>
</vn-horizontal> </vn-horizontal>
</vn-auto> </vn-auto>

View File

@ -1,14 +1,17 @@
{ {
module: "crud", module: "crud",
routes: [{ routes: [
{
url: "/clients", url: "/clients",
state: "clients", state: "clients",
component: "vn-client-index" component: "vn-client-index"
},{ },
{
url: "/clients/:id", url: "/clients/:id",
state: "clientCard", state: "clientCard",
component: "vn-client-card" component: "vn-client-card"
},{ },
{
url: "/basic-data", url: "/basic-data",
state: "clientCard.basicData", state: "clientCard.basicData",
component: "vn-client-basic-data", component: "vn-client-basic-data",
@ -17,29 +20,39 @@
}, },
description: "Datos básicos", description: "Datos básicos",
icon: "person" icon: "person"
},{ }
,{
url: "/fiscal-data", url: "/fiscal-data",
state: "clientCard.fiscalData", state: "clientCard.fiscalData",
component: "vn-client-fiscal-data", component: "vn-client-fiscal-data",
description: "Datos facturación", description: "Datos facturación",
icon: "assignment" icon: "assignment"
},{ },
{
url: "/addresses", url: "/addresses",
state: "clientCard.addresses", state: "clientCard.addresses",
component: "vn-client-addresses", component: "vn-client-addresses",
description: "Consignatarios", description: "Consignatarios",
icon: "local_shipping" icon: "local_shipping"
},{ },
{
url: "/web-access", url: "/web-access",
state: "clientCard.webAccess", state: "clientCard.webAccess",
component: "vn-client-web-access", component: "vn-client-web-access",
description: "Acceso web", description: "Acceso web",
icon: "language" icon: "language"
},{ },
{
url: "/notes", url: "/notes",
state: "clientCard.notes", state: "clientCard.notes",
component: "vn-client-notes", component: "vn-client-notes",
description: "Notas", description: "Notas",
icon: "insert_drive_file" icon: "insert_drive_file"
}] },
{
url: "/create",
state: "create",
component: "vn-client-create",
}
]
} }

18
db.json
View File

@ -2,7 +2,9 @@
"ids": { "ids": {
"User": 2, "User": 2,
"AccessToken": 2, "AccessToken": 2,
"Client": 3 "Client": 15,
"PaymentMethod": 4,
"SalesPerson": 4
}, },
"models": { "models": {
"User": { "User": {
@ -12,8 +14,18 @@
"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue": "{\"id\":\"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue\",\"ttl\":1209600,\"created\":\"2016-11-21T11:06:11.113Z\",\"userId\":1}" "NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue": "{\"id\":\"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue\",\"ttl\":1209600,\"created\":\"2016-11-21T11:06:11.113Z\",\"userId\":1}"
}, },
"Client": { "Client": {
"1": "{\"name\":\"Cliente1 SL\",\"salesPerson\":1,\"fi\":\"123456789\",\"registerDate\":\"29/11/2016\",\"contact\":\"a@a.com\",\"phone\":\"123456789\",\"quality\":\"1\",\"id\":1}", "12": "{\"name\":\"Cliente 2\",\"id\":12,\"fi\":\"1111111111\",\"salesPerson\":\"2\"}",
"2": "{\"name\":\"Cliente2 SL\",\"salesPerson\":1,\"fi\":\"123456788\",\"contact\":\"b@b.com\",\"phone\":\"222222222\",\"quality\":\"1\",\"id\":2}" "14": "{\"name\":\"cliente 1\",\"id\":14}"
},
"PaymentMethod": {
"1": "{\"name\":\"Tarjeta\",\"id\":1}",
"2": "{\"name\":\"Giro Bancario\",\"id\":2}",
"3": "{\"name\":\"Transferencia\",\"id\":3}"
},
"SalesPerson": {
"1": "{\"id\":1,\"name\":\"Jesus Brocal\"}",
"2": "{\"name\":\"Juan Carlos Lorenzo\",\"id\":2}",
"3": "{\"name\":\"Carlos Zambrano\",\"id\":3}"
} }
} }
} }

View File

@ -35,9 +35,7 @@
}, },
"active": { "active": {
"type": "boolean" "type": "boolean"
} },
/*
"credit": { "credit": {
"type": "Number" "type": "Number"
}, },
@ -61,14 +59,18 @@
"invoiceByEmail": { "invoiceByEmail": {
"type": "boolean", "type": "boolean",
"description": "Send invoices by email" "description": "Send invoices by email"
} },
"relations": {
"salesPerson": { "salesPerson": {
"type": "Number", "type": "belongsTo",
"required": "true" "model": "SalesPerson",
},*/ "foreignKey": "salePersonId"
},
"paymentMethod":{
"type": "belongsTo",
"model": "PaymentMethod",
"foreingKey": "payId"
}
}
} }
} }

View File

@ -0,0 +1,15 @@
{
"name": "PaymentMethod",
"base": "PersistedModel",
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string",
"required": "true"
}
}
}

View File

@ -0,0 +1,15 @@
{
"name": "SalesPerson",
"base": "PersistedModel",
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string",
"required": "true"
}
}
}

View File

@ -36,6 +36,14 @@
"dataSource": "db", "dataSource": "db",
"public": true "public": true
}, },
"PaymentMethod": {
"dataSource": "db",
"public": true
},
"SalesPerson": {
"dataSource": "db",
"public": true
},
"Address": { "Address": {
"dataSource": "db", "dataSource": "db",
"public": true "public": true