+
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 (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
}
+ onClick={() => remove(field.name)}
+ className="flex items-center justify-center"
/>
-
-
-
-
-
}
- onClick={() => remove(field.name)}
- className="flex items-center justify-center"
- />
-
-
- ))}
+
+
+ 小计: NT${subtotal.toLocaleString()}
+
+
+ );
+ })}