diff --git a/CHANGELOG.md b/CHANGELOG.md
index 87ce669..d1c7c3c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [1.4.6] - 2025-12-09
+
+### Fixed
+- 修复:内置TaskDrawer中负责人列表可以外部初始化
+- Fixed: The assignee list in the built-in TaskDrawer can be initialized externally
+
## [1.4.5] - 2025-12-06
### Changed
diff --git a/README-EN.md b/README-EN.md
index 1118b09..9b67581 100644
--- a/README-EN.md
+++ b/README-EN.md
@@ -23,7 +23,8 @@
中文 |
- English
+ English |
+ Release Notes
A modern Vue 3 Gantt chart component library providing complete solutions for project management and task scheduling
@@ -188,8 +189,9 @@ npm run dev
| `useDefaultDrawer` | `boolean` | `true` | Whether to use the built-in task edit drawer (TaskDrawer) |
| `useDefaultMilestoneDialog` | `boolean` | `true` | Whether to use the built-in milestone edit dialog (MilestoneDialog) |
| `autoSortByStartDate` | `boolean` | `false` | Whether to automatically sort tasks by start date |
-| `allowDragAndResize` | `boolean` | `true` | Whether to allow dragging and resizing tasks/milestones |
-| `enableTaskRowMove` | `boolean` | `false` | Whether to alloww dragging and dropping TaskRow
+| `allowDragAndResize` | `boolean` | `true` | Whether to allow dragging and resizing tasks/milestones |
+| `enableTaskRowMove` | `boolean` | `false` | Whether to allow dragging and dropping TaskRow |
+| `assigneeOptions` | `Array<{ key?: string \| number; value: string \| number; label: string }>` | `[]` | Assignee dropdown options in task edit drawer |
#### Configuration Object Props
@@ -251,7 +253,7 @@ For complete event documentation, see:
```vue
-
+
@@ -269,6 +271,12 @@ const tasks = ref([
progress: 100,
},
])
+
+const assigneeOptions = ref([
+ { value: 'alice', label: 'Alice' },
+ { value: 'bob', label: 'Bob' },
+ { value: 'charlie', label: 'Charlie' },
+])
```
@@ -277,7 +285,7 @@ const tasks = ref([
```vue
-
+
@@ -305,6 +313,12 @@ const milestones = ref([
icon: 'diamond',
},
])
+
+const assigneeOptions = ref([
+ { value: 'alice', label: 'Alice' },
+ { value: 'bob', label: 'Bob' },
+ { value: 'charlie', label: 'Charlie' },
+])
```
@@ -325,6 +339,7 @@ const milestones = ref([
:tasks="tasks"
:milestones="milestones"
:show-toolbar="false"
+ :assignee-options="assigneeOptions"
@task-added="handleTaskAdded"
@milestone-saved="handleMilestoneSaved"
/>
@@ -340,6 +355,12 @@ import 'jordium-gantt-vue3/dist/assets/jordium-gantt-vue3.css'
const tasks = ref([])
const milestones = ref([])
+const assigneeOptions = ref([
+ { value: 'alice', label: 'Alice' },
+ { value: 'bob', label: 'Bob' },
+ { value: 'charlie', label: 'Charlie' },
+])
+
const addTask = () => {
const newTask = {
id: Date.now(),
@@ -387,7 +408,8 @@ Tasks are the core elements of the Gantt chart. The component provides complete
| `endDate` | `string` | - | - | End date, format: 'YYYY-MM-DD' or 'YYYY-MM-DD HH:mm' |
| `progress` | `number` | - | `0` | Task progress, range 0-100 |
| `predecessor` | `number[]` | - | - | Array of predecessor task IDs, standard format: `[1, 2, 3]` **Compatible formats**: Also supports string `'1,2,3'` or string array `['1', '2', '3']`, component will auto-parse |
-| `assignee` | `string` | - | - | Task assignee |
+| `assignee` | `string` | - | - | Task assignee, used as the value binding for the assignee dropdown menu |
+| `assigneeName` | `string` | - | - | Task assignee name, automatically obtained from the label in the bound `assigneeOptions` dataset; for custom display, you can set it in the `task-added` callback event of GanttChart |
| `avatar` | `string` | - | - | Avatar URL of task assignee |
| `estimatedHours` | `number` | - | - | Estimated hours |
| `actualHours` | `number` | - | - | Actual hours |
@@ -426,7 +448,8 @@ Tasks are the core elements of the Gantt chart. The component provides complete
| `taskBarConfig` | `TaskBarConfig` | `{}` | Task bar style configuration, see [TaskBarConfig Configuration](#taskbarconfig-configuration) |
| `taskListConfig` | `TaskListConfig` | `undefined` | Task list configuration, see [TaskListConfig Configuration](#tasklistconfig-configuration) |
| `autoSortByStartDate` | `boolean` | `false` | Whether to automatically sort tasks by start date |
-| `enableTaskRowMove` | `boolean` | `false` | Whether to alloww dragging and dropping TaskRow
+| `enableTaskRowMove` | `boolean` | `false` | Whether to alloww dragging and dropping TaskRow |
+| `assigneeOptions` | `Array<{ key?: string \| number; value: string \| number; label: string }>` | `[]` | Assignee dropdown options in task edit drawer |
**Configuration Notes**:
@@ -467,6 +490,7 @@ Tasks are the core elements of the Gantt chart. The component provides complete
([
},
])
+const assigneeOptions = ref([
+ { value: 'alice', label: 'Alice' },
+ { value: 'bob', label: 'Bob' },
+ { value: 'charlie', label: 'Charlie' },
+])
+
// Toolbar "Add Task" button click event
const handleAddTask = () => {
console.log('Preparing to add task...')
@@ -556,6 +586,7 @@ Tasks can configure predecessors via the `predecessor` field, and the component
@@ -618,6 +649,12 @@ const tasks = ref([
},
])
+const assigneeOptions = ref([
+ { value: 'alice', label: 'Alice' },
+ { value: 'bob', label: 'Bob' },
+ { value: 'charlie', label: 'Charlie' },
+])
+
// Triggered when adding predecessor via context menu
const handlePredecessorAdded = (event: { targetTask: Task; newTask: Task }) => {
console.log(`Task [${event.targetTask.name}] added predecessor [${event.newTask.name}]`)
@@ -671,6 +708,7 @@ Suitable for scenarios requiring complete custom control bar:
:show-toolbar="false"
:use-default-drawer="true"
:use-default-milestone-dialog="true"
+ :assignee-options="assigneeOptions"
@add-task="handleAddTask"
@add-milestone="handleAddMilestone"
@task-added="handleTaskAdded"
@@ -686,6 +724,12 @@ import 'jordium-gantt-vue3/dist/assets/jordium-gantt-vue3.css'
const tasks = ref([])
const milestones = ref([])
+const assigneeOptions = ref([
+ { value: 'alice', label: 'Alice' },
+ { value: 'bob', label: 'Bob' },
+ { value: 'charlie', label: 'Charlie' },
+])
+
// Custom button triggers event (component will respond and open built-in editor)
const triggerAddTask = () => {
// Directly trigger component's add-task event
@@ -729,6 +773,7 @@ Allow users to adjust task hierarchy and order by dragging TaskRow:
@@ -765,6 +810,12 @@ const tasks = ref([
},
])
+const assigneeOptions = ref([
+ { value: 'alice', label: 'Alice' },
+ { value: 'bob', label: 'Bob' },
+ { value: 'charlie', label: 'Charlie' },
+])
+
// Task row drag completed event (optional)
const handleTaskRowMoved = async (payload: {
draggedTask: Task
@@ -1248,6 +1299,54 @@ const handleDelete = () => {
This section details the configuration options and extension capabilities of the GanttChart component, including Component Configuration, Theme & Internationalization, and Custom Extensions.
+### Task Type Definition
+
+Task type (`type` field) is used to distinguish different types of tasks, and the component internally executes different logic based on the type.
+
+#### Built-in Task Types
+
+| Type | Description | Default |
+| ------- | ------------- | ------- |
+| `story` | User Story | - |
+| `task` | Regular Task | ✅ |
+| `bug` | Bug/Issue | - |
+
+#### Feature Differences
+
+Different task types have different functional characteristics in the component:
+
+| Feature | story | task | bug |
+| -------------------- | ----- | ---- | --- |
+| Can be parent task | ✅ | ✅ | ❌ |
+| Can be predecessor | ❌ | ✅ | ❌ |
+| Timer support | ❌ | ✅ | ✅ |
+| Auto parent task | ✅ | ❌ | ❌ |
+| Special delete hint | ✅ | ❌ | ❌ |
+
+#### Important Notes
+
+> ⚠️ **Important**
+>
+> 1. Task type values are used for internal component logic, **do not modify** these enum values arbitrarily
+> 2. When customizing TaskDrawer, you must maintain these three enum values: `story`, `task`, `bug`
+> 3. For additional business labels, use custom property fields such as: `customType`, `category`, `label`, etc.
+
+**Example: Using Custom Labels**
+
+```typescript
+const tasks = ref([
+ {
+ id: 1,
+ name: 'Requirements Analysis',
+ type: 'task', // Keep built-in component type
+ customType: 'requirement', // Custom business type
+ category: 'analysis', // Custom category
+ startDate: '2025-01-01',
+ endDate: '2025-01-10',
+ },
+])
+```
+
### Component Configuration
#### ToolbarConfig (Toolbar Configuration)
@@ -2199,5 +2298,5 @@ View the complete [Contributors list](./CONTRIBUTORS.md)。
---
- If this project helps you, please give it a ⭐️ to support it!
+ If this project helps you, please give it a ⭐️ to support it!
diff --git a/README.md b/README.md
index a479489..dfc8467 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,8 @@
中文 |
- English
+ English |
+ 更新日志
现代化的 Vue 3 甘特图组件库,为项目管理和任务调度提供完整解决方案
@@ -178,16 +179,17 @@ npm run dev
#### 基础属性
-| 属性名 | 类型 | 默认值 | 说明 |
-| --------------------------- | --------- | ------- | -------------------------------------------------------------- |
-| `tasks` | `Task[]` | `[]` | 任务数据数组 |
-| `milestones` | `Task[]` | `[]` | 里程碑数据数组(注意:类型为 Task[],需设置 type='milestone') |
-| `showToolbar` | `boolean` | `true` | 是否显示工具栏 |
-| `useDefaultDrawer` | `boolean` | `true` | 是否使用内置任务编辑抽屉(TaskDrawer) |
-| `useDefaultMilestoneDialog` | `boolean` | `true` | 是否使用内置里程碑编辑对话框(MilestoneDialog) |
-| `autoSortByStartDate` | `boolean` | `false` | 是否根据开始时间自动排序任务 |
-| `allowDragAndResize` | `boolean` | `true` | 是否允许拖拽和调整任务/里程碑大小 |
-| `enableTaskRowMove` | `boolean` | `false` | 是否允许拖拽和摆放TaskRow |
+| 属性名 | 类型 | 默认值 | 说明 |
+| --------------------------- | ----------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------- |
+| `tasks` | `Task[]` | `[]` | 任务数据数组 |
+| `milestones` | `Task[]` | `[]` | 里程碑数据数组(注意:类型为 Task[],需设置 type='milestone') |
+| `showToolbar` | `boolean` | `true` | 是否显示工具栏 |
+| `useDefaultDrawer` | `boolean` | `true` | 是否使用内置任务编辑抽屉(TaskDrawer) |
+| `useDefaultMilestoneDialog` | `boolean` | `true` | 是否使用内置里程碑编辑对话框(MilestoneDialog) |
+| `autoSortByStartDate` | `boolean` | `false` | 是否根据开始时间自动排序任务 |
+| `allowDragAndResize` | `boolean` | `true` | 是否允许拖拽和调整任务/里程碑大小 |
+| `enableTaskRowMove` | `boolean` | `false` | 是否允许拖拽和摆放TaskRow |
+| `assigneeOptions` | `Array<{ key?: string \| number; value: string \| number; label: string }>` | `[]` | 任务编辑抽屉中负责人下拉菜单的选项列表 |
#### 配置对象属性
@@ -249,7 +251,7 @@ npm run dev
```vue
-
+
@@ -267,6 +269,12 @@ const tasks = ref([
progress: 100,
},
])
+
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
+])
```
@@ -275,7 +283,7 @@ const tasks = ref([
```vue
-
+
@@ -303,6 +311,12 @@ const milestones = ref([
icon: 'diamond',
},
])
+
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
+])
```
@@ -323,6 +337,7 @@ const milestones = ref([
:tasks="tasks"
:milestones="milestones"
:show-toolbar="false"
+ :assignee-options="assigneeOptions"
@task-added="handleTaskAdded"
@milestone-saved="handleMilestoneSaved"
/>
@@ -338,6 +353,12 @@ import 'jordium-gantt-vue3/dist/assets/jordium-gantt-vue3.css'
const tasks = ref([])
const milestones = ref([])
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
+])
+
const addTask = () => {
const newTask = {
id: Date.now(),
@@ -385,7 +406,8 @@ const handleMilestoneSaved = milestone => {
| `endDate` | `string` | - | - | 结束日期,格式:'YYYY-MM-DD' 或 'YYYY-MM-DD HH:mm' |
| `progress` | `number` | - | `0` | 任务进度,范围 0-100 |
| `predecessor` | `number[]` | - | - | 前置任务 ID 数组,标准格式:`[1, 2, 3]` **兼容格式**:也支持字符串 `'1,2,3'` 或字符串数组 `['1', '2', '3']`,组件会自动解析 |
-| `assignee` | `string` | - | - | 任务负责人 |
+| `assignee` | `string` | - | - | 任务负责人,用作负责人下拉菜单的值绑定 |
+| `assigneeName` | `string` | - | - | 任务负责人姓名,自动从绑定的数据集`assigneeOptions`中获取Label作为显示,如果需要自定义,可以在GanttChart回调事件`task-added`中自定义信息 |
| `avatar` | `string` | - | - | 任务负责人头像 URL |
| `estimatedHours` | `number` | - | - | 预估工时(小时) |
| `actualHours` | `number` | - | - | 实际工时(小时) |
@@ -424,7 +446,8 @@ const handleMilestoneSaved = milestone => {
| `taskBarConfig` | `TaskBarConfig` | `{}` | 任务条样式配置,详见 [TaskBarConfig 配置](#taskbarconfig-配置) |
| `taskListConfig` | `TaskListConfig` | `undefined` | 任务列表配置,详见 [TaskListConfig 配置](#tasklistconfig-配置) |
| `autoSortByStartDate` | `boolean` | `false` | 是否根据开始时间自动排序任务 |
-| `enableTaskRowMove` | `boolean` | `false` | 是否允许拖拽和摆放TaskRow
+| `enableTaskRowMove` | `boolean` | `false` | 是否允许拖拽和摆放TaskRow |
+| `assigneeOptions` | `Array<{ key?: string \| number; value: string \| number; label: string }>` | `[]` | 任务编辑抽屉中负责人下拉菜单的选项列表 |
**配置说明**:
@@ -465,6 +488,7 @@ const handleMilestoneSaved = milestone => {
([
},
])
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
+])
+
// 工具栏"添加任务"按钮点击事件
const handleAddTask = () => {
console.log('准备新增任务...')
@@ -554,6 +584,7 @@ const handleTaskDragEnd = (task: Task) => {
@@ -616,6 +647,12 @@ const tasks = ref([
},
])
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
+])
+
// 通过右键菜单添加前置任务时触发
const handlePredecessorAdded = (event: { targetTask: Task; newTask: Task }) => {
console.log(`任务 [${event.targetTask.name}] 添加了前置任务 [${event.newTask.name}]`)
@@ -669,6 +706,7 @@ const handleSuccessorAdded = (event: { targetTask: Task; newTask: Task }) => {
:show-toolbar="false"
:use-default-drawer="true"
:use-default-milestone-dialog="true"
+ :assignee-options="assigneeOptions"
@add-task="handleAddTask"
@add-milestone="handleAddMilestone"
@task-added="handleTaskAdded"
@@ -684,6 +722,12 @@ import 'jordium-gantt-vue3/dist/assets/jordium-gantt-vue3.css'
const tasks = ref([])
const milestones = ref([])
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
+])
+
// 自定义按钮触发事件(组件会响应并打开内置编辑器)
const triggerAddTask = () => {
// 直接触发组件的 add-task 事件
@@ -727,6 +771,7 @@ const handleTaskAdded = e => {
@@ -763,6 +808,12 @@ const tasks = ref([
},
])
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
+])
+
// 任务行拖拽完成事件(可选)
const handleTaskRowMoved = async (payload: {
draggedTask: Task
@@ -1239,6 +1290,54 @@ const handleDelete = () => {
本章节详细介绍 GanttChart 组件的配置选项和扩展能力,包括组件配置、主题与国际化、自定义扩展三个部分。
+### 任务类型定义
+
+任务类型(`type` 字段)用于区分不同类型的任务,组件内部会根据类型执行不同的逻辑判断。
+
+#### 内置任务类型
+
+| 类型值 | 说明 | 默认值 |
+| ------- | ---------- | ------ |
+| `story` | 用户故事 | - |
+| `task` | 普通任务 | ✅ |
+| `bug` | 缺陷/问题 | - |
+
+#### 功能区分
+
+不同任务类型在组件中具有不同的功能特性:
+
+| 功能 | story | task | bug |
+| ---------------- | ----- | ---- | --- |
+| 可作为上级任务 | ✅ | ✅ | ❌ |
+| 可作为前置任务 | ❌ | ✅ | ❌ |
+| 支持计时器 | ❌ | ✅ | ✅ |
+| 自动视为父任务 | ✅ | ❌ | ❌ |
+| 删除时特殊提示 | ✅ | ❌ | ❌ |
+
+#### 注意事项
+
+> ⚠️ **重要提示**
+>
+> 1. 任务类型值为组件内置判断使用,**请勿随意修改**这些枚举值
+> 2. 客制化 TaskDrawer 时,必须保持 `story`、`task`、`bug` 这三个枚举值
+> 3. 如需添加其他业务标签,建议使用自定义属性字段,例如:`customType`、`category`、`label` 等
+
+**示例:使用自定义标签**
+
+```typescript
+const tasks = ref([
+ {
+ id: 1,
+ name: '需求分析',
+ type: 'task', // 保持组件内置类型
+ customType: 'requirement', // 自定义业务类型
+ category: 'analysis', // 自定义分类
+ startDate: '2025-01-01',
+ endDate: '2025-01-10',
+ },
+])
+```
+
### 组件配置
#### ToolbarConfig(工具栏配置)
@@ -2190,5 +2289,5 @@ jordium-gantt-vue3/
---
- 如果这个项目对你有帮助,请给一个 ⭐️ 支持一下!
+ 如果这个项目对你有帮助,请给一个 ⭐️ 支持一下!
diff --git a/demo/App.vue b/demo/App.vue
index cf39f1e..2ec1a85 100644
--- a/demo/App.vue
+++ b/demo/App.vue
@@ -187,6 +187,18 @@ const allowDragAndResize = ref(true)
// 控制是否启用TaskRow拖拽移动
const enableTaskRowMove = ref(true)
+// 指派人员选项列表
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
+ { value: 'zhaoliu', label: '赵六' },
+ { value: 'qianqi', label: '钱七' },
+ { key: 'user_sunba', value: 'sunba', label: '孙八' }, // 示例:使用自定义 key
+ { value: 'zhoujiu', label: '周九' },
+ { value: 'wushi', label: '吴十' },
+])
+
// TaskBar配置
const taskBarOptions = ref({
showAvatar: true,
@@ -1088,6 +1100,7 @@ const handleTaskRowMoved = async (payload: {
:use-default-milestone-dialog="true"
:allow-drag-and-resize="allowDragAndResize"
:enable-task-row-move="enableTaskRowMove"
+ :assignee-options="assigneeOptions"
:on-export-csv="handleCustomCsvExport"
:on-language-change="handleLanguageChange"
:on-theme-change="handleThemeChange"
diff --git a/demo/version-history.json b/demo/version-history.json
index 4aa8e49..f856540 100644
--- a/demo/version-history.json
+++ b/demo/version-history.json
@@ -342,5 +342,17 @@
"Optimized: Task item move and drag-and-drop functionality in the task list",
"Special thanks to jun201607@github for their valuable use and feedback "
]
+ },
+ {
+ "version": "1.4.6",
+ "date": "2025-12-09",
+ "notes": [
+ "修复:内置TaskDrawer中负责人列表可以外部初始化",
+ "修复:未设置startDate和endDate时,任务无法正确显示的问题",
+ "特别感谢 yue-xiaochuan & YQ6494@gitee的使用及反馈的宝贵意见 ",
+ "Fixed: The assignee list in the built-in TaskDrawer can be initialized externally",
+ "Fixed: The issue where tasks could not be displayed correctly when startDate and endDate were not set",
+ "Special thanks to yue-xiaochuan & YQ6494@gitee for their valuable use and feedback "
+ ]
}
]
diff --git a/npm-demo/src/components/GanttTest.vue b/npm-demo/src/components/GanttTest.vue
index 8132ba0..839d7bd 100644
--- a/npm-demo/src/components/GanttTest.vue
+++ b/npm-demo/src/components/GanttTest.vue
@@ -60,6 +60,15 @@ const availableColumns = ref([
{ key: 'progress', label: '进度', visible: true },
{ key: 'department', label: '部门', visible: true, width: 200 },
{ key: 'departmentCode', label: '部门编号', visible: true },
+ { key: 'assigneeName', label: '负责人', visible: true },
+])
+
+// 使用内置TaskDrawer组件的时候,可以传入负责人选项
+// 请先设置GanttChart组件属性use-default-drawer="true"
+const assigneeOptions = ref([
+ { value: 'zhangsan', label: '张三' },
+ { value: 'lisi', label: '李四' },
+ { value: 'wangwu', label: '王五' },
])
// TaskList宽度配置示例
@@ -140,16 +149,16 @@ const handleTaskRowMoved = async (payload: {
newParent: Task | null
}) => {
const { draggedTask, targetTask, position, oldParent, newParent } = payload
-
+
// 组件已自动完成任务移动、parentId更新和TaskList/Timeline同步
// 监听此事件为完全可选,仅用于:
-
+
// 1. 显示自定义提示消息
const oldParentName = oldParent?.name || '根目录'
const newParentName = newParent?.name || '根目录'
const positionText = position === 'after' ? '在目标任务之后' : '作为目标任务的子任务'
alert(`任务 [${draggedTask.name}] 已从 [${oldParentName}] 移动到 [${newParentName}] (${positionText})`, 'success')
-
+
// 2. 调用后端 API 保存新的任务层级关系
try {
await api.updateTaskHierarchy({
@@ -163,17 +172,36 @@ const handleTaskRowMoved = async (payload: {
console.error('保存任务层级失败:', error)
alert('保存失败,请刷新页面')
}
-
+
// 3. 触发其他业务逻辑(如更新关联数据、记录操作日志等)
// ...
}
+
+// 任务添加后回调
+const onTaskAdded = (res) => {
+ const addedTask = tasks.value.find(t => t.id === res.task.id);
+ if (addedTask) {
+ // 使用addedTask.assignee去查找assigneeOptions的label进行赋值
+ const assigneeOption = assigneeOptions.value.find(option => option.value === addedTask.assignee);
+ if (assigneeOption) {
+ addedTask.assigneeName = assigneeOption.label;
+ }
+ } else {
+ // 使用addedTask.assignee去查找assigneeOptions的label进行赋值
+ const assigneeOption = assigneeOptions.value.find(option => option.value === res.task.assignee);
+ if (assigneeOption) {
+ res.task.assigneeName = assigneeOption.label;
+ }
+ tasks.value.push(res.task);
+ }
+};
-
@@ -196,7 +225,7 @@ const handleTaskRowMoved = async (payload: {
添加任务
添加里程碑
-
+
@@ -204,24 +233,24 @@ const handleTaskRowMoved = async (payload: {
自定义添加任务组件
×
-
+
-
+
-
@@ -252,7 +281,7 @@ const handleTaskRowMoved = async (payload: {
确定
取消
-
+
@@ -403,4 +432,4 @@ const handleTaskRowMoved = async (payload: {
from { transform: translateX(100%); }
to { transform: translateX(0); }
}
-
\ No newline at end of file
+
diff --git a/npm-webpack-demo/src/App.vue b/npm-webpack-demo/src/App.vue
index 6959968..ec08be0 100644
--- a/npm-webpack-demo/src/App.vue
+++ b/npm-webpack-demo/src/App.vue
@@ -1,150 +1,3 @@
-
-
@@ -157,11 +10,15 @@ const onMilestoneDblclick = (milestone: any) => {
:use-default-milestone-dialog="false"
:locale-messages="customMessages"
:allow-drag-and-resize="true"
+ :enable-task-row-move="true"
+ :assignee-options="assigneeOptions"
+ @task-row-moved="handleTaskRowMoved"
@add-task="showAddTaskDrawer = true"
@add-milestone="showAddMilestoneDialog = true"
@task-double-click="onTaskDblclick"
@task-click="onTaskClick"
@milestone-double-click="onMilestoneDblclick"
+ @task-added="onTaskAdded"
>
@@ -205,8 +62,8 @@ const onMilestoneDblclick = (milestone: any) => {
@@ -230,6 +87,212 @@ const onMilestoneDblclick = (milestone: any) => {
+
+