1.0.22 • Published 3 years ago

vue-calendar-by-week v1.0.22

Weekly downloads
52
License
MIT
Repository
github
Last release
3 years ago

vue-calendar-by-week

为用户提供周日历日程表设计,用户可通过自由拖动选区建立日程事件。

使用

npm install vue-calendar-by-week
// 或者
yarn add vue-calendar-by-week
// vue项目入口文件main.js内
import CalendarByWeek from "vue-calendar-by-week";
Vue.use(CalendarByWeek);
<!-- 需要引入日程表的地方 -->
<CalendarByWeek
  ref="myCalendar"
  :granularity="10"
  :start-time="8"
  :end-time="22"
  start-date="2020/11/23"
  :data="list"
  :readonly="false"
  @on-selected="onSelected"
  @on-contextmenu="onContextMenu"
/>

Calendar props

属性说明类型默认值
granularity单位时间间隔颗粒度,需要可平分 1 个小时,如:10,30,15 等Number/String30
data显示的结构化数据,表示日程表记录,具体格式见后文Array[]
start-date必填,开始日期,本日程表目前以周为单位进行设计,展示该日期往后一周的日历String-
unit-time日程表单位时间,整数,以小时为单位Number/String1
start-time日程表单位开始时间,目前仅支持整点,24 小时制Number/String0
end-time日程表单位结束时间,目前仅支持整点,24 小时制Number/String24
readonly日程表表格操作状态,为 true 时仅作展示使用Booleantrue
disabled-time设置不可选择的时间段,函数,参数为当前时间段,需要返回 Boolean 是否禁用该时间段,具体见后文Function小于当前时间均不可选
need-bottom-time底部结束时间Booleanfalse
has-header是否显示表格头部Booleantrue
space-line单元格间隙横线粗细X(表示Xpx solid #eeeeee)Number0

Calendar events

事件名说明返回值
on-selected拖动选取时间段单元格完成时触发object,选中的资源对象,内容包括时间段和日期等
on-contextmenu日程记录右击事件rowrecordevent
on-error日程表格错误反馈msg

Calendar methods

事件名说明参数
cancelSelect清除当前选择

Calendar slot

名称说明属性
thead日历表格头部内容item,对象格式,{date:'日期',day:'周几'}
item日程项,可自定义设置日程内容item,日程条目,具体见下文data
contextMenu右键菜单

如:

<!-- item -->
<template slot="item" slot-scope="slotProps">
  <div class="slot-item">
    {{slotProps.item.time}}<br />{{slotProps.item.content}}
  </div>
</template>

data

结构化记录描述数据对象,是 data 内的一项

属性说明类型默认值
id日程记录主键String-
date日程日期,YY/MM/DDString-
start_time日程开始时间点,hh:mmString-
end_time日程结束时间点,hh:mmString-
content日程内容String-

disabled-time

设置不可选择的时间段,参数为当前时间段time,需要返回 Boolean 是否禁用该时间段,time(YYYY/MM/DD HH:mm:ss)表示当前时间颗粒的开始时间。

如:

<template>
    <CalendarByWeek disabled-time="disabledTime" />
</template>
<script>
export default {
    data() {
        return {
            disabledTime: function(time) {
                let currentTime = new Date().getTime();
                let start_time = new Date(time).getTime();
                return currentTime < start_time;
            }
        }
    }
}
</script>

设计

提供一个整体表格的二维数组,根据 granularity 和 unit-time。

日程记录 record,关于渲染的内容:

{
  "id": "",
  "start_time": "",
  "end_time": "",
  "content": ""
}
1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago