You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
8.5 KiB

2 years ago
<template>
<div class="container">
<div class="header">
<p>代执行</p>
<div class="type">
<div class="type-item" v-for="item in statusType">
<div class="type-item__color" :style="{ 'background': item.color }"></div>
<p class="type-item__label">{{ item.label }}</p>
</div>
</div>
</div>
<el-scrollbar>
<div class="list">
<div v-for="(item, index) in toDo" :key="item.id" class="list-item" :class="`list-item-${timeStatusFormat(item)}`">
<div class="list-item__status">
<template v-if="timeStatusFormat(item) === 2">
<div class="list-item__status-2"></div>
<p>存在执行中指令</p>
</template>
<template v-else-if="timeStatusFormat(item) === 3">
<div class="list-item__status-3"></div>
<p>倒计时{{ $moment(item.start_time).diff($moment(time),'minutes') }}分钟</p>
</template>
<template v-else-if="timeStatusFormat(item) === 4">
<div class="list-item__status-4"></div>
<p>超时未执行</p>
</template>
<template v-else>
</template>
</div>
<div class="list-item__name">
{{ item.equipment_id_equipments_id_relation ? item.equipment_id_equipments_id_relation.name : '' }}
</div>
<div class="list-item__time">
执行时间{{ timeFormat(item.start_time) }}{{ timeFormat(item.end_time,'HH:mm') }}
</div>
<div class="list-item__last">预计时长 {{ $moment(item.end_time).diff($moment(item.start_time),'hours') }}</div>
<div class="list-item__operate">
<div v-for="(s, si) in status" class="step">
<div class="step-icon">
<div class="step-icon__cir" :class="`step-icon__cir-${stepFormat(item.status,s.value)}`"></div>
<div class="step-icon__line" :class="`step-icon__line-${stepFormat(item.status,s.value)}`" v-if="si < status.length-1"></div>
</div>
<div class="step-label">{{ s.label }}</div>
</div>
</div>
<Button type="primary" size="small" class="list-item__btn">查看</Button>
</div>
</div>
</el-scrollbar>
</div>
</template>
<script>
export default {
inject: ["transfers", "nowTime"],
data() {
return {
status: [
{
value: 2,
label: "已接收"
},
{
value: 3,
label: "已开启通知"
},
{
value: 4,
label: "已开启"
},
{
value: 5,
label: "确认关闭通知"
},
{
value: 6,
label: "确认关闭"
},
],
statusType: [
{
label: "存在执行中",
color: "linear-gradient(to top left,#527ded, #527ded43)",
},
{
label: "超时",
color: "linear-gradient(to top left,#d15d52, #d15d5243)"
},
{
label: "即将执行",
color: "linear-gradient(to top left,#ecc069, #ecc06943)"
}
]
}
},
methods: {},
computed: {
time () {
return this.nowTime()
},
toDo () {
console.log(this.transfers("toDo"))
return this.transfers("toDo")
},
timeFormat () {
return function (time,format='YYYY-MM-DD HH:mm') {
return this.$moment(time).format(format)
}
},
timeStatusFormat () {
return function (item) {
//1 普通 2 进行中 3 倒计时 4 超时
if (item.status === 3) {
return 2
}
const diffMins = this.$moment(item.start_time).diff(this.time,"minutes");
if (diffMins <= 5 && diffMins >= 0) {
return 3
}
if (diffMins < 0) {
return 4
}
return 1
}
},
stepFormat () {
return function (statue,s) {
const doneStatus = Array.from({ length: statue },((_,i) => (i + 1)))
if (statue === s) {
return "doing"
}
if (doneStatus.find(i => i === s)) {
return "done"
}
return false
}
}
},
}
</script>
<style scoped lang="scss">
.container {
background: #FFFFFF;
box-shadow: 5px 0px 20px 0px #234382;
border-radius: 0.67rem;
position: relative;
margin: 1.6rem 3.62rem 0 3.62rem;
}
.header {
font-size: 1.15rem;
height: 5.33rem;
display: flex;
align-items: center;
justify-content: space-between;
background: #F5F5F5;
border-radius: .67rem .67rem 0 0 ;
padding: 0 2rem;
p {
font-weight: 600;
}
.type {
display: flex;
&-item {
display: flex;
justify-content: center;
align-items: center;
margin-left: 2rem;
&__color {
width: 1.6rem;
height: 1.6rem;
border-radius: 3px;
margin-right: .6rem;
}
&__label {
font-weight: normal;
}
}
}
}
.list {
max-height: 56rem;
&-item {
font-size: 1.15rem;
display: flex;
align-items: center;
border-bottom: 1px #fff solid;
padding: 1.2rem 2rem;
&:nth-last-child(1) {
border-radius: 0 0 .67rem .67rem;
border-bottom: none;
}
$bkg-colors: #fff,linear-gradient(to bottom,#527ded18, #527ded28),linear-gradient(to bottom,#ecc06918, #ecc06928),linear-gradient(to bottom,#d15d5218, #d15d5228);
@for $i from 1 through length($bkg-colors) {
&-#{$i} {
background: nth($bkg-colors,$i);
@if $i == 3 {
border: 1px solid #d15d52aa;
border-bottom: 1px solid #d15d52aa !important;
& + & {
border-top: none;
}
}
}
}
&__status {
display: flex;
align-items: center;
font-weight: 600;
flex-basis: 10%;
$font-colors: #333, #527ded, #ecc069,#d15d52;
$colors: #fff,linear-gradient(to top left,#527ded, #527ded43),linear-gradient(to top left,#ecc069, #ecc06943),linear-gradient(to top left,#d15d52, #d15d5243);
@for $i from 1 through length($colors) {
&-#{$i} {
background: nth($colors,$i);
width: 1.28rem;
height: 1.28rem;
border-radius: 3px;
& + p {
color: nth($font-colors,$i);
}
}
}
}
&__name {
font-weight: 600;
font-size: 1.34rem;
flex: 1;
}
&__time {
flex-basis: 19%;
text-align: center;
}
&__last {
flex-basis: 7%;
text-align: center;
}
&__operate {
flex-basis: 31%;
display: flex;
align-items: center;
justify-content: center;
.step {
width: 6.6rem;
&-icon {
display: flex;
align-items: center;
justify-content: center;
position: relative;
&__cir {
width: 2.2rem;
height: 2.2rem;
background: #dcdcdc;
border-radius: 100%;
z-index: 2;
position: relative;
&-doing {
cursor: pointer;
transform: scale(.9, .9);
background: #6fc0af;
position: relative;
&::before {
content: "";
width: 132%;
height: 132%;
border-radius: 100%;
background: #6fc0af65;
transform: translate(-50%,-50%);
animation: scale infinite ease-out 4s;
position: absolute;
left: 50%;
top: 50%;
}
@keyframes scale {
0%,100% {
transform: translate(-50%,-50%);
}
50% {
transform: translate(-50%,-50%) scale(1.1,1.1);
}
}
}
&-done {
background: #7ccac8;
}
}
&__line {
width: 100%;
height: 2px;
background: #dcdcdc;
position: absolute;
left: 50%;
&-done {
background: #7ccac8;
}
}
}
&-label {
text-align: center;
font-size: 1.05rem;
line-height: 1.5;
margin-top: 4px;
}
}
}
&__btn {
font-size: 1.3rem;
height: 2.4rem;
width: 5rem;
background: #a4ddf0;
color: #333;
border-color: #a4ddf0;
}
}
}
</style>