open-hand / choerodon-ui Goto Github PK
View Code? Open in Web Editor NEWAn enterprise UI framework and react-based implementation.
Home Page: http://choerodon.io
License: MIT License
An enterprise UI framework and react-based implementation.
Home Page: http://choerodon.io
License: MIT License
当调用 dataSet 的 query 方法进行重新查询数据后,已经展开的节点的子节异步加载不了。
需要重新渲染 Tree 组件才能正常显示。
如题
handleClick = record => {
if (!record?.isCurrent) record?.dataSet?.locate(record.index);
}
使用上面的方法实现点击定位到当前行始终会跳到第一页。
猪齿鱼UI的record的index是基于当前页的,比如我一页有10行,就是0~9,因此使用dataset.locate(1)应该是定位到当前页的第2行,而不是查询并定位到第1页的第2行。
目前我们实现定位到当前行的逻辑需要根据page和size来计算真实的index才能实现:dataSet.locate(record?.index + dataSet.pageSize * (dataSet.currentPage - 1))
。能否修改locate的逻辑:基于当前行定位或者将计算index的逻辑加进去,或者修改record.index的取值逻辑
下载 https://codesandbox.io/s/11ej3 代码后,然后替换index.js内容如下:
代码如下:
import 'choerodon-ui/dist/choerodon-ui.css';
import 'choerodon-ui/dist/choerodon-ui-pro.css';
import 'choerodon-ui/dist/choerodon-ui-demo-data-mock.min.js';
import React from 'react';
import ReactDOM from 'react-dom';
import { Button, PerformanceTable } from 'choerodon-ui/pro';
const fakeTreeData = [
{
key: 1,
name: 'John Brown sr.',
age: 60,
address: 'New York No. 1 Lake Park',
children: [
{
key: 11,
name: 'John Brown',
age: 42,
address: 'New York No. 2 Lake Park',
},
{
key: 12,
name: 'John Brown jr.',
age: 30,
address: 'New York No. 3 Lake Park',
children: [
{
key: 121,
name: 'Jimmy Brown',
age: 16,
address: 'New York No. 3 Lake Park',
},
],
},
{
key: 13,
name: 'Jim Green sr.',
age: 72,
address: 'London No. 1 Lake Park',
children: [
{
key: 131,
name: 'Jim Green',
age: 42,
address: 'London No. 2 Lake Park',
children: [
{
key: 1311,
name: 'Jim Green jr.',
age: 25,
address: 'London No. 3 Lake Park',
},
{
key: 1312,
name: 'Jimmy Green sr.',
age: 18,
address: 'London No. 4 Lake Park',
},
],
},
],
},
],
},
{
key: 2,
name: 'Joe Black',
age: 32,
address: 'Sidney No. 1 Lake Park',
},
]
const rowKey = 'key'
// 拍平数组
const flatNode = list => {
return list.reduce((total, cur) => {
const t = total.concat(cur);
return cur.children ? t.concat(flatNode(cur.children)) : t;
}, []);
};
/**
* 通过当前id 在原数组中查找该id对应的节点
* @param {*} list 原数组
* @param {*} curLineId 查找id
*/
const getChildNode = (list, curLineId) => {
const arr = [];
for (let i = 0; i < list.length; i++) {
const item = list[i];
if (item[rowKey] === curLineId) {
arr.push(item);
break;
} else if (item.children) {
const result = getChildNode(item.children, curLineId);
if (result.length) arr.push(result[0]);
}
}
return arr;
};
const uniq = (arr) => [...new Set(arr)]
const handleRowKeys = list => list.map(v => v[rowKey]);
class TreeTable extends React.Component {
constructor(props) {
super(props);
this.state = {
data: fakeTreeData.slice(0, 100),
selectedRowKeys: [],
selectedRows: []
};
}
// componentDidMount() {
// fetch('https://open-hand.github.io/choerodon-ui/zh/procmp/data/fakeLargeData.json')
// .then((response) => response.json())
// .then((data) => {
// this.setState({
// data: data
// })
// });
// }
setSelectedRowKeys = (selectedRowKeys) => {
this.setState({ selectedRowKeys: uniq(selectedRowKeys) });
}
setSelectedRows = (selectedRows) => {
this.setState({ selectedRows: uniq(selectedRows) })
}
onRowSelect = (record, selected, _selectedRows) => {
const { selectedRowKeys, selectedRows } = this.state;
console.log(selected, 'selected')
if (selected) {
const curLineId = record[rowKey];
// 选中时
const arr = getChildNode(this.state.data, curLineId);
const list = flatNode(arr);
const rowKeys = handleRowKeys(list);
this.setSelectedRowKeys([...selectedRowKeys, ...rowKeys]);
this.setSelectedRows([...selectedRows, ...list]);
} else {
// 取消
const curRowKey = record[rowKey];
this.setSelectedRowKeys(selectedRowKeys.filter(v => v !== curRowKey));
// 返回的 _selectedRows 中已经过滤掉
this.setSelectedRows(_selectedRows);
}
};
onSelectAll = selected => {
if (selected) {
// 全选
const list = flatNode(this.state.data);
const rowKeys = handleRowKeys(list);
this.setSelectedRowKeys(rowKeys);
this.setSelectedRows(list);
} else {
// 取消
this.setSelectedRowKeys([]);
this.setSelectedRows([]);
}
};
get rowSelection() {
const { selectedRowKeys } = this.state;
const rowSelection = {
type: 'checkbox',
columnWidth: 100,
fixed: true,
selectedRowKeys,
// checkStrictly: true,
onSelect: this.onRowSelect,
onSelectAll: this.onSelectAll,
}
return rowSelection;
}
render() {
// const { rowSelection } = this;
const { data, selectedRowKeys } = this.state;
console.log(selectedRowKeys, 'selectedRowKeys')
const rowSelection = {
type: 'checkbox',
columnWidth: 100,
fixed: true,
selectedRowKeys,
checkStrictly: true,
onSelect: this.onRowSelect,
onSelectAll: this.onSelectAll,
}
const columns = [
{
title: 'Name',
dataIndex: 'name',
key: 'name',
width: 200,
treeCol: true,
},
{
title: 'Age',
dataIndex: 'age',
key: 'age',
width: 300,
},
{
title: 'Address',
dataIndex: 'address',
width: 500,
key: 'address',
},
];
return (
<div>
<Button onClick={() => {
this.setSelectedRowKeys([12, 121])
}}>
动态更新selectedRowKeys
</Button>
<PerformanceTable
isTree
virtualized
rowKey={rowKey}
minHeight={260}
height={400}
data={data}
columns={columns}
rowSelection={rowSelection}
defaultExpandedRowKeys={[0]}
onExpandChange={(expanded, rowData) => {
// console.log(expanded, rowData);
}}
// renderTreeToggle={(icon, rowData, expanded) => {
// // if (rowData.labelName === '手机') {
// // return <i className="icon icon-spin icon-spinner" />;
// // }
// // return icon;
// return <i className="icon icon-spin icon-spinner" />;
// }}
/>
</div>
);
}
}
ReactDOM.render(<TreeTable />, document.getElementById('container'));
# 1. yarn 的源配置
yarn config set registry http://nexus.saas.hand-china.com/content/groups/srm-npm-group/
# 2. 安装
yarn
# 3. 运行
yarn start
Mac
Chrome 98
choerodon-ui: 1.5.1
use drawerTransitionName prop with 'slide-bottom', Page report error;
Although there is no need to use the expected value in the enumeration, it should not be obtained by an error response.
.ant-table.resizable-table table {
table-layout: fixed;
}
hzero-ui table组件 这个样式,影响页面布局,
hzero-ui
版本号 1.0.84
文档中Icon组件的 示例都挂了;
比如日期插件的content: '‹' ; content: '«'; 都会出现乱码。这种情况转unicode更好吧。
值集视图可能会用于很多个页面 而大多数需要显示的是name,偶尔有两个地方需要显示code,所以希望c7n针对这种情况,优化一下Lov组件,新增属性用于修改显示值即可
这个和antd关系是什么 很多链接点过去都是antd
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
table
package.json 1.2.0
这个问题依然 还没解决啊, 下面的API props什么的看不太懂,
const modal = Modal.open(...)
我把modal 传进 loadData 函数那, setState完了后, 不管我
modal.render()/ renderChildren(modal.getBody())/ forceUpdate/ renderChildren( getForm(dataSet) ) 。。
都不行啊 控制台显示 renderChildren 不是一个function
Form绑定dataSet, 查询虽然是异步, 但都正常显示了, 就头像这 查询时放进state里, filelist查state, 不是最新的
使用import { Table } from 'choerodon-ui/pro';
的Table组件会报下面的错误
TypeError: Cannot read property 'length' of undefined
Table.renderTable
D:/Microsoft VS Code/project/PH/powerpip-choerodon-demo/table/Table.js:649
646 | const { rowSelection } = this.props;
647 | const prefixCls = this.getPrefixCls();
648 | const columns = this.columns.concat();
649 | if (rowSelection) {
| ^ 650 | const data = this.getFlatCurrentPageData().filter((item, index) => {
651 | if (rowSelection.getCheckboxProps) {
652 | return !this.getCheckboxPropsByItem(item, index).disabled;
基于 Ant [email protected] 的 Choerodon UI 的 React 实现,后续Ant Design的版本有升级吗 ?
this.headerDS.query().then((res) => {
if (res.relationMethodCode === 'HEAD') {
this.headerDS.addField('expRequisitionNumber', {
type: FieldType.string,
label: intl.get('hssp.screen.exp_report_hd.exp_requisition'),
required: !!res.reqRequired,
})
}
})
查询之后添加的动态字段用record.getField取不到相应的字段信息
Tree pro components has worse performence, when load more than 2000 records, cause chrome crash
有些业务场景我们需要动态的创建dataset并获取所有的Field。现在没有直接方法可以获取到。
望猪齿鱼开发组可以添加一个这样的方法。
该UI挺不错的,很多功能都很全面
choerodon-ui 是否考虑支持vue版本
支持vue2,vue3版本
用了图床的图片都看不了
0.8.68 版本 Cascader pro 组件, 看文档(https://choerodon.github.io/choerodon-ui/zh/procmp/data-entry/cascader) 没有看到允许支持选择父节点的地方, 只能选叶子节点吗?
按照官网文档示例教程配置好后写一个Button,没有“choerodon-ui 的蓝色按钮组件”
参考教程:https://open-hand.github.io/choerodon-ui/zh/tutorials/demo-build
依赖配置:
"axios": "^0.24.0",
"choerodon-ui": "1.5.1",
"mobx": "~4.15.7",
"mobx-react": "~6.1.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^2.1.3"
将choerodon-ui降级到1.4.5没问题
Hi, @Huihuawk @HughHzWu, a vulnerability CVE-2021-23358 is introduced in choerodon-ui via:
● [email protected] ➔ [email protected] ➔ [email protected] ➔ [email protected]
However, jsonlint is a legacy package, which has not been maintained for about 3 years.
Is it possible to migrate jsonlint to other package or remove it to remediate this vulnerability?
I noticed a migration record in other js repo for jsonlint:
● in cfn-include, version 1.0.0 ➔ 1.0.1, remove jsonlint via commit
● in gavel, version 2.1.2 ➔ 2.1.3, migrate jsonlint to json-parse-helpfulerror via commit
Thanks.
能否像必输的c7n-pro-field-required
样式类一样,给只读组件添加一个c7n-pro-field-readonly
的样式类?
因为现在Select
之类的组件,里面的input
标签始终是readonly的,所以没有办法通过readonly
属性自定义只读的样式。
Unhandled Rejection (Error): [MobX] 'has()' can only be used on observable objects, arrays and maps
import React from 'react';
import { Table } from 'choerodon-ui/pro';
export default class BusinessTrip extends React.Component {
render(){
return < Table columns={[]} dataSource={[]} / >
}
}
从choerodon-ui/pro中引用Table或者DataSet并且在页面中使用就会报这个错,有其他人遇到吗 怎么解决的.我的配置文件
[
'import',
{
libraryName: 'choerodon-ui',
style: true,
},
'c7n',
],
[
'import',
{
libraryName: 'choerodon-ui/pro',
style: true,
},
'c7n-pro',
],
下载 https://codesandbox.io/s/11ej3 代码到本地安装运行报错
# 1. yarn 的源配置
yarn config set registry http://nexus.saas.hand-china.com/content/groups/srm-npm-group/
# 2. 安装
yarn
# 3. 运行
yarn start
Mac
Chrome 98
choerodon-ui: 1.5.1
tableStore.getConfig(...) is not a function
使用import {Table } from 'choerodon-ui/pro';
createError.js:16 Uncaught (in promise) Error: Request failed with status code 404
at createError (createError.js:16)
at settle (settle.js:17)
at MockXMLHttpRequest.handleLoad [as onreadystatechange] (xhr.js:62)
at MockXMLHttpRequest.dispatchEvent (mock.js:8476)
at XMLHttpRequest.handle (mock.js:8304)
createError @ createError.js:16
settle @ settle.js:17
handleLoad @ xhr.js:62
dispatchEvent @ mock.js:8476
handle @ mock.js:8304
Promise.then (async)
asyncGeneratorStep @ asyncToGenerator.js:13
_next @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
fetchLovConfig @ Field.js:525
(anonymous) @ Field.js:66
executeAction @ mobx.module.js:191
runInAction @ mobx.module.js:375
Field @ Field.js:60
(anonymous) @ DataSet.js:1133
processIntlField @ utils.js:594
addField @ DataSet.js:1132
executeAction @ mobx.module.js:191
res @ mobx.module.js:183
(anonymous) @ DataSet.js:1118
initFields @ DataSet.js:1115
(anonymous) @ DataSet.js:67
executeAction @ mobx.module.js:191
runInAction @ mobx.module.js:375
DataSet @ DataSet.js:41
initQueryDataSet @ DataSet.js:1368
(anonymous) @ DataSet.js:69
executeAction @ mobx.module.js:191
runInAction @ mobx.module.js:375
DataSet @ DataSet.js:41
(anonymous) @ index.js:37
./src/components/TableDemo2/index.js @ index.js:297
webpack_require @ bootstrap:851
fn @ bootstrap:150
(anonymous) @ App.css?dde5:82
./src/App.js @ App.js:20
webpack_require @ bootstrap:851
fn @ bootstrap:150
(anonymous) @ index.css?bb0a:82
./src/index.js @ index.js:17
webpack_require @ bootstrap:851
fn @ bootstrap:150
1 @ index.js:17
webpack_require @ bootstrap:851
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.chunk.js:1
Show 17 more frames
createError.js:16 Uncaught (in promise) Error: Request failed with status code 404
at createError (createError.js:16)
at settle (settle.js:17)
at MockXMLHttpRequest.handleLoad [as onreadystatechange] (xhr.js:62)
at MockXMLHttpRequest.dispatchEvent (mock.js:8476)
at XMLHttpRequest.handle (mock.js:8304)
createError @ createError.js:16
settle @ settle.js:17
handleLoad @ xhr.js:62
dispatchEvent @ mock.js:8476
handle @ mock.js:8304
Promise.then (async)
asyncGeneratorStep @ asyncToGenerator.js:13
_next @ asyncToGenerator.js:25
(anonymous) @ asyncToGenerator.js:32
(anonymous) @ asyncToGenerator.js:21
fetchLovConfig @ Field.js:525
(anonymous) @ Field.js:66
executeAction @ mobx.module.js:191
runInAction @ mobx.module.js:375
Field @ Field.js:60
(anonymous) @ Record.js:524
processIntlField @ utils.js:594
addField @ Record.js:523
executeAction @ mobx.module.js:191
res @ mobx.module.js:183
(anonymous) @ Record.js:519
initFields @ Record.js:519
(anonymous) @ Record.js:43
executeAction @ mobx.module.js:191
runInAction @ mobx.module.js:375
Record @ Record.js:28
create @ DataSet.js:658
(anonymous) @ DataSet.js:118
(anonymous) @ _baseDelay.js:18
setTimeout (async)
baseDelay @ _baseDelay.js:18
(anonymous) @ defer.js:23
apply @ _apply.js:15
(anonymous) @ _overRest.js:32
(anonymous) @ DataSet.js:116
(anonymous) @ DataSet.js:115
executeAction @ mobx.module.js:191
runInAction @ mobx.module.js:375
set @ DataSet.js:111
initQueryDataSet @ DataSet.js:1373
(anonymous) @ DataSet.js:69
executeAction @ mobx.module.js:191
runInAction @ mobx.module.js:375
DataSet @ DataSet.js:41
(anonymous) @ index.js:37
./src/components/TableDemo2/index.js @ index.js:297
webpack_require @ bootstrap:851
fn @ bootstrap:150
(anonymous) @ App.css?dde5:82
./src/App.js @ App.js:20
webpack_require @ bootstrap:851
fn @ bootstrap:150
(anonymous) @ index.css?bb0a:82
./src/index.js @ index.js:17
webpack_require @ bootstrap:851
fn @ bootstrap:150
1 @ index.js:17
webpack_require @ bootstrap:851
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.chunk.js:1
construct.js:19 Uncaught (in promise) Error: Request failed with status code 404
at createError (createError.js:16)
at settle (settle.js:17)
at MockXMLHttpRequest.handleLoad [as onreadystatechange] (xhr.js:62)
at MockXMLHttpRequest.dispatchEvent (mock.js:8476)
at XMLHttpRequest.handle (mock.js:8304)
_construct @ construct.js:19
Wrapper @ wrapNativeSuper.js:26
(anonymous) @ DataSetComponent.js:33
DataSetRequestError @ DataSetRequestError.js:4
_callee9$ @ DataSet.js:1449
tryCatch @ runtime.js:63
invoke @ runtime.js:293
(anonymous) @ runtime.js:118
asyncGeneratorStep @ asyncToGenerator.js:3
_throw @ asyncToGenerator.js:29
Promise.catch (async)
add @ PromiseQueue.js:25
executeAction @ mobx.module.js:191
res @ mobx.module.js:183
query @ DataSet.js:439
(anonymous) @ DataSet.js:78
executeAction @ mobx.module.js:191
runInAction @ mobx.module.js:375
DataSet @ DataSet.js:41
(anonymous) @ index.js:37
./src/components/TableDemo2/index.js @ index.js:297
webpack_require @ bootstrap:851
fn @ bootstrap:150
(anonymous) @ App.css?dde5:82
./src/App.js @ App.js:20
webpack_require @ bootstrap:851
fn @ bootstrap:150
(anonymous) @ index.css?bb0a:82
./src/index.js @ index.js:17
webpack_require @ bootstrap:851
fn @ bootstrap:150
1 @ index.js:17
webpack_require @ bootstrap:851
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.chunk.js:1
createError.js:16 Uncaught (in promise) Error: Request failed with status code 404
at createError (createError.js:16)
at settle (settle.js:17)
at MockXMLHttpRequest.handleLoad [as onreadystatechange] (xhr.js:62)
at MockXMLHttpRequest.dispatchEvent (mock.js:8476)
at XMLHttpRequest.handle (mock.js:8304)
猜测:内层 content div 高度是科学计数法表示的,未处理,导致浏览器渲染出问题
测试版本:1.4.4,1.4.5
浏览器:chrome 91.0
我是一个后端, 对前端了解不多, 看到猪齿鱼这个UI风格很棒, 但如何快速的构造一个完整(带路由、权限等)、简易、UI风格
统一的项目, 供后续开发? 通过提供的帮助文档我只能零星的知道其中的某个组件怎么用。 找一个现成的react项目,替换掉全部
的component ? antd pro 则提供了一键初始化项目的功能。
这个要求是不是太大了?😂
业务场景:在选择支付币种时,会带出精度字段,付款金额需要根据精度字段显示对应的精度。
目前currency类型好像只会显示两位小数,建议后期能加个精度属性,这样就不用自定义editor去实现这个业务场景了
import React, { PureComponent } from 'react';
import { Header, Content } from 'components/Page';
import { Collapse } from 'choerodon-ui';
const { Panel } = Collapse;
export default class ReportDetailPage extends PureComponent {
render() {
return (
<>
<Header title="费用报销单详情" backPath="/exp/report/list">
</Header>
<Content>
<Collapse>
<Panel key="1" header="测试">
123
</Panel>
</Collapse>
</Content>
</>
);
}
}
choerodon-ui version : 0.8.59
文档中提示feedback的类型应为Feedback,但实际在typescript中要求的类型为TransportProps
后端兼职前端,新人,对react的一些核心概念似懂非懂...
问题:
点开弹出框,显示的用户头像是上一次的,fileList不是最新值,之前antd的时候,是在render中 写Modal标签用visible控制显示,它自己会实时渲染的,这里Modal的pro组件可以这么写吗?visible属性都没有, 请问大神这问题该如何解决?
( 另外想知道问题出现的原因是什么, 是因为非return/render不会实时渲染吗? )
伪代码如下:
const comp = () => {
const context = useContext(Store);
const { dataSet } = context;
const [fileList,setFileList] = useState(UploadFile[]);
// 点击按钮,触发
const showModal = (userId: number) => {
loadData(userId)
Modal.open(
..
children: getForm() // 调用getForm获取表单
)
}
async function loadData (userId: number) {
axios.get(..) // 调后端,查用户信息.
.then(result => {
dataSet.loadData([result])
setFileList({ // 头像url放进state中
..
url
})
})
}
cosnt getForm = () => {
props = {
..
defaultList = fileList // 取state变量
}
<Form dataSet={dataSet}>
..
<Upload props={..props} >上传</>
</Form>
}
return (
<div>XXXX</div>
)
}
export default comp;
{
name: 'reportDateFrom',
type: FieldType.date,
max: 'reportDateTo',
label: intl.get('hssp.screen.exp_report_header.report_date_from'),
},
{
name: 'reportDateTo',
type: FieldType.date,
min: 'reportDateFrom',
label: intl.get('hssp.screen.exp_report_header.report_date_to'),
},
在dataset的fields里给日期字段指定了最大值、最小值之后,在没有选择日期时,最大值、最小值都会变成当前日期。
这样会导致用户日期从
选不到当前日期之后的日期,日期到
选不到当前日期之前的日期。如果选了之后再清空,就全部变成不可选了。
能否改成没有值的时候不做限制?
使用版本:1.3.2; 测试版本:1.3.2、1.4.4
IntlField 组件,DS中设置字段maxLength属性 只能限制 中文名称的长度,英文跟日文没限制
Error: [MobX] 'has()' can only be used on observable objects, arrays and maps
▶ 36 stack frames were collapsed.
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error. Click the 'X' or hit ESC to dismiss this message.
我想在 Sketch 中使用这套 UI,在官网好像没找到 Sketch 相关的插件。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.