From e2204323df167ee7b9c5ff642d47867d33c16339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com> Date: Tue, 31 May 2022 19:51:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 22 --------- src/store/modules/home/home.js | 44 +++++++---------- src/views/home/dateRange.vue | 87 ++++++++++++++++++++++++++++++++++ src/views/home/index.vue | 51 +++++++++++++++----- 4 files changed, 143 insertions(+), 61 deletions(-) create mode 100644 src/views/home/dateRange.vue diff --git a/src/router/index.js b/src/router/index.js index f31982c..ad7b75c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -22,28 +22,6 @@ export const globalRoutes = [ global: true, }, }, - { - path: '/', - name: 'App', - redirect: { name: 'Home' }, - component: () => import('@/layouts/default.vue'), - meta: { - layout: true, - title: '首页', - icon: 'home-fill', - }, - children: [ - { - path: '/home', - name: 'Home', - component: () => import('@/views/home/index.vue'), - meta: { - title: '首页', - icon: 'home-fill', - }, - }, - ], - }, ]; export const demoRoutes = import.meta.env.MODE === 'development' ? demoModule : []; diff --git a/src/store/modules/home/home.js b/src/store/modules/home/home.js index 976ee94..0cd681b 100644 --- a/src/store/modules/home/home.js +++ b/src/store/modules/home/home.js @@ -16,11 +16,13 @@ const state = () => ({ label: '今日销售额', value: 5000, icon: 'money-cny-box', + type: 'money', }, { label: '近7天销售总额', value: 50000, icon: 'line-chart', + type: 'money', }, ], order: [ @@ -181,21 +183,6 @@ const state = () => ({ }, ], }, - condition1: { - today: false, - beginDateTime: null, - endDateTime: null, - }, - condition2: { - today: false, - beginDateTime: null, - endDateTime: null, - }, - condition3: { - today: false, - beginDateTime: null, - endDateTime: null, - }, }); const getters = {}; const mutations = { @@ -267,19 +254,25 @@ const actions = { commit('setChartInfo3', res); return res; }, - loadChartData1: async ({ state, commit }) => { - let res = await (state.condition1.today ? api.customerToday : api.customerSummary)(state.condition1); - commit('setChartData1', res); + loadChartData1: async ({ commit }, data) => { + let today = + data.beginDateTime === data.endDateTime && data.endDateTime === dayjs(new Date()).format('YYYY-MM-DD'); + let res = await (today ? api.customerToday : api.customerSummary)(data); + commit('setChartData1', res || []); return res; }, - loadChartData2: async ({ state, commit }) => { - let res = await (state.condition2.today ? api.orderToday : api.orderSummary)(state.condition2); - commit('setChartData2', res); + loadChartData2: async ({ commit }, data) => { + let today = + data.beginDateTime === data.endDateTime && data.endDateTime === dayjs(new Date()).format('YYYY-MM-DD'); + let res = await (today ? api.orderToday : api.orderSummary)(data); + commit('setChartData2', res || []); return res; }, - loadChartData3: async ({ state, commit }) => { - let res = await (state.condition3.today ? api.orderToday : api.orderSummary)(state.condition3); - commit('setChartData3', res); + loadChartData3: async ({ commit }, data) => { + let today = + data.beginDateTime === data.endDateTime && data.endDateTime === dayjs(new Date()).format('YYYY-MM-DD'); + let res = await (today ? api.orderToday : api.orderSummary)(data); + commit('setChartData3', res || []); return res; }, load: async ({ dispatch }) => { @@ -291,9 +284,6 @@ const actions = { dispatch('loadChartInfo1'), dispatch('loadChartInfo2'), dispatch('loadChartInfo3'), - dispatch('loadChartData1'), - dispatch('loadChartData2'), - dispatch('loadChartData3'), ]); }, }; diff --git a/src/views/home/dateRange.vue b/src/views/home/dateRange.vue new file mode 100644 index 0000000..238fbe8 --- /dev/null +++ b/src/views/home/dateRange.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 851235a..fc2abac 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -5,7 +5,7 @@

{{ item.label }}

-

{{ item.value }}

+

{{ handleValue(item) }}

@@ -42,7 +42,7 @@