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

fix: 处理采购合同下单修改异常

parent f4bba90e
......@@ -68,7 +68,7 @@ const callForBidsSearch: React.FC<{}> = () => {
}
const handleWithdraw = () => {
history.push('memberCenter/procurementAbility/callForBids/remarkBidCommittee/add')
history.push('/memberCenter/procurementAbility/callForBids/remarkBidCommittee/add')
}
// 复制 id存入本地存储跳转至新增页
......
......@@ -59,14 +59,14 @@ export const MaterialTableCell:React.FC<MaterialTableCellProps> = ({
// select的change
const change = async (va, op, idx) => {
console.log(va, op, idx)
// try {
// const values = await form.validateFields();
// values[idx] = op['label']
// values['unitId'] = op['value']
// handleSave({ ...record, ...values });
// } catch (errInfo) {
// console.log('Save failed:', errInfo);
// }
try {
const values = await form.validateFields();
values[idx] = op['label']
values['logistics'] = op['value']
handleSave({ ...record, ...values });
} catch (errInfo) {
console.log('Save failed:', errInfo);
}
}
const chooseFormItem = (type, v) => {
......
......@@ -25,6 +25,26 @@ export const PriceComp = (props) => {
</div>
}
/** 修改采购合同下单 回显字段转换 */
export const procurementRenderField = (_orderProductRequests) => {
return _orderProductRequests.map(item => {
return {
...item,
relevanceProductId: item.productId,
relevanceProductName: item.productName,
relevanceProductBrand: item.brand,
relevanceProductCategory: item.category,
logistics: item.logistics.deliveryType,
id: item.materialId,
code: item.materialCode,
name: item.materialName,
type: item.materialType,
category: item.materialCategory,
brand: item.materialBrand,
}
})
}
/** 采购合同下单 字段转换 */
export const procurementProcessField = (value) => {
value.orderProductRequests = value.orderProductRequests.map(item => {
......
......@@ -74,7 +74,6 @@ export const useModelTypeChange = (callback) => {
const utils = useLinkageUtils()
// 下单模式发生改变时
FormEffectHooks.onFieldValueChange$('orderModel').subscribe(state => {
console.log(state.value, 'efffect')
callback(state)
})
}
......
......@@ -9,7 +9,7 @@ import { SaveOutlined, LinkOutlined, PlusOutlined, CodeSandboxCircleFilled, Ques
import NiceForm from '@/components/NiceForm'
import { orderDetailSchema, orderAddSchema, mergeAllSchemas, payInfo, orderMaterial, orderProduct } from './schema'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay, useOrderUpdateChangeOther } from './effects'
import { orderTypeLabel, orderCombination, orderTypeLabelMap, procurementProcessField } from './constant'
import { orderTypeLabel, orderCombination, orderTypeLabelMap, procurementProcessField, procurementRenderField } from './constant'
import { OrderModalType } from '@/constants'
import ProductModalTable from './components/productModalTable'
import MemberModalTable from './components/memberModalTable'
......@@ -179,6 +179,8 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
const { data } = res
setInitFormValue({
...data,
// 判断是否合同下单
orderProductRequests: data.orderModel > 30 ? procurementRenderField(data.orderProductRequests) : data.orderProductRequests,
deliveryTime: formatTimeString(data.deliveryTime)
})
setFormLoading(false)
......@@ -203,6 +205,10 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}, [])
useEffect(() => {
console.log(initFormValue, 'init')
}, [initFormValue])
const handleSubmit = async (value) => {
let _orderProductRequests = JSON.parse(JSON.stringify(value.orderProductRequests))
let processEnum = value['processEnum']
......@@ -361,7 +367,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
...params,
ordeProducts: addSchemaAction.getFieldValue("ordeProducts")
})
} else if(params.orderModel > 30) {
} else if(params.orderModel > 30) { // 判断是否合同下单
let _params = procurementProcessField(params)
let _ = _params.quotationNo
_params.quotationNo = _params.contractNo
......@@ -456,6 +462,31 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
productSumPrice,
setProductSumPrice
}
// 显示采购下单合同栏目
const showContractColumn = () => {
// 移除支付信息栏 订单商品栏 添加订单物料
setInitFormSchema(() => {
let origin = {...initFormSchema}
delete origin.properties.NO_SUBMIT_TABS.properties.payInfo
delete origin.properties.NO_SUBMIT_TABS.properties.orderProduct
origin.properties.NO_SUBMIT_TABS.properties.orderMaterial = orderMaterial
return origin
})
}
// 移除采购合同下单栏目 恢复原有
const removeContractColumn = () => {
// 移除订单物料 添加支付信息栏 订单商品栏
setInitFormSchema(() => {
let origin = {...initFormSchema}
origin.properties.NO_SUBMIT_TABS.properties.payInfo = payInfo
origin.properties.NO_SUBMIT_TABS.properties.orderProduct = orderProduct
delete origin.properties.NO_SUBMIT_TABS.properties.orderMaterial
return origin
})
}
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
......@@ -552,19 +583,13 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
state.props.enum = enumList.filter(item => item.type === 4 && item.environment === 1)
})
}
// 判断合同下单
if(value > 30) {
ctx.setFieldState('quotationNo', state => {
state.props.title = orderTypeLabelMap[value]
state.visible = true
})
// 移除支付信息栏 订单商品栏 添加订单物料
setInitFormSchema(() => {
let origin = {...initFormSchema}
delete origin.properties.NO_SUBMIT_TABS.properties.payInfo
delete origin.properties.NO_SUBMIT_TABS.properties.orderProduct
origin.properties.NO_SUBMIT_TABS.properties.orderMaterial = orderMaterial
return origin
})
showContractColumn()
} else {
ctx.setFieldState('quotationNo', state => {
state.props.title = '对应报价单号'
......@@ -572,14 +597,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
ctx.setFieldState('payInfo', state => {
state.visible = true
})
// 移除订单物料 添加支付信息栏 订单商品栏
setInitFormSchema(() => {
let origin = {...initFormSchema}
origin.properties.NO_SUBMIT_TABS.properties.payInfo = payInfo
origin.properties.NO_SUBMIT_TABS.properties.orderProduct = orderProduct
delete origin.properties.NO_SUBMIT_TABS.properties.orderMaterial
return origin
})
removeContractColumn()
}
}
......@@ -634,6 +652,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
value === OrderModalType.PURCHASE_BIDDING_CONTRACT_ORDER ||
value === OrderModalType.PURCHASE_TENDER_CONTRACT_ORDER
) {
// 判断合同下单
setTimeout(() => {
addSchemaAction.setFieldState('orderProductRequests', productState => {
productState.props["x-component-props"] = {
......@@ -642,6 +661,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}
})
}, 300)
showContractColumn()
} else {
setTimeout(() => {
addSchemaAction.setFieldState('orderProductRequests', productState => {
......
......@@ -29,10 +29,11 @@ const AddRule:React.FC<{}> = (props) => {
const formSubmit = async (values) => {
setIsDisabled(true)
const params = omit(values, ['state']) // 移除不需要的字段
params.processEnum = params.processEnumId
addSchemaAction.getFieldState('processEnumId', state => {
const process = state.dataSource.filter(item => item.id === params.processEnumId)[0]
params.type = process.type
params.processEnum = process.processEnum
params.processEnumId = process.id
})
let res: any = {}
......
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