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