This commit is contained in:
liamzi
2024-12-27 18:34:17 +08:00
parent c3c8966cce
commit bfa895fa16
2 changed files with 21 additions and 17 deletions

View File

@@ -3,13 +3,13 @@ import { Form, Input, InputNumber, Button, Card, Typography, Modal, message, Div
import { PlusOutlined, DeleteOutlined, EditOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons'; import { PlusOutlined, DeleteOutlined, EditOutlined, CheckOutlined, CloseOutlined } from '@ant-design/icons';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import { supabase } from "@/config/supabase"; import { supabase } from "@/config/supabase";
import { supabaseService } from "@/hooks/supabaseService";
const { Text } = Typography; const { Text } = Typography;
const SectionList = ({ const SectionList = ({
form, form,
isView, isView,
formValues, formValues,
type,
currentCurrency = 'CNY' currentCurrency = 'CNY'
}) => { }) => {
const [editingSectionIndex, setEditingSectionIndex] = useState(null); const [editingSectionIndex, setEditingSectionIndex] = useState(null);
@@ -143,14 +143,17 @@ const SectionList = ({
const fetchUnits = async () => { const fetchUnits = async () => {
setLoadingUnits(true); setLoadingUnits(true);
try { try {
const { data: unitsData, error } = await supabase const { data: units } = await supabaseService.select('resources', {
.from('resources') filter: {
.select('*') 'type': { eq: 'units' },
.eq('type', 'units') 'attributes->>template_type': { in: `(${type},common)` }
.order('created_at', { ascending: false }); },
order: {
if (error) throw error; column: 'created_at',
setUnits(unitsData || []); ascending: false
}
});
setUnits(units || []);
} catch (error) { } catch (error) {
message.error('获取单位列表失败'); message.error('获取单位列表失败');
console.error(error); console.error(error);

View File

@@ -3,7 +3,7 @@ import { Form, Card, Input, Select, message,Button } from 'antd';
import { supabaseService } from '@/hooks/supabaseService'; import { supabaseService } from '@/hooks/supabaseService';
import {ArrowLeftOutlined}from '@ant-design/icons' import {ArrowLeftOutlined}from '@ant-design/icons'
import SectionList from '@/components/SectionList'; import SectionList from '@/components/SectionList';
const TYPE = 'quotation'
const QuotationTemplate = ({ id, isView, onCancel,isEdit }) => { const QuotationTemplate = ({ id, isView, onCancel,isEdit }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
@@ -28,7 +28,7 @@ const QuotationTemplate = ({ id, isView, onCancel,isEdit }) => {
filter: { filter: {
id: { eq: id }, id: { eq: id },
type: { eq: 'serviceTemplate' }, type: { eq: 'serviceTemplate' },
'attributes->>template_type': { eq: 'quotation' } 'attributes->>template_type': { eq: TYPE }
} }
}); });
console.log(data,'data'); console.log(data,'data');
@@ -57,7 +57,7 @@ const QuotationTemplate = ({ id, isView, onCancel,isEdit }) => {
const { data } = await supabaseService.select('resources', { const { data } = await supabaseService.select('resources', {
filter: { filter: {
type: { eq: 'categories' }, type: { eq: 'categories' },
'attributes->>template_type': { in: `(quotation,common)` } 'attributes->>template_type': { in: `(${TYPE},common)` }
}, },
order: { order: {
column: 'created_at', column: 'created_at',
@@ -95,7 +95,7 @@ const QuotationTemplate = ({ id, isView, onCancel,isEdit }) => {
const serviceData = { const serviceData = {
type: "serviceTemplate", type: "serviceTemplate",
attributes: { attributes: {
template_type: "quotation", template_type: TYPE,
templateName: values.templateName, templateName: values.templateName,
description: values.description, description: values.description,
sections: values.sections, sections: values.sections,
@@ -189,13 +189,16 @@ const QuotationTemplate = ({ id, isView, onCancel,isEdit }) => {
bordered={false} bordered={false}
> >
<SectionList <SectionList
type="quotation"
form={form} form={form}
isView={isView} isView={isView}
formValues={formValues} formValues={formValues}
onValuesChange={handleValuesChange} onValuesChange={handleValuesChange}
/> />
</Card> </Card>
<div className="flex justify-end space-x-4">
</Form>
<div className="flex justify-end pt-4 space-x-4">
<Button <Button
icon={<ArrowLeftOutlined />} icon={<ArrowLeftOutlined />}
onClick={onCancel} onClick={onCancel}
@@ -212,8 +215,6 @@ const QuotationTemplate = ({ id, isView, onCancel,isEdit }) => {
</Button> </Button>
)} )}
</div> </div>
</Form>
</> </>
); );
}; };