StepList.vue
4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<template>
<div>
<van-list v-model="loading" :finished="finished" finished-text="没有更多了" loading-text="上划加载更多">
<van-cell v-for="(item, index) in wList" :key="index">
<!-- 时间 -->
<p class="f12" style="position:relative; ">
{{ dateFormat(item[0].createTime, 'yyyy-MM-dd w') }}
<!-- {{item1.trajectoryType}} -->
</p>
<!-- <van-cell> -->
<van-steps
direction="vertical"
inactive-color="#2c8cf0"
:active="active"
v-for="(item1, index) in item"
:key="index"
>
<van-step class="msg">
<span class="f12 po"> {{ dateFormat(item[0].createTime, 'hh:mm') }}</span>
<span class="fs14">{{ chargeType(item1.trajectoryType) }}</span>
<span class="finish-box">
<span class="finish" v-if="item1.trajectoryType == 4 && item1.status != 3" @click="finDynamic(item1.id)"
>完成</span
>
<span class="deldynamic" @click="delDynamic(item1.id)">删除</span>
</span>
<p class="fs14 con ">{{ item1.content }}</p>
</van-step>
<!-- <van-step>
<span class="f12 po"> 12:40</span>
<span class="fs14">社交动态</span>
<span class="deldynamic">删除</span>
<p class="fs14 con ">编辑编辑</p>
</van-step> -->
</van-steps>
</van-cell>
<!-- <van-divider /> -->
</van-list>
</div>
</template>
<script>
import { removeTrajectory, handleWait } from '@/api/portrait'
import { dateFormat } from '@/utils'
export default {
props: ['stepList'],
inject: ['reload'],
data() {
return {
// 步骤条
active: -1,
// 轨迹外层按时间
wlist: [],
content: '',
type: 0,
wList: [],
finished: false,
loading: false,
dateFormat
}
},
watch: {
stepList(newVal, oldVal) {
// console.log(newVal, oldVal);
this.wList = []
let dayList = []
newVal.forEach((ele) => {
let date = this.dateFormat(ele.createTime, 'yyyyMMdd')
dayList.includes(date) || dayList.push(date)
})
dayList.sort((a, b) => b - a)
for (let i = 0; i < dayList.length; i++) {
let timeList = []
for (let j = 0; j < newVal.length; j++) {
// console.log(newVal[j].createTime);
if (dayList[i] == this.dateFormat(newVal[j].createTime, 'yyyyMMdd')) {
timeList.push(newVal[j])
}
}
this.wList.push(timeList)
}
this.loading = false
this.finished = true
// console.log(this.wlist);
// this.onLoad()
}
},
methods: {
onLoad() {
// // 异步更新数据
// // setTimeout 仅做示例,真实场景中一般为 ajax 请求
// setTimeout(() => {
// // debugger
// let total = this.wlist.length > 10 ? 10 : this.wlist.length
// for (let i = 0; i < total; i++) {
// this.wList.push(this.wlist[i])
// }
// console.log(this.wList)
// // 加载状态结束
// this.loading = false
// // 数据全部加载完成
// if (this.wList.length >= this.wlist.length) {
// this.finished = true
// }
// }, 1000)
},
// 根据数字判断类型
chargeType(num) {
if (num == 1) {
return (this.type = '信息动态')
} else if (num == 2) {
return (this.type = '社交动态')
} else if (num == 3) {
return (this.type = '活动规则')
} else if (num == 4) {
return (this.type = '待办动态')
}
},
// 删除轨迹
delDynamic(id) {
this.$dialog
.confirm({
title: '警告',
message: '确定要删除吗?'
})
.then(() => {
return removeTrajectory(id)
})
.then((data) => {
this.$toast.success('删除成功')
// 重新获取全部数据
this.$emit('reload')
})
.catch(() => {
// on cancel
})
},
// 点击完成
finDynamic(id) {
handleWait(id)
.then((data) => {
this.$emit('reload')
})
.catch((err) => {
console.log(err)
})
}
}
}
</script>
<style lang="less" scoped>
.f12 {
color: #9c9c9c;
font-size: 12px;
font-weight: 600;
}
/deep/.msg {
&::after {
border: none;
}
.po {
position: relative;
}
}
.fs14 {
color: #333;
font-size: 14px;
position: relative;
left: 20px;
}
.deldynamic {
float: right;
color: #9c9c9c;
font-size: 12px;
font-weight: 600;
}
.con {
left: 51px;
margin-top: 20px;
}
.finish-box {
float: right;
position: relative;
width: 80px;
}
.finish {
position: absolute;
color: #2c8cf0;
font-size: 12px;
font-weight: 600;
// right: 30px;
// top: 0px;
}
</style>