Commit 90a20fef authored by Bill's avatar Bill

fix: 修改首页结算,商品中心跳转附带搜索参数

parent e1b79321
......@@ -24,12 +24,13 @@ const Search = props => {
const justifyAlign = align || 'flex-end';
const changeFilterVisible = () => {
if (state.filterSearch) {
props.form.reset({
// 清除FILTER_PARAMS下所有字段
selector: `*.${FORM_FILTER_PATH}.*`,
});
}
/** 隐藏的时候没必要清除, 隐藏下 提交值默认为undefined, 这里如果对niceForm下做初始值的时候,隐藏了即重置了高级筛选下的字段会把初始值也去掉了 */
// if (state.filterSearch) {
// props.form.reset({
// // 清除FILTER_PARAMS下所有字段
// selector: `*.${FORM_FILTER_PATH}.*`,
// });
// }
setState({
filterSearch: !state.filterSearch,
});
......
......@@ -16,7 +16,7 @@ const useSetSearchValueInTable = () => {
return {}
}
return {
initialValues: cacheData
value: cacheData
}
}, [cacheData])
......@@ -24,8 +24,6 @@ const useSetSearchValueInTable = () => {
setSearchData(null);
}, [])
return {
searchData: cacheData,
formatInitialValue,
......
......@@ -59,7 +59,6 @@ const SettlementList = () => {
...searchParams,
status: searchParams.status || '0',
orderType: searchParams.orderType || '0',
}
const { data } = await PublicApi.getSettleAccountsMemberSettlementPagePayableSettlement(postData);
return data
......
......@@ -22,6 +22,7 @@ import Voucher from '../../components/Voucher';
import ConfirmAccount from '../../components/ConfirmAccount';
import { usePageStatus } from '@/hooks/usePageStatus';
import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable';
import { Moment } from 'moment';
const { RangePicker } = DatePicker;
......@@ -30,8 +31,8 @@ const formActions = createFormActions();
type requestDataType = {
status: number,
orderType: string | number,
startTime: string,
endTime: string,
startTime?: Moment,
endTime?: Moment,
settlementName: string,
payName: string,
settlementNo: number,
......@@ -41,18 +42,21 @@ type requestDataType = {
const SettlementList = () => {
const ref = useRef<any>({})
const { searchData, formatInitialValue } = useSetSearchValueInTable();
const { searchData, formatInitialValue, clear } = useSetSearchValueInTable();
const [files, setFiles] = useState<any>([]);
const { columns, confirmPayInfo, confirmPayVisible, reconciliationInfo, reconciliationVisible, viewVisible, payVoucherInfo, viewModalonCancel, confirmPayOnCancel, reconciliationOnCancel } = useFetchColumns("receiveable")
const fetchListData = async (params: requestDataType) => {
const searchParams = {
...params,
orderType: params.orderType || '0',
status: params.status || '0',
...searchData,
...params,
}
const { data } = await PublicApi.getSettleAccountsMemberSettlementPageReceivableSettlement(searchParams as any);
const postData = {
...searchParams,
status: searchParams.status || '0',
orderType: searchParams.orderType || '0',
}
const { data } = await PublicApi.getSettleAccountsMemberSettlementPageReceivableSettlement(postData as any);
return data
}
......@@ -93,7 +97,7 @@ const SettlementList = () => {
/**
* 搜索
*/
const handleSearch = (values: any) => {
const handleSearch = (values: requestDataType) => {
const format = 'YYYY-MM-DD'
const startTime = values.startTime?.format(format);
const endTime = values.endTime ? values.endTime.endOf("day").format('YYYY-MM-DD HH:mm:ss') : "";
......@@ -129,6 +133,9 @@ const SettlementList = () => {
}}
schema={schema}
onSubmit={handleSearch}
onReset={() => {
clear()
}}
{...formatInitialValue}
/>
}
......
......@@ -27,6 +27,7 @@ import useFetchColumns from '../../hooks/useFetchColumns';
import { STATUS_TEXT } from '@/constants/balance';
import { numFormat, priceFormat } from '@/utils/numberFomat';
import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable';
import { GetSettleAccountsPlatformSettlementPageReceivableSettlementRequest } from '@/services/SettleV2Api';
const formActions = createFormActions();
const { RangePicker } = DatePicker;
......@@ -103,11 +104,14 @@ const AccountReceivable = () => {
const { retColumn } = useIsExistBrokerage(columns, ["brokerage"]);
const fetchListData = async (params) => {
const postData = {
const fetchListData = async (params: GetSettleAccountsPlatformSettlementPageReceivableSettlementRequest) => {
const searchParams = {
...searchData,
...params,
status: params.status || 0,
...searchData
}
const postData = {
...searchParams,
status: searchParams.status || '0',
}
const { data } = await PublicApi.getSettleAccountsPlatformSettlementPageReceivableSettlement(postData);
return data
......
......@@ -25,6 +25,7 @@ import ConfirmAccount from '../../components/ConfirmAccount';
import { COMPLETED, TO_BE_COLLECTED, TO_BE_RECONCILED } from '../../common/constants';
import { STATUS_TEXT } from '@/constants/balance';
import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable';
import { GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementRequest } from '@/services/SettleV2Api';
const formActions = createFormActions();
const Integral: React.FC = () => {
......@@ -44,7 +45,7 @@ const Integral: React.FC = () => {
handleViewPayModal
} = useFetchColumns("receiveable");
const [files, setFiles] = useState([]);
const { searchData, formatInitialValue } = useSetSearchValueInTable();
const { searchData, formatInitialValue, clear } = useSetSearchValueInTable();
const columns = [
{
......@@ -101,11 +102,14 @@ const Integral: React.FC = () => {
}
]
const fetchListData = async (params) => {
const postData = {
...params,
status: params.status || 0,
const fetchListData = async (params: GetSettleAccountsPlatformScoreSettlementPageReceivableSettlementRequest) => {
const searchParams = {
...searchData,
...params,
}
const postData = {
...searchParams,
status: searchParams.status || '0',
}
// /settle/accounts/platform/score/settlement/pageReceivableSettlement
const { data } = await PublicApi.getSettleAccountsPlatformScoreSettlementPageReceivableSettlement(postData);
......@@ -114,7 +118,6 @@ const Integral: React.FC = () => {
/**
* 确认对账
* @param {cancel: function, id: number} cancel 为关闭回调函数
*/
const handleConfirm = async (params: {id: number}) => {
const { code } = await PublicApi.postSettleAccountsPlatformScoreSettlementConfirmAccountComplete({settlementId: params.id})
......@@ -182,8 +185,9 @@ const Integral: React.FC = () => {
schema={schema}
onSubmit={handleSearch}
onReset={() => {
formActions.setFieldValue('startTime', null);
formActions.setFieldValue('endTime', null);
clear()
// formActions.setFieldValue('startTime', null);
// formActions.setFieldValue('endTime', null);
}}
{...formatInitialValue}
/>
......
import React, { useState, useEffect, useRef, ReactNode } from 'react'
import React, { useState, useEffect, useRef, ReactNode, useMemo } from 'react'
import { history } from 'umi'
import { Button, Form, Card, Modal, Result, Progress, Select, Tooltip, Checkbox, Row, Col, Dropdown, Input, Menu, Space, message, InputNumber } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
......@@ -24,6 +24,7 @@ import NiceForm from '@/components/NiceForm'
import { createFormActions, FormEffectHooks } from '@formily/antd'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { searchBrandOptionEffect, searchCustomerCategoryOptionEffect } from './effect'
import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable'
const { Option } = Select;
const { confirm } = Modal;
......@@ -62,6 +63,21 @@ const Products: React.FC<{}> = () => {
const [isDisabledOKbtn, setIsDisabledOKbtn] = useState<boolean>(false)
const [shopId, setShopId] = useState<any>()
/** 带参数查询,给表单带默认值 */
const { searchData, formatInitialValue, clear } = useSetSearchValueInTable();
const formatedFormValue = useMemo(() => {
const value = formatInitialValue?.value || {};
if (value && "statusList" in value) {
return {
value: {
...value,
statusList: +value.statusList
}
}
}
return value
}, [formatInitialValue])
const columns: ColumnType<any>[] = [
{
......@@ -237,8 +253,16 @@ const Products: React.FC<{}> = () => {
}
const fetchData = (params: any) => {
const searchParams = {
...searchData,
...params,
}
const postData = {
...searchParams,
statusList: searchParams?.statusList || '',
}
return new Promise((resolve, reject) => {
PublicApi.getProductCommodityGetCommodityList(params).then(res => {
PublicApi.getProductCommodityGetCommodityList(postData).then(res => {
const { data } = res
resolve(data)
})
......@@ -600,6 +624,10 @@ const Products: React.FC<{}> = () => {
})
}}
schema={productSchema}
{ ...formatedFormValue }
onReset={() => {
clear()
}}
/>
}
/>
......
......@@ -21,7 +21,7 @@ const ADD_REPOSITORIES = '/memberCenter/commodityAbility/repositories/add';
// 3、设置库存:判断当前用户是否有仓位库存管理权限,有则显示设置库存按钮,点击跳转能力中心-商品能力-仓位管理--新增仓位库存
const ProductCenter: React.FC<Iprops> = () => {
const { loading, responseData, isError, ref } = useViewRequest<GetReportMemberHomeGetCommodityTallyResponse, any>(PublicApi.getReportMemberHomeGetCommodityTally, {})
const { loading, responseData, isError, ref, withQueryParams } = useViewRequest<GetReportMemberHomeGetCommodityTallyResponse, any>(PublicApi.getReportMemberHomeGetCommodityTally, {})
const { userAuth, hasAbilityFunc } = useGetAuth();
const hasAbility = hasAbilityFunc('commodityAbility');
......@@ -39,6 +39,30 @@ const ProductCenter: React.FC<Iprops> = () => {
authUrl: ADD_REPOSITORIES
},
], [])
/** @review 就离谱, 搜索状态值拼接到链接上,后端不做交给了前端。坑啊 */
const withParamsList = useMemo(() => {
const status = {
"商品总数": "",
"品牌总数": "",
"待提交审核商品": "statusList=1",
"待上架商品": "statusList=2",
"待提交审核品牌": "status=1",
}
return status
}, [])
const formatDataWithLink = useMemo(() => {
// const newData = [...responseData];
const newData = responseData?.map((_item) => {
return {
..._item,
link: `${_item.link}?${withParamsList[_item.name]}`
}
})
return newData
}, [responseData, withParamsList])
return (
<Layout
hasAuth={hasAbility}
......@@ -70,7 +94,7 @@ const ProductCenter: React.FC<Iprops> = () => {
<span className={styles.rowTitle}>商品</span>
<div className={styles.rowValues}>
{
responseData && responseData.map((item: GetReportMemberHomeGetCommodityTallyResponse[0], key) => {
formatDataWithLink?.map((item: GetReportMemberHomeGetCommodityTallyResponse[0], key) => {
return (
<div className={styles.wrapCol} key={key}>
<div className={styles.colTitle}>{item.name}</div>
......
......@@ -73,6 +73,8 @@ function useViewRequest<T, P>(fn: (postData: P) => Promise<ResponseDataType & {
return filterEmptyList && Object.keys(filterEmptyList).length === 0;
}, [filterEmptyList])
/** 商品中心不适用, 就不直接兼容了 */
const withQueryParams = useCallback((withParamsList: { [key: string]: { [name: string]: string } }) => {
const newData = {...filterEmptyList}
Object.keys(withParamsList).forEach((_item) => {
......
import React, { ReactNode, useRef, useEffect } from 'react'
import React, { ReactNode, useRef, useEffect, useMemo } from 'react'
import { history } from 'umi'
import { Button, Popconfirm, Card, message, Dropdown, Menu, Modal, Space } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
......@@ -19,6 +19,7 @@ import { createFormActions } from '@formily/antd'
import { FORM_FILTER_PATH } from '@/formSchema/const'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import Submit from '@/components/NiceForm/components/Submit'
import useSetSearchValueInTable from '@/hooks/useSetSearchValueInTable'
const { confirm } = Modal
......@@ -26,10 +27,34 @@ const formActions = createFormActions();
const Trademark: React.FC<{}> = () => {
const ref = useRef<any>({})
/** 带参数查询,给表单带默认值 */
const { searchData, formatInitialValue, clear } = useSetSearchValueInTable();
const formatedFormValue = useMemo(() => {
const value = formatInitialValue?.value || {};
if (value && "status" in value) {
return {
value: {
...value,
status: +value.status
}
}
}
return value
}, [formatInitialValue])
const fetchData = (params: any) => {
const searchParams = {
...searchData,
...params,
}
const postData = {
...searchParams,
name: searchParams?.name || '',
status: searchParams?.status || 0,
}
return new Promise((resolve, reject) => {
PublicApi.getProductBrandGetBrandList({ ...params, name: params.name || '', status: params.status || 0 }).then(res => {
PublicApi.getProductBrandGetBrandList(postData).then(res => {
const { data } = res
resolve(data)
})
......@@ -286,6 +311,10 @@ const Trademark: React.FC<{}> = () => {
}
}}
onSubmit={values => ref.current.reload(values)}
onReset={() => {
clear()
}}
{...formatedFormValue}
/>
}
......
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