Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
admin-ci-test
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
test-ci
admin-ci-test
Commits
c719f928
提交
c719f928
authored
6月 08, 2023
作者:
龚洪江
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
联调:行业方案,品牌,产品管理联调
上级
66945260
隐藏空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
983 行增加
和
396 行删除
+983
-396
interface.ts
src/api/interface.ts
+5
-5
produceManageType.ts
src/api/interface/produceManageType.ts
+101
-1
categoryManage.ts
src/api/modules/categoryManage.ts
+5
-1
makeManage.ts
src/api/modules/makeManage.ts
+4
-4
produceManageAPI.ts
src/api/modules/produceManageAPI.ts
+48
-25
request.ts
src/api/request.ts
+1
-1
index.tsx
...ge/industryDetail/components/addOrEditSpecModal/index.tsx
+1
-1
index.tsx
...nage/industryDetail/components/productListModal/index.tsx
+6
-6
index.tsx
src/pages/mallManage/industryManage/industryDetail/index.tsx
+21
-21
index.tsx
src/pages/mallManage/makeManage/makeList/index.tsx
+125
-19
index.tsx
...duceDetail/components/addOrEditProduceSpecModal/index.tsx
+148
-0
index.tsx
...oduceDetail/components/setProduceSpecPriceModal/index.tsx
+267
-0
index.tsx
src/pages/mallManage/produceManage/produceDetail/index.tsx
+144
-215
index.tsx
...ge/produceList/components/addOrEditProduceModal/index.tsx
+44
-30
index.tsx
src/pages/mallManage/produceManage/produceList/index.tsx
+60
-36
propsType.ts
src/pages/mallManage/produceManage/produceList/propsType.ts
+0
-29
privateRouter.tsx
src/router/privateRouter.tsx
+1
-1
index.ts
src/utils/index.ts
+1
-1
vite.config.ts
vite.config.ts
+1
-0
没有找到文件。
src/api/interface.ts
浏览文件 @
c719f928
// 分页通用接口
// 分页通用接口
export
interface
PaginationProps
{
export
interface
PaginationProps
{
pageSize
?
:
number
;
pageSize
:
number
;
pageNo
?
:
number
;
pageNo
:
number
;
}
}
// 通用返回接口(分页)
// 通用返回接口(分页)
...
@@ -39,17 +39,17 @@ export interface ResponseType<D> {
...
@@ -39,17 +39,17 @@ export interface ResponseType<D> {
// 通用接口封装函数(分页) 建议用这个
// 通用接口封装函数(分页) 建议用这个
export
interface
InterListFunction
<
D
extends
object
,
T
>
{
export
interface
InterListFunction
<
D
extends
object
,
T
>
{
(
req
:
D
&
Pa
ginationProps
):
Promise
<
ResponseListType
<
T
>>
;
(
req
:
D
&
Pa
rtial
<
PaginationProps
>
):
Promise
<
ResponseListType
<
T
>>
;
}
}
// 通用接口封装函数(不分页) 建议用这个
// 通用接口封装函数(不分页) 建议用这个
export
interface
InterFunction
<
D
extends
object
,
T
>
{
export
interface
InterFunction
<
D
extends
object
,
T
>
{
(
req
:
D
):
Promise
<
ResponseType
<
T
>>
;
(
req
?
:
D
):
Promise
<
ResponseType
<
T
>>
;
}
}
// 通用接口封装函数(分页了,但又没有分页) 建议用这个
// 通用接口封装函数(分页了,但又没有分页) 建议用这个
export
interface
InterItemFunction
<
D
extends
object
,
T
>
{
export
interface
InterItemFunction
<
D
extends
object
,
T
>
{
(
req
:
D
&
Pa
ginationProps
):
Promise
<
ResponseItemType
<
T
>>
;
(
req
:
D
&
Pa
rtial
<
PaginationProps
>
):
Promise
<
ResponseItemType
<
T
>>
;
}
}
// 返回类型封装
// 返回类型封装
...
...
src/api/interface/produceManageType.ts
浏览文件 @
c719f928
import
{
InterItemFunction
}
from
'~/api/interface'
;
import
{
Inter
Function
,
Inter
ItemFunction
}
from
'~/api/interface'
;
export
type
MakeListType
=
InterItemFunction
<
export
type
MakeListType
=
InterItemFunction
<
any
,
any
,
...
@@ -31,6 +31,54 @@ export type productListType = InterItemFunction<
...
@@ -31,6 +31,54 @@ export type productListType = InterItemFunction<
}[];
}[];
}[]
}[]
>
;
>
;
//产品-新增
export
type
addProductType
=
InterFunction
<
{
categoryId
:
number
;
directoryId
:
number
;
model
:
string
;
productBrandId
:
number
;
productName
:
string
;
},
null
>
;
//产品-编辑
export
type
editProductType
=
InterFunction
<
{
categoryId
:
number
;
directoryId
:
number
;
model
:
string
;
productBrandId
:
number
;
productName
:
string
;
id
?:
number
;
},
any
>
;
//产品-删除
export
type
deleteProductType
=
InterFunction
<
{
id
:
number
},
null
>
;
//产品-详情
export
type
productDetailType
=
InterFunction
<
{
id
:
number
},
{
id
:
number
;
productName
:
string
;
productBrandId
:
number
;
productBrand
:
string
;
model
:
string
;
categoriesId
:
number
;
categoryName
:
string
;
directoryId
:
number
;
directoryName
:
string
;
productSpecList
:
{
id
:
number
;
partNo
:
string
;
specImage
:
string
;
specName
:
string
;
versionDesc
:
string
;
productSkuId
:
number
;
}[];
}
>
;
//产品-规格-列表
//产品-规格-列表
export
type
ProductSpecListType
=
InterItemFunction
<
export
type
ProductSpecListType
=
InterItemFunction
<
{
productSkuId
:
number
},
{
productSkuId
:
number
},
...
@@ -43,3 +91,55 @@ export type ProductSpecListType = InterItemFunction<
...
@@ -43,3 +91,55 @@ export type ProductSpecListType = InterItemFunction<
productSkuId
:
number
;
productSkuId
:
number
;
}[]
}[]
>
;
>
;
//产品-规格-新增
export
type
productSpecAddType
=
InterFunction
<
{
partNo
:
string
;
productSkuId
:
number
;
specImage
:
string
;
specName
:
string
;
versionDesc
:
string
;
},
null
>
;
//产品-规格-编辑
export
type
productSpecEditType
=
InterFunction
<
{
partNo
:
string
;
productSkuId
:
number
;
specImage
:
string
;
specName
:
string
;
versionDesc
:
string
;
id
?:
number
;
},
null
>
;
//产品-规格-删除
export
type
productSpecDeleteType
=
InterFunction
<
{
id
:
number
},
any
>
;
//产品-规格-配置价格
export
type
productSpecPriceType
=
InterFunction
<
{
leaseTerm
?:
number
;
productSpecId
?:
number
;
specPrice
:
{
cooperationTag
:
number
;
price
:
number
}[];
type
:
number
;
},
null
>
;
//产品-规格-获取配置价格
export
type
getProductSpecPriceType
=
InterFunction
<
{
leaseTerm
?:
number
;
productSpecId
?:
number
;
type
:
number
},
{
id
:
number
;
cooperationTag
:
number
;
price
:
number
;
leaseTerm
:
number
}[]
>
;
//产品-规格-配置价格修改
export
type
editProductSpecPriceType
=
InterFunction
<
{
leaseTerm
?:
number
;
productSpecId
?:
number
;
specPrice
:
{
cooperationTag
:
number
;
price
:
number
}[];
type
:
number
;
},
null
>
;
//加盟标签-列表
export
type
cooperationTagType
=
InterFunction
<
any
,
{
id
:
number
;
tagName
:
string
}[]
>
;
src/api/modules/categoryManage.ts
浏览文件 @
c719f928
import
axios
from
'../request'
;
import
axios
from
'../request'
;
import
{
categoryListType
,
GoodsInfo
}
from
'~/api/interface/categoryManage'
;
import
{
categoryListType
,
directoryListType
,
GoodsInfo
}
from
'~/api/interface/categoryManage'
;
export
class
CategoryManageAPI
{
export
class
CategoryManageAPI
{
// 分类目录
// 分类目录
...
@@ -8,6 +8,10 @@ export class CategoryManageAPI {
...
@@ -8,6 +8,10 @@ export class CategoryManageAPI {
params
,
params
,
});
});
};
};
// 分类目录(类型)
static
getDirectoryListClone
:
directoryListType
=
(
params
)
=>
{
return
axios
.
get
(
'/pms/classify/getDirectoryList'
,
{
params
});
};
//目录列表不含分页
//目录列表不含分页
static
getDirectoryList
=
(
params
:
{
type
:
number
})
=>
{
static
getDirectoryList
=
(
params
:
{
type
:
number
})
=>
{
...
...
src/api/modules/makeManage.ts
浏览文件 @
c719f928
...
@@ -9,21 +9,21 @@ import axios from '../request';
...
@@ -9,21 +9,21 @@ import axios from '../request';
export
class
MakeManageAPI
{
export
class
MakeManageAPI
{
// 品牌-新增
// 品牌-新增
static
addBrandInfo
:
MakeAddType
=
(
params
)
=>
{
static
addBrandInfo
:
MakeAddType
=
(
params
)
=>
{
return
axios
.
get
(
'
uavgood
s/brand/addBrandInfo'
,
{
params
});
return
axios
.
get
(
'
/pm
s/brand/addBrandInfo'
,
{
params
});
};
};
// 品牌-编辑
// 品牌-编辑
static
editBrandInfo
:
MakeEditType
=
(
params
)
=>
{
static
editBrandInfo
:
MakeEditType
=
(
params
)
=>
{
return
axios
.
get
(
'
uavgood
s/brand/editBrandInfo'
,
{
params
});
return
axios
.
get
(
'
/pm
s/brand/editBrandInfo'
,
{
params
});
};
};
// 品牌-列表
// 品牌-列表
static
getListBrandInfo
:
MakeListType
=
(
params
)
=>
{
static
getListBrandInfo
:
MakeListType
=
(
params
)
=>
{
return
axios
.
get
(
'
uavgood
s/brand/listBrandInfo'
,
{
params
});
return
axios
.
get
(
'
/pm
s/brand/listBrandInfo'
,
{
params
});
};
};
// 品牌刪除
// 品牌刪除
static
deleteBrandInfo
:
MakeDeleteType
=
(
params
)
=>
{
static
deleteBrandInfo
:
MakeDeleteType
=
(
params
)
=>
{
return
axios
.
get
(
'
uavgood
s/brand/deleteBrandInfo'
,
{
params
});
return
axios
.
get
(
'
/pm
s/brand/deleteBrandInfo'
,
{
params
});
};
};
}
}
src/api/modules/produceManageAPI.ts
浏览文件 @
c719f928
import
axios
from
'../request'
;
import
axios
from
'../request'
;
import
{
import
{
MakeListType
,
addProductType
,
cooperationTagType
,
deleteProductType
,
editProductSpecPriceType
,
editProductType
,
getProductSpecPriceType
,
productDetailType
,
productListType
,
productListType
,
productSpecAddType
,
productSpecDeleteType
,
productSpecEditType
,
ProductSpecListType
,
ProductSpecListType
,
productSpecPriceType
,
}
from
'~/api/interface/produceManageType'
;
}
from
'~/api/interface/produceManageType'
;
import
dayjs
from
'dayjs'
;
export
class
ProduceManageAPI
{
export
class
ProduceManageAPI
{
// 产品管理-分页列表
// 产品管理-分页列表
...
@@ -11,41 +22,53 @@ export class ProduceManageAPI {
...
@@ -11,41 +22,53 @@ export class ProduceManageAPI {
return
axios
.
post
(
'/pms/product/spec/listPageProductSku'
,
data
);
return
axios
.
post
(
'/pms/product/spec/listPageProductSku'
,
data
);
};
};
// 产品sku管理-删除产品sku
// 产品sku管理-删除产品sku
static
removeProductSku
=
(
params
:
unknown
)
=>
{
static
removeProductSku
:
deleteProductType
=
(
params
)
=>
{
return
axios
.
get
(
'uavgoods/product/spec/removeProductSku'
,
{
params
});
return
axios
.
get
(
'/pms/product/spec/removeProductSku'
,
{
params
});
};
static
directoryList
=
()
=>
{
return
axios
.
get
(
'uavgoods/directory/directoryList'
);
};
// 分类列表(属于商品)
static
getListGoodsTypeList
=
(
type
:
number
):
any
=>
{
return
axios
.
get
(
`uavgoods/mgoods/getGoodsTypeInfoList/
${
type
}
`
);
};
// 品牌-列表
static
getListBrandInfo
:
MakeListType
=
(
params
)
=>
{
return
axios
.
get
(
'uavgoods/brand/listBrandInfo'
,
{
params
});
};
};
// 产品sku管理-新增产品sku
// 产品sku管理-新增产品sku
static
addProductSku
=
(
data
:
unknown
)
=>
{
static
addProductSku
:
addProductType
=
(
data
)
=>
{
return
axios
.
post
(
'
uavgood
s/product/spec/addProductSku'
,
data
);
return
axios
.
post
(
'
/pm
s/product/spec/addProductSku'
,
data
);
};
};
// 产品sku管理-编辑产品sku
// 产品sku管理-编辑产品sku
static
editProductSku
=
(
data
:
unknown
)
=>
{
static
editProductSku
:
editProductType
=
(
data
)
=>
{
return
axios
.
post
(
'
uavgood
s/product/spec/editProductSku'
,
data
);
return
axios
.
post
(
'
/pm
s/product/spec/editProductSku'
,
data
);
};
};
// 产品规格管理---删除规格
static
removeProductSpec
=
(
params
:
unknown
)
=>
{
return
axios
.
get
(
'uavgoods/product/spec/removeProductSpec'
,
{
params
});
};
// 产品sku管理-编辑单个产品sku时的信息回显
// 产品sku管理-编辑单个产品sku时的信息回显
static
getProductSkuDetail
=
(
params
:
unknown
)
=>
{
static
getProductSkuDetail
:
productDetailType
=
(
params
)
=>
{
return
axios
.
get
(
'
uavgood
s/product/spec/getProductSkuDetail'
,
{
params
});
return
axios
.
get
(
'
/pm
s/product/spec/getProductSkuDetail'
,
{
params
});
};
};
// 产品规格管理---删除规格
static
removeProductSpec
:
productSpecDeleteType
=
(
params
)
=>
{
return
axios
.
get
(
'/pms/product/spec/removeProductSpec'
,
{
params
});
};
//产品规格管理---新增规格
static
addProductSpec
:
productSpecAddType
=
(
data
)
=>
{
return
axios
.
post
(
'/pms/product/spec/addOrEditProductSpec'
,
data
);
};
//产品规格管理---编辑规格
static
editProductSpec
:
productSpecEditType
=
(
data
)
=>
{
return
axios
.
post
(
'/pms/product/spec/addOrEditProductSpec'
,
data
);
};
// 产品sku管理-产品规格管理-分页列表
// 产品sku管理-产品规格管理-分页列表
static
listPageProductSpec
:
ProductSpecListType
=
(
params
)
=>
{
static
listPageProductSpec
:
ProductSpecListType
=
(
params
)
=>
{
return
axios
.
get
(
'/pms/product/spec/listPageProductSpec'
,
{
params
});
return
axios
.
get
(
'/pms/product/spec/listPageProductSpec'
,
{
params
});
};
};
//产品sku管理-产品规格管理-价格配置
static
setProductSpecPrice
:
productSpecPriceType
=
(
data
)
=>
{
return
axios
.
post
(
'/pms/product/spec/productSpecCPQ'
,
data
);
};
//产品sku管理-产品规格管理-获取价格配置
static
getProductSpecPrice
:
getProductSpecPriceType
=
(
data
)
=>
{
return
axios
.
post
(
'/pms/product/spec/getProductSpecCPQ'
,
data
);
};
//产品sku管理-产品规格管理-价格配置修改
static
editProductSpecPrice
:
editProductSpecPriceType
=
(
data
)
=>
{
return
axios
.
post
(
'/pms/product/spec/updateProductSpecCPQ'
,
data
);
};
//加盟标签-列表
static
getCooperationListTag
:
cooperationTagType
=
()
=>
{
return
axios
.
get
(
'/userapp/cooperation/listTag'
);
};
}
}
src/api/request.ts
浏览文件 @
c719f928
...
@@ -13,7 +13,7 @@ const service = axios.create({
...
@@ -13,7 +13,7 @@ const service = axios.create({
});
});
service
.
interceptors
.
request
.
use
(
service
.
interceptors
.
request
.
use
(
(
config
:
any
)
=>
{
(
config
:
any
)
=>
{
const
token
=
Cookies
.
get
(
'SHAREFLY
-
TOKEN'
);
const
token
=
Cookies
.
get
(
'SHAREFLY
_
TOKEN'
);
// console.log('token --->', token);
// console.log('token --->', token);
if
(
token
)
{
if
(
token
)
{
config
.
headers
.
token
=
token
;
config
.
headers
.
token
=
token
;
...
...
src/pages/mallManage/industryManage/industryDetail/components/addOrEditSpecModal/index.tsx
浏览文件 @
c719f928
...
@@ -50,7 +50,7 @@ const AddOrEditSpecModal: FC<ModalProps & PropsType> = ({
...
@@ -50,7 +50,7 @@ const AddOrEditSpecModal: FC<ModalProps & PropsType> = ({
{
{
title
:
'序号'
,
title
:
'序号'
,
align
:
'center'
,
align
:
'center'
,
render
:
(
text
:
string
,
record
:
selfProduceItemType
,
index
:
number
)
=>
{
render
:
(
_text
:
string
,
_
record
:
selfProduceItemType
,
index
:
number
)
=>
{
return
(
pagination
.
pageNo
-
1
)
*
pagination
.
pageSize
+
index
+
1
;
return
(
pagination
.
pageNo
-
1
)
*
pagination
.
pageSize
+
index
+
1
;
},
},
},
},
...
...
src/pages/mallManage/industryManage/industryDetail/components/productListModal/index.tsx
浏览文件 @
c719f928
...
@@ -18,7 +18,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
...
@@ -18,7 +18,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
title
:
'序号'
,
title
:
'序号'
,
align
:
'center'
,
align
:
'center'
,
width
:
'50px'
,
width
:
'50px'
,
render
:
(
text
:
string
,
record
:
productInventoryListType
[
0
],
index
:
number
)
=>
{
render
:
(
_text
:
string
,
_
record
:
productInventoryListType
[
0
],
index
:
number
)
=>
{
return
index
+
1
;
return
index
+
1
;
},
},
},
},
...
@@ -27,7 +27,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
...
@@ -27,7 +27,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
dataIndex
:
'productName'
,
dataIndex
:
'productName'
,
align
:
'center'
,
align
:
'center'
,
width
:
'100px'
,
width
:
'100px'
,
render
:
(
text
:
string
,
record
:
productInventoryListType
[
0
])
=>
{
render
:
(
_
text
:
string
,
record
:
productInventoryListType
[
0
])
=>
{
return
record
.
productSku
.
productName
;
return
record
.
productSku
.
productName
;
},
},
},
},
...
@@ -36,7 +36,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
...
@@ -36,7 +36,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
dataIndex
:
'typeName'
,
dataIndex
:
'typeName'
,
align
:
'center'
,
align
:
'center'
,
width
:
'100px'
,
width
:
'100px'
,
render
:
(
text
:
string
,
record
:
productInventoryListType
[
0
])
=>
{
render
:
(
_
text
:
string
,
record
:
productInventoryListType
[
0
])
=>
{
return
record
.
productSku
.
goodsTypeId
;
return
record
.
productSku
.
goodsTypeId
;
},
},
},
},
...
@@ -45,7 +45,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
...
@@ -45,7 +45,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
dataIndex
:
'model'
,
dataIndex
:
'model'
,
align
:
'center'
,
align
:
'center'
,
width
:
'100px'
,
width
:
'100px'
,
render
:
(
text
:
string
,
record
:
productInventoryListType
[
0
])
=>
{
render
:
(
_
text
:
string
,
record
:
productInventoryListType
[
0
])
=>
{
return
record
.
productSku
.
model
;
return
record
.
productSku
.
model
;
},
},
},
},
...
@@ -54,7 +54,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
...
@@ -54,7 +54,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
dataIndex
:
'productBrand'
,
dataIndex
:
'productBrand'
,
align
:
'center'
,
align
:
'center'
,
width
:
'100px'
,
width
:
'100px'
,
render
:
(
text
:
string
,
record
:
productInventoryListType
[
0
])
=>
{
render
:
(
_
text
:
string
,
record
:
productInventoryListType
[
0
])
=>
{
return
record
.
productSku
.
productName
;
return
record
.
productSku
.
productName
;
},
},
},
},
...
@@ -62,7 +62,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
...
@@ -62,7 +62,7 @@ const ProductListModal: FC<ModalProps & PropsType> = ({ open, onCancel, data })
title
:
'产品规格'
,
title
:
'产品规格'
,
// align: "left",
// align: "left",
width
:
'200px'
,
width
:
'200px'
,
render
:
(
text
:
string
,
record
)
=>
{
render
:
(
_
text
:
string
,
record
)
=>
{
if
(
record
.
select
===
0
)
{
if
(
record
.
select
===
0
)
{
return
'不指定'
;
return
'不指定'
;
}
}
...
...
src/pages/mallManage/industryManage/industryDetail/index.tsx
浏览文件 @
c719f928
...
@@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom';
...
@@ -4,7 +4,7 @@ import { useNavigate } from 'react-router-dom';
import
{
ColumnsType
}
from
'antd/es/table'
;
import
{
ColumnsType
}
from
'antd/es/table'
;
import
{
IndustryManageAPI
}
from
'~/api'
;
import
{
IndustryManageAPI
}
from
'~/api'
;
import
{
useSearchParams
}
from
'react-router-dom'
;
import
{
useSearchParams
}
from
'react-router-dom'
;
import
{
inventoryType
}
from
'../industryList/propsType'
;
//
import { inventoryType } from '../industryList/propsType';
import
{
InterDataType
,
PaginationProps
}
from
'~/api/interface'
;
import
{
InterDataType
,
PaginationProps
}
from
'~/api/interface'
;
import
{
import
{
industryDetailType
,
industryDetailType
,
...
@@ -48,13 +48,13 @@ function IndustryDetail() {
...
@@ -48,13 +48,13 @@ function IndustryDetail() {
// 方案规格
// 方案规格
const
[
industrySpecData
,
setIndustrySpecData
]
=
useState
<
industrySpecType
>
([]);
const
[
industrySpecData
,
setIndustrySpecData
]
=
useState
<
industrySpecType
>
([]);
// 产品清单弹窗显示
// 产品清单弹窗显示
const
[
visibleList
,
setVisibleList
]
=
useState
<
boolean
>
(
false
);
//
const [visibleList, setVisibleList] = useState<boolean>(false);
// 产品规格清单
// 产品规格清单
const
[
listData
,
setListData
]
=
useState
<
inventoryType
[]
>
([]);
//
const [listData, setListData] = useState<inventoryType[]>([]);
// 配置价格弹窗显示
// 配置价格弹窗显示
const
[
visiblePrice
,
setVisiblePrice
]
=
useState
<
boolean
>
(
false
);
//
const [visiblePrice, setVisiblePrice] = useState<boolean>(false);
// 当前配置价格数据
// 当前配置价格数据
const
[
priceData
,
setPriceData
]
=
useState
([]);
//
const [priceData, setPriceData] = useState([]);
// 新增编辑规格弹窗是否显示
// 新增编辑规格弹窗是否显示
const
[
addOrEditSpecModalShow
,
setAddOrEditSpecModalShow
]
=
useState
<
boolean
>
(
false
);
const
[
addOrEditSpecModalShow
,
setAddOrEditSpecModalShow
]
=
useState
<
boolean
>
(
false
);
//关联产品弹窗
//关联产品弹窗
...
@@ -81,8 +81,8 @@ function IndustryDetail() {
...
@@ -81,8 +81,8 @@ function IndustryDetail() {
title
:
'规格图片'
,
title
:
'规格图片'
,
dataIndex
:
'specImage'
,
dataIndex
:
'specImage'
,
align
:
'center'
,
align
:
'center'
,
render
:
(
text
:
string
,
record
)
=>
{
render
:
(
text
)
=>
{
return
<
Image
width=
{
50
}
height=
{
50
}
src=
{
record
.
specImage
}
alt=
'图片'
/>;
return
<
Image
width=
{
50
}
height=
{
50
}
src=
{
text
}
alt=
'图片'
/>;
},
},
},
},
{
{
...
@@ -101,13 +101,13 @@ function IndustryDetail() {
...
@@ -101,13 +101,13 @@ function IndustryDetail() {
title
:
'操作'
,
title
:
'操作'
,
align
:
'center'
,
align
:
'center'
,
width
:
'250px'
,
width
:
'250px'
,
render
:
(
text
:
string
,
record
:
any
)
=>
{
render
:
(
_text
,
record
)
=>
{
return
(
return
(
<
div
>
<
div
>
<
Button
<
Button
type=
'link'
type=
'link'
onClick=
{
()
=>
{
onClick=
{
()
=>
{
handlePrice
(
record
);
//
handlePrice(record);
}
}
}
}
>
>
配置价格
配置价格
...
@@ -139,20 +139,20 @@ function IndustryDetail() {
...
@@ -139,20 +139,20 @@ function IndustryDetail() {
});
});
// 关闭产品清单
// 关闭产品清单
const
handleListClosed
=
()
=>
{
//
const handleListClosed = () => {
setListData
([]);
//
setListData([]);
setVisibleList
(
false
);
//
setVisibleList(false);
};
//
};
// 打开配置价格弹窗
// 打开配置价格弹窗
const
handlePrice
=
(
arr
:
any
)
=>
{
//
const handlePrice = (arr: any) => {
setPriceData
(
arr
);
//
setPriceData(arr);
setVisiblePrice
(
true
);
//
setVisiblePrice(true);
};
//
};
// 关闭配置价格弹窗
// 关闭配置价格弹窗
const
handlePriceClosed
=
()
=>
{
//
const handlePriceClosed = () => {
setPriceData
([]);
//
setPriceData([]);
setVisiblePrice
(
false
);
//
setVisiblePrice(false);
};
//
};
// 打开新增弹窗
// 打开新增弹窗
const
handleAdd
=
()
=>
{
const
handleAdd
=
()
=>
{
setAddOrEditSpecModalShow
(
true
);
setAddOrEditSpecModalShow
(
true
);
...
...
src/pages/mallManage/makeManage/makeList/index.tsx
浏览文件 @
c719f928
import
{
Button
,
Table
}
from
'antd'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
Button
,
message
,
Modal
,
Table
}
from
'antd'
;
import
{
PlusOutlined
}
from
'@ant-design/icons'
;
import
{
PlusOutlined
}
from
'@ant-design/icons'
;
import
{
ColumnsType
}
from
'antd/es/table'
;
import
type
{
ColumnsType
}
from
'antd/es/table'
;
// import AddOrEditMakeModal from './components/addOrEditMakeModal';
import
AddOrEditMakeModal
from
'./components/addOrEditMakeModal'
;
import
{
MakeManageAPI
}
from
'~/api'
;
import
{
MakeItemEntity
}
from
'~/api/interface/makeManage'
;
import
{
PaginationProps
}
from
'~/api/interface'
;
const
Make
List
=
()
=>
{
const
Make
Manage
=
()
=>
{
const
columns
:
ColumnsType
<
an
y
>
=
[
const
columns
:
ColumnsType
<
MakeItemEntit
y
>
=
[
{
{
title
:
'品牌名称'
,
title
:
'品牌名称'
,
align
:
'center'
,
align
:
'center'
,
...
@@ -18,28 +22,130 @@ const MakeList = () => {
...
@@ -18,28 +22,130 @@ const MakeList = () => {
{
{
title
:
'操作'
,
title
:
'操作'
,
align
:
'center'
,
align
:
'center'
,
render
:
()
=>
(
render
:
(
_text
:
string
,
record
:
MakeItemEntity
)
=>
(
<>
<>
<
Button
type=
'link'
>
编辑
</
Button
>
<
Button
type=
'link'
onClick=
{
()
=>
editMake
(
record
)
}
>
<
Button
type=
'link'
danger
>
编辑
</
Button
>
<
Button
type=
'link'
danger
onClick=
{
()
=>
deleteMake
(
record
)
}
>
删除
删除
</
Button
>
</
Button
>
</>
</>
),
),
},
},
];
];
const
[
tableData
,
setTableData
]
=
useState
<
MakeItemEntity
[]
>
([]);
const
[
pagination
,
setPagination
]
=
useState
<
PaginationProps
&
{
totalCount
:
number
}
>
({
pageNo
:
1
,
pageSize
:
10
,
totalCount
:
0
,
});
// add or edit modal is show
const
[
currentMakeItem
,
setCurrentMakeItem
]
=
useState
<
MakeItemEntity
>
();
const
[
addOrEditModalShow
,
setAddOrEditModalShow
]
=
useState
<
boolean
>
(
false
);
// 新建
const
addMakeClick
=
()
=>
{
setAddOrEditModalShow
(
true
);
};
// add or edit modal event
const
addOrEditModalOk
=
()
=>
{
getListBrandInfo
({
pageSize
:
pagination
.
pageSize
,
pageNo
:
pagination
.
pageNo
,
});
setAddOrEditModalShow
(
false
);
setCurrentMakeItem
(
undefined
);
};
const
addOrEditModalCancel
=
()
=>
{
setCurrentMakeItem
(
undefined
);
setAddOrEditModalShow
(
false
);
};
// 品牌-列表
const
getListBrandInfo
=
(
data
:
Pick
<
PaginationProps
,
'pageSize'
|
'pageNo'
>
)
=>
{
MakeManageAPI
.
getListBrandInfo
(
data
).
then
(({
result
})
=>
{
setTableData
(
result
.
list
||
[]);
pagination
.
pageNo
=
data
.
pageNo
;
pagination
.
pageSize
=
data
.
pageSize
;
pagination
.
totalCount
=
result
.
totalCount
;
setPagination
(
pagination
);
});
};
// 分页
const
paginationChange
=
(
pageNo
:
number
,
pageSize
:
number
)
=>
{
getListBrandInfo
({
pageSize
,
pageNo
,
});
};
// edit
const
editMake
=
(
record
:
MakeItemEntity
)
=>
{
setCurrentMakeItem
(
record
);
setAddOrEditModalShow
(
true
);
};
// delete
const
deleteMake
=
(
record
:
MakeItemEntity
)
=>
{
Modal
.
confirm
({
content
:
'是否删除该品牌?'
,
onOk
:
()
=>
{
MakeManageAPI
.
deleteBrandInfo
({
id
:
record
.
id
}).
then
(({
code
,
message
:
msg
})
=>
{
if
(
code
===
'200'
)
{
message
.
success
(
'删除成功'
);
if
(
tableData
.
length
===
1
&&
pagination
.
pageNo
!==
1
)
{
pagination
.
pageNo
--
;
}
getListBrandInfo
({
pageSize
:
pagination
.
pageSize
,
pageNo
:
pagination
.
pageNo
,
});
}
else
{
message
.
error
(
msg
);
}
});
},
});
};
useEffect
(()
=>
{
getListBrandInfo
({
pageSize
:
pagination
.
pageSize
,
pageNo
:
pagination
.
pageNo
,
});
},
[]);
return
(
return
(
<
div
className=
'make-list'
>
<
div
className=
'make-manage'
>
<
div
className=
'make-list-operate'
>
<
Button
<
Button
type=
'primary'
icon=
{
<
PlusOutlined
/>
}
>
icon=
{
<
PlusOutlined
/>
}
新增
type=
'primary'
</
Button
>
onClick=
{
addMakeClick
}
</
div
>
style=
{
{
marginBottom
:
'10px'
}
}
<
div
className=
'make-list-content'
style=
{
{
marginTop
:
'10px'
}
}
>
>
<
Table
bordered
columns=
{
columns
}
/>
新建
</
div
>
</
Button
>
{
/*<AddOrEditMakeModal />*/
}
<
Table
columns=
{
columns
}
bordered
rowKey=
'id'
dataSource=
{
tableData
}
pagination=
{
{
total
:
pagination
.
totalCount
,
pageSize
:
pagination
.
pageSize
,
current
:
pagination
.
pageNo
,
showSizeChanger
:
true
,
showQuickJumper
:
true
,
onChange
:
(
page
:
number
,
pageSize
:
number
)
=>
paginationChange
(
page
,
pageSize
),
showTotal
:
(
total
,
range
)
=>
`当前 ${range[0]}-${range[1]} 条记录 / 共 ${total} 条数据`
,
}
}
/>
<
AddOrEditMakeModal
open=
{
addOrEditModalShow
}
onOk=
{
addOrEditModalOk
}
handleCancel=
{
addOrEditModalCancel
}
title=
{
currentMakeItem
?
'编辑品牌'
:
'新建品牌'
}
makeItem=
{
currentMakeItem
}
/>
</
div
>
</
div
>
);
);
};
};
export
default
Make
List
;
export
default
Make
Manage
;
src/pages/mallManage/produceManage/produceDetail/components/addOrEditProduceSpecModal/index.tsx
0 → 100644
浏览文件 @
c719f928
import
React
,
{
FC
,
useEffect
,
useState
}
from
'react'
;
import
{
Form
,
Input
,
Modal
,
message
,
ModalProps
}
from
'antd'
;
import
{
Uploader
}
from
'~/components/uploader'
;
import
{
UploadOutlined
}
from
'@ant-design/icons'
;
import
{
ProduceManageAPI
}
from
'~/api'
;
import
{
InterDataType
}
from
'~/api/interface'
;
import
{
ProductSpecListType
}
from
'~/api/interface/produceManageType'
;
//产品规格返回类型
type
specType
=
InterDataType
<
ProductSpecListType
>
[
'list'
];
interface
PropsType
{
onCancel
:
()
=>
void
;
onOk
:
()
=>
void
;
data
:
specType
[
0
]
|
undefined
;
productSkuId
:
number
;
}
const
AddOrEditProduceSpecModal
:
FC
<
ModalProps
&
PropsType
>
=
({
open
,
onCancel
,
data
,
onOk
,
productSkuId
,
})
=>
{
// 表格事件
const
[
form
]
=
Form
.
useForm
();
//文件列表
const
[
fileList
,
setFileList
]
=
useState
<
{
id
:
number
;
name
:
string
;
uid
:
number
;
url
:
string
;
}[]
>
([]);
// 关闭弹窗
const
handleClosed
=
()
=>
{
form
.
resetFields
();
setFileList
([]);
onCancel
();
};
// 触发表单验证
const
handleSubmit
=
()
=>
{
form
.
validateFields
()
.
then
((
values
)
=>
{
const
obj
=
{
...
data
,
...
values
,
productSkuId
};
ProduceManageAPI
[
!
obj
.
id
?
'addProductSpec'
:
'editProductSpec'
](
obj
).
then
(({
code
})
=>
{
if
(
code
===
'200'
)
{
message
.
success
(
'操作成功'
);
form
.
resetFields
();
setFileList
([]);
onOk
();
}
});
})
.
catch
((
err
)
=>
{
message
.
warning
(
err
.
errorFields
[
0
].
errors
[
0
]).
then
();
});
};
//上传成功
const
uploadSuccess
=
(
value
:
{
id
:
number
;
name
:
string
;
uid
:
number
;
url
:
string
;
}[],
)
=>
{
form
.
setFieldsValue
({
specImage
:
value
[
0
].
url
,
});
};
// componentsDidMounted
useEffect
(()
=>
{
if
(
data
)
{
form
.
setFieldsValue
({
...
data
,
});
setFileList
([
{
uid
:
Math
.
random
(),
name
:
'img'
,
id
:
Math
.
random
(),
url
:
data
.
specImage
,
},
]);
}
},
[
data
]);
return
(
<
div
>
<
Modal
open=
{
open
}
title=
'新增'
onCancel=
{
handleClosed
}
onOk=
{
handleSubmit
}
destroyOnClose
width=
{
800
}
>
<
Form
name=
'form'
form=
{
form
}
layout=
'horizontal'
labelCol=
{
{
span
:
4
}
}
wrapperCol=
{
{
span
:
16
}
}
>
<
Form
.
Item
name=
'specName'
label=
'规格名称'
rules=
{
[{
required
:
true
,
message
:
'请输入规格名称'
}]
}
>
<
Input
placeholder=
'请输入规格名称'
allowClear
maxLength=
{
30
}
/>
</
Form
.
Item
>
<
Form
.
Item
name=
'specImage'
label=
'规格图片'
rules=
{
[{
required
:
true
,
message
:
'请上传规格图片'
}]
}
>
<
Uploader
fileUpload
listType=
'picture-card'
onChange=
{
uploadSuccess
}
defaultFileList=
{
fileList
}
>
<
UploadOutlined
/>
</
Uploader
>
</
Form
.
Item
>
<
Form
.
Item
name=
'partNo'
label=
'产品料号'
rules=
{
[{
required
:
true
,
message
:
'请输入产品料号'
}]
}
>
<
Input
placeholder=
'请输入产品料号'
allowClear
maxLength=
{
50
}
/>
</
Form
.
Item
>
<
Form
.
Item
name=
'versionDesc'
label=
'版本描述'
rules=
{
[{
required
:
true
,
message
:
'请输入版本描述'
}]
}
>
<
Input
placeholder=
'请输入版本描述'
allowClear
maxLength=
{
50
}
/>
</
Form
.
Item
>
</
Form
>
</
Modal
>
</
div
>
);
};
export
default
AddOrEditProduceSpecModal
;
src/pages/mallManage/produceManage/produceDetail/components/setProduceSpecPriceModal/index.tsx
0 → 100644
浏览文件 @
c719f928
import
React
,
{
FC
,
useEffect
,
useState
}
from
'react'
;
import
{
Form
,
Input
,
message
,
Modal
,
Select
,
Row
,
Col
,
Button
,
ModalProps
,
Card
}
from
'antd'
;
import
{
ProduceManageAPI
}
from
'~/api'
;
import
{
InterDataType
}
from
'~/api/interface'
;
import
{
cooperationTagType
,
ProductSpecListType
}
from
'~/api/interface/produceManageType'
;
import
{
filterObjAttr
}
from
'~/utils'
;
//加盟标签返回类型
type
cooperationTagResponseType
=
InterDataType
<
cooperationTagType
>
;
//产品规格返回类型
type
specType
=
InterDataType
<
ProductSpecListType
>
[
'list'
][
0
];
interface
PropsType
{
onCancel
:
()
=>
void
;
data
:
specType
|
undefined
;
}
const
{
Option
}
=
Select
;
const
SetProduceSpecPriceModal
:
FC
<
ModalProps
&
PropsType
>
=
({
open
,
onCancel
,
data
})
=>
{
const
tabList
=
[
{
key
:
'0'
,
tab
:
'销售价格'
,
},
{
key
:
'1'
,
tab
:
'租赁价格'
,
},
];
//当前tab
const
[
currentTab
,
setCurrentTab
]
=
useState
<
string
>
(
'0'
);
// 表格事件
const
[
form
]
=
Form
.
useForm
();
// 等级标签列表
const
[
tagInfoList
,
setTagInfoList
]
=
useState
<
cooperationTagResponseType
>
([]);
// 选择的列表
const
[
selectList
,
setSelectList
]
=
useState
<
number
[]
>
([]);
//是否编辑
const
[
isEdit
,
setIsEdit
]
=
useState
<
boolean
>
(
false
);
// 获取当前规格的价格
const
getProductSpecPrice
=
(
type
:
number
,
productSpecId
?:
number
,
leaseTerm
?:
number
)
=>
{
ProduceManageAPI
.
getProductSpecPrice
({
type
,
productSpecId
,
leaseTerm
}).
then
(({
result
})
=>
{
setIsEdit
(
!!
result
.
length
);
const
levelNumber
:
number
[]
=
result
.
filter
((
v
)
=>
v
.
cooperationTag
!=
0
)
.
map
((
v
)
=>
v
.
cooperationTag
);
const
Obj
:
any
=
result
.
reduce
((
pre
:
any
,
cur
)
=>
{
pre
[
cur
.
cooperationTag
]
=
cur
.
price
;
return
{
...
pre
};
},
{});
if
(
result
.
length
)
{
form
.
setFieldsValue
({
...
Obj
,
level
:
levelNumber
});
}
else
{
form
.
setFieldsValue
({
0
:
undefined
,
level
:
undefined
,
});
}
const
arr
=
result
.
map
((
i
)
=>
{
return
i
.
cooperationTag
;
})
.
filter
((
i
:
number
)
=>
i
!==
0
);
setSelectList
(
arr
);
});
};
// 获取等级标签
const
getTagNameList
=
()
=>
{
ProduceManageAPI
.
getCooperationListTag
().
then
(({
result
})
=>
{
setTagInfoList
(
result
||
[]);
});
};
// 选择器点击事件
const
handleChange
=
(
value
:
number
[])
=>
{
setSelectList
(
value
);
};
// 将val转换为label
const
transValtoLabel
=
(
id
:
number
)
=>
{
const
item
=
tagInfoList
.
find
((
i
)
=>
i
.
id
===
id
);
return
item
?
item
.
tagName
:
id
;
};
// 关闭弹窗
const
handleClosed
=
()
=>
{
setCurrentTab
(
'0'
);
const
data
=
Object
.
fromEntries
(
selectList
.
map
((
i
)
=>
{
return
[
i
,
undefined
];
}),
);
form
.
setFieldsValue
({
0
:
undefined
,
...
data
,
});
setSelectList
([]);
onCancel
();
};
// 触发表单验证
const
handleSubmit
=
()
=>
{
form
.
validateFields
()
.
then
(
async
(
values
)
=>
{
const
specPrice
=
Object
.
keys
(
filterObjAttr
(
values
,
[
'leaseTerm'
,
'level'
])).
reduce
(
(
pre
:
any
,
cur
:
string
)
=>
{
return
[...
pre
,
{
price
:
values
[
cur
],
cooperationTag
:
Number
(
cur
)
}];
},
[],
);
ProduceManageAPI
[
isEdit
?
'editProductSpecPrice'
:
'setProductSpecPrice'
]({
specPrice
,
productSpecId
:
data
?.
id
,
type
:
Number
(
currentTab
),
leaseTerm
:
values
.
leaseTerm
,
}).
then
(({
code
})
=>
{
if
(
code
===
'200'
)
{
message
.
success
(
'操作成功'
);
handleClosed
();
}
});
})
.
catch
((
err
)
=>
{
message
.
warning
(
err
.
errorFields
[
0
].
errors
[
0
]).
then
();
});
};
// 价格正则
const
priceValidator
=
(
_rule
:
any
,
value
:
any
)
=>
{
const
regExp
=
/^
[
1-9
]\d{0,7}(\.\d{1,2})?
$|^0
(\.\d{1,2})?
$/
;
const
bol
:
boolean
=
regExp
.
test
(
value
);
if
(
!
value
)
{
return
Promise
.
reject
(
new
Error
(
'请输入定价金额'
));
}
if
(
!
bol
)
{
return
Promise
.
reject
(
new
Error
(
'金额应为数字,小数最多两位,整数最多八位,不能输入0开头的整数'
),
);
}
return
Promise
.
resolve
();
};
//tab change
const
onTabChange
=
(
key
:
string
)
=>
{
form
.
resetFields
();
switch
(
key
)
{
case
'0'
:
getProductSpecPrice
(
Number
(
key
),
data
?.
id
);
break
;
case
'1'
:
getProductSpecPrice
(
Number
(
key
),
data
?.
id
,
0
);
break
;
}
setSelectList
([]);
setCurrentTab
(
key
);
};
//租期选择
const
rentDateChange
=
(
value
:
string
)
=>
{
getProductSpecPrice
(
Number
(
currentTab
),
data
?.
id
,
Number
(
value
));
};
// componentsDidMounted
useEffect
(()
=>
{
if
(
data
)
{
getTagNameList
();
getProductSpecPrice
(
Number
(
currentTab
),
data
?.
id
);
}
},
[
data
]);
return
(
<
Modal
open=
{
open
}
title=
'配置价格'
destroyOnClose
width=
{
768
}
onCancel=
{
handleClosed
}
footer=
{
[
<
Button
key=
'1'
type=
'default'
onClick=
{
handleClosed
}
>
取消
</
Button
>,
<
Button
key=
'2'
type=
'primary'
onClick=
{
handleSubmit
}
>
确认
</
Button
>,
]
}
>
<
Card
tabList=
{
tabList
}
onTabChange=
{
onTabChange
}
>
<
Form
name=
'form'
form=
{
form
}
layout=
'horizontal'
labelWrap
initialValues=
{
{
leaseTerm
:
0
}
}
>
{
currentTab
===
'1'
&&
(
<
Form
.
Item
label=
'租期'
labelCol=
{
{
span
:
5
}
}
wrapperCol=
{
{
span
:
15
}
}
name=
'leaseTerm'
rules=
{
[{
required
:
true
,
message
:
'请选择租期'
}]
}
>
<
Select
onChange=
{
rentDateChange
}
>
<
Select
.
Option
value=
{
0
}
>
1-7天
</
Select
.
Option
>
<
Select
.
Option
value=
{
1
}
>
8-15天
</
Select
.
Option
>
<
Select
.
Option
value=
{
2
}
>
16-30天
</
Select
.
Option
>
<
Select
.
Option
value=
{
3
}
>
31天以上
</
Select
.
Option
>
</
Select
>
</
Form
.
Item
>
)
}
<
Form
.
Item
label=
'渠道等级'
name=
'level'
rules=
{
[{
required
:
true
,
message
:
'请选择渠道等级'
}]
}
labelCol=
{
{
span
:
5
}
}
wrapperCol=
{
{
span
:
15
}
}
>
<
Select
placeholder=
'请选择渠道等级'
allowClear
mode=
'multiple'
onChange=
{
handleChange
}
value=
{
selectList
}
>
{
tagInfoList
.
map
((
i
,
j
)
=>
(
<
Option
value=
{
i
.
id
}
key=
{
j
}
>
{
i
.
tagName
}
</
Option
>
))
}
</
Select
>
</
Form
.
Item
>
<
Row
>
<
Col
span=
{
20
}
>
<
Form
.
Item
name=
'0'
label=
'市场单价'
rules=
{
[{
required
:
true
,
validator
:
priceValidator
}]
}
labelCol=
{
{
span
:
6
}
}
wrapperCol=
{
{
span
:
18
}
}
>
<
Input
placeholder=
'请输入市场单价'
maxLength=
{
11
}
allowClear
/>
</
Form
.
Item
>
</
Col
>
<
Col
span=
{
4
}
>
<
div
style=
{
{
margin
:
'6px 0 0 10px'
}
}
>
元/件
</
div
>
</
Col
>
</
Row
>
{
selectList
.
map
((
i
,
j
)
=>
(
<
Row
key=
{
j
}
>
<
Col
span=
{
20
}
>
<
Form
.
Item
name=
{
i
}
label=
{
transValtoLabel
(
i
)
}
rules=
{
[{
required
:
true
,
validator
:
priceValidator
}]
}
key=
{
j
}
labelCol=
{
{
span
:
6
}
}
wrapperCol=
{
{
span
:
18
}
}
>
<
Input
placeholder=
'请输入定价金额'
maxLength=
{
11
}
allowClear
/>
</
Form
.
Item
>
</
Col
>
<
Col
span=
{
4
}
>
<
div
style=
{
{
margin
:
'6px 0 0 10px'
}
}
>
元/件
</
div
>
</
Col
>
</
Row
>
))
}
</
Form
>
</
Card
>
</
Modal
>
);
};
export
default
SetProduceSpecPriceModal
;
src/pages/mallManage/produceManage/produceDetail/index.tsx
浏览文件 @
c719f928
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
qs
from
'query-string'
;
import
{
Button
,
Descriptions
,
message
,
Table
,
Modal
,
Image
}
from
'antd'
;
import
{
Button
,
Descriptions
,
message
,
Table
,
Modal
}
from
'antd'
;
import
{
ColumnsType
}
from
'antd/es/table'
;
import
{
ColumnsType
}
from
'antd/es/table'
;
// import { PriceModal } from '@/pages/goodsManage/productManage/comp/priceModal';
import
AddOrEditProduceSpecModal
from
'./components/addOrEditProduceSpecModal'
;
// import { AddEditDetailModal } from '@/pages/goodsManage/productManage/comp/addEditDetailModal';
import
SetProduceSpecPriceModal
from
'./components/setProduceSpecPriceModal'
;
import
useOption
from
'~/common/hook/optionHook'
;
import
{
ProductSkuType
,
ProductSpecType
}
from
'../produceList/propsType'
;
import
{
ProduceManageAPI
}
from
'~/api'
;
import
{
ProduceManageAPI
}
from
'~/api'
;
import
{
useSearchParams
}
from
'react-router-dom'
;
import
{
InterDataType
,
PaginationProps
}
from
'~/api/interface'
;
import
{
productDetailType
,
ProductSpecListType
}
from
'~/api/interface/produceManageType'
;
//产品详情返回类型
type
detailType
=
InterDataType
<
productDetailType
>
;
//产品规格返回类型
type
specType
=
InterDataType
<
ProductSpecListType
>
[
'list'
];
const
{
confirm
}
=
Modal
;
const
{
confirm
}
=
Modal
;
function
ProduceDetail
(
props
:
any
)
{
function
ProduceDetail
()
{
const
[
searchParams
]
=
useSearchParams
();
//产品id
const
[
productId
,
setProductId
]
=
useState
<
number
>
(
0
);
// 基本信息
// 基本信息
const
[
detailData
,
setDetailData
]
=
useState
<
ProductSku
Type
>
();
const
[
detailData
,
setDetailData
]
=
useState
<
detail
Type
>
();
// 表格数据
// 表格数据
const
[
tableData
,
setTableData
]
=
useState
<
ProductSpecType
[]
>
([]);
const
[
tableData
,
setTableData
]
=
useState
<
specType
>
([]);
// 图片是否放大
//新增、编辑产品规格弹窗
const
[
visibleImg
,
setVisibleImg
]
=
useState
<
boolean
>
(
false
);
const
[
addOrEditProduceSpecModalShow
,
setAddOrEditProduceSpecModalShow
]
=
// 当前放大图片
useState
<
boolean
>
(
false
);
const
[
currentImgList
,
setCurrentImgList
]
=
useState
<
{
src
:
string
}[]
>
([]);
// 当前数据
// 产品清单弹窗显示
const
[
addEditData
,
setAddEditData
]
=
useState
<
specType
[
0
]
>
();
const
[
visibleList
,
setVisibleList
]
=
useState
<
boolean
>
(
false
);
//配置价格弹窗
// 当前放大图片
const
[
produceSpecPriceModalShow
,
setProduceSpecPriceModalShow
]
=
useState
<
boolean
>
(
false
);
const
[
listData
,
setListData
]
=
useState
([]);
// 表格结构
// 配置价格弹窗显示
const
columns
:
ColumnsType
<
specType
[
0
]
>
=
[
const
[
visiblePrice
,
setVisiblePrice
]
=
useState
<
boolean
>
(
false
);
{
title
:
'规格名称'
,
dataIndex
:
'specName'
,
align
:
'center'
},
// 当前配置价格数据
{
const
[
priceData
,
setPriceData
]
=
useState
([]);
title
:
'规格图片'
,
// 配置价格弹窗显示
dataIndex
:
'specImage'
,
const
[
visibleAddEdit
,
setVisibleAddEdit
]
=
useState
<
boolean
>
(
false
);
align
:
'center'
,
// 当前配置价格数据
render
:
(
text
:
string
)
=>
{
const
[
addEditData
,
setAddEditData
]
=
useState
<
ProductSpecType
>
();
return
<
Image
width=
{
50
}
height=
{
50
}
src=
{
text
}
/>;
// 按钮权限
},
const
btnAdd
=
useOption
(
22155
);
},
const
btnSetPrice
=
useOption
(
22156
);
{
title
:
'版本描述'
,
dataIndex
:
'versionDesc'
,
align
:
'center'
},
const
btnEdit
=
useOption
(
22157
);
{
title
:
'料号'
,
dataIndex
:
'partNo'
,
align
:
'center'
},
const
btnDelete
=
useOption
(
22158
);
{
// 预览图片
title
:
'操作'
,
const
previewImage
=
(
url
:
string
)
=>
{
align
:
'center'
,
setVisibleImg
(
true
);
width
:
'250px'
,
setCurrentImgList
([{
src
:
url
}]);
render
:
(
_text
:
string
,
record
)
=>
{
};
return
(
// 关闭图片放大
<
div
>
const
setVisibleEvent
=
()
=>
{
<
Button
setVisibleImg
(
false
);
type=
'link'
};
onClick=
{
()
=>
{
// 查看产品清单
handlePrice
(
record
);
const
handleList
=
(
arr
:
any
)
=>
{
}
}
setListData
(
arr
);
>
setVisibleList
(
true
);
配置价格
};
</
Button
>
// 关闭产品清单
<
Button
const
handleListClosed
=
()
=>
{
type=
'link'
setListData
([]);
onClick=
{
()
=>
{
setVisibleList
(
false
);
handleEdit
(
record
);
};
}
}
// 打开配置价格弹窗
>
const
handlePrice
=
(
arr
:
any
)
=>
{
编辑
setPriceData
(
arr
);
</
Button
>
setVisiblePrice
(
true
);
<
Button
type=
'link'
onClick=
{
()
=>
handleDelete
(
record
)
}
>
};
删除
// 关闭配置价格弹窗
</
Button
>
const
handlePriceClosed
=
()
=>
{
</
div
>
setPriceData
([]);
);
setVisiblePrice
(
false
);
},
};
},
];
// 表格分页配置
const
[
pagination
,
setPagination
]
=
useState
<
PaginationProps
&
{
totalCount
:
number
}
>
({
totalCount
:
0
,
pageSize
:
10
,
pageNo
:
1
,
});
// 打开新增弹窗
// 打开新增弹窗
const
handleAdd
=
()
=>
{
const
handleAdd
=
()
=>
{
const
{
id
}
=
qs
.
parse
(
props
.
location
.
search
);
setAddEditData
(
undefined
);
setAddEditData
({
setAddOrEditProduceSpecModalShow
(
true
);
createTime
:
''
,
id
:
0
,
partNo
:
''
,
productSkuId
:
id
as
unknown
as
number
,
specImage
:
''
,
specName
:
''
,
versionDesc
:
''
,
});
setVisibleAddEdit
(
true
);
};
};
// 打开编辑弹窗
// 打开编辑弹窗
const
handleEdit
=
(
arr
:
ProductSpecType
)
=>
{
const
handleEdit
=
(
record
:
specType
[
0
]
)
=>
{
setAddEditData
(
arr
);
setAddEditData
(
record
);
set
VisibleAddEdit
(
true
);
set
AddOrEditProduceSpecModalShow
(
true
);
};
};
// 关闭新增编辑弹窗
// 关闭新增编辑弹窗
const
handleAddEditClosed
=
()
=>
{
const
addOrEditProduceSpecModalCancel
=
()
=>
{
paginationChange
(
pagination
.
current
,
pagination
.
pageSiz
e
);
setAddOrEditProduceSpecModalShow
(
fals
e
);
setAddEditData
(
undefined
);
setAddEditData
(
undefined
);
setVisibleAddEdit
(
false
);
};
};
// 删除产品
const
addOrEditProduceSpecModalOk
=
()
=>
{
const
handleDelete
=
(
record
:
ProductSpecType
)
=>
{
setAddOrEditProduceSpecModalShow
(
false
);
getProductSpecList
(
productId
);
};
// 删除产品
const
handleDelete
=
(
record
:
specType
[
0
])
=>
{
confirm
({
confirm
({
title
:
'提示'
,
title
:
'提示'
,
content
:
'删除后此数据将会丢失,确定删除吗?'
,
content
:
'删除后此数据将会丢失,确定删除吗?'
,
async
onOk
()
{
async
onOk
()
{
const
res
:
any
=
await
ProduceManageAPI
.
removeProductSpec
({
id
:
record
.
id
});
const
{
code
,
result
}
=
await
ProduceManageAPI
.
removeProductSpec
({
id
:
record
.
id
});
if
(
res
.
code
!==
'200'
)
{
if
(
!
result
&&
code
===
'200'
)
{
return
message
.
error
(
res
.
message
);
message
.
success
(
'操作成功'
);
}
getProductSpecList
(
productId
);
if
(
!
res
.
result
)
{
await
message
.
success
(
'操作成功'
);
await
paginationChange
(
pagination
.
current
,
pagination
.
pageSize
);
return
;
return
;
}
}
message
.
info
({
message
.
info
({
content
:
(
content
:
(
<
div
style=
{
{
textAlign
:
'left'
}
}
>
<
div
style=
{
{
textAlign
:
'left'
}
}
>
{
res
.
res
ult
.
goodsName
&&
(
{
result
.
goodsName
&&
(
<
div
>
<
div
>
<
div
style=
{
{
color
:
'red'
}
}
>
删除失败,已被商品关联
</
div
>
<
div
style=
{
{
color
:
'red'
}
}
>
删除失败,已被商品关联
</
div
>
<
div
>
关联商品为:
{
res
.
res
ult
.
goodsName
.
join
(
','
)
}
</
div
>
<
div
>
关联商品为:
{
result
.
goodsName
.
join
(
','
)
}
</
div
>
</
div
>
</
div
>
)
}
)
}
{
res
.
res
ult
.
industrySkuName
&&
(
{
result
.
industrySkuName
&&
(
<
div
>
<
div
>
<
div
style=
{
{
color
:
'red'
}
}
>
删除失败,已被方案关联
</
div
>
<
div
style=
{
{
color
:
'red'
}
}
>
删除失败,已被方案关联
</
div
>
<
div
>
关联方案SKU为:
{
getTipInfo
(
res
.
res
ult
.
industrySkuName
)
}
</
div
>
<
div
>
关联方案SKU为:
{
getTipInfo
(
result
.
industrySkuName
)
}
</
div
>
</
div
>
</
div
>
)
}
)
}
</
div
>
</
div
>
),
),
duration
:
2
,
duration
:
2
,
// key: date,
// onClick: () => {
// message.destroy(date);
// },
});
});
},
},
});
});
};
};
// 表格结构
const
columns
:
ColumnsType
<
ProductSpecType
>
=
[
{
title
:
'规格名称'
,
dataIndex
:
'specName'
,
align
:
'center'
},
{
title
:
'规格图片'
,
dataIndex
:
'specImage'
,
align
:
'center'
,
render
:
(
text
:
string
)
=>
{
return
(
<
img
style=
{
{
width
:
'50px'
,
height
:
'50px'
}
}
src=
{
text
}
alt=
'图片'
onClick=
{
()
=>
{
previewImage
(
text
);
}
}
/>
);
},
},
{
title
:
'版本描述'
,
dataIndex
:
'versionDesc'
,
align
:
'center'
},
{
title
:
'料号'
,
dataIndex
:
'partNo'
,
align
:
'center'
},
{
title
:
'操作'
,
align
:
'center'
,
width
:
'250px'
,
render
:
(
text
:
string
,
record
:
ProductSpecType
)
=>
{
return
(
<
div
>
{
btnSetPrice
?
(
<
Button
type=
'link'
onClick=
{
()
=>
{
handlePrice
(
record
);
}
}
>
配置价格
</
Button
>
)
:
(
''
)
}
{
btnEdit
?
(
<
Button
type=
'link'
onClick=
{
()
=>
{
handleEdit
(
record
);
}
}
>
编辑
</
Button
>
)
:
(
''
)
}
{
btnDelete
?
(
<
Button
type=
'link'
onClick=
{
()
=>
handleDelete
(
record
)
}
>
删除
</
Button
>
)
:
(
''
)
}
</
div
>
);
},
},
];
// 表格分页配置
const
[
pagination
,
setPagination
]
=
useState
({
total
:
0
,
pageSize
:
10
,
current
:
1
,
totalPage
:
0
,
});
// 获取基本信息
// 获取基本信息
const
getDetailData
=
async
()
=>
{
const
getDetailData
=
(
id
:
number
)
=>
{
const
{
id
}
=
qs
.
parse
(
props
.
location
.
search
);
ProduceManageAPI
.
getProductSkuDetail
({
id
}).
then
(({
result
})
=>
{
const
res
:
any
=
await
ProduceManageAPI
.
getProductSkuDetail
({
id
});
setDetailData
(
result
||
{});
if
(
res
&&
res
.
code
===
'200'
)
{
});
setDetailData
(
res
.
result
);
}
};
};
// 获取表格数据
//获取产品规格列表
// 新版通用部分(ES6+ for React) ZhangLK 2022/08/30 Start
const
getProductSpecList
=
(
productSkuId
:
number
)
=>
{
// 加载列表
ProduceManageAPI
.
listPageProductSpec
({
const
getTableList
=
async
(
value
=
{})
=>
{
pageNo
:
pagination
.
pageNo
,
// 只需要修改这个地方的接口即可
const
res
:
any
=
await
ProduceManageAPI
.
listPageProductSpec
({
pageNo
:
pagination
.
current
,
pageSize
:
pagination
.
pageSize
,
pageSize
:
pagination
.
pageSize
,
...
value
,
productSkuId
,
productSkuId
:
qs
.
parse
(
props
.
location
.
search
).
id
,
}).
then
(({
result
})
=>
{
setTableData
(
result
.
list
);
pagination
.
totalCount
=
result
.
totalCount
;
setPagination
(
pagination
);
});
});
if
(
res
&&
res
.
code
===
'200'
)
{
// console.log("res -->", res);
const
{
list
,
pageNo
,
totalCount
,
pageSize
,
totalPage
}
=
res
.
result
;
// 解构
setPagination
({
total
:
totalCount
,
pageSize
,
current
:
pageNo
,
totalPage
,
});
setTableData
(
list
);
}
else
{
message
.
warning
(
res
.
message
);
}
};
};
// 翻页
// 翻页
const
paginationChange
=
(
pageNo
:
number
,
pageSize
:
number
)
=>
{
const
paginationChange
=
(
pageNo
:
number
,
pageSize
:
number
)
=>
{
getTableList
({
pageNo
,
pageSize
}).
then
();
pagination
.
pageNo
=
pageNo
;
pagination
.
pageSize
=
pageSize
;
getProductSpecList
(
productId
);
};
//配置价格
const
handlePrice
=
(
record
:
specType
[
0
])
=>
{
setAddEditData
(
record
);
setProduceSpecPriceModalShow
(
true
);
};
const
produceSpecPriceModalCancel
=
()
=>
{
setProduceSpecPriceModalShow
(
false
);
};
};
// 返回上一页
// 返回上一页
const
handleBack
=
()
=>
{
const
handleBack
=
()
=>
{
...
@@ -248,9 +173,9 @@ function ProduceDetail(props: any) {
...
@@ -248,9 +173,9 @@ function ProduceDetail(props: any) {
return
data
.
map
((
v
:
any
)
=>
`
${
v
.
industrySkuName
}
(
${
v
.
industrySpecNames
}
)`
).
join
(
'、'
);
return
data
.
map
((
v
:
any
)
=>
`
${
v
.
industrySkuName
}
(
${
v
.
industrySpecNames
}
)`
).
join
(
'、'
);
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
// if (!props.location.search) return
;
setProductId
(
Number
(
searchParams
.
get
(
'id'
)))
;
// getDetailData().then(
);
getDetailData
(
Number
(
searchParams
.
get
(
'id'
))
);
// getTableList().then(
);
getProductSpecList
(
Number
(
searchParams
.
get
(
'id'
))
);
},
[]);
},
[]);
return
(
return
(
<
div
className=
'detail-wrap'
>
<
div
className=
'detail-wrap'
>
...
@@ -269,7 +194,7 @@ function ProduceDetail(props: any) {
...
@@ -269,7 +194,7 @@ function ProduceDetail(props: any) {
>
>
<
Descriptions
.
Item
label=
'产品名称'
>
{
detailData
?.
productName
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'产品名称'
>
{
detailData
?.
productName
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'产品目录'
>
{
detailData
?.
directoryName
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'产品目录'
>
{
detailData
?.
directoryName
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'产品类型'
>
{
detailData
?.
type
Name
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'产品类型'
>
{
detailData
?.
category
Name
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'型号'
>
{
detailData
?.
model
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'型号'
>
{
detailData
?.
model
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'产品品牌'
>
{
detailData
?.
productBrand
}
</
Descriptions
.
Item
>
<
Descriptions
.
Item
label=
'产品品牌'
>
{
detailData
?.
productBrand
}
</
Descriptions
.
Item
>
</
Descriptions
>
</
Descriptions
>
...
@@ -280,15 +205,11 @@ function ProduceDetail(props: any) {
...
@@ -280,15 +205,11 @@ function ProduceDetail(props: any) {
labelStyle=
{
{
width
:
'200px'
}
}
labelStyle=
{
{
width
:
'200px'
}
}
style=
{
{
marginTop
:
'20px'
}
}
style=
{
{
marginTop
:
'20px'
}
}
>
>
{
btnAdd
?
(
<
Descriptions
.
Item
>
<
Descriptions
.
Item
>
<
Button
type=
'primary'
onClick=
{
handleAdd
}
>
<
Button
type=
'primary'
onClick=
{
handleAdd
}
>
新增规格
新增规格
</
Button
>
</
Button
>
</
Descriptions
.
Item
>
</
Descriptions
.
Item
>
)
:
(
''
)
}
<
Descriptions
.
Item
>
<
Descriptions
.
Item
>
<
Table
<
Table
size=
'small'
size=
'small'
...
@@ -298,9 +219,9 @@ function ProduceDetail(props: any) {
...
@@ -298,9 +219,9 @@ function ProduceDetail(props: any) {
style=
{
{
width
:
'100%'
}
}
style=
{
{
width
:
'100%'
}
}
bordered
bordered
pagination=
{
{
pagination=
{
{
total
:
pagination
.
total
,
total
:
pagination
.
total
Count
,
pageSize
:
pagination
.
pageSize
,
pageSize
:
pagination
.
pageSize
,
current
:
pagination
.
current
,
current
:
pagination
.
pageNo
,
showSizeChanger
:
true
,
showSizeChanger
:
true
,
showQuickJumper
:
true
,
showQuickJumper
:
true
,
onChange
:
(
page
:
number
,
pageSize
:
number
)
=>
paginationChange
(
page
,
pageSize
),
onChange
:
(
page
:
number
,
pageSize
:
number
)
=>
paginationChange
(
page
,
pageSize
),
...
@@ -310,12 +231,20 @@ function ProduceDetail(props: any) {
...
@@ -310,12 +231,20 @@ function ProduceDetail(props: any) {
/>
/>
</
Descriptions
.
Item
>
</
Descriptions
.
Item
>
</
Descriptions
>
</
Descriptions
>
{
/*<PriceModal visible={visiblePrice} closed={handlePriceClosed} data={priceData} />*/
}
{
/*新增、编辑*/
}
{
/*<AddEditDetailModal*/
}
<
AddOrEditProduceSpecModal
{
/* visible={visibleAddEdit}*/
}
open=
{
addOrEditProduceSpecModalShow
}
{
/* closed={handleAddEditClosed}*/
}
onCancel=
{
addOrEditProduceSpecModalCancel
}
{
/* data={addEditData}*/
}
data=
{
addEditData
}
{
/*/>*/
}
onOk=
{
addOrEditProduceSpecModalOk
}
productSkuId=
{
productId
}
/>
{
/*配置价格*/
}
<
SetProduceSpecPriceModal
open=
{
produceSpecPriceModalShow
}
onCancel=
{
produceSpecPriceModalCancel
}
data=
{
addEditData
}
/>
</
div
>
</
div
>
);
);
}
}
...
...
src/pages/mallManage/produceManage/produceList/components/addOrEditProduceModal/index.tsx
浏览文件 @
c719f928
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
FC
,
useEffect
,
useState
}
from
'react'
;
import
{
Form
,
Input
,
Modal
,
message
,
Select
}
from
'antd'
;
import
{
Form
,
Input
,
Modal
,
message
,
Select
,
ModalProps
}
from
'antd'
;
import
{
CategoryManageAPI
,
ProduceManageAPI
}
from
'~/api'
;
import
{
CategoryManageAPI
,
ProduceManageAPI
}
from
'~/api'
;
import
{
ProductSkuType
,
MakeItemEntity
}
from
'../../propsType'
;
import
{
InterDataType
,
InterReqType
}
from
'~/api/interface'
;
import
{
InterDataType
}
from
'~/api/interface'
;
import
{
categoryListType
,
directoryListType
}
from
'~/api/interface/categoryManage'
;
import
{
categoryListType
,
directoryListType
}
from
'~/api/interface/categoryManage'
;
import
{
MakeListType
}
from
'~/api/interface/makeManage'
;
import
{
addProductType
}
from
'~/api/interface/produceManageType'
;
import
{
filterObjAttr
}
from
'~/utils'
;
//目录返回类型
//目录返回类型
type
directoryType
=
InterDataType
<
directoryListType
>
;
type
directoryType
=
InterDataType
<
directoryListType
>
;
//分类返回类型
//分类返回类型
type
categoryType
=
InterDataType
<
categoryListType
>
[
'list'
];
type
categoryType
=
InterDataType
<
categoryListType
>
[
'list'
];
//品牌返回类型
type
makeListType
=
InterDataType
<
MakeListType
>
[
'list'
];
//表单类型
type
addMakeParameterType
=
InterReqType
<
addProductType
>
;
interface
PropsType
{
interface
PropsType
{
visible
:
boolean
;
closed
:
()
=>
void
;
closed
:
any
;
data
:
(
addMakeParameterType
&
{
id
:
number
;
categoriesId
:
number
})
|
undefined
;
data
:
ProductSkuType
|
undefined
;
makeList
:
MakeItemEntity
[];
decList
:
directoryType
;
decList
:
directoryType
;
makeList
:
makeListType
;
onOk
:
()
=>
void
;
}
}
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
function
AddOrEditProduceModal
(
props
:
PropsType
)
{
const
AddOrEditProduceModal
:
FC
<
ModalProps
&
PropsType
>
=
({
// 父组件传参
open
,
const
{
visible
,
closed
,
data
,
makeList
,
decList
}
=
props
;
closed
,
data
,
decList
,
makeList
,
onOk
,
})
=>
{
// 产品类型下拉列表
// 产品类型下拉列表
const
[
productTypeSelectList
,
setProductTypeSelectList
]
=
useState
<
categoryType
>
([]);
const
[
productTypeSelectList
,
setProductTypeSelectList
]
=
useState
<
categoryType
>
([]);
// 表格事件
// 表格事件
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
<
addMakeParameterType
>
();
// 关闭弹窗
// 关闭弹窗
const
handleClosed
=
async
()
=>
{
const
handleClosed
=
async
()
=>
{
form
.
resetFields
();
form
.
resetFields
();
...
@@ -36,15 +47,17 @@ function AddOrEditProduceModal(props: PropsType) {
...
@@ -36,15 +47,17 @@ function AddOrEditProduceModal(props: PropsType) {
const
handleSubmit
=
()
=>
{
const
handleSubmit
=
()
=>
{
form
form
.
validateFields
()
.
validateFields
()
.
then
(
async
(
values
)
=>
{
.
then
((
values
)
=>
{
const
obj
=
{
...
data
,
...
values
};
const
obj
:
any
=
{
...
data
,
...
values
};
const
res
:
any
=
await
ProduceManageAPI
[
!
obj
.
id
?
'addProductSku'
:
'editProductSku'
](
obj
);
ProduceManageAPI
[
!
obj
.
id
?
'addProductSku'
:
'editProductSku'
](
if
(
res
&&
res
.
code
===
'200'
)
{
filterObjAttr
(
obj
,
[
'categoriesId'
]),
message
.
success
(
'操作成功'
);
).
then
(({
code
})
=>
{
await
handleClosed
();
if
(
code
===
'200'
)
{
}
else
{
message
.
success
(
'操作成功'
);
message
.
warning
(
res
.
message
);
form
.
resetFields
();
}
onOk
();
}
});
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
message
.
warning
(
err
.
errorFields
[
0
].
errors
[
0
]).
then
();
message
.
warning
(
err
.
errorFields
[
0
].
errors
[
0
]).
then
();
...
@@ -60,20 +73,21 @@ function AddOrEditProduceModal(props: PropsType) {
...
@@ -60,20 +73,21 @@ function AddOrEditProduceModal(props: PropsType) {
};
};
// 目录修改
// 目录修改
const
decSelectChange
=
(
value
:
number
)
=>
{
const
decSelectChange
=
(
value
:
number
)
=>
{
form
.
setFieldValue
(
'
goodsType
Id'
,
undefined
);
form
.
setFieldValue
(
'
category
Id'
,
undefined
);
getCategoryListByDirectory
(
value
);
getCategoryListByDirectory
(
value
);
};
};
// componentsDidMounted
// componentsDidMounted
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
data
)
return
;
if
(
data
)
{
getCategoryListByDirectory
(
data
.
directoryId
);
getCategoryListByDirectory
(
data
.
directoryId
);
form
.
setFieldsValue
({
form
.
setFieldsValue
({
...
data
,
...
data
,
});
});
}
},
[
data
]);
},
[
data
]);
return
(
return
(
<
Modal
<
Modal
open=
{
visible
}
open=
{
open
}
title=
{
data
?.
id
?
'编辑'
:
'新增'
}
title=
{
data
?.
id
?
'编辑'
:
'新增'
}
onCancel=
{
handleClosed
}
onCancel=
{
handleClosed
}
onOk=
{
handleSubmit
}
onOk=
{
handleSubmit
}
...
@@ -108,7 +122,7 @@ function AddOrEditProduceModal(props: PropsType) {
...
@@ -108,7 +122,7 @@ function AddOrEditProduceModal(props: PropsType) {
</
Select
>
</
Select
>
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
<
Form
.
Item
name=
'
goodsType
Id'
name=
'
category
Id'
label=
'产品类型'
label=
'产品类型'
rules=
{
[{
required
:
true
,
message
:
'请选择产品类型'
}]
}
rules=
{
[{
required
:
true
,
message
:
'请选择产品类型'
}]
}
>
>
...
@@ -156,5 +170,5 @@ function AddOrEditProduceModal(props: PropsType) {
...
@@ -156,5 +170,5 @@ function AddOrEditProduceModal(props: PropsType) {
</
Form
>
</
Form
>
</
Modal
>
</
Modal
>
);
);
}
}
;
export
default
AddOrEditProduceModal
;
export
default
AddOrEditProduceModal
;
src/pages/mallManage/produceManage/produceList/index.tsx
浏览文件 @
c719f928
...
@@ -3,36 +3,36 @@ import './index.scss';
...
@@ -3,36 +3,36 @@ import './index.scss';
import
{
Button
,
Form
,
Input
,
message
,
Modal
,
Select
,
Table
}
from
'antd'
;
import
{
Button
,
Form
,
Input
,
message
,
Modal
,
Select
,
Table
}
from
'antd'
;
import
{
useNavigate
}
from
'react-router-dom'
;
import
{
useNavigate
}
from
'react-router-dom'
;
import
{
ColumnsType
}
from
'antd/es/table'
;
import
{
ColumnsType
}
from
'antd/es/table'
;
import
{
CategoryManageAPI
,
ProduceManageAPI
}
from
'~/api'
;
import
{
CategoryManageAPI
,
MakeManageAPI
,
ProduceManageAPI
}
from
'~/api'
;
import
AddOrEditProduce
from
'./components/addOrEditProduceModal'
;
import
AddOrEditProduce
from
'./components/addOrEditProduceModal'
;
import
{
MakeItemEntity
}
from
'./propsType'
;
import
{
InterDataType
,
InterReqType
,
PaginationProps
}
from
'~/api/interface'
;
import
{
InterDataType
,
PaginationProps
}
from
'~/api/interface'
;
import
{
addProductType
,
productListType
}
from
'~/api/interface/produceManageType'
;
import
{
productListType
}
from
'~/api/interface/produceManageType'
;
import
{
categoryListType
,
directoryListType
}
from
'~/api/interface/categoryManage'
;
import
{
categoryListType
,
directoryListType
}
from
'~/api/interface/categoryManage'
;
import
{
MakeListType
}
from
'~/api/interface/makeManage'
;
//产品列表返回类型
//产品列表返回类型
type
produceListType
=
InterDataType
<
productListType
>
[
'list'
];
type
produceListType
=
InterDataType
<
productListType
>
[
'list'
];
//产品列表参数类型
type
produceParametersType
=
Omit
<
InterReqType
<
productListType
>
,
'pageSize'
|
'pageNo'
>
;
//分类返回类型
//分类返回类型
type
categoryType
=
InterDataType
<
categoryListType
>
[
'list'
];
type
categoryType
=
InterDataType
<
categoryListType
>
[
'list'
];
//目录返回类型
//目录返回类型
type
directoryType
=
InterDataType
<
directoryListType
>
;
type
directoryType
=
InterDataType
<
directoryListType
>
;
//品牌返回类型
type
makeListType
=
InterDataType
<
MakeListType
>
[
'list'
];
//新增编辑表单类型
type
addMakeParameterType
=
InterReqType
<
addProductType
>
;
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
const
{
confirm
}
=
Modal
;
const
{
confirm
}
=
Modal
;
// 搜索表单的数据
let
query
:
any
=
{};
// 表单提交
interface
FormType
{
productName
?:
string
;
goodsTypeId
?:
number
;
}
function
ProduceManage
()
{
function
ProduceManage
()
{
// 路由操作
// 路由操作
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
// 表格数据
// 表格数据
const
[
tableData
,
setTableData
]
=
useState
<
produceListType
>
([]);
const
[
tableData
,
setTableData
]
=
useState
<
produceListType
>
([]);
//筛选表单
const
[
query
,
setQuery
]
=
useState
<
produceParametersType
>
();
// 加载中
// 加载中
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
const
[
loading
,
setLoading
]
=
useState
<
boolean
>
(
false
);
// 产品类型下拉列表
// 产品类型下拉列表
...
@@ -40,9 +40,11 @@ function ProduceManage() {
...
@@ -40,9 +40,11 @@ function ProduceManage() {
// 新增弹窗是否显示
// 新增弹窗是否显示
const
[
visibleAddEdit
,
setVisibleAddEdit
]
=
useState
(
false
);
const
[
visibleAddEdit
,
setVisibleAddEdit
]
=
useState
(
false
);
// 新增弹窗内容
// 新增弹窗内容
const
[
addEditData
,
setAddEditData
]
=
useState
<
produceListType
[
0
]
>
();
const
[
addEditData
,
setAddEditData
]
=
useState
<
addMakeParameterType
&
{
id
:
number
;
categoriesId
:
number
}
>
();
// 品牌列表
// 品牌列表
const
[
makeList
,
setMakeList
]
=
useState
<
MakeItemEntity
[]
>
([]);
const
[
makeList
,
setMakeList
]
=
useState
<
makeListType
>
([]);
// 目录列表
// 目录列表
const
[
decList
,
setDecList
]
=
useState
<
directoryType
>
([]);
const
[
decList
,
setDecList
]
=
useState
<
directoryType
>
([]);
// 表格结构
// 表格结构
...
@@ -66,7 +68,7 @@ function ProduceManage() {
...
@@ -66,7 +68,7 @@ function ProduceManage() {
align
:
'center'
,
align
:
'center'
,
width
:
'15%'
,
width
:
'15%'
,
fixed
:
'right'
,
fixed
:
'right'
,
render
:
(
text
:
string
,
record
)
=>
{
render
:
(
_
text
:
string
,
record
)
=>
{
return
(
return
(
<
div
>
<
div
>
<
Button
type=
'link'
onClick=
{
()
=>
handleDetail
(
record
)
}
>
<
Button
type=
'link'
onClick=
{
()
=>
handleDetail
(
record
)
}
>
...
@@ -99,42 +101,61 @@ function ProduceManage() {
...
@@ -99,42 +101,61 @@ function ProduceManage() {
};
};
// 新增弹窗
// 新增弹窗
const
handleAdd
=
()
=>
{
const
handleAdd
=
()
=>
{
getMakeList
();
setVisibleAddEdit
(
true
);
setVisibleAddEdit
(
true
);
setAddEditData
(
undefined
);
setAddEditData
(
undefined
);
};
};
// 编辑弹窗
// 编辑弹窗
const
handleEdit
=
(
record
:
produceListType
[
0
])
=>
{
const
handleEdit
=
(
record
:
produceListType
[
0
])
=>
{
getMakeList
();
setVisibleAddEdit
(
true
);
setVisibleAddEdit
(
true
);
setAddEditData
(
record
);
setAddEditData
({
id
:
record
.
id
,
categoryId
:
record
.
categoriesId
,
directoryId
:
record
.
directoryId
,
model
:
record
.
model
,
productBrandId
:
record
.
productBrandId
,
productName
:
record
.
productName
,
categoriesId
:
record
.
categoriesId
,
});
};
};
// 关闭弹窗
// 关闭弹窗
const
handleAddEditClosed
=
()
=>
{
const
handleAddEditClosed
=
()
=>
{
setVisibleAddEdit
(
false
);
setVisibleAddEdit
(
false
);
setAddEditData
(
undefined
);
setAddEditData
(
undefined
);
paginationChange
(
pagination
.
pageNo
,
pagination
.
pageSize
);
};
const
addOrEditProduceOk
=
()
=>
{
setVisibleAddEdit
(
false
);
setAddEditData
(
undefined
);
getProduceList
(
query
);
};
};
// 删除产品
// 删除产品
const
handleDelete
=
(
record
:
produceListType
[
0
])
=>
{
const
handleDelete
=
(
record
:
produceListType
[
0
])
=>
{
confirm
({
confirm
({
title
:
'提示'
,
title
:
'提示'
,
content
:
'删除后此数据将会丢失,确定删除吗?'
,
content
:
'删除后此数据将会丢失,确定删除吗?'
,
async
onOk
()
{
onOk
()
{
const
res
:
any
=
await
ProduceManageAPI
.
removeProductSku
({
id
:
record
.
id
});
ProduceManageAPI
.
removeProductSku
({
id
:
record
.
id
}).
then
(({
code
})
=>
{
if
(
res
&&
res
.
code
===
'200'
)
{
if
(
code
===
'200'
)
{
await
message
.
success
(
'操作成功'
);
if
(
pagination
.
pageNo
!=
1
&&
tableData
.
length
===
1
)
{
await
paginationChange
(
pagination
.
pageNo
,
pagination
.
pageSize
);
pagination
.
pageNo
-=
1
;
}
else
{
}
message
.
error
(
res
.
message
);
message
.
success
(
'删除成功'
);
}
getProduceList
(
query
);
}
});
},
},
});
});
};
};
//产品列表
//产品列表
const
getProduceList
=
()
=>
{
const
getProduceList
=
(
query
?:
produceParametersType
)
=>
{
setLoading
(
true
);
ProduceManageAPI
.
listPageProductSku
({
ProduceManageAPI
.
listPageProductSku
({
pageNo
:
pagination
.
pageNo
,
pageNo
:
pagination
.
pageNo
,
pageSize
:
pagination
.
pageSize
,
pageSize
:
pagination
.
pageSize
,
...
query
,
}).
then
(({
result
})
=>
{
}).
then
(({
result
})
=>
{
setLoading
(
false
);
setTableData
(
result
.
list
||
[]);
setTableData
(
result
.
list
||
[]);
setPagination
(
pagination
);
setPagination
(
pagination
);
});
});
...
@@ -143,29 +164,31 @@ function ProduceManage() {
...
@@ -143,29 +164,31 @@ function ProduceManage() {
const
paginationChange
=
(
pageNo
:
number
,
pageSize
:
number
)
=>
{
const
paginationChange
=
(
pageNo
:
number
,
pageSize
:
number
)
=>
{
pagination
.
pageNo
=
pageNo
;
pagination
.
pageNo
=
pageNo
;
pagination
.
pageSize
=
pageSize
;
pagination
.
pageSize
=
pageSize
;
getProduceList
();
getProduceList
(
query
);
};
};
// 表单提交
// 表单提交
const
onFinish
=
(
val
:
Form
Type
)
=>
{
const
onFinish
=
(
val
:
produceList
Type
)
=>
{
// 在这里对提交的数据做处理,如range转为开始和结束时间
// 在这里对提交的数据做处理,如range转为开始和结束时间
const
data
=
Object
.
fromEntries
(
const
data
=
Object
.
fromEntries
(
// 过滤为空项
// 过滤为空项
Object
.
entries
({
Object
.
entries
({
...
val
,
...
val
,
}).
filter
((
i
)
=>
i
[
1
]
!==
''
&&
i
[
1
]
!==
undefined
&&
i
[
1
]
!==
null
),
}).
filter
(
(
i
)
=>
(
typeof
i
[
1
]
===
'string'
&&
i
[
1
]
!==
''
)
||
(
i
[
1
]
!==
undefined
&&
i
[
1
]
!==
null
),
),
);
);
query
=
data
;
setQuery
(
data
)
;
// getTableList(data).then(
);
getProduceList
(
data
);
};
};
//
获取
品牌列表
//品牌列表
const
getMakeList
=
()
=>
{
const
getMakeList
=
()
=>
{
ProduceManageAPI
.
getListBrandInfo
({
pageNo
:
1
,
pageSize
:
999999
}).
then
(({
code
,
result
})
=>
{
MakeManageAPI
.
getListBrandInfo
({
pageNo
:
1
,
pageSize
:
9999
}).
then
(({
result
})
=>
{
setMakeList
(
result
.
list
||
[]);
setMakeList
(
result
.
list
||
[]);
});
});
};
};
// 目录列表
// 目录列表
const
getDirectoryList
=
()
=>
{
const
getDirectoryList
=
()
=>
{
CategoryManageAPI
.
getDirectoryList
({
type
:
4
}).
then
(({
result
})
=>
{
CategoryManageAPI
.
getDirectoryList
Clone
({
type
:
4
}).
then
(({
result
})
=>
{
setDecList
(
result
||
[]);
setDecList
(
result
||
[]);
});
});
};
};
...
@@ -185,7 +208,7 @@ function ProduceManage() {
...
@@ -185,7 +208,7 @@ function ProduceManage() {
};
};
// componentDidMount
// componentDidMount
useEffect
(()
=>
{
useEffect
(()
=>
{
getProduceList
();
getProduceList
(
query
);
getDirectoryList
();
getDirectoryList
();
},
[]);
},
[]);
...
@@ -245,11 +268,12 @@ function ProduceManage() {
...
@@ -245,11 +268,12 @@ function ProduceManage() {
}
}
}
}
/>
/>
<
AddOrEditProduce
<
AddOrEditProduce
visible
=
{
visibleAddEdit
}
open
=
{
visibleAddEdit
}
closed=
{
handleAddEditClosed
}
closed=
{
handleAddEditClosed
}
data=
{
addEditData
}
data=
{
addEditData
}
makeList=
{
makeList
}
makeList=
{
makeList
}
decList=
{
decList
}
decList=
{
decList
}
onOk=
{
addOrEditProduceOk
}
/>
/>
</
div
>
</
div
>
);
);
...
...
src/pages/mallManage/produceManage/produceList/propsType.ts
deleted
100644 → 0
浏览文件 @
66945260
// 产品sku管理-分页列表
export
interface
ProductSkuType
{
createTime
:
string
;
goodsTypeId
:
number
;
id
:
number
;
model
:
string
;
productBrand
:
number
;
productName
:
string
;
typeName
:
string
;
productBrandId
:
number
;
directoryId
:
number
;
directoryName
:
string
;
}
// 产品sku管理-产品规格管理-分页列表
export
interface
ProductSpecType
{
createTime
:
string
;
id
:
number
;
partNo
:
string
;
productSkuId
:
number
;
specImage
:
string
;
specName
:
string
;
versionDesc
:
string
;
}
// 品牌管理-列表
export
type
MakeItemEntity
=
{
createTime
:
string
;
brandName
:
string
;
id
:
number
;
};
src/router/privateRouter.tsx
浏览文件 @
c719f928
...
@@ -11,7 +11,7 @@ function PrivateRouter() {
...
@@ -11,7 +11,7 @@ function PrivateRouter() {
const
beforeEach
=
()
=>
{
const
beforeEach
=
()
=>
{
// TODO: 判断是否登录 (需要改为实时获取地址栏的路由)
// TODO: 判断是否登录 (需要改为实时获取地址栏的路由)
const
path
=
location
.
pathname
;
const
path
=
location
.
pathname
;
const
token
=
Cookies
.
get
(
'SHAREFLY
-
TOKEN'
);
const
token
=
Cookies
.
get
(
'SHAREFLY
_
TOKEN'
);
if
(
!
token
&&
path
!==
'/login'
)
{
if
(
!
token
&&
path
!==
'/login'
)
{
location
.
replace
(
'/login'
);
location
.
replace
(
'/login'
);
return
;
return
;
...
...
src/utils/index.ts
浏览文件 @
c719f928
...
@@ -35,7 +35,7 @@ export const urlToBase64 = (url: string) => {
...
@@ -35,7 +35,7 @@ export const urlToBase64 = (url: string) => {
};
};
// 过滤对象属性
// 过滤对象属性
export
const
filterObjAttr
=
(
obj
:
any
,
key
:
string
[])
=>
{
export
const
filterObjAttr
=
(
obj
:
any
,
key
:
string
[])
=>
{
return
Object
.
keys
(
obj
).
reduce
((
pre
:
any
,
cur
:
string
)
=>
{
return
Object
.
keys
(
JSON
.
parse
(
JSON
.
stringify
(
obj
))
).
reduce
((
pre
:
any
,
cur
:
string
)
=>
{
if
(
!
key
.
includes
(
cur
))
{
if
(
!
key
.
includes
(
cur
))
{
pre
[
cur
]
=
obj
[
cur
];
pre
[
cur
]
=
obj
[
cur
];
}
}
...
...
vite.config.ts
浏览文件 @
c719f928
...
@@ -12,6 +12,7 @@ export default defineConfig({
...
@@ -12,6 +12,7 @@ export default defineConfig({
proxy
:
{
proxy
:
{
'/api'
:
{
'/api'
:
{
// target: 'http://192.168.3.111:8077', // 后端女oms
// target: 'http://192.168.3.111:8077', // 后端女oms
// target: 'http://192.168.3.17:8099', // 狗旺
target
:
'https://test.iuav.shop'
,
target
:
'https://test.iuav.shop'
,
changeOrigin
:
true
,
changeOrigin
:
true
,
rewrite
:
(
path
)
=>
path
.
replace
(
/^
\/
api/
,
''
),
rewrite
:
(
path
)
=>
path
.
replace
(
/^
\/
api/
,
''
),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论