Bladeren bron

feat: 新增销售分析模块,添加多个分析数据接口,优化数据请求格式,更新路由配置以支持新页面,提升用户体验。

master
lizhuang 1 week geleden
bovenliggende
commit
191ac80359
4 gewijzigde bestanden met toevoegingen van 1370 en 118 verwijderingen
  1. 187
    108
      src/api/sales-analysis.js
  2. 5
    0
      src/router/index.js
  3. 25
    10
      src/utils/tools.js
  4. 1153
    0
      src/views/sales-analysis/reports/CommonAnalysis.vue

+ 187
- 108
src/api/sales-analysis.js Bestand weergeven

@@ -1,11 +1,11 @@
import request from "@/utils/request";
import request from '@/utils/request'

export function getProductCodeSuggestions(params) {
return request({
url: "/reports/product-code-suggestions",
method: "get",
params,
});
url: '/reports/product-code-suggestions',
method: 'get',
params
})
}
/**
* 销售分析模块API接口
@@ -30,10 +30,10 @@ export function getProductCodeSuggestions(params) {
*/
export function getAnalysisDataList(params) {
return request({
url: "/analysis-data",
method: "get",
params,
});
url: '/analysis-data',
method: 'get',
params
})
}

/**
@@ -45,9 +45,9 @@ export function getAnalysisDataList(params) {
export function updateAnalysisData(id, data) {
return request({
url: `/analysis-data/${id}`,
method: "put",
data,
});
method: 'put',
data
})
}

/**
@@ -58,8 +58,8 @@ export function updateAnalysisData(id, data) {
export function deleteAnalysisData(id) {
return request({
url: `/analysis-data/${id}`,
method: "delete",
});
method: 'delete'
})
}

/**
@@ -70,8 +70,8 @@ export function deleteAnalysisData(id) {
export function batchDeleteAnalysisData(ids) {
return request({
url: `/analysis-data/batch/${ids}`,
method: "delete",
});
method: 'delete'
})
}

/**
@@ -80,12 +80,12 @@ export function batchDeleteAnalysisData(ids) {
* @returns {string} 导出文件URL
*/
export function exportAnalysisData(params) {
const queryString = new URLSearchParams(params).toString();
const queryString = new URLSearchParams(params).toString()
return request({
url: `/analysis-data/export?${queryString}`,
responseType: "blob",
method: "get",
});
responseType: 'blob',
method: 'get'
})
}

// ==================== 数据导入 ====================
@@ -97,13 +97,13 @@ export function exportAnalysisData(params) {
*/
export function importAnalysisDataBatch(formData) {
return request({
url: "/analysis-data/import-batch",
method: "post",
url: '/analysis-data/import-batch',
method: 'post',
data: formData,
headers: {
"Content-Type": "multipart/form-data",
},
});
'Content-Type': 'multipart/form-data'
}
})
}

/**
@@ -113,13 +113,13 @@ export function importAnalysisDataBatch(formData) {
*/
export function importFBADataBatch(formData) {
return request({
url: "/analysis-data/import/fba/batch",
method: "post",
url: '/analysis-data/import/fba/batch',
method: 'post',
data: formData,
headers: {
"Content-Type": "multipart/form-data",
},
});
'Content-Type': 'multipart/form-data'
}
})
}

/**
@@ -129,10 +129,10 @@ export function importFBADataBatch(formData) {
*/
export function saveImportedData(data) {
return request({
url: "/analysis-data/save-imported",
method: "post",
data,
});
url: '/analysis-data/save-imported',
method: 'post',
data
})
}

// ==================== 基准数据管理 ====================
@@ -143,9 +143,9 @@ export function saveImportedData(data) {
*/
export function getCategoriesSimple() {
return request({
url: "/categories/simple",
method: "get",
});
url: '/categories/simple',
method: 'get'
})
}

/**
@@ -156,8 +156,8 @@ export function getCategoriesSimple() {
export function getCategoryDetail(categoryId) {
return request({
url: `/categories/${categoryId}`,
method: "get",
});
method: 'get'
})
}

/**
@@ -172,10 +172,10 @@ export function getCategoryDetail(categoryId) {
*/
export function getBaseDataList(params) {
return request({
url: "/basedata",
method: "get",
params,
});
url: '/basedata',
method: 'get',
params
})
}

/**
@@ -186,9 +186,9 @@ export function getBaseDataList(params) {
export function exportBaseData(categoryId) {
return request({
url: `/basedata/export/${categoryId}`,
responseType: "blob",
method: "get",
});
responseType: 'blob',
method: 'get'
})
}

/**
@@ -199,8 +199,8 @@ export function exportBaseData(categoryId) {
export function deleteBaseData(id) {
return request({
url: `/basedata/${id}`,
method: "delete",
});
method: 'delete'
})
}

/**
@@ -211,8 +211,8 @@ export function deleteBaseData(id) {
export function batchDeleteBaseData(ids) {
return request({
url: `/basedata/batch/${ids}`,
method: "delete",
});
method: 'delete'
})
}

/**
@@ -222,10 +222,10 @@ export function batchDeleteBaseData(ids) {
*/
export function BaseDataAdd(data) {
return request({
url: "/basedata",
method: "post",
data,
});
url: '/basedata',
method: 'post',
data
})
}

/**
@@ -237,9 +237,9 @@ export function BaseDataAdd(data) {
export function BaseDataUpdate(id, data) {
return request({
url: `/basedata/${id}`,
method: "put",
data,
});
method: 'put',
data
})
}

// ==================== 分类管理 ====================
@@ -254,10 +254,10 @@ export function BaseDataUpdate(id, data) {
*/
export function getCategoriesList(params) {
return request({
url: "/categories",
method: "get",
params,
});
url: '/categories',
method: 'get',
params
})
}

/**
@@ -267,10 +267,10 @@ export function getCategoriesList(params) {
*/
export function createCategory(data) {
return request({
url: "/categories",
method: "post",
data,
});
url: '/categories',
method: 'post',
data
})
}

/**
@@ -282,9 +282,9 @@ export function createCategory(data) {
export function updateCategory(id, data) {
return request({
url: `/categories/${id}`,
method: "put",
data,
});
method: 'put',
data
})
}

/**
@@ -295,8 +295,8 @@ export function updateCategory(id, data) {
export function deleteCategory(id) {
return request({
url: `/categories/${id}`,
method: "delete",
});
method: 'delete'
})
}

// ==================== 店铺客户关联管理 ====================
@@ -312,10 +312,10 @@ export function deleteCategory(id) {
*/
export function getShopCustomerList(params) {
return request({
url: "/shop-customer",
method: "get",
params,
});
url: '/shop-customer',
method: 'get',
params
})
}

/**
@@ -326,8 +326,8 @@ export function getShopCustomerList(params) {
export function deleteShopCustomer(id) {
return request({
url: `/shop-customer/${id}`,
method: "delete",
});
method: 'delete'
})
}

/**
@@ -338,8 +338,8 @@ export function deleteShopCustomer(id) {
export function batchDeleteShopCustomer(ids) {
return request({
url: `/shop-customer/batch/${ids}`,
method: "delete",
});
method: 'delete'
})
}

/**
@@ -348,10 +348,10 @@ export function batchDeleteShopCustomer(ids) {
*/
export function exportShopCustomer() {
return request({
url: "/shop-customer/export",
responseType: "blob",
method: "get",
});
url: '/shop-customer/export',
responseType: 'blob',
method: 'get'
})
}

/**
@@ -361,10 +361,10 @@ export function exportShopCustomer() {
*/
export function ShopCustomerAdd(data) {
return request({
url: "/shop-customer",
method: "post",
data,
});
url: '/shop-customer',
method: 'post',
data
})
}

/**
@@ -376,9 +376,9 @@ export function ShopCustomerAdd(data) {
export function ShopCustomerUpdate(id, data) {
return request({
url: `/shop-customer/${id}`,
method: "put",
data,
});
method: 'put',
data
})
}

// ==================== 报表分析 ====================
@@ -389,9 +389,12 @@ export function ShopCustomerUpdate(id, data) {
*/
export function getReportFilterOptions() {
return request({
url: "/reports/filter-options",
method: "get",
});
url: '/reports/filter-options',
method: 'get',
headers: {
'Content-Type': 'application/json'
}
})
}

/**
@@ -404,10 +407,10 @@ export function getReportFilterOptions() {
*/
export function getProductAnalysisReport(params) {
return request({
url: "/reports/product-analysis",
method: "get",
params,
});
url: '/reports/product-analysis',
method: 'get',
params
})
}

/**
@@ -420,10 +423,10 @@ export function getProductAnalysisReport(params) {
*/
export function getShopAnalysisReport(params) {
return request({
url: "/reports/shop-analysis",
method: "get",
params,
});
url: '/reports/shop-analysis',
method: 'get',
params
})
}

/**
@@ -435,10 +438,10 @@ export function getShopAnalysisReport(params) {
*/
export function getCategoryAnalysisReport(params) {
return request({
url: "/reports/category-analysis",
method: "get",
params,
});
url: '/reports/category-analysis',
method: 'get',
params
})
}

/**
@@ -450,8 +453,84 @@ export function getCategoryAnalysisReport(params) {
*/
export function getOverallAnalysisReport(params) {
return request({
url: "/reports/overall-analysis",
method: "get",
params,
});
url: '/reports/overall-analysis',
method: 'get',
params
})
}

/**
* 获取分析数据所有筛选选项
* @param {*} params
* @returns
*/
export function getAnalysisAllFilterOptions(params) {
return request({
url: '/tjfx/analysis-data/filter-options',
method: 'get',
params
})
}

/**
* 获取分析数据商品分析
* @param {*} params
* @returns
*/
export function getAnalysisProductAnalysis(params) {
return request({
url: '/tjfx/analysis-data/product-analysis',
method: 'get',
params
})
}

/**
* 获取分析数据月度分析
* @param {*} params
* @returns
*/
export function getAnalysisMonthlyAnalysis(params) {
return request({
url: '/tjfx/analysis-data/monthly-analysis',
method: 'get',
params
})
}
/**
* 获取分析数据商品店铺分析
* @param {*} params
* @returns
*/
export function getAnalysisProductShopAnalysis(params) {
return request({
url: '/tjfx/analysis-data/product-shop-analysis',
method: 'get',
params
})
}
/**
* 获取分析数据综合分析
* @param {*} params
* @returns
*/
export function getAnalysisComprehensiveAnalysis(params) {
return request({
url: '/tjfx/analysis-data/comprehensive-analysis',
method: 'get',
params
})
}

/**
* 获取分析数据SSD月度分析
* @param {*} params
* @returns
*/
export function getAnalysisSsdMonthlyAnalysis(params) {
return request({
url: '/tjfx/analysis-data/ssd-monthly-analysis',
method: 'get',
params
})
}

+ 5
- 0
src/router/index.js Bestand weergeven

@@ -95,6 +95,11 @@ export const constantRoutes = [
hidden: true,
meta: { title: "menu.checkin", icon: "date" },
},
{
path: "/sales-analysis/reports/analysis",
component: () => import("@/views/sales-analysis/reports/CommonAnalysis"),
meta: { title: "menu.commonAnalysis", icon: "date" },
},
];

// 动态路由,基于用户权限动态去加载

+ 25
- 10
src/utils/tools.js Bestand weergeven

@@ -220,19 +220,34 @@ export function tansParams(params) {
const value = params[propName]
var part = encodeURIComponent(propName) + '='
if (value !== null && value !== '' && typeof value !== 'undefined') {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
if (
value[key] !== null &&
value[key] !== '' &&
typeof value[key] !== 'undefined'
) {
const params = propName + '[' + key + ']'
var subPart = encodeURIComponent(params) + '='
result += subPart + encodeURIComponent(value[key]) + '&'
if (Array.isArray(value)) {
// 数组类型:生成重复参数名格式 key=value1&key=value2
for (const item of value) {
if (item !== null && item !== '' && typeof item !== 'undefined') {
result += part + encodeURIComponent(item) + '&'
}
}
} else if (typeof value === 'object') {
// 特殊处理 categorySpecs 对象
if (propName === 'categorySpecs') {
// categorySpecs 需要特殊处理,将嵌套对象转换为 JSON 字符串
result += part + encodeURIComponent(JSON.stringify(value)) + '&'
} else {
// 其他对象类型:保持原有的 key[subkey]=value 格式
for (const key of Object.keys(value)) {
if (
value[key] !== null &&
value[key] !== '' &&
typeof value[key] !== 'undefined'
) {
const params = propName + '[' + key + ']'
var subPart = encodeURIComponent(params) + '='
result += subPart + encodeURIComponent(value[key]) + '&'
}
}
}
} else {
// 基本类型:直接添加
result += part + encodeURIComponent(value) + '&'
}
}

+ 1153
- 0
src/views/sales-analysis/reports/CommonAnalysis.vue
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


Laden…
Annuleren
Opslaan