Commit dd7275d7 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 对接新增商品发货周期和新增属性值功能

parent 8fec28f5
......@@ -64,6 +64,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
setProductName,
setSelectCategoryId,
setSelectBrandId,
setSendCycle,
} = ProductStore
useEffect(() => {
......@@ -147,11 +148,13 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
setShowCategory(data?.type)
setAttributeLists(data?.customerAttributeList)
setSelectCategoryId(seletCategoryId)
setSendCycle(data?.sendCycle || 0)
})
}
else
else {
setShowCategory(null)
}
}
const onCommodityAreaChange = (value: any, selected: any) => {
let areaParams: AreaParams = {
......
......@@ -33,7 +33,7 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
const [banCarriageType, setBanCarriageType] = useState(false)
const [template, setTemplate] = useState(false) // 是否必填运费模板
const { productInfoByEdit, selectCategoryId, productPriceType } = ProductStore
const { productInfoByEdit, selectCategoryId, productPriceType, sendCycle } = ProductStore
useEffect(() => {
//传入ref给父级
......@@ -85,6 +85,8 @@ const LogisticsForm: React.FC<Iprops> = (props) => {
}
}, [productPriceType])
useEffect(() => { logisticsForm.setFieldsValue({ sendCycle: sendCycle }) }, [sendCycle])
const changeDeliveryType = (e) => {
console.log(e)
setDeliveryType(e.target.value)
......
......@@ -45,7 +45,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
const [addVisible, setAddVisible] = useState<boolean>(false)
const [loading, setLoading] = useState<boolean>(false)
const currentRow = useRef<any>()
const [dataSource, setDataSource] = useState<any>([...attributesData])
const [dataSource, setDataSource] = useState<any>([])
const [newValue, setNewValue] = useState<string>()
useEffect(() => {
......@@ -58,6 +58,10 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
}, [])
useEffect(() => {
setDataSource(() => [...attributesData])
}, [attributesData])
useEffect(() => {
// 属性变动 表明品类品牌变动 清空页面全局参数组合和store的选中属性 重置表单 (只对新增有效)
if (history.location.query?.id) {
// 编辑第一次执行不清空,之后的变动需要清空
......@@ -153,7 +157,6 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
}
const addAtttributeValue = (record) => {
console.log(record)
currentRow.current = record
setAddVisible(true)
addForm.setFieldsValue({'name': record['name'], isEnable: true, id: record['id']})
......@@ -173,16 +176,14 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
if(code === 1000) {
const _dataSource = dataSource.map((item) => {
if(item.id === currentRow.current.id) {
// @todo 调用后台新增属性值接口 成功后把返回的id写入属性值 目前随机数生成
item.customerAttributeValueList.push({
...item.customerAttributeValueList[0],
id: parseInt(Math.random()*10000+''),
id: data,
...values,
})
}
return item
})
console.log(_dataSource)
setDataSource([..._dataSource])
setAddVisible(false)
setLoading(false)
......@@ -208,18 +209,16 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
value: newValue
}).then(({code, data}) => {
if(code === 1000) {
// @todo 调用后台新增属性值接口 成功后把返回的id写入属性值 目前随机数生成
const _dataSource = dataSource.map((item, index) => {
if(item.id === record.id) {
item.customerAttributeValueList.push({
...item.customerAttributeValueList[0],
id: parseInt(Math.random()*10000+''),
id: data,
value: newValue,
})
}
return item
})
console.log(_dataSource)
setDataSource([..._dataSource])
setNewValue('')
}
......
......@@ -31,6 +31,7 @@ class ProductStore implements IProductModule {
@observable public tabClickItem: any[] = []; // tab标签页点击项
@observable public productPriceType: any = null; // 商品价格类型
@observable public isRecombination: boolean = false; // 编辑时 是否重新属性组合
@observable public sendCycle: number; // 品类发货周期
/** 计算操作 **/
// 加工接口返回的数据,用户编辑回显数据
......@@ -234,6 +235,11 @@ class ProductStore implements IProductModule {
this.isRecombination = data
}
@action.bound
public setSendCycle(data: number) {
this.sendCycle = data
}
}
export default ProductStore
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment