Guest User

Untitled

a guest
Jul 8th, 2019
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.77 KB | None | 0 0
  1. vuetify.js?ce5b:6508
  2. Uncaught RangeError: Maximum call stack size exceeded.
  3. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  4. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  5. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  6. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  7. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  8. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  9. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  10. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  11. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  12. at VueComponent.onFocusin (vuetify.js?ce5b:6508)
  13.  
  14. <template>
  15. <div>
  16. <v-toolbar :color="tab == 0 ? 'red' : 'green'" dark tabs>
  17. <v-toolbar-title>Categorias</v-toolbar-title>
  18.  
  19. <v-spacer></v-spacer>
  20.  
  21. <v-btn icon>
  22. <v-icon>search</v-icon>
  23. </v-btn>
  24.  
  25. <v-btn icon>
  26. <v-icon>more_vert</v-icon>
  27. </v-btn>
  28.  
  29. <template v-slot:extension>
  30. <v-tabs v-model="tab" align-with-title :color="tab == 0 ? 'red' : 'green'">
  31. <v-tabs-slider color="white"></v-tabs-slider>
  32.  
  33. <v-tab v-for="item in items" :key="item">{{ item }}</v-tab>
  34. </v-tabs>
  35. </template>
  36. </v-toolbar>
  37.  
  38. <v-tabs-items v-model="tab">
  39. <v-tab-item v-for="item in items" :key="item">
  40. <v-card class="CardTable">
  41. <!-- <template> -->
  42. <!--<div>-->
  43. <v-toolbar flat id="TituloCategoria">
  44. <v-toolbar-title>Categorias ativas</v-toolbar-title>
  45. <!--<v-divider
  46. class="mx-2"
  47. inset
  48. vertical
  49. ></v-divider>-->
  50. <v-spacer></v-spacer>
  51. <v-dialog v-model="dialog" max-width="500px">
  52. <template v-slot:activator="{ on }">
  53. <!--<v-btn color="primary" dark class="mb-2" v-on="on">New Item</v-btn>-->
  54. </template>
  55. <v-card>
  56. <v-card-title>
  57. <span class="headline">{{ formTitle }}</span>
  58. </v-card-title>
  59.  
  60. <v-card-text>
  61. <v-container grid-list-md>
  62. <v-layout wrap>
  63. <v-flex xs12>
  64. <v-text-field v-model="Categoria.descricao" label="Nome"></v-text-field>
  65. </v-flex>
  66. <v-flex xs12>
  67. <span>Ícone</span>
  68. <v-spacer></v-spacer>
  69. <v-icon>{{ Categoria.icone }}</v-icon>
  70. </v-flex>
  71. <v-spacer></v-spacer>
  72.  
  73. <v-flex>
  74. <span>Cor</span>
  75. <v-layout row>
  76. <v-flex>
  77. <v-radio-group row>
  78. <v-radio label="vermelho" color="red" value="red"></v-radio>
  79. <v-radio label="azul" color="blue" value="blue"></v-radio>
  80. <v-radio label="laranja" color="orange" value="orange"></v-radio>
  81. <v-radio label="roxo" color="purple" value="purple"></v-radio>
  82. <v-radio label="verde" color="green" value="green"></v-radio>
  83. <v-radio label="preto" color="black" value="black"></v-radio>
  84. <v-radio label="cinza" color="grey" value="grey"></v-radio>
  85. <v-radio label="rosa" color="pink" value="pink"></v-radio>
  86. <v-radio label="indigo" color="indigo" value="indigo"></v-radio>
  87. <v-radio label="amarelo" color="yellow" value="yellow"></v-radio>
  88. </v-radio-group>
  89. </v-flex>
  90. </v-layout>
  91. </v-flex>
  92. </v-layout>
  93. </v-container>
  94. </v-card-text>
  95.  
  96. <v-card-actions>
  97. <v-spacer></v-spacer>
  98. <v-btn color="blue darken-1" flat @click="close">Cancelar</v-btn>
  99. <v-btn color="blue darken-1" flat @click="save">Salvar</v-btn>
  100. </v-card-actions>
  101. </v-card>
  102. </v-dialog>
  103. </v-toolbar>
  104. <v-data-table
  105. :headers="headers"
  106. :loading="loadingItemsExibidos"
  107. :items="itemsExibidos"
  108. item-key="id"
  109. hide-actions
  110. >
  111. <template v-slot:items="props">
  112. <td>{{ props.item.descricao }}</td>
  113.  
  114. <td class="text-xs-left">
  115. <v-icon>{{ props.item.icone }}</v-icon>
  116. </td>
  117. <td class="text-xs-left">
  118. <v-avatar size="20px" :color="props.item.cor"></v-avatar>
  119. </td>
  120. <td class="justify-right layout px-0">
  121. <v-btn flat small fab>
  122. <v-icon flat small @click="editItemCategoria(props.item)" class="mr-2">edit</v-icon>
  123. </v-btn>
  124. <v-btn flat small fab>
  125. <v-icon flat small @click="deleteCategoria(props.item)">delete</v-icon>
  126. </v-btn>
  127. </td>
  128. </template>
  129. </v-data-table>
  130. <!-- </div> -->
  131. <!-- </template> -->
  132. </v-card>
  133. </v-tab-item>
  134. </v-tabs-items>
  135.  
  136. <v-snackbar :timeout="2500" v-model="snackbar" :top="true" :right="true">
  137. <v-progress-circular indeterminate color="primary"></v-progress-circular>Aguarde um momento...
  138. </v-snackbar>
  139. <v-snackbar
  140. :timeout="2500"
  141. :color="'success'"
  142. v-model="snackbarOK"
  143. :top="true"
  144. :right="true"
  145. >{{messageResponse}}</v-snackbar>
  146. <v-snackbar
  147. :timeout="2500"
  148. :color="'error'"
  149. v-model="snackbarError"
  150. :top="true"
  151. :right="true"
  152. >{{errorResponse}}</v-snackbar>
  153. </div>
  154. </template>
  155.  
  156.  
  157. <script>
  158. import ClassCategoria from "../../class/categoria";
  159. export default {
  160. name: "Categorias",
  161. data: () => ({
  162. dialog: false,
  163. Categoria: undefined,
  164. tab: 0,
  165. messageResponse: "",
  166. errorResponse: "",
  167. snackbar: false,
  168. snackbarOK: false,
  169. snackbarError: false,
  170. items: ["DESPESAS", "RECEITAS"],
  171. headers: [
  172. {
  173. text: "Nome",
  174. align: "left",
  175. sortable: false,
  176. value: "descricao"
  177. },
  178. { text: "Ícone", value: "icone" },
  179. { text: "Cor", value: "cor" },
  180. { text: "Ações", value: "descricao", sortable: false }
  181. ],
  182. loadingItemsExibidos: false,
  183. itemsExibidos: [],
  184. editedIndex: -1,
  185. editedItem: {
  186. descricao: "",
  187. icone: "",
  188. cor: ""
  189. }
  190. }),
  191. computed: {
  192. formTitle() {
  193. return this.editedIndex === -1 ? "Nova categoria" : "Editar categoria";
  194. }
  195. },
  196. watch: {
  197. tab(val) {
  198. //console.log('tabs', val)
  199. if (val == 0) {
  200. this.getCategorias(0);
  201. } else {
  202. this.getCategorias(1);
  203. }
  204. }
  205. },
  206. created() {
  207. //this.initialize()
  208. this.Categoria = new ClassCategoria();
  209. },
  210. mounted() {
  211. this.getCategorias(0);
  212. },
  213. methods: {
  214. initialize() {
  215. this.itemsExibidos = [
  216. {
  217. name: "Aluguel",
  218. calories: 159,
  219. fat: 6.0,
  220. carbs: 24,
  221. protein: 4.0,
  222. icon: "home"
  223. },
  224. {
  225. name: "Transporte",
  226. calories: 237,
  227. fat: 9.0,
  228. carbs: 37,
  229. protein: 4.3,
  230. icon: "directions_car"
  231. },
  232. {
  233. name: "Gasolina",
  234. calories: 262,
  235. fat: 16.0,
  236. carbs: 23,
  237. protein: 6.0,
  238. icon: "local_gas_station"
  239. },
  240. {
  241. name: "Alimentação",
  242. calories: 305,
  243. fat: 3.7,
  244. carbs: 67,
  245. protein: 4.3,
  246. icon: "restaurant"
  247. },
  248. {
  249. name: "Pagamentos",
  250. calories: 356,
  251. fat: 16.0,
  252. carbs: 49,
  253. protein: 3.9,
  254. icon: "payment"
  255. }
  256. ];
  257. },
  258. async getCategorias(tipo) {
  259. this.itemsExibidos = [];
  260. await this.Categoria.getByTipo(tipo).then(result => {
  261. //console.log(result);
  262. this.itemsExibidos = result;
  263. });
  264. },
  265. editItemCategoria(item) {
  266. console.log(item);
  267. this.editedIndex = this.itemsExibidos.indexOf(item);
  268. this.Categoria = Object.assign(new ClassCategoria(), item);
  269. this.dialog = true;
  270. },
  271. async deleteCategoria(item) {
  272. const index = this.itemsExibidos.indexOf(item);
  273. confirm("Tem certeza que deseja excluir essa categoria?") &&
  274. this.itemsExibidos.splice(index, 1);
  275. },
  276. close() {
  277. this.dialog = false;
  278. setTimeout(() => {
  279. this.editedItem = Object.assign({}, this.defaultItem);
  280. this.editedIndex = -1;
  281. }, 300);
  282. },
  283. save() {
  284. this.snackbar = true;
  285. this.Categoria.save().then(
  286. result => {
  287. this.snackbar = false;
  288. this.snackbarOK = true;
  289. this.messageResponse = result;
  290. this.close();
  291. },
  292. erro => {
  293. this.snackbar = false;
  294. this.snackbarError = true;
  295. this.errorResponse = result;
  296. this.close();
  297. }
  298. );
  299. }
  300. }
  301. };
  302. </script>
  303.  
  304. <style>
  305. .CardTable {
  306. align-items: center;
  307. justify-content: space-between;
  308. padding-bottom: 10px;
  309. background-color: #000;
  310. transform: translateY(0);
  311. transition: all 0.3s;
  312. border-radius: 15px;
  313. margin: 20px;
  314. }
  315. #TituloCategoria {
  316. background-color: #e1e1e1 !important;
  317. border-top-right-radius: 15px;
  318. border-top-left-radius: 15px;
  319. }
  320. </style>
Advertisement
Add Comment
Please, Sign In to add comment