场景:项目内迭代工时统计
场景描述
用户希望在项目中通过表格的方式直观的看到项目内各迭代的工时信息
实现效果
在项目内添加自定义组件,可以通过表格的形式查看项目下各迭代的相关 数据
解决方案
实现思路
使用插件承载 project 自定义组件
能力,在插件内实现表格数据的自定义组件
插件开发
1. 添加插件承载 project 自定义组件
能力,添加ones:project:component:new
插槽,将对应组件的modules.id
填入abilities.relateModule.componentModuleEnter
中
config/plugin.yaml
service:
app_id: ...
name: 项目内迭代工时统计
version: 1.0.0
description: 展示项目内迭代的工时情况
mode: org
logo: null
language: nodejs
language_version: 16.13.0
host_version: 1.0.4
host_sub_version: 1.0.0
min_system_version: 3.5.0
auth: null
config: null
scope: 1
apis:
- type: addition
methods:
- POST
url: /hello
function: hello
modules:
- id: ones-project-component-new-aQbS
title: 迭代统计
moduleType: ones:project:component:new
entry: modules/ones-project-component-new-aQbS/index.html
abilities:
- id: tRUFWEsd
name: 自定义组件
abilityType: ProjectCustomComponent
function:
copyPluginData: copyTest
version: 1.0.0
relateModule:
componentModuleEnter: 'ones-project-component-new-aQbS'
config:
- key: component_name
label: 自定义组件名称
value: 迭代统计
fieldType: Input
show: false
- key: component_desc
label: 自定义组件描述
value: 展示迭代的工时消耗情况
fieldType: TextArea
show: false
props:
placeholder: 可配置自定义组件描述,允许为空
- key: is_support_copy
label: 是否支持插件数据复制
value: false
show: false
2. 完成自定义组件的功能
在插件前端目录下,完成数据表格的功能开发
index.tsx
web/src/modules/ones-project-component-new-aQbS/index.tsx
import React from 'react'
import ReactDOM from 'react-dom'
import { ConfigProvider } from '@ones-design/core'
import { SprintStatistics } from './components/sprint-statistics'
import './index.css'
ReactDOM.render(
<ConfigProvider>
<SprintStatistics />
</ConfigProvider>,
document.getElementById('ones-mf-root')
)
表格样式
web/src/modules/ones-project-component-new-aQbS/index.css
body {
background: transparent;
font-family: PingFang SC, '微软雅黑', Arial;
line-height: 1.5;
padding: 20px 0;
}
#ones-mf-root {
overflow: hidden;
position: relative;
display: flex;
height: 100%;
flex-direction: column;
background: #fff;
.sprint-container {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
box-sizing: border-box;
background: #fff;
.sprint-head {
.sprint-head-title {
font-weight: 500;
font-size: 18px;
line-height: 26px;
padding: 0 20px;
}
.sprint-head-alert {
margin: 20px 0px 15px;
padding: 0 20px;
}
}
.sprint-picker {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 0 20px;
width: 40%;
.sprint-status-select {
display: flex;
flex-direction: row;
align-items: center;
width: 60%;
margin-right: 20px;
.select-title {
width: 30%;
}
.select-main {
width: 70%
}
}
.sprint-done-interval {
width: 40%;
}
}
.sprint-table {
margin: 0 20px;
margin-top: 20px;
}
}
}