diff --git a/src/api/file.js b/src/api/file.js index 79139c9..dc1a8e2 100644 --- a/src/api/file.js +++ b/src/api/file.js @@ -23,7 +23,9 @@ export function sign(serviceName, configId) { export async function upload(serviceName, configId, file, cancelToken) { let oss = await sign(serviceName, configId); let data = new FormData(); - data.append('name', file.name); + let arr = file.name.split('/'); + arr[arr.length - 1] = encodeURIComponent(arr[arr.length - 1]); + data.append('name', arr.join('/')); data.append('key', `${oss.dir}${'${filename}'}`); data.append('policy', oss.policy); data.append('OSSAccessKeyId', oss.accessId); diff --git a/src/api/home/index.js b/src/api/home/index.js index d0d3a8f..17f7024 100644 --- a/src/api/home/index.js +++ b/src/api/home/index.js @@ -47,7 +47,7 @@ export const orderSummary = (params) => { // 获取今日订单统计数据 export const orderToday = () => { return request({ - url: '/mall/base/frontPage/listOrderStatistics', + url: '/mall/base/frontPage/listTodayOrderStatistics', method: 'get', }); }; diff --git a/src/assets/home/customer.png b/src/assets/home/customer.png new file mode 100644 index 0000000..fa59ae8 Binary files /dev/null and b/src/assets/home/customer.png differ diff --git a/src/assets/home/down.png b/src/assets/home/down.png new file mode 100644 index 0000000..8f8574d Binary files /dev/null and b/src/assets/home/down.png differ diff --git a/src/assets/home/icon-advertise.png b/src/assets/home/icon-advertise.png new file mode 100644 index 0000000..e79c09b Binary files /dev/null and b/src/assets/home/icon-advertise.png differ diff --git a/src/assets/home/icon-limit.png b/src/assets/home/icon-limit.png new file mode 100644 index 0000000..51c70ef Binary files /dev/null and b/src/assets/home/icon-limit.png differ diff --git a/src/assets/home/icon-notify.png b/src/assets/home/icon-notify.png new file mode 100644 index 0000000..c9ff219 Binary files /dev/null and b/src/assets/home/icon-notify.png differ diff --git a/src/assets/home/icon-order.png b/src/assets/home/icon-order.png new file mode 100644 index 0000000..de47fc9 Binary files /dev/null and b/src/assets/home/icon-order.png differ diff --git a/src/assets/home/icon-product.png b/src/assets/home/icon-product.png new file mode 100644 index 0000000..f9c98eb Binary files /dev/null and b/src/assets/home/icon-product.png differ diff --git a/src/assets/home/order.png b/src/assets/home/order.png new file mode 100644 index 0000000..26503b3 Binary files /dev/null and b/src/assets/home/order.png differ diff --git a/src/assets/home/sales.png b/src/assets/home/sales.png new file mode 100644 index 0000000..73f1b60 Binary files /dev/null and b/src/assets/home/sales.png differ diff --git a/src/assets/home/sales2.png b/src/assets/home/sales2.png new file mode 100644 index 0000000..dc41ac8 Binary files /dev/null and b/src/assets/home/sales2.png differ diff --git a/src/assets/home/up.png b/src/assets/home/up.png new file mode 100644 index 0000000..f11fd1f Binary files /dev/null and b/src/assets/home/up.png differ diff --git a/src/components/extra/ElInput.vue b/src/components/extra/ElInput.vue index 6851a69..7435014 100644 --- a/src/components/extra/ElInput.vue +++ b/src/components/extra/ElInput.vue @@ -13,6 +13,10 @@ type: Boolean, default: true, }, + maxlength: { + type: [Number, String], + default: 255, + }, placeholder: { type: String, default: '请输入', @@ -44,6 +48,7 @@ }); const attrs = useAttrs(); const slots = useSlots(); - const render = () => ; + const showWordLimit = props.showWordLimit === true && props.maxlength !== 255; + const render = () => ; diff --git a/src/layouts/default.vue b/src/layouts/default.vue index 2da54df..1dfb112 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -28,6 +28,7 @@ .layout-container { width: 100vw; height: 100vh; + min-width: 1200px; background-color: @color-white-dark; } .layout-default { diff --git a/src/router/index.js b/src/router/index.js index ad7b75c..c559595 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -59,13 +59,19 @@ router.onError((error, to) => { router.beforeEach(async (to, from, next) => { if (store.state.local.token) { if (!store.state.auth.permission.length) { - await store.dispatch('auth/getUserInfo'); + let res1 = true, + res2 = true; + res1 = await store.dispatch('auth/getUserInfo'); if (config.useLocalRouter) { store.commit('auth/setPermission', routes); } else { - await store.dispatch('auth/getPermission'); + res2 = await store.dispatch('auth/getPermission'); + } + if (res1 && res2) { + next({ ...to, replace: true }); + } else { + next(false); } - next({ ...to, replace: true }); } else { console.info(`[router] from ${from.name} to ${to.name}`); const deep = (route) => { diff --git a/src/store/modules/home/home.js b/src/store/modules/home/home.js index 0cd681b..4a30fc7 100644 --- a/src/store/modules/home/home.js +++ b/src/store/modules/home/home.js @@ -1,78 +1,87 @@ import * as api from '@/api/home/index.js'; +import customer from '~/home/customer.png'; +import iconAdvertise from '~/home/icon-advertise.png'; +import iconLimit from '~/home/icon-limit.png'; +import iconNotify from '~/home/icon-notify.png'; +import iconOrder from '~/home/icon-order.png'; +import iconProduct from '~/home/icon-product.png'; +import order from '~/home/order.png'; +import sales from '~/home/sales.png'; +import sales2 from '~/home/sales2.png'; const state = () => ({ opts: { summary: [ { label: '今日访客数', - value: 1526, - icon: 'bar-chart', + value: '-', + icon: customer, }, { label: '今日订单数', - value: 200, - icon: 'file-list', + value: '-', + icon: order, }, { label: '今日销售额', - value: 5000, - icon: 'money-cny-box', + value: '-', + icon: sales, type: 'money', }, { label: '近7天销售总额', - value: 50000, - icon: 'line-chart', + value: '-', + icon: sales2, type: 'money', }, ], order: [ { label: '待付款订单', - value: '10', + value: '-', route: { name: 'OrderManagement', - params: { + query: { status: 1, }, }, }, { - label: '待处理退款申请', - value: '10', + label: '待发货订单', + value: '-', route: { - name: 'ServiceManagement', - params: { - status: 1, + name: 'OrderManagement', + query: { + status: 3, }, }, }, { - label: '待发货订单', - value: '10', + label: '已发货订单', + value: '-', route: { name: 'OrderManagement', - params: { - status: 1, + query: { + status: 4, }, }, }, { - label: '待确认退货订单', - value: '10', + label: '待处理退款申请', + value: '-', route: { - name: 'ServiceManagement', - params: { + name: 'ServiceApplication', + query: { status: 1, }, }, }, { - label: '已发货订单', - value: '10', + label: '待确认退货订单', + value: '-', route: { - name: 'OrderManagement', - params: { - status: 1, + name: 'ServiceApplication', + query: { + status: 4, }, }, }, @@ -80,35 +89,38 @@ const state = () => ({ teleport: [ { label: '添加商品', - value: 'product-hunt', + value: iconProduct, route: { name: 'CreateProduct', }, }, { label: '订单列表', - value: 'money-cny-circle', + value: iconOrder, route: { name: 'OrderManagement', + query: { + status: 0, + }, }, }, { label: '秒杀管理', - value: 'auction', + value: iconLimit, route: { name: 'LimitActivity', }, }, { label: '消息通知', - value: 'notification-3', + value: iconNotify, route: { name: 'NotifyManagement', }, }, { label: '广告管理', - value: 'advertisement', + value: iconAdvertise, route: { name: 'AdvertiseManagement', }, @@ -117,69 +129,66 @@ const state = () => ({ product: [ { label: '已上架', - value: 100, + value: '-', }, { label: '未上架', - value: 400, + value: '-', }, { label: '库存紧张', - value: 50, + value: '-', }, { label: '全部商品', - value: 500, + value: '-', }, ], customer: [ { label: '今日新增', - value: 100, + value: '-', }, { - label: '昨日新添', - value: 200, + label: '昨日新增', + value: '-', }, { label: '本月新增', - value: 1000, + value: '-', }, { label: '用户总数', - value: 5000, + value: '-', }, ], chart: [ { - info: {}, - data: [ - { label: '1月', value: 152 }, - { label: '2月', value: 215 }, - { label: '3月', value: 198 }, - { label: '4月', value: 348 }, - { label: '5月', value: 111 }, - ], + info: { + monthUpsOrDownsScale: '-', + monthVisitor: '-', + weekUpsOrDownsScale: '-', + weekVisitor: '-', + }, + data: [], }, { - info: {}, - data: [ - { label: '1月', value: 152 }, - { label: '2月', value: 215 }, - { label: '3月', value: 198 }, - { label: '4月', value: 348 }, - { label: '5月', value: 111 }, - ], + info: { + monthUpsOrDownsScale: '-', + monthOrder: '-', + weekUpsOrDownsScale: '-', + weekOrder: '-', + }, + data: [], }, { - info: {}, - data: [ - { label: '1月', value: 152 }, - { label: '2月', value: 215 }, - { label: '3月', value: 198 }, - { label: '4月', value: 348 }, - { label: '5月', value: 111 }, - ], + info: { + monthUpsOrDownsScale: '-', + monthSales: '-', + weekUpsOrDownsScale: '-', + weekSales: '-', + }, + data: [], }, ], }, @@ -194,10 +203,10 @@ const mutations = { }, setOrder: (state, data) => { state.opts.order[0].value = data.waitPayCount || 0; - state.opts.order[1].value = data.waitRefundCount || 0; - state.opts.order[2].value = data.waitShipCount || 0; - state.opts.order[3].value = data.waitReturnGoodsCount || 0; - state.opts.order[4].value = data.shippedCount || 0; + state.opts.order[1].value = data.waitShipCount || 0; + state.opts.order[2].value = data.shippedCount || 0; + state.opts.order[3].value = data.waitRefundCount || 0; + state.opts.order[4].value = data.waitReturnGoodsCount || 0; }, setProduct: (state, data) => { state.opts.product[0].value = data.onTheShelfCount || 0; @@ -211,9 +220,27 @@ const mutations = { state.opts.customer[2].value = data.monthIncreaseCount || 0; state.opts.customer[3].value = data.allCount || 0; }, - setChartInfo1: (state, data) => (state.opts.chart[0].info = data), - setChartInfo2: (state, data) => (state.opts.chart[1].info = data), - setChartInfo3: (state, data) => (state.opts.chart[2].info = data), + setChartInfo1: (state, data) => + (state.opts.chart[0].info = data || { + monthUpsOrDownsScale: 0, + monthVisitor: 0, + weekUpsOrDownsScale: 0, + weekVisitor: 0, + }), + setChartInfo2: (state, data) => + (state.opts.chart[1].info = data || { + monthUpsOrDownsScale: 0, + monthOrder: 0, + weekUpsOrDownsScale: 0, + weekOrder: 0, + }), + setChartInfo3: (state, data) => + (state.opts.chart[2].info = data || { + monthUpsOrDownsScale: 0, + monthSales: 0, + weekUpsOrDownsScale: 0, + weekSales: 0, + }), setChartData1: (state, data) => (state.opts.chart[0].data = data), setChartData2: (state, data) => (state.opts.chart[1].data = data), setChartData3: (state, data) => (state.opts.chart[2].data = data), @@ -221,22 +248,22 @@ const mutations = { const actions = { loadSummary: async ({ commit }) => { let res = await api.summary(); - commit('setSummary', res); + commit('setSummary', res || {}); return res; }, loadOrder: async ({ commit }) => { let res = await api.order(); - commit('setOrder', res); + commit('setOrder', res || {}); return res; }, loadProduct: async ({ commit }) => { let res = await api.product(); - commit('setProduct', res); + commit('setProduct', res || {}); return res; }, loadCustomer: async ({ commit }) => { let res = await api.customer(); - commit('setCustomer', res); + commit('setCustomer', res || {}); return res; }, loadChartInfo1: async ({ commit }) => { @@ -255,24 +282,63 @@ const actions = { return 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 || []); + let res = await api.customerSummary(data); + commit( + 'setChartData1', + (res || []).map((item) => { + return { label: item.recordDate, value: item.count }; + }) + ); + return res; + }, + loadChartData11: async ({ commit }) => { + let res = await api.customerToday(); + commit( + 'setChartData1', + (res || []).map((item) => { + return { label: item.recordDate, value: item.count }; + }) + ); return 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 || []); + let res = await api.orderSummary(data); + commit( + 'setChartData2', + (res || []).map((item) => { + return { label: item.recordDate, value: item.count }; + }) + ); + return res; + }, + loadChartData22: async ({ commit }) => { + let res = await api.orderToday(); + commit( + 'setChartData2', + (res || []).map((item) => { + return { label: item.recordDate, value: item.count }; + }) + ); return 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 || []); + let res = await api.moneySummary(data); + commit( + 'setChartData3', + (res || []).map((item) => { + return { label: item.recordDate, value: item.sales }; + }) + ); + return res; + }, + loadChartData33: async ({ commit }) => { + let res = await api.moneyToday(); + commit( + 'setChartData3', + (res || []).map((item) => { + return { label: item.recordDate, value: item.sales }; + }) + ); return res; }, load: async ({ dispatch }) => { diff --git a/src/store/modules/sales/product.js b/src/store/modules/sales/product.js index e1fbdc7..8e8c6a2 100644 --- a/src/store/modules/sales/product.js +++ b/src/store/modules/sales/product.js @@ -113,11 +113,9 @@ const actions = { delete data.singleBuyLimit; } data.virtualProductModifyDTOList = data.fileList.map((item) => { - let arr = item.split('/'); - arr[arr.length - 1] = encodeURIComponent(arr[arr.length - 1]); return { shipType: 1, - shipContent: arr.join('/'), + shipContent: item, }; }); if (data.autoSend) { diff --git a/src/utils/request.js b/src/utils/request.js index 034ba57..4a7d620 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -12,10 +12,13 @@ const handleResponse = async ({ config: requestConfig, data, status }) => { if (requestConfig.headers.download === true) { return data; } - let code = data.code || status; - console.info('[api]', code, requestConfig.method, requestConfig.url, data.data); + let code = data?.code || status; + console.info('[api]', code, requestConfig.method, requestConfig.url, data?.data); if (code !== 'SUCCESS') { - ElMessage.error(data.message || '服务器异常'); + ElMessage.error(data?.message || '服务器异常'); + if (data) { + data.data = null; + } switch (code) { case 'SYSTEM_ERROR': //系统异常 case 'INTERFACE_SYSTEM_ERROR': // 外部接口调用异常 diff --git a/src/views/home/dateRange.vue b/src/views/home/dateRange.vue index 238fbe8..390a537 100644 --- a/src/views/home/dateRange.vue +++ b/src/views/home/dateRange.vue @@ -1,16 +1,18 @@