Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
merchant-manage-ui
Commits
17dddc9a
Commit
17dddc9a
authored
Jun 17, 2022
by
张子雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 解决倒计时更新不及时的问题
parent
ba135c72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
43 deletions
+54
-43
index.jsx
src/pages/AfterSaleManage/Pending/index.jsx
+54
-43
No files found.
src/pages/AfterSaleManage/Pending/index.jsx
View file @
17dddc9a
import
React
,
{
useState
,
useRef
}
from
'
react
'
;
import
{
notification
,
Button
,
Popconfirm
,
Modal
}
from
'
antd
'
;
import
{
notification
,
Button
,
Popconfirm
,
Modal
,
Statistic
}
from
'
antd
'
;
import
ProTable
from
'
@ant-design/pro-table
'
;
import
moment
from
'
moment
'
;
import
_
from
'
lodash
'
;
...
...
@@ -12,6 +12,8 @@ import { getDetail } from '../../afterSale/appeal/services';
import
AppealDetail
from
'
../../afterSale/components/detail
'
;
import
AfterLog
from
'
../components/AfterLog
'
;
const
{
Countdown
}
=
Statistic
;
const
{
confirm
}
=
Modal
;
export
default
()
=>
{
const
table
=
useRef
();
...
...
@@ -75,8 +77,7 @@ export default () => {
const
data
=
await
logisticsIntercept
({
serviceNo
:
r
.
serviceNo
});
if
(
data
.
businessCode
===
'
0000
'
)
{
notification
.
success
({
message
:
'
拦截成功
'
});
// eslint-disable-next-line no-unused-expressions
table
.
current
?.
reload
?.();
table
.
current
.
reload
();
}
else
{
notification
.
error
({
message
:
data
.
msg
||
'
拦截失败
'
});
}
...
...
@@ -86,39 +87,39 @@ export default () => {
},
});
};
const
renderContent
=
(
record
,
index
,
action
)
=>
{
if
(
!
time
[
record
.
serviceNo
])
{
const
serviceTime
=
moment
(
record
.
approvalEndTime
).
valueOf
();
const
nowTime
=
moment
(
record
.
nowTime
).
valueOf
();
let
timeNumber
=
(
serviceTime
-
nowTime
)
/
1000
;
time
[
record
.
serviceNo
]
=
setInterval
(()
=>
{
if
(
timeNumber
>
0
)
{
timeNumber
-=
1
;
// eslint-disable-next-line radix
const
hours
=
parseInt
(
timeNumber
/
3600
)
.
toString
()
.
padStart
(
2
,
'
0
'
);
// eslint-disable-next-line radix
const
minutes
=
parseInt
((
timeNumber
/
60
)
%
60
)
.
toString
()
.
padStart
(
2
,
'
0
'
);
// eslint-disable-next-line radix
const
seconds
=
parseInt
(
timeNumber
%
60
)
.
toString
()
.
padStart
(
2
,
'
0
'
);
const
str
=
`
${
hours
}
时
${
minutes
}
分
${
seconds
}
秒`
;
timeString
[
record
.
serviceNo
]
=
str
;
const
strings
=
_
.
cloneDeep
(
timeString
);
setTimeString
(
strings
);
}
else
{
clearInterval
(
time
[
record
.
serviceNo
]);
timeString
[
record
.
serviceNo
]
=
'
0时0分0秒
'
;
const
strings
=
_
.
cloneDeep
(
timeString
);
setTimeString
(
strings
);
}
},
1000
);
}
};
//
const renderContent = (record, index, action) => {
//
if (!time[record.serviceNo]) {
//
const serviceTime = moment(record.approvalEndTime).valueOf();
//
const nowTime = moment(record.nowTime).valueOf();
//
let timeNumber = (serviceTime - nowTime) / 1000;
//
time[record.serviceNo] = setInterval(() => {
//
if (timeNumber > 0) {
//
timeNumber -= 1;
//
// eslint-disable-next-line radix
//
const hours = parseInt(timeNumber / 3600)
//
.toString()
//
.padStart(2, '0');
//
// eslint-disable-next-line radix
//
const minutes = parseInt((timeNumber / 60) % 60)
//
.toString()
//
.padStart(2, '0');
//
// eslint-disable-next-line radix
//
const seconds = parseInt(timeNumber % 60)
//
.toString()
//
.padStart(2, '0');
//
const str = `${hours}时${minutes}分${seconds}秒`;
//
timeString[record.serviceNo] = str;
//
const strings = _.cloneDeep(timeString);
//
setTimeString(strings);
//
} else {
//
clearInterval(time[record.serviceNo]);
//
timeString[record.serviceNo] = '0时0分0秒';
//
const strings = _.cloneDeep(timeString);
//
setTimeString(strings);
//
}
//
}, 1000);
//
}
//
};
const
columns
=
[
{
title
:
'
审核倒计时
'
,
...
...
@@ -126,12 +127,22 @@ export default () => {
key
:
'
serviceTime
'
,
hideInSearch
:
true
,
width
:
150
,
render
:
(
val
,
record
,
index
,
action
)
=>
[
<
span
style=
{
{
color
:
'
red
'
}
}
>
{
renderContent
(
record
,
index
,
action
)
}
{
timeString
[
record
.
serviceNo
]
}
</
span
>,
],
// render: (val, record, index, action) => [
// <span style={{ color: 'red' }}>
// {renderContent(record, index, action)}
// {timeString[record.serviceNo]}
// </span>,
// ],
render
:
(
val
,
record
)
=>
{
const
serviceTime
=
moment
(
record
.
approvalEndTime
).
valueOf
();
return
(
<
Countdown
format=
"HH时mm分ss秒"
value=
{
serviceTime
}
valueStyle=
{
{
color
:
'
red
'
,
fontSize
:
'
14px
'
}
}
/>
);
},
},
{
title
:
'
售后状态
'
,
...
...
@@ -165,7 +176,7 @@ export default () => {
hideInSearch
:
true
,
dataIndex
:
'
action
'
,
width
:
250
,
//
fixed: 'right',
fixed
:
'
right
'
,
render
:
(
val
,
r
)
=>
[
<
Button
key=
"link1"
onClick=
{
()
=>
openAudit
(
r
)
}
className=
"mr10"
type=
"primary"
>
审核
...
...
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