feat:v1
This commit is contained in:
@@ -105,10 +105,12 @@ const QuotationForm = () => {
|
||||
},
|
||||
[currentCurrency]
|
||||
);
|
||||
|
||||
// 处理表单值变化
|
||||
useEffect(()=>{
|
||||
console.log(currentCurrency,'currency');
|
||||
|
||||
},[currentCurrency])
|
||||
// 处理表单值变化
|
||||
const handleValuesChange = (changedValues, allValues) => {
|
||||
console.log("Form values changed:", allValues); // 调试用
|
||||
setFormValues(allValues);
|
||||
if (changedValues.currency) {
|
||||
setCurrentCurrency(changedValues.currency);
|
||||
@@ -153,7 +155,6 @@ const QuotationForm = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 修改获取详情的函数
|
||||
const fetchQuotationDetail = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
@@ -404,7 +405,7 @@ const QuotationForm = () => {
|
||||
const quotationData = {
|
||||
quataName: template.attributes.templateName,
|
||||
description: template.attributes.description,
|
||||
currency: "CNY",
|
||||
currency: template.attributes.currency || "CNY",
|
||||
category: template.attributes.category,
|
||||
sections: template.attributes.sections.map((section) => ({
|
||||
key: uuidv4(),
|
||||
@@ -419,7 +420,7 @@ const QuotationForm = () => {
|
||||
})),
|
||||
})),
|
||||
};
|
||||
|
||||
setCurrentCurrency(template.attributes.currency || "CNY");
|
||||
form.setFieldsValue(quotationData);
|
||||
setFormValues(quotationData);
|
||||
}
|
||||
@@ -518,68 +519,6 @@ const QuotationForm = () => {
|
||||
fetchCustomers();
|
||||
}, []);
|
||||
|
||||
const renderItemFields = (itemField, itemIndex, sectionIndex) => (
|
||||
<div
|
||||
key={`${sectionIndex}-${itemIndex}-${itemField.key}`}
|
||||
className="grid grid-cols-[3fr_4fr_1fr_1fr_2fr_1fr_40px] gap-4 mb-4 items-start"
|
||||
>
|
||||
<Form.Item
|
||||
{...itemField}
|
||||
name={[itemField.name, "productName"]}
|
||||
className="!mb-0"
|
||||
>
|
||||
<Input placeholder="服务项目名称" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
{...itemField}
|
||||
name={[itemField.name, "note"]}
|
||||
className="!mb-0"
|
||||
>
|
||||
<Input placeholder="请输入描述/备注" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
{...itemField}
|
||||
name={[itemField.name, "unit"]}
|
||||
className="!mb-0"
|
||||
>
|
||||
<Input placeholder="单位" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
{...itemField}
|
||||
name={[itemField.name, "quantity"]}
|
||||
className="!mb-0"
|
||||
>
|
||||
<InputNumber placeholder="数量" min={0} className="w-full" />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
{...itemField}
|
||||
name={[itemField.name, "price"]}
|
||||
className="!mb-0"
|
||||
>
|
||||
<InputNumber placeholder="单价" min={0} className="w-full" />
|
||||
</Form.Item>
|
||||
<div className="text-right">
|
||||
<span className="text-gray-500">
|
||||
{formatCurrency(
|
||||
calculateItemAmount(
|
||||
formValues?.sections?.[sectionIndex]?.items?.[itemIndex]
|
||||
?.quantity,
|
||||
formValues?.sections?.[sectionIndex]?.items?.[itemIndex]?.price
|
||||
)
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
{!isView && itemFields.length > 1 && (
|
||||
<Button
|
||||
type="text"
|
||||
danger
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={() => removeItem(itemField.name)}
|
||||
className="flex items-center justify-center"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
// 确保在组件加载时正确获取数据
|
||||
useEffect(() => {
|
||||
@@ -594,35 +533,7 @@ const QuotationForm = () => {
|
||||
}
|
||||
}, [id, templateId]);
|
||||
|
||||
// 处理小节名称编辑
|
||||
const handleSectionNameEdit = (sectionIndex, initialValue) => {
|
||||
setEditingSectionIndex(sectionIndex);
|
||||
setEditingSectionName(initialValue || "");
|
||||
};
|
||||
|
||||
// 保存小节名称
|
||||
const handleSectionNameSave = () => {
|
||||
if (!editingSectionName.trim()) {
|
||||
message.error("请输入小节名称");
|
||||
return;
|
||||
}
|
||||
|
||||
const sections = form.getFieldValue("sections");
|
||||
const newSections = [...sections];
|
||||
newSections[editingSectionIndex] = {
|
||||
...newSections[editingSectionIndex],
|
||||
sectionName: editingSectionName.trim(),
|
||||
};
|
||||
form.setFieldValue("sections", newSections);
|
||||
setEditingSectionIndex(null);
|
||||
setEditingSectionName("");
|
||||
};
|
||||
|
||||
// 取消编辑
|
||||
const handleSectionNameCancel = () => {
|
||||
setEditingSectionIndex(null);
|
||||
setEditingSectionName("");
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="bg-gradient-to-b from-gray-50 to-white dark:from-gray-800 dark:to-gray-900/90 min-h-screen p-2">
|
||||
|
||||
Reference in New Issue
Block a user