Commit 01cbd249 authored by XieZhiXiong's avatar XieZhiXiong
parents 9bd7f371 4714db4d
......@@ -47,6 +47,11 @@ export interface IDecsParams {
word: string[];
}
export interface IPage {
current: number;
pageSize: number;
}
export interface IProductModule {
productInfoByEdit: GetProductCommodityGetCommodityResponse;
attributeLists: any[];
......@@ -59,6 +64,7 @@ export interface IProductModule {
priceAttributeParams: any[]; // 价格设置的传输数据
productAttributeAndImageParams: any[]; //价格属性包含图片的传输数据
areaOption: any[]; // 省市数据
currentPageInStore: IPage;
setAttributeLists(lists: any[]): void;
setProductName(name: string): void;
......@@ -72,4 +78,5 @@ export interface IProductModule {
setProductAttributeAndImageParams(datas: any[]): void;
setAreaOption(datas: any[]): void;
setProductInfoByEdit(data: GetProductCommodityGetCommodityResponse): void;
setCurrentPageInStore(data: IPage): void;
}
......@@ -32,6 +32,7 @@ const PropertyValue: React.FC<{}> = () => {
const ref = useRef<any>({})
const [selectKey, setSelectKey] = useState(undefined)
const [selectNode, setSelectNode] = useState<any>()
const [innerExpandKeys, setInnerExpandKeys] = useState<any[]>([])
const {
treeStatus,
......@@ -55,8 +56,9 @@ const PropertyValue: React.FC<{}> = () => {
if(beforeKey){ // 展开之前的选择项
setSelectKey(beforeKey)
setInnerExpandKeys([`${prefix}_${beforeKey}`])
treeActions.setExpandedKeys([`${prefix}_${beforeKey}`]) // 拼接不正常的key
console.log(`${prefix}_${beforeKey}`)
console.log(`${prefix}_${beforeKey}`, '展开的key')
}
}, [])
......
......@@ -87,7 +87,7 @@ const SetPrice:React.FC<IProps> = (props) => {
// 获取商品规格列表
const fetchSpecData = (params?: any) => {
PublicApi.getProductChannelCommodityGetCommodityUnitPrice({id: productSelectRowInStore.id + '', source: selectedSource}).then(res => {
PublicApi.getProductChannelCommodityGetCommodityUnitPrice({id: productSelectRowInStore.id + '', source: selectedSource + ''}).then(res => {
const { data } = res
setOriginTableData(data)
if(data.length > 0)
......
......@@ -58,6 +58,12 @@ const AddDirectChannel:React.FC<{}> = (props) => {
params.childMemberRoleName = selectedRole?.children || null
params.commodityMemberList = selectChannel.map(item => ({ memberId: item.memberId, memberName: item.name }))
if(!tableDataInSetPrice.length){
message.error('请选择商品规格!')
setIsDisabledSave(false)
return ;
}
if(params.childMemberRoleName)
PublicApi.postProductChannelCommoditySaveChannelCommodity(params).then(res=>{
setIsDisabledSave(false)
......
......@@ -46,7 +46,7 @@ const AddProducts: React.FC<{}> = (props) => {
clearData,
setProductInfoByEdit,
isAllAttributePic,
productInfoByEdit
productInfoByEdit,
} = ProductStore
useEffect(()=>{
......@@ -256,15 +256,15 @@ const AddProducts: React.FC<{}> = (props) => {
PublicApi.postProductCommoditySaveOrUpdateCommodity(_params).then(res => {
if(res.code === 1000){
setIsEnableCheck(false)
setIsDisableSaveBtn(false)
// setIsDisableSaveBtn(false)
setReponseId(res.data)
}
})
}).then( e => {
setIsDisableSaveBtn(false)
if(e)
if(e){
setIsDisableSaveBtn(false)
message.error(e.message)
}
console.log(e, 'e')
}).catch(error => {
setIsDisableSaveBtn(false)
......
......@@ -128,7 +128,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
_attributeValueArr.push(_tempArr) // 价格属性的属性值数组 用于SKU组合
_temp_attributeValObjArr.push(_tempObjArr)
})
}else if(history.location.query?.id){ // 此时没有属性并且处于编辑状态 取接口返回的数据 [0]? *9.12*
}else if(history.location.query?.id){ // 此时没有属性并且处于编辑状态 取接口返回的数据 [0]? (也有可能编辑情况下切换到无规格的品类)
_attributeNameArr = productInfoByEdit.unitPriceAndPicList[0]?.attributeAndValueList.map(_ => _.customerAttribute.name)
_attributeValueArr = [productInfoByEdit.unitPriceAndPicList.map(item => item.attributeAndValueList.map(_ => _.customerAttributeValue.value))]
_temp_attributeObjArr = productInfoByEdit.unitPriceAndPicList[0]?.attributeAndValueList.map(item => {
......@@ -408,12 +408,10 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
setPriceForm.resetFields()
setLadderPrice(false)
setPlanPrice(v.target.value)
// console.log(v.target.value, 'v')
}
const setPriceOk = () => {
setPriceForm.validateFields().then(v => {
// console.log(v, 'ladder')
setSetPriceModal(false)
const { ladderPrice, ladderRange } = v
let _priceRange = {}
......
......@@ -40,7 +40,13 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
const productAttributeFormRef = useRef()
const [attributeForm] = Form.useForm()
const { ProductStore } = store
const { attributeLists, setProductSelectAttribute, getProductAttributeFormParamsByEdit, productInfoByEdit, clearProductDetailsUnitPriceAndPicListInEdit } = ProductStore
const {
attributeLists,
setProductSelectAttribute,
getProductAttributeFormParamsByEdit,
productInfoByEdit,
clearProductDetailsUnitPriceAndPicListInEdit
} = ProductStore
useEffect(()=>{
onRef(productAttributeFormRef)
......
......@@ -226,7 +226,6 @@ const DirectChannel: React.FC<{}> = () => {
}
const fetchData = (params: any) => {
console.log(params, 'params')
return new Promise((resolve, reject) => {
PublicApi.getProductChannelCommodityGetChannelCommodityList(params).then(res => {
const { data } = res
......
......@@ -184,7 +184,6 @@ const FastModifyPrice: React.FC<{}> = () => {
];
const fetchData = (params: any) => {
console.log(params, filterParams)
return new Promise((resolve, reject) => {
//@ts-ignore
PublicApi.getProductCommodityGetCommodityDetailList({ ...filterParams, ...params, environment: 1 }).then(res => {
......@@ -297,8 +296,10 @@ const FastModifyPrice: React.FC<{}> = () => {
}
const handleHightSearch = (val?: string) => {
console.log(val)
let obj = val ? {...filterParams, name: val} : { ...filterParams }
let _params: any = { ...filterParams }
if(_params.priceType)
_params.priceTypeList = [_params.priceType]
let obj = val ? {..._params, name: val} : { ..._params }
setFilterParams(obj)
ref.current.reload(obj)
}
......
......@@ -20,6 +20,8 @@ import styles from "./index.less"
import { PublicApi } from '@/services/api'
import { GetProductCommodityGetShopResponse } from '@/services'
import { store } from '@/store'
const { Option } = Select;
const { confirm } = Modal;
......@@ -65,6 +67,14 @@ const Products: React.FC<{}> = () => {
const [checkedValues, setCheckedValues] = useState<any>([])
const [currentOptionId, setCurrentOptionId] = useState()
const [isDisabledOKbtn, setIsDisabledOKbtn] = useState<boolean>(false)
const [pageTotal, setPageTotal] = useState<number>() // 表格当前总数
const { ProductStore } = store
const {
currentPageInStore,
setCurrentPageInStore
} = ProductStore
const [currentPage, setCurrentPage] = useState<number>(currentPageInStore.current||1) // 表格当前页
const [currentPageSize, setCurrentPageSize] = useState<number>(currentPageInStore.pageSize||10)
let [isHighSearch, setIsHighSearch] = useState(false)
const [filterParams, setFilterParams] = useState<paramItem>({
......@@ -75,7 +85,7 @@ const Products: React.FC<{}> = () => {
min: null,
max: null,
brandId: 0,
customerCategoryId: 0,
customerCategoryId: 0,
status: null,
statusList: null,
})
......@@ -249,10 +259,14 @@ const Products: React.FC<{}> = () => {
}
const fetchData = (params: any) => {
if(currentPageInStore.current){
params.current = currentPageInStore.current
params.pageSize = currentPageInStore.pageSize
}
return new Promise((resolve, reject) => {
PublicApi.getProductCommodityGetCommodityList({ ...filterParams, ...params}).then(res => {
console.log(res, 'res')
const { data } = res
setPageTotal(data.totalCount)
resolve(data)
})
})
......@@ -365,6 +379,11 @@ const Products: React.FC<{}> = () => {
const [time, setTime] = useState(0); // timer
useEffect(() => {
clearInterval(timeChange)
// 监听路由 清空页码数据
history.listen((location, action) => {
if(location.pathname.indexOf('/commodity/products') === -1)
setCurrentPageInStore({current: null, pageSize: null})
})
}, [])
useEffect(() => {
console.log(modalStep)
......@@ -428,7 +447,7 @@ const Products: React.FC<{}> = () => {
message.error('您还还未创建店铺,请先创建店铺!')
setTimeout(() => {
history.push('/memberCenter/shopAbility/infoManage')
}, 3000)
}, 1000)
}
})
}
......@@ -608,6 +627,18 @@ const Products: React.FC<{}> = () => {
ref.current.reload(obj)
}
const onChangePage = (page, pageSize) => {
setCurrentPageInStore({ current: page, pageSize: pageSize })
setCurrentPage(page)
setCurrentPageSize(pageSize)
}
const onChangePageSize = (current, size) => {
setCurrentPageInStore({ current: 1, pageSize: size })
setCurrentPage(1)
setCurrentPageSize(size)
}
const menuMore = (
<Menu onClick={(e) => handleMenuClick(e)}>
<Menu.Item key="1" icon={<DeleteOutlined />}>
......@@ -619,6 +650,7 @@ const Products: React.FC<{}> = () => {
</Menu>
)
return (
<PageHeaderWrapper>
<Card>
......@@ -626,7 +658,21 @@ const Products: React.FC<{}> = () => {
columns={columns}
currentRef={ref}
rowSelection={rowSelection}
tableProps={{rowKey: 'id'}}
tableProps={{
rowKey: 'id',
pagination: {
onChange: onChangePage,
current: currentPage,
total: pageTotal,
showTotal: total => `共 ${total} 条`,
size: 'small',
defaultPageSize: 10,
showSizeChanger: true,
pageSize: currentPageSize,
onShowSizeChange: onChangePageSize,
showQuickJumper: true
}
}}
fetchTableData={(params: any) => fetchData(params)}
controlRender={
<Row>
......
......@@ -101,7 +101,7 @@ const ModifyDirectChannel:React.FC<{}> = () => {
// 构建规格弹框table 列columns
let col: any = []
let temp: any = []
data[0].attributeAndValueList.map(_item => {
data[0]?.attributeAndValueList.map(_item => {
temp.push({title: _item.customerAttribute.name, dataIndex: [_item.customerAttribute.name, 'value'], key: _item.customerAttribute.name})
})
col.push({
......
......@@ -65,6 +65,7 @@ const AddBrand: React.FC<{}> = () => {
const [responseId, setReponseId] = useState<number>(null)
const [formValues, setFormValues] = useState<any>({})
const [banSomeField, setBanSomeField] = useState<boolean>(false)
const [isDisabledSave, setIsDisabledSave] = useState<boolean>(false)
useEffect(()=>{
const { id } = history.location.query
......@@ -138,6 +139,7 @@ const AddBrand: React.FC<{}> = () => {
delete values.proveUrl.file
}
PublicApi.postProductBrandSaveOrUpdateBrand(values).then(res => {
setIsDisabledSave(true)
setIsEnableCheck(false)
//@ts-ignore
setReponseId(res.data)
......@@ -178,7 +180,7 @@ const AddBrand: React.FC<{}> = () => {
title={history.location.query?.id?'修改品牌':'新建品牌'}
extra={[
<Button key="2" disabled={isEnableCheck} onClick={handleApplyCheck}>直接提交审核</Button>,
<Button icon={<SaveOutlined />} key="1" type="primary" onClick={handleSave}>
<Button icon={<SaveOutlined />} key="1" type="primary" onClick={handleSave} disabled={isDisabledSave}>
保存
</Button>,
]}
......
import {action, computed, observable, runInAction} from 'mobx'
import { IProductModule, IProductSelectAttribute, IBasicFormParam, IPriceAttributeParam, IOtherParam, IDecsParams } from '@/module/productModule'; // mobx要用到的数据类型
import { IProductModule, IProductSelectAttribute, IBasicFormParam, IPriceAttributeParam, IOtherParam, IDecsParams, IPage } from '@/module/productModule'; // mobx要用到的数据类型
class ProductStore implements IProductModule {
@observable public attributeLists: any[] = [];
......@@ -15,6 +15,7 @@ class ProductStore implements IProductModule {
@observable public productInfoByEdit: any;
@observable public productDescription: IDecsParams;
@observable public isAllAttributePic: boolean = true; // 是否所有属性共用
@observable public currentPageInStore: IPage = { current: null, pageSize: null }; // 页码相关
/** 计算操作 **/
// 加工接口返回的数据,用户编辑回显数据
......@@ -168,6 +169,11 @@ class ProductStore implements IProductModule {
this.isAllAttributePic = data
}
@action.bound
public setCurrentPageInStore(data: IPage) {
this.currentPageInStore = data
}
}
......
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