Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-ui
Commits
3ade5e40
提交
3ade5e40
authored
1月 03, 2025
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(bi/sale): 重构商品明细每日
完成
上级
d2635ee9
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
93 行增加
和
31 行删除
+93
-31
math.js
src/utils/math.js
+3
-3
LineChart.vue
src/views/bi/sale/LineChart.vue
+36
-12
index.vue
src/views/bi/sale/index.vue
+54
-16
没有找到文件。
src/utils/math.js
浏览文件 @
3ade5e40
...
@@ -27,11 +27,11 @@ export function divSafe(arg1, arg2) {
...
@@ -27,11 +27,11 @@ export function divSafe(arg1, arg2) {
* @param {number} fixed - 保留几位小数
* @param {number} fixed - 保留几位小数
* @param {bool} round - 是否取整(四舍五入)
* @param {bool} round - 是否取整(四舍五入)
* @param {bool} pos - 是否统一正数
* @param {bool} pos - 是否统一正数
* @param {bool} comma - 是否使用千分位逗号
* @param {bool} comma - 是否使用千分位逗号
(从这里开始往下就是字符串了)
* @param {string} des - 尾部额外添加描述字符(例如:人 / 元 / %等)
* @param {string} des - 尾部额外添加描述字符(例如:人 / 元 / %等)
* @returns {string} 格式化后的字符串
* @returns {string} 格式化后的字符串
*/
*/
export
function
formatNumberWithUnit
({
value
,
carry
=
true
,
fixed
=
2
,
round
=
true
,
pos
=
true
,
comma
=
true
,
des
})
{
export
function
formatNumberWithUnit
({
value
,
carry
=
true
,
fixed
=
2
,
round
=
true
,
pos
=
true
,
comma
=
true
,
des
=
''
})
{
// console.log('传入', value, carry, fixed, round, pos, comma, des)
// console.log('传入', value, carry, fixed, round, pos, comma, des)
let
resultNum
=
0
// 保存计算后的结果
let
resultNum
=
0
// 保存计算后的结果
let
unit
=
''
;
// 保存转换后的单位(例如:万 / 亿)
let
unit
=
''
;
// 保存转换后的单位(例如:万 / 亿)
...
@@ -77,7 +77,7 @@ export function formatNumberWithUnit({ value, carry = true, fixed = 2, round = t
...
@@ -77,7 +77,7 @@ export function formatNumberWithUnit({ value, carry = true, fixed = 2, round = t
resultNum
=
Math
.
abs
(
resultNum
);
resultNum
=
Math
.
abs
(
resultNum
);
}
}
if
(
comma
)
{
if
(
comma
)
{
// 是否添加千分位符号
(从这里开始就是字符串了)
// 是否添加千分位符号
resultNum
=
resultNum
.
toString
().
replace
(
/
\B(?=(\d{3})
+
(?!\d))
/g
,
','
);
resultNum
=
resultNum
.
toString
().
replace
(
/
\B(?=(\d{3})
+
(?!\d))
/g
,
','
);
}
}
return
`
${
resultNum
}
${
unit
}${
des
}
`
;
return
`
${
resultNum
}
${
unit
}${
des
}
`
;
...
...
src/views/bi/sale/LineChart.vue
浏览文件 @
3ade5e40
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
<
script
setup
>
<
script
setup
>
import
*
as
echarts
from
'echarts'
import
*
as
echarts
from
'echarts'
import
{
useWindowResize
}
from
'@/hooks'
import
{
useWindowResize
}
from
'@/hooks'
import
{
formatNumberWithUnit
}
from
'@/utils'
const
props
=
defineProps
({
const
props
=
defineProps
({
className
:
{
className
:
{
...
@@ -53,7 +54,21 @@ const setOptions = () => {
...
@@ -53,7 +54,21 @@ const setOptions = () => {
text
:
props
.
chartData
.
title
,
text
:
props
.
chartData
.
title
,
},
},
tooltip
:
{
tooltip
:
{
trigger
:
'axis'
trigger
:
'axis'
,
formatter
:
function
(
params
)
{
let
tooltip
=
''
;
params
.
forEach
((
item
)
=>
{
// 获取系列颜色
var
color
=
item
.
color
;
// 拼接提示内容
tooltip
+=
'<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:'
+
color
+
';"></span>'
+
item
.
seriesName
+
': '
+
formatNumberWithUnit
({
value
:
item
.
value
,
des
:
props
.
chartData
.
yName
,
carry
:
myThousand
.
value
})
+
'<br>'
;
});
return
tooltip
;
}
},
},
legend
:
{
legend
:
{
data
:
props
.
chartData
.
data
?.
map
(
o
=>
o
.
name
)
data
:
props
.
chartData
.
data
?.
map
(
o
=>
o
.
name
)
...
@@ -77,7 +92,6 @@ const setOptions = () => {
...
@@ -77,7 +92,6 @@ const setOptions = () => {
icon
:
'path://M50,50 L100,50 L100,100 L150,100 L150,150 L100,150 L100,200 L50,200 L50,150 L0,150 L0,100 L50,100 Z'
,
icon
:
'path://M50,50 L100,50 L100,100 L150,100 L150,150 L100,150 L100,200 L50,200 L50,150 L0,150 L0,100 L50,100 Z'
,
onclick
:
()
=>
{
onclick
:
()
=>
{
myThousand
.
value
=
!
myThousand
.
value
myThousand
.
value
=
!
myThousand
.
value
lockThousand
.
value
=
!
lockThousand
.
value
setOptions
()
setOptions
()
}
}
}
}
...
@@ -85,33 +99,43 @@ const setOptions = () => {
...
@@ -85,33 +99,43 @@ const setOptions = () => {
},
},
xAxis
:
{
xAxis
:
{
type
:
'category'
,
type
:
'category'
,
boundaryGap
:
false
,
//
boundaryGap: false,
data
:
props
.
chartData
.
xData
data
:
props
.
chartData
.
xData
},
},
yAxis
:
{
yAxis
:
{
type
:
'value'
,
type
:
'value'
,
name
:
(
myThousand
.
value
?
'(万)'
:
''
)
+
props
.
chartData
.
yName
name
:
props
.
chartData
.
yName
,
axisLabel
:
{
formatter
(
value
)
{
return
formatNumberWithUnit
({
value
,
des
:
props
.
chartData
.
yName
,
carry
:
myThousand
.
value
})
}
},
},
},
series
:
props
.
chartData
.
data
?.
map
(
o
=>
{
series
:
props
.
chartData
.
data
?.
map
(
o
=>
{
return
{
return
{
name
:
o
.
name
,
name
:
o
.
name
,
type
:
'line'
,
type
:
'line'
,
data
:
o
.
data
.
map
(
num
=>
{
data
:
o
.
data
return
parseFloat
((
myThousand
.
value
?
num
/
10000
:
num
).
toFixed
(
2
))
})
}
}
})
})
})
}
,
true
)
}
}
watch
(()
=>
props
.
chartData
,
()
=>
{
watch
(()
=>
props
.
chartData
,
()
=>
{
console
.
log
(
props
.
chartData
)
// 自动计算是否需要过万单位
// 自动计算是否需要过万单位
// if (!this.lockThousand) {
// if (!this.lockThousand) {
// this.myThousand = thi
s.chartData.data?.some(o => {
myThousand
.
value
=
prop
s
.
chartData
.
data
?.
some
(
o
=>
{
//
return o.data.some(num => num >= 10000)
return
o
.
data
.
some
(
num
=>
num
>=
10000
)
//
})
})
// }
// }
chart
&&
setOptions
()
chart
&&
setOptions
()
},
{
deep
:
true
})
})
watch
(()
=>
props
.
showTool
,
()
=>
{
watch
(()
=>
props
.
showTool
,
()
=>
{
...
@@ -125,7 +149,7 @@ const initChart = () => {
...
@@ -125,7 +149,7 @@ const initChart = () => {
const
resize
=
()
=>
{
const
resize
=
()
=>
{
chart
.
value
.
resize
()
chart
.
resize
()
}
}
useWindowResize
(
resize
)
useWindowResize
(
resize
)
...
...
src/views/bi/sale/index.vue
浏览文件 @
3ade5e40
...
@@ -112,13 +112,19 @@
...
@@ -112,13 +112,19 @@
align=
"center"
align=
"center"
min-width=
"100px"
min-width=
"100px"
sortable
sortable
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(cellValue, '', false, true)"
></el-table-column>
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(
{
value: cellValue,
round: false
})">
</el-table-column>
<el-table-column
label=
"销售额"
<el-table-column
label=
"销售额"
prop=
"YTD.salePrice"
prop=
"YTD.salePrice"
align=
"center"
align=
"center"
min-width=
"100px"
min-width=
"100px"
sortable
sortable
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(cellValue, '', true, false)"
>
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(
{
value: cellValue,
round: false
})">
</el-table-column>
</el-table-column>
<!--
<el-table-column
label=
"达成率"
<!--
<el-table-column
label=
"达成率"
prop=
"YTD.needNumPercentage"
prop=
"YTD.needNumPercentage"
...
@@ -143,11 +149,17 @@
...
@@ -143,11 +149,17 @@
align=
"center"
align=
"center"
min-width=
"100px"
min-width=
"100px"
sortable
sortable
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(cellValue, '', true, false)"
></el-table-column>
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(
{
value: cellValue,
round: false
})">
</el-table-column>
<el-table-column
label=
"销售额"
<el-table-column
label=
"销售额"
prop=
"MTD.salePrice"
prop=
"MTD.salePrice"
align=
"center"
align=
"center"
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(cellValue, '', true, false)"
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(
{
value: cellValue,
round: false
})"
min-width="100px"
min-width="100px"
sortable>
</el-table-column>
sortable>
</el-table-column>
<!--
<el-table-column
label=
"达成率"
<!--
<el-table-column
label=
"达成率"
...
@@ -167,11 +179,17 @@
...
@@ -167,11 +179,17 @@
align=
"center"
align=
"center"
min-width=
"100px"
min-width=
"100px"
sortable
sortable
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(cellValue, '', true, false)"
></el-table-column>
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(
{
value: cellValue,
round: false
})">
</el-table-column>
<el-table-column
label=
"销售额"
<el-table-column
label=
"销售额"
prop=
"week.salePrice"
prop=
"week.salePrice"
align=
"center"
align=
"center"
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(cellValue, '', true, false)"
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(
{
value: cellValue,
round: false
})"
min-width="100px"
min-width="100px"
sortable>
</el-table-column>
sortable>
</el-table-column>
</el-table-column>
</el-table-column>
...
@@ -184,11 +202,17 @@
...
@@ -184,11 +202,17 @@
align=
"center"
align=
"center"
min-width=
"120px"
min-width=
"120px"
sortable
sortable
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(cellValue, '', true, false)"
></el-table-column>
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(
{
value: cellValue,
round: false
})">
</el-table-column>
<el-table-column
label=
"日总额"
<el-table-column
label=
"日总额"
prop=
"last.salePrice"
prop=
"last.salePrice"
align=
"center"
align=
"center"
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(cellValue, '', true, false)"
:formatter=
"(row, cell, cellValue) => formatNumberWithUnit(
{
value: cellValue,
round: false
})"
min-width="100px"
min-width="100px"
sortable>
</el-table-column>
sortable>
</el-table-column>
</el-table-column>
</el-table-column>
...
@@ -287,7 +311,7 @@ const dict = proxy.useDict("sale_platform");
...
@@ -287,7 +311,7 @@ const dict = proxy.useDict("sale_platform");
const
allSeriesList
=
ref
([])
// 总系列列表
const
allSeriesList
=
ref
([])
// 总系列列表
const
prdTagList
=
ref
([])
// 总商品标签列表
const
prdTagList
=
ref
([])
// 总商品标签列表
const
platformSalesList
=
ref
([])
// 平台销售数据列表
const
platformSalesList
=
ref
([])
// 平台销售数据列表
const
platformSalesObj
=
{
// 平台销售数据对象(一套表图数据对应一个对象)
const
platformSalesObj
=
reactive
(
{
// 平台销售数据对象(一套表图数据对应一个对象)
queryParams
:
{
// 查询参数
queryParams
:
{
// 查询参数
prdTagId
:
undefined
,
prdTagId
:
undefined
,
seriesId
:
undefined
,
seriesId
:
undefined
,
...
@@ -326,7 +350,7 @@ const platformSalesObj = { // 平台销售数据对象(一套表图数据对
...
@@ -326,7 +350,7 @@ const platformSalesObj = { // 平台销售数据对象(一套表图数据对
data
:
[],
// 图表现在展示用数据
data
:
[],
// 图表现在展示用数据
xData
:
[],
// 日期(用于 x 轴)
xData
:
[],
// 日期(用于 x 轴)
}
}
}
}
)
const
{
pickerOptions
}
=
useDatePickerOptions
()
const
{
pickerOptions
}
=
useDatePickerOptions
()
const
uploadDemandImportVisible
=
ref
(
false
)
const
uploadDemandImportVisible
=
ref
(
false
)
const
uploadDemand
=
ref
({
// 上传货需数据对象
const
uploadDemand
=
ref
({
// 上传货需数据对象
...
@@ -353,7 +377,7 @@ const getSaleList = async (item) => {
...
@@ -353,7 +377,7 @@ const getSaleList = async (item) => {
platformId
:
o
.
platformId
,
platformId
:
o
.
platformId
,
targetSaleSum
:
o
.
targetSaleSum
,
targetSaleSum
:
o
.
targetSaleSum
,
YTD
:
{
YTD
:
{
saleNum
:
1398213.123
,
saleNum
:
o
.
saleCountY
,
salePrice
:
o
.
saleSumY
,
salePrice
:
o
.
saleSumY
,
goodsSupplyDemandCount
:
o
.
goodsSupplyDemandCountY
,
goodsSupplyDemandCount
:
o
.
goodsSupplyDemandCountY
,
// needNumPercentage: (formatNumberWithUnit(o.saleCountY, o.goodsSupplyDemandCountY) * 100).toFixed(2)
// needNumPercentage: (formatNumberWithUnit(o.saleCountY, o.goodsSupplyDemandCountY) * 100).toFixed(2)
...
@@ -400,7 +424,9 @@ const getSaleList = async (item) => {
...
@@ -400,7 +424,9 @@ const getSaleList = async (item) => {
}
}
})
})
// 默认先显示销售量数据
// 默认先显示销售量数据
item
.
chartData
.
data
=
item
.
chartData
.
saleCount
item
.
chartData
.
data
=
item
.
chartData
.
saleCount
console
.
log
(
'item.chartData.data'
,
item
.
chartData
.
data
)
item
.
loading
=
false
item
.
loading
=
false
}
}
...
@@ -453,16 +479,28 @@ const getSummaries = (param) => {
...
@@ -453,16 +479,28 @@ const getSummaries = (param) => {
},
0
);
},
0
);
if
(
column
.
property
.
includes
(
'saleNum'
))
{
if
(
column
.
property
.
includes
(
'saleNum'
))
{
// 带 Num 是量(后台字段在上面被我处理成其他字段名字了)
// 带 Num 是量(后台字段在上面被我处理成其他字段名字了)
return
sums
[
index
]
=
formatNumberWithUnit
(
sums
[
index
])
return
sums
[
index
]
=
formatNumberWithUnit
({
value
:
sums
[
index
],
round
:
false
})
}
else
if
(
column
.
property
.
includes
(
'salePrice'
))
{
}
else
if
(
column
.
property
.
includes
(
'salePrice'
))
{
// 带 Price 是价
// 带 Price 是价
return
sums
[
index
]
=
formatNumberWithUnit
(
sums
[
index
])
return
sums
[
index
]
=
formatNumberWithUnit
({
value
:
sums
[
index
],
round
:
false
})
}
else
if
(
column
.
property
.
includes
(
'targetSaleSum'
))
{
}
else
if
(
column
.
property
.
includes
(
'targetSaleSum'
))
{
// 合计销售目标
// 合计销售目标
return
sums
[
index
]
=
formatNumberWithUnit
(
sums
[
index
])
return
sums
[
index
]
=
formatNumberWithUnit
({
value
:
sums
[
index
],
round
:
false
})
}
else
if
(
column
.
property
.
includes
(
'goodsSupplyDemandCount'
))
{
}
else
if
(
column
.
property
.
includes
(
'goodsSupplyDemandCount'
))
{
// 货需量
// 货需量
return
sums
[
index
]
=
formatNumberWithUnit
(
sums
[
index
])
return
sums
[
index
]
=
formatNumberWithUnit
({
value
:
sums
[
index
],
round
:
false
})
}
else
if
(
column
.
property
.
includes
(
'needNumPercentage'
))
{
}
else
if
(
column
.
property
.
includes
(
'needNumPercentage'
))
{
// 达成率
// 达成率
return
sums
[
index
]
=
(
sums
[
index
]
/
data
.
length
).
toFixed
(
2
)
+
'%'
return
sums
[
index
]
=
(
sums
[
index
]
/
data
.
length
).
toFixed
(
2
)
+
'%'
...
@@ -507,7 +545,7 @@ const prdChange = async (item) => {
...
@@ -507,7 +545,7 @@ const prdChange = async (item) => {
}
}
// 创建查询某个系列/商品的套表
// 创建查询某个系列/商品的套表
const
createTableAndECharts
=
()
=>
{
const
createTableAndECharts
=
()
=>
{
let
item
=
reactive
(
deepClone
(
platformSalesObj
))
let
item
=
reactive
(
deepClone
(
toRaw
(
platformSalesObj
)
))
// 如果是第一套套表,默认填写日期
// 如果是第一套套表,默认填写日期
if
(
platformSalesList
.
value
.
length
===
0
)
{
if
(
platformSalesList
.
value
.
length
===
0
)
{
item
.
queryParams
.
date
=
[
new
Date
().
setDate
(
1
),
new
Date
().
setDate
((
new
Date
().
getDate
()
-
1
))]
// 默认查询和显示的是当月 1 号到 T-1 日期
item
.
queryParams
.
date
=
[
new
Date
().
setDate
(
1
),
new
Date
().
setDate
((
new
Date
().
getDate
()
-
1
))]
// 默认查询和显示的是当月 1 号到 T-1 日期
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论