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:
commit
30a08a08ff
@ -27,7 +27,7 @@ import { useFieldSchema } from '@formily/react';
|
|||||||
import { isValid } from '@formily/shared';
|
import { isValid } from '@formily/shared';
|
||||||
import { useCreateActionProps } from './hooks/useCreateActionProps';
|
import { useCreateActionProps } from './hooks/useCreateActionProps';
|
||||||
import { useOutboundActionProps } from './hooks/useOutboundActionProps';
|
import { useOutboundActionProps } from './hooks/useOutboundActionProps';
|
||||||
import { AssociatedField } from './components/AssociatedField';
|
import { AssociatedField } from './components/fields/AssociatedField';
|
||||||
import { DatePicker } from './schema-components/date-picker';
|
import { DatePicker } from './schema-components/date-picker';
|
||||||
import { SettingBlockInitializer } from './schema-initializer/SettingBlockInitializer';
|
import { SettingBlockInitializer } from './schema-initializer/SettingBlockInitializer';
|
||||||
import {
|
import {
|
||||||
@ -73,7 +73,7 @@ import { CustomAssociatedFieldInterface } from './interfaces/customAssociated';
|
|||||||
import { SignaturePadFieldInterface } from './interfaces/signatureSchema';
|
import { SignaturePadFieldInterface } from './interfaces/signatureSchema';
|
||||||
import { CalcResult } from './components/fields/CalcResult';
|
import { CalcResult } from './components/fields/CalcResult';
|
||||||
import { CustomAssociatedField } from './components/custom-components/CustomAssociatedField';
|
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 { CustomField } from './components/custom-components/CustomField';
|
||||||
import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents';
|
import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents';
|
||||||
import { useGetCustomComponents } from './hooks/useGetCustomComponents';
|
import { useGetCustomComponents } from './hooks/useGetCustomComponents';
|
||||||
|
@ -59,7 +59,7 @@ export const RecordItemValuationQuantity = observer((props) => {
|
|||||||
(rule) => rule.product?.category_id === item.product?.category_id || rule.product?.id === item.product?.id,
|
(rule) => rule.product?.category_id === item.product?.category_id || rule.product?.id === item.product?.id,
|
||||||
);
|
);
|
||||||
if (rule) {
|
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);
|
const count = subtotal(rule, item, productCategory, reqWeightRules);
|
||||||
count && result.push({ label: '报价', value: count });
|
count && result.push({ label: '报价', value: count });
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ const summary = (event: RecordItems, rules: any[], ruleWeight: any, recordData =
|
|||||||
// 处理报价跟合同不同数据结构问题 [].flat()
|
// 处理报价跟合同不同数据结构问题 [].flat()
|
||||||
[item.products]
|
[item.products]
|
||||||
.flat()
|
.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 };
|
if (!plain) return { ruleCalc };
|
||||||
ruleCalc.name = category.name;
|
ruleCalc.name = category.name;
|
||||||
|
@ -34,6 +34,7 @@ export const RecordTotalPrice: CustomFunctionComponent = () => {
|
|||||||
const [recordWeight, setRecordWeight] = useState(0);
|
const [recordWeight, setRecordWeight] = useState(0);
|
||||||
// 总金额计算方法
|
// 总金额计算方法
|
||||||
const computeTotalPrice = () => {
|
const computeTotalPrice = () => {
|
||||||
|
if (!leaseData) return;
|
||||||
const about_product = form.values.items.filter(
|
const about_product = form.values.items.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.product?.id === leaseData.product?.id || item.product?.category_id === leaseData.product?.id - 99999,
|
item.product?.id === leaseData.product?.id || item.product?.category_id === leaseData.product?.id - 99999,
|
||||||
@ -93,34 +94,32 @@ export const RecordTotalPrice: CustomFunctionComponent = () => {
|
|||||||
setAllPrice(allPrice);
|
setAllPrice(allPrice);
|
||||||
};
|
};
|
||||||
useFormEffects(() => {
|
useFormEffects(() => {
|
||||||
onFieldInit('items.*', () => {
|
const updateProducts = () => {
|
||||||
setProducts(_.cloneDeep(form.values.items));
|
setProducts(_.cloneDeep(form.values.items));
|
||||||
});
|
};
|
||||||
onFieldValueChange('items.*', () => {
|
const updateLeaseData = () => {
|
||||||
setProducts(_.cloneDeep(form.values.items));
|
|
||||||
});
|
|
||||||
onFieldInit('price_items.*', () => {
|
|
||||||
if (form.values.price_items) {
|
if (form.values.price_items) {
|
||||||
setLeaseData(_.cloneDeep(form.values.price_items[lease_index]));
|
setLeaseData(_.cloneDeep(form.values.price_items[lease_index]));
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
onFieldValueChange('price_items.*', () => {
|
const updateGroupWeight = () => {
|
||||||
if (form.values.price_items) {
|
|
||||||
setLeaseData(_.cloneDeep(form.values.price_items[lease_index]));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
onFieldInit('group_weight_items.*', () => {
|
|
||||||
setGroupWeight(_.cloneDeep(form.values.group_weight_items));
|
setGroupWeight(_.cloneDeep(form.values.group_weight_items));
|
||||||
});
|
};
|
||||||
onFieldValueChange('group_weight_items.*', () => {
|
const updateRecordWeight = () => {
|
||||||
setGroupWeight(_.cloneDeep(form.values.group_weight_items));
|
|
||||||
});
|
|
||||||
onFieldInit('weight', () => {
|
|
||||||
setRecordWeight(_.cloneDeep(form.values.weight));
|
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(() => {
|
useEffect(() => {
|
||||||
if (!reqProduct.loading && !reqWeightRules.loading) {
|
if (!reqProduct.loading && !reqWeightRules.loading) {
|
||||||
|
@ -224,9 +224,9 @@ const PreviewDocument = ({
|
|||||||
name = detail.contract?.project?.associated_company?.name ?? detail.systemTitle;
|
name = detail.contract?.project?.associated_company?.name ?? detail.systemTitle;
|
||||||
} else {
|
} else {
|
||||||
if (outOfStorage === '入库') {
|
if (outOfStorage === '入库') {
|
||||||
name = detail.out_stock?.associated_company?.name ?? detail.systemTitle;
|
name = detail.in_stock?.name ?? detail.systemTitle;
|
||||||
} else {
|
} else {
|
||||||
name = detail.in_stock?.associated_company?.name ?? detail.systemTitle;
|
name = detail.out_stock?.name ?? detail.systemTitle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
@ -427,7 +427,7 @@ const PreviewDocument = ({
|
|||||||
{item?.right_unit_price && formatQuantity(item.right_unit_price, 2) + '元/' + item.right_unit}
|
{item?.right_unit_price && formatQuantity(item.right_unit_price, 2) + '元/' + item.right_unit}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={styles.tableCell}>
|
<Text style={styles.tableCell}>
|
||||||
{formatQuantity(item.right_count)}
|
{item.right_count && formatQuantity(item.right_count)}
|
||||||
{item.right_unit}
|
{item.right_unit}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={styles.tableCell}>
|
<Text style={styles.tableCell}>
|
||||||
|
@ -64,8 +64,17 @@ export class RecordPdfService {
|
|||||||
data['all_price'] = data['count'] * data['unit_price'];
|
data['all_price'] = data['count'] * data['unit_price'];
|
||||||
return data;
|
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;
|
make_price = setData;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ export class RecordService {
|
|||||||
const weight_items = values.group_weight_items;
|
const weight_items = values.group_weight_items;
|
||||||
let allPrice = 0;
|
let allPrice = 0;
|
||||||
for (const item of rule) {
|
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;
|
allPrice += data;
|
||||||
}
|
}
|
||||||
const recordId = record.id;
|
const recordId = record.id;
|
||||||
@ -260,7 +260,7 @@ export class RecordService {
|
|||||||
* @param weight_items 全部分组实际重量
|
* @param weight_items 全部分组实际重量
|
||||||
* @returns 单个规则产生的总金额
|
* @returns 单个规则产生的总金额
|
||||||
*/
|
*/
|
||||||
private async amountCalculation(rule, products, weight_items) {
|
private async amountCalculation(rule, products, weight_items, recprdWeight) {
|
||||||
const calc_products = products.filter(
|
const calc_products = products.filter(
|
||||||
(product) => product.product.category_id === rule.product.id - 99999 || product.product.id === rule.product.id,
|
(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;
|
return allPrice / 1000;
|
||||||
} else if (rule.conversion_logic.id === ConversionLogics.ActualWeight) {
|
} else if (rule.conversion_logic.id === ConversionLogics.ActualWeight) {
|
||||||
// 根据产品找分组实际重量
|
// 根据产品找分组实际重量
|
||||||
const weightDate = weight_items.find((item) =>
|
const weightDate =
|
||||||
item.products?.find((product) => product?.id === rule.product.id - 99999),
|
weight_items.find((item) => item.products?.find((product) => product?.id === rule.product.id - 99999))
|
||||||
);
|
?.weight || recprdWeight;
|
||||||
if (weightDate) {
|
if (weightDate) {
|
||||||
const allPrice = weightDate.weight * rule.unit_price;
|
const allPrice = weightDate * rule.unit_price;
|
||||||
return allPrice;
|
return allPrice;
|
||||||
} else {
|
} else {
|
||||||
const allPrice = calc_products.reduce((accumulator, currentValue) => {
|
const allPrice = calc_products.reduce((accumulator, currentValue) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user