Commit 2992a995 authored by XieZhiXiong's avatar XieZhiXiong

chore: 添加退货发货数量校验

parent 40fd6227
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-08-07 15:11:54
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-07 20:14:24
* @LastEditTime: 2021-08-09 14:12:50
* @Description: 退货发货处理抽屉
*/
import React from 'react';
......@@ -13,6 +13,7 @@ import {
import {
createAsyncFormActions,
FormEffectHooks,
FormPath,
} from '@formily/antd';
import { ArrayTable } from '@formily/antd-components';
import { PublicApi } from '@/services/api';
......@@ -182,16 +183,34 @@ const ReturnDeliverDrawer: React.FC<IProps> = (props) => {
components={{
ArrayTable,
}}
effects={($, { setFieldValue }) => {
effects={($, { setFieldValue, getFieldValue, setFieldState }) => {
useAsyncSelect('logisticsName', fetchLogisticsCompany, ['label', 'value']);
onFieldInputChange$('logisticsName').subscribe(state => {
onFieldInputChange$('logisticsName').subscribe((state) => {
const { originAsyncData, value } = state;
const current = originAsyncData.find(item => item.value === value);
const current = originAsyncData.find((item) => item.value === value);
if (current) {
setFieldValue('logisticsNameTxt', current.label);
}
});
onFieldInputChange$('productList.*.count').subscribe((fieldState) => {
const { value, name } = fieldState;
const noDeliveryCountValue = getFieldValue('noDeliveryCount');
setFieldState(
FormPath.transform(name, /\d/, $1 => {
return `productList.${$1}.count`
}),
state => {
if (+value > +noDeliveryCountValue) {
state.errors = ['填写值已超过未退货发货数量,请重新填写'];
} else {
state.errors = [];
}
}
);
});
}}
actions={formActions}
schema={schema}
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2021-01-06 11:36:34
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-08-07 19:20:26
* @LastEditTime: 2021-08-09 13:43:24
* @Description: 退货发货
*/
import React, { useState } from 'react';
......@@ -77,7 +77,7 @@ const ReturnPrDeliverVerify: React.FC = () => {
<ReturnDeliverDrawer
value={{
productList: info?.goodsDetailList,
productList: info?.goodsDetailList.filter((item) => item.noDeliveryCount > 0),
}}
visible={visible}
onClose={() => handleVisibleDrawer(false)}
......
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