diff --git a/src/views/products/Detail.jsx b/src/views/products/Detail.jsx index 997348a..64f072e 100644 --- a/src/views/products/Detail.jsx +++ b/src/views/products/Detail.jsx @@ -1217,7 +1217,7 @@ function Detail() { open={batchImportPriceVisible} onOk={handleBatchImportOK} onCancel={() => setBatchImportPriceVisible(false)} - width={620} + width={'90%'} > diff --git a/src/views/products/Detail/BatchImportPrice.jsx b/src/views/products/Detail/BatchImportPrice.jsx index 5f3dbcc..ab56f58 100644 --- a/src/views/products/Detail/BatchImportPrice.jsx +++ b/src/views/products/Detail/BatchImportPrice.jsx @@ -1,14 +1,70 @@ import { useState } from 'react'; -import { Button, Card, Checkbox, Col, Flex, DatePicker, Typography, Form, Input, Row, Select, Space } from 'antd'; +import { Button, Card, Checkbox, Table, Col, Flex, DatePicker, Typography, Form, Input, Row, Select, Space } from 'antd'; import dayjs from "dayjs"; -import { CloseOutlined } from '@ant-design/icons'; +import { useTranslation } from 'react-i18next'; +import { CloseOutlined, StarOutlined } from '@ant-design/icons'; import { useDatePresets } from '@/hooks/useDatePresets'; const { Option } = Select; const { RangePicker } = DatePicker; const BatchImportPrice = ({ onBatchImportData }) => { - const [priceForm] = Form.useForm(); - const presets = useDatePresets(); + const { t } = useTranslation() + + const previewTableColumns = [ + { title: t('products:adultPrice'), dataIndex: 'adult_cost', width: '10%' }, + { title: t('products:childrenPrice'), dataIndex: 'child_cost', width: '10%' }, + { title: t('products:currency'), dataIndex: 'currency', width: '10%' }, + { + title: t('products:Types'), + dataIndex: 'unit', + width: '10%', + editable: true, + render: (text) => (text === '0' ? '每人' : text === '1' ? '每团' : text), + }, + { + title: t('products:number'), + dataIndex: 'group_size', + width: '10%', + editable: true, + render: (_, record) => `${record.group_size_min}-${record.group_size_max}` + }, + { + title: t('products:validityPeriod'), + dataIndex: 'validityPeriod', + width: '20%', + editable: true, + render: (_, record) => dayjs(record.use_dates_start).format('YYYY-MM-DD') + '~' + dayjs(record.use_dates_end).format('YYYY-MM-DD') + }, + { title: t('products:Weekdays'), dataIndex: 'weekdays', width: '10%' }, + ] + + const [priceForm] = Form.useForm() + const [previewData, setPreviewData] = useState([]) + const presets = useDatePresets() + + const previewSetupPrice = () => { + let previewList = [] + const defList = priceForm.getFieldsValue().defList + + defList.forEach(definition => { + const previewPrice = definition?.priceList.map(price => { + return { + adult_cost: price.priceInput.audultPrice, + child_cost: price.priceInput.childrenPrice, + group_size_min: price.priceInput.numberStart, + group_size_max: price.priceInput.numberEnd, + + currency: definition.currency, + unit: definition.unitName, + use_dates_start: definition.useDate[0], + use_dates_end: definition.useDate[1], + weekdays: definition.weekend.join(','), + } + }) + previewList.push(...previewPrice) + }) + setPreviewData(previewList) + } const PriceInput = (props) => { const { id, value = {}, onChange } = props @@ -116,7 +172,7 @@ const BatchImportPrice = ({ onBatchImportData }) => { } const priceInitialValues = { - "items": [ + "defList": [ // 旺季 { "useDate": [ @@ -128,7 +184,7 @@ const BatchImportPrice = ({ onBatchImportData }) => { "5", "6" ], - "prieceList": [ + "priceList": [ { "priceInput": { "numberStart": 1, @@ -170,13 +226,11 @@ const BatchImportPrice = ({ onBatchImportData }) => { ], "unitName": "每人", "currency": "CNY", - "weekend": [ "5", "6" ], - - "prieceList": [ + "priceList": [ { "priceInput": { "numberStart": 1, @@ -216,7 +270,7 @@ const BatchImportPrice = ({ onBatchImportData }) => { return ( - +
{ autoComplete="off" initialValues={priceInitialValues} > - + {(fields, { add, remove }) => ( {fields.map((field, index) => ( @@ -259,15 +313,15 @@ const BatchImportPrice = ({ onBatchImportData }) => { /> - - {(prieceFieldList, priceOptList) => ( + + {(priceFieldList, priceOptList) => ( - {prieceFieldList.map((priceField) => ( + {priceFieldList.map((priceField, index) => ( - priceOptList.remove(priceField.name)} /> + {index==0?: priceOptList.remove(priceField.name)} />} ))} + + ); };