diff --git a/src/views/products/Detail/BatchImportPrice.jsx b/src/views/products/Detail/BatchImportPrice.jsx
index 3b7bdaa..535d811 100644
--- a/src/views/products/Detail/BatchImportPrice.jsx
+++ b/src/views/products/Detail/BatchImportPrice.jsx
@@ -288,14 +288,7 @@ const BatchImportPrice = ({ onBatchImportData }) => {
"6"
],
"priceList": [
- {
- "priceInput": {
- "numberStart": 1,
- "numberEnd": 2,
- "audultPrice": 0,
- "childrenPrice": 0
- }
- },
+ // defaultPriceValue
]
}
diff --git a/src/views/products/Detail/ProductInfoForm.jsx b/src/views/products/Detail/ProductInfoForm.jsx
index ccb96e5..3c79acd 100644
--- a/src/views/products/Detail/ProductInfoForm.jsx
+++ b/src/views/products/Detail/ProductInfoForm.jsx
@@ -89,7 +89,6 @@ const InfoForm = ({ formInstance, onSubmit, onReset, onValuesChange, editable, s
{/* */}
-
@@ -104,6 +103,7 @@ const InfoForm = ({ formInstance, onSubmit, onReset, onValuesChange, editable, s
)}
+
>
);
};
diff --git a/src/views/products/Detail/ProductInfoQuotation.jsx b/src/views/products/Detail/ProductInfoQuotation.jsx
index 7e9364a..235310d 100644
--- a/src/views/products/Detail/ProductInfoQuotation.jsx
+++ b/src/views/products/Detail/ProductInfoQuotation.jsx
@@ -1,130 +1,130 @@
-import { createContext, useEffect, useState } from 'react';
-import { Table, Form, Modal, Button, InputNumber, Select, DatePicker, Popconfirm } from 'antd';
-import { useTranslation } from 'react-i18next';
-import dayjs from 'dayjs';
-import BatchImportPrice from './BatchImportPrice';
-import { useDatePresets, useWeekdays } from '@/hooks/useDatePresets';
+import { useState } from 'react'
+import { Table, Form, Modal, Button, Radio, Input, InputNumber, Checkbox, DatePicker, Space } from 'antd'
+import { useTranslation } from 'react-i18next'
+import dayjs from 'dayjs'
+import BatchImportPrice from './BatchImportPrice'
+import { useDatePresets } from '@/hooks/useDatePresets'
+import useProductsStore from '@/stores/Products/Index'
+
+const { RangePicker } = DatePicker
+
+const ProductInfoQuotation = ({ editable, ...props }) => {
+
+ const { t } = useTranslation()
+
+ const [isQuotationModalOpen, setQuotationModalOpen] = useState(false)
+ const [quotationForm] = Form.useForm()
+
+ const datePresets = useDatePresets()
+
+ const [editingProduct] = useProductsStore((state) => [state.editingProduct])
+ const [batchImportPriceVisible, setBatchImportPriceVisible] = useState(false)
+ const [quotationTableVisible, setQuotationTableVisible] = useState(false)
+ const [quotation, setQuotation] = useState([])
+ const [batchImportData, setBatchImportData] = useState([])
+
-const { RangePicker } = DatePicker;
-const ProductInfoQuotation = ({ editable, formInstance, ...props }) => {
- const { t } = useTranslation();
- const presets = useDatePresets();
- const weekdaySets = useWeekdays();
- const [batchImportPriceVisible, setBatchImportPriceVisible] = useState(false);
- const [quotationTableVisible, setQuotationTableVisible] = useState(false);
- const [editIndex, setEditIndex] = useState(null);
- const [quotation, setQuotation] = useState([]);
- const [batchImportData, setBatchImportData] = useState([]);
- const [weekdays, setWeekdays] = useState([]);
- const [selectedDays, setSelectedDays] = useState([]);
- const [currentQuotationRecord, setCurrentQuotationRecord] = useState({
- use_dates_start: null,
- use_dates_end: null,
- });
- const edit = (record, index) => {
- setQuotationTableVisible(true);
- setEditIndex(index);
- setCurrentQuotationRecord(record);
- };
- const handleAdd = () => {
- const newData = {
- adult_cost: 0,
- child_cost: 0,
- currency: '',
- group_size_min: 0,
- group_size_max: 0,
- id: '',
- lastedit_changed: '',
- use_dates_start: '',
- use_dates_end: '',
- weekdays: '',
- tempKey: Math.random(),
- };
- setQuotation([...quotation, newData]);
- const index = [...quotation, newData].length - 1;
- edit(newData, index);
- };
const handleBatchImportData = (data) => {
- setBatchImportData(data);
- };
+ setBatchImportData(data)
+ }
- const handleBatchImport = () => {
- setBatchImportPriceVisible(true);
- };
const handleBatchImportOK = () => {
const tempBatchImportData = batchImportData.map((item) => {
- const { tag, validPeriod, ...rest } = item;
- return rest;
- });
- const newData = [...quotation, ...tempBatchImportData];
+ const { tag, validPeriod, ...rest } = item
+ return rest
+ })
+ const newData = [...quotation, ...tempBatchImportData]
const sortedData = [...newData].sort((a, b) => {
if (a.group_size_min !== b.group_size_min) {
- return a.group_size_min - b.group_size_min;
+ return a.group_size_min - b.group_size_min
}
- return a.group_size_max - b.group_size_max;
- });
+ return a.group_size_max - b.group_size_max
+ })
- setQuotation(sortedData);
- setBatchImportPriceVisible(false);
- };
+ setQuotation(sortedData)
+ setBatchImportPriceVisible(false)
+ }
const quotationTableVisibleOK = () => {
- currentQuotationRecord.use_dates_start = dayjs(currentQuotationRecord.use_dates_start).format('YYYY-MM-DD');
- currentQuotationRecord.use_dates_end = dayjs(currentQuotationRecord.use_dates_end).format('YYYY-MM-DD');
- const tempQuotation = [...quotation];
- tempQuotation[editIndex] = { ...currentQuotationRecord, weekdays: weekdays };
+ const tempQuotation = [...quotation]
+
const sortedData = [...tempQuotation].sort((a, b) => {
- const aValidPeriod = dayjs(a.use_dates_end).diff(dayjs(a.use_dates_start));
- const bValidPeriod = dayjs(b.use_dates_end).diff(dayjs(b.use_dates_start));
+ const aValidPeriod = dayjs(a.use_dates_end).diff(dayjs(a.use_dates_start))
+ const bValidPeriod = dayjs(b.use_dates_end).diff(dayjs(b.use_dates_start))
if (aValidPeriod !== bValidPeriod) {
- return aValidPeriod - bValidPeriod;
+ return aValidPeriod - bValidPeriod
}
- const aGroupSize = a.group_size_max - a.group_size_min;
- const bGroupSize = b.group_size_max - b.group_size_min;
+ const aGroupSize = a.group_size_max - a.group_size_min
+ const bGroupSize = b.group_size_max - b.group_size_min
- return aGroupSize - bGroupSize;
- });
- setQuotation(sortedData);
- setQuotationTableVisible(false);
- };
+ return aGroupSize - bGroupSize
+ })
+ setQuotation(sortedData)
+ setQuotationTableVisible(false)
+ }
const quotationTableVisibleCancel = () => {
- setQuotationTableVisible(false);
- };
- const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
- const handleDayClick = (dayOfWeek) => {
-
- setSelectedDays((prevSelectedDays) => {
- const updatedDays = prevSelectedDays.includes(dayOfWeek) ? prevSelectedDays.filter((d) => d !== dayOfWeek) : [...prevSelectedDays, dayOfWeek];
- const weekdaysString = updatedDays.sort().join(',');
- setWeekdays(weekdaysString);
- return updatedDays;
- });
- };
+ setQuotationTableVisible(false)
+ }
const handleDelete = (index) => {
- const newData = [...quotation];
- newData.splice(index, 1);
+ const newData = [...quotation]
+ newData.splice(index, 1)
const sortedData = [...newData].sort((a, b) => {
- const aValidPeriod = dayjs(a.use_dates_end).diff(dayjs(a.use_dates_start));
- const bValidPeriod = dayjs(b.use_dates_end).diff(dayjs(b.use_dates_start));
+ const aValidPeriod = dayjs(a.use_dates_end).diff(dayjs(a.use_dates_start))
+ const bValidPeriod = dayjs(b.use_dates_end).diff(dayjs(b.use_dates_start))
if (aValidPeriod !== bValidPeriod) {
- return aValidPeriod - bValidPeriod;
+ return aValidPeriod - bValidPeriod
}
- const aGroupSize = a.group_size_max - a.group_size_min;
- const bGroupSize = b.group_size_max - b.group_size_min;
+ const aGroupSize = a.group_size_max - a.group_size_min
+ const bGroupSize = b.group_size_max - b.group_size_min
+
+ return aGroupSize - bGroupSize
+ })
+ setQuotation(sortedData)
+ }
+
+ const onQuotationSeleted = async (quotation) => {
+ // 转换为 RangePicker 赋值格式
+ quotation.use_dates = [dayjs(quotation.use_dates_start), dayjs(quotation.use_dates_end)]
+ quotationForm.setFieldsValue(quotation)
+ setQuotationModalOpen(true)
+ }
+
+ const onNewQuotation = () => {
+ // const emptyQuotation = newEmptyQuotation()
+ // quotationForm.setFieldsValue(emptyQuotation)
+ // setQuotationModalOpen(true)
+ }
- return aGroupSize - bGroupSize;
- });
- setQuotation(sortedData);
- };
- const columns = [
+ const onQuotationFinish = (values) => {
+ console.info(values)
+ // saveOrUpdateQuotation(values)
+ // .then(() => {
+ // setQuotationModalOpen(false)
+ // })
+ // .catch(ex => {
+ // notification.error({
+ // message: 'Notification',
+ // description: ex.message,
+ // placement: 'top',
+ // duration: 4,
+ // })
+ // })
+ }
+
+ const onQuotationFailed = (error) => {
+ console.log('Failed:', error)
+ // form.resetFields()
+ }
+
+ const quotationColumns = [
{ title: t('products:adultPrice'), dataIndex: 'adult_cost', width: '4rem' },
{ title: t('products:childrenPrice'), dataIndex: 'child_cost', width: '4rem' },
{ title: t('products:currency'), dataIndex: 'currency', width: '4rem' },
{
title: t('products:Types'),
- dataIndex: 'unit',
+ dataIndex: 'unit_name',
width: '4rem',
render: (text) => (text === '0' ? '每人' : text === '1' ? '每团' : text),
},
@@ -137,129 +137,180 @@ const ProductInfoQuotation = ({ editable, formInstance, ...props }) => {
{
title: t('products:validityPeriod'),
- dataIndex: 'validityPeriod',
+ dataIndex: 'use_dates',
width: '6rem',
render: (_, record) => `${record.use_dates_start}-${record.use_dates_end}`,
},
{ title: t('products:Weekdays'), dataIndex: 'weekdays', width: '4rem' },
- ...(editable
- ? [
- {
- title: t('products:operation'),
- dataIndex: 'operation',
- width: '6rem',
- render: (_, record, index) => {
- const canEdit = true; // record.audit_state_id === -1; // todo:
- return (
-
- {canEdit ? (
- edit(record, index)} style={{ marginRight: 8 }}>
- {t('Edit')}
-
- ) : (
- {t('Edit')}
- )}
- {canEdit ? (
- handleDelete(index)}>
- {t('Delete')}
-
- ) : (
- {t('Delete')}
- )}
-
- );
- },
- },
- ]
- : []),
- ];
+ {
+ title: t('products:operation'),
+ dataIndex: 'operation',
+ width: '3%',
+ render: (_, quotation) => {
+ return (
+
+
+
+
+ )
+ },
+ },
+ ]
+
return (
<>
{t('products:EditComponents.Quotation')}
-
-
- {
- editable &&
-
- }
+
+ {
+ // editable &&
+
+ }
- {
- editable &&
-
- }
-
+ {
+ // editable &&
+
+ }
setBatchImportPriceVisible(false)} width={'90%'}>
-
- 成人价
- setCurrentQuotationRecord({ ...currentQuotationRecord, adult_cost: e })} />
- 儿童价
- setCurrentQuotationRecord({ ...currentQuotationRecord, child_cost: e })} />
- 币种
-
- 类型
-
-
- 人等
-
- setCurrentQuotationRecord({ ...currentQuotationRecord, group_size_min: e })}
- style={{ width: '50%', marginRight: '10px' }}
- />
- -
- setCurrentQuotationRecord({ ...currentQuotationRecord, group_size_max: e })}
- style={{ width: '50%', marginLeft: '10px' }}
- />
- |
- 有效期
- {
- setCurrentQuotationRecord({
- ...currentQuotationRecord,
- use_dates_start: dates[0],
- use_dates_end: dates[1],
- });
- }}
- />
- 周末
- {weekdaySets.map((day, index) => (
-
- ))}
+ setQuotationModalOpen(false)}
+ destroyOnClose
+ forceRender
+ modalRender={(dom) => (
+
+ )}
+ >
+
+
+
+
+
+
+
+
+
+ RMB
+ USD
+
+
+
+
+ 每人
+ 每团
+
+
+
+
+
+
+
+
+
+
+
+
+
+
>
- );
-};
-export default ProductInfoQuotation;
+ )
+}
+
+export default ProductInfoQuotation