|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
|
import { Table, Form, Modal, Button, Radio, Input, Flex, Card, Select, Typography, InputNumber, Checkbox, DatePicker, Space } from 'antd'
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
import { CloseOutlined, StarTwoTone, PlusOutlined, ExclamationCircleFilled } from '@ant-design/icons';
|
|
|
|
|
import { useDatePresets } from '@/hooks/useDatePresets'
|
|
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
import useProductsStore from '@/stores/Products/Index'
|
|
|
|
|
|
|
|
|
|
const { RangePicker } = DatePicker
|
|
|
|
@ -245,8 +245,8 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
|
|
|
|
|
|
const datePresets = useDatePresets()
|
|
|
|
|
|
|
|
|
|
const [newEmptyQuotation, appendQuotationList, quotationList] =
|
|
|
|
|
useProductsStore((state) => [state.newEmptyQuotation, state.appendQuotationList, state.quotationList])
|
|
|
|
|
const [newEmptyQuotation, appendQuotationList, quotationList, saveOrUpdateQuotation] =
|
|
|
|
|
useProductsStore((state) => [state.newEmptyQuotation, state.appendQuotationList, state.quotationList, state.saveOrUpdateQuotation])
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
console.info('quotationList: ', quotationList)
|
|
|
|
@ -266,9 +266,8 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onQuotationFinish = (values) => {
|
|
|
|
|
console.info(values)
|
|
|
|
|
saveOrUpdateQuotation(values)
|
|
|
|
|
setQuotationModalOpen(false)
|
|
|
|
|
// saveOrUpdateQuotation(values)
|
|
|
|
|
// .then(() => {
|
|
|
|
|
// setQuotationModalOpen(false)
|
|
|
|
|
// })
|
|
|
|
@ -282,20 +281,14 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onQuotationFailed = (error) => {
|
|
|
|
|
console.log('Failed:', error)
|
|
|
|
|
// form.resetFields()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const onBatchSetupFinish = () => {
|
|
|
|
|
console.info(batchSetupForm.getFieldsValue())
|
|
|
|
|
let previewList = []
|
|
|
|
|
let priceList = []
|
|
|
|
|
const defList = batchSetupForm.getFieldsValue().defList
|
|
|
|
|
|
|
|
|
|
defList.forEach(definition => {
|
|
|
|
|
const previewPrice = definition?.priceList.map(price => {
|
|
|
|
|
const mappedPriceList = definition?.priceList.map(price => {
|
|
|
|
|
return {
|
|
|
|
|
id: 0,
|
|
|
|
|
id: null,
|
|
|
|
|
adult_cost: price.priceInput.audultPrice,
|
|
|
|
|
child_cost: price.priceInput.childrenPrice,
|
|
|
|
|
group_size_min: price.priceInput.numberStart,
|
|
|
|
@ -309,10 +302,10 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
|
weekdays: definition.weekend.join(','),
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
previewList.push(...previewPrice)
|
|
|
|
|
priceList.push(...mappedPriceList)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
appendQuotationList(previewList)
|
|
|
|
|
appendQuotationList(priceList)
|
|
|
|
|
setBatchSetupModalOpen(false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -379,18 +372,16 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
|
pagination={false}
|
|
|
|
|
/>
|
|
|
|
|
{
|
|
|
|
|
// editable &&
|
|
|
|
|
<Button onClick={() => onNewQuotation()} type='primary' ghost style={{ marginTop: 16 }}>
|
|
|
|
|
{t('products:addQuotation')}
|
|
|
|
|
</Button>
|
|
|
|
|
editable &&
|
|
|
|
|
<Space>
|
|
|
|
|
<Button onClick={() => onNewQuotation()} type='primary' ghost style={{ marginTop: 16 }}>
|
|
|
|
|
{t('products:addQuotation')}
|
|
|
|
|
</Button>
|
|
|
|
|
<Button onClick={() => setBatchSetupModalOpen(true)} type='primary' ghost style={{ marginTop: 16, marginLeft: 16 }}>
|
|
|
|
|
批量设置
|
|
|
|
|
</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
// editable &&
|
|
|
|
|
<Button onClick={() => setBatchSetupModalOpen(true)} type='primary' ghost style={{ marginTop: 16, marginLeft: 16 }}>
|
|
|
|
|
批量设置
|
|
|
|
|
</Button>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
|
centered
|
|
|
|
|
title='批量设置价格'
|
|
|
|
@ -496,7 +487,6 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
|
|
|
|
|
wrapperCol={{ span: 20 }}
|
|
|
|
|
className='max-w-2xl'
|
|
|
|
|
onFinish={onQuotationFinish}
|
|
|
|
|
onFinishFailed={onQuotationFailed}
|
|
|
|
|
autoComplete='off'
|
|
|
|
|
>
|
|
|
|
|
{dom}
|
|
|
|
|