计划软件 - hours
计划软件右侧hours, vue3版本
安装
npm install @codernote/plan-hours-vue3
使用
<template>
<PlanHours
:hoursMap="hoursMap"
:day="hoursFocusIdx"
:show="showHours"
:importType="1"
@hide="handleHideHours"
@updateHoursInfo="updateHoursInfo"
@taskStatusChange="taskStatusChange"
/>
</template>
<script>
import {
PlanHours,
hoursConstant,
} from "@codernote/plan-hours";
const getCurrentDayIdx = () => {
const dayTimeStamp = 24 * 60 * 60 * 1000
const beginTime = new Date('1987/01/01 00:00:00').getTime()
const pastTime = Date.now() - beginTime
return parseInt(pastTime / dayTimeStamp)
}
export default {
components: {
PlanHours,
},
data() {
return {
showHours: false,
hoursFocusIdx: getCurrentDayIdx(),
hoursMap: {
level1: [],
level2: [],
level3: []
},
}
},
mounted() {
this.initData()
},
methods: {
initData() {
this.hoursMap = {
level1: [
{
"bold": 1,
"finish": 0,
"desc": "重要任务",
"idx": this.hoursFocusIdx,
"item_id": "1720970094340",
"isAssigned": 1,
"assignStartTime": "11:58",
"assignEndTime": "12:58",
"type": 6,
"created_at": 1720970102545,
"updated_at": 1720970102545,
"deleted_at": 0,
"lastInsertRowid": 33,
"success": true
}
],
level2: [
{
"item_id": "1720967835253",
"type": 6,
"idx": this.hoursFocusIdx,
"desc": "任务2",
"finish": 0,
"bold": 1,
"isAssigned": 1,
"assignStartTime": "13:58",
"assignEndTime": "14:58",
"created_at": 1720969641966,
"updated_at": 1720970065241,
"deleted_at": 0
}
],
level3: [
{
"idx": this.hoursFocusIdx,
"desc": "临时任务",
"finish": 0,
"assignStartTime": "15:26",
"assignEndTime": "16:26",
"created_at": 1720961199752,
"updated_at": 1720961200251,
"deleted_at": 0,
"level": "level3",
"item_id": "1720961199752",
"top": "395.8705882352941",
"height": "46.94117647058823"
}
]
}
this.showHours = true
},
handleHideHours() {
this.showHours = false
},
updateHoursInfo(data = {}) {
this.hoursMap = data
},
taskStatusChange(enter) {
const { tableName, action, item } = enter
switch(action) {
case hoursConstant.ARRANGE_TASK_TYPE.add:
console.log('添加', tableName, item)
break;
case hoursConstant.ARRANGE_TASK_TYPE.update:
console.log('修改', tableName, item)
break;
case hoursConstant.ARRANGE_TASK_TYPE.del:
console.log('删除', tableName, item)
break;
}
}
}
}
</script>
props
<PlanHours
{}
:day="hoursFocusIdx"
{}
:hoursMap="{
// 🌟 重点任务
level1: [], // goalTree表,根据条件查询 filter: { isAssigned: 1, type: 6, idx: hoursFocusIdx, bold: 1}
// 🌟 已安排的任务
level2: [], // goalTree表,根据条件查询 filter: { isAssigned: 1, type: 6, idx: hoursFocusIdx, bold: 0}
// 🌟 临时任务
level3: [] // hoursInfo表, 根据条件查询 filter: { idx: hoursFocusIdx }
}"
{}
:show="true"
{}
:disabled="false"
{}
:isWidthTransition="false"
{}
:importType="1"
{}
:openBottomMenu="true"
{}
:headConf="{
dateShow: true, // 日期显示
clockStart: 7, // 开始钟点时间
clockEnd: 24, // 结束钟点时间
clockShow: true, // 显示钟点区间
closeShow: true, // 显示关闭按钮
}"
{}
:themeColor="{
timeScale: '#e7e7e7', // 时间轴背景色
timeLine: 'green', // 时间线颜色
taskBorderColor: '#008080', // 任务active边框色
task1Back: '#909399', // 左侧任务背景色
task2Back: '#c0c4cc', // 中间任务背景色
task3Back: '#e4e7ed', // 右侧任务背景色
}"
{}
@hide="handleHideHours"
{}
@updateHoursInfo="updateHoursInfo"
{}
@taskStatusChange="taskStatusChange"
/>
helper
const getCurrentDayIdx = () => {
const dayTimeStamp = 24 * 60 * 60 * 1000
const beginTime = new Date('1987/01/01 00:00:00').getTime()
const pastTime = Date.now() - beginTime
return parseInt(pastTime / dayTimeStamp)
}
constants
const MEASURE_ENUM = {
lives: 0,
expect: 1,
year: 2,
quarter: 3,
month: 4,
week: 5,
day: 6
}
发布
npm publish