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

fix: 采购合同下单查询用户配置的流程接口切换

parent 55c72382
......@@ -253,6 +253,10 @@ export const formSchema: ISchema = {
required: true,
"x-rules": [
{
required: true,
message: '请填写详细地址',
},
{
limitByte: true,
maxByte: 100,
},
......
......@@ -96,42 +96,6 @@ export const AddressPop = (props) => {
</Space> : children
}
export const filterProductDataById = (data, targetData) => {
return targetData.reduce(async (prev: any[], next) => {
const { logistics } = next
// 由于自选商品和进货单商品字段不一致,需手动同步
next.brand = next.brand || next.brandName
next.category = next.category || next.customerCategoryName
next.unit = next.unit || next.unitName
next.productName = next.productName || next.name
if (logistics.deliveryType === 2 && logistics.sendAddress) {
const { code, data } = await PublicApi.getLogisticsShipperAddressGet({
id: logistics.sendAddress
}, { ttl: 60 * 1000, useCache: true })
logistics.render = data
} else {
logistics.render = DELIVERY_TYPE[logistics.deliveryType]
}
// 配送方式外置, 用于接口字段冗余
next.deliveryType = logistics.deliveryType
// id 存在集合中, 采用target中的数据, 否则采用data中的数据
const findResult = data.find(v => v.id === next.id)
// 由于迭代时,会出现promise的 已完成状态, 需转换一下,实现异步转同步化
if (!Array.isArray(prev)) {
prev = await prev
}
if (findResult) {
// 已经选中过这一项, 则需要采用原有的商品列表
prev.push(findResult)
} else {
prev.push(next)
}
return prev
}, [])
}
const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
const { type = 'checkbox', schemaAction, confirmModal, currentRef, sectionProps, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = sectionProps
......@@ -146,19 +110,55 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
}
}, [])
const addMaterialProcessField = (value, origin) => {
if(Array.isArray(value)) {
let processData = value.map(v => {
let temp: any = {};
temp.id = v.id;
temp.code = v.materielNo;
temp.name = v.materielName;
temp.type = v.type;
temp.category = v.category;
temp.brand = v.brand;
temp.unit = v.unit;
temp.relevanceProductId = v.associatedDataId;
temp.relevanceProductName = v.associatedGoods;
temp.relevanceProductNo = v.associatedMaterielNo;
temp.relevanceProductType = v.associatedType;
temp.relevanceProductCategory = v.associatedCategory;
temp.relevanceProductBrand = v.associatedBrand;
temp.price = v.price;
temp.inventory = v.bidCount;
temp.taxInclusive = v.isHasTax;
temp.taxRate = v.taxRate;
// @ 配送方式 默认物流
temp.logistics = 1
return temp
})
let originIds = origin.map(item => item.id)
processData.map(item => {
if(!originIds.includes(item.id)) {
origin.push(item)
}
})
return origin
}
}
const handleConfirm = async () => {
// 判断所选择的商品是否属于同一个工作流
console.log(rowSelectionCtl, 'rowSelectionCtl')
// @ts-ignore
const res = await PublicApi.postOrderIsWorkFlow({
memberId: rowSelectionCtl.selectRow[0].memberId,
memberRoleId: rowSelectionCtl.selectRow[0].memberRoleId,
productIds: rowSelectionCtl.selectedRowKeys,
memberId: schemaAction.getFieldValue('supplyMembersId'),
memberRoleId: schemaAction.getFieldValue('supplyMembersRoleId'),
productIds: rowSelectionCtl.selectRow.map(item => item.associatedDataId),
orderModel: schemaAction.getFieldValue('orderModel')
}, { ctlType: 'none' })
if (res.code === 1000) {
const productData = schemaAction.getFieldValue('orderProductRequests')
schemaAction.setFieldValue('orderProductRequests', await filterProductDataById(productData, rowSelectionCtl.selectRow))
schemaAction.setFieldValue('orderProductRequests', addMaterialProcessField(rowSelectionCtl.selectRow, productData))
confirmModal && confirmModal()
setVisible(false)
} else {
......@@ -172,7 +172,7 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
...values,
contractId,
}
return fetchOrderApi.getProductList(params)
return fetchOrderApi.getContractPurchaseMaterielList(params)
}
......@@ -186,7 +186,7 @@ const MaterialModalTable:React.FC<MaterialModalTableProps> = (props) => {
cancel={() => setVisible(false)}
fetchTableData={fetchMaterialList}
rowSelection={rowSelection}
resetModal={{destroyOnClose: true, forceRender: true}}
resetModal={{destroyOnClose: true}}
modalType='none'
tableProps={{
rowKey: 'id',
......
......@@ -25,12 +25,12 @@ export const PriceComp = (props) => {
</div>
}
// @采购合同下单 字段转换
/** 采购合同下单 字段转换 */
export const procurementProcessField = (value) => {
value.orderProductRequests = value.orderProductRequests.map(item => {
// @todo 查询商品对应的最小起订数
// const { data, code } = await PublicApi.getProductCommodityGetCommodity({id: item.relevanceProductId})
delete item.id
// delete item.id
return {
...item,
productId: item.relevanceProductId,
......
......@@ -74,6 +74,7 @@ export const useModelTypeChange = (callback) => {
const utils = useLinkageUtils()
// 下单模式发生改变时
FormEffectHooks.onFieldValueChange$('orderModel').subscribe(state => {
console.log(state.value, 'efffect')
callback(state)
})
}
......
......@@ -36,6 +36,7 @@ import { fetchOrderApi } from './apis'
import MergeOrderModalTable from './components/mergeOrderModalTable'
import { useMaterialTable } from './model/useMaterialTable'
import ContractModalTable from './components/contractModalTable'
import MaterialModalTable from './components/materialModalTable'
export interface PurchaseOrderDetailProps {}
......@@ -164,7 +165,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 订单商品
const { productAddButton, productRef, productColumns, productComponents, ...sectionProps } = useProductTable(addSchemaAction, mergeRef)
// 订单物料
const { materialAddButton, materialRef, materialColumns, materialComponents, ...restProps } = useMaterialTable(addSchemaAction)
const { materialAddButton, materialRef, materialColumns, materialComponents, ...surplusProps } = useMaterialTable(addSchemaAction)
let timerSignature = null
// 页面进入时, 当前所处的下单模式
......@@ -618,29 +619,35 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
value === OrderModalType.CHANNEL_SPOT_MANUAL_ORDER ||
(value === OrderModalType.CONSOLIDATED_ORDER && quotationOrderValue)
) {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
prefix: editable ? productAddButton : '',
}
})
setTimeout(() => {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
prefix: editable ? productAddButton : '',
}
})
})
} else if (
value === OrderModalType.PURCHASE_ENQUIRY_CONTRACT_ORDER ||
value === OrderModalType.PURCHASE_BIDDING_CONTRACT_ORDER ||
value === OrderModalType.PURCHASE_TENDER_CONTRACT_ORDER
) {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
prefix: editable ? materialAddButton : '',
}
})
setTimeout(() => {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
prefix: editable ? materialAddButton : '',
}
})
}, 300)
} else {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
prefix: '',
}
setTimeout(() => {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
...productState.props["x-component-props"],
prefix: '',
}
})
})
}
// 选择某种类型时, 需显示对应的订单类型
......@@ -724,7 +731,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
<ContractModalTable currentRef={contractOrderRef} schemaAction={addSchemaAction}/>
{/* @todo 选择采购物料 */}
{/* <MaterialModalTable currentRef={materialRef} schemaAtion={addSchemaAction} /> */}
<MaterialModalTable currentRef={materialRef} schemaAction={addSchemaAction} sectionProps={surplusProps} />
......
......@@ -61,7 +61,7 @@ const SelectProcesss = (props: ISchemaFieldComponentProps) => {
const { value, mutators, editable } = props
useEffect(() => {
PublicApi.getOrderTradingRulesTransactionProcessList().then(res => {
PublicApi.getManagePurchaseProcesByMember().then(res => {
setFieldState({
dataSource: res.data,
showMore
......
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