Created
November 6, 2016 17:30
-
-
Save cpereiraweb/43e07bc1e48dc2616199c3d177ab0753 to your computer and use it in GitHub Desktop.
Erro ao tentar utilizar o VeeValidate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** SnClients **/ | |
<script> | |
import SnClientsTable from './table.vue' | |
import SnClientForm from './form.vue' | |
import moment from 'moment' | |
import bus from '../utils/events/bus' | |
export default { | |
props: ['lista', 'token', 'success'], | |
computed: { | |
}, | |
components: { | |
SnClientsTable, | |
SnClientForm | |
}, | |
methods: { | |
}, | |
data() { | |
return { | |
} | |
} | |
} | |
</script> | |
<template> | |
<div> | |
<sn-clients-table :lista="lista"></sn-clients-table> | |
<sn-client-form :token="token"></sn-client-form> | |
</div> | |
</template> | |
<style> | |
.red { | |
color: red; | |
} | |
.green { | |
color: green; | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
import bus from '../utils/events/bus' | |
export default { | |
props: ['token'], | |
data () { | |
return { | |
isEditing: false, | |
cliente: { | |
id: 0, | |
nome: '', | |
contato: '', | |
telefone: '', | |
observacoes: '', | |
ativo: true | |
}, | |
} | |
}, | |
computed: { | |
action () { | |
if (this.isEditing) { | |
return `/clientes/edit/${this.cliente.id}` | |
} else { | |
return `/clientes/create` | |
} | |
}, | |
}, | |
mounted () { | |
const modal = jQuery(this.$refs.modal) | |
bus.$on('open-form', (obj) => { | |
if (obj !== undefined) { | |
this.cliente = obj.cliente | |
this.isEditing = true | |
} | |
modal.modal('show') | |
}) | |
modal.on('hidden.bs.modal', () => { | |
this.cliente.id = 0 | |
this.cliente.nome = '' | |
this.cliente.contato = '' | |
this.cliente.telefone = '' | |
this.cliente.observacoes = '' | |
this.cliente.ativo = true | |
}) | |
}, | |
} | |
</script> | |
<template> | |
<div class="box box-primary"> | |
<div ref="modal" class="modal fade" tabindex="-1" role="dialog"> | |
<div class="modal-dialog" role="document"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
<h4 class="modal-title">Criar novo cliente</h4> | |
</div> | |
<div class="modal-body"> | |
<form method="post" :action="action"> | |
<input type="hidden" name="_token" :value="token"> | |
<div class="form-group"> | |
<label for="nome" class="control-label">Nome</label> | |
<input | |
v-validate data-rules="required|min:{5}" | |
:class="{'form-control': true, 'is-danger': errors.has('nome') }" | |
id="nome" name="nome" type="text" | |
v-model="cliente.nome"> | |
<span v-show="errors.has('nome')" class="help is-danger">{{ errors.first('nome') }}</span> | |
</div> | |
<div class="form-group"> | |
<label for="contato" class="control-label">Contato</label> | |
<input id="contato" name="contato" type="text" class="form-control" v-model="cliente.contato"> | |
</div> | |
<div class="form-group"> | |
<label for="telefone" class="control-label">Telefone</label> | |
<input id="telefone" name="telefone" type="text" class="form-control" v-model="cliente.telefone"> | |
</div> | |
<div class="form-group"> | |
<label for="observacoes" class="control-label">Observações</label> | |
<textarea rows="4" cols="50" id="observacoes" name="observacoes" class="form-control" v-model="cliente.observacoes"></textarea> | |
</div> | |
<button type="submit" class="btn btn-primary">Salvar</button> | |
</form> | |
</div> | |
</div><!-- /.modal-content --> | |
</div><!-- /.modal-dialog --> | |
</div><!-- /.modal --> | |
</div> | |
</template> | |
<style> | |
body{ | |
background-color:#ff0000; | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by claudio on 02/11/16. | |
*/ | |
window.jQuery = window.$ | |
import Vue from 'vue' | |
import VueResource from 'vue-resource' | |
import VeeValidate from 'vee-validate' | |
import SnClients from './app/clients/index.vue' | |
Vue.use(VueResource) | |
Vue.use(VeeValidate) | |
new Vue({ | |
el: '#app', | |
components: { | |
SnClients | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment