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
linweijiong
jinfa-platform
Commits
3d0083d0
Commit
3d0083d0
authored
Aug 06, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
d74d340a
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
129 additions
and
48 deletions
+129
-48
index.tsx
src/components/StatusSwitch/index.tsx
+4
-2
index.ts
src/module/productModule/index.ts
+14
-0
addGoods.tsx
src/pages/commodity/goods/addGoods.tsx
+1
-0
basicInfoForm.tsx
...ages/commodity/products/addProductsItem/basicInfoForm.tsx
+12
-7
logisticsForm.tsx
...ages/commodity/products/addProductsItem/logisticsForm.tsx
+5
-2
otherForm.tsx
src/pages/commodity/products/addProductsItem/otherForm.tsx
+1
-7
priceAttributeForm.tsx
...commodity/products/addProductsItem/priceAttributeForm.tsx
+18
-3
productAttributeForm.tsx
...mmodity/products/addProductsItem/productAttributeForm.tsx
+24
-5
productImageForm.tsx
...s/commodity/products/addProductsItem/productImageForm.tsx
+3
-3
fastModifyPrice.tsx
src/pages/commodity/products/fastModifyPrice.tsx
+7
-3
index.ts
src/services/index.ts
+0
-0
index.ts
src/store/product/index.ts
+40
-16
No files found.
src/components/StatusSwitch/index.tsx
View file @
3d0083d0
...
...
@@ -4,12 +4,14 @@ import { PlayCircleOutlined } from '@ant-design/icons'
export
interface
StatusSwitchProps
{
record
:
any
,
fieldNames
?:
string
,
// 自定义字段名称 默认'state'
expectTrueValue
?:
boolean
|
number
|
string
,
//期望为ture(有效)的值 默认1
handleConfirm
?(),
handleCancel
?()
}
const
StatusSwitch
:
React
.
FC
<
StatusSwitchProps
>
=
(
props
)
=>
{
const
{
record
}
=
props
const
{
record
,
fieldNames
=
'state'
,
expectTrueValue
=
1
}
=
props
return
(
<
Popconfirm
title=
"确定要执行这个操作?"
...
...
@@ -18,7 +20,7 @@ const StatusSwitch:React.FC<StatusSwitchProps> = (props) => {
okText=
"是"
cancelText=
"否"
>
<
Button
type=
"link"
style=
{
record
.
state
===
1
?{
color
:
'#00B37A'
}:{
color
:
'red'
}
}
>
{
record
.
state
===
1
?
'有效'
:
'无效'
}
<
PlayCircleOutlined
/></
Button
>
<
Button
type=
"link"
style=
{
record
[
fieldNames
]
===
expectTrueValue
?{
color
:
'#00B37A'
}:{
color
:
'red'
}
}
>
{
record
[
fieldNames
]
===
expectTrueValue
?
'有效'
:
'无效'
}
<
PlayCircleOutlined
/></
Button
>
</
Popconfirm
>
)
}
...
...
src/module/productModule/index.ts
View file @
3d0083d0
...
...
@@ -10,6 +10,20 @@ export interface IBasicFormParam {
slogan
:
string
;
}
export
interface
IPriceAttributeParam
{
unitName
:
string
;
minOrder
:
number
;
isMemberPrice
:
boolean
;
priceType
:
number
;
}
export
interface
IOtherParam
{
isInvoice
:
boolean
;
marks
:
string
;
packing
:
string
;
afterService
:
string
;
}
interface
InnerAttributeValueList
{
customerAttributeValueId
:
number
;
value
:
string
;
...
...
src/pages/commodity/goods/addGoods.tsx
View file @
3d0083d0
...
...
@@ -128,6 +128,7 @@ const AddGoods = () => {
form=
{
form
}
name=
"add-goods"
onFinish=
{
onFinish
}
colon=
{
false
}
>
<
Form
.
Item
name=
"code"
...
...
src/pages/commodity/products/addProductsItem/basicInfoForm.tsx
View file @
3d0083d0
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
'react'
import
{
history
}
from
'umi'
;
import
{
Button
,
Form
,
Select
,
Tabs
,
Input
,
Tooltip
,
Cascader
,
Tag
,
Spin
}
from
'antd'
import
{
QuestionCircleOutlined
,
...
...
@@ -90,16 +91,21 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
}
})
onRef
(
basicFormRef
)
if
(
productInfoByEdit
?.
id
){
},
[])
useEffect
(()
=>
{
const
{
id
}
=
history
.
location
.
query
if
(
id
){
console
.
log
(
productInfoByEdit
,
'productInfoByEdit'
)
handleBrandSearch
(
getBasicFormParamsByEdit
.
brandName
)
onCustomerCategoryChange
([
45
,
47
])
basicForm
.
setFieldsValue
(
getBasicFormParamsByEdit
)
}
},
[])
},
[
productInfoByEdit
,
getBasicFormParamsByEdit
])
//
const onFinish = (values: any) => {
//
console.log(values,'原values')
//
}
const
onFinish
=
(
values
:
any
)
=>
{
console
.
log
(
values
,
'原values'
)
}
const
handleBrandSearch
=
(
value
:
any
)
=>
{
// end value
console
.
log
(
value
,
'handleBrandSearch'
)
...
...
@@ -161,7 +167,6 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
const
onChangeName
=
(
value
:
any
)
=>
{
setProductName
(
value
)
}
return
(<>
<
Form
{
...
layout
}
...
...
@@ -171,7 +176,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
// onFinish={onFinish}
colon=
{
false
}
ref=
{
basicFormRef
}
initialValues=
{
productInfoByEdit
?.
id
?
getBasicFormParamsByEdit
:
{}
}
//
initialValues={productInfoByEdit?.id ? getBasicFormParamsByEdit : {}}
>
<
Form
.
Item
name=
"customerCategoryId"
...
...
src/pages/commodity/products/addProductsItem/logisticsForm.tsx
View file @
3d0083d0
import
React
,
{
useState
,
useEffect
,
useRef
}
from
'react'
import
{
history
}
from
'umi'
import
{
Button
,
Form
,
Select
,
Checkbox
,
Tooltip
,
Radio
,
Input
,
Table
,
Modal
,
Row
,
Col
,
InputNumber
}
from
'antd'
import
{
Form
,
Select
,
Radio
,
Input
}
from
'antd'
import
{
PublicApi
}
from
'@/services/api'
import
{
GetLogisticsSelectListCompanyResponse
,
GetLogisticsSelectListShipperAddressResponse
}
from
'@/services'
import
{
store
}
from
'@/store'
const
{
ProductStore
}
=
store
const
layout
=
{
labelCol
:
{
...
...
@@ -26,6 +27,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
const
[
logisticsForm
]
=
Form
.
useForm
()
const
[
logisticsCompanyLists
,
setLogisticsCompanyLists
]
=
useState
<
GetLogisticsSelectListCompanyResponse
>
()
const
[
logisticsAddressList
,
setLogisticsAddressList
]
=
useState
<
GetLogisticsSelectListShipperAddressResponse
>
()
const
{
productInfoByEdit
}
=
ProductStore
useEffect
(()
=>
{
//传入ref给父级
...
...
@@ -50,6 +52,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
labelAlign=
"left"
ref=
{
logisticsFormRef
}
colon=
{
false
}
initialValues=
{
productInfoByEdit
?.
id
?
productInfoByEdit
.
logistics
:
{}
}
>
<
Form
.
Item
name=
"deliveryType"
...
...
src/pages/commodity/products/addProductsItem/otherForm.tsx
View file @
3d0083d0
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'
import
{
PublicApi
}
from
'@/services/api'
import
{
StandardTable
}
from
'god'
import
{
ColumnType
}
from
'antd/lib/table/interface'
import
{
EyeOutlined
,
QuestionCircleOutlined
,
SettingOutlined
,
PlusOutlined
,
MinusOutlined
}
from
'@ant-design/icons'
import
{
Form
,
Select
,
Radio
,
Input
}
from
'antd'
const
layout
=
{
labelCol
:
{
...
...
src/pages/commodity/products/addProductsItem/priceAttributeForm.tsx
View file @
3d0083d0
...
...
@@ -50,12 +50,25 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
const
[
colums
,
setColumns
]
=
useState
<
ColumnType
<
any
>
[]
>
()
const
{
ProductStore
}
=
store
const
{
productName
,
selectedGoods
,
productSelectAttribute
,
tableDataSource
,
setTableDataSource
,
clearData
,
setPriceAttributeParams
}
=
ProductStore
const
{
productName
,
selectedGoods
,
productSelectAttribute
,
tableDataSource
,
setTableDataSource
,
clearData
,
setPriceAttributeParams
,
productInfoByEdit
,
getPriceAttributeFormParamsByEdit
}
=
ProductStore
_tableDataSource
=
useMemo
(()
=>
tableDataSource
,
[
tableDataSource
])
// 保持最新值
useEffect
(()
=>
{
onRef
(
priceFormRef
)
if
(
productInfoByEdit
?.
id
){
handleUnitSearch
(
getPriceAttributeFormParamsByEdit
.
unitName
)
}
},[])
useEffect
(()
=>
{
...
...
@@ -83,6 +96,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
let
_tempObjArr
=
[]
// 取id备用
_item
.
customerAttributeValueList
.
map
(
__item
=>
{
_tempArr
.
push
(
__item
.
value
)
console
.
log
(
__item
,
'__item'
)
_tempObjArr
.
push
({
customerAttributeValueId
:
__item
.
customerAttributeValueId
,
value
:
__item
.
value
})
})
_attributeValueArr
.
push
(
_tempArr
)
// 价格属性的属性值数组 用于SKU组合
...
...
@@ -157,14 +171,14 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
if
(
combineArray
?.
length
>
0
){
// length存在 表示表格的行数
combineArray
.
map
((
_rowArr
:
any
[],
i
:
any
)
=>
{
// _rowArr 属性值数组
let
_tempObj
:
any
=
{
索引
:
i
,
商品名称
:
productName
}
console
.
log
(
_rowArr
,
'_rowArr'
)
//
console.log(_rowArr,'_rowArr')
Array
.
isArray
(
_rowArr
)
?
_rowArr
.
map
((
__rowArr
,
index
)
=>
{
_tempObj
[
_attributeNameArr
[
index
]]
=
__rowArr
})
:
_tempObj
[
_attributeNameArr
[
i
]]
=
_rowArr
_tempObj
[
'对应货品'
]
=
selectedGoods
.
length
>
0
?
selectedGoods
[
0
].
id
:
0
_tempObj
[
'单价'
]
=
{}
_tableData
.
push
(
_tempObj
)
console
.
log
(
_rowArr
,
'_tempObj'
)
//
console.log(_rowArr,'_tempObj')
})
}
else
{
// length不存在,默认只有商品名称一行
let
_tempObj
:
any
=
{
索引
:
0
,
商品名称
:
productName
}
...
...
@@ -322,6 +336,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
labelAlign=
"left"
ref=
{
priceFormRef
}
colon=
{
false
}
initialValues=
{
productInfoByEdit
?.
id
?
getPriceAttributeFormParamsByEdit
:
{}
}
>
<
Form
.
Item
name=
"unitId"
...
...
src/pages/commodity/products/addProductsItem/productAttributeForm.tsx
View file @
3d0083d0
...
...
@@ -37,10 +37,13 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
const
productAttributeFormRef
=
useRef
()
const
[
attributeForm
]
=
Form
.
useForm
()
const
{
ProductStore
}
=
store
const
{
setProductSelectAttribute
,
getProductAttributeFormParamsByEdit
,
productInfoByEdit
}
=
ProductStore
const
{
attributeLists
,
setProductSelectAttribute
,
getProductAttributeFormParamsByEdit
,
productInfoByEdit
}
=
ProductStore
useEffect
(()
=>
{
onRef
(
productAttributeFormRef
)
// 编辑情况下 构建选中属性数据
if
(
productInfoByEdit
?.
id
)
constructProductSelectAttribute
()
},
[])
const
onFinish
=
(
values
)
=>
{
...
...
@@ -88,13 +91,29 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
return
item
},{}))
//遍历 排空
//
遍历 排空
let
resultParams
=
_resultParams
.
filter
((
_item
:
any
)
=>
_item
.
customerAttributeValueList
.
length
!=
0
)
console
.
log
(
resultParams
,
'resultParams'
)
// 最终传输数据
setProductSelectAttribute
(
resultParams
)
}
/* 编辑情况下,利用商品信息中的属性值转换为结果参数,用于后续表格生成 */
const
constructProductSelectAttribute
=
()
=>
{
let
_selectAttributeByEdit
=
productInfoByEdit
.
commodityAttributeList
.
map
((
item
,
index
)
=>
{
console
.
log
(
item
,
'____'
,
attributeLists
[
index
])
return
{
attributeName
:
item
.
customerAttribute
.
name
,
customerAttributeId
:
item
.
customerAttribute
.
id
,
customerAttributeValueList
:
item
.
customerAttributeValueList
,
// isPrice: attributeLists[index].isPrice, //乱序情况下会出现错误
isPrice
:
attributeLists
.
filter
(
_item
=>
_item
.
name
===
item
.
customerAttribute
.
name
)[
0
].
isPrice
}
})
console
.
log
(
_selectAttributeByEdit
,
'__selectAttributeByEdit__'
,
attributeLists
)
setProductSelectAttribute
(
_selectAttributeByEdit
)
}
const
renderTabPanchildren
=
(
attrItem
:
any
)
=>
{
return
(
<>
...
...
@@ -163,7 +182,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
form=
{
attributeForm
}
name=
"attribute-form"
labelAlign=
"left"
onFinish=
{
onFinish
}
//
onFinish={onFinish}
ref=
{
productAttributeFormRef
}
colon=
{
false
}
initialValues=
{
productInfoByEdit
?.
id
?
getProductAttributeFormParamsByEdit
:
{}
}
...
...
@@ -180,14 +199,14 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
)
}
</
Tabs
>
<
Form
.
Item
{
...
tailLayout
}
>
{
/*
<Form.Item {...tailLayout}>
<Button type="primary" htmlType="submit">
保存
</Button>
<Button className={styles.ml20}>
取消
</Button>
</
Form
.
Item
>
</Form.Item>
*/
}
</
Form
>
{
attributesData
?.
length
===
0
&&
"请先选择基本信息中商品品类项!"
}
</>)
...
...
src/pages/commodity/products/addProductsItem/productImageForm.tsx
View file @
3d0083d0
...
...
@@ -61,18 +61,18 @@ const ProductImageForm: React.FC<Iprops> = (props) => {
const
[
previewTitle
,
setPreviewTitle
]
=
useState
(
''
)
const
{
ProductStore
}
=
store
const
{
priceAttributeParams
,
attributeLists
,
setProductAttributeAndImageParams
}
=
ProductStore
const
{
priceAttributeParams
,
setProductAttributeAndImageParams
}
=
ProductStore
/* 给数据添加图片字段 */
useEffect
(()
=>
{
console
.
log
(
'!!!'
,
priceAttributeParams
)
let
_priceAttributeParams
=
priceAttributeParams
.
map
(
_item
=>
{
let
_obj
=
{...
_item
}
_obj
.
commodityPic
=
[]
return
_obj
})
// let _imageAttributeParams = attributeLists.filter(_item => _item.isImage
)
console
.
log
(
'???'
,
_priceAttributeParams
)
if
(
_priceAttributeParams
?.
length
>
0
&&
_priceAttributeParams
[
0
]?.
goodsCustomerAttributeList
?.
length
!=
0
){
console
.
log
(
'???'
)
setDefaultChecked
(
0
)
}
setPriceAttributeParamsByRender
(
_priceAttributeParams
)
...
...
src/pages/commodity/products/fastModifyPrice.tsx
View file @
3d0083d0
...
...
@@ -71,6 +71,7 @@ const FastModifyPrice: React.FC<{}> = () => {
const
[
brandValue
,
setBrandValue
]
=
useState
(
undefined
)
const
[
classData
,
setClassData
]
=
useState
<
any
>
([])
const
[
classValue
,
setClassValue
]
=
useState
(
undefined
)
const
[
priceType
,
setPriceType
]
=
useState
<
number
>
(
null
)
const
columns
:
ColumnType
<
any
>
[]
=
[
{
...
...
@@ -167,7 +168,7 @@ const FastModifyPrice: React.FC<{}> = () => {
render
:
(
text
:
any
,
record
:
any
)
=>
{
return
(
<>
<
Button
type=
'link'
className=
"padLeft0"
onClick=
{
()
=>
handleModify
(
record
)
}
>
修改价格
</
Button
>
<
Button
type=
'link'
className=
"padLeft0"
onClick=
{
()
=>
handleModify
(
record
)
}
>
{
record
.
priceType
===
3
?
'修改积分'
:
'修改价格'
}
</
Button
>
</>
)
}
...
...
@@ -191,9 +192,12 @@ const FastModifyPrice: React.FC<{}> = () => {
}
const
handleModify
=
(
record
:
object
)
=>
{
const
handleModify
=
(
record
:
any
)
=>
{
console
.
log
(
'点击修改价格'
,
record
)
const
{
id
,
unitPrice
,
priceType
}
=
record
// 阶梯价格回显处理
setModifyModal
(
true
)
setPriceType
(
priceType
)
}
...
...
@@ -391,7 +395,7 @@ const FastModifyPrice: React.FC<{}> = () => {
/>
</
Card
>
<
Modal
title=
"设置价格"
title=
{
priceType
===
3
?
'设置积分'
:
'设置价格'
}
visible=
{
modifyModal
}
onOk=
{
handleOk
}
onCancel=
{
handleCancel
}
...
...
src/services/index.ts
View file @
3d0083d0
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/store/product/index.ts
View file @
3d0083d0
import
{
action
,
computed
,
observable
,
runInAction
}
from
'mobx'
import
{
IProductModule
,
IProductSelectAttribute
,
IBasicFormParam
}
from
'@/module/productModule'
;
// mobx要用到的数据类型
import
{
IProductModule
,
IProductSelectAttribute
,
IBasicFormParam
,
IPriceAttributeParam
,
IOtherParam
}
from
'@/module/productModule'
;
// mobx要用到的数据类型
import
{
GetProductGoodsGetGoodsListResponseDetail
,
GetProductCommodityGetCommodityResponse
}
from
'@/services'
;
class
ProductStore
implements
IProductModule
{
...
...
@@ -11,8 +11,10 @@ class ProductStore implements IProductModule {
@
observable
public
priceAttributeParams
:
any
[]
=
[];
@
observable
public
productAttributeAndImageParams
:
any
[]
=
[];
@
observable
public
areaOption
:
any
[]
=
[];
@
observable
public
productInfoByEdit
:
GetProductCommodityGetCommodityResponse
;
// id属性可以作为判断是否是编辑状态的依据
@
observable
public
productInfoByEdit
:
GetProductCommodityGetCommodityResponse
;
/** 计算操作 **/
// 加工接口返回的数据,用户编辑回显数据
@
computed
public
get
getBasicFormParamsByEdit
():
IBasicFormParam
{
return
{
...
...
@@ -28,23 +30,45 @@ class ProductStore implements IProductModule {
@
computed
public
get
getProductAttributeFormParamsByEdit
():
any
{
let
attributeArr
=
this
.
productInfoByEdit
.
commodityAttributeList
.
map
(
item
=>
item
.
customerAttribute
)
let
attributeValueArr
=
this
.
productInfoByEdit
.
commodityAttributeList
.
map
(
item
=>
item
.
customerAttributeValueList
)
let
attributeIdArr
=
attributeArr
.
map
(
item
=>
item
.
id
)
let
attributeValueIdArr
=
attributeValueArr
.
map
(
item
=>
item
.
map
(
_item
=>
_item
.
id
))
let
tempObj
=
{}
attributeIdArr
.
map
((
item
,
index
)
=>
{
if
(
attributeValueIdArr
[
index
].
length
>
1
){
tempObj
[
item
]
=
attributeValueIdArr
[
index
]
}
else
{
tempObj
[
item
]
=
attributeValueIdArr
[
index
][
0
]
}
})
return
tempObj
let
attributeArr
=
this
.
productInfoByEdit
?.
commodityAttributeList
.
map
(
item
=>
item
.
customerAttribute
)
let
attributeValueArr
=
this
.
productInfoByEdit
?.
commodityAttributeList
.
map
(
item
=>
item
.
customerAttributeValueList
)
if
(
attributeArr
?.
length
>
0
&&
attributeValueArr
?.
length
>
0
){
let
attributeIdArr
=
attributeArr
.
map
(
item
=>
item
.
id
)
let
attributeValueIdArr
=
attributeValueArr
.
map
(
item
=>
item
.
map
(
_item
=>
_item
.
id
))
let
tempObj
=
{}
attributeIdArr
.
map
((
item
,
index
)
=>
{
if
(
attributeValueIdArr
[
index
].
length
>
1
){
tempObj
[
item
]
=
attributeValueIdArr
[
index
]
}
else
{
tempObj
[
item
]
=
attributeValueIdArr
[
index
][
0
]
}
})
return
tempObj
}
}
@
computed
public
get
getPriceAttributeFormParamsByEdit
():
IPriceAttributeParam
{
return
{
unitName
:
this
.
productInfoByEdit
?.
unitName
,
minOrder
:
this
.
productInfoByEdit
?.
minOrder
,
isMemberPrice
:
this
.
productInfoByEdit
?.
isMemberPrice
,
priceType
:
this
.
productInfoByEdit
?.
priceType
,
}
}
@
computed
public
get
getOtherFormParamsByEdit
():
IOtherParam
{
return
{
isInvoice
:
this
.
productInfoByEdit
?.
isInvoice
,
marks
:
this
.
productInfoByEdit
?.
marks
,
packing
:
this
.
productInfoByEdit
?.
packing
,
afterService
:
this
.
productInfoByEdit
?.
afterService
,
}
}
/** 定义动作区块,外部调用,改变对应的状态 **/
// 可以改变
存的testText
值
// 可以改变
受观察的public
值
@
action
.
bound
public
setAttributeLists
(
lists
:
any
[])
{
this
.
attributeLists
=
lists
;
...
...
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