Commit f8caf3a4 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 对接新增物流单

parent 0efdc615
...@@ -178,45 +178,18 @@ export const addOrderModalSchema: ISchema = { ...@@ -178,45 +178,18 @@ export const addOrderModalSchema: ISchema = {
}, },
}, },
properties: { properties: {
customerCategoryId: { category: {
type: 'string', type: 'string',
'x-component': 'CustomCategorySearch',
'x-component-props': { 'x-component-props': {
placeholder: intl.formatMessage({ id: 'components.shangpinpinlei' }), placeholder: intl.formatMessage({ id: 'components.shangpinpinlei' }),
showSearch: true,
notFoundContent: null,
style: { width: '174px' },
dataoption: [],
fieldNames: { label: 'title', value: 'id', children: 'children' },
}, },
}, },
brandId: { brand: {
type: 'string', type: 'string',
'x-component': 'CustomInputSearch',
'x-component-props': { 'x-component-props': {
placeholder: intl.formatMessage({ id: 'components.shangpinpinpai' }), placeholder: intl.formatMessage({ id: 'components.shangpinpinpai' }),
showSearch: true,
showArrow: true,
defaultActiveFirstOption: false,
filterOption: false,
notFoundContent: null,
style: { width: '174px' },
searchValue: null,
dataoption: [],
}, },
}, },
// brandId: {
// type: 'string',
// "x-component": 'SearchSelect',
// "x-component-props": {
// placeholder: '请选择品牌',
// fetchSearch: getProductSelectGetMemberBrand,
// style: {
// width: 160
// },
// queryParams: {},
// }
// },
submit: { submit: {
"x-component": 'Submit', "x-component": 'Submit',
"x-mega-props": { "x-mega-props": {
......
...@@ -145,9 +145,9 @@ const AddProducts: React.FC<{}> = (props) => { ...@@ -145,9 +145,9 @@ const AddProducts: React.FC<{}> = (props) => {
// 切换模板 // 切换模板
const renderTemplate = () => { const renderTemplate = () => {
// if(currentTemplateName === 'science') // if(currentTemplateName === 'science')
// return <ProductDescFormDefualt /> // return <ProductDescFormDefualt />
// else if(currentTemplateName === 'cloud') // else if(currentTemplateName === 'cloud')
// return <ProductDescFormCloud /> // return <ProductDescFormCloud />
return <ProductDescFormYang /> return <ProductDescFormYang />
} }
......
...@@ -318,7 +318,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -318,7 +318,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
// 生成表格dataSource // 生成表格dataSource
let combineArray = SKUCombine(_attributeValueArr) let combineArray = SKUCombine(_attributeValueArr)
console.log(combineArray, 'combineArray') // console.log(combineArray, 'combineArray')
setCombineAttributeArray(combineArray) setCombineAttributeArray(combineArray)
setAttributeObjArr(_temp_attributeObjArr) setAttributeObjArr(_temp_attributeObjArr)
setAttributeValObjArr(_temp_attributeValObjArr) setAttributeValObjArr(_temp_attributeValObjArr)
...@@ -412,7 +412,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -412,7 +412,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
_tableDataSource.map(item => item[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })] = {}) _tableDataSource.map(item => item[intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.unitPrice' })] = {})
} }
} }
console.log(_tableDataSource, '_tableDataSource') // console.log(_tableDataSource, '_tableDataSource')
setTableDataSource(productName ? _tableDataSource : []) // 通过商品名称来判断是否显示表格数据 setTableDataSource(productName ? _tableDataSource : []) // 通过商品名称来判断是否显示表格数据
constructedPrarams() constructedPrarams()
...@@ -478,7 +478,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => { ...@@ -478,7 +478,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
id: _tableDataSource[0] && _tableDataSource[0][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.id' })], id: _tableDataSource[0] && _tableDataSource[0][intl.formatMessage({ id: 'commodity.products.addProductsItem.priceAttributeForm.id' })],
}) /*带上货品id 带上单价*/ /* code1 end */ }) /*带上货品id 带上单价*/ /* code1 end */
setPriceAttributeParams(_paramsArray) setPriceAttributeParams(_paramsArray)
console.log(_paramsArray, '_paramsArray') // console.log(_paramsArray, '_paramsArray')
} }
/** /**
......
...@@ -25,7 +25,10 @@ const ISalePlaceholder = [ ...@@ -25,7 +25,10 @@ const ISalePlaceholder = [
getIntl().formatMessage({ id: 'commodity.products.addProductsItem.productDescFormCloud.ISalePlaceholder.5' }), getIntl().formatMessage({ id: 'commodity.products.addProductsItem.productDescFormCloud.ISalePlaceholder.5' }),
] ]
const ProductDescFormCloud: React.FC<{}> = (props) => { /**
* YunXianCai式商品模板
*/
const ProductDescFormCloud: React.FC<{}> = () => {
const intl = useIntl(); const intl = useIntl();
const { token } = getAuth() || {} const { token } = getAuth() || {}
// 初始商品特色4个input值和3*4个image值 // 初始商品特色4个input值和3*4个image值
......
...@@ -19,6 +19,9 @@ import { postContractContractSignSaleSignContractCreate } from '@/services/Contr ...@@ -19,6 +19,9 @@ import { postContractContractSignSaleSignContractCreate } from '@/services/Contr
const schemaActions = createFormActions() const schemaActions = createFormActions()
/**
* 商品 默认模板
*/
const ProductDescFormDefualt: React.FC<{}> = () => { const ProductDescFormDefualt: React.FC<{}> = () => {
const intl = useIntl(); const intl = useIntl();
const [fileImageList, setFileImageList] = useState<any>([]) const [fileImageList, setFileImageList] = useState<any>([])
......
...@@ -22,7 +22,10 @@ const schemaActions = createFormActions() ...@@ -22,7 +22,10 @@ const schemaActions = createFormActions()
const imagesTypeKeyValue = ['', 'descriptionImages', 'certificationImages', 'reportImages'] const imagesTypeKeyValue = ['', 'descriptionImages', 'certificationImages', 'reportImages']
const ProductDescFormDefualt: React.FC<{}> = () => { /**
* YangLian式商品模板
*/
const ProductDescFormYang: React.FC<{}> = () => {
const intl = useIntl(); const intl = useIntl();
const [fileImageList, setFileImageList] = useState<any>({ const [fileImageList, setFileImageList] = useState<any>({
descriptionImages: [], // 商品描述 descriptionImages: [], // 商品描述
...@@ -430,4 +433,4 @@ const ProductDescFormDefualt: React.FC<{}> = () => { ...@@ -430,4 +433,4 @@ const ProductDescFormDefualt: React.FC<{}> = () => {
</div>) </div>)
} }
export default observer(ProductDescFormDefualt) export default observer(ProductDescFormYang)
import { getOrderBuyerCreatePageItems, getOrderBuyerPageItems, GetOrderBuyerPageItemsResponse, getOrderBuyerTakePageItems, getOrderBuyerValidatePageItems, getOrderVendorPageItems, getOrderVendorTakePageItems, getOrderVendorValidatePageItems } from '@/services/OrderNewV2Api' import {
getOrderBuyerCreatePageItems,
getOrderBuyerPageItems,
GetOrderBuyerPageItemsResponse,
getOrderBuyerTakePageItems,
getOrderBuyerValidatePageItems,
getOrderVendorPageItems,
getOrderVendorTakePageItems,
getOrderVendorValidatePageItems,
getOrderVendorOrderTypeAll,
getOrderBuyerOrderTypeAll
} from '@/services/OrderNewV2Api'
import { getProductSelectGetSelectCategory } from '@/services/ProductV2Api' import { getProductSelectGetSelectCategory } from '@/services/ProductV2Api'
import { getPurchaseRequisitionFindInnerStatusEnum } from '@/services/PurchaseV2Api' import { getPurchaseRequisitionFindInnerStatusEnum } from '@/services/PurchaseV2Api'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
...@@ -151,3 +162,35 @@ export const getSaleOrderReadyDistributionPageSelectOption = () => { ...@@ -151,3 +162,35 @@ export const getSaleOrderReadyDistributionPageSelectOption = () => {
return state return state
} }
/** 销售订单 通用 订单类型下拉框列表 */
export const getSaleOrderPublicUsePageSelectOption = () => {
const [state, setstate] = useState<any>([])
useEffect(() => {
getOrderVendorOrderTypeAll({}).then(res => {
const { code, data } = res
if (code === 1000) {
setstate(data)
}
})
}, [])
return state
}
/** 采购订单 通用 订单类型下拉框列表 */
export const getPurchaseOrderPublicUsePageSelectOption = () => {
const [state, setstate] = useState<any>([])
useEffect(() => {
getOrderBuyerOrderTypeAll({}).then(res => {
const { code, data } = res
if (code === 1000) {
setstate(data)
}
})
}, [])
return state
}
import { getProductCommodityCommonGetCommodityListByBuyer } from "@/services/ProductV2Api" import { getOrderVendorLogisticsProductPage } from "@/services/OrderNewV2Api"
export const fetchOrderApi = { export const fetchOrderApi = {
/** 弹窗获取商品列表 */ /** 弹窗获取 发货单 商品明细 */
async getProductList(params) { async getProductList(params) {
const { data } = await getProductCommodityCommonGetCommodityListByBuyer(params, { useCache: true, ttl: 10 * 1000 }) const { data } = await getOrderVendorLogisticsProductPage(params, { useCache: true, ttl: 10 * 1000 })
return data return data
}, },
......
import React, { useEffect } from 'react' import React, { useEffect } from 'react'
import ModalTable, { ModalTableProps } from '@/components/ModalTable' import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { fetchOrderApi } from '../../apis' import { fetchOrderApi } from '../../apis'
import { FormEffectHooks, ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd' import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { DELIVERY_TYPE, OrderModalType } from '@/constants/order'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch' import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import { addOrderModalSchema } from '@/components/ModalTable/schema' import { addOrderModalSchema } from '@/components/ModalTable/schema'
...@@ -10,11 +9,9 @@ import Search from '@/components/NiceForm/components/Search' ...@@ -10,11 +9,9 @@ import Search from '@/components/NiceForm/components/Search'
import SearchSelect from '@/components/NiceForm/components/SearchSelect'; import SearchSelect from '@/components/NiceForm/components/SearchSelect';
import Submit from '@/components/NiceForm/components/Submit'; import Submit from '@/components/NiceForm/components/Submit';
import DateSelect from '@/components/NiceForm/components/DateSelect'; import DateSelect from '@/components/NiceForm/components/DateSelect';
import { searchBrandOptionEffect, searchCustomerCategoryOptionEffect } from '../../effects'
import CustomCategorySearch from '@/components/NiceForm/components/CustomCategorySearch' import CustomCategorySearch from '@/components/NiceForm/components/CustomCategorySearch'
import CustomInputSearch from '@/components/NiceForm/components/CustomInputSearch' import CustomInputSearch from '@/components/NiceForm/components/CustomInputSearch'
import { getLogisticsShipperAddressGet } from '@/services/LogisticsV2Api' import { getIntl, history } from 'umi'
import { getIntl } from 'umi'
export interface ProductModalTableProps extends ModalTableProps { export interface ProductModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox', type?: 'radio' | 'checkbox',
...@@ -27,9 +24,9 @@ export interface ProductModalTableProps extends ModalTableProps { ...@@ -27,9 +24,9 @@ export interface ProductModalTableProps extends ModalTableProps {
export const productColumns: any[] = [ export const productColumns: any[] = [
{ {
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.id'}), title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.id'}),
dataIndex: 'id', dataIndex: 'productId',
align: 'center', align: 'center',
key: 'id', key: 'productId',
}, },
{ {
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.name'}), title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.name'}),
...@@ -39,62 +36,33 @@ export const productColumns: any[] = [ ...@@ -39,62 +36,33 @@ export const productColumns: any[] = [
}, },
{ {
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.customerCategoryName'}), title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.customerCategoryName'}),
dataIndex: 'customerCategoryName', dataIndex: 'category',
align: 'center', align: 'center',
key: 'customerCategoryName', key: 'category',
}, },
{ {
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.brandName'}), title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.brandName'}),
dataIndex: 'brandName', dataIndex: 'brand',
align: 'center', align: 'center',
key: 'brandName', key: 'brand',
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.unitName'}),
dataIndex: 'unitName',
align: 'center',
key: 'unitName'
},
{
title: getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.stockCount'}),
dataIndex: 'stockCount',
align: 'center',
key: 'stockCount'
}, },
] ]
// 下单类型->商城类型映射
const orderProductShopTypeMaps = {
[OrderModalType.PURCHASE_ORDER]: 1,
[OrderModalType.CHANNEL_DIRECT_PURCHASE_ORDER]: 3,
[OrderModalType.CHANNEL_EXISTING_PURCHASE_ORDER]: 4
}
export const filterProductDataById = (data, targetData) => { export const filterProductDataById = (data, targetData) => {
return targetData.reduce(async (prev: any[], next) => { return targetData.reduce(async (prev: any[], next) => {
const { logistics } = next // 由于自选发货单商品和物流单单商品字段不一致,需手动同步
// 由于自选商品和进货单商品字段不一致,需手动同步
next.id = next.id || next.productId
next.productId = next.id || next.productId
next.brand = next.brand || next.brandName next.brand = next.brand || next.brandName
next.category = next.category || next.customerCategoryName next.category = next.category || next.customerCategoryName
next.unit = next.unit || next.unitName next.unit = next.unit || next.unitName
next.productName = next.productName || next.name next.productName = next.productName || next.name
next.deliverType = next.logistics.sendAddress // 保证和详情编辑字段一致 next.amount = next.quantity || next.amount
next.weight = next.weight || null
if (logistics.deliveryType === 2 && logistics.sendAddress) {
const { code, data } = await getLogisticsShipperAddressGet({
id: logistics.sendAddress
}, { ttl: 60 * 1000, useCache: true })
logistics.render = {...data, deliveryType: logistics.deliveryType}
} else {
logistics.render = DELIVERY_TYPE[logistics.deliveryType]
}
// 配送方式外置, 用于接口字段冗余
next.deliveryType = logistics.deliveryType
// id 存在集合中, 采用target中的数据, 否则采用data中的数据 // id 存在集合中, 采用target中的数据, 否则采用data中的数据
const findResult = data.find(v => v.id === next.id) const findResult = data.find(v => v.productId === next.productId)
// 由于迭代时,会出现promise的 已完成状态, 需转换一下,实现异步转同步化 // 由于迭代时,会出现promise的 已完成状态, 需转换一下,实现异步转同步化
if (!Array.isArray(prev)) { if (!Array.isArray(prev)) {
...@@ -126,29 +94,16 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -126,29 +94,16 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
}, []) }, [])
const handleConfirmProduct = async () => { const handleConfirmProduct = async () => {
const newData = rowSelectionCtl.selectRow.map(v => { const newData = [...rowSelectionCtl.selectRow]
v.orderMode = schemaAction.getFieldValue('orderMode') schemaAction.setFieldValue('detailList', await filterProductDataById([], newData))
v.shopId = schemaAction.getFieldValue('shopId')
v.buyerMemberId = schemaAction.getFieldValue('buyerMemberId')
v.buyerRoleId = schemaAction.getFieldValue('buyerRoleId')
return v
})
schemaAction.setFieldValue('products', await filterProductDataById([], newData))
confirmModal && confirmModal() confirmModal && confirmModal()
setVisible(false) setVisible(false)
} }
const fetchProductList = (values) => { const fetchProductList = (values) => {
const modelType = schemaAction.getFieldValue('orderMode')
const buyerMembersId = schemaAction.getFieldValue('buyerMemberId')
const shopId = schemaAction.getFieldValue('shopId')
const params = { const params = {
...values, ...values,
shopType: orderProductShopTypeMaps[modelType], orderId: history.location.query.id
environment: 1,
memberId: buyerMembersId,
priceTypeList: [1],
shopId: schemaAction.getFieldValue('shopId')
} }
return fetchOrderApi.getProductList(params) return fetchOrderApi.getProductList(params)
} }
...@@ -156,7 +111,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -156,7 +111,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
return ( return (
<ModalTable <ModalTable
modalTitle={getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.title'})} modalTitle={getIntl().formatMessage({id: 'purchaseOrder.orderCollect.productModalTable.title'})}
width={900} width={900}
columns={productColumns} columns={productColumns}
visible={visible} visible={visible}
...@@ -167,11 +122,11 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -167,11 +122,11 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
resetModal={{destroyOnClose: true, forceRender: true}} resetModal={{destroyOnClose: true, forceRender: true}}
modalType='none' modalType='none'
tableProps={{ tableProps={{
rowKey: 'id', rowKey: 'productId',
onRow: (record) => ({ onRow: (record) => ({
onClick: () => { onClick: () => {
rowSelectionCtl.appendSelectRow(record); rowSelectionCtl.appendSelectRow(record);
rowSelectionCtl.appendSelectRowKeys(record.id); rowSelectionCtl.appendSelectRowKeys(record.productId);
}, },
}) })
}} }}
...@@ -186,12 +141,6 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -186,12 +141,6 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
'name', 'name',
FORM_FILTER_PATH, FORM_FILTER_PATH,
); );
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(() => {
searchCustomerCategoryOptionEffect(schemaAction, actions, 'customerCategoryId')
})
FormEffectHooks.onFieldChange$('brandId').subscribe(() => {
searchBrandOptionEffect(schemaAction, actions, 'brandId')
})
} }
} }
}} }}
......
...@@ -22,7 +22,8 @@ export const PriceComp = (props) => { ...@@ -22,7 +22,8 @@ export const PriceComp = (props) => {
/**新增物流单 初始值转换 */ /**新增物流单 初始值转换 */
export const procurmentRenderInit = (initValue: any) => { export const procurmentRenderInit = (initValue: any) => {
return { return {
shipmentOrderId: initValue.deliveryNo, // shipmentOrderId: initValue.deliveryNo,
shipmentOrderCode: initValue.deliveryNo,
relevanceOrderId: initValue.orderId, relevanceOrderId: initValue.orderId,
relevanceOrderCode: initValue.orderNo, relevanceOrderCode: initValue.orderNo,
memberName: initValue.buyerMemberName, memberName: initValue.buyerMemberName,
......
import { FormEffectHooks, ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'; import { FormEffectHooks, ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { getProductCustomerGetMemberCustomerCategoryTree, getProductSelectGetMemberBrand } from '@/services/ProductV2Api';
export const useMaterialTableChangeForAmount = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, update) => { export const useDetailTableChangeForAmount = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, update) => {
FormEffectHooks.onFieldValueChange$('detailList').subscribe(state => { FormEffectHooks.onFieldValueChange$('detailList').subscribe(() => {
// 强制渲染一次, 用于统计总数 // 强制渲染一次, 用于统计总数
update() update()
}) })
} }
/**
* 高级筛选schema中用于获取供应商 商品品类Effect
* @param ctx 外部表单action
* @param mctx 模态框表单action
* @param fieldName 字段名称
*/
export const searchCustomerCategoryOptionEffect = (ctx: any, mctx: any, fieldName: string) => {
const params: any = {}
params['memberId'] = ctx.getFieldValue('vendorMemberId')
params['memberRoleId'] = ctx.getFieldValue('vendorRoleId')
mctx.getFieldState(fieldName, state => {
// params['name'] = state.props['x-component-props'].searchValue
getProductCustomerGetMemberCustomerCategoryTree(params).then(res => {
mctx.setFieldState(fieldName, state => {
state.props['x-component-props'].dataoption = res.data
})
})
})
}
/**
* 高级筛选schema中用于获取供应商 商品品牌Effect
* @param ctx 外部表单action
* @param mctx 模态框表单action
* @param fieldName 字段名称
*/
export const searchBrandOptionEffect = (ctx: any, mctx: any, fieldName: string) => {
const params: any = {}
params['memberId'] = ctx.getFieldValue('vendorMemberId')
params['memberRoleId'] = ctx.getFieldValue('vendorRoleId')
mctx.getFieldState(fieldName, state => {
params['name'] = state.props['x-component-props'].searchValue
getProductSelectGetMemberBrand(params).then(res => {
mctx.setFieldState(fieldName, state => {
state.props['x-component-props'].dataoption = res.data
})
})
})
}
...@@ -6,8 +6,8 @@ import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd ...@@ -6,8 +6,8 @@ import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd
import { SaveOutlined } from '@ant-design/icons' import { SaveOutlined } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm' import NiceForm from '@/components/NiceForm'
import { increaseSchema } from './schema' import { increaseSchema } from './schema'
import { useMaterialTableChangeForAmount } from './effects' import { useDetailTableChangeForAmount } from './effects'
import { procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant' import { procurementProcessField, procurmentRenderInit } from './constant'
import { useUpdate } from '@umijs/hooks' import { useUpdate } from '@umijs/hooks'
import { help } from '../../common' import { help } from '../../common'
import styled from 'styled-components' import styled from 'styled-components'
...@@ -17,7 +17,7 @@ import { FormDetailContext } from '@/formSchema/context' ...@@ -17,7 +17,7 @@ import { FormDetailContext } from '@/formSchema/context'
import { useProductTable } from './model/useProductTable' import { useProductTable } from './model/useProductTable'
import { useFormDetail } from '@/formSchema/effects/useFormDetail' import { useFormDetail } from '@/formSchema/effects/useFormDetail'
import ProductModalTable from './components/productModalTable' import ProductModalTable from './components/productModalTable'
import { getOrderVendorCreateLogisticsDetail, getOrderVendorSellDeliveryDetail } from '@/services/OrderNewV2Api' import { getOrderVendorCreateLogisticsDetail } from '@/services/OrderNewV2Api'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect' import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
import { getLogisticsCompanyPage, getLogisticsShipperAddressPage,postLogisticsOrderWaitSubmitAdd } from '@/services/LogisticsV2Api' import { getLogisticsCompanyPage, getLogisticsShipperAddressPage,postLogisticsOrderWaitSubmitAdd } from '@/services/LogisticsV2Api'
import addressText from '../../components/addressText' import addressText from '../../components/addressText'
...@@ -42,7 +42,7 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', () => { ...@@ -42,7 +42,7 @@ export const MoneyTotalBox = registerVirtualBox('moneyTotalBox', () => {
const intl = useIntl() const intl = useIntl()
const { form } = useFormSpy({ selector: [['onFieldValueChange', 'detailList']], reducer: v => v }) const { form } = useFormSpy({ selector: [['onFieldValueChange', 'detailList']], reducer: v => v })
const data = form.getFieldValue('detailList') const data = form.getFieldValue('detailList')
console.log(data, 'data')
const totalCarton = data.reduce((prev, next) => (prev*1000 + (next.carton || 0)*1000)/1000, 0) const totalCarton = data.reduce((prev, next) => (prev*1000 + (next.carton || 0)*1000)/1000, 0)
const totalWeight = data.reduce((prev, next) => (prev*1000 + (next.weight || 0)*1000)/1000, 0) const totalWeight = data.reduce((prev, next) => (prev*1000 + (next.weight || 0)*1000)/1000, 0)
const totalVolume = data.reduce((prev, next) => (prev*1000 + (next.volume || 0)*1000)/1000, 0) const totalVolume = data.reduce((prev, next) => (prev*1000 + (next.volume || 0)*1000)/1000, 0)
...@@ -77,13 +77,9 @@ const AddLogisticsOrder:React.FC<{}> = () => { ...@@ -77,13 +77,9 @@ const AddLogisticsOrder:React.FC<{}> = () => {
useEffect(() => { useEffect(() => {
if (id) { if (id) {
setFormLoading(true) setFormLoading(true)
getOrderVendorCreateLogisticsDetail({ orderId: '5870' }).then(res => { getOrderVendorCreateLogisticsDetail({ orderId: id }).then(res => {
const { data } = res const { data } = res
setInitFormValue(() => procurmentRenderInit(data)) setInitFormValue(() => procurmentRenderInit(data))
// const _orderProductRequests = procurementRenderField(data)
// setTimeout(() => {
// addSchemaAction.setFieldValue('detailList', _orderProductRequests)
// }, 1000)
setFormLoading(false) setFormLoading(false)
}) })
getSettleAccountsPlatformConfigGetSettlementWay({memberId: memberId + '', roleId: memberRoleId + ''}).then(res => { getSettleAccountsPlatformConfigGetSettlementWay({memberId: memberId + '', roleId: memberRoleId + ''}).then(res => {
...@@ -97,7 +93,6 @@ const AddLogisticsOrder:React.FC<{}> = () => { ...@@ -97,7 +93,6 @@ const AddLogisticsOrder:React.FC<{}> = () => {
const handleSubmit = async (value) => { const handleSubmit = async (value) => {
try { try {
// let fnResult = null
// 新增物流单/编辑物流单 // 新增物流单/编辑物流单
const params = { ...value } const params = { ...value }
console.log(value) console.log(value)
...@@ -107,11 +102,6 @@ const AddLogisticsOrder:React.FC<{}> = () => { ...@@ -107,11 +102,6 @@ const AddLogisticsOrder:React.FC<{}> = () => {
setBtnLoading(true) setBtnLoading(true)
const _params = procurementProcessField(params) const _params = procurementProcessField(params)
// if(id) {
// fnResult = await postPurchaseRequisitionUpdate({..._params, id})
// } else {
// fnResult = await postPurchaseRequisitionCreate(_params)
// }
const fnResult = await postLogisticsOrderWaitSubmitAdd(_params) const fnResult = await postLogisticsOrderWaitSubmitAdd(_params)
if (fnResult.code === 1000) { if (fnResult.code === 1000) {
setTimeout(() => { setTimeout(() => {
...@@ -145,10 +135,6 @@ const AddLogisticsOrder:React.FC<{}> = () => { ...@@ -145,10 +135,6 @@ const AddLogisticsOrder:React.FC<{}> = () => {
} }
const renderTitle = () => { const renderTitle = () => {
// intl.formatMessage({ id: 'saleOrder.xiugaiwuliudan', defaultMessage: '修改物流单' })
// if(preview) {
// return intl.formatMessage({ id: 'saleOrder.chakanwuliudan', defaultMessage: '查看物流单' })
// }
return intl.formatMessage({ id: 'saleOrder.xinzengwuliudan', defaultMessage: '新增物流单' }) return intl.formatMessage({ id: 'saleOrder.xinzengwuliudan', defaultMessage: '新增物流单' })
} }
...@@ -176,7 +162,7 @@ const AddLogisticsOrder:React.FC<{}> = () => { ...@@ -176,7 +162,7 @@ const AddLogisticsOrder:React.FC<{}> = () => {
effects={($, ctx) => { effects={($, ctx) => {
$('onFormMount').subscribe(() => { }) $('onFormMount').subscribe(() => { })
// 物流明细信息的改动 渲染总额 // 物流明细信息的改动 渲染总额
useMaterialTableChangeForAmount(ctx, update) useDetailTableChangeForAmount(ctx, update)
// 注入表单完成进度 // 注入表单完成进度
formContext.useAttachmentChangeForContext(ctx) formContext.useAttachmentChangeForContext(ctx)
......
import { useRef, useState } from 'react' import { useRef, useState } from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'; import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { Button, message } from 'antd'; import { Button } from 'antd';
import { PriceComp, productInfoColumns } from '../constant'; import { PriceComp, productInfoColumns } from '../constant';
import ProductTableCell, { ProductEditableRow } from '../components/productTableCell'; import ProductTableCell, { ProductEditableRow } from '../components/productTableCell';
import { useModalTable } from './useModalTable'; import { useModalTable } from './useModalTable';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'; import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { useIntl } from 'umi'; import { useIntl } from 'umi';
// 对象按key排序(运用于商城传过来的阶梯价格排序)
export const sortByKey = (params) => {
let keys = Object.keys(params).sort((x,y)=> parseInt(x) - parseInt(y));
let newParams = {};
keys.forEach((key) => {
newParams[key] = params[key];
});
return newParams;
}
export const getUnitPriceTotal = (record) => {
const { pageStatus } = usePageStatus()
const purchaseCount = Number(record['purchaseCount']) || 0
// fix 当没有传递unitPrice字段时 自动容错, 单价显示为0
// fix 编辑订单取price
record.unitPrice = pageStatus === PageStatus.EDIT ? record.price : record.unitPrice || record.price || 0
if (typeof record.unitPrice === 'number') {
return record.isMemberPrice ?
Number((record.unitPrice * purchaseCount * record.memberPrice).toFixed(2))
:
Number((record.unitPrice * purchaseCount).toFixed(2))
}
if(record.unitPrice) {
record.unitPrice = sortByKey(record.unitPrice)
}
// fix 当没有传递unitPrice字段时 但有price字段时 补全unitPrice字段
if(record.price && JSON.stringify(record.unitPrice) === "{}") {
record.unitPrice = {'0-0': record.price}
}
// fix 当有unitPrice字段时 没有price字段时 补全price字段
if(!record?.price && JSON.stringify(record.unitPrice) !== "{}") {
if(Object.keys(record.unitPrice)[0] === '0-0') record.price = record.unitPrice['0-0']
}
let unitPrice = 0
Object.entries(record.unitPrice).forEach(([key, value]) => {
const [min, max] = key.split('-').map(v => Number(v))
if (min === 0 && max === 0) {
unitPrice = Number(value)
return false
}
if ((purchaseCount >= min && purchaseCount <= max) || (purchaseCount > max)) {
// 处于该区间或者大于该区间
unitPrice = Number(value)
return false
}
})
// 考虑会员折扣
let memberPrice = record.memberPrice
if(record.isMemberPrice) {
return Number((unitPrice * purchaseCount * memberPrice).toFixed(2))
} else {
return Number((unitPrice * purchaseCount).toFixed(2))
}
}
/** /**
* @param ctx schemaAction * @param ctx schemaAction
*/ */
export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => { export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const { pageStatus, preview = null } = usePageStatus() const { pageStatus, preview = null } = usePageStatus()
const productRef = useRef<any>({}) const productRef = useRef<any>({})
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type: 'checkbox'}) const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type: 'checkbox', customKey: 'productId'})
const intl = useIntl() const intl = useIntl()
const handleDelete = (record) => { const handleDelete = (record) => {
const newData = [...ctx.getFieldValue('detailList')] const newData = [...ctx.getFieldValue('detailList')]
// 删除formvalue // 删除formvalue
...@@ -82,47 +27,26 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction ...@@ -82,47 +27,26 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
rowSelectionCtl.setSelectedRowKeys(newData.map(v => v.id)) rowSelectionCtl.setSelectedRowKeys(newData.map(v => v.id))
ctx.setFieldValue('detailList', newData) ctx.setFieldValue('detailList', newData)
// 商品行数变动 清空之前的支付信息
if (pageStatus === PageStatus.ADD) {
ctx.setFieldValue('payments', [])
}
} }
const [productColumns, setProductColumns] = useState(() => { const [productColumns, setProductColumns] = useState(() => {
// if (pageStatus === PageStatus.ADD) { // 渲染操作
// 渲染操作 productInfoColumns[productInfoColumns.length - 1].render = (text, record) => <Button type='link' onClick={() => handleDelete(record)}>{intl.formatMessage({id: 'saleOrder.delete'})}</Button>
productInfoColumns[productInfoColumns.length - 1].render = (text, record) => <Button type='link' onClick={() => handleDelete(record)}>{intl.formatMessage({id: 'saleOrder.delete'})}</Button>
// 渲染单价
productInfoColumns[5].render = (t, r) => {
return r.price ? <span style={{color: 'red'}}>{r.price}</span> : <PriceComp priceSection={r.unitPrice}/>
}
// 渲染商品ID
productInfoColumns[0].render = (t, r) => {
return r.id
}
// } else { // 渲染单价
// // 渲染单价 productInfoColumns[5].render = (t, r) => {
// productInfoColumns[5].render = (t, r) => <span style={{color: 'red'}}>¥ {r.price}</span> return r.price ? <span style={{color: 'red'}}>{r.price}</span> : <PriceComp priceSection={r.unitPrice}/>
}
// // 渲染商品ID // 渲染商品ID
// productInfoColumns[0].render = (t, r) => r.productId productInfoColumns[0].render = (t, r) => {
return r.id
// return [...productInfoColumns].slice(0, productInfoColumns.length - 1) }
// }
return productInfoColumns return productInfoColumns
}) })
const handleShowProduct = () => { const handleShowProduct = () => {
const buyerMemberId = ctx.getFieldValue('buyerMemberId') productRef.current.setVisible(true)
const shopId = ctx.getFieldValue('shopId')
if (buyerMemberId && shopId) {
productRef.current.setVisible(true)
} else {
message.error(intl.formatMessage({id: 'purchaseOrder.orderCollect.model.message'}))
}
} }
const productAddButton = !preview && <Button onClick={handleShowProduct} block type='default' style={{margin: '24px auto'}}>{intl.formatMessage({ id: 'saleOrder.xuanzeshangpin', defaultMessage: '选择商品' })}</Button> const productAddButton = !preview && <Button onClick={handleShowProduct} block type='default' style={{margin: '24px auto'}}>{intl.formatMessage({ id: 'saleOrder.xuanzeshangpin', defaultMessage: '选择商品' })}</Button>
...@@ -144,8 +68,6 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction ...@@ -144,8 +68,6 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
const newData = [...ctx.getFieldValue('detailList')]; const newData = [...ctx.getFieldValue('detailList')];
const index = newData.findIndex(item => row.id === item.id); const index = newData.findIndex(item => row.id === item.id);
const item = newData[index]; const item = newData[index];
row['money'] = getUnitPriceTotal(row)
row['productId'] = row.commodityId
newData.splice(index, 1, { newData.splice(index, 1, {
...item, ...item,
...row, ...row,
......
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import { getSaleOrderReadyDistributionPageSelectOption } from '@/pages/transaction/effect'; import { getSaleOrderPublicUsePageSelectOption } from '@/pages/transaction/effect';
import { useIntl } from 'umi'; import { useIntl } from 'umi';
export const tableListSchema: any = () => { export const tableListSchema: any = () => {
const intl = useIntl() const intl = useIntl()
const data = getSaleOrderReadyDistributionPageSelectOption() const data = getSaleOrderPublicUsePageSelectOption()
if(data) { if(data) {
return { return {
......
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