Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈智峰
jinfa-platform
Commits
1484df37
Commit
1484df37
authored
Aug 13, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge
parent
1e9b3524
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
162 additions
and
31 deletions
+162
-31
index.js
scripts/services/index.js
+33
-0
CardCheckBox.tsx
src/components/NiceForm/components/CardCheckBox.tsx
+2
-2
global.d.ts
src/global/config/global.d.ts
+23
-0
useRowSelectionTable.ts
src/hooks/useRowSelectionTable.ts
+48
-4
addRepository.tsx
src/pages/repositories/addRepository.tsx
+6
-3
adjustRepository.tsx
src/pages/repositories/adjustRepository.tsx
+9
-2
index.tsx
src/pages/repositories/effects/index.tsx
+15
-0
index.tsx
src/pages/repositories/schema/index.tsx
+4
-20
index.ts
src/utils/index.ts
+22
-0
No files found.
scripts/services/index.js
View file @
1484df37
...
...
@@ -23,12 +23,45 @@ const serviceConfig = {
url
:
'/member/menu/register/type'
,
method
:
'get'
}
},
web
:
{
shopInfo
:
{
url
:
'/manage/shop/all'
,
method
:
'get'
},
site
:
{
url
:
'/manage/paas/site/all'
,
method
:
'get'
,
// params: linkage => {
// return {
// id: linkage.id
// }
// }
}
},
}
// 批量组装接口
async
function
batchAxiosHttps
()
{
const
asyncHttpQueue
=
deepClone
(
serviceConfig
)
// 请求队列的回调数据
// const requestQueueResult = {}
// const serverFn = async (obj) => {
// for (const item in obj) {
// // 当前属性是一个请求方法
// if (obj[item].url && obj[item].method) {
// const requestConfig = deepClone(obj[item])
// const { data } = await axios(requestConfig)
// requestQueueResult[requestConfig.url] = data.data
// obj[item] = data.data
// } else {
// serverFn(obj[item])
// }
// }
// }
// serverFn(asyncHttpQueue)
for
(
const
item
in
serviceConfig
)
{
for
(
const
subItem
in
serviceConfig
[
item
])
{
const
data
=
await
axios
(
serviceConfig
[
item
][
subItem
])
...
...
src/components/NiceForm/components/CardCheckBox.tsx
View file @
1484df37
...
...
@@ -83,8 +83,8 @@ const CardCheckBox = (props) => {
dataSource
.
map
((
v
,
i
)
=>
{
return
(
<
Col
key=
{
v
.
id
}
className=
{
cx
(
'card-checkbox-item'
,
isChecked
(
v
.
id
)
?
'active'
:
''
)
}
onClick=
{
()
=>
handleChange
(
v
.
id
)
}
>
{
v
.
logo
?
<
img
className=
'card-logo'
src=
{
v
.
logo
}
/>
:
<
div
className=
'card-logo default'
>
logo
</
div
>
}
<
span
className=
'card-checkbox-title'
>
{
v
.
titl
e
}
</
span
>
{
v
.
logo
Url
?
<
img
className=
'card-logo'
src=
{
v
.
logoUrl
}
/>
:
<
div
className=
'card-logo default'
>
logo
</
div
>
}
<
span
className=
'card-checkbox-title'
>
{
v
.
nam
e
}
</
span
>
</
Col
>
)
})
...
...
src/global/config/global.d.ts
View file @
1484df37
...
...
@@ -17,6 +17,27 @@ export interface UserRegister {
useType
:
UseType
;
}
export
interface
ShopInfo
{
id
:
number
;
name
:
string
;
type
:
number
;
environment
:
number
;
logoUrl
:
string
;
describe
:
string
;
state
:
number
;
url
:
string
;
}
export
interface
Site
{
id
:
number
;
name
:
string
;
}
export
interface
Web
{
shopInfo
:
ShopInfo
[];
site
:
Site
[];
}
export
interface
CountryList
{
name
:
string
;
key
:
string
;
...
...
@@ -40,5 +61,6 @@ export interface Global {
export
interface
RootObject
{
userRegister
:
UserRegister
;
web
:
Web
;
global
:
Global
;
}
\ No newline at end of file
src/hooks/useRowSelectionTable.ts
View file @
1484df37
import
{
useState
}
from
'react'
import
{
TableRowSelection
}
from
'antd/es/table/interface'
import
{
mergeArrByKey
,
dupliArr
}
from
'@/utils'
import
{
useSelections
}
from
'@umijs/hooks'
interface
useRowSelectionTableCtl
{
selectRow
:
any
[],
...
...
@@ -18,16 +20,58 @@ interface useRowSelectionOptions {
*/
export
const
useRowSelectionTable
=
(
options
:
useRowSelectionOptions
=
{}):
[
TableRowSelection
<
any
>
,
useRowSelectionTableCtl
]
=>
{
const
{
type
=
'checkbox'
}
=
options
const
[
selectRow
,
setSelectRow
]
=
useState
<
any
[]
>
([])
// 模态框选择的行数据
const
[
selectedRowKeys
,
setSelectedRowKeys
]
=
useState
<
any
[]
>
(()
=>
[])
const
mergeRowKeys
=
(
item
)
=>
{
setSelectedRowKeys
([...
selectedRowKeys
,
item
])
}
const
mergeRow
=
(
item
)
=>
{
setSelectRow
([...
selectRow
,
item
])
}
const
removeRows
=
(
arr
:
any
[])
=>
{
return
selectRow
.
filter
(
v
=>
{
const
result
=
arr
.
find
(
item
=>
item
.
id
===
v
.
id
)
if
(
!
result
)
{
return
v
}
})
}
const
removeRowsKeys
=
(
arr
:
any
[])
=>
{
return
selectedRowKeys
.
filter
(
v
=>
{
const
result
=
arr
.
find
(
item
=>
item
===
v
)
if
(
!
result
)
{
return
v
}
})
}
const
rowSelection
=
{
selectedRowKeys
:
selectedRowKeys
,
type
,
onChange
:
(
selectedRowKeys
:
any
,
selectedRows
:
any
)
=>
{
setSelectRow
(
selectedRows
);
setSelectedRowKeys
(
selectedRowKeys
);
// 为解决分页情况下, 保存多选的数据
onSelect
:
(
record
,
selects
,
selectedRows
,
nativeEvent
)
=>
{
const
findIds
=
selectedRowKeys
.
indexOf
(
record
.
id
)
if
(
findIds
===
-
1
)
{
mergeRowKeys
(
record
.
id
)
mergeRow
(
record
)
}
else
{
setSelectedRowKeys
(
selectedRowKeys
.
filter
((
_
,
i
)
=>
i
!==
findIds
))
setSelectRow
(
selectRow
.
filter
((
_
,
i
)
=>
i
!==
findIds
))
}
},
onSelectAll
:
(
selected
,
selectedRows
,
changeRows
)
=>
{
if
(
selected
)
{
setSelectedRowKeys
(
dupliArr
([...
selectedRowKeys
,
...
changeRows
.
map
(
v
=>
v
.
id
)]))
setSelectRow
(
mergeArrByKey
(
selectRow
,
changeRows
,
'id'
))
}
else
{
setSelectedRowKeys
(
removeRowsKeys
(
changeRows
.
map
(
v
=>
v
.
id
)))
setSelectRow
(
removeRows
(
changeRows
))
}
}
}
...
...
src/pages/repositories/addRepository.tsx
View file @
1484df37
...
...
@@ -22,7 +22,7 @@ import { useRowSelectionTable } from '@/hooks/useRowSelectionTable'
import
{
useAsyncSelect
}
from
'@/formSchema/effects/useAsyncSelect'
import
{
usePageStatus
,
PageStatus
}
from
'@/hooks/usePageStatus'
import
{
useInitValue
}
from
'@/formSchema/effects/useInitValue'
import
{
useWarehouseSelect
,
createAddRepositoryEffect
}
from
'./effects'
import
{
useWarehouseSelect
,
createAddRepositoryEffect
,
useUnitPreview
}
from
'./effects'
import
ModalTable
from
'@/components/ModalTable'
const
fetchMemberList
=
async
(
params
)
=>
{
...
...
@@ -44,12 +44,16 @@ const AddRepository:React.FC<{}> = (props) => {
pageStatus
}
=
usePageStatus
()
const
initValue
=
useInitValue
(
PublicApi
.
getWarehouseFreightSpaceDetails
)
useUnitPreview
(
initValue
,
addSchemaAction
)
const
[
visibleChannelMember
,
setVisibleChannelMember
]
=
useState
(
false
)
const
[
visibleChannelRroduct
,
setVisibleChannelRroduct
]
=
useState
(
false
)
const
[
memberRowSelection
,
memberRowCtl
]
=
useRowSelectionTable
()
const
[
productRowSelection
,
productRowCtl
]
=
useRowSelectionTable
({
type
:
'radio'
})
const
columnsSetMember
:
ColumnType
<
any
>
[]
=
[
{
title
:
'ID'
,
...
...
@@ -167,7 +171,6 @@ const AddRepository:React.FC<{}> = (props) => {
// 设置货品名称
addSchemaAction
.
setFieldValue
(
'itemNo'
,
data
.
name
)
}
const
handleCancelAddProduct
=
()
=>
{
setVisibleChannelRroduct
(
false
)
}
...
...
@@ -233,7 +236,7 @@ const AddRepository:React.FC<{}> = (props) => {
onBack=
{
()
=>
history
.
goBack
()
}
backIcon=
{
<
ReutrnEle
description=
"返回"
/>
}
className=
'addRepository'
title=
"新建仓位"
title=
{
pageStatus
===
PageStatus
.
PREVIEW
?
'查看仓位'
:
'新增仓位'
}
extra=
{
[
<
Button
key=
"1"
onClick=
{
()
=>
addSchemaAction
.
submit
()
}
type=
"primary"
icon=
{
<
SaveOutlined
/>
}
>
保存
...
...
src/pages/repositories/adjustRepository.tsx
View file @
1484df37
...
...
@@ -24,7 +24,7 @@ import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import
{
useInitValue
}
from
'@/formSchema/effects/useInitValue'
import
{
useSyncValues
}
from
'@/formSchema/effects/useSyncValues'
import
{
useLinkageUtils
}
from
'@/utils/formEffectUtils'
import
{
createAddRepositoryEffect
}
from
'./effects'
import
{
createAddRepositoryEffect
,
useUnitPreview
}
from
'./effects'
import
ModalTable
from
'@/components/ModalTable'
const
fetchMemberList
=
async
(
params
)
=>
{
...
...
@@ -75,7 +75,7 @@ const AddRepository:React.FC<{}> = (props) => {
const
[
memberRowSelection
,
memberRowCtl
]
=
useRowSelectionTable
()
const
[
productRowSelection
,
productRowCtl
]
=
useRowSelectionTable
({
type
:
'radio'
})
useUnitPreview
(
initValue
,
addSchemaAction
)
const
columnsSetMember
:
ColumnType
<
any
>
[]
=
[
{
title
:
'ID'
,
...
...
@@ -211,6 +211,13 @@ const AddRepository:React.FC<{}> = (props) => {
{
dataIndex
:
'ctl'
,
title
:
'操作'
,
align
:
'center'
,
render
:
(
_
,
record
)
=>
<
Button
type=
'link'
onClick=
{
()
=>
handleDeleteTable
(
record
.
id
)
}
>
删除
</
Button
>
}
]
const
tableRecordColumns
=
[
{
dataIndex
:
'id'
,
title
:
'ID'
,
align
:
'center'
},
{
dataIndex
:
'id'
,
title
:
'ID'
,
align
:
'center'
},
{
dataIndex
:
'id'
,
title
:
'ID'
,
align
:
'center'
},
{
dataIndex
:
'id'
,
title
:
'ID'
,
align
:
'center'
},
]
const
tableAddButton
=
<
Button
style=
{
{
marginBottom
:
16
}
}
block
icon=
{
<
PlusOutlined
/>
}
onClick=
{
handleAddMemberBtn
}
type=
'dashed'
>
选择指定会员
</
Button
>
const
formSearch
:
ISchema
=
{
...
...
src/pages/repositories/effects/index.tsx
View file @
1484df37
import
React
,
{
useEffect
}
from
'react'
import
{
ISchemaFormActions
,
FormEffectHooks
}
from
'@formily/antd'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
useAsyncSelect
}
from
'@/formSchema/effects/useAsyncSelect'
;
...
...
@@ -30,3 +31,16 @@ export const createAddRepositoryEffect = (context) => {
useAsyncSelect
(
'warehouseId'
,
fetchWarehouseAll
)
useWarehouseSelect
(
context
)
}
export
const
useUnitPreview
=
(
initValue
,
context
)
=>
{
useEffect
(()
=>
{
if
(
initValue
)
{
context
.
setFieldState
(
'inventory'
,
state
=>
{
if
(
!
state
.
props
[
'x-props'
])
{
state
.
props
[
'x-props'
]
=
{}
}
state
.
props
[
'x-props'
].
addonAfter
=
<
div
style=
{
{
marginLeft
:
4
}
}
>
{
initValue
.
unit
}
</
div
>
})
}
},
[
initValue
])
}
\ No newline at end of file
src/pages/repositories/schema/index.tsx
View file @
1484df37
import
React
from
'react'
import
{
ISchema
}
from
'@formily/antd'
;
import
{
FORM_FILTER_PATH
}
from
'@/formSchema/const'
;
import
EyePreview
from
'@/components/EyePreview'
;
import
{
Button
}
from
'antd'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
export
const
repositSchema
:
ISchema
=
{
type
:
'object'
,
...
...
@@ -224,12 +223,7 @@ export const repositMoreSchema: ISchema = {
"type"
:
"array:number"
,
"x-component"
:
'CardCheckBox'
,
"x-component-props"
:
{
dataSource
:
[
{
logo
:
''
,
title
:
'会员'
,
id
:
1
},
{
logo
:
''
,
title
:
'小程序'
,
id
:
2
},
{
logo
:
''
,
title
:
'H5'
,
id
:
3
},
{
logo
:
''
,
title
:
'渠道'
,
id
:
4
},
]
dataSource
:
GlobalConfig
.
web
.
shopInfo
},
"title"
:
"适用商城"
,
required
:
true
,
...
...
@@ -414,12 +408,7 @@ export const repositDetailSchema: ISchema = {
"type"
:
"array:number"
,
"x-component"
:
'CardCheckBox'
,
"x-component-props"
:
{
dataSource
:
[
{
logo
:
''
,
title
:
'会员'
,
id
:
1
},
{
logo
:
''
,
title
:
'小程序'
,
id
:
2
},
{
logo
:
''
,
title
:
'H5'
,
id
:
3
},
{
logo
:
''
,
title
:
'渠道'
,
id
:
4
},
]
dataSource
:
GlobalConfig
.
web
.
shopInfo
},
"title"
:
"适用商城"
,
required
:
true
,
...
...
@@ -604,12 +593,7 @@ export const repositTabOneSchema: ISchema = {
"type"
:
"array:number"
,
"x-component"
:
'CardCheckBox'
,
"x-component-props"
:
{
dataSource
:
[
{
logo
:
''
,
title
:
'会员'
,
id
:
1
},
{
logo
:
''
,
title
:
'小程序'
,
id
:
2
},
{
logo
:
''
,
title
:
'H5'
,
id
:
3
},
{
logo
:
''
,
title
:
'渠道'
,
id
:
4
},
]
dataSource
:
GlobalConfig
.
web
.
shopInfo
},
"title"
:
"适用商城"
,
required
:
true
,
...
...
src/utils/index.ts
View file @
1484df37
...
...
@@ -128,6 +128,28 @@ export const findItemAndDelete = (arr: any[], target) => {
}
}
// 数组通过某个key进行去重合并, 并返回一个新数组
export
const
mergeArrByKey
=
(
preArr
:
any
[],
nextArr
:
any
[],
target
?:
string
)
=>
{
const
mergeArr
=
preArr
.
concat
(
nextArr
)
if
(
target
)
{
const
result
:
any
[]
=
[]
mergeArr
.
forEach
(
v
=>
{
const
s
=
result
.
find
(
j
=>
j
[
target
]
===
v
[
target
])
if
(
!
s
)
{
result
.
push
(
v
)
}
})
return
result
}
else
{
return
Array
.
from
(
new
Set
(
mergeArr
))
}
}
// 数组去重
export
const
dupliArr
=
(
arr
:
any
[])
=>
{
return
Array
.
from
(
new
Set
(
arr
))
}
// 遍历树拿到所有key的集合
export
const
findTreeKeys
=
(
arr
:
any
[],
keyword
?:
ReactText
)
=>
{
const
copyArr
:
any
[]
=
deepClone
(
arr
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment