diff --git a/.env.example b/.env.example deleted file mode 100644 index f31f253..0000000 --- a/.env.example +++ /dev/null @@ -1,4 +0,0 @@ -VITE_SUPABASE_URL=your_supabase_url -VITE_SUPABASE_ANON_KEY=your_supabase_anon_key - - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2f3049..9765c6a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -53,6 +53,9 @@ importers: react-dom: specifier: ^18.2.0 version: 18.3.1(react@18.3.1) + react-icons: + specifier: ^5.4.0 + version: 5.4.0(react@18.3.1) react-infinite-scroll-component: specifier: ^6.1.0 version: 6.1.0(react@18.3.1) @@ -2121,6 +2124,11 @@ packages: peerDependencies: react: ^18.3.1 + react-icons@5.4.0: + resolution: {integrity: sha512-7eltJxgVt7X64oHh6wSWNwwbKTCtMfK35hcjvJS0yxEAhPM8oUKdS3+kqaW1vicIltw+kR2unHaa12S9pPALoQ==} + peerDependencies: + react: '*' + react-infinite-scroll-component@6.1.0: resolution: {integrity: sha512-SQu5nCqy8DxQWpnUVLx7V7b7LcA37aM7tvoWjTLZp1dk6EJibM5/4EJKzOnl07/BsM1Y40sKLuqjCwwH/xV0TQ==} peerDependencies: @@ -5008,6 +5016,10 @@ snapshots: react: 18.3.1 scheduler: 0.23.2 + react-icons@5.4.0(react@18.3.1): + dependencies: + react: 18.3.1 + react-infinite-scroll-component@6.1.0(react@18.3.1): dependencies: react: 18.3.1 diff --git a/src/components/Layout/Header.jsx b/src/components/Layout/Header.jsx index 7329932..00914dd 100644 --- a/src/components/Layout/Header.jsx +++ b/src/components/Layout/Header.jsx @@ -18,6 +18,7 @@ const Header = ({ collapsed, setCollapsed }) => { console.error("Logout error:", error); } }; +console.log(user); const userMenuItems = [ { @@ -79,7 +80,7 @@ const Header = ({ collapsed, setCollapsed }) => { )}

- {!user?.user_metadata?.name || user?.email?.split("@")[0]} + {user?.user_metadata?.name || user?.email?.split("@")[0]}

diff --git a/src/components/Layout/MainLayout.jsx b/src/components/Layout/MainLayout.jsx index b9d6c3a..993f7b6 100644 --- a/src/components/Layout/MainLayout.jsx +++ b/src/components/Layout/MainLayout.jsx @@ -12,13 +12,13 @@ const MainLayout = () => { const { isDarkMode } = useTheme(); return ( - + - +
{ // 子表格列定义 const expandedRowRender = (record) => { return ( -
+
{record.attributes.sections.map((section) => (
diff --git a/src/pages/company/service/itemsManange/classify/index.jsx b/src/pages/company/service/itemsManange/classify/index.jsx index ea7605d..170f740 100644 --- a/src/pages/company/service/itemsManange/classify/index.jsx +++ b/src/pages/company/service/itemsManange/classify/index.jsx @@ -130,7 +130,7 @@ const Classify = ({activeType,typeList}) => { /> ) : ( - {text} + {text} ); }, }, @@ -152,7 +152,7 @@ const Classify = ({activeType,typeList}) => { /> ) : ( - + {typeList.find(t => t.value === text)?.label || text} ); @@ -225,8 +225,8 @@ const Classify = ({activeType,typeList}) => { ]; return ( -
-
+
+
diff --git a/src/pages/company/service/itemsManange/index.jsx b/src/pages/company/service/itemsManange/index.jsx index e46797b..2522cfd 100644 --- a/src/pages/company/service/itemsManange/index.jsx +++ b/src/pages/company/service/itemsManange/index.jsx @@ -56,7 +56,7 @@ const ResourceManagement = () => { - +
) diff --git a/src/pages/company/service/itemsManange/sections/index.jsx b/src/pages/company/service/itemsManange/sections/index.jsx index 64afcaf..aeb4ab6 100644 --- a/src/pages/company/service/itemsManange/sections/index.jsx +++ b/src/pages/company/service/itemsManange/sections/index.jsx @@ -8,7 +8,7 @@ import { message, Popconfirm, Select, - Segmented, + Divider, InputNumber, Card, Typography @@ -19,30 +19,22 @@ import { v4 as uuidv4 } from 'uuid'; const { Text } = Typography; -const SectionsManagement = ({ activeType = 'quotation', typeList }) => { +const SectionsManagement = ({ activeType = 'quotation' }) => { const [data, setData] = useState([]); const [loading, setLoading] = useState(false); const [editingKey, setEditingKey] = useState(''); const [form] = Form.useForm(); - const [filterType, setFilterType] = useState('all'); - - const fetchSections = async (type = activeType, filterTypeValue = filterType) => { +const [loadingUnits,setLoadingUnits]=useState(false) +const [units,setUnit]=useState([]) +const [formValues, setFormValues] = useState({}); + const fetchSections = async () => { setLoading(true); try { - let filterCondition; - - switch (filterTypeValue) { - case 'current': - filterCondition = { eq: type }; - break; - default: - filterCondition = { eq: type }; - } const { data: sections } = await supabaseService.select('resources', { filter: { 'type': { eq: 'sections' }, - 'attributes->>template_type': filterCondition + 'attributes->>template_type': {eq:activeType} }, order: { column: 'created_at', @@ -58,9 +50,30 @@ const SectionsManagement = ({ activeType = 'quotation', typeList }) => { setLoading(false); } }; - + const fetchUnits = async () => { + setLoadingUnits(true); + try { + const { data: units } = await supabaseService.select("resources", { + filter: { + type: { eq: "units" }, + "attributes->>template_type": { in: `(${activeType},common)` }, + }, + order: { + column: "created_at", + ascending: false, + }, + }); + setUnit(units || []); + } catch (error) { + message.error("获取单位列表失败"); + console.error(error); + } finally { + setLoadingUnits(false); + } + }; useEffect(() => { - fetchSections(activeType, filterType); + fetchSections(); + }, [activeType]); const handleAdd = () => { @@ -139,7 +152,32 @@ const SectionsManagement = ({ activeType = 'quotation', typeList }) => { console.error(error); } }; + const handleAddUnit = async (unitName) => { + try { + const { error } = await supabase.from("resources").insert([ + { + type: "units", + attributes: { + name: unitName, + template_type: activeType, + }, + schema_version: 1, + }, + ]); + if (error) throw error; + message.success("新增单位成功"); + fetchUnits(); + return true; + } catch (error) { + message.error("新增单位失败"); + console.error(error); + return false; + } + }; + const handleValuesChange = (changedValues, allValues) => { + setFormValues(allValues); + }; const columns = [ { title: '模块名称', @@ -155,11 +193,10 @@ const SectionsManagement = ({ activeType = 'quotation', typeList }) => { > ) : ( - {text} + {text} ); }, }, @@ -168,61 +205,114 @@ const SectionsManagement = ({ activeType = 'quotation', typeList }) => { dataIndex: ['attributes', 'items'], render: (items, record) => { const isEditing = record.id === editingKey; - if (isEditing) { return ( {(fields, { add, remove }) => (
- {fields.map((field, index) => ( - -
- - - - - - - - { + const items = formValues.items || []; + const currentItem = items[field.name] || {}; + const subtotal = (currentItem.quantity || 0) * (currentItem.price || 0); + + return ( + +
+ + + + +