Merge pull request 'fix: 报价总金额结算组件编辑报错修复(待重构)购销单pdf打印名称更正,pdf报价金额修复,购销列表总金额修复' (#417) from fix_reordpdf_updateprice_tableallprices into @hera/dev

Reviewed-on: daoyoucloud/tachycode#417
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
This commit is contained in:
sealday 2024-03-18 22:27:19 +08:00
commit 30a08a08ff
7 changed files with 45 additions and 37 deletions

View File

@ -27,7 +27,7 @@ import { useFieldSchema } from '@formily/react';
import { isValid } from '@formily/shared';
import { useCreateActionProps } from './hooks/useCreateActionProps';
import { useOutboundActionProps } from './hooks/useOutboundActionProps';
import { AssociatedField } from './components/AssociatedField';
import { AssociatedField } from './components/fields/AssociatedField';
import { DatePicker } from './schema-components/date-picker';
import { SettingBlockInitializer } from './schema-initializer/SettingBlockInitializer';
import {
@ -73,7 +73,7 @@ import { CustomAssociatedFieldInterface } from './interfaces/customAssociated';
import { SignaturePadFieldInterface } from './interfaces/signatureSchema';
import { CalcResult } from './components/fields/CalcResult';
import { CustomAssociatedField } from './components/custom-components/CustomAssociatedField';
import Expression from './components/Expression';
import Expression from './components/fields/Expression';
import { CustomField } from './components/custom-components/CustomField';
import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents';
import { useGetCustomComponents } from './hooks/useGetCustomComponents';

View File

@ -59,7 +59,7 @@ export const RecordItemValuationQuantity = observer((props) => {
(rule) => rule.product?.category_id === item.product?.category_id || rule.product?.id === item.product?.id,
);
if (rule) {
rule.conversion_logic_id = rule.conversion_logic.id;
rule.conversion_logic_id = rule.conversion_logic?.id;
const count = subtotal(rule, item, productCategory, reqWeightRules);
count && result.push({ label: '报价', value: count });
}

View File

@ -206,7 +206,7 @@ const summary = (event: RecordItems, rules: any[], ruleWeight: any, recordData =
// 处理报价跟合同不同数据结构问题 [].flat()
[item.products]
.flat()
.find((product) => product?.id - 99999 === event.product.category_id || product.id === event.product.id),
.find((product) => product?.id - 99999 === event.product.category_id || product?.id === event.product.id),
);
if (!plain) return { ruleCalc };
ruleCalc.name = category.name;

View File

@ -34,6 +34,7 @@ export const RecordTotalPrice: CustomFunctionComponent = () => {
const [recordWeight, setRecordWeight] = useState(0);
// 总金额计算方法
const computeTotalPrice = () => {
if (!leaseData) return;
const about_product = form.values.items.filter(
(item) =>
item.product?.id === leaseData.product?.id || item.product?.category_id === leaseData.product?.id - 99999,
@ -93,34 +94,32 @@ export const RecordTotalPrice: CustomFunctionComponent = () => {
setAllPrice(allPrice);
};
useFormEffects(() => {
onFieldInit('items.*', () => {
const updateProducts = () => {
setProducts(_.cloneDeep(form.values.items));
});
onFieldValueChange('items.*', () => {
setProducts(_.cloneDeep(form.values.items));
});
onFieldInit('price_items.*', () => {
};
const updateLeaseData = () => {
if (form.values.price_items) {
setLeaseData(_.cloneDeep(form.values.price_items[lease_index]));
}
});
onFieldValueChange('price_items.*', () => {
if (form.values.price_items) {
setLeaseData(_.cloneDeep(form.values.price_items[lease_index]));
}
});
onFieldInit('group_weight_items.*', () => {
};
const updateGroupWeight = () => {
setGroupWeight(_.cloneDeep(form.values.group_weight_items));
});
onFieldValueChange('group_weight_items.*', () => {
setGroupWeight(_.cloneDeep(form.values.group_weight_items));
});
onFieldInit('weight', () => {
};
const updateRecordWeight = () => {
setRecordWeight(_.cloneDeep(form.values.weight));
});
onFieldValueChange('weight', () => {
setRecordWeight(_.cloneDeep(form.values.weight));
});
};
onFieldInit('items.*', updateProducts);
onFieldValueChange('items.*', updateProducts);
onFieldInit('price_items.*', updateLeaseData);
onFieldValueChange('price_items.*', updateLeaseData);
onFieldInit('group_weight_items.*', updateGroupWeight);
onFieldValueChange('group_weight_items.*', updateGroupWeight);
onFieldInit('weight', updateRecordWeight);
onFieldValueChange('weight', updateRecordWeight);
});
useEffect(() => {
if (!reqProduct.loading && !reqWeightRules.loading) {

View File

@ -224,9 +224,9 @@ const PreviewDocument = ({
name = detail.contract?.project?.associated_company?.name ?? detail.systemTitle;
} else {
if (outOfStorage === '入库') {
name = detail.out_stock?.associated_company?.name ?? detail.systemTitle;
name = detail.in_stock?.name ?? detail.systemTitle;
} else {
name = detail.in_stock?.associated_company?.name ?? detail.systemTitle;
name = detail.out_stock?.name ?? detail.systemTitle;
}
}
return name;
@ -427,7 +427,7 @@ const PreviewDocument = ({
{item?.right_unit_price && formatQuantity(item.right_unit_price, 2) + '元/' + item.right_unit}
</Text>
<Text style={styles.tableCell}>
{formatQuantity(item.right_count)}
{item.right_count && formatQuantity(item.right_count)}
{item.right_unit}
</Text>
<Text style={styles.tableCell}>

View File

@ -64,8 +64,17 @@ export class RecordPdfService {
data['all_price'] = data['count'] * data['unit_price'];
return data;
});
const setData = Array.from(new Set(price_rule.map((item) => item.name))).map((name) =>
price_rule.find((item) => item.name === name),
const setData = Object.values(
price_rule.reduce((acc, item) => {
if (!acc[item.name]) {
acc[item.name] = { ...item };
} else {
acc[item.name].count += item.count;
acc[item.name].all_price += item.all_price;
}
return acc;
}, {}),
);
make_price = setData;
}

View File

@ -99,7 +99,7 @@ export class RecordService {
const weight_items = values.group_weight_items;
let allPrice = 0;
for (const item of rule) {
const data = await this.amountCalculation(item, products, weight_items);
const data = await this.amountCalculation(item, products, weight_items, values.weight);
allPrice += data;
}
const recordId = record.id;
@ -260,7 +260,7 @@ export class RecordService {
* @param weight_items
* @returns
*/
private async amountCalculation(rule, products, weight_items) {
private async amountCalculation(rule, products, weight_items, recprdWeight) {
const calc_products = products.filter(
(product) => product.product.category_id === rule.product.id - 99999 || product.product.id === rule.product.id,
);
@ -299,11 +299,11 @@ export class RecordService {
return allPrice / 1000;
} else if (rule.conversion_logic.id === ConversionLogics.ActualWeight) {
// 根据产品找分组实际重量
const weightDate = weight_items.find((item) =>
item.products?.find((product) => product?.id === rule.product.id - 99999),
);
const weightDate =
weight_items.find((item) => item.products?.find((product) => product?.id === rule.product.id - 99999))
?.weight || recprdWeight;
if (weightDate) {
const allPrice = weightDate.weight * rule.unit_price;
const allPrice = weightDate * rule.unit_price;
return allPrice;
} else {
const allPrice = calc_products.reduce((accumulator, currentValue) => {