From dbdb1135bc60d7273c7639c3f098f1263697a3f8 Mon Sep 17 00:00:00 2001
From: "hello@lv" <2256334253@qq.com>
Date: Fri, 12 Apr 2024 13:44:17 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B4=B9=E7=94=A8=E8=8C=83=E5=9B=B4?=
=?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=80=83=E8=99=91=E7=9B=B4=E5=8F=91=E5=8D=95?=
=?UTF-8?q?=EF=BC=8C=E5=85=88=E7=AE=80=E5=8D=95=E5=A4=84=E7=90=86=E6=8E=89?=
=?UTF-8?q?=20=20feat=20#687=20(#688)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachycode/pulls/688
Co-authored-by: hello@lv <2256334253@qq.com>
Co-committed-by: hello@lv <2256334253@qq.com>
---
.changeset/tall-windows-cross.md | 5 +++
.../custom-components/RecordFeeScope.tsx | 38 +++++++++++++++++--
2 files changed, 40 insertions(+), 3 deletions(-)
create mode 100644 .changeset/tall-windows-cross.md
diff --git a/.changeset/tall-windows-cross.md b/.changeset/tall-windows-cross.md
new file mode 100644
index 000000000..34a949aa2
--- /dev/null
+++ b/.changeset/tall-windows-cross.md
@@ -0,0 +1,5 @@
+---
+"@hera/plugin-rental": patch
+---
+
+费用范围没有考虑直发单,暂时简单处理
diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeScope.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeScope.tsx
index ad7509359..515beb734 100644
--- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeScope.tsx
+++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordFeeScope.tsx
@@ -13,9 +13,36 @@ export const RecordFeeScope = observer(() => {
const path: any = field.path.entire;
const fieldPath = path?.replace(`.${fieldSchema.name}`, '');
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 = [];
- if (data?.data?.length > 0) {
+ if (data.data?.length > 0) {
const items = data.data as {
products: { category_id: Number }[];
fee_items: { fee_product_id: Number }[];
@@ -29,7 +56,12 @@ export const RecordFeeScope = observer(() => {
form.setValuesIn(fieldPath, result);
}, [result, form, fieldPath]);
- return loading ? : <>>;
+ return ((form.values.record_category === '1' || form.values.record_category === '0') && contractLoading) ||
+ _loading ? (
+
+ ) : (
+ <>>
+ );
}) as CustomFC;
RecordFeeScope.displayName = 'RecordFeeScope';