Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linweijiong
jinfa-platform
Commits
dce56f71
Commit
dce56f71
authored
Nov 27, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:处理采购新建订单来自于商城下单商品数据显示异常
parent
8e6d9c5d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
3 deletions
+19
-3
index.ts
...s/transaction/purchaseOrder/orderCollect/effects/index.ts
+3
-0
useProductTable.tsx
...tion/purchaseOrder/orderCollect/model/useProductTable.tsx
+13
-2
type.ts
src/utils/type.ts
+3
-1
No files found.
src/pages/transaction/purchaseOrder/orderCollect/effects/index.ts
View file @
dce56f71
...
...
@@ -8,6 +8,7 @@ import { useUpdate } from '@umijs/hooks';
import
{
PublicApi
}
from
'@/services/api'
;
import
{
filterProductDataById
}
from
'../components/productModalTable'
import
{
getUnitPriceTotal
}
from
'../model/useProductTable'
;
import
{
toPercent
}
from
'@/utils/type'
;
// 异步填充表格字段
const
asyncPadDataForProduct
=
async
(
ctx
:
ISchemaFormActions
|
ISchemaFormAsyncActions
,
productValue
:
any
)
=>
{
...
...
@@ -176,6 +177,8 @@ export const useOrderFormInitEffect = (ctx: ISchemaFormActions | ISchemaFormAsyn
money
:
v
.
count
*
v
.
unitPrice
,
productId
:
v
.
id
,
memberId
:
initValue
.
supplyMembersId
,
// 添加 memberId 字段
commodityId
:
v
.
id
,
// 添加commodityId用于判断是商品价格是使用price字段还是unitPrice字段(也可判断是报价订单还是其他)
memberPrice
:
v
.
memberDiscount
!==
1
?
toPercent
(
v
.
memberDiscount
)
:
1
,
// 添加会员折扣
}
})))
}
...
...
src/pages/transaction/purchaseOrder/orderCollect/model/useProductTable.tsx
View file @
dce56f71
...
...
@@ -7,14 +7,26 @@ import { useModalTable } from './useModalTable';
import
{
usePageStatus
,
PageStatus
}
from
'@/hooks/usePageStatus'
;
import
{
toPoint
}
from
'@/utils/type'
;
// 对象按key排序(运用于商城传过来的阶梯价格排序)
export
const
sortByKey
=
(
params
)
=>
{
let
keys
=
Object
.
keys
(
params
).
sort
((
x
,
y
)
=>
parseInt
(
x
)
-
parseInt
(
y
));
let
newParams
=
{};
keys
.
forEach
((
key
)
=>
{
newParams
[
key
]
=
params
[
key
];
});
return
newParams
;
}
export
const
getUnitPriceTotal
=
(
record
)
=>
{
const
purchaseCount
=
Number
(
record
[
'purchaseCount'
])
||
0
console
.
log
(
record
,
purchaseCount
,
'rrr'
)
// fix 当没有传递unitPrice字段时 自动容错, 单价显示为0
record
.
unitPrice
=
record
.
unitPrice
||
record
.
price
||
0
if
(
typeof
record
.
unitPrice
===
'number'
)
{
return
record
.
unitPrice
*
purchaseCount
}
if
(
record
.
unitPrice
)
{
record
.
unitPrice
=
sortByKey
(
record
.
unitPrice
)
}
let
unitPrice
=
0
Object
.
entries
(
record
.
unitPrice
).
forEach
(([
key
,
value
])
=>
{
const
[
min
,
max
]
=
key
.
split
(
'-'
).
map
(
v
=>
Number
(
v
))
...
...
@@ -29,7 +41,6 @@ export const getUnitPriceTotal = (record) => {
}
})
// 考虑会员折扣
console
.
log
(
'算价格'
,
record
.
memberPrice
)
let
memberPrice
=
record
.
memberPrice
!==
1
?
toPoint
(
record
.
memberPrice
)
:
1
return
unitPrice
*
purchaseCount
*
memberPrice
}
...
...
src/utils/type.ts
View file @
dce56f71
...
...
@@ -11,7 +11,8 @@ export const toPoint = (percent: string) => {
// 小数转分数
export
const
toPercent
=
(
point
:
number
)
=>
{
let
str
=
Number
(
point
*
100
).
toFixed
(
1
);
// let str = Number(point * 100).toFixed(1);
let
str
=
Number
(
point
*
100
);
str
+=
"%"
;
return
str
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment