Skip to content

add table components - #6

Merged
lazyperson merged 5 commits into
masterfrom
table
Jun 26, 2019
Merged

add table components#6
lazyperson merged 5 commits into
masterfrom
table

Conversation

@baukh789

Copy link
Copy Markdown

1、增加table组件;2、修改webpack.config中loader的范围

return (
<Table
gridManagerName={gridManagerName}
ajax_data='http://www.lovejavascript.com/blogManager/getBlogList'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api的风格都统一成一种风格吧,ajax_data=>ajaxData...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ajax_*API是否可以合并一下?比如传一个resourcepromise...就可以

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在React版本中,除特殊情况。
仅会使用到ajax_data,其它的是应用于特殊情况,并非常用项。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们正常的使用方式,应该是如下:

ajax_data: () => {
       return promise;  // 这里返回一个promise,或await
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在这个文件内将demo调整为promise的形式。

render() {
return (
<Table
gridManagerName={gridManagerName}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gridManagerName这个参数不传是否可以正常工作呢,如果这个字段在外面没有什么其他操作的话,可以在内部生成一个唯一的

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以在组件内部去创建一个唯一的name,如果外面传进来了,那么使用外面传进来的,一般情况下外面传进来可能是因为页面纯在多分表格,然后有一些操作,纯展示的表格我认为是不需要传name的

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个值是必传项,且不允许重复。
类似于一组数据的ID。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否可以把gridManagerName封装到Table内部呢

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个值在调用方法时需要用到

| isCombSorting | 用于配置是否使用组合排序功能| boolean | false |
| mergeSort | 配置是否合并排序字段| boolean | false |
| sortKey | ajax请求中排序字段所使用的前缀| string | 'sort_' |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以考虑把 refreshGrid方法帮到Table上,比如 Table.refreshGrid(...),这样Table更像一个比较封闭的组件,而不是需要借助Table组件之外的其他方法/服务

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前是支持这种形式的, 共有两种调用方式。如下:

import Table, {$gridManager} from '/xxx/table';
Table. refreshGrid(...) or gridManager. refreshGrid(...) 

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议只暴露一种方式,不暴露多种使用方式,既然两种效果是一样的,那么保留一种就好,然后API文档上注明这个服务的作用和使用方式

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Table为react对像,$gridManager为原生对像。
现在是仅将Table爆露

Comment thread src/components/table/index.js Outdated
@@ -0,0 +1,87 @@
/* eslint-disable */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉禁用eslint

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个暂时无法移除,需要调整框架对依赖项的配置,已经与@rookie沟通。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image
这个需要去调整规则,或者是查看在该项目中出现这种情况的原因(已经在其它项目测试,不存在该问题)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已引入了eslint-import-resolver-webpack进行了处理

// 组件: 标题
function TitleComponents(props) {
return (
<a href={'https://www.lovejavascript.com/#!zone/blog/content.html?id=' + props.row.id} target={'_black'}>{props.row.title}</a>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议:用模板字符串的方式拼接看上去优雅一些

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个需要调整eslint规则,现有eslint规则中markdown不能使用模板字符串。

{index} - 快速、灵活的对Table标签进行实例化,让Table标签充满活力。该项目已开源,
<a target="_blank" href="https://github.com/baukh789/GridManager">点击进入</a>
github
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsx缩进对齐格式

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块是两个text中间有一个a标签,并不是父子关系的元素。


.table-wrap.ccms-skin,
.table-wrap.ccms-skin.icon-follow-text {
.table-header{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

类名与{之间缺少空格

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index.less多处类名与{空格问题需要调整

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

色值大小写应该一致,有的是大写,有的是小写

Comment thread src/components/table/index.less Outdated
@table-header-color: #F1F1F1;
@table-border: 1px solid #EEEEEE;
@sort-action-color: #ccc;
@sort-action-color-hover: #0083BA;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

颜色值最好统一全部大写或全部小写

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@lazyperson
lazyperson merged commit 18ff761 into master Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants