Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with Prettier and StandardJS #389

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/hooks/useTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useTable = (props) => {
}
dataInterface({
...(isPagination ? { pageNum: page, pageSize } : {}),
...other,
...other
}).then((resp) => {
if (resp && resp.status === 1) {
setPage(page)
Expand Down Expand Up @@ -73,7 +73,7 @@ const useTable = (props) => {
setCachePayload({ ...payload })
getTableList(dataInterface || props.dataInterface, {
...cachePayload,
...payload,
...payload
})
}

Expand Down Expand Up @@ -101,16 +101,16 @@ const useTable = (props) => {
showQuickJumper: true,
showSizeChanger: true,
hideOnSinglePage: false,
showTotal: (total) => <span>{`共计 ${total} 条记录 第${page}/${Math.ceil(total / pageSize)}页`}</span>,
showTotal: (total) => <span>{`共计 ${total} 条记录 第${page}/${Math.ceil(total / pageSize)}页`}</span>
}
: false,
scroll: dataSource.length ? { scrollToFirstRowOnChange: true, x: 'max-content' } : false,
scroll: dataSource.length ? { scrollToFirstRowOnChange: true, x: 'max-content' } : false
},
page,
pageSize,
rawData,
updateTable,
resetTable,
resetTable
}
}
export default useTable
Expand Down
2 changes: 1 addition & 1 deletion src/components/stateful/CheckableTags/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const CheckableTags = forwardRef((props, ref) => {

useImperativeHandle(ref, () => ({
setSelectedTags,
handleChange,
handleChange
}))
return (
<div className={styles.checkableTags}>
Expand Down
16 changes: 8 additions & 8 deletions src/components/stateful/TreeList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Index = forwardRef((props, ref) => {
selectedKeys, // 选中的节点
setSelectedKeys, // 选中外传函数
selectable = false, // 父级节点是否可以选中
params = {}, // 额外的参数
params = {} // 额外的参数
} = props
const [treeList, setTreeList] = useState([]) // 全量数据源列表
const [treeData, setTreeData] = useState([])
Expand Down Expand Up @@ -87,7 +87,7 @@ const Index = forwardRef((props, ref) => {
return {
...item,
key: itemPath,
...(item.children?.length ? { children: setPath(item.children, itemPath) } : {}),
...(item.children?.length ? { children: setPath(item.children, itemPath) } : {})
}
})
treeData = setPath(treeData)
Expand Down Expand Up @@ -123,7 +123,7 @@ const Index = forwardRef((props, ref) => {
const defaultKey = selectable
? {
selected: [treeData[0].key],
expanded: [treeData[0].key],
expanded: [treeData[0].key]
}
: getDefaultKey(treeData)
selected = defaultKey.selected
Expand All @@ -133,7 +133,7 @@ const Index = forwardRef((props, ref) => {
const defaultKey = selectable
? {
selected: [treeData[0].key],
expanded: [treeData[0].key],
expanded: [treeData[0].key]
}
: getDefaultKey(treeData)
selected = defaultKey.selected
Expand All @@ -159,7 +159,7 @@ const Index = forwardRef((props, ref) => {
})
selected = selectedKeys

function loop(params) {
function loop (params) {
return params.some((item) => {
if (item.realId === selectedKeys[0]) {
expanded = [item.key]
Expand All @@ -176,7 +176,7 @@ const Index = forwardRef((props, ref) => {
const defaultKey = selectable
? {
selected: [treeData[0].key],
expanded: [treeData[0].key],
expanded: [treeData[0].key]
}
: getDefaultKey(treeData)
selected = defaultKey.selected
Expand Down Expand Up @@ -214,14 +214,14 @@ const Index = forwardRef((props, ref) => {
expandedKeys,
setExpandedKeys,
setSelectedKeys: _setSelectedKeys,
treeData,
treeData
}))

return (
<div className={`${styles.treeList} treeList`}>
<div>
{search && (
<Search placeholder="搜索" onSearch={onSearch} style={{ marginBottom: 10, width: '100%' }} allowClear />
<Search placeholder='搜索' onSearch={onSearch} style={{ marginBottom: 10, width: '100%' }} allowClear />
)}
<Tree
selectedKeys={!isEmpty(selectedKeys) ? selectedKeys : _selectedKeys}
Expand Down
34 changes: 18 additions & 16 deletions src/components/stateful/TreeList/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/* eslint-disable no-underscore-dangle */
import React from 'react'

export function getDefaultKey(treeData) {
export function getDefaultKey (treeData) {
let selected = []
let expanded = []
function forFn(data, parentKey) {
function forFn (data, parentKey) {
return data.some((item) => {
if (item.children && item.children.length) {
return forFn(item.children, item.key)
Expand All @@ -19,14 +19,14 @@ export function getDefaultKey(treeData) {

return { selected, expanded }
}
export function processTreeData(list, pid) {
export function processTreeData (list, pid) {
return list
.filter((item) => item.pid === pid)
.map((item) => ({
pid,
key: item.id,
title: item.name,
children: processTreeData(list, item.id),
children: processTreeData(list, item.id)
}))
}

Expand All @@ -38,16 +38,16 @@ export const loopTreeData = (data) =>
title,
key: item.key,
pid: item.pid,
children: loopTreeData(item.children),
children: loopTreeData(item.children)
}
}
return {
title,
key: item.key,
pid: item.pid,
pid: item.pid
}
})
export function expandTree(a, b, setExpandedKeys) {
export function expandTree (a, b, setExpandedKeys) {
if (b.expanded) {
if (a.length > 0) {
a.splice(0, a.length - 1)
Expand Down Expand Up @@ -77,27 +77,29 @@ export const loopTreeDataWithSearch = (data, searchValue) =>
const beforeStr = item.title.substr(0, index)
const afterStr = item.title.substr(index + searchValue.length)
const title =
index > -1 ? (
<span>
{beforeStr} <span style={{ color: '#D12604' }}>{searchValue}</span> {afterStr}
</span>
) : (
<span>{item.title}</span>
)
index > -1
? (
<span>
{beforeStr} <span style={{ color: '#D12604' }}>{searchValue}</span> {afterStr}
</span>
)
: (
<span>{item.title}</span>
)
if (item.children) {
return {
title,
key: item.key,
pid: item.pid,
// selectable: item.flag,
children: loopTreeDataWithSearch(item.children, searchValue),
children: loopTreeDataWithSearch(item.children, searchValue)
}
}
return {
title,
// selectable: item.flag,
key: item.key,
pid: item.pid,
pid: item.pid
}
})
export const getParentKey = (key, tree) => {
Expand Down
Loading