1.2.13 • Published 4 years ago

z-gantt v1.2.13

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

甘特图

业务组件

preview

安装

npm install z-gantt --save

demo

npm install
npm run serve

example

编译

npm run lib

使用

example:

<gantt
    show-tree :type="type"
    :data="data"
    :theme="theme"
    :start="start"
    :hide-holiday="hideHoliday"
    :loading="loading
    :max="max"
    :cellWidth="cellWidth"
    :cellHeight="cellHeight"
    :ghost="ghost"
    :show-desc="showDesc"
    :merge="merge"
    @change="refresh"
    :is-holiday="isHoliday"
>
  <div slot="tooltip" slot-scope="{row, cell}">
    <p>项目名:{{row.name}}</p>
    <p>开发团队:{{row.team || '--'}}</p>
    <p>开发人员:{{cell.user || '--'}}</p>
    <p>开始日期:{{cell.start}}</p>
    <p>结束日期:{{cell.end}}</p>
  </div>
</gantt>

import Gantt from 'z-gantt'
import 'z-gantt/lib/gantt.css'

export default {
  data () {
    return {
      hideHoliday: false,
      type: 'day',
      theme: 'blue',
      ghost: false,
      max: 20,
      cellWidth: 80,
      cellHeight: 30,
      start: '2020-04-30',
      data: [
        {
          data: [
            {
              start: '2020-04-30',
              end: '2020-05-15',
              msg: '项目周期'
            },
          ],
          id: 1,
          name: '项目',
          expand: false,
        },
        {
          data: [
            {
              start: '2020-04-30',
              end: '2020-05-04',
              msg: 'UI设计',
              user: '张三',
            },
            {
              start: '2020-05-01',
              end: '2020-05-02',
              msg: '数据库设计',
              user: '李四',
            },
            {
              start: '2020-05-02',
              end: '2020-05-10',
              msg: '后端',
              user: '李四',
            },
            {
              start: '2020-05-04',
              end: '2020-05-10',
              msg: '前端',
              user: '王五',
            },
            {
              start: '2020-05-10',
              end: '2020-05-15',
              msg: '前后端联调',
              user: '张三,王五',
            },
          ],
          parent: 1,
          id: 2,
          name: '我的自家院子项目',
          team: 'xxx团队',
          expand: false,
        },
        {
          data: [],
          id: 3,
          name: '具体计划',
          expand: false,
        },
        {
          data: [
            {
              start: '2020-05-04',
              end: '2020-05-06',
              msg: '主页'
            },
            {
              start: '2020-05-05',
              end: '2020-05-07',
              msg: '发现'
            },
            {
              start: '2020-05-07',
              end: '2020-05-10',
              msg: '我的'
            },
            {
              start: '2020-05-10',
              end: '2020-05-15',
              msg: '联调'
            },
          ],
          id: 4,
          parent: 3,
          name: '前端',
          expand: false,
        },
        {
          data: [
            {
              start: '2020-04-30',
              end: '2020-05-02',
              msg: '数据库设计'
            },
            {
              start: '2020-05-02',
              end: '2020-05-10',
              msg: '接口设计'
            },
            {
              start: '2020-05-10',
              end: '2020-05-15',
              msg: '联调'
            },
          ],
          id: 5,
          parent: 3,
          name: '后端',
          expand: false,
        },
      ],
      showDesc: false,
      merge: false,
      colors: [
        '#7BBFF9',
        '#89A6F8',
        '#AA84E4',
        '#F08DBE',
        '#EF7F79',
        '#F2A077',
        '#F7C177',
        '#FAD678',
        '#FEF47D',
        '#DAEF77',
        '#A6DB74',
        '#7ED8D2',
      ],
    }
  },
}

API

props

属性说明类型默认值
data甘特图数据Array[]
type类型: day,hour,month,year 暂时只支持dayStringday
theme主题: yellow,blue,greenStringyellow
cellWidth单元格宽度Number78
cellHeight单元格高度Number30
max最大显示范围Number20
start开始日期Number,String2020-5-1
step左右加载步进Number5
hideHoliday是否因此节假日Booleanfalse
loading是否显示加载框Booleanfalse
ghost是否镂空单元格Booleanfalse
merge是否合并单元格(会导致相互重叠)Booleanfalse
showDesc是否合显示描述Booleantrue
showTree是否树形展示,暂支持2层嵌套,必须要有id,parent字段Booleanfalse
colors自定义单元格颜色,按顺序取余,默认主题色Array[]
isHoliday自定义节假日函数,默认周六日,返回Boolean值Functiondate=>0,6.includes(date.day())

slots

名称说明参数
aside-title左侧大标题-
aside-row侧边栏每一行,showTree为false才有该slotslot-scope="{row}"
cell单元格slot-scope="{rowIndex, cellIndex}"
desc单元格描述slot-scope="{row, cell}"
cell-block单元格中每个日期块slot-scope="{row}"
tooltip提示框slot-scope="{row, cell, date}"

events

时间名称说明-
change{startDate: 开始日期, type: 操作类型(向左向右), range: 范围}@change="change"
1.2.12

4 years ago

1.2.13

4 years ago

1.2.11

4 years ago

1.2.9

4 years ago

1.2.10

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.1.0

5 years ago