feat: 费用范围没有考虑直发单,先简单处理掉 feat #687 (#688)

Reviewed-on: daoyoucloud/tachycode#688
Co-authored-by: hello@lv <2256334253@qq.com>
Co-committed-by: hello@lv <2256334253@qq.com>
This commit is contained in:
hello@lv 2024-04-12 13:44:17 +08:00 committed by sealday
parent 946b77e9df
commit dbdb1135bc
2 changed files with 40 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
"@hera/plugin-rental": patch
---
费用范围没有考虑直发单,暂时简单处理

View File

@ -13,9 +13,36 @@ export const RecordFeeScope = observer(() => {
const path: any = field.path.entire; const path: any = field.path.entire;
const fieldPath = path?.replace(`.${fieldSchema.name}`, ''); const fieldPath = path?.replace(`.${fieldSchema.name}`, '');
const item = form.getValuesIn(field.path.slice(0, -2).entire); const item = form.getValuesIn(field.path.slice(0, -2).entire);
const { data, loading } = useFeeItems(item.product?.category_id, form.values.contract_plan?.id); let _loading = false;
let contractLoading = false;
const data = {
data: [],
};
if (form.values.record_category === '1' || form.values.record_category === '0') {
let _in = [],
_out = [];
const { data: inData, loading: inLoading } = useFeeItems(
item.product?.category_id,
form.values.in_contract_plan?.id,
);
_in = inData?.data || [];
contractLoading = contractLoading || inLoading;
if (form.values.record_category === '1') {
const { data: outData, loading: outLoading } = useFeeItems(
item.product?.category_id,
form.values.out_contract_plan?.id,
);
_out = outData?.data || [];
contractLoading = contractLoading || outLoading;
}
data.data = [..._in, ..._out];
} else {
const { data: origin, loading } = useFeeItems(item.product?.category_id, form.values.contract_plan?.id);
data.data = origin?.data;
_loading = _loading || loading;
}
let result = []; let result = [];
if (data?.data?.length > 0) { if (data.data?.length > 0) {
const items = data.data as { const items = data.data as {
products: { category_id: Number }[]; products: { category_id: Number }[];
fee_items: { fee_product_id: Number }[]; fee_items: { fee_product_id: Number }[];
@ -29,7 +56,12 @@ export const RecordFeeScope = observer(() => {
form.setValuesIn(fieldPath, result); form.setValuesIn(fieldPath, result);
}, [result, form, fieldPath]); }, [result, form, fieldPath]);
return loading ? <Spin /> : <></>; return ((form.values.record_category === '1' || form.values.record_category === '0') && contractLoading) ||
_loading ? (
<Spin />
) : (
<></>
);
}) as CustomFC; }) as CustomFC;
RecordFeeScope.displayName = 'RecordFeeScope'; RecordFeeScope.displayName = 'RecordFeeScope';