├── .browserslistrc ├── public ├── favicon.ico └── index.html ├── src ├── assets │ └── logo.png ├── views │ ├── About.vue │ ├── Page404.vue │ └── Dashboard.vue ├── main.js ├── components │ ├── Button.vue │ ├── SelectCategories.vue │ ├── PaymentsDisplay.vue │ ├── Pagination.vue │ └── AddPayment.vue ├── App.vue ├── router │ └── index.js └── store │ └── index.js ├── babel.config.js ├── .gitignore ├── README.md ├── .eslintrc.js └── package.json /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5hadown1/vuejs/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/5hadown1/vuejs/HEAD/src/assets/logo.png -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/views/About.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /src/views/Page404.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | Vue.config.productionTip = false 5 | 6 | import store from './store'; 7 | import router from './router'; 8 | 9 | new Vue({ 10 | render: h => h(App), 11 | store, 12 | router 13 | }).$mount('#app') 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | 6 | # local env files 7 | .env.local 8 | .env.*.local 9 | 10 | # Log files 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | pnpm-debug.log* 15 | 16 | # Editor directories and files 17 | .idea 18 | .vscode 19 | *.suo 20 | *.ntvs* 21 | *.njsproj 22 | *.sln 23 | *.sw? 24 | -------------------------------------------------------------------------------- /src/components/Button.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vuejs 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Lints and fixes files 19 | ``` 20 | npm run lint 21 | ``` 22 | 23 | ### Customize configuration 24 | See [Configuration Reference](https://cli.vuejs.org/config/). 25 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | 'extends': [ 7 | 'plugin:vue/essential', 8 | 'eslint:recommended' 9 | ], 10 | parserOptions: { 11 | parser: 'babel-eslint' 12 | }, 13 | rules: { 14 | 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 15 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/components/SelectCategories.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 27 | 28 | -------------------------------------------------------------------------------- /src/components/PaymentsDisplay.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <%= htmlWebpackPlugin.options.title %> 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuejs", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "core-js": "^3.6.5", 12 | "vue": "^2.6.11", 13 | "vue-router": "^3.5.2", 14 | "vuex": "^3.6.2" 15 | }, 16 | "devDependencies": { 17 | "@vue/cli-plugin-babel": "~4.5.0", 18 | "@vue/cli-plugin-eslint": "~4.5.0", 19 | "@vue/cli-service": "~4.5.0", 20 | "babel-eslint": "^10.1.0", 21 | "eslint": "^6.7.2", 22 | "eslint-plugin-vue": "^6.2.2", 23 | "sass": "^1.26.5", 24 | "sass-loader": "^8.0.2", 25 | "vue-template-compiler": "^2.6.11" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Router from 'vue-router'; 3 | 4 | import Dashboard from '../views/Dashboard.vue'; 5 | import About from '../views/About.vue'; 6 | import Page404 from '../views/Page404.vue'; 7 | import AddPayment from '../components/AddPayment.vue'; 8 | 9 | Vue.use(Router); 10 | 11 | export default new Router({ 12 | mode: 'history', 13 | routes: [ 14 | { 15 | path: '/dashboard', 16 | name: 'Dashboard', 17 | component: Dashboard 18 | }, { 19 | path: '/about*', 20 | name: 'About', 21 | component: About 22 | }, { 23 | path: '/add/payment/:category', 24 | name: 'AddPaymentRouting', 25 | component: AddPayment 26 | }, { 27 | path: '/404', 28 | name: 'NotFound', 29 | component: Page404 30 | } 31 | ] 32 | }) 33 | -------------------------------------------------------------------------------- /src/components/Pagination.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 34 | 35 | -------------------------------------------------------------------------------- /src/components/AddPayment.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Vuex from 'vuex'; 3 | 4 | Vue.use(Vuex); 5 | 6 | export default new Vuex.Store({ 7 | state: { 8 | paymentsList: [], 9 | categoryList: [], 10 | }, 11 | mutations: { 12 | setPaymentsListData (state, payload) { 13 | state.paymentsList = [...state.paymentsList, ...payload]; 14 | }, 15 | addDataToPaymentsList (state, payload) { 16 | state.paymentsList.push(payload); 17 | }, 18 | setCategories (state, payload) { 19 | if (!Array.isArray(payload)) { 20 | payload = [payload] 21 | } 22 | state.categoryList.push(...payload) 23 | }, 24 | }, 25 | getters: { 26 | getPaymentsList: state => state.paymentsList, 27 | getFullPaymentValue: state => { 28 | return state.paymentsList 29 | .reduce((res, cur) => + res + cur.value, 0) 30 | }, 31 | getCategoryList: state => state.categoryList, 32 | }, 33 | actions: { 34 | fetchData({ commit }) { 35 | return new Promise((resolve) => { 36 | // имитируем работу с сетью, ставим задержку получения данных в 2 секунды 37 | setTimeout(()=>{ 38 | const items = [] 39 | for(let i= 1; i< 50; i++){ 40 | items.push({ 41 | id: i, 42 | date: "23.12.2020", 43 | category: "Sport", 44 | value: i 45 | }) 46 | } 47 | resolve(items) 48 | },1000) 49 | }) 50 | .then(res => { 51 | // запускаем изменение состояния через commit 52 | commit('setPaymentsListData', res) 53 | }) 54 | }, 55 | fetchCategories ({ commit }) { 56 | return new Promise((resolve) => { 57 | // имитируем работу с сетью 58 | setTimeout(() => { 59 | resolve(['Food', 'Transport', 'Education', 'Entertainment']) 60 | }, 1000) 61 | }) 62 | .then(resolve => { 63 | // запускаем изменение состояния через commit 64 | commit('setCategories', resolve) 65 | }) 66 | }, 67 | }, 68 | }); -------------------------------------------------------------------------------- /src/views/Dashboard.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 16 | 93 | 94 | --------------------------------------------------------------------------------