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.
 
 
 
 
 

136 lines
3.8 KiB

<template>
<view class="column">
<view v-if="tasks && tasks.length">
<view :key="index" v-for="(task, index) in tasks">
<view class="flex">
<TimeStatus :task="task" />
<view class="flex items-center justify-between flex-1 ml-2 task-column">
<view>{{ $moment(+task.planStart).format(startTimeFormat) }}</view>
<!-- 任务功能菜单 -->
<TaskTools />
</view>
</view>
<view class="border-l-2 border-gray-300 plugin">
<view class="ml-3 overflow-hidden shadow-lg task-box">
<u-card
:show-foot="false"
:show-head="false"
:style="{ height: setHeight(task.panel) }"
@click="onClickTask(+task.planStart)"
class="h-16"
margin="0"
>
<!-- v-if="task.plugins && task.plugins.length" -->
<!-- 任务面板插件 -->
<view slot="body">
<!-- TODO: 逻辑不完善 -->
<view v-if="!task.plugins.length">
<skeleton :banner="false" :loading="true" :row="4" animate class="mt-2 u-line-2 skeleton"></skeleton>
</view>
<view class="p-0 u-col-between" v-else>
<view :key="pIndex" v-for="(row, pIndex) in task.plugins">
<view class="grid gap-2" v-if="row.length">
<Plugin
:class="getClass(plugin.col, plugin.row)"
:task="task"
:key="plugin.pluginTaskId"
:plugin-task-id="plugin.pluginTaskId"
:plugin-id="plugin.pluginId"
:param="plugin.param"
:style-type="styleType || 0"
v-for="plugin in row"
/>
</view>
</view>
</view>
</view>
</u-card>
</view>
</view>
</view>
</view>
<view v-else class="flex flex-row items-center ml-1">
<u-icon name="plus-circle" color="#2979ff" size="40" class="mr-2"></u-icon>
新建任务
</view>
<!-- 局部弹框操作栏 -->
<Tips />
</view>
</template>
<script>
import { mapState, mapMutations, mapGetters, mapActions } from 'vuex';
import Skeleton from '@/components/Skeleton/Skeleton';
import TimeStatus from './TimeStatus.vue';
import TaskTools from './TaskTools.vue';
export default {
name: 'TimeBox',
components: { TimeStatus, Skeleton, TaskTools },
data() {
return { currentComponent: '', styleType: 0 };
},
computed: {
...mapState('role', ['roleId']),
...mapState('task', ['timeUnit', 'tasks', 'taskLoading']),
...mapGetters('task', ['startTimeFormat']),
},
methods: {
...mapActions('task', ['getGlobal']),
...mapMutations('task', ['setTipsContent', 'setTipsContent', 'setTimeNode']),
// 设置任务面板高度
setHeight(panel) {
if (panel && panel.height) {
return panel.height + 'px';
} else {
return 'auto';
}
},
/**
* 点击了定期任务的面板 更新可变的日常任务
* @param {number} planStart 任务计划开始时间
*/
onClickTask(planStart) {
const param = { roleId: this.roleId, timeNode: planStart, timeUnit: this.timeUnit };
this.getGlobal(param);
},
// 设置网格布局
getClass(col, row) {
return [`row-span-${row}`, `col-span-${col}`];
},
},
};
</script>
<style scoped lang="scss">
.task-box {
border-radius: 24rpx;
}
.column {
padding: 24px 14px;
}
.task-column {
height: 33px;
}
.plugin {
margin-top: 8px;
margin-bottom: 8px;
margin-left: 15px;
}
/deep/ .ml-2 {
margin-left: 16px;
}
/deep/ .ml-3 {
margin-left: 20px;
}
</style>