提交 43cd8d88 作者: 龚洪江

功能:服务分页,修复租赁商品修改400问题

上级 ef83c6bc
#请求接口地址 #请求接口地址
#VITE_REQUEST_BASE_URL='https://iuav.mmcuav.cn' VITE_REQUEST_BASE_URL='https://iuav.mmcuav.cn'
VITE_REQUEST_BASE_URL='https://test.iuav.shop' #VITE_REQUEST_BASE_URL='https://test.iuav.shop'
#VITE_REQUEST_BASE_URL='/api' #VITE_REQUEST_BASE_URL='/api'
#旧版接口地址 #旧版接口地址
#VITE_REQUEST_BASE_URL='https://iuav.mmcuav.cn' #VITE_REQUEST_BASE_URL='https://iuav.mmcuav.cn'
......
...@@ -186,7 +186,11 @@ const GoodsAddOrEditOrDetail = () => { ...@@ -186,7 +186,11 @@ const GoodsAddOrEditOrDetail = () => {
...values.subImg.map((v: any) => ({ ...values.subImg.map((v: any) => ({
imgType: 1, imgType: 1,
imgUrl: v.url, imgUrl: v.url,
id: goodsDetail ? goodsDetail.images.some((i) => i.id === v.id) : undefined, id: goodsDetail
? goodsDetail.images.some((i) => i.id === v.id)
? v.id
: undefined
: undefined,
})), })),
); );
} }
......
import React, { FC, useEffect, useState } from 'react'; import React, { FC, useEffect, useRef, useState } from 'react';
import { useNavigate } from 'react-router-dom'; import { useNavigate, useSearchParams } from 'react-router-dom';
import { searchColumns } from '~/components/search-box'; import { searchColumns } from '~/components/search-box';
import SearchBox from '~/components/search-box'; import SearchBox from '~/components/search-box';
import AddOrEditServiceModal from './components/addOrEditServiceModal'; import AddOrEditServiceModal from './components/addOrEditServiceModal';
...@@ -16,6 +16,7 @@ import { CategoryManageAPI, MallManageAPI } from '~/api'; ...@@ -16,6 +16,7 @@ import { CategoryManageAPI, MallManageAPI } from '~/api';
import { InterDataType, InterReqType, PaginationProps } from '~/api/interface'; import { InterDataType, InterReqType, PaginationProps } from '~/api/interface';
import { categoryListType } from '~/api/interface/categoryManage'; import { categoryListType } from '~/api/interface/categoryManage';
import { serviceType } from '~/api/interface/mallManageType'; import { serviceType } from '~/api/interface/mallManageType';
import qs from 'query-string';
//分类返回类型 //分类返回类型
type categoryType = InterDataType<categoryListType>['list']; type categoryType = InterDataType<categoryListType>['list'];
...@@ -25,7 +26,9 @@ type serviceListType = InterDataType<serviceType>['list']; ...@@ -25,7 +26,9 @@ type serviceListType = InterDataType<serviceType>['list'];
type serviceParametersType = Omit<InterReqType<serviceType>, 'pageSize' | 'pageNo'>; type serviceParametersType = Omit<InterReqType<serviceType>, 'pageSize' | 'pageNo'>;
const ServiceList: FC<any> = () => { const ServiceList: FC<any> = () => {
const searchRef = useRef<any>();
const navigate = useNavigate(); const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
const tabList = [ const tabList = [
{ {
key: '1', key: '1',
...@@ -156,7 +159,11 @@ const ServiceList: FC<any> = () => { ...@@ -156,7 +159,11 @@ const ServiceList: FC<any> = () => {
const onTabChange = (key: string) => { const onTabChange = (key: string) => {
pagination.pageNo = 1; pagination.pageNo = 1;
pagination.pageSize = 10;
setQuery({ ...query, displayState: key === '1' ? undefined : key === '2' ? 0 : 1 }); setQuery({ ...query, displayState: key === '1' ? undefined : key === '2' ? 0 : 1 });
setSearchParams(
qs.stringify({ ...query, displayState: key === '1' ? 'all' : key === '2' ? 0 : 1 }),
);
setActiveTabKey(key); setActiveTabKey(key);
getServiceList({ ...query, displayState: key === '1' ? undefined : key === '2' ? 0 : 1 }); getServiceList({ ...query, displayState: key === '1' ? undefined : key === '2' ? 0 : 1 });
}; };
...@@ -267,6 +274,14 @@ const ServiceList: FC<any> = () => { ...@@ -267,6 +274,14 @@ const ServiceList: FC<any> = () => {
const paginationChange = (pageNo: number, pageSize: number) => { const paginationChange = (pageNo: number, pageSize: number) => {
pagination.pageNo = pageNo; pagination.pageNo = pageNo;
pagination.pageSize = pageSize; pagination.pageSize = pageSize;
setSearchParams(
qs.stringify({
...query,
pageNo,
pageSize,
displayState: query.displayState === undefined ? 'all' : query.displayState,
}),
);
getServiceList(query); getServiceList(query);
}; };
// 表格多选事件 // 表格多选事件
...@@ -276,6 +291,15 @@ const ServiceList: FC<any> = () => { ...@@ -276,6 +291,15 @@ const ServiceList: FC<any> = () => {
//筛选 //筛选
const searchSuccess = (data: any) => { const searchSuccess = (data: any) => {
pagination.pageNo = 1; pagination.pageNo = 1;
pagination.pageSize = 10;
setSearchParams(
qs.stringify({
...data,
pageNo: pagination.pageNo,
pageSize: pagination.pageSize,
displayState: query.displayState === undefined ? 'all' : query.displayState,
}),
);
setQuery(data); setQuery(data);
getServiceList(data); getServiceList(data);
}; };
...@@ -288,7 +312,39 @@ const ServiceList: FC<any> = () => { ...@@ -288,7 +312,39 @@ const ServiceList: FC<any> = () => {
setPreviewShow(false); setPreviewShow(false);
}; };
useEffect(() => { useEffect(() => {
getServiceList(); pagination.pageNo = Number(searchParams.get('pageNo') || 1);
pagination.pageSize = Number(searchParams.get('pageSize') || 10);
searchRef.current.getForm().setFieldsValue({
serviceName: searchParams.get('serviceName') || undefined,
applicationId: searchParams.get('applicationId')
? Number(searchParams.get('applicationId'))
: undefined,
industryId: searchParams.get('industryId')
? Number(searchParams.get('industryId'))
: undefined,
});
const queryObj = {
serviceName: searchParams.get('serviceName') || undefined,
applicationId: searchParams.get('applicationId')
? Number(searchParams.get('applicationId'))
: undefined,
industryId: searchParams.get('industryId')
? Number(searchParams.get('industryId'))
: undefined,
displayState:
searchParams.get('displayState') === 'all' || searchParams.get('displayState') === null
? undefined
: Number(searchParams.get('displayState')),
};
setQuery(queryObj);
setActiveTabKey(
searchParams.get('displayState') === 'all' || searchParams.get('displayState') === null
? '1'
: Number(searchParams.get('displayState')) === 0
? '2'
: '3',
);
getServiceList(queryObj);
getIndustryCategoryList(); getIndustryCategoryList();
getApplicationCategoryList(); getApplicationCategoryList();
}, []); }, []);
...@@ -307,6 +363,7 @@ const ServiceList: FC<any> = () => { ...@@ -307,6 +363,7 @@ const ServiceList: FC<any> = () => {
</Button> </Button>
} }
searchData={searchSuccess} searchData={searchSuccess}
baseRef={searchRef}
/> />
<Card tabList={tabList} activeTabKey={activeTabKey} onTabChange={onTabChange}> <Card tabList={tabList} activeTabKey={activeTabKey} onTabChange={onTabChange}>
<div className='header-operate' style={{ marginBottom: '10px' }}> <div className='header-operate' style={{ marginBottom: '10px' }}>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论