Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_admin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_admin
Commits
d28bebd2
Commit
d28bebd2
authored
Dec 27, 2023
by
yaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 倒计时优化
parent
3449bdab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
142 additions
and
50 deletions
+142
-50
src/views/consign/components/NormalCountdown.vue
src/views/consign/components/NormalCountdown.vue
+138
-0
src/views/consign/consignList.vue
src/views/consign/consignList.vue
+4
-50
No files found.
src/views/consign/components/NormalCountdown.vue
0 → 100644
View file @
d28bebd2
<
template
>
<div
class=
"normalCountdown component__normalCountdown"
>
<span
style=
"color: red"
>
{{
formatTime
}}
</span>
</div>
</
template
>
<
script
>
export
default
{
name
:
'
NormalCountdown
'
,
props
:
{
last
:
{
type
:
Number
,
default
:
0
}
},
data
()
{
return
{
hh
:
'
00
'
,
mm
:
'
00
'
,
ss
:
'
00
'
,
ticker
:
null
,
timer
:
null
,
seckillTicker
:
null
,
seckillTimer
:
null
,
errTime
:
0
,
formatTime
:
''
}
},
created
()
{
if
(
this
.
last
)
{
this
.
startCountdown
()
}
},
destroyed
()
{
clearTimeout
(
this
.
timer
)
},
methods
:
{
startCountdown
()
{
this
.
initCountdown
()
const
mistiming
=
this
.
last
-
Date
.
now
()
if
(
mistiming
<
0
)
{
return
}
// if (!this.ticker) {
// this.ticker = createTicker()
// }
if
(
!
this
.
timer
)
{
this
.
timer
=
setInterval
(()
=>
{
const
deltaTime
=
this
.
last
-
(
Date
.
now
())
if
(
deltaTime
>
60
*
60
*
1000
)
{
this
.
formatTime
=
this
.
formatDuring
(
deltaTime
)
// const newTime = formatTime.split(':')
// if (newTime.length >= 3) {
// this.hh = newTime[0]
// this.mm = newTime[1]
// this.ss = newTime[2]
// this.zzz = null
// // this.showMS = false;
// }
}
else
if
(
deltaTime
>
0
)
{
this
.
ticker
.
clearInterval
(
this
.
timer
)
this
.
timer
=
null
}
},
1000
)
}
},
initCountdown
()
{
const
deltaTime
=
this
.
last
-
Date
.
now
()
-
this
.
errTime
this
.
formatTime
=
this
.
formatDuring
(
deltaTime
)
/* const newTime = formatTime.split(':')
if (newTime.length >= 3) {
this.hh = newTime[0] === '00' ? null : newTime[0]
this.mm = newTime[1]
this.ss = newTime[2]
// this.showMS = false;
}*/
},
formatDuring
(
mss
)
{
console
.
log
(
'
======mss=
'
,
mss
)
if
(
mss
>
0
)
{
const
hours
=
parseInt
((
mss
%
(
1000
*
60
*
60
*
24
))
/
(
1000
*
60
*
60
))
// 得到小时
const
minutes
=
parseInt
((
mss
%
(
1000
*
60
*
60
))
/
(
1000
*
60
))
// 得到分钟数
// 获取分钟
const
str1
=
minutes
<
10
?
(
'
0
'
+
minutes
)
:
minutes
// 得到秒数
const
seconds
=
parseInt
((
mss
%
(
1000
*
60
))
/
1000
)
const
str2
=
seconds
<
10
?
(
'
0
'
+
seconds
)
:
seconds
return
'
剩余
'
+
hours
+
'
:
'
+
str1
+
'
:
'
+
str2
}
else
{
return
'
已超时
'
}
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.component__normalCountdown
{
.countDown
{
margin-right
:
30px
;
&
__title
{
font-size
:
24px
;
font-weight
:
400
;
color
:
rgba
(
255
,
0
,
0
,
1
);
line-height
:
32px
;
text-align
:
right
;
margin-right
:
10px
;
margin-bottom
:
10px
;
}
&
__item
{
// margin-left: 18px;
&
:not
(
:first-child
)
{
margin-left
:
8px
;
}
}
&
__num
{
font-weight
:
600
;
color
:
rgba
(
255
,
0
,
0
,
1
);
border-radius
:
8px
;
font-size
:
15px
;
}
&
__text
{
font-size
:
24px
;
font-weight
:
500
;
color
:
rgba
(
255
,
0
,
0
,
1
);
line-height
:
15
;
margin-left
:
4px
;
}
}
}
</
style
>
src/views/consign/consignList.vue
View file @
d28bebd2
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
<el-table
<el-table
v-loading=
"listLoading"
v-loading=
"listLoading"
:data=
"list"
:data=
"list"
:key=
"itemKey"
size=
"small"
size=
"small"
element-loading-text=
"正在查询中..."
element-loading-text=
"正在查询中..."
border
border
...
@@ -49,7 +48,7 @@
...
@@ -49,7 +48,7 @@
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<div
v-if=
"!scope.row.isHasPrice"
>
暂无估价
</div>
<div
v-if=
"!scope.row.isHasPrice"
>
暂无估价
</div>
<div
v-if=
"scope.row.isHasPrice"
>
<div
v-if=
"scope.row.isHasPrice"
>
<
span
style=
"color: red"
>
{{
scope
.
row
.
intervalTime
}}
</span
>
<
NormalCountdown
:last=
"scope.row.timeStr"
/
>
</div>
</div>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
...
@@ -169,10 +168,12 @@ import ImageValueDialog from './components/ImageValueDialog'
...
@@ -169,10 +168,12 @@ import ImageValueDialog from './components/ImageValueDialog'
import
SaleConsignDialog
from
'
./components/SaleConsignDialog
'
import
SaleConsignDialog
from
'
./components/SaleConsignDialog
'
import
FinishSettlementDialog
from
'
./components/FinishSettlementDialog
'
import
FinishSettlementDialog
from
'
./components/FinishSettlementDialog
'
import
CancelConsignDialog
from
'
./components/CancelConsignDialog
'
import
CancelConsignDialog
from
'
./components/CancelConsignDialog
'
import
NormalCountdown
from
'
./components/NormalCountdown
'
export
default
{
export
default
{
name
:
'
ConsignList
'
,
name
:
'
ConsignList
'
,
components
:
{
components
:
{
NormalCountdown
,
CancelConsignDialog
,
CancelConsignDialog
,
FinishSettlementDialog
,
FinishSettlementDialog
,
SaleConsignDialog
,
SaleConsignDialog
,
...
@@ -229,7 +230,6 @@ export default {
...
@@ -229,7 +230,6 @@ export default {
finishDialogShow
:
false
,
finishDialogShow
:
false
,
// 寄售凭证
// 寄售凭证
finishSettlementDialogShow
:
false
,
finishSettlementDialogShow
:
false
,
itemContent
:
{},
// 取消
// 取消
cancelConsignDialogShow
:
false
,
cancelConsignDialogShow
:
false
,
currentSaleId
:
''
currentSaleId
:
''
...
@@ -246,7 +246,7 @@ export default {
...
@@ -246,7 +246,7 @@ export default {
// 清除所有定时器
// 清除所有定时器
clearAll
()
{
clearAll
()
{
if
(
this
.
list
)
{
if
(
this
.
list
)
{
this
.
list
.
forEach
(
el
=>
{
this
.
list
.
forEach
(
(
el
)
=>
{
clearInterval
(
el
.
countDown
)
clearInterval
(
el
.
countDown
)
})
})
}
}
...
@@ -270,12 +270,6 @@ export default {
...
@@ -270,12 +270,6 @@ export default {
this
.
list
=
response
.
data
.
data
.
dataList
this
.
list
=
response
.
data
.
data
.
dataList
this
.
total
=
response
.
data
.
data
.
total
this
.
total
=
response
.
data
.
data
.
total
this
.
listLoading
=
false
this
.
listLoading
=
false
if
(
this
.
listQuery
.
systemState
===
'
1
'
||
this
.
listQuery
.
systemState
===
'
8
'
)
{
this
.
itemKey
++
this
.
list
.
forEach
((
item
)
=>
{
this
.
countDown
(
item
)
})
}
}).
catch
((
e
)
=>
{
}).
catch
((
e
)
=>
{
this
.
list
=
[]
this
.
list
=
[]
this
.
total
=
0
this
.
total
=
0
...
@@ -294,7 +288,6 @@ export default {
...
@@ -294,7 +288,6 @@ export default {
*/
*/
handleImageValueDialogShow
(
item
)
{
handleImageValueDialogShow
(
item
)
{
this
.
imageValueDialogShow
=
true
this
.
imageValueDialogShow
=
true
this
.
itemContent
=
item
this
.
currentSaleId
=
item
.
saleId
this
.
currentSaleId
=
item
.
saleId
},
},
/**
/**
...
@@ -319,7 +312,6 @@ export default {
...
@@ -319,7 +312,6 @@ export default {
// 取消完成寄售
// 取消完成寄售
handleCancelFinishDialog
()
{
handleCancelFinishDialog
()
{
this
.
finishDialogShow
=
false
this
.
finishDialogShow
=
false
this
.
itemContent
=
{}
this
.
finishForm
=
{}
this
.
finishForm
=
{}
},
},
/**
/**
...
@@ -328,14 +320,12 @@ export default {
...
@@ -328,14 +320,12 @@ export default {
handleIdentifyValueDialogShow
(
item
)
{
handleIdentifyValueDialogShow
(
item
)
{
this
.
identifyValueDialogShow
=
true
this
.
identifyValueDialogShow
=
true
this
.
currentSaleId
=
item
.
saleId
this
.
currentSaleId
=
item
.
saleId
this
.
itemContent
=
item
},
},
/**
/**
* 货品售出
* 货品售出
*/
*/
handleFinishDialogShow
(
item
)
{
handleFinishDialogShow
(
item
)
{
this
.
finishDialogShow
=
true
this
.
finishDialogShow
=
true
this
.
itemContent
=
item
this
.
currentSaleId
=
item
.
saleId
this
.
currentSaleId
=
item
.
saleId
},
},
/**
/**
...
@@ -343,7 +333,6 @@ export default {
...
@@ -343,7 +333,6 @@ export default {
*/
*/
handleFinishSettlementDialogShow
(
item
)
{
handleFinishSettlementDialogShow
(
item
)
{
this
.
finishSettlementDialogShow
=
true
this
.
finishSettlementDialogShow
=
true
this
.
itemContent
=
item
this
.
currentSaleId
=
item
.
saleId
this
.
currentSaleId
=
item
.
saleId
},
},
/**
/**
...
@@ -351,42 +340,7 @@ export default {
...
@@ -351,42 +340,7 @@ export default {
*/
*/
handleCancelDialogShow
(
item
)
{
handleCancelDialogShow
(
item
)
{
this
.
cancelConsignDialogShow
=
true
this
.
cancelConsignDialogShow
=
true
this
.
itemContent
=
item
this
.
currentSaleId
=
item
.
saleId
this
.
currentSaleId
=
item
.
saleId
},
/** 倒计时*/
countDown
(
item
)
{
// acceptanceOverTime 是我后台返回的截止时间
if
(
new
Date
(
item
.
countdownTime
).
getTime
()
-
new
Date
().
getTime
()
<=
0
)
{
return
}
item
.
countDown
=
setInterval
(()
=>
{
if
(
new
Date
(
item
.
countdownTime
).
getTime
()
-
new
Date
().
getTime
()
<=
0
)
{
item
.
intervalTime
=
'
已超时
'
return
}
this
.
itemKey
++
item
.
intervalTime
=
this
.
formatDuring
(
new
Date
(
item
.
countdownTime
).
getTime
()
-
new
Date
().
getTime
())
},
1000
)
// 这边采取的是10秒调用一次
// 这里采用简单写法,直接在查询的时候调用一次,不用等定时器调用
item
.
intervalTime
=
this
.
formatDuring
(
new
Date
(
item
.
countdownTime
).
getTime
()
-
new
Date
().
getTime
())
},
formatDuring
(
mss
)
{
console
.
log
(
'
======mss=
'
,
mss
)
if
(
mss
>
0
)
{
const
hours
=
parseInt
((
mss
%
(
1000
*
60
*
60
*
24
))
/
(
1000
*
60
*
60
))
// 得到小时
const
minutes
=
parseInt
((
mss
%
(
1000
*
60
*
60
))
/
(
1000
*
60
))
// 得到分钟数
// 获取分钟
const
str1
=
minutes
<
10
?
(
'
0
'
+
minutes
)
:
minutes
// 得到秒数
const
seconds
=
parseInt
((
mss
%
(
1000
*
60
))
/
1000
)
const
str2
=
seconds
<
10
?
(
'
0
'
+
seconds
)
:
seconds
return
'
剩余
'
+
hours
+
'
:
'
+
str1
+
'
:
'
+
str2
}
else
{
return
'
已超时
'
}
}
}
}
}
}
}
...
...
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