ai产报价单
This commit is contained in:
@@ -140,22 +140,8 @@ const QuotationForm = () => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
// 改添加小节的函数
|
|
||||||
const handleAddSection = () => {
|
|
||||||
setTemplateModalVisible(true);
|
|
||||||
fetchAvailableSections();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 修改添加项目的函数
|
|
||||||
const handleAddItem = (add, sectionIndex) => {
|
|
||||||
add({
|
|
||||||
key: uuidv4(),
|
|
||||||
name: "",
|
|
||||||
quantity: 1,
|
|
||||||
price: 0,
|
|
||||||
description: "",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchQuotationDetail = async () => {
|
const fetchQuotationDetail = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -208,22 +194,6 @@ const QuotationForm = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 添加获取可用小节模板的方法
|
|
||||||
const fetchAvailableSections = async () => {
|
|
||||||
try {
|
|
||||||
const { data: sections, error } = await supabase
|
|
||||||
.from("resources")
|
|
||||||
.select("*")
|
|
||||||
.eq("type", "sections")
|
|
||||||
.order("created_at", { ascending: false });
|
|
||||||
|
|
||||||
if (error) throw error;
|
|
||||||
setAvailableSections(sections || []);
|
|
||||||
} catch (error) {
|
|
||||||
message.error("获取小节模版失败");
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -375,20 +345,45 @@ const QuotationForm = () => {
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
const handleExport = (data) => {
|
const handleExport = (data) => {
|
||||||
const _data={
|
if(data?.activityName&&data?.currency){
|
||||||
...data,
|
const quotationData = {
|
||||||
key: uuidv4(),
|
quataName: data.activityName,
|
||||||
|
description: data.description,
|
||||||
|
currency: data.currency || "TWD",
|
||||||
|
sections: data.sections.map((section) => ({
|
||||||
|
key: uuidv4(),
|
||||||
|
sectionName: section.sectionName,
|
||||||
|
items: section.items.map((item) => ({
|
||||||
|
key: uuidv4(),
|
||||||
|
name: item.name,
|
||||||
|
quantity: item.quantity,
|
||||||
|
price: item.price,
|
||||||
|
description: item.description,
|
||||||
|
unit: item.unit,
|
||||||
|
})),
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
setCurrentCurrency(data.currency || "TWD");
|
||||||
|
form.setFieldsValue(quotationData);
|
||||||
|
setFormValues(quotationData);
|
||||||
|
setTaxRate(data.taxRate || 0);
|
||||||
|
message.success('已添加报价单');
|
||||||
|
|
||||||
|
}else{
|
||||||
|
const _data={
|
||||||
|
...data,
|
||||||
|
key: uuidv4(),
|
||||||
|
}
|
||||||
|
const newSections = [...formValues.sections, _data];
|
||||||
|
form.setFieldValue('sections', newSections);
|
||||||
|
const currentFormValues = form.getFieldsValue();
|
||||||
|
setFormValues({
|
||||||
|
...currentFormValues,
|
||||||
|
sections: newSections
|
||||||
|
});
|
||||||
|
message.success('已添加新的服务项目');
|
||||||
}
|
}
|
||||||
const newSections = [...formValues.sections, _data];
|
|
||||||
console.log(newSections,'newSections');
|
|
||||||
|
|
||||||
form.setFieldValue('sections', newSections);
|
|
||||||
const currentFormValues = form.getFieldsValue();
|
|
||||||
setFormValues({
|
|
||||||
...currentFormValues,
|
|
||||||
sections: newSections
|
|
||||||
});
|
|
||||||
message.success('已添加新的服务项目');
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user