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
3e410bcf
Commit
3e410bcf
authored
Jul 29, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
fe52fe33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
131 additions
and
30 deletions
+131
-30
index.ts
src/module/productModule/index.ts
+11
-0
addProducts.tsx
src/pages/commodity/products/addProducts.tsx
+20
-6
basicInfoForm.tsx
...ages/commodity/products/addProductsItem/basicInfoForm.tsx
+0
-0
logisticsForm.tsx
...ages/commodity/products/addProductsItem/logisticsForm.tsx
+11
-3
otherForm.tsx
src/pages/commodity/products/addProductsItem/otherForm.tsx
+10
-3
priceAttributeForm.tsx
...commodity/products/addProductsItem/priceAttributeForm.tsx
+0
-0
productAttributeForm.tsx
...mmodity/products/addProductsItem/productAttributeForm.tsx
+25
-11
selectGoodsForm.tsx
...es/commodity/products/addProductsItem/selectGoodsForm.tsx
+12
-5
index.tsx
src/store/index.tsx
+7
-2
index.ts
src/store/product/index.ts
+35
-0
No files found.
src/module/productModule/index.ts
0 → 100644
View file @
3e410bcf
export
interface
IProductModule
{
productName
:
string
;
productSelectAttribute
:
any
[];
selectedGoods
:
any
[];
tableDataSource
:
any
[];
setProductName
(
name
:
string
):
void
;
setProductSelectAttribute
(
list
:
any
[]):
void
;
setSelectedGoods
(
lists
:
any
[]):
void
;
setTableDataSource
(
datas
:
any
[]):
void
;
}
src/pages/commodity/products/addProducts.tsx
View file @
3e410bcf
import
React
,
{
useState
,
useRef
,
useEffect
}
from
'react'
import
React
,
{
useState
,
useRef
,
useEffect
,
createContext
}
from
'react'
import
{
history
}
from
'umi'
;
import
{
Button
,
Card
,
Tabs
}
from
'antd'
import
{
PageHeaderWrapper
}
from
'@ant-design/pro-layout'
...
...
@@ -21,9 +21,12 @@ const { TabPane } = Tabs
const
AddProducts
:
React
.
FC
<
{}
>
=
(
props
)
=>
{
const
[
attributeList
,
setAttributeList
]
=
useState
<
any
[]
>
([])
let
[
formRefs
,
setFormRefs
]
=
useState
([])
//子form的ref数组
const
onSave
=
()
=>
{
console
.
log
(
'点击保存'
)
console
.
log
(
formRefs
,
'formrefs'
)
}
const
callback
=
(
key
:
any
)
=>
{
...
...
@@ -45,16 +48,23 @@ const AddProducts: React.FC<{}> = (props) => {
<
Card
>
<
Tabs
onChange=
{
callback
}
type=
"card"
defaultActiveKey=
"1"
>
<
TabPane
tab=
"基本信息"
key=
"11"
>
<
BasicInfoForm
onChangeAttributeList=
{
(
_lists
:
any
)
=>
setAttributeList
(
_lists
)
}
/>
<
BasicInfoForm
onRef=
{
(
refs
)
=>
setFormRefs
([...
formRefs
,
refs
])
}
onChangeAttributeList=
{
(
_lists
:
any
)
=>
setAttributeList
(
_lists
)
}
/>
</
TabPane
>
<
TabPane
tab=
"选择货品"
key=
"22"
>
<
SelectGoodsForm
/>
</
TabPane
>
<
TabPane
tab=
"商品属性"
key=
"33"
>
<
ProductAttributeForm
attributesData=
{
attributeList
}
/>
<
ProductAttributeForm
onRef=
{
(
refs
)
=>
setFormRefs
([...
formRefs
,
refs
])
}
attributesData=
{
attributeList
}
/>
</
TabPane
>
<
TabPane
tab=
"价格设置"
key=
"44"
>
<
PriceAttributeForm
/>
<
PriceAttributeForm
onRef=
{
(
refs
)
=>
setFormRefs
([...
formRefs
,
refs
])
}
/>
</
TabPane
>
<
TabPane
tab=
"商品图片"
key=
"55"
style=
{
{
border
:
'1px solid rgba(223,225,230,1)'
}
}
>
<
ProductImageForm
/>
...
...
@@ -63,10 +73,14 @@ const AddProducts: React.FC<{}> = (props) => {
<
ProductDescForm
/>
</
TabPane
>
<
TabPane
tab=
"物流信息"
key=
"77"
>
<
LogisticsForm
/>
<
LogisticsForm
onRef=
{
(
refs
)
=>
setFormRefs
([...
formRefs
,
refs
])
}
/>
</
TabPane
>
<
TabPane
tab=
"其他"
key=
"88"
>
<
OtherForm
/>
<
OtherForm
onRef=
{
(
refs
)
=>
setFormRefs
([...
formRefs
,
refs
])
}
/>
</
TabPane
>
</
Tabs
>
</
Card
>
...
...
src/pages/commodity/products/addProductsItem/basicInfoForm.tsx
View file @
3e410bcf
This diff is collapsed.
Click to expand it.
src/pages/commodity/products/addProductsItem/logisticsForm.tsx
View file @
3e410bcf
import
React
,
{
useState
,
useEffect
}
from
'react'
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
import
{
history
}
from
'umi'
import
{
Button
,
Form
,
Select
,
Checkbox
,
Tooltip
,
Radio
,
Input
,
Table
,
Modal
,
Row
,
Col
}
from
'antd'
import
styles
from
'./index.less'
...
...
@@ -17,21 +17,29 @@ const layout = {
}
export
interface
Iprops
{
onRef
:
(
refs
:
any
)
=>
void
;
}
const
{
Option
}
=
Select
const
LogisticsForm
:
React
.
FC
<
Iprops
>
=
(
props
)
=>
{
const
{
onRef
}
=
props
const
logisticsFormRef
=
useRef
()
const
[
logisticsForm
]
=
Form
.
useForm
()
useEffect
(()
=>
{
//传入ref给父级
onRef
(
logisticsFormRef
)
},
[])
return
(<>
<
Form
{
...
layout
}
form=
{
logisticsForm
}
name=
"
add-products-transport
"
name=
"
logistic-form
"
labelAlign=
"left"
ref=
{
logisticsFormRef
}
>
<
Form
.
Item
name=
"transportType"
...
...
src/pages/commodity/products/addProductsItem/otherForm.tsx
View file @
3e410bcf
import
React
,
{
useState
,
useEffect
}
from
'react'
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
import
{
history
}
from
'umi'
import
{
Button
,
Form
,
Select
,
Checkbox
,
Tooltip
,
Radio
,
Input
,
Table
,
Modal
,
Row
,
Col
}
from
'antd'
import
styles
from
'./index.less'
...
...
@@ -17,22 +17,29 @@ const layout = {
}
export
interface
Iprops
{
onRef
:
(
refs
:
any
)
=>
void
;
}
const
{
Option
}
=
Select
const
{
TextArea
}
=
Input
const
OtherForm
:
React
.
FC
<
Iprops
>
=
(
props
)
=>
{
const
{
onRef
}
=
props
const
otherFormRef
=
useRef
()
const
[
otherForm
]
=
Form
.
useForm
()
useEffect
(()
=>
{
//传入ref给父级
onRef
(
otherFormRef
)
},
[])
return
(<>
<
Form
{
...
layout
}
form=
{
otherForm
}
name=
"
add-products-other
"
name=
"
other-form
"
labelAlign=
"left"
ref=
{
otherFormRef
}
>
<
Form
.
Item
name=
"bill"
...
...
src/pages/commodity/products/addProductsItem/priceAttributeForm.tsx
View file @
3e410bcf
This diff is collapsed.
Click to expand it.
src/pages/commodity/products/addProductsItem/productAttributeForm.tsx
View file @
3e410bcf
import
React
,
{
useState
,
useEffect
}
from
'react'
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
'react'
import
{
history
}
from
'umi'
import
{
Button
,
Form
,
Select
,
Checkbox
,
Tabs
,
Input
}
from
'antd'
import
styles
from
'./index.less'
...
...
@@ -7,6 +7,11 @@ import { StandardTable } from 'god'
import
{
ColumnType
}
from
'antd/lib/table/interface'
import
{
EyeOutlined
}
from
'@ant-design/icons'
import
{
inject
,
observer
}
from
'mobx-react'
// import { IProductModule } from '@/module/productModule'
// import { IStore } from '@/store';
import
{
store
}
from
'@/store'
const
layout
=
{
labelCol
:
{
span
:
2
,
...
...
@@ -24,6 +29,7 @@ const tailLayout = {
export
interface
Iprops
{
attributesData
:
any
[];
onRef
:
(
refs
:
any
)
=>
void
;
}
const
{
TabPane
}
=
Tabs
...
...
@@ -31,8 +37,15 @@ const { Option } = Select
const
{
TextArea
}
=
Input
const
ProductAttributeForm
:
React
.
FC
<
Iprops
>
=
(
props
)
=>
{
const
{
attributesData
}
=
props
const
{
attributesData
,
onRef
}
=
props
const
productAttributeFormRef
=
useRef
()
const
[
attributeForm
]
=
Form
.
useForm
()
const
{
ProductStore
}
=
store
useEffect
(()
=>
{
//传入ref给父级
onRef
(
productAttributeFormRef
)
},
[])
let
paramsArray
=
[];
...
...
@@ -47,7 +60,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
* @param {Object} attrItem 属性数据对象
*/
const
onChange
=
(
value
,
attrItem
)
=>
{
let
params
=
{
customerAttributeId
:
attrItem
.
id
,
customerAttributeValueList
:
[]
}
let
params
=
{
customerAttributeId
:
attrItem
.
id
,
attributeName
:
attrItem
.
name
,
isPrice
:
attrItem
.
isPrice
,
customerAttributeValueList
:
[]
}
if
(
attrItem
.
type
!==
3
){
for
(
let
item
of
attrItem
?.
customerAttributeValueList
){
if
(
value
?.
length
){
...
...
@@ -55,7 +68,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
if
(
item
.
id
===
i
){
params
.
customerAttributeValueList
.
push
({
customerAttributeValueId
:
i
,
value
:
item
.
value
value
:
item
.
value
,
})
}
}
...
...
@@ -63,7 +76,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
if
(
item
.
id
===
value
){
params
.
customerAttributeValueList
.
push
({
customerAttributeValueId
:
value
,
value
:
item
.
value
value
:
item
.
value
,
})
}
}
...
...
@@ -71,7 +84,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
}
else
{
params
.
customerAttributeValueList
.
push
({
customerAttributeValueId
:
null
,
value
:
value
.
target
.
value
value
:
value
.
target
.
value
,
})
}
paramsArray
.
push
(
params
)
...
...
@@ -80,8 +93,8 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
item
[
next
.
customerAttributeId
]
=
next
;
return
item
},{}))
console
.
log
(
resultParams
)
// 最终转换的数据格式
console
.
log
(
resultParams
,
'resultParams'
)
// 最终转换数据
ProductStore
.
setProductSelectAttribute
(
resultParams
)
//注入mobx
}
const
renderTabPanchildren
=
(
attrItem
:
any
)
=>
{
...
...
@@ -123,7 +136,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
<
Checkbox
.
Group
onChange=
{
(
v
)
=>
onChange
(
v
,
attrItem
)
}
>
{
attrItem
?.
customerAttributeValueList
.
length
>
0
&&
attrItem
.
customerAttributeValueList
.
map
((
item
:
any
,
index
:
string
)
=>
(
<
Checkbox
key=
{
item
.
id
}
value=
{
item
.
id
}
>
{
item
.
value
}
</
Checkbox
>
<
Checkbox
key=
{
item
.
id
+
index
}
value=
{
item
.
id
}
>
{
item
.
value
}
</
Checkbox
>
))
}
</
Checkbox
.
Group
>
...
...
@@ -153,6 +166,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
name=
"attribute-form"
labelAlign=
"left"
onFinish=
{
onFinish
}
ref=
{
productAttributeFormRef
}
>
<
Tabs
defaultActiveKey=
"1"
tabPosition=
"left"
>
{
...
...
@@ -179,4 +193,4 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
</>)
}
export
default
ProductAttributeForm
\ No newline at end of file
export
default
observer
(
ProductAttributeForm
)
\ No newline at end of file
src/pages/commodity/products/addProductsItem/selectGoodsForm.tsx
View file @
3e410bcf
import
React
,
{
useState
,
useEffect
}
from
'react'
import
React
,
{
useState
,
useEffect
,
useContext
}
from
'react'
import
{
history
}
from
'umi'
import
{
Button
,
Form
,
Select
,
Checkbox
}
from
'antd'
import
styles
from
'./index.less'
...
...
@@ -7,6 +7,11 @@ import { StandardTable } from 'god'
import
{
ColumnType
}
from
'antd/lib/table/interface'
import
{
EyeOutlined
}
from
'@ant-design/icons'
import
{
inject
,
observer
}
from
'mobx-react'
// import { IProductModule } from '@/module/productModule'
// import { IStore } from '@/store';
import
{
store
}
from
'@/store'
const
layout
=
{
labelCol
:
{
span
:
2
,
...
...
@@ -22,9 +27,10 @@ export interface Iprops {
const
SelectGoodsForm
:
React
.
FC
<
Iprops
>
=
(
props
)
=>
{
const
[
selectGoodsForm
]
=
Form
.
useForm
()
const
[
showSelectGoods
,
setSelectGoods
]
=
useState
(
false
)
const
[
showSelectGoods
,
set
Is
SelectGoods
]
=
useState
(
false
)
const
[
selectGoodsRow
,
setSelectGoodsRow
]
=
useState
<
any
[]
>
([])
// 模态框选择的行数据
const
[
selectedGoodsRowKeys
,
setSelectedGoodsRowKeys
]
=
useState
<
Array
<
number
>>
([])
const
{
ProductStore
}
=
store
const
fetchData
=
(
params
:
any
)
=>
{
console
.
log
(
params
)
...
...
@@ -78,12 +84,13 @@ const SelectGoodsForm: React.FC<Iprops> = (props) => {
const
onSelectGoodsChange
=
(
value
:
any
)
=>
{
setSelectedGoodsRowKeys
([])
setSelectGoods
(
value
.
target
.
checked
)
set
Is
SelectGoods
(
value
.
target
.
checked
)
}
const
rowSelection
=
{
selectedRowKeys
:
selectedGoodsRowKeys
,
onChange
:
(
selectedRowKeys
:
any
,
selectedRows
:
any
)
=>
{
ProductStore
.
setSelectedGoods
(
selectedRows
)
setSelectGoodsRow
(
selectedRows
);
setSelectedGoodsRowKeys
(
selectedRowKeys
);
console
.
log
(
`selectedRowKeys:
${
selectedRowKeys
}
`
,
'selectedRows: '
,
selectedRows
);
...
...
@@ -112,4 +119,4 @@ const SelectGoodsForm: React.FC<Iprops> = (props) => {
</>)
}
export
default
SelectGoodsForm
\ No newline at end of file
export
default
observer
(
SelectGoodsForm
)
\ No newline at end of file
src/store/index.tsx
View file @
3e410bcf
import
UserStore
from
'./user'
import
ThemeStore
from
'./theme'
import
ProductStroe
from
'./product'
import
React
from
'react'
;
import
{
Provider
}
from
'mobx-react'
import
{
IUserModule
}
from
'@/module/userModule'
;
import
{
IProductModule
}
from
'@/module/productModule'
// import { ProductContext } from '@/pages/commodity/products/addProducts';
/**
*
...
...
@@ -20,12 +23,14 @@ import { IUserModule } from '@/module/userModule';
*/
export
interface
IStore
{
userStore
:
IUserModule
userStore
:
IUserModule
;
ProductStore
:
IProductModule
;
}
const
store
=
{
export
const
store
=
{
userStore
:
new
UserStore
,
ThemeStore
:
new
ThemeStore
,
ProductStore
:
new
ProductStroe
}
const
MobxProvider
:
React
.
FC
=
(
props
)
=>
{
...
...
src/store/product/index.ts
0 → 100644
View file @
3e410bcf
import
{
action
,
computed
,
observable
,
runInAction
}
from
'mobx'
import
{
IProductModule
}
from
'@/module/productModule'
;
// mobx要用到的数据类型
class
ProductStore
implements
IProductModule
{
@
observable
public
productName
:
string
=
""
;
@
observable
public
productSelectAttribute
:
any
[]
=
[];
@
observable
public
selectedGoods
:
any
[]
=
[];
@
observable
public
tableDataSource
:
any
[]
=
[];
/** 定义动作区块,外部调用,改变对应的状态 **/
// 可以改变存的testText值
@
action
.
bound
public
setProductName
(
name
:
string
)
{
this
.
productName
=
name
;
}
@
action
.
bound
public
setProductSelectAttribute
(
list
:
any
[])
{
this
.
productSelectAttribute
=
list
;
}
@
action
.
bound
public
setSelectedGoods
(
list
:
any
[])
{
this
.
selectedGoods
=
list
;
}
@
action
.
bound
public
setTableDataSource
(
datas
:
any
[])
{
console
.
log
(
datas
,
'innerBox'
)
this
.
tableDataSource
=
datas
;
}
}
export
default
ProductStore
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