Commit 0e5a9bd4 authored by 前端-许佳敏's avatar 前端-许佳敏

进货单下单

parent 4d18cc22
......@@ -153,9 +153,9 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
// 路由切换时, 自动回到顶部
document.body.scrollTop = document.documentElement.scrollTop = 0
if (isDev) {
return;
}
// if (isDev) {
// return;
// }
if (whiteLists.includes(location.pathname)) {
return
......
......@@ -122,7 +122,6 @@ const BasicLayout: React.FC<BasicLayoutProps> = (props) => {
setOpenKeys([])
}
}, [currentRouter, location.pathname, collapsed])
console.log(getPageTitle({ pathname: location.pathname }), "getPageTitle({ pathname: location.pathname })")
return (
<ProLayout
title=""
......
......@@ -7,6 +7,7 @@ import {
import OuterSider from './OuterSide'
import { GlobalConfig } from '@/global/config'
import styles from '../styles/MenuSlider.less'
import { getRouters } from '@/utils/auth';
const { Sider } = Layout
const { SubMenu } = Menu;
......@@ -33,9 +34,11 @@ const MenuSlider: React.FC<MenuSliderProps> = (props) => {
const getMenus = (menuArray: any, hasChildren: boolean = false) => {
if (!!menuArray && menuArray.length > 0) {
return menuArray.map((item: any) => {
if (item.hideInMenu) {
// 不存在路由表内或者 需要隐藏
if (item.hideInMenu || !getRouters().includes(item.path)) {
return null
}
if (item.children) {
return (
<SubMenu
......
......@@ -8,6 +8,7 @@ import SelectLang from './SelectLang';
import Location from './Location';
import Roles from './Roles';
import styles from '../styles/RightContent.less';
import { Link } from 'umi';
// export type SiderTheme = 'light' | 'dark';
// export interface GlobalHeaderRightProps extends Partial<ConnectProps> {
......@@ -26,6 +27,7 @@ const GlobalHeaderRight: React.SFC<{}> = (props) => {
return (
<div className={className}>
<Link to='/' style={{color: 'rgba(0, 0, 0, 0.85)'}}>返回商城</Link>
<Roles />
<Location />
<SelectLang />
......
......@@ -83,7 +83,7 @@ export const AddressPop = (props) => {
</Space> : children
}
const filterProductDataById = (data, targetData) => {
export const filterProductDataById = (data, targetData) => {
return targetData.reduce(async (prev: any[], next) => {
const { logistics } = next
if (logistics.deliveryType === 2) {
......
......@@ -6,6 +6,7 @@ import { history } from 'umi';
import { fetchOrderApi } from '../apis';
import { useUpdate } from '@umijs/hooks';
import { PublicApi } from '@/services/api';
import { filterProductDataById } from '../components/productModalTable'
// 异步填充表格字段
const asyncPadDataForProduct = async (ctx: ISchemaFormActions | ISchemaFormAsyncActions, productValue: any) => {
......@@ -110,10 +111,13 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
// 表单初始化时,对应操作
export const useOrderFormInitEffect = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const { orderModel = 0 } = history.location.query
FormEffectHooks.onFormMount$().subscribe(() => {
// query中存在orderModel参数, 则是从其他页面跳转而来,需禁用其余query选项
const typeEnums = parseInt(orderModel)
const { modelType = 0, spam_id } = history.location.query
FormEffectHooks.onFormMount$().subscribe(async () => {
// query中存在modelType参数, 则是从其他页面跳转而来,需禁用其余query选项
// 商城跳转过来的数据
const initValue = JSON.parse(window.sessionStorage.getItem(spam_id))
const typeEnums = parseInt(modelType)
ctx.setFieldState('orderModel', state => {
state.props.enum = state.props.enum.map(v => {
const assign: any = Object.assign({}, v)
......@@ -124,6 +128,27 @@ export const useOrderFormInitEffect = (ctx: ISchemaFormActions | ISchemaFormAsyn
}).sort((prev, next) => prev.disabled ? prev.value : next.value - prev.value)
})
// 从商城跳转, 需回显数据
if (initValue) {
ctx.setFieldValue('supplyMembersId', initValue.supplyMembersId)
ctx.setFieldValue('supplyMembersName', initValue.supplyMembersName)
ctx.setFieldValue('orderProductRequests', await filterProductDataById([], initValue.orderList[0].orderList.map(v => {
return {
...v,
brandName: v.brand,
customerCategoryName: v.category,
unitPrice: v.priceRange.reduce((prev, next) => {
prev[next.range] = next.price
return prev
}, {}),
isMemberPrice: !!v.memberDiscount,
purchaseCount: v.count,
price: v.count * v.unitPrice,
}
})))
}
// 写入收货地址数据
useProductAddress(ctx)
})
......
......@@ -45,11 +45,6 @@ const RowStyle = styled(props => <Row style={{marginTop: 12}} justify='end' {...
const addSchemaAction = createFormActions()
const orderTitle = {
0: '新增订单',
1: '审核订单',
}
// 总计金额联动框
export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
// @todo 由于缺乏商品字段, 目前选用假数据
......@@ -59,7 +54,6 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', props => {
const sum = data.reduce((prev, next) => prev + (next.price || 0), 0)
const [freePrice, setFreePrice] = useState<number>(0)
useEffect(() => {
if (sum + freePrice) {
form.notify('sumPrice', sum + freePrice)
......@@ -113,13 +107,29 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
const [btnLoading, setBtnLoading] = useState(false)
const update = useUpdate()
const [productSumPrice, setProductSumPrice] = useState<number>(0)
const [initFormValue, setInitFormValue] = useState<any>(null)
const { pageStatus, id, page_type = '0', modelType, spam_id } = usePageStatus()
const [initFormValue, setInitFormValue] = useState<any>(() => {
let resultState = {}
if (modelType) {
resultState = {
orderModel: parseInt(modelType)
}
}
// 订单数据
if (spam_id) {
const item = JSON.parse(window.sessionStorage.getItem(spam_id))
if (item) {
console.log(item)
}
}
return resultState
})
const [paymentColumns, paymentComponents, paymentSave] = usePaymentInfo(addSchemaAction)
const { productAddButton, productRef, productColumns, productComponents, ...sectionProps } = useProductTable(addSchemaAction)
// 页面进入时, 当前所处的下单模式
const { pageStatus, id, page_type = '0' } = usePageStatus()
useEffect(() => {
if (id) {
......@@ -172,7 +182,9 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}
}
if (fnResult.code === 1000) {
history.goBack()
// 跳转至待新增列表
window.sessionStorage.removeItem(spam_id)
history.replace('/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder')
}
setBtnLoading(false)
} catch (error) {
......
......@@ -269,7 +269,7 @@ const CommonOrderDetail: React.FC<CommonOrderDetailProps> = (props) => {
{/* 提交时触发的弹窗集合 */}
<ModalForm
modalTitle='单据审核'
modalTitle='提示'
currentRef={approvedRef}
confirm={handleConfirmApproved}
actions={approvedActions}
......
......@@ -24,7 +24,7 @@ export const setRouters = (routers: any[]) => {
window.sessionStorage.setItem('rt', JSON.stringify(routers))
}
export const getRouters = () => {
export const getRouters = (): string[] => {
try {
const sessionRt = window.sessionStorage.getItem('rt')
return sessionRt ? JSON.parse(sessionRt) : []
......
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