|
|
@ -1,59 +1,12 @@ |
|
|
|
<template> |
|
|
|
<view class="u-font-14"> |
|
|
|
<!-- 0 未开始 --> |
|
|
|
<view |
|
|
|
class="flex items-center justify-center rounded-full icon-column" |
|
|
|
:class="[orderStyle.color]" |
|
|
|
v-if="status === 0" |
|
|
|
@tap="changeStatus($event, 0)" |
|
|
|
> |
|
|
|
<u-circle-progress :percent="100" active-color="#2979ff" bg-color="rgba(255,255,255,0)" border-width="4" width="66"> |
|
|
|
<view class="flex items-center justify-center rounded-full icon-column" :style="{ color: orderStyle.color }" @tap="changeStatus"> |
|
|
|
<u-circle-progress :percent="100" :active-color="orderStyle.color" bg-color="rgba(255,255,255,0)" border-width="4" width="66"> |
|
|
|
<view class="u-progress-content"> |
|
|
|
<view class="u-progress-dot"></view> |
|
|
|
<view class="u-progress-info"> |
|
|
|
<u-icon name="checkmark" size="30"></u-icon> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</u-circle-progress> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 1 进行中 --> |
|
|
|
<view class="flex items-center justify-center text-black rounded-full icon-column" v-if="status === 1" @tap="changeStatus($event, 1)"> |
|
|
|
<u-circle-progress :percent="80" active-color="#2979ff" bg-color="rgba(255,255,255,0)" border-width="6" width="66"> |
|
|
|
<view class="u-progress-content"> |
|
|
|
<view class="u-progress-dot"></view> |
|
|
|
<view class="u-progress-info">{{ time }}</view> |
|
|
|
</view> |
|
|
|
</u-circle-progress> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 2 暂停中 --> |
|
|
|
<view |
|
|
|
class="flex items-center justify-center text-gray-400 rounded-full icon-column" |
|
|
|
v-if="status === 2" |
|
|
|
@tap="changeStatus($event, 2)" |
|
|
|
> |
|
|
|
<u-circle-progress :percent="40" active-color="#2979ff" bg-color="rgba(255,255,255,0)" border-width="6" width="66"> |
|
|
|
<view class="u-progress-content"> |
|
|
|
<view class="u-progress-dot"></view> |
|
|
|
<view class="u-progress-info"> |
|
|
|
<u-icon name="play-right-fill" size="30"></u-icon> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</u-circle-progress> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 3 已完成 --> |
|
|
|
<view |
|
|
|
class="flex items-center justify-center font-black text-red-800 rounded-full icon-column" |
|
|
|
@tap="changeStatus($event, 3)" |
|
|
|
v-if="status === 3" |
|
|
|
> |
|
|
|
<u-circle-progress :percent="80" active-color="#2979ff" bg-color="rgba(255,255,255,0)" border-width="6" width="66"> |
|
|
|
<view class="u-progress-content"> |
|
|
|
<view class="u-progress-dot"></view> |
|
|
|
<view class="u-progress-info"> |
|
|
|
<u-icon name="pause" size="30"></u-icon> |
|
|
|
<u-icon :name="orderStyle.icon" v-if="orderStyle.icon" size="30"></u-icon> |
|
|
|
<template v-else>{{ time }}</template> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</u-circle-progress> |
|
|
@ -62,24 +15,19 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { mapMutations } from 'vuex'; |
|
|
|
|
|
|
|
// 任务状态 0未开始 1进行中 2暂停中 3已完成 |
|
|
|
|
|
|
|
// 颜色 |
|
|
|
// 图标 |
|
|
|
// 数字 |
|
|
|
import { mapState, mapMutations } from 'vuex'; |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'TimeStatus', |
|
|
|
props: { |
|
|
|
// status: { default: 0, type: Number }, |
|
|
|
content: { default: '', type: String }, |
|
|
|
status: { default: 0, type: Number }, |
|
|
|
taskName: { default: '', type: String }, |
|
|
|
taskId: { type: String, default: '' }, |
|
|
|
}, |
|
|
|
|
|
|
|
data() { |
|
|
|
return { |
|
|
|
status: 2, |
|
|
|
// status: 3, |
|
|
|
time: 20, |
|
|
|
start: [{ text: '确认开始任务', color: 'blue' }], |
|
|
|
pause: [{ text: '继续' }, { text: '重新开始任务', color: 'blue' }, { text: '结束' }], |
|
|
@ -89,51 +37,61 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
computed: { |
|
|
|
...mapState('task', ['tip']), |
|
|
|
// 图标文本颜色 |
|
|
|
// 任务状态 0未开始 1进行中 2暂停中 3已完成 |
|
|
|
orderStyle() { |
|
|
|
let color = 'text-gray-400'; |
|
|
|
let icon = ''; |
|
|
|
let color = '#9CA3AF'; |
|
|
|
let icon = 'play-right-fill'; |
|
|
|
switch (this.status) { |
|
|
|
case 1: // 进行中 |
|
|
|
color = 'text-blue-400'; |
|
|
|
color = '#60A5FA'; |
|
|
|
icon = ''; |
|
|
|
break; |
|
|
|
case 2: |
|
|
|
color = 'text-red-400'; |
|
|
|
case 2: // 暂停中 |
|
|
|
color = '#F87171'; |
|
|
|
icon = 'pause'; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
color = 'text-green-400'; |
|
|
|
case 3: // 已结束 |
|
|
|
color = '#34D399'; |
|
|
|
icon = 'checkmark'; |
|
|
|
break; |
|
|
|
default: |
|
|
|
// 未开始 |
|
|
|
color = 'text-gray-400'; |
|
|
|
color = '#9CA3AF'; |
|
|
|
icon = 'play-right'; |
|
|
|
break; |
|
|
|
} |
|
|
|
return { color }; |
|
|
|
return { color, icon }; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
...mapMutations('task', ['setClient', 'setTips', 'setStatus', 'setTipsContent']), |
|
|
|
...mapMutations('task', ['setTip']), |
|
|
|
|
|
|
|
chooseList() { |
|
|
|
return this.start; |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 点击了图标 修改任务状态 |
|
|
|
* @param {object} event |
|
|
|
*/ |
|
|
|
changeStatus(event) { |
|
|
|
const { status, taskId, taskName, tip } = this; |
|
|
|
tip.status = status; |
|
|
|
tip.taskId = taskId; |
|
|
|
tip.left = event.target.x; |
|
|
|
tip.top = event.target.y; |
|
|
|
tip.show = true; |
|
|
|
tip.text = this.genetateTips(status, taskName); |
|
|
|
|
|
|
|
changeStatus(e, num) { |
|
|
|
this.setStatus(num); |
|
|
|
this.setTipsContent(this.chooseTips(num, this.content)); |
|
|
|
const client = { |
|
|
|
left: e.target.x, |
|
|
|
top: e.target.y, |
|
|
|
}; |
|
|
|
this.setClient(client); |
|
|
|
this.setTips(true); |
|
|
|
this.setTip(tip); |
|
|
|
}, |
|
|
|
|
|
|
|
chooseTips(num, content) { |
|
|
|
switch (num) { |
|
|
|
/** |
|
|
|
* 计算tip的标题内容 |
|
|
|
*/ |
|
|
|
genetateTips(status, content) { |
|
|
|
switch (status) { |
|
|
|
case 0: |
|
|
|
return `确认开始任务${content}吗?`; |
|
|
|
return `确认开始任务"${content}"吗?`; |
|
|
|
case 1: |
|
|
|
return `请选择要执行的操作`; |
|
|
|
case 2: |
|
|
|