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

fix: 处理采购/销售发货单校验和翻译问题

parent ad51cd9d
......@@ -30,7 +30,7 @@ export const useFormDetail = () => {
/**
* 收集表单完成度逻辑
* 若需要统计表单有效字段完成度,需要把此函数注入到NiceForm的effects里面
* @param ctx
* @param ctx FormActions
*/
const useAttachmentChangeForContext = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
FormEffectHooks.onFormMount$().subscribe(() => {
......
......@@ -573,6 +573,9 @@ export default {
'saleOrder.productTableCell.validator1': 'x must be entered',
'saleOrder.productTableCell.validator2': 'Only one decimal digit is reserved for the value',
'saleOrder.productTableCell.validator3': 'The value is reserved for three decimal places only',
'saleOrder.qingwanshanwuliudan': 'Please improve the detailed data of logistics order',
'saleOrder.qingwanshanfahuodan': 'Please improve the detailed data of invoice',
'saleOrder.shouhuoshuliangjin': 'The quantity received is limited to three decimal places only',
// Requisitions
......
......@@ -571,6 +571,9 @@ export default {
'saleOrder.productTableCell.validator1': 'x는 반드시',
'saleOrder.productTableCell.validator2': '값은 소수점 한 자리만 남는다',
'saleOrder.productTableCell.validator3': '값은 세 자리 소수만 남는다',
'saleOrder.qingwanshanwuliudan': '물류 명세서 데이터를 완벽히 하세요',
'saleOrder.qingwanshanfahuodan': '인보이스 명세 데이터를 보완해 주세요',
'saleOrder.shouhuoshuliangjin': '상품을 받을 수 있는 수량은 세 자리 소수로만 제한한다',
// 请购单
......
......@@ -370,7 +370,7 @@ export default {
'purchaseOrder.danjuzhaiyao': '单据摘要',
'purchaseOrder.baocun': '保存',
'purchaseOrder.shanchu': '删除',
'purchaseOrder.qingwanshancaigou': '请完善采购收货单商品数据',
'purchaseOrder.qingwanshancaigou': '请完善采购收货单明细数据',
'saleOrder.daochuerweima': '导出二维码',
'saleOrder.tijiaoshenhe': '提交审核',
......@@ -570,6 +570,9 @@ export default {
'saleOrder.productTableCell.validator1': 'x必须填写',
'saleOrder.productTableCell.validator2': '数值仅保留一位小数',
'saleOrder.productTableCell.validator3': '数值仅保留三位小数',
'saleOrder.qingwanshanwuliudan': '请完善物流单明细数据',
'saleOrder.qingwanshanfahuodan': '请完善发货单明细数据',
'saleOrder.shouhuoshuliangjin': '收货数量仅限三位小数',
// 请购单
......
import { postMemberManageLowerProviderPage } from "@/services/MemberV2Api"
import { getProductCommodityCommonGetCommodityListByBuyer, getProductGoodsGetGoodsList } from "@/services/ProductV2Api"
export const fetchOrderApi = {
/** 弹窗获取商品列表 */
async getProductList(params) {
const { data } = await getProductCommodityCommonGetCommodityListByBuyer(params, { useCache: true, ttl: 10 * 1000 })
return data
},
/** 获取下架服务提供者会员列表 */
async getMemberListByMemberName(params) {
const { data } = await postMemberManageLowerProviderPage({...params}, { ctlType: 'none' })
return data
},
/** 请购单物料 获取商品货品列表 */
async getPurchaseRequesitionMaterielList(params) {
const { data } = await getProductGoodsGetGoodsList(params)
return data
},
}
......@@ -56,18 +56,7 @@ const AddPurchaseReceiveOrder: React.FC<{}> = () => {
const params = { ...value }
console.log(value)
if(formContext.innerFormErrors) {
throw new Error(intl.formatMessage({ id: 'purchaseOrder.qingwanshancaigou', defaultMessage: '请完善采购收货单商品数据' }))
}
// 校验采购数量
const judgementByCount = params.products?.length && params.products.map(item => {
if(item.quantity){
return true
} else {
return false
}
})
if(!judgementByCount || judgementByCount.includes(false)){
throw new Error('请填写商品收货数量')
throw new Error(intl.formatMessage({ id: 'purchaseOrder.qingwanshancaigou', defaultMessage: '请完善采购收货单明细数据' }))
}
setBtnLoading(true)
......
import { postMemberManageLowerProviderPage } from "@/services/MemberV2Api"
import { getProductCommodityCommonGetCommodityListByBuyer, getProductGoodsGetGoodsList } from "@/services/ProductV2Api"
import { getProductCommodityCommonGetCommodityListByBuyer } from "@/services/ProductV2Api"
export const fetchOrderApi = {
/** 弹窗获取商品列表 */
......@@ -8,17 +7,4 @@ export const fetchOrderApi = {
return data
},
/** 获取下架服务提供者会员列表 */
async getMemberListByMemberName(params) {
const { data } = await postMemberManageLowerProviderPage({...params}, { ctlType: 'none' })
return data
},
/** 请购单物料 获取商品货品列表 */
async getPurchaseRequesitionMaterielList(params) {
const { data } = await getProductGoodsGetGoodsList(params)
return data
},
}
......@@ -107,7 +107,6 @@ export const filterProductDataById = (data, targetData) => {
prev.push(next)
}
return prev
}, [])
}
......@@ -187,10 +186,10 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
'name',
FORM_FILTER_PATH,
);
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(state => {
FormEffectHooks.onFieldChange$('customerCategoryId').subscribe(() => {
searchCustomerCategoryOptionEffect(schemaAction, actions, 'customerCategoryId')
})
FormEffectHooks.onFieldChange$('brandId').subscribe(state => {
FormEffectHooks.onFieldChange$('brandId').subscribe(() => {
searchBrandOptionEffect(schemaAction, actions, 'brandId')
})
}
......
import React, { useRef, useContext } from 'react'
import { Form, Input } from 'antd';
import { useIntl } from 'umi';
import { FormDetailContext } from '@/formSchema/context';
export interface ProductTableCellProps {
title: React.ReactNode;
......@@ -48,12 +49,16 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
const formItemRef = useRef<any>();
const { form } = useContext(EditableContext);
const intl = useIntl()
const { formContext } = useContext(FormDetailContext);
const save = async () => {
try {
const values = await form.validateFields();
values.purchaseCount = Number(values.purchaseCount) || 0
handleSave({ ...record, ...values });
formContext.ctl.setInnerFormErrors(0)
} catch (errInfo) {
formContext.ctl.setInnerFormErrors(errInfo.errorFields.length)
console.log('Save failed:', errInfo);
}
};
......
......@@ -19,7 +19,7 @@ export const PriceComp = (props) => {
</div>
}
/**代客下单 初始值转换 */
/**新增物流单 初始值转换 */
export const procurmentRenderInit = (initValue: any) => {
return {
......@@ -38,7 +38,7 @@ export const procurmentRenderInit = (initValue: any) => {
}
}
/** 代客下单 回显商品字段转换 */
/** 新增物流单 回显商品字段转换 */
export const procurementRenderField = (data) => {
const _orderProductRequests = data.product.products
return _orderProductRequests.map(item => {
......@@ -71,7 +71,7 @@ export const procurementRenderField = (data) => {
})
}
/** 代客下单提交 字段转换 */
/** 新增物流单 字段转换 */
export const procurementProcessField = (value) => {
value.products = value.products.map(item => {
return {
......
......@@ -87,22 +87,11 @@ const AddLogisticsOrder:React.FC<{}> = () => {
const handleSubmit = async (value) => {
try {
let fnResult = null
// 新增订单/编辑订
// 新增物流单/编辑物流
const params = { ...value }
console.log(value)
if(formContext.innerFormErrors) {
throw new Error(intl.formatMessage({ id: 'purchaseRequisition.qingwanshandingdan', defaultMessage: '请完善订单物料数据' }))
}
// 校验采购数量
const judgementByCount = params.products?.length && params.products.map(item => {
if(item.quantity){
return true
} else {
return false
}
})
if(!judgementByCount || judgementByCount.includes(false)){
throw new Error(intl.formatMessage({ id: 'purchaseRequisition.qingtianxieshangpin', defaultMessage: '请填写商品采购数量' }))
throw new Error(intl.formatMessage({ id: 'saleOrder.qingwanshanwuliudan', defaultMessage: '请完善物流单明细数据' }))
}
setBtnLoading(true)
......@@ -123,7 +112,6 @@ const AddLogisticsOrder:React.FC<{}> = () => {
} catch (error) {
setBtnLoading(false)
error?.message && message.error(error.message)
console.log(error)
}
}
......@@ -170,6 +158,9 @@ const AddLogisticsOrder:React.FC<{}> = () => {
// 物料信息的改动 渲染总额
useMaterialTableChangeForAmount(ctx, update)
// 注入表单完成进度
formContext.useAttachmentChangeForContext(ctx)
useAsyncSelect(
'deliverAddress',
fetchDeliverAddressSelectOptions,
......@@ -179,10 +170,6 @@ const AddLogisticsOrder:React.FC<{}> = () => {
'logisticProvider',
fetchLogisticProviderSelectOptions,
)
// 注入表单完成进度
formContext.useAttachmentChangeForContext(ctx)
}}
expressionScope={{
productColumns,
......
......@@ -46,7 +46,8 @@ const basicInfo: ISchema = {
logisticProvider: {
type: 'string',
title: intl.formatMessage({ id: 'saleOrder.wuliufuwushang', defaultMessage: '物流服务商' }),
enum: []
enum: [],
required: true,
},
deliverAddress: {
type: 'string',
......
import { postMemberManageLowerProviderPage } from "@/services/MemberV2Api"
import { getProductCommodityCommonGetCommodityListByBuyer, getProductGoodsGetGoodsList } from "@/services/ProductV2Api"
export const fetchOrderApi = {
/** 弹窗获取商品列表 */
async getProductList(params) {
const { data } = await getProductCommodityCommonGetCommodityListByBuyer(params, { useCache: true, ttl: 10 * 1000 })
return data
},
/** 获取下架服务提供者会员列表 */
async getMemberListByMemberName(params) {
const { data } = await postMemberManageLowerProviderPage({...params}, { ctlType: 'none' })
return data
},
/** 请购单物料 获取商品货品列表 */
async getPurchaseRequesitionMaterielList(params) {
const { data } = await getProductGoodsGetGoodsList(params)
return data
},
}
......@@ -145,26 +145,18 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
style={{ margin: 0 }}
name={dataIndex}
initialValue={record[dataIndex] || ''}
rules={dataIndex === 'quantity' ? [
rules={[
{
required: true,
message: `${title}${intl.formatMessage({ id: 'saleOrder.bixutianxie', defaultMessage: '必须填写' })}`,
},
{
pattern: /^\d+(\.\d{1,3})?$/,
message: intl.formatMessage({ id: 'saleOrder.caigoushuliangjin', defaultMessage: '采购数量仅限三位小数' }),
message: intl.formatMessage({ id: 'saleOrder.shouhuoshuliangjin', defaultMessage: '收货数量仅限三位小数' }),
},
{
validator: validatorNumber
},
] : [
{
pattern: /^\d+(\.\d{1,4})?$/,
message: intl.formatMessage({ id: 'saleOrder.danjiajinxiansi', defaultMessage: '单价仅限四位小数' }),
},
{
validator: validatorNumber
}
]}
>
{chooseFormItem(formItem, record[dataIndex] || '')}
......
......@@ -52,21 +52,10 @@ const AddSaleDelevedOrder:React.FC<{}> = () => {
const handleSubmit = async (value) => {
try {
let fnResult = null
// 新增订单/编辑订
// 新增发货单/编辑发货
const params = { ...value }
if(formContext.innerFormErrors) {
throw new Error(intl.formatMessage({ id: 'purchaseRequisition.qingwanshandingdan', defaultMessage: '请完善订单物料数据' }))
}
// 校验采购数量
const judgementByCount = params.products?.length && params.products.map(item => {
if(item.quantity){
return true
} else {
return false
}
})
if(!judgementByCount || judgementByCount.includes(false)){
throw new Error(intl.formatMessage({ id: 'purchaseRequisition.qingtianxieshangpin', defaultMessage: '请填写商品采购数量' }))
throw new Error(intl.formatMessage({ id: 'saleOrder.qingwanshanfahuodan', defaultMessage: '请完善发货单明细数据' }))
}
setBtnLoading(true)
......
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